text
stringlengths
28
935k
meta
stringlengths
137
139
red_pajama_subset
stringclasses
1 value
\section{Introduction} Topological data analysis (TDA) via persistent homology provides an efficient way of analyzing the cycle or loop structures embedded in multi-dimensional data. Particularly the one-dimensional homology structure is closely related to the repeating patterns in music flow when it mapped to the proper topological space. We consider, in this research, three famous Korean old music pieces, namely {\color{black}{{\it Suyeonjangjigok} (Suyeonjang hereafter), {\it Songkuyeojigok} (Songkuyeo hereafter)}}, and {\it Taryong} and study their cycle structures when represented in a music network — the cycle structures are the key element that characterizes these music pieces. They are categorized as “Jeong-Ak” meaning the ‘Right Music’ mostly played at the palace and among noble community and were written in Jeongganbo, a unique music representation invented by Sejong the Great of Joseon dynasty. Contrary to the western music notation, the pitch of each note is encrypted and the length is visualized directly in a matrix form of Jeongganbo. As {\color{black}{the music}} is written in Jeongganbo, it sometimes provides a special musical pattern according to the Jeongganbo's matrix form. In this paper, we study the cycle structures and how those cycles are interconnected over the music flows of {\it Suyeonjang} and {\it Songkuyeo} and compare them with those of {\it Taryong}. According to the earliest literature in 1451 (Korea-sa-ak-ji (高麗史樂志) volumes 70 \& 71) the primitive form of {\it Suyeonjang} and {\it Songkuyeo} appeared before the Joseon dynasty (1392$\sim$1897) in Korea. Suyeonjang is {\color{black}{originally a Chinese feast dance}} played at the palace wishing the king's longevity. {\color{black}{It has later evolved throughout Joseon dynasty to an orchestral ensemble with variations, and became one of the most representative Korean Jeong-Ak musics}}. Songkuyeo is the music composed in a similar pattern as Suyeonjang but with one octave higher. Suyeonjang and Songkuyeo have their unique music structure known as {\color{black}{“Dodeuri”}}, which means repeat-and-return. As Songkuyeo is composed with one octave higher, it is also called as “{\color{black}{Wut-Dodeuri}}” (Upper {\color{black}{Dodeuri}}) as Suyeonjang referred as “Mit-{\color{black}{Dodeuri}}” (Lower {\color{black}{Dodeuri}}). The {\color{black}{"Dodeuri"}} is a unique music structure. Its simplest pattern has a form of A-B-C-B where the second pattern C-B is the variation of the first pattern of A-B while the second part B of each pattern is repeated in both patterns. While this {\color{black}{"Dodeuri"}} music is old and has been studied for long, research is rare that studies how to define repeating cycles, how these repeating cycles are interconnected over the music flow, and what characteristics of the {\color{black}{"Dodeuri"}} patterns make both Suyeonjang and Songkuyeo unique in Jeong-Ak. In this study, we use the notion of persistent homology to define cycles embedded in Suyeonjang and Songkuyeo after we represent them as a music network. In order to construct the music network of these music pieces, we first define and determine the node elements, that constitute the music, characterized uniquely with its pitch and length. Then we transform the music into a graph and introduce a proper metric to define the distance between the notes using their adjacent occurrence rate. If two nodes appear, side-by-side, frequently we consider that those nodes are close. The graph with the metric is then used as a point cloud. For the analysis, we compute persistent homology of the constructed point cloud, especially for the one-dimensional homology. Through this research we identified cycles from each music as the cycles identified through persistent homology. Among those cycles found, some match the music, i.e. appear in the music in their found form, while some do not appear in the music directly. Then, by visualizing the distribution of those cycles in the music, we showed how those cycles are interconnected in the music. The main discovery of this work is that the cycles of Suyeonjang and Songuyeo, defined using homology, frequently overlap each other when appearing over the music while the cycles found in Taryong, which does not belong to {\it {\color{black}{Dodeuri}}} class, appear rather individually when they appear in the music. This gives an interesting musical effect that the listener feels he or she hears multiple cycles played simultaneously when they appear in the music. The outline of the paper is as follows. In Section \ref{sec:tda} we briefly explain TDA, particularly persistent homology, and how we associate our music data with TDA tools in order to study the cycle structure in the music. Section \ref{sec:jeongganbo} reviews basic characteristics of Korean musical notation Jeongganbo, in particular Suyeonjang, Songkuyeo and Taryong. In Section \ref{sec:construction} we construct music network from music data and define the distance matrix which will be used to generate barcode for each music by Javaplex \citep{ATVJ} with Vietoris-Rips method. Section \ref{sec:freq} provides the frequency of the occurrence of each node in music. It is observed that the frequency decays more exponentially than algebraically. Detailed analysis of the barcodes and comparison between Suyeonjang, Songkuyeo and Taryong is given in Section \ref{sec:analysis}. At the end of the paper we provide the list of all nodes of Suyeonjang, Songkuyeo and Taryong, according to our node definition, in Tables \ref{tab:syj_allnodes}, \ref{tab:songkuyeo_allnodes} and \ref{tab:taryong_allnodes} in Appendix. \section{Topological data analysis} \label{sec:tda} In this section we briefly explain TDA, particularly persistent homology. For more detailed explanation we refer to \citep{Carlsson}. The main motivation of using TDA is to study the cycle structure in music data. In this paper, we focus on the one-dimensional cycle, which is reflected as a repeated pattern in music. The two-dimensional cycle (or a two-dimensional void) would be also of interest, but its interpretation is uncertain at the moment. Below, we explain singular homology and then persistent homology. In the end, the cycle structure is visualized in the so-called barcode. The barcode is the key tool used in this paper. The point cloud used for TDA is constructed in Section \ref{sec:construction}. To begin with, we first explain a simplex. Let $\sigma_k$ be the oriented $k$-simplex. The $k$-simplex, $\sigma_k = [x_0, x_1, \cdots, x_k]$ is the convex hull of $k+1$ geometrically independent points (or vertices), $\{x_0, x_1, \cdots, x_k \} \subset R^n$, $k \le n$. Roughly speaking $\sigma_n$ is an $n$ dimensional triangle. For example, $\sigma_0$ is a point or vertex, $\sigma_1$ an edge, $\sigma_2$ a triangle and $\sigma_3$ a tetrahedron. A higher dimensional simplex is the higher dimensional equivalent to a triangle. In this paper, the independent point is replaced with the node in a music network in the following section. In the following, 0-simplex (vertex), 1-simplex (edge) and 2-simplex (triangle) are shown from left to right, respectively. Here note that the inside of triangle (n-dimensional triangle) is filled. \begin{center} \begin{tikzpicture} \filldraw[color=blue!99, fill=blue!99, very thick](-1,0) circle (0.2); \filldraw[color=blue!99, fill=blue!99, very thick](1,0) circle (0.2); \filldraw[color=blue!99, fill=blue!99, very thick](3,0) circle (0.2); \draw [color = blue!99] (1,0) -- (3,0); \path[draw, fill=green!20] (5,0)--(6,1.6)--(7,0)--cycle; \filldraw[color=blue!99, fill=blue!99, very thick](5,0) circle (0.2); \filldraw[color=blue!99, fill=blue!99, very thick](6,1.6) circle (0.2); \filldraw[color=blue!99, fill=blue!99, very thick](7,0) circle (0.2); \draw [color = blue!99] (5,0) -- (6,1.6); \draw [color = blue!99] (6,1.6) -- (7,0); \draw [color = blue!99] (7,0) -- (5,0); \end{tikzpicture} \end{center} To explain singular homology, consider a ring $R$ and a topological space $X$, $(X,R)$. $R$ can be replaced with {\color{black}{$\mathbb{Q}$}}. In our case, the topological space $X$ is the music network constructed from the Jeongganbo music. Given $(X,R)$, let $C_n(X, R)$ be the free $R$-module generated by all possible continuous images of $\sigma_n$. Consider $\delta_n:$ $C_n \rightarrow C_{n-1}$, the boundary map defined as below $$ \delta_n\sigma_n = \sum_{k=0}^n (-1)^k[p_0,\dots, p_{k-1}, p_{k+1}, \dots, p_n] $$ where $\{p_i\}$ are the vertices, the music nodes in our case. Then it is easy to show that $\delta_{n} \circ \delta_{n+1} = 0$ for $\forall n = 0, 1, \cdots$. For $n = 0$, we choose $\delta_0$ as a trivial map. Using the relation of vanishing consecutive boundary maps, we consider two subgroups, the kernel and image groups, $ker(\delta_n):= Z_n$ and $im(\delta_{n+1}):= B_n$, respectively. The kernel group is also called the cycle group and the image group is also called the boundary group. Obviously $Z_n\subset C_n$ and $B_n \subset C_n$. Further, $B_n \subseteq Z_n$, i.e. every boundary group is a cycle group. Using $B_n \subseteq Z_n$, the $n$th homology group of $X$ with the coefficient $R$ is defined by the following quotient group $$ H_n(X, R) = Z_n/ B_n = ker(\delta_n)/im(\delta_{n+1}). $$ \textcolor{black}{For a detailed, rigorous description of homology we refer the reader to \citep{Hatcher, Munkres}}. Practically the $n$-dimensional homology group indicates how many $n$-dimensional {\it holes} are there in $X$. For example, for the sphere $H_0 = Z^1, H_1 = Z^0, H_2 = Z^1$ while for a torus $H_0 = Z^1, H_1 = Z^2, H_2 = Z^1$. The existence of holes and the number of holes are useful information that we will use in this research. Some useful theorems of using homology for the practical problem can be found in \citep{Bergomithesis, Cohen, EHarer}. It is, however, difficult to compute $H_n$ in general and we use the notion of simplicial complex out of the given data to understand the hole structures. Roughly speaking, with the simplicial complex, we approximate the original topological space $X$. Once the simplicial complex is constructed, we find its homology. \textcolor{black}{Related articles on using topological tools in music analysis are found in \citep{Bergomi, Bigo} and references therein}. The tuple composed of pitch and length in Jeongganbo is regarded as a node and all the nodes in the music constitutes a point cloud, which we will use to construct the simplicial complex. The simplicial complex is a topological space constructed by gluing a finite number of simplices. Since the exact topological space $X$ is unknown, we use its approximate topological space, i.e. the simplicial complex. In this research, for the simplicial complex, we consider the Vietoris-Rips complex. The basic procedure is as follows. From the given point cloud, we create one-simplices by connecting vertices resulting in edges, then create two-simplices by connecting edges and repeat this procedure for the construction of higher simplices. For the connecting condition, we rely on the notion of metric. That is, the topology is described as metric topology. For the metric, we need to introduce the proper metric. In many cases, Euclidean metric is used to measure the pair-wise distance between simplices. For our research, we will use a different definition of metric defined in the following section based on the occurrence of consecutive nodes in the music flow. The procedure of connecting simplices is conducted if the connecting condition is satisfied. For the connecting condition, let us introduce an auxiliary parameter, so-called the filtration parameter, $\tau$. If the distance between two simplices is less than the given value of the filtration parameter, $\tau$, those two simplices will be connected. Once such a simplicial complex is constructed, we compute homology group at a particular value of $d$. Then we {\it collect }all the homology group in the sequence of $\tau$. This provides the notion of persistent homology. We also use the $n$-dimensional Betti number, $\beta_n$. The $n$-dimensional Betti number is the number of generators of the $n$th homology group. That is, $\beta_n$ is the number of copies of $R$. When $n = 0$, $\beta_0$ simply means the total number of connected components. For example, for a torus, {\color{black}{$\beta_0 = 1$, $\beta_1 = 2$ and $\beta_2 = 1$}}. Once the simplicial complex is constructed from the Jeongganbo data, we will measure the Betti number in each dimension. One can compute the $n$th Betti number of the constructed simplicial complex at a particular value of $\tau$. The barcode is the collection of the Betti number with respect to the given value of $\tau$ in each dimension. For example, if $\tau= 0$, no two vertices are to be connected and the $0$th Betti number is the number of all connected components, which is simply the total number of vertices, nodes in our case. And $n$th Betti number will be zero for $n \ge 1$. For computational purpose and data analysis, one can plot $\beta_n$ versus $\tau$, known as barcode. There exists a certain interval of $\tau$ where the homology invariant in $n$ dimension. Then in barcode, such interval will be visualized as a persistent line, which we will call a {\it persistence}. The starting value of $\tau$ and the ending value of $\tau$ of such line are called the {\it birth} and {\it death}. The plot of the death versus birth is called the persistence diagram. For example, we consider the following simple data composed of four music nodes, each a vertex of a unit square. Then the minimum distance between two random nodes will be $1$ and the maximum distance will be $\sqrt{2}$, the diagonal distance between the orange and red nodes or the green and blue nodes. \begin{center} \begin{tikzpicture} \filldraw[color=blue!99, fill=blue!99, very thick](1,0) circle (0.2); \filldraw[color=orange!99, fill=orange!99, very thick](2,0) circle (0.2); \filldraw[color=teal!60, fill=teal!60, very thick](2,1) circle (0.2); \filldraw[color=red!30, fill=red!30, very thick](1,1) circle (0.2); \end{tikzpicture} \end{center} Now using various values of $\tau\ge 0$, let us connect nodes. Here note that if a triangle is formed as a result, the triangle should be filled. The following shows how these four nodes are connected with different value of $\tau = 0, 0.5, 1, \sqrt{2}, 2$. The Betti numbers $\beta_0$ and $\beta_1$ are also provided for the give $\tau$. For example, when $\tau_1 = 1$, all the nodes are connected, so there is just one connected component, that is, $\beta_0 = 1$. As shown in the figure, the connected nodes also form one hole, a square. This $\beta_1 = 1$. But when $\tau = \sqrt{2}$, the square becomes two triangles as the blue and green nodes are connected with $\tau = \sqrt{2}$ and the hole disappear as those two triangles are filled inside. Note that it is also possible to connect the red and orange nodes instead of connecting the blue and green nodes. But once one of them is established, the other one can not be established because the non-empty intersection of any two simplices is a simplex. \begin{center} \begin{tikzpicture} \filldraw[color=blue!99, fill=blue!99, very thick](1,0) circle (0.2); \filldraw[color=orange!99, fill=orange!99, very thick](2,0) circle (0.2); \filldraw[color=teal!60, fill=teal!60, very thick](2,1) circle (0.2); \filldraw[color=red!30, fill=red!30, very thick](1,1) circle (0.2); \node at (1.5, -1) (nodeXi) {{\bf $\tau = 0$}}; \node at (1.5, -2) (nodeXi) {$\beta_0 = 4$}; \node at (1.5, -2.5) (nodeXi) {$\beta_1 = 0$}; \filldraw[color=blue!99, fill=blue!99, very thick](4,0) circle (0.2); \filldraw[color=orange!99, fill=orange!99, very thick](5,0) circle (0.2); \filldraw[color=teal!60, fill=teal!60, very thick](5,1) circle (0.2); \filldraw[color=red!30, fill=red!30, very thick](4,1) circle (0.2); \node at (4.5, -1) (nodeXi) {$\tau = 0.5$}; \node at (4.5, -2) (nodeXi) {$\beta_0 = 4$}; \node at (4.5, -2.5) (nodeXi) {$\beta_1 = 0$}; \draw [color = blue!99] (7,0) -- (8,0); \draw [color = blue!99] (7,0) -- (7,1); \draw [color = blue!99] (7,1) -- (8,1); \draw [color = blue!99] (8,1) -- (8,0); \filldraw[color=blue!99, fill=blue!99, very thick](7,0) circle (0.2); \filldraw[color=orange!99, fill=orange!99, very thick](8,0) circle (0.2); \filldraw[color=teal!60, fill=teal!60, very thick](8,1) circle (0.2); \filldraw[color=red!30, fill=red!30, very thick](7,1) circle (0.2); \node at (7.5, -1) (nodeXi) {$\tau = 1$}; \node at (7.5, -2) (nodeXi) {$\beta_0 = 1$}; \node at (7.5, -2.5) (nodeXi) {$\beta_1 = 1$}; \draw [color = blue!99] (10,0) -- (11,0); \draw [color = blue!99] (10,0) -- (10,1); \draw [color = blue!99] (10,1) -- (11,1); \draw [color = blue!99] (11,1) -- (11,0); \draw [color = blue!99] (10,0) -- (11,1); \path[draw, fill=green!20] (10,0)--(10,1)--(11,1)--cycle; \path[draw, fill=red!20] (10,0)--(11,0)--(11,1)--cycle; \filldraw[color=blue!99, fill=blue!99, very thick](10,0) circle (0.2); \filldraw[color=orange!99, fill=orange!99, very thick](11,0) circle (0.2); \filldraw[color=teal!60, fill=teal!60, very thick](11,1) circle (0.2); \filldraw[color=red!30, fill=red!30, very thick](10,1) circle (0.2); \node at (10.5, -1) (nodeXi) {$\tau = \sqrt{2}$}; \node at (10.5, -2) (nodeXi) {$\beta_0 = 1$}; \node at (10.5, -2.5) (nodeXi) {$\beta_1 = 0$}; \draw [color = blue!99] (13,0) -- (14,0); \draw [color = blue!99] (13,0) -- (13,1); \draw [color = blue!99] (13,1) -- (14,1); \draw [color = blue!99] (14,1) -- (14,0); \draw [color = blue!99] (13,0) -- (14,1); \path[draw, fill=green!20] (13,0)--(13,1)--(14,1)--cycle; \path[draw, fill=red!20] (13,0)--(14,0)--(14,1)--cycle; \filldraw[color=blue!99, fill=blue!99, very thick](13,0) circle (0.2); \filldraw[color=orange!99, fill=orange!99, very thick](14,0) circle (0.2); \filldraw[color=teal!60, fill=teal!60, very thick](14,1) circle (0.2); \filldraw[color=red!30, fill=red!30, very thick](13,1) circle (0.2); \node at (13.5, -1) (nodeXi) {$\tau = 2$}; \node at (13.5, -2) (nodeXi) {$\beta_0 = 1$}; \node at (13.5, -2.5) (nodeXi) {$\beta_1 = 0$}; \end{tikzpicture} \end{center} For the above example we used only $5$ values of $\tau$. If we use multiple values of $\tau$ as many as we want and plot $\beta_0$ and $\beta_1$ versus $\tau$, the following barcodes are obtained. We plot the points at each $\tau$ as many as the given Betti number in the vertical axis. \begin{center} \begin{tikzpicture} \draw [color = black!99] (1,0) -- (7,0); \draw [color = black!99] (1,0) -- (1,5); \draw [color = black!99, line width=3mm] (1,1) -- (3,1); \draw [color = black!99, line width=3mm] (1,2) -- (3,2); \draw [color = black!99, line width=3mm] (1,3) -- (3,3); \draw [color = black!99, line width=3mm] (1,4) -- (7,4); \draw [color = black!99] (3,-0.1) -- (3,0.1); \node at (3,-0.5) (nodeXi) {$\tau = 1$}; \node at (2,-1) (nodeXi) {$\mbox{Barcode for } H_0 $}; \node at (0.5,1) (nodeXi) {$1$}; \node at (0.5,2) (nodeXi) {$2$}; \node at (0.5,3) (nodeXi) {$3$}; \node at (0.5,4) (nodeXi) {$4$}; \draw [color = black!99] (9,0) -- (15,0); \draw [color = black!99] (9,0) -- (9,5); \draw [color = black!99] (11,-0.1) -- (11,0.1); \node at (10.5,-0.5) (nodeXi) {$\tau = $}; \node at (11,-0.5) (nodeXi) {$1$}; \draw [color = black!99, line width=3mm] (11,1) -- (11.9,1); \draw [color = black!99] (11.9,-0.1) -- (11.9,0.1); \node at (11.9,-0.5) (nodeXi) {$\sqrt{2}$}; \node at (8.5,1) (nodeXi) {$1$}; \node at (10,-1) (nodeXi) {$\mbox{Barcode for } H_1$}; \end{tikzpicture} \end{center} For later use, we define the persistence $\Pi^n_i$ denoting the length of $i$th barcode in $n$th dimension. For example, for the above example, $$ \Pi^0_1 = \Pi^0_2 = \Pi^0_3 = 1, $$ and $$ \Pi^1_1 = \sqrt{2} - 1. $$ As $\tau \rightarrow \infty$, there remains only one connected component implying $\Pi^0_4 \rightarrow \infty$. \section{Korean musical notation Jeongganbo} \label{sec:jeongganbo} Jeongganbo was created some time before June of 1447 by Sejong the Great of Joseon dynasty and many musicians in order to overcome the limitations of existing musical notations including Yukbo, Yuljabo and Gongcheokbo \citep{HKY}. It is the first notation method which shows the exact length and height of the sound to be played. In Jeongganbo, each column is usually composed of 32, 16, 12 or 6 squares called Jeonggan (井間). The pitches are displayed by the first letters of each of the 12 Yulmyeong (Hwang, Dae, Tae, Hyeop, Go, Jung, Yu, Im, I, Nam, Mu and Eung) and the length of each note is displayed by the number of Jeonggans. Typically one Jeonggan represents the equivalent of one quarter note \citep{PG}. So, as shown in \figref{fig:1jeonggan} for example, if only one Hwang is placed in one Jeonggan, it counts as one beat; and if Hwang and Tae are both in one Jeonggan {\color{black}{and occupy equal amount of space}}, this divides the rhythm into eighth notes and so on. Within each Jeonggan, the notes are read from left to right and from top to bottom. The rule of reading the length of a pitch in Jeongganbo is illustrated in \figref{fig:pitchlength}. \begin{figure}[!h]\centering \includegraphics[scale=0.6]{1jeonggan.png} \caption{Reading pitches in one Jeonggan.} \label{fig:1jeonggan} \end{figure} \begin{figure}[!h] \centering \includegraphics[scale=0.6]{pitchlength.png} \caption{Reading the length of a pitch in Jeongganbo.} \label{fig:pitchlength} \end{figure} \textcolor{black}{In this paper we study in particular three music pieces Suyeonjang, Songkuyeo and Taryong, mentioned earlier, played by Haegeum instrument. In Suyeonjang and Songkuyeo each column contains 6 Jeonggans, while in Taryong each column contains 12 Jeonggans. In these music pieces five notes including Jung ($G\#3$), Im ($A\#3$), Nam ($C4$), Hwang ($D\#4$) and Tae ($F4$) are used, where Jung ($G\#3$) can be played two octaves higher and the remaining four notes can be played one octave higher, making a total of eleven pitches, that are $G\#3$, $A\#3$, $C4$, $D\#4$, $F4$, $G\#4$, $A\#4$, $C5$, $D\#5$, $F5$ and $G\#5$, as shown in \figref{fig:11pitches}. The lengths of notes range from 1/6-Jeonggan to 6-Jeonggan. } \begin{figure}[!h]\centering \includegraphics[scale=0.55]{11pitches.png} \caption{Eleven pitches used in Suyeonjang, Songkuyeo and Taryong.} \label{fig:11pitches} \end{figure} \textcolor{black}{Beside the main letters that show the notes to be played Jeongganbo, in particular Suyeonjang, Songkuyeo and Taryong, various musical symbols are used to notate pitch and length of the note or provide information about how to play the note. For the sake of simplicity but still keeping the main characteristics of the music pieces we have left out \textit{kkumim-eums} (ornamenting tones) and instrument-specific, i.e. Haegeum in our case, notations which give the performer information about special playing techniques such as how to control the bow stick and horsehair. {\color{black}{Development of diverse kkumim-eums is one of the main characteristics of Korean traditional music. Detailed analysis of the effects of kkumim-eums should be made in the future studies}}. Figure \ref{fig:abbr} illustrates the musical symbols used in Suyeonjang, Songkuyeo and Taryong that we interpret. The symbol \includegraphics[height=0.7\fontcharht\font`\B]{an.png} notates one note higher than the previous note, meaning that for example if it appears after note Hwang, then the symbol \includegraphics[height=0.7\fontcharht\font`\B]{an.png} stands for note Tae which is one pitch higher than Hwang. The length of this note is read according to the rule of reading the length of a pitch in Figure \ref{fig:pitchlength}. Symbol \includegraphics[height=\fontcharht\font`\B]{ah.png} represents two notes, one is one pitch lower than the main note and the other is two pitches lower than the main note. So, if \includegraphics[height=\fontcharht\font`\B]{ah.png} is placed after note Jung, then two notes Tae and Hwang with equal length should be played. Symbol \includegraphics[height=\fontcharht\font`\B]{at.png} stands for the note that is two pitches higher than the previous note. So if the symbol \includegraphics[height=\fontcharht\font`\B]{at.png} appears after note Jung then it is supposed to be note Nam. Symbol \includegraphics[height=\fontcharht\font`\B]{az.png} simply stands for a repetition of the previous note. The last symbol \includegraphics[height=\fontcharht\font`\B]{ai.png} so-called Ingeojil represents a short higher note. So if it appears after note Im then Im is played quite longer followed by a short note Nam before proceeding to the next note. } \begin{figure}[!h] \centering \includegraphics[scale=0.6]{abbreviations.png} \caption{Reading musical symbols used in Suyeonjang, Songkuyeo and Taryong.} \label{fig:abbr} \end{figure} \section{Construction of music network} \label{sec:construction} \textcolor{black}{A conventional approach of studying music is to use the network representation \citep{BW, Gomez, Itz, Liu}}. Let $G = (N, E)$ be the music network that we want to construct, where $N$ is the set of nodes and $E$ is the set of edges in $G$. We define each node, $n \in N$ in $G$ to be a pair of a pitch and its length as a tuple below \begin{equation} n = (\mbox{pitch}, \mbox{length}). \end{equation} As mentioned in the previous section, Suyeonjang, \textcolor{black}{Songkuyeo and Taryong consist of eleven pitches including $G\#3$, $A\#3$, $C4$, $D\#4$, $F4$, $G\#4$, $A\#4$, $C5$, $D\#5$, $F5$ and $G\#5$} with the lengths of notes ranging from 1/6-Jeonggan to \textcolor{black}{6}-Jeonggan. For example, if the $i$th node, $n_i$, is a pair of a pitch, say $G\#3$, and its length, say one Jeonggan, then the node is represented by $ n_i = (G\#3,1)$. Using this construction the network of Suyeonjang, \textcolor{black}{Songkuyeo and Taryong} contains in total $33$, \textcolor{black}{ $37$ and $40$ nodes, respectively}. Two nodes are connected if they occur adjacent in time. Let $e_{ij} \in E$ be the edge whose end points are $n_i$ and $n_j$. The weight or the degree of the edge $e_{ij}$, {\textcolor{black}{$w_{ij}$}}, between $n_i$ and $n_j$ is the number of occurrences of those two nodes being adjacent in time. {\textcolor{black} {For two distinct nodes $n_i$ and $n_j$ with $i<j$, let $p_{ij}$ be the path with the minimum number of edges between $n_i$ and $n_j$ found by using Dijkstra algorithm. Then we define the distance $d_{ij}$ between nodes $n_i$ and $n_j$ and form the distance matrix $D = \{d_{ij}\}$ as follows \begin{equation} d_{ij} = \left\{ \begin{array}{lc} {\sum \limits_{e_{kl}\in p_{ij}}w_{kl}^{-1}}, & i < j \\ 0, & i = j \end{array} \right. \quad \text{and} \quad d_{ij} = d_{ji}, i> j, \label{1} \end{equation} where $w_{kl}$ represents the weight of the edge $e_{kl}$ and $p_{ij} = \bigcup e_{kl} $. }} \textcolor{black}{It is clear that if two node $n_k$ and $n_l$ are connected by the edge $e_{kl}$ then $w_{kl} \neq 0$ and further $w_{kl} \ge 1$. Thus $w_{kl}^{-1}$ is well defined in the above distance definition. Also note that since there is no isolated node which is not an end point of any of edges in $E$ (due to the fact that there is no empty Jeonggan where the music is not played), there always exists at least one path between any two nodes $n_i$ and $n_j$ even if they do not appear adjacently in the whole music, that is, $p_{ij}$ exists, $\forall i<j$. Thus for this definition it is not necessary that $n_i$ and $n_j$ are adjacent. Therefore the definition of the distance Eq. (\ref{1}) is well-defined. This observation is valid at least for those music we consider in this paper, played with Haegeum. } The metric is taken this way because we want to construct a space where the more closely connected nodes in networks are the closer in the space. Therefore, we took the inverse of the weight since we look at networks where larger weights indicate more closely connected relationships between nodes. \begin{remark} Because of the definition of the distance in Eq. (\ref{1}), we observe that the point cloud obtained from the constructed network of Suyeonjang is in non-Euclidean metric space. Thus, in generating the barcode we use the method \textsf{ExplicitMetricSpace} in Javaplex \citep{ATVJ} which works for a point cloud in an arbitrary, in particular non-Euclidean, metric space. \end{remark} All nodes of Suyeonjang, Songkuyeo and Taryong, according to the node definition above, are provided in Tables \ref{tab:syj_allnodes}, \ref{tab:songkuyeo_allnodes} and \ref{tab:taryong_allnodes} in Appendix. All nodes in each table are listed in ascending order in terms of pitch first then length. That is, $n_j$ has a higher pitch than $n_i$ or both have the same pitch but $n_j$ has a longer length than $n_i$ if $j > i$. Suyeonjang, Songkuyeo and Taryong have, in total, $33$, $37$ and $40$ nodes, respectively. \section{Frequency} \label{sec:freq} We first provide the frequency of the occurrence of each node in music. Table \ref{tab:table1} shows the node frequency for Suyeonjang, Songkuyeo and Taryong, left to right, respectively. For each music, the left column shows the node number and the right column the corresponding occurrence frequency. The frequencies are listed from first to last in rank in the table. Figure \ref{figure1} shows the frequency versus rank in semi-logarithmic scale. The horizontal axis represents the rank and the vertical axis the frequency in logarithmic scale. Note that the frequency is a positive integer by definition. As shown in the figure, the frequency decays more exponentially than algebraically. \begin{table}[] \begin{center} \caption{Frequency versus node.} \label{tab:table1} {\footnotesize{ \begin{tabular}{| c | |c c|| c c|| c c|} \hline {rank}& {Suyeonjang} & & {Songkuyeo} & & {Taryong} & \\ \hline 1 & $n_{18}$ & 76 & $n_{20}$ & 65 & $n_{16}$ & 38 \\ 2 & $n_{6}$ & 57 & $n_{31}$ & 53 & $n_{11}$ & 28 \\ 3 & $n_{11}$ & 44 & $n_{13}$ & 45 & $n_{13}$ & 23 \\ 4 & $n_{22}$ & 44 & $n_{26}$ & 44 & $n_{26}$ & 18 \\ 5 & $n_{1}$ & 30 & $n_{8}$ & 27 & $n_{29}$ & 17 \\ 6 & $n_{20}$ & 26 & $n_{18}$ & 23 & $n_{31}$ & 15 \\ 7 & $n_{27}$ & 22 & $n_{4}$ & 18 & $n_{28}$ & 15 \\ 8 & $n_{3}$ & 16 & $n_{33}$ & 18 & $n_{3}$ & 14 \\ 9 & $n_{28}$ & 14 & $n_{6}$ & 11 & $n_{18}$ & 13 \\ 10 & $n_{12}$ & 10 & $n_{16}$ & 11 & $n_{15}$ & 11 \\ 11 & $n_{16}$ & 9 & $n_{25}$ & 11 & $n_{12}$ & 10 \\ 12 & $n_{26}$ & 9 & $n_{19}$ & 10 & $n_{22}$ & 10 \\ 13 & $n_{31}$ & 9 & $n_{24}$ & 10 & $n_{6}$ & 9 \\ 14 & $n_{2}$ & 7 & $n_{27}$ & 10 & $n_{32}$ & 8 \\ 15 & $n_{4}$ & 7 & $n_{28}$ & 9 & $n_{17}$ & 7 \\ 16 & $n_{23}$ & 7 & $n_{32}$ & 8 & $n_{20}$ & 7 \\ 17 & $n_{9}$ & 6 & $n_{2}$ & 6 & $n_{4}$ & 5 \\ 18 & $n_{10}$ & 6 & $n_{15}$ & 5 & $n_{9}$ & 4 \\ 19 & $n_{5}$ & 5 & $n_{7}$ & 4 & $n_{0}$ & 3 \\ 20 & $n_{8}$ & 5 & $n_{11}$ & 3 & $n_{14}$ & 3 \\ 21 & $n_{13}$ & 5 & $n_{12}$ & 3 & $n_{2}$ & 2 \\ 22 & $n_{0}$ & 4 & $n_{14}$ & 3 & $n_{5}$ & 2 \\ 23 & $n_{7}$ & 3 & $n_{17}$ & 3 & $n_{7}$ & 2 \\ 24 & $n_{17}$ & 3 & $n_{21}$ & 3 & $n_{8}$ & 2 \\ 25 & $n_{19}$ & 3 & $n_{23}$ & 3 & $n_{19}$ & 2 \\ 26 & $n_{21}$ & 2 & $n_{35}$ & 3 & $n_{21}$ & 2 \\ 27 & $n_{25}$ & 2 & $n_{0}$ & 2 & $n_{27}$ & 2 \\ 28 & $n_{29}$ & 2 & $n_{3}$ & 2 & $n_{33}$ & 2 \\ 29 & $n_{30}$ & 2 & $n_{9}$ & 2 & $n_{34}$ & 2 \\ 30 & $n_{32}$ & 2 & $n_{10}$ & 2 & $n_{35}$ & 2 \\ 31 & $n_{14}$ & 1 & $n_{36}$ & 2 & $n_{1}$ & 1 \\ 32 & $n_{15}$ & 1 & $n_{34}$ & 2 & $n_{10}$ & 1 \\ 33 & $n_{24}$ & 1 & $n_{1}$ & 1 & $n_{23}$ & 1 \\ 34 & & & $n_{5}$ & 1 & $n_{24}$ & 1 \\ 35 & & & $n_{22}$ & 1 & $n_{25}$ & 1 \\ 36 & & & $n_{29}$ & 1 & $n_{30}$ & 1 \\ 37 & & & $n_{30}$ & 1 & $n_{38}$ & 1 \\ 38 & & & & & $n_{36}$ & 1 \\ 39 & & & & & $n_{37}$ & 1 \\ 40 & & & & & $n_{39}$ & 1 \\ \hline \end{tabular} }} \end{center} \end{table} \begin{figure}[th] \centering \includegraphics[width=0.3\textwidth]{SYJ_1.eps} \includegraphics[width=0.3\textwidth]{SKY_1.eps} \includegraphics[width=0.3\textwidth]{TR_1.eps} \caption{Frequency versus node. The horizontal axis represents the rank and the vertical axis the frequency in logarithmic scale. Left: Suyeonjang. Middle: Songkuyeo. Right: Taryong. Note that the minimum frequency is unity as the minimum occurrence of a particular node is at least one by definition. } \label{figure1} \end{figure} \section{Analysis of the barcodes} \label{sec:analysis} In this section we analyze the barcode and give an interpretation of the persistence intervals in the first dimension for Suyeonjang, Songkuyeo and Taryong. \subsection{Suyeonjang} The barcode for Suyeonjang generated by Javaplex with Vietoris-Rips method is given in \figref{fig:syj_barcode}. \begin{figure}[h] \begin{center} \includegraphics[width=0.5\textwidth]{suyeonjang_barcode.eps} \caption{Barcode of Suyeonjang using Vietoris-Rips method. Top: 0-D barcode. Bottom: 1-D barcode. In 1D barcode, we observe 8 non-zero persistence implying 8 cycles in $G$.} \label{fig:syj_barcode} \end{center} \end{figure} In \figref{fig:syj_barcode} the horizontal axis is the filtration value $\tau$. Vertically we have multiple intervals that correspond to generators of the homology groups. In the zeroth dimension we have $33$ generators that correspond to $33$ components when $\tau$ is small, which eventually are connected into a single component when $\tau=1$. The $33$ components are actually those $33$ nodes defined in Suyeonjang. All these components constitute a single component because of the fact that any node in the network connects at least one time with another node, which means that at most when distance $d=1$ all nodes in the network are connected. In the first dimension we see $8$ generators which topologically correspond to eight cycles. A natural question is whether these cycles are related to the repetition of music melodies. In the following we will go into detailed analysis about the musical meaning of these cycles. The persistence algorithm computing intervals is used to find a representative cycle for each interval. The annotated intervals computed by the method \textsf{computeAnnotatedIntervals} in Javaplex tell us what the nodes in the intervals of persistence are. In the one dimension case, the annotated intervals consist of the components in the loops generated in the process of filtration. \figref{fig:syj_cycles} shows $8$ cycles identified by TDA corresponding to $8$ persistence intervals in dimension one of the barcode. The order of cycles is the order of their appearance in the barcode. That is, the earlier \textcolor{black}{ the 1D barcode dies} the lower number is assigned to the corresponding cycle. For example, the \textcolor{black}{death} of Cycle $i$ is earlier than the \textcolor{black}{death} of Cycle $j$ if $i < j$. Note that this order is different from the order of their appearance in the actual music. In the figure, each cycle is shown with {\textcolor{black}{the persistence interval,}} the node information (its node number and note), edge weight ({\textcolor{black}{in normal size in blue), distance between node (in small size in blue in brackets)}} and the average weight (in red in center) which is the simple mean of all edge weights. As shown in the figure, the minimum number of nodes that constitute a cycle is $4$ and the maximum number is $6$. The average node number is $4.625$. The average weight is $9.39375$. Cycle 2 {\color{black}{corresponds}} to the shortest persistence in 1D barcode. Cycle 4 {\color{black}{corresponds}} to the longest persistence in 1D barcode. The information of corresponding music notes is given in \tabref{tab:syj_nodeinfo}. {\color{black}{It should be kept}} in mind that Suyeonjang has in total $33$ nodes, and the cycles show which node combinations are of interest. \include{syj_cycles} \include{syj_nodeinfo} The first attempt is to find in the music sheet the sequence of music notes appearing in each cycle. We have found that except for cycles 6, 7 and 8, five remaining cycles indeed represent consecutive sequences of notes in Suyeonjang. Among them two sequences of music notes actually make up two {\textcolor{black}{closed}} cycles 4 and 5. They appear in Suyeonjang in the following orders \begin{center}\begin{tikzpicture}[scale = 1] \tikzstyle{every node}=[draw,shape=circle,inner sep=0pt,minimum size=.6cm,inner sep=0pt,minimum size=.6cm]; \node[fill=blue!99] (v1) at (1,0) {\textcolor{white}{\includegraphics[width=0.36cm]{Imw.png}}} \node[fill=blue!99] (v2) at (2,0) {\textcolor{white}{\includegraphics[width=0.36cm]{namw.png}}} \node[fill=red!30] (v3) at (3,0) {\textcolor{black}{\includegraphics[width=0.36cm]{jung0.png}}} \node[fill=orange!99] (v4) at (4,0) {\textcolor{white}{\includegraphics[width=0.36cm]{Imw.png}}} \node[fill=teal!60] (v5) at (5,0) {\textcolor{black}{\includegraphics[width=0.36cm]{jung0.png}}} \node[fill=blue!99] (v6) at (6,0) {\textcolor{white}{\includegraphics[width=0.36cm]{Imw.png}}} \node[draw=none] (v01) at (1.1,-0.5) {$n_{6}$}; \node[draw=none] (v02) at (2.1,-0.5) {$n_{11}$}; \node[draw=none] (v03) at (3.1,-0.5) {$n_{2}$}; \node[draw=none] (v04) at (4.1,-0.5) {$n_{7}$}; \node[draw=none] (v05) at (5.1,-0.5) {$n_{0}$}; \node[draw=none] (v06) at (6.1,-0.5) {$n_{6}$}; \draw (v1) -- (v2) (v2) -- (v3) (v3) -- (v4) (v4) -- (v5) (v5) -- (v6); \end{tikzpicture}\end{center} for cycle 4 (appearing three times) and \begin{center}\begin{tikzpicture}[scale = 1] \tikzstyle{every node}=[draw,shape=circle,inner sep=0pt,minimum size=.6cm,inner sep=0pt,minimum size=.6cm]; \node[fill=blue!99] (v1) at (1,0) {\textcolor{white}{\includegraphics[width=0.36cm]{Imw.png}}} \node[fill=blue!99] (v2) at (2,0) {\textcolor{white}{黃}} \node[fill=blue!30] (v3) at (3,0) {\textcolor{black}{太}} \node[fill=teal!60] (v4) at (4,0) {\textcolor{black}{黃}} \node[fill=blue!99] (v5) at (5,0) {\textcolor{white}{\includegraphics[width=0.36cm]{Imw.png}}} \node[fill=blue!99] (v6) at (6,0) {\textcolor{white}{黃}} \node[draw=none] (v01) at (1.1,-0.5) {$n_{6}$}; \node[draw=none] (v02) at (2.1,-0.5) {$n_{18}$}; \node[draw=none] (v03) at (3.1,-0.5) {$n_{21}$}; \node[draw=none] (v04) at (4.1,-0.5) {$n_{16}$}; \node[draw=none] (v05) at (5.1,-0.5) {$n_{6}$}; \node[draw=none] (v06) at (6.1,-0.5) {$n_{18}$}; \draw (v1) -- (v2) (v2) -- (v3) (v3) -- (v4) (v4) -- (v5) (v5) -- (v6); \end{tikzpicture}\end{center} for cycle 5 (appearing one time), respectively. Note sequences in cycles 2 and 3 are also found in the music in the following orders \begin{center}\begin{tikzpicture}[scale = 1] \tikzstyle{every node}=[draw,shape=circle,inner sep=0pt,minimum size=.6cm,inner sep=0pt,minimum size=.6cm]; \node[fill=blue!99] (v1) at (1,0) {\textcolor{white}{\includegraphics[width=0.36cm]{Imw.png}}} \node[fill=orange!99] (v2) at (2,0) {\textcolor{white}{\includegraphics[width=0.36cm]{namw.png}}} \node[fill=teal!60] (v3) at (3,0) {\textcolor{black}{\includegraphics[width=0.36cm]{Im0.png}}} \node[fill=blue!99] (v4) at (4,0) {\textcolor{white}{黃}} \node[draw=none] (v01) at (1.1,-0.5) {$n_{6}$}; \node[draw=none] (v02) at (2.1,-0.5) {$n_{12}$}; \node[draw=none] (v03) at (3.1,-0.5) {$n_{3}$}; \node[draw=none] (v04) at (4.1,-0.5) {$n_{18}$}; \draw (v1) -- (v2) (v2) -- (v3) (v3) -- (v4); \end{tikzpicture}\end{center} for cycle 2 (appearing two times) and \begin{center}\begin{tikzpicture}[scale = 1] \tikzstyle{every node}=[draw,shape=circle,inner sep=0pt,minimum size=.6cm,inner sep=0pt,minimum size=.6cm]; \node[fill=teal!60] (v1) at (1,0) {\textcolor{black}{太}} \node[fill=blue!30] (v2) at (2,0) {\textcolor{black}{仲}} \node[fill=orange!99] (v3) at (3,0) {\textcolor{white}{太}} \node[fill=teal!60] (v4) at (4,0) {\textcolor{black}{黃}} \node[fill=blue!99] (v5) at (5,0) {\textcolor{white}{太}} \node[draw=none] (v01) at (1.1,-0.5) {$n_{20}$}; \node[draw=none] (v02) at (2.1,-0.5) {$n_{26}$}; \node[draw=none] (v03) at (3.1,-0.5) {$n_{23}$}; \node[draw=none] (v04) at (4.1,-0.5) {$n_{16}$}; \node[draw=none] (v05) at (5.1,-0.5) {$n_{22}$}; \draw (v1) -- (v2) (v2) -- (v3) (v3) -- (v4) (v4) -- (v5); \end{tikzpicture}\end{center} for cycle 3 (appearing one time), respectively. Although these two sequences do not make up closed cycles, they do preserve the order of edge connectivity of the cycles. For cycle~1 we found two sequences of the same notes but in a slightly different order \begin{center}\begin{tikzpicture}[scale = 1] \tikzstyle{every node}=[draw,shape=circle,inner sep=0pt,minimum size=.6cm,inner sep=0pt,minimum size=.6cm]; \node[fill=teal!60] (v1) at (1,0) {\textcolor{black}{太}} \node[fill=blue!99] (v2) at (2,0) {\textcolor{white}{仲}} \node[fill=blue!99] (v3) at (3,0) {\textcolor{white}{黃}} \node[fill=blue!99] (v4) at (4,0) {\textcolor{white}{太}} \node[draw=none] (v01) at (1.1,-0.5) {$n_{20}$}; \node[draw=none] (v02) at (2.1,-0.5) {$n_{27}$}; \node[draw=none] (v03) at (3.1,-0.5) {$n_{18}$}; \node[draw=none] (v04) at (4.1,-0.5) {$n_{22}$}; \draw (v1) -- (v2) (v2) -- (v3) (v3) -- (v4); \end{tikzpicture}\end{center} In summary, by using TDA tools we obtain a set of $8$ persistence intervals that can be interpreted as $8$ cycles in dimension one. Our approach is to find sequences of notes in the music that correspond to these cycles. We have found that out of the $8$ cycles five of them appear as consecutive sequences of notes in Suyeonjang (single or multiple times) and the other three are not found. The order in which notes appear in the music is not necessarily the same as the order of edge connectivity of the cycles. \figref{fig:7} shows the $5$ cycles appearing in Suyeonjang with time. The horizontal axis represents the time sequence the music flows and the vertical axis represents the cycle number, from $1$ to $5$. {\textcolor{black}{ Ignore the number displayed in the axis. }} The width of each is the total number of nodes involved in the cycle. The height of each bar in the figure has no meaning but is displayed only for the visual distinction purpose. {\textcolor{black}{The monotonicity means that the sequence is the same as the cycle sequence. The variance in color means the slight variation of the cycle sequence when appearing.}} For example, the figure shows that Cycle 4 (the $4$th bar from top) appears three times in the first half of music while the rest cycles appear in the second half of the music. We observe that the occurrence of the cycles in the complete form is sparse. \begin{figure}[!h] \begin{center} \includegraphics[height = 5cm, width = \textwidth]{syj_cycleappear.png} \caption{Consecutive sequences of notes corresponding to Cycles 1, 2, 3, 4, 5 found in Suyeonjang. The horizontal axis is the time sequence of music flow and the vertical axis is for the cycles. The top bars represents Cycle 1 and the bottom Cycle 5. The width of each bar is the number of nodes contained in each cycle. The height of each bar is only for the visual distinction purpose. Note that Cycles 6, 7 and 8 are not appearing. } \label{fig:7} \end{center} \end{figure} Let $s$ be a positive integer. Consider a music piece $\mathcal{O}$ composed of $d$ notes that flows in the following order $\mathcal{L} = \{ \nu_1, \ldots, \nu_d\}$ and assume that the barcode for it in the first dimension consists of $k$ generators which topologically correspond to $k$ Cycles, $C_1, \ldots, C_k$. We define the Overlap matrix on $s$-scale for $\mathcal{O}$ as follows. \definition{Matrix $M_{k\times d}^s=\{m_{ij}^s\}$ is called the Overlap matrix on $s$-scale for $\mathcal{O}$ if it satisfies the following conditions \[ m_{ij}^s = \begin{cases} 1, & \text{ if } \exists~ t,l \geq 0 \text{ satisfying } t + l \geq s-1 \text{ such that }\\ & \hspace{0.5cm} \nu_{j-l}, \nu_{j-l-1}, \ldots, \nu_j, \ldots, \nu_{j+t-1}, \nu_{j+t} \in C_i,\\ 0, & \text{ otherwise,} \end{cases} \] for all $i = 1,\ldots, k$; $j = 1,\ldots,d$. }\label{def:overlapmat} In other words, a binary matrix $M_{k\times d}^s=\{m_{ij}^s\}$, i.e., a matrix whose entries are either $0$ or $1$, belongs to $s$-scale if and only if on each row of $M_{k\times d}^s$ any entry equal to $1$ should be staying in a consecutive sequence of length at least $s$ columns that equal to $1$. \figref{fig:syj_min4notes} shows the Overlap matrix on $4$-scale for Suyeonjang. This plot is similar to \figref{fig:7}, the cycle occurrence with respect to music flow. The only difference is that each cycle is displayed in the figure whenever at least $4$ nodes in the cycle are appearing in the music. The order may not be the same for each occurrence. We observe that the occurrence is now rather dense compared to \figref{fig:7}. We also observe that the invisible Cycles $6, 7$ and $8$ in \figref{fig:7} are now appearing in the figure. In fact, the number of the occurrences of Cycle 6 is not small. Also notice that multiple cycles can be found simultaneously. \begin{figure}[!h] \begin{center} \includegraphics[height = 4cm, width = \textwidth]{syj_overlap4.png} \caption{Overlap matrix on $4$-scale for Suyeonjang. This shows consecutive sequences of at least $4$ nodes involved in cycles of Suyeonjang. Similar plot as \figref{fig:7}. Those cycles are displayed when at least $4$ nodes in the cycle are appearing in the music. Notice that Cycles $6, 7$ and $8$ are appearing in the figure. } \label{fig:syj_min4notes} \end{center} \end{figure} \figref{fig:syj_numofcyc} shows how many cycles are there that each of $33$ nodes in Suyeonjang in \tabref{tab:syj_allnodes} belongs to. The horizontal axis shows all $33$ nodes in ascending order in terms of pitch and the vertical axis shows the total number of cycles that the node belongs to and cycle number together. For examples, each of the first three nodes $n_0, n_1, n_2, n_3$ belongs to only one cycle, i.e. Cycle 4 (c4), Cycle 6 (c6), Cycle 4 (c4) and Cycle 2 (c2) while $n_5$ and $n_6$ do not belong to any of cycles and $n_7$ belongs to $5$ cycles, Cycle 2 (c2), Cycle 4 (c4), Cycle 5 (c5), Cycle 6 (c6) and Cycle 7 (c7). \begin{figure}[!h] \begin{center} \includegraphics[width=\textwidth]{freq_syj2.png} \caption{Number of cycles that each node in Suyeonjang belongs to. The horizontal axis shows all nodes in Suyeonjang and the vertical axis shows the total number of cycles that each node belongs to and the actual cycle number. } \label{fig:syj_numofcyc} \end{center} \end{figure} \subsection{Songkuyeo} We provide the similar data for Songkuyeo. \figref{fig:songkuyeo_barcode} shows the barcodes in 0-D, 1-D and 2D. We observe that there are $37$ components when $\tau = 0$, which corresponds to the total number of nodes in Songkuyeo. In 1D barcode, we observe that there are $8$ non-zero persistences implying that there are $8$ cycles in music network as Suyeonjang. It is interesting to observe that there is one persistence in 2D. This implies that there exists a void-like structure in Songkuyeo network although the size of the void is small as the size of the persistence is small. \begin{figure}[h] \begin{center} \includegraphics[width=0.6\textwidth]{songkuyeo_barcode.eps} \caption{Barcode of Songkuyeo using Vietoris-Rips method for 0-D, 1-D and 2-D. We observe there are $8$ cycles in 1-D barcode while there is one void structure in 2-D barcode. } \label{fig:songkuyeo_barcode} \end{center} \end{figure} \figref{fig:songkuyeo_cycles} shows the $8$ cycles identified by TDA in Songkuyeo. Cycle 1 is corresponding to the shortest persistence in 1D barcode. Cycle 6 is corresponding to the longest persistence in 1D barcode. Cycles $2, 3, 5, 6, 7$ and $8$ do not appear in actual music in their whole consecutive form. The persistences of Cycles 7 and 8 start from $\tau = 1$ in 1D barcode. The number of nodes in the cycles in Songkuyeo ranges from $4$ to $8$. Recall that the maximum number of nodes in a cycle for Suyeonjang is $6$. The average node number is {\textcolor{black}{$5.375$}} which is {\textcolor{black}{larger}} than the average node number of Suyeonjang. The average weight is {\textcolor{black}{ $7.84125$}}, which is {\textcolor{black}{smaller}} than the average weight of Suyeonjang. The information of corresponding music notes is given in Table \ref{tab:songkuyeo_nodeinfo}. \include{songkuyeo_cycles} \include{songkuyeo_nodeinfo} Unlike Suyeonjang, there are only two cycles that appear in the music as a whole consecutive form, Cycle 1 and Cycle 4. The following Cycle 1 appears in the music but is not a closed cycle. \begin{figure}[h]\begin{center} \begin{center}\begin{tikzpicture}[scale = 1] \tikzstyle{every node}=[draw,shape=circle,inner sep=0pt,minimum size=.6cm,inner sep=0pt,minimum size=.6cm]; \node[fill=blue!99] (v1) at (1,0) {\textcolor{white}{林}} \node[fill=orange!99] (v2) at (2,0) {\textcolor{white}{南}} \node[fill=teal!60] (v3) at (3,0) {\textcolor{black}{林}} \node[fill=blue!99] (v4) at (4,0) {\textcolor{white}{潢}} \node[draw=none] (v01) at (1.1,-0.5) {$n_{20}$}; \node[draw=none] (v02) at (2.1,-0.5) {$n_{27}$}; \node[draw=none] (v03) at (3.1,-0.5) {$n_{18}$}; \node[draw=none] (v04) at (4.1,-0.5) {$n_{31}$}; \draw (v1) -- (v2) (v2) -- (v3) (v3) -- (v4); \end{tikzpicture}\end{center} \end{center} \end{figure} The following Cycle 4 also appears in the music and is a closed cycle in terms of pitch. \begin{figure}[h]\begin{center} \begin{center}\begin{tikzpicture}[scale = 1] \tikzstyle{every node}=[draw,shape=circle,inner sep=0pt,minimum size=.6cm,inner sep=0pt,minimum size=.6cm]; \node[fill=blue!99] (v1) at (1,0) {\textcolor{white}{太}} \node[fill=orange!99] (v2) at (2,0) {\textcolor{white}{林}} \node[fill=teal!60] (v3) at (3,0) {\textcolor{black}{太}} \node[fill=blue!99] (v4) at (4,0) {\textcolor{white}{林}} \node[draw=none] (v01) at (1.1,-0.5) {$n_{8}$}; \node[draw=none] (v02) at (2.1,-0.5) {$n_{21}$}; \node[draw=none] (v03) at (3.1,-0.5) {$n_{6}$}; \node[draw=none] (v04) at (4.1,-0.5) {$n_{20}$}; \draw (v1) -- (v2) (v2) -- (v3) (v3) -- (v4); \end{tikzpicture} \end{center} \end{center} \end{figure} Figure \ref{figure12} shows the actual cycles appearing in Songkuyeo in their whole consecutive form. As shown in the figure, there are only two cycles, Cycle 1 and Cycle 4 appearing in the music. Cycle 4 appears in the first half of the music and Cycle 1 in the second half of the music. As in Suyeonjang, the distribution of these cycles in the music is sparse. \begin{figure}[!h] \begin{center} \includegraphics[height = 5cm, width = \textwidth]{songkuyeo_cycleappear.png} \caption{Consecutive sequences of notes corresponding to Cycles 1 and 4 found in Songkuyeo. The horizontal axis is the time sequence of music flow and the vertical axis is for the cycles. The top bars represents Cycle 1 and the bottom Cycle 4. The width of each bar is the number of nodes contained in each cycle. The height of each bar is only for the visual distinction purpose. Note that only two cycles among eight are appearing. } \label{figure12} \end{center} \end{figure} Figure \ref{fig:sky_min4notes} shows the Overlap matrix on $4$-scale for Songkuyeo. This is the cycle occurrence with respect to music flow whenever at least $4$ nodes in the cycle are appearing in the music. The order may not be the same for each occurrence. We observe that the occurrence becomes now dense. We also observe that all the cycles except Cycle 5 are appearing. It is interesting to notice that Cycle 4 still appears only 3 times. Also notice again that multiple cycles can be found simultaneously. \begin{figure}[!h] \begin{center} \includegraphics[height = 4cm, width = \textwidth]{sky_overlap4.png} \caption{Overlap matrix on $4$-scale for Songkuyeo. This shows consecutive sequences of at least $4$ nodes involved in cycles of Songkuyeo. Cycles are displayed when at least $4$ nodes in the cycle are appearing in the music. Notice that all cycles except Cycle 5 are appearing in the figure. } \label{fig:sky_min4notes} \end{center} \end{figure} Figure \ref{fig:sky_numofcyc} shows how many cycles are there that each of $37$ nodes in Songkuyeo in \tabref{tab:songkuyeo_allnodes} belongs to. The horizontal axis shows all $37$ nodes in ascending order in terms of pitch and the vertical axis shows the total number of cycles that the node belongs to and cycle number together. The visualization follows the same format of Figure \ref{fig:syj_numofcyc}. \begin{figure}[h] \begin{center} \includegraphics[width=1.0\textwidth]{freq_sky2.png} \caption{Number of cycles that each node in Songkuyeo belongs to. The horizontal axis shows all nodes in Songkuyeo and the vertical axis shows the total number of cycles that each node belongs to and the actual cycle number. } \label{fig:sky_numofcyc} \end{center} \end{figure} \subsection{Taryong} Figure \ref{fig:taryong_barcode} shows the barcode of Taryong. As expected, there are $40$ components in 0-D barcode as there are $40$ nodes in Taryong. We observe that there are $10$ cycles in 1D barcode and $1$ cycle (void) in 2-D barcode. The number of 1D cycles of Taryong is larger than both those numbers of Suyeonjang and Songkuyeo. The following figure shows the $10$ cycles identified by TDA in Taryong. Each cycle shows {\textcolor{black}{the persistence interval}}, the node number, edge weight {\textcolor{black}{(normal size in blue), distance between node (small size in blue in brackets)}}, and the average weight (red in center). Cycle 1 is corresponding to the shortest persistence in 1D barcode. Cycle 10 is corresponding to the longest persistence in 1D barcode. Cycles $2, 3, 7$ and $8$ do not appear in actual music in their whole consecutive form. The corresponding persistences of Cycles $7$ and $8$ start from $\tau = 1$ while the persistences of Cycles $2$ and $3$ start earlier in 1D barcode. The average node number is $4.8$. The average weight is $4.385$. Notice that the number of cycles identified for Taryong is larger than those numbers of Suyeonjang and Songkuyeo, but the average node number {\textcolor{black}{is smaller than that of Songkuyeo}}. In fact, despite the larger number of cycles, the occurrence plot of cycles appearing in the music is much sparser than those plots of Suyeonjang and Songkuyeo, shown in Figures \ref{figure18} and \ref{fig:tr_min4notes}. \begin{figure}[h] \begin{center} \includegraphics[width=0.6\textwidth]{taryong_barcode.eps} \captionof{figure}{Barcode of Taryong using Vietoris-Rips method. Notice that there is a 2D persistence in 2D barcode corresponding to the 2D void in music network. There are $10$ cycles in 1D barcode. } \label{fig:taryong_barcode} \end{center} \end{figure} \include{taryong_cycles} \include{taryong_nodeinfo} \begin{figure}[!h]\centering\resizebox{40ex}{!}{% \begin{tikzpicture} \tikzstyle{every node}=[draw,shape=circle,inner sep=0pt,minimum size=.6cm,inner sep=0pt,minimum size=.6cm]; \begin{scope}[shift={(0,0)},scale = 1.3] \node[draw=none,rectangle,fontscale=-1] at (2.5,-0.8) {$\text{Cycle } 1$}; \node[fill=blue!99] (v0) at (0.0,0) {\textcolor{white}{太}} \node[draw=none] (n0) at (0.1,-0.4) {$n_{16}$}; \node[fill=orange!70] (v1) at (1.0,0) {\textcolor{white}{黃}} \node[draw=none] (n1) at (1.1,-0.4) {$n_{12}$}; \node[fill=blue!20] (v2) at (2.0,0) {\textcolor{black}{\includegraphics[width=2.35ex]{nam0.png}}} \node[draw=none] (n2) at (2.1,-0.4) {$n_{6}$}; \node[fill=blue!99] (v3) at (3.0,0) {\textcolor{white}{\includegraphics[width=2.35ex]{Imw.png}}} \node[draw=none] (n3) at (3.1,-0.4) {$n_{3}$}; \node[fill=red!20] (v4) at (4.0,0) {\textcolor{black}{黃}} \node[draw=none] (n4) at (4.1,-0.4) {$n_{13}$}; \node[fill=blue!99] (v5) at (5.0,0) {\textcolor{white}{太}} \node[draw=none] (n5) at (5.1,-0.4) {$n_{16}$}; \draw (v0) -- (v1); \draw (v1) -- (v2); \draw (v2) -- (v3); \draw (v3) -- (v4); \draw (v4) -- (v5); \end{scope} \begin{scope}[shift={(0,-2)},scale = 1.3] \node[draw=none,rectangle,fontscale=-1] at (2.5,-0.8) {$\text{Cycle } 4$}; \node[fill=orange!70] (v0) at (1.0,0) {\textcolor{white}{\includegraphics[width=2.35ex]{Imw.png}}} \node[draw=none] (n0) at (1.1,-0.4) {$n_{4}$}; \node[fill=blue!20] (v1) at (2.0,0) {\textcolor{black}{\includegraphics[width=2.35ex]{jung0.png}}} \node[draw=none] (n1) at (2.1,-0.4) {$n_{0}$}; \node[fill=blue!99] (v2) at (3.0,0) {\textcolor{white}{\includegraphics[width=2.35ex]{Imw.png}}} \node[draw=none] (n2) at (3.1,-0.4) {$n_{3}$}; \node[fill=red!20] (v3) at (4.0,0) {\textcolor{black}{黃}} \node[draw=none] (n3) at (4.1,-0.4) {$n_{13}$}; \draw (v0) -- (v1); \draw (v1) -- (v2); \draw (v2) -- (v3); \end{scope} \begin{scope}[shift={(0,-4)},scale = 1.3] \node[draw=none,rectangle,fontscale=-1] at (2.5,-0.8) {$\text{Cycle } 5$}; \node[fill=orange!70] (v0) at (1.0,0) {\textcolor{white}{黃}} \node[draw=none] (n0) at (1.1,-0.4) {$n_{12}$}; \node[fill=blue!20] (v1) at (2.0,0) {\textcolor{black}{\includegraphics[width=2.35ex]{Im0.png}}} \node[draw=none] (n1) at (2.1,-0.4) {$n_{2}$}; \node[fill=blue!99] (v2) at (3.0,0) {\textcolor{white}{黃}} \node[draw=none] (n2) at (3.1,-0.4) {$n_{11}$}; \node[fill=red!20] (v3) at (4.0,0) {\textcolor{black}{太}} \node[draw=none] (n3) at (4.1,-0.4) {$n_{18}$}; \draw (v0) -- (v1); \draw (v1) -- (v2); \draw (v2) -- (v3); \end{scope} \begin{scope}[shift={(0,-6)},scale = 1.3] \node[draw=none,rectangle,fontscale=-1] at (2.5,-0.8) {$\text{Cycle } 6$}; \node[fill=blue!99] (v0) at (0.5,0) {\textcolor{white}{黃}} \node[draw=none] (n0) at (0.6,-0.4) {$n_{11}$}; \node[fill=brown!20] (v1) at (1.5,0) {\textcolor{black}{太}} \node[draw=none] (n1) at (1.6,-0.4) {$n_{19}$}; \node[fill=red!20] (v2) at (2.5,0) {\textcolor{black}{仲}} \node[draw=none] (n2) at (2.6,-0.4) {$n_{23}$}; \node[fill=blue!99] (v3) at (3.5,0) {\textcolor{white}{太}} \node[draw=none] (n3) at (3.6,-0.4) {$n_{16}$}; \node[fill=red!20] (v4) at (4.5,0) {\textcolor{black}{林}} \node[draw=none] (n4) at (4.6,-0.4) {$n_{29}$}; \draw (v0) -- (v1); \draw (v1) -- (v2); \draw (v2) -- (v3); \draw (v3) -- (v4); \end{scope} \begin{scope}[shift={(0,-8)},scale = 1.3] \node[draw=none,rectangle,fontscale=-1] at (2.5,-0.8) {$\text{Cycle } 9$}; \node[fill=red!20] (v0) at (-0.5,0) {\textcolor{black}{林}} \node[draw=none] (n0) at (-0.4,-0.4) {$n_{29}$}; \node[fill=blue!99] (v1) at (0.5,0) {\textcolor{white}{林}} \node[draw=none] (n1) at (0.6,-0.4) {$n_{26}$}; \node[fill=red!20] (v2) at (1.5,0) {\textcolor{black}{南}} \node[draw=none] (n2) at (1.6,-0.4) {$n_{33}$}; \node[fill=red!90] (v3) at (2.5,0) {\textcolor{white}{潢}} \node[draw=none] (n3) at (2.6,-0.4) {$n_{37}$}; \node[fill=teal!30] (v4) at (3.5,0) {\textcolor{black}{汰}} \node[draw=none] (n4) at (3.6,-0.4) {$n_{38}$}; \node[fill=blue!99] (v5) at (4.5,0) {\textcolor{white}{南}} \node[draw=none] (n5) at (4.6,-0.4) {$n_{32}$}; \node[fill=red!20] (v6) at (5.5,0) {\textcolor{black}{林}} \node[draw=none] (n6) at (5.6,-0.4) {$n_{29}$}; \draw (v0) -- (v1); \draw (v1) -- (v2); \draw (v2) -- (v3); \draw (v3) -- (v4); \draw (v4) -- (v5); \draw (v5) -- (v6); \end{scope} \begin{scope}[shift={(0,-10)},scale = 1.3] \node[draw=none,rectangle,fontscale=-1] at (2.5,-0.8) {$\text{Cycle } 10$}; \node[fill=blue!20] (v0) at (0.5,0) {\textcolor{black}{黃}} \node[draw=none] (n0) at (0.6,-0.4) {$n_{10}$}; \node[fill=red!70] (v1) at (1.5,0) {\textcolor{white}{仲}} \node[draw=none] (n1) at (1.6,-0.4) {$n_{24}$}; \node[fill=red!20] (v2) at (2.5,0) {\textcolor{black}{林}} \node[draw=none] (n2) at (2.6,-0.4) {$n_{29}$}; \node[fill=blue!99] (v3) at (3.5,0) {\textcolor{white}{仲}} \node[draw=none] (n3) at (3.6,-0.4) {$n_{21}$}; \node[fill=red!20] (v4) at (4.5,0) {\textcolor{black}{太}} \node[draw=none] (n4) at (4.6,-0.4) {$n_{18}$}; \draw (v0) -- (v1); \draw (v1) -- (v2); \draw (v2) -- (v3); \draw (v3) -- (v4); \end{scope} \end{tikzpicture}} \caption{Cycles appearing in Taryong as a whole consecutive form.} \label{fig:TRseq} \end{figure} \begin{figure}[!h] \begin{center} \includegraphics[height = 5cm, width = \textwidth]{taryong_cycleappear.png} \caption{Consecutive sequences of nodes corresponding to Cycles 1, 4, 5, 6, 9 and 10 found in Taryong. The horizontal axis is the time sequence of music flow and the vertical axis is for the cycles. The top bars represent Cycle 1 and the bottom Cycle 10. The width of each bar is the number of nodes contained in each cycle. The height of each bar is only for the visual distinction purpose. Note that {\textcolor{black} {six cycles among all cycles}} are appearing in the music.} \label{figure18} \end{center} \end{figure} {\textcolor{black}{Figures \ref{fig:TRseq} and}} \ref{figure18} show the consecutive sequences of nodes corresponding to Cycles 1, 4, 5, 6, 9 and 10 found in Taryong. {\textcolor{black}{Among them Cycles 1 and 9 are closed cycles.} The top bars represent Cycle 1 and the bottom bars represent Cycle 10. Note that {\textcolor{black} {six cycles among all cycles}} are appearing in the music. As Suyeonjang and Songkuyeo, the occurrence distribution is sparse. \begin{figure}[!h] \begin{center} \includegraphics[height = 5cm, width = \textwidth]{tr_overlap4.png} \caption{Overlap matrix on $4$-scale for Taryong. This shows consecutive sequences of at least $4$ nodes involved in cycles of Taryong. Cycles are displayed when at least $4$ nodes in the cycle are appearing in the music. Notice that all cycles except Cycle 2 are appearing in the figure. } \label{fig:tr_min4notes} \end{center} \end{figure} Figure \ref{fig:tr_min4notes} shows the Overlap matrix on $4$-scale for Taryong. This shows consecutive sequences of at least $4$ nodes involved in cycles of Taryong. Cycles are displayed when at least $4$ nodes in the cycle are appearing in the music. Notice that all cycles except Cycle 2 are appearing in the figure. It is interesting to observe that unlike Suyeonjang and {\textcolor{black}{Songkuyeo}} the plot is still spare although Taryong has more cycles than Suyeonjang and Songkuyeo. \textcolor{black}{We compare Figures \ref{fig:syj_min4notes}, \ref{fig:sky_min4notes} and \ref{fig:tr_min4notes} in Table \ref{tab:comparison}. The denseness is defined as follows \[ \text{Denseness} = \frac{A_c}{A_f}, \] where $A_c$ is the total area that consecutive sequences of at least 4 nodes belonging to the cycles occupy, and $A_f$ is the total area of the corresponding Figure. } We see that the denseness of cycles of Suyeonjang and Songkuyeo are about three times larger than that of Taryong. \textcolor{black}{It is also observed that, unlike Suyeonjang and Songkuyeo, the consecutive sequences of at least 4 nodes involved in cycles of Taryong are non-overlapping, meaning that only one cycle occurs at a time as music flows. So, if we define the overlapping percentage b \[ \text{Overlap} = \frac{N_s}{N_c} \times 100\%, \] where $N_s$ is the number of times at least two cycles occurred simultaneously, and $N_c$ is the number of times a cycle occurred in the time sequence of music flow, then the consecutive sequences of at least 4 nodes involved in cycles of Suyeonjang and Songkuyeo overlap $36.2318\%$ and $32.05128\%$, respectively, and those of Taryong overlap $0\%$. The results are showed in the last column of Table \ref{tab:comparison}. It is reasonable to hypothesize that the cycle overlapping gives Suyeonjang and Songkuyeo a feeling of melodic repetition which is well matched with the fact that they are classified as {\color{black}{Dodeuri}}, literally translated as "repetition", in Korean traditional music. } \begin{table}[!h] \begin{center} \caption{Comparison of cycle distributions} \label{tab:comparison} \resizebox{\columnwidth}{!}{% \begin{tabular}{| c || c | c | c| c| c| c|} \hline & \# of cycles & Average node \# & Average weight & Occurrence/Cycle & Denseness & Overlap (\%) \\ \hline Suyeonjang & 8 & {\textcolor{black}{4.625}} & {\textcolor{black}{9.39375}} & 1.125 & 0.09489 & 36.23188 \\ Songkuyeo & 8 & {\textcolor{black}{5.375}} & {\textcolor{black}{7.84125}} & 0.625 & 0.10153 & 32.05128 \\ Taryong & 10 & 4.8 & 4.385 & 0.7 & 0.03194 & 0\\ \hline \end{tabular}% } \end{center} \end{table} \begin{figure}[!h] \begin{center} \includegraphics[width=1.0\textwidth]{freq_tr2.png} \caption{Number of cycles that each node in Taryong belongs to. The horizontal axis shows all nodes in Taryong and the vertical axis shows the total number of cycles that each node belongs to and the actual cycle number. } \label{fig:tr_numofcyc} \end{center} \end{figure} Figure \ref{fig:tr_numofcyc} shows how many cycles are there that each of $40$ nodes in Taryong in \tabref{tab:taryong_allnodes} belongs to. The horizontal axis shows all $40$ nodes in ascending order in terms of pitch and the vertical axis shows the total number of cycles that the node belongs to and the corresponding cycle number together. The visualization follows the same format of Figure \ref{fig:syj_numofcyc}. \section{Concluding remark} In this work we used persistent homology to identify the cycles in three famous old Korean music pieces, namely Suyeonjang, Songkuyeo and Taryong by constructing the simplicial complex of music network of those three pieces. By calculating homology at different scales, we found several one-dimensional cycles in each music. By visualizing the distribution of the cycles in the music flow, we showed how those identified cycles appear through the music flow. We found that the first two music pieces, Suyeonjang and Songkuyeo, show similar overlapping patterns of those cycles in a way that cycles appear simultaneously while Taryong shows different patterns that cycles only appear individually. Our finding provides a systematic explanation of the unique structure embedded in Suyeonjang and Songkuyeo known as {\color{black}{"Dodeuri"}} (repeat-and-return) pattern. That is, {\color{black}{"Dodeuri"}} pattern does not only repeat or variate themes but also juxtapose those parallely to maximize its musical inspiration of cyclic patterns. In this paper, we showed that persistent homology provides a useful tool to analyze the Korean music written in Jeongganbo. Our current work did not consider the ornamenting tones and the analysis was based on the instrument-specific notes. In our future work, we plan to consider the ornamenting tones and expand the analysis to other instruments using persistent homology. \vskip .2in \noindent {\bf{Acknowledgements:} } This work is supported by the NRF SGER grant under grant number 2021R1A2C33009648. This research was partially supported by Samsung Science \& Technology Foundation SSTF-BA1802-02 \bibliographystyle{plain}
{'timestamp': '2021-07-02T02:01:28', 'yymm': '2103', 'arxiv_id': '2103.06620', 'language': 'en', 'url': 'https://arxiv.org/abs/2103.06620'}
arxiv
\section*{Acknowledgements} \section{Hardware Acceleration} \label{sec:arch} CHOCO-TACO\xspace is a hardware accelerator for homomorphic encryption and decryption operations, designed for client-aided HE. Figure \ref{fig:clientwntt}, shows that accelerating NTT/INTT and dyadic multiplication~\cite{heax} only is insufficient in reducing the dominating costs of these cryptographic primitives. CHOCO-TACO\xspace, by contrast, effectively accelerates all of the component functions that make up HE encryption and decryption, which we demonstrate through a worked example in Section~\ref{sec:arch:example} and show quantitatively in Section~\ref{sec:designspace}. \subsection{BFV Encryption}\label{sec:arch:encryption} {\small \begin{equation}\label{eq:encryption} \begin{split} Enc([P0, P1], m) = ([\Delta m + P0u + e1]_q , [P1u + e2]_q) \\ where \ u \stackrel{\$}\leftarrow \ R_2 \ and \ e1, e2 \leftarrow \chi \quad \quad \quad \quad \quad \end{split} \end{equation} } CHOCO-TACO\xspace accelerates asymmetric BFV encryption, described by Equation \ref{eq:encryption}~\cite{SEALmanual}, where $m$ is a message to encrypt, $P0, P1$ are public keys, and $u, e1, e2$ are vectors of randomly sampled numbers. Figure~\ref{fig:encryptpipeline} fully diagrams the RNS implementation of equation~\ref{eq:encryption} from SEAL~\cite{SEAL3.4}. The algorithm encrypts a message by first producing an encrypted "zero" by combining the vectors of randomly sampled numbers with the public keys through coefficient-wise multiplication and addition. The encoded message is then added to the encrypted zero to produce the final ciphertext. \begin{comment} To encrypt zero, SEAL BFV draws a vector $u$ of $N$ random values from a ternary distribution, taking the modulus of each by each of the $k$ residue primes. BFV then transforms the vector using NTT, and performs element-wise multiplication with the public key residues. The reverse transformation, INTT, is performed on the multiplication result creating distinct intermediate results for each component, $c1$ and $c0$, of the ciphertext. The algorithm then adds $N$ normally distributed random values to all $k$ RNS residues, including the special key prime residue. The modulus switching operation then drops this special residue, producing a ciphertext with only $k-1$ polynomials. Next, BFV adds an encoded message to the encrypted zero. The plaintext message is a vector of (up to) $N$ signed 64-bit integers. Encoding the message takes the modulus of each with the plaintext modulus $t$, then applies INTT, and finally converts the vector to RNS form with $k-1$ polynomials. The encoded message is added to the encrypted-zero $c0$ polynomial, both in the same RNS form, to yield the final encrypted message. \end{comment} \begin{figure}[!ht] \centering \includegraphics[width=\linewidth]{img/encryptpipeline.pdf} \caption{Pipeline of the BFV encryption operation to sample random noise, scale the input message, and ultimately create a ciphertext of two polynomials, each in RNS form. \cite{SEALmanual, HEAWS}} \label{fig:encryptpipeline} \end{figure} \begin{figure*}[t] \centering \includegraphics[width=\linewidth]{img/EncryptDecryptArchv4.pdf} \caption{Specialized architecture to support encryption \& decryption for $k = 3$} \label{fig:encryptarch} \end{figure*} \subsection{Encryption Architecture} \label{sec:arch:arch} CHOCO-TACO\xspace accelerates each of the main sub-operations that make up BFV encryption and decryption. CHOCO-TACO\xspace is a parallel, pipelined accelerator that directly implements the BFV algorithm. Figure \ref{fig:encryptarch} shows the full encryption and decryption accelerator. The design has several key {\em modules}: Random Number Generation, Polynomial Multiplication, Polynomial Addition and Modulus Switching, and Message Encoding. Each module contains functional blocks, which may be replicated for parallelism, and memory necessary to perform each operation. Each functional block contains an array of processing elements to allow for data parallelism within a functional block. The design additionally pipelines operations within and across modules. \par \subsubsection{Random Number Generation} CHOCO-TACO\xspace has a dedicated RNG module that implements the Blake3~\cite{Blake3} cryptographic hashing algorithm. The CHOCO-TACO\xspace configuration in Figure \ref{fig:encryptarch}, requries this module to produce 565 MB/s of random values at peak and 201 MB/s on average. The RNG module is also responsible for interpreting the provided randomness as an integer from either a ternary or normal distribution, which it transforms into RNS form. We upgraded our software encryption implementation to use Blake3 instead of Blake2, giving the algorithmic performance increases to both CHOCO-TACO\xspace and the baseline. \par \subsubsection{Polynomial Multiplication} CHOCO-TACO\xspace includes a module for polynomial multiplication of two polynomials, like prior work~\cite{heax, HEAWS, VLSIencrypt, heat}. The module transforms the polynomials to NTT form, then performs element-wise dyadic product. The module converts the result back to a polynomial using INTT. CHOCO-TACO\xspace's NTT and INTT modules are conceptually similar to HEAX~\cite{heax}. The modules perform pipelined SIMD memory accesses, following the NTT's butterfly dataflow pattern. The hardware computes polynomial multiplication of the RNS form of $u$ and each public key, $P0$ and $P1$. SEAL stores public keys in NTT form, so only the single NTT transformation for $u$ is supported in hardware. NTT's butterfly dataflow requires access to an entire polynomial at once, precluding aggressive pipelining (i.e., forwarding partial results). Once $u$ is entirely transformed, results flow to the dyadic product block along with $P0$, and $P1$. Both ciphertext components ($c0$ and $c1$) use the same NTT encoding of $u$, allowing it to remain in the NTT working buffer throughout encryption. Dyadic multiply results flow to a separate INTT buffer. After all outputs accumulate, the hardware performs in-place INTT, producing a result. \par \subsubsection{Polynomial Addition and Modulus Switching} After polynomial multiplication the accelerator applies polynomial addition and modulus switching. Polynomial addition is coefficient-wise addition of polynomials, taking one input from the INTT buffer and the other from a buffer filled by the RNG module. The output fills a small intermediate buffer that is the input to modulus switching, which removes the key-prime residue from the RNS encoding, resulting in $k-1$ polynomials. Modulus switching applies a series of modular multiplications and reductions, Modulus switching is the only operation that requires interaction across RNS residues, which precludes straightforward data parallelism across residues. \par \subsubsection{Message Encoding} After encrypting zero, CHOCO-TACO\xspace encodes, scales, and adds the input message to the encrypted zero. The encode/decode module includes a pair of small NTT and INTT blocks. The encoding hardware computes the modulus of each coefficient by the plaintext modulus $t$, and reorders coefficients into slots of the plaintext. The hardware must convert the encoded message to RNS, by scaling, representing it with $k-1$ residues only. A dedicated polynomial addition module adds the result to the $k-1$ intermediate residues of $c0$ and stores the result in the final output buffer. \subsubsection{Memory} Each module integrates and manages embedded SRAM scratchpad memory. All modules except NTT accept streaming inputs, and a module's memories must accommodate its incoming (parallel) input stream at the rate of input arrivals and operation duration. NTT and INTT, however, algorithmically operate on an entire polynomial, requiring their buffers to be sized according to the HE scheme's polynomial size. With HE parameters $N=8192$ and $k=3$, each NTT/INTT buffer is 64kB. In contrast, other memories, sized via our design-space exploration in Section \ref{sec:designspace} are sub-1kB. As Section \ref{sec:designspace} explains, we model memories using Destiny, ported for single-reader, single-writer 64-byte data accesses. \subsection{Encryption Operation Example} \label{sec:arch:example} BFV encryption encrypts zero into a ciphertext and adds a scaled message to the encrypted-zero ciphertext. To start, the accelerator samples $N$ bytes from the RNG according to a ternary distribution storing them in the NTT working buffer as $u$. The NTT block produces the NTT of $u$ in place, and the value becomes the input to the dyadic product module. The dyadic product module's other input is the accelerator input buffer, which software initializes with the NTT-transformed residues of $P1$, a public key. Dyadic multiply produces the element-wise product of $u$ and $P1$ in the INTT block's buffer, which the INTT block processes. In parallel with the dyadic product of $u$ and $P1$ the RNG unit produces $e2$, a sequence of 8-byte, normally distributed samples, storing them in a buffer in the cipher addition module. When the INTT completes, the PolyAdd module streams in its result, performing element-wise, addition with $e2$ and storing the results in a buffer in the modulus switching module, as $c1$.\par $c1$ is one component of the final ciphertext, which is output into the CPU's host memory Meanwhile, the accelerator begins producing $c0$ in the Poly Multiplication module. Computing $c0$ reuses the NTT of $u$, performing element-wise multiplication with public key $P0$. The accelerator samples a sequence of normally-distributed 8-byte $e1$ values (like $e2$) adding them element-wise with the result of the INTT of the product of $u$ and $P0$. The result is a partially-computed version of $c0$, the other component of the ciphertext.\par The last step is the polynomial addition of the partially computed $c0$ and the encoded input message, producing $c0$, which together with $c1$ makes the final ciphertext. \subsection{Adding Parallelism} \label{sec:arch:designspace} CHOCO-TACO\xspace exploits pipeline and data parallelism available in BFV encryption. Parallelism exists in independent RNS residues, independent coefficients and in pipelining throughout the accelerator. Polynomial multiplication and addition manipulate the multiple residues of an RNS-encoded polynomial. Each of these residues is an independent share of the polynomial being manipulated and operations need to be applied identically to each residue. Up to the limits of area and power, a CHOCO-TACO\xspace architecture can create parallel replicas of these operations' modules, including their input and output memories, enabling parallel processing of a polynomials RNS residues. RNS parallelism also eliminates the need to buffer the large vectors of random number for future execution. Instead, $u, e1,$ and $e2$ are immediately consumed and distributed to all residues as they are generated. Figure \ref{fig:encryptarch} illustrates the parallelism of RNS residue operations graphically through layering. Within each RNS layer, thousands of coefficients per polynomial afford data parallelism. A key design parameter for the CHOCO-TACO\xspace architecture is the degree to which each module exploits this source of data parallelism. Up to the limits of area and power, a CHOCO-TACO\xspace architecture can create parallel replicas of the blocks in a module, sizing memories to match, to enable higher throughput processing of coefficients. Section~\ref{sec:designspace} systematically explores the design space of parallel accelerators. \subsection{Decryption Support}\label{sec:arch:decryption} BFV decryption is operationally very similar to encryption. Equation \ref{eq:decryption} shows decryption mathematically. \begin{equation}\label{eq:decryption} Dec(s, [c0, c1]) = \left[\bigg\lfloor\frac{t}{q}[c0 + c1s]_q\bigg\rceil\right]_t \end{equation} Figure~\ref{fig:encryptarch} shows the flow of control and data for decryption with black lines. Decryption requires a few additional hardware components, but reuses the existing polynomial multiplication and addition modules to process $c1$, $s$, and $c0$. After addition, these intermediate results undergo fast base conversion and error correction, after which the message need only be decoded. Decoding uses the message encoding module, performing NTT, then moding by the plaintext modulus $t$. The result is the decrypted message, which the hardware conveys to the CPU's memory. \section{Background \& Motivation}\label{sec:background} CHOCO\xspace allows an IoT device to offload computation to a more-capable server that computes on encrypted data using Homomorphic Encryption (HE). Primitive operations, most of which support encrypted, Single Instruction Multiple Data (SIMD) computation, are composed into HE algorithms. These algorithms are in turn used to build encrypted HE applications, such as DNN inference. \subsection{Homomorphic Encryption}\label{sec:background:HE} Homomorphic encryption is a class of cryptography schemes that allow computing on encrypted data. In HE, for a pair of messages $m_1$ and $m_2$ that can be manipulated by an operation $\oplus$, a homomorphic version of the operation $\oplus'$, and encryption/decryption operations, $Enc()$, $Dec()$, the homomorphic operation applied to the encrypted data produces a result that, when decrypted is equal to the operation applied to unencrypted data: \begin{equation}\label{eq:heproperty} Dec(Enc(m_1) \oplus' Enc(m_2)) = m_1 \oplus m_2 \end{equation} Modern HE schemes~\cite{FV,ckks} are based on the ring learning with errors problem (RLWE). These schemes encrypt a {\em vector} of thousands of values into the coefficients of a large polynomial, hiding the vector's contents through modular arithmetic and the addition of noise. The HE operations in Table~\ref{tab:ops} manipulate ciphertexts, producing new ciphertexts containing the result of an operation applied element-wise to the input as depicted in Figure \ref{fig:fheexplain}. Each operation adds a predictable amount of noise to the encrypted vector, with some operations (e.g., multiplication) adding a large amount of noise, and others (e.g., addition) adding little. \begin{figure}[!ht] \centering \includegraphics[width=\linewidth]{img/FHEexplain.pdf} \caption{Homomorphic Encryption allows for computation directly on encrypted vectors of data.} \label{fig:fheexplain} \end{figure} The arithmetic depth of an HE computation is limited by noise growth. A sequence of operations that exhausts the noise budget renders decryption impossible and data unrecoverable. To avoid exceeding the noise budget, a system must schedule encrypted operations to limit noise growth. \input{table/ops} HE can {\em refresh} a ciphertext to eliminate accumulated noise, replenishing the full budget. {\em Fully} Homomorphic Encryption (FHE) refreshes noise without decryption at enormous computational cost through ``bootstrapping''~\cite{gentryFHE}. In contrast, {\em Somewhat} Homomorphic Encryption (SHE)~\cite{bfv1,bfv2,ckks,SEAL3.4,Gazelle} refreshes noise with pre-scheduled decryption and re-encryption operations. \input{table/params} CHOCO\xspace uses the increasingly practical Brakerski/Fan-Vercauteren (BFV) SHE scheme\cite{bfv1, bfv2} in SEAL~\cite{SEAL3.4}. Table \ref{tab:params} summarizes the scheme's parameters, which dictate its security, computational complexity, noise budget, and ciphertext size: \begin{equation}\label{eq:ciphersize} w \times N \times s \times (k-1) \end{equation} Typically, the polynomial modulus, $N$, is a power of two between $2^{11}$ and $2^{15}$. A fresh ciphertext is two polynomials ($s = 2$) of $N$ elements each. For a given $N$, a smaller coefficient modulus $q$ provides higher security but a smaller noise budget. A practical $q$ value is hundreds of bits. Operating directly on such large values is inefficient; HE schemes use the Residual Number System (RNS)~\cite{rns} to represent numbers using $k$ smaller, co-prime moduli. SEAL uses 60-bit residual moduli, to fit in a 64-bit machine word. BFV supports integer operations modulo the plaintext modulus $t$. A larger $t$ allows for larger numbers but contributes to a smaller noise budget. Parameter selection is application-dependent and must allow for sufficiently large plaintext values while maintaining a budget for sufficient noise growth. Table \ref{tab:paramselect} shows CHOCO\xspace's parameters and ciphertext size, in bytes. \input{table/paramselect} \subsection{Homomorphic Algorithms}\label{sec:background:algorithms} Primitive HE operations presented in Table \ref{tab:ops} allow for SIMD arithmetic to be performed on large vectors. These fundamental operations compose to support computations such as convolution or matrix multiplication. Algorithms using HE primitives come in two varieties depending on how inputs are encoded into ciphertexts. {\em Batching} algorithms, optimized for throughput, encode a single data point from thousands of inputs into a single ciphertext vector and exploit natural SIMD operations\cite{CryptoNets, DNNTexas}. Alternately, {\em packed} algorithms, optimized for latency, encode multiple data points from a single input as a ciphertext vector and utilize permutations to properly align and operate on the desired points \cite{LoLa, Gazelle}. \begin{comment} This isn't the correct description of batching in FHE terms... batching for throughput vs packing for latency. Algorithms using HE primitives schedule operations by packing data into ciphertext coefficients and planning encrypted rotations to operate on values in the correct sequence. HE algorithms often amortize the cost of large ciphertexts by batching many input data into vectors~\cite{nGraphHE2,CryptoNets}. \end{comment} \subsection{Homomorphic Applications}\label{sec:background:apps} HE theoretically supports arbitrary functions (through mapping to polynomials at extremely high computational cost \cite{CHET}), however, practical HE applications use HE primitives directly and are arithmetic-depth-limited. Prior work has identified ML inference using deep neural networks (DNNs) as a compelling use of HE, because of its structured form and complete reliance on simple linear algebra. Early work on HE for ML performed all computation on encrypted data \cite{CryptoNets, LoLa, DNNTexas}, communicating with the source of the data only to receive initial inputs and return final results. Unfortunately, these techniques have limited applicability to large and complex networks because of their modified activation functions, large noise growth across multiple layers, and subsequent reliance on very large parameter selections \cite{CHET}. This directly results in ciphertext sizes of multiple megabytes, inflating both computation and communication costs to impractical levels. \begin{comment} Most work on HE for ML performs all computation on encrypted data, communicating with the source of data only to receive initial inputs and return final results. CryptoNets~\cite{CryptoNets} and subsequent work build on this idea~\cite{CHET,LoLa,DNNTexas}. Although promising, these techniques have limited applicability to large and complex networks. A key problem is that common, non-linear activation functions (e.g., ReLu, tanh) must be converted to a low-degree polynomial function evaluable via HE operations. Using polynomial activations requires re-training the ML model from scratch for HE deployment. Moreover, the large noise growth from repeated multiplication across multiple layers requires the use of very large ciphertexts (as in CHET~\cite{CHET}), inflates computational costs, and limits DNN depth. \end{comment} As an alternative, recent solutions have focused on {\em client-aided} HE \cite{Gazelle, nGraphHE2, Cheetah}. In these protocols, the natural linear algebra capabilities of HE are used to perform convolution and fully-connected layers on the offload server. The client is then enlisted to perform all non-linear activation and pooling operations. Intermediate results are communicated at layer boundaries and computation continues back-and-forth until the entire network is completed. Client-aided HE has been shown to boast multiple benefits. By avoid modified activation functions, they allow for privacy-preserving inference on pre-trained networks. Furthermore, by sending data back to the client for some operations, client-aided HE regularly refreshes the ciphertext noise budget. Thus, client-aided HE does {\em not} limit DNN depth, and does {\em not} require extremely costly HE parameter settings. These benefits, however, come at the cost of increased client responsibility, especially for the abundant decryption and re-encryption operations. The client-side costs are the central impediment to the adoption of client-aided HE for IoT devices. CHOCO\xspace aims to break this participation barrier through encrypted algorithm optimization and architectural acceleration. \begin{comment} the encrypted offload device enlists the client to periodically perform operations in plaintext that would be especially costly in HE. An alternative to encrypted inference over entire networks, is the {\em client-aided} approach. In client-aided HE, the offload device enlists the client to periodically perform operations in plaintext that would be costly in HE. The layered structure of DNNs allows simple division of responsibility between linear and non-linear layers; the client performs all activation and pooling operations in plaintext. Prior work\cite{Gazelle,nGraphHE2} showed that, while costly, such a scheme is feasible, avoiding polynomial activations and allowing for privacy-preserving inference on pre-trained networks. By sending data back to the client for some operations, client-aided HE regularly refreshes the ciphertext noise budget in the process. Thus, client-aided HE does {\em not} limit DNN depth, and does {\em not} require extremely costly HE parameter settings. These benefits, however, come at the cost of increased communication to and computation on the client, especially encryption and decryption computations. The client-side costs are the central impediment to the success of client-aided HE. \end{comment} \begin{comment} An alternative to HE for an entire ML inference that avoids polynomial actiavtions is the {\em client-aided} approach. The offload HE computing device in client-aided HE enlists the client device to perform some operations on plaintext that are costly in HE. The layered structure of DNNs allows simple division of responsibility between linear and non-linear layers; the client performs all activation and pooling on plaintext. Prior work\cite{Gazelle,MiniONN,Chameleon,nGraphHE2} showed that, while costly, such a scheme is feasible, allowing for privacy-preserving inference on pre-trained networks. Client-aided HE allows for networks of arbitrary depth because its structure regularly sends data back to the client to perform some operations, refreshing the noise budget in the process. Client-aided HE is {\em not} depth limited, and does {\em not} require extremely costly HE parameter settings. These benefits, however, come at the cost of increased communication to and computation on the client, especially encryption and decryption computations. The client-side costs are the central impediment to the success of client-aided HE. CHOCO\xspace aims to make client-aided HE feasible and favorable for IoT devices through software and architectural optimization. \end{comment} \section{Conclusion}\label{sec:conclusion} In this work we present CHOCO\xspace, Client-aided HE for Opaque Compute Offloading\xspace, a client-optimized system for privacy-preserving collaborative computing that enables participation from resource-constrained IoT client devices. We show that selecting efficient encryption parameters is critical to the performance of such a system and present rotational redundancy as an encrypted algorithm optimization to allow for more efficient selections. Because of its ability to use smaller ciphertexts, CHOCO\xspace reduces communication overheads by up to three orders of magnitude over existing privacy-preserving DNN inference protocols. Motivated by the remaining client computation bottleneck, we introduce CHOCO-TACO\xspace, hardware support to accelerate HE encryption and decryption along the critical path. By exploiting parallelism and supporting local data storage, CHOCO-TACO\xspace boasts a 417$\times$\xspace speedup and a 603$\times$\xspace energy savings for a single encryption operation. When integrated back into the full CHOCO\xspace system this translates to a 121$\times$\xspace speedup on average for the client-side compute of DNN inference. For a reference implementation using Bluetooth communication, the combined hardware and software benefits from CHOCO-TACO\xspace make collaborative encrypted computing competitive against local compute with TFLite. A previously insurmountable task, this work, through its intentional client-aware optimizations, demonstrates that participation from resource-constrained IoT clients in collaborative encrypted computing is both feasible and even favorable. \section{Architectural Design Space Exploration}\label{sec:designspace} We explore the design space of the CHOCO-TACO\xspace hardware using a custom simulation infrastructure. The hardware model captures the effects of parallelism and pipelining and estimates time, power, area, and energy. We implemented individual hardware components in RTL and synthesized them with Cadence Genus, in a generic 45nm technology node. We modeled three-stage, pipelined multiplication and division units. To model memory, we used Destiny~\cite{destiny}, modeling SRAMs using its aggressive wire technology, optimized for read energy with 8-word, 64-byte, memory accesses. The access latency of our energy-optimized memories limits clock frequency, and we clocked the design at 100 MHz. \subsection{Performance Tradeoffs} We quantified the tradeoff of area, time, and power, with a systematic exploration of the CHOCO-TACO\xspace hardware design space. Using our simulator, we swept across 31,340 different architectural configurations. For each block in each module, the study varied the number of processing elements from one to 16 in powers of two, varying memory capacity commensurately, between 128 and 1024 bytes per RNS-parallel layer, except for NTT/INTT units, which require a fixed memory size. For each configuration, the study assessed power (leakage \& average dynamic), area, energy and compute time for a single encryption operation. Results from the design exploration are presented in Figure \ref{fig:designspace}. \par Overall, the design space shows significant variation in power and area, with a marked Pareto frontier along which power, time, and area balance. We selected an operating point for CHOCO-TACO\xspace by limiting power to 200 mW, and choosing the smallest design that had a run time within 1\% of the best run time (and energy). The chosen configuration has 19.3 mm$^2$\xspace area and consumes .1228 mJ\xspace to perform a single encryption in .66 ms\xspace. Figure \ref{fig:encryptarch} depicts this configuration graphically. \begin{figure}[!ht] \centering \includegraphics[width=\linewidth]{img/plot_designspace_wider.png} \caption{Design space for encryption hardware with respect to power, area, and energy. Parallelism tradeoffs are available in multiple dimensions at each stage of the encryption pipeline.} \label{fig:designspace} \end{figure} \subsection{CHOCO-TACO\xspace Makes Encryption Fast and Low-Energy}\label{sec:designspace:scalability} We evaluated the benefit in time and energy of CHOCO-TACO\xspace for encryption compared to a software encryption baseline, showing that across a range of HE parameter settings, hardware support provides substantial improvements. Figure~\ref{fig:scalability} shows data comparing software encryption to encryption with hardware acceleration. We evaluated the default HE parameter settings of SEAL, as well as CHOCO\xspace's parameter setting of (8192, 3), as presented in Table \ref{tab:paramselect}. The baseline is an average of 100 encryption operations running in software on our IMX6 hardware. Results are shown in Figure \ref{fig:scalability}. We omit baseline data for the (32768,16) parameter setting because the IMX6 board does not have enough memory to encrypt data for these parameters. Notably, this configuration with its prohibitive memory requirements is not uncommon in existing encrypted inference solutions \cite{CHET, LoLa} For the CHOCO\xspace (8192, 3) configuration, CHOCO-TACO\xspace provides an improvement over the software baseline of 417$\times$\xspace in time and 603$\times$\xspace in energy. The data also show a performance scaling trend, in that with hardware support, encryption time scales up directly with $N$, while software scales up with both $N$ and $k$. The scalability benefits comes from parallelism in the accelerator architecture: replicated modules process independent RNS residues in parallel. Decryption sees less benefit from hardware acceleration than encryption, with only a 125$\times$\xspace speedup over software for the (8192,3) CHOCO\xspace parameter selection. This decrease in speedup is contributed to limited parallelism because decryption operates on only a single polynomial at this parameter selection. Overall, CHOCO-TACO\xspace provides up to 1094$\times$\xspace and 648$\times$\xspace savings in time and energy, respectively, and providing consistent gains across HE parameter settings.\par \begin{figure}[!ht] \centering \includegraphics[width=\linewidth]{img/plot_cryptcompare.png} \caption{Logarithmic comparison of time \& energy of the CHOCO-TACO\xspace architecture presented in Figure \ref{fig:encryptarch} for varying encryption parameters versus a 528MHz device w/o dedicated hardware support.} \label{fig:scalability} \end{figure} \section{Evaluation}\label{sec:evaluation} We evaluate CHOCO\xspace to show the importance of algorithm optimization and architectural acceleration to the practicality of resource-constrained devices participating in client-aided privacy preserving computation. In accordance with prior work, we evaluate CHOCO\xspace using several large-scale machine learning models. We show reduction of communication overhead by up to three orders of magnitude over existing state of the art privacy-preserving DNN inference solutions. This is a direct result of the smaller parameter selections enabled by CHOCO\xspace optimizations, including rotational redundancy. Additionally, we show that the comprehensive hardware acceleration provided by CHOCO-TACO\xspace improves the runtime of active client computation by an additional \tacovsheax than dedicated NTT/INTT and dyadic product acceleration alone. Ultimately, we demonstrate that a complete CHOCO\xspace implementation using Bluetooth communication is comparable to local computation with TensrFlow Lite and, for large networks, reduces inference energy by up to 37\%. \subsection{Applications \& Methodology}\label{sec:eval:method} \subsubsection{Neural Network Selection}\label{sec:method:nn} We evaluate CHOCO\xspace for DNN inference, implementing client-aided, encrypted versions of the four image classification DNNs in Table \ref{tab:networks}. The Lenet variants operate on MNIST data~\cite{MNIST}, and the other, larger networks classify CIFAR-10 images~\cite{CIFAR10}. We trained the DNNs on unencrypted data using standard quantization-aware training in Tensorflow 2.2.0~\cite{Tensorflow2.2}. Evaluations are performed by running single-image inference through each network. \input{table/networks} \subsubsection{Client Modeling}\label{sec:method:system} We perform baseline client evaluations for software running on an NXP IMX6 evaluation kit with an ARM Cortex-A7 CPU at 528MHz, 32/128 kB of L1/L2 cache, and 4 GB DDR3L SDRAM. We estimate power and energy using an average power characterization (running Dhrystone) of 269.5 mW from the manufacturer's Application Note AN5345~\cite{imx6appnote}. We follow the methodology from Section \ref{sec:background} to estimate HEAX acceleration and use the hardware configuration from Section \ref{sec:designspace} to model CHOCO-TACO\xspace acceleration. \subsection{CHOCO\xspace Optimizations Reduce Communication}\label{sec:eval:mpccomm} The algorithmic optimizations presented in Section \ref{sec:system:algos}, including rotational redundancy, minimize noise growth to enable smaller parameter selections and correspondingly smaller ciphertexts. As discussed in Section \ref{sec:background:HE}, all of the networks included in Table \ref{tab:networks} can be evaluated in CHOCO\xspace using ciphertexts with no more than 8192 elements ($N=8192$). This is in contrast to existing HE solutions \cite{Gazelle, CHET, Cheetah, CryptoNets, LoLa, MiniONN} which commonly use ciphertexts of 16 or even 32 thousand elements. By eliminating unnecessary prime residues, CHOCO\xspace further reduces ciphertext size by another 50\% over SEAL's default parameters at $N=8192$. \begin{figure}[!ht] \centering \includegraphics[width=\linewidth]{img/plot_mpccomm.png} \caption{Comparison of total communication requirements to perform single image inference via the Lenet-5-Large (MNIST) and SqueezeNet (CIFAR-10) implementations in CHOCO\xspace and comparable networks in several state of the art privacy-preserving DNN protocols.} \label{fig:mpccomm} \end{figure} This reduction in ciphertext size directly translates to improvements in server runtime, client responsibility (Figure \ref{fig:clientwchoco}), and communication overhead. Figure \ref{fig:mpccomm} demonstrates the communication improvement over several state of the art privacy-preserving DNN protocols. Comparisons are evaluated between the CHOCO\xspace implementations of Lenet-5-Large and SqueezeNet and comparable networks performing MNIST and CIFAR-10 single-image inference, respectively. They include communication for both offline preprocessing and online computation. Although the networks evaluated in this work are substantially larger (more model parameters) in all cases, CHOCO\xspace outperforms existing protocols by up to three orders of magnitude. Because of the smaller parameter selections and more efficient ciphertext packing, benefits are witnessed even compared to LoLa\cite{LoLa}, a \emph{non}-client-aided encrypted inference protocol. For the most closely comparable protocol, namely Gazelle \cite{Gazelle}, CHOCO\xspace still provides a nearly $90\times$ improvement in communication overhead. This reduction dramatically reduces end-to-end latency, especially for IoT devices often communicating over lower bandwidth channels such as Bluetooth. \begin{figure}[!ht] \centering \includegraphics[width=\linewidth]{img/plot_breakdown_eval_defaultbase.png} \caption{Extension of client execution times shown in Figure \ref{fig:clientwntt} including CHOCO\xspace execution time breakdown.} \label{fig:clientwchoco} \end{figure} \subsection{CHOCO-TACO\xspace Accelerates Client Computation} We evaluate our hardware setup running single-image inference. We compare it to both the software optimized baseline and the baseline equipped with HEAX's NTT unit and Dyadic Multiply unit only. The software optimized baseline includes the algorithmic optimizations of CHOCO\xspace, namely rotational redundancy, and already demonstrates an average \avgswspeedup improvement over the SEAL baseline software with standard permutations and default parameter selections. A baseline that runs local inference on the ARM Cortex-A7 CPU using TensorFlow Lite (TFLite) software is also included as a lower-bound. We compute time and energy savings for active client computation by counting the number of encryption and decryption operations necessary to run inference for each network, and multiplying by the cost of each operation. We assume that the time for client computation and quantization, including ReLu and Pooling, stays the same for CHOCO\xspace as in the baseline. Figure \ref{fig:clientwchoco} reports the resulting execution times, breaking down the total time into its constituent components. The data show an average speedup of 121$\times$\xspace over the optimized software baseline for computations on the client, which is consistent with the 417$\times$\xspace and 125$\times$\xspace speedups observed for encryption and decryption, respectively. The data clearly show that encryption and decryption are the bottleneck on the client. NTT and Dyadic multiply only account for roughly 50\% of these operations. Thus, dedicated hardware units for these sub-operations alone, including but not limited to those provided by HEAX\cite{heax}, is not enough. The cryptographic operations for a client-aided protocol are still \avgheaxtimeovhd slower on average than computing the entire network locally with TF Lite. Comprehensive hardware acceleration for encryption and decryption is imperative. CHOCO-TACO\xspace recognizes this and uses an optimal allocation of compute resources, minimal buffering, tightly integrated memories, and multiple levels of parallelism to address the remaining 50\% of computation. With the acceleration provided by CHOCO-TACO\xspace, the time of active client computation on client-aided encrypted DNN inference becomes \avghwvstflite faster on average than local inference. \subsection{Full Implementation Comparable to Local Compute} To understand the end-to-end benefits, we study a reference implementation of CHOCO\xspace that communicates between the client and the offload using 10mW Bluetooth communication at 22 Mbps\cite{MECcomm}. Timing and energy results follow analytically from the data communication requirements, included in Table \ref{tab:networks}, of each network. End-to-end time and energy results are compared against the TFLite baseline in Figure \ref{fig:vstflite}. The data show that in a full implementation communication time begins to dominate. For low-power, low-data-rate protocols such as Bluetooth, communication presents a 24$\times$\xspace average time overhead compared to local compute. However, in small devices battery preservation often outweighs the need for fast compute. In energy consumption CHOCO\xspace is competitive with the TFLite baseline. For VGG, the largest and most complex of the DNNs evaluated, CHOCO\xspace earns up to a 37\%\xspace end-to-end decrease in energy consumption. \begin{comment} . Wifi communication offers a substantial improvement over Bluetooth, in the best case, coming within 2.1$\times$ the time of TFLite, end-to-end. CHOCO\xspace's energy consumption is more competitive with the TFLite baseline. CHOCO\xspace earns up to a {\em 37\%\xspace end-to-end decrease in energy consumption} running VGG, the largest and most complex of the DNNs evaluated. Communication presents a tradeoff: while wifi provides better run time performance, CHOCO\xspace using Bluetooth uses less energy. \end{comment} The data carry several main take-away points. The first take-away is that hardware acceleration, like CHOCO-TACO\xspace is essential to make feasible the CHOCO\xspace model for client-aided encrypted computing. Without our hardware acceleration --- even with the partial acceleration from HEAX~\cite{heax} --- encryption and decryption are the computing and energy bottleneck. Our hardware support accelerates the entire encryption and decryption computation, driving its cost down, eliminating it as the bottleneck, and making CHOCO\xspace feasible. Second, intentional client-aware optimizations are essential to bring privacy-preserving computation to resource-constrained IoT clients. Although communication remains a key bottleneck in time and energy, the algorithmic optimizations of CHOCO\xspace reduce this cost by up to three orders of magnitude. For the first time, this dramatic reduction makes client time and energy requirements competitive with local inference, even displaying the possibility of end-to-end gains. Third, the benefit of CHOCO-TACO\xspace depends on the structure of the computation: VGG sees substantial performance and energy improvements, while SqueezeNet sees a break-even or loss. We characterize this workload-dependent benefit in the next section. \begin{figure}[!ht] \centering \includegraphics[width=\linewidth]{img/plot_tflite.png} \caption{Client execution time \& energy for single image inference via local compute using TFLite software and offloaded compute using a full hardware-software reference implementation of CHOCO-TACO\xspace using Bluetooth communication.} \label{fig:vstflite} \end{figure} \subsection{Network Design} Different workloads see different benefit from CHOCO\xspace computation, which owes to differences in the rates of computation and communication required by these different workloads. CHOCO\xspace using Bluetooth communication for VGG sees a 37\%\xspace energy savings, while SqueezeNet sees a 82.5\%\xspace energy overhead. We performed a microbenchmarking study to evaluate this influence of workload structure. We constructed workloads with a variety of different convolutional DNN layers of different dimensions. The structure of the convolutional layers varies the number of multiply-accumulate (MAC) operations performed by each layer, as well as the amount of communication required to send and receive the ciphertexts that contain each layer's inputs. Figure~\ref{fig:layerstudy} shows the results of this study, plotting these microbenchmark convolution points, as well as each of the layers from VGG and from SqueezeNet. For the microbenchmark points, we varied image size from 2 to 32 by powers of two, varied image channel values from 32 to 512 by powers of 2. Following the implementations of SqueezeNet and VGG16, we used filter sizes of 3 or 1. The data show that workloads like VGG (which are likely to see its same energy benefits) are ones that maximize the number of MACs per MB of communication. Workloads like SqueezeNet (which are likely to see its break-even or costs) are ones that have fewer MACs per MB of communication. These data provide two main benefits in interpreting CHOCO\xspace. First, the data show that a quick analytical comparison of computation (MACs) versus communication (MBs) per layer helps an application designer decide if their DNN application will see an energy benefit in the CHOCO\xspace client-aided model. Second, the data point to an opportunity for future work, optimizing DNN structure to maximize compute per communication for the CHOCO\xspace model. \begin{figure}[!ht] \centering \includegraphics[width=0.95\linewidth]{img/plot_layerstudy.png} \caption{Communication vs Computation for Convolution Layers of a DNN with different parameters} \label{fig:layerstudy} \end{figure} \subsection{CHOCO\xspace with Model Privacy} CHOCO\xspace targets a use case with relaxed model security requirements, and optimizes for minimal client-side computation and communication. However, when model security is a strict necessity, many optimizations presented would also benefit a client participating in a hybrid HE-MPC protocol. Namely, rotational redundancy can be applied to any HE algorithms using windowed rotations to reduce noise growth and enable smaller parameter selections, thus providing similar improvements in computation and communication to other protocols. Additionally, in any client-aided model encryption and decryption will repeatedly fall along the critical path. Therefore, hardware acceleration such as that presented in CHOCO-TACO\xspace will continue to be beneficial in reducing the time and energy required for these critical operations. \section{Introduction}\label{sec:introduction} Data-producing client devices have a long history of decreasing in size and energy storage capability~\cite{wisp,capy,amulet,flikker} leading the way to trillions of tiny devices~\cite{arm-iot-trillion}. As clients scale down, the sophistication of computations on sensor data is scaling up, now often using complex machine learning (ML). With little total energy (potentially no battery) \cite{wisp, capy, amulet, flikker, permacam, camaroptera} and constrained compute and memory, a device is fundamentally limited in its local processing capability. A contrast to local compute is ``inference as a service'' offloading. A server houses a large collection of DNN models and processes data from many clients, without consuming client memory and energy resources for processing. Such centralized models are easy to evolve, requiring a single update to the model on the server, and avoiding the need to re-distribute an updated model to a large network of fielded client devices. {\em Data privacy} is the main barrier to realizing these benefits of offload computing: offloading exposes sensitive user data to a shared, potentially untrusted offload server. Recent work offers several options for privacy-preserving computation, including trusted execution environments (TEEs)\cite{SGX, nestedSGX, SecureEnclaves}, differential privacy (DP), multi-party computation (MPC)\cite{Soteria, XONN, EzPC}, and homomorphic encryption (HE) \cite{LoLa, CHET, CryptoNets, nGraphHE2}. Client-aided, hybrid HE-MPC protocols have seen recent success for DNN inference\cite{Gazelle, Delphi, MiniONN, Cheetah}, owing to their ability to use HE to protect user data and process linear operations (e.g. convolution) on encrypted data. Hybrid HE-MPC protocols obfuscate intermediate results of linear operations and send them to the client, which applies non-linear operations (e.g. activations) using MPC. HE-MPC imposes the high client-side cost of MPC to ensure privacy, not only of client data, but also model data. If an application requires only client data privacy, then HE-MPC needlessly imposes MPC's cost. Hybrid HE-MPC implementations of privacy-preserving DNN inference show promising results, but have largely neglected to address the added compute burden on the client. Existing solutions optimize HE-MPC parameters to the benefit of the centralized model server, for both performance and model privacy. Systems choose large ciphertext sizes (MBs), requiring {\em gigabytes} of client-server communication for a single inference. It is infeasible for resource-constrained client devices, to participate in such schemes. This work identifies the ``middle-ground'' between fully-local compute, with its associated resource requirements and inability to use centrally-managed models, and hybrid HE-MPC, with its prohibitive compute and communication costs imposed on client devices for model privacy. We propose Client-aided HE for Opaque Compute Offloading\xspace (CHOCO\xspace), a system for privacy-preserving computation that minimizes client costs. CHOCO\xspace targets applications that do not require model privacy, but that require strict client data privacy. CHOCO\xspace reduces client costs by {\em orders of magnitude} over HE-MPC, availing resource-constrained client devices of the benefits of privacy-preserving ML. CHOCO\xspace is client-aided HE without MPC, performing encrypted linear operations on the server and plaintext non-linear operations on the client. CHOCO\xspace introduces {\em rotational redundancy}, a new encrypted permutation algorithm that minimizes client communication and resource requirements. Additionally, a unique facet of client-aided HE motivates CHOCO\xspace: in a typical HE scheme, encryption and decryption happen once per computation, but in client-aided HE, encryption and decryption happen repeatedly on the critical path. We quantitatively show that the prohibitively high time and energy cost to encrypt and decrypt is the client's primary bottleneck. We propose Client-aided HE for Opaque Compute Offloading Through Accelerated Cryptographic Operations\xspace (CHOCO-TACO\xspace), a {\em comprehensive} hardware accelerator implementing all of each of these HE cryptographic primitives and virtually eliminating their time cost. Our evaluation of a complete hardware-software implementation demonstrates the benefits of a client-optimized system for privacy-preserving computation. Comparing to seven prior HE and/or MPC approaches, CHOCO\xspace reduces client communication costs by {\em orders of magnitude}, with improvements ranging from \mpccommmin--\mpccommmax. CHOCO-TACO\xspace's hardware acceleration improves client time and energy by \tacovssw compared to software and \tacovsheax compared to HEAX, which accelerates some (but not all) cryptographic sub-operations in hardware. Our results show that CHOCO\xspace makes client-privacy-preserving DNN inference comparably performant to local inference (using TFLite), sometimes even {\em exceeding} the performance of local inference, while avoiding the limitations of fully-local compute. Our main contributions are: \begin{itemize} \item CHOCO\xspace, a client-optimized system for privacy-preserving computation enabling encrypted computing for resource-constrained devices. \item Rotational redundancy, an encrypted permutation algorithm that minimizes client-server communication. \item CHOCO-TACO\xspace, a specialized hardware accelerator for client-side HE primitives. \item A full hardware-software implementation of client-aided privacy-preserving DNN inference that improves client costs by orders of magnitude compared to HE-MPC, performing comparably to local computation, while enjoying the benefits of model centralization. \end{itemize} \subsection{Motivation for Client-Aware Optimization}\label{sec:motivation} Client-aided privacy-preserving computation places an enormous burden on resource-constrained IoT client devices. The computational costs intrinsic to the client-aided model motivate our work on client-optimized software and hardware support. Interaction with the client is used to refresh the ciphertext noise budget and compute (relatively inexpensive) non-linear activation and pooling operations in plaintext. To do so, the system regularly exchanges data with the client to be decrypted, minimally computed on, and re-encrypted. This process has an important net effect on client responsibility: {\em abundant encryption and decryption operations are on the critical path}. These cryptographic operations in software are extremely computationally costly, even using a highly-optimized commercially available implementation~\cite{SEAL3.4}. We used our end-to-end software-only client-aided prototype to measure the cost of encryption and decryption in real encrypted neural network implementations. The software baseline system (which we describe in detail in Section \ref{sec:system}) utilizes existing server-optimized encrypted algorithms from \cite{Gazelle} and default parameter selections from \cite{SEAL3.4}. We measure the time to complete a single classification inference using each of four full-fledged DNN models (we describe our methodology in detail in~\ref{sec:eval:method}). Figure~\ref{fig:runtime} shows the time spent computing on the client, running encrypted computation on the offload, and communicating. As model size increases, communication and client computation cost increases. Encrypted computation cost at the offload device is consistently very time consuming. A rich and complementary line of work in server-optimized encrypted algorithms \cite{LoLa, Gazelle, nGraphHE2, Cheetah, MiniONN, Delphi} and hardware support \cite{heax, HEAWS, heat} is expected to continue reducing these costs, but the goal of our work is {\em not} to optimize offload-side HE. Instead, we focus on reducing the costs in time (and commensurately in energy) on the client side. Minimally addressed by prior work \cite{VLSIencrypt}, we approach this pursuit with specific attention toward realistic applications (e.g. parameters selections) and IoT devices (e.g. low-power). The compute costs on the client side are primarily the work of encryption and decryption. Figure~\ref{fig:clientwntt} shows a breakdown of time spent by the client during these DNN inference computations. Over 99\% of the client's time is HE operations, rather than ML operations (i.e., non-linear computation \& quantization). The plot also shows that existing hardware support for the Number Theoretic Transform (NTT) and Dyadic Multiplication, such as that provided in HEAX~\cite{heax}, is not sufficient to reduce the cost of encryption. We profiled the encryption and decryption computations in SEAL to determine that these operations only account for about 50\% of the total runtime. We optimistically modeled the benefit of hardware support for both sub-operations by scaling our software runtime accordingly by the speedup factor reported in the original HEAX paper. Even with the the modular benefits of HEAX and other offload-side accelerators \cite{heax, HEAWS, heat}, encryption and decryption time spent by the client remains dominant by orders of magnitude over ML computations. Often dismissed as insignificant one-time costs, encryption and decryption are on the critical path in the client-aided model and demand further optimization via client-optimized encrypted algorithms and comprehensive hardware support. In this work, we develop such support, making client-aided encrypted inference feasible and favorable for resource-constrained IoT clients. \begin{figure}[!ht] \centering \includegraphics[width=\linewidth]{img/plot_runtime_default.png} \caption{Complete runtime in seconds for single image inference on each network.} \label{fig:runtime} \end{figure} \begin{figure}[!ht] \centering \includegraphics[width=\linewidth]{img/plot_breakdown_motiv_defaultbase.png} \caption{Breakdown of client execution time in seconds using SEAL software with the default parameter settings on an unmodified ARM core and with hardware support for limited operations from \cite{heax}} \label{fig:clientwntt} \end{figure} \section{Related Works}\label{sec:rw} \subsection{Privacy Preserving DNN Inference}\label{sec:rw:ppdnn} ML offloading requires data privacy. Recent work optimized server-centric metrics, including usability \cite{CryptoNets, CHET}, training \cite{SecureML}, throughput (via batching) \cite{CryptoNets, DNNTexas, nGraphHE2}, latency (via packing) \cite{LoLa, CHET, Chameleon, Gazelle}, network complexity \cite{Gazelle, nGraphHE2, MiniONN}, performance \cite{heax, HEAWS, heat}, and model privacy \cite{MiniONN, Gazelle, Cheetah, EzPC, Delphi, Soteria, XONN}. Unlike prior work that focused on the server, to the best of our knowledge, CHOCO\xspace is the first work optimizing for resource-constrained client devices in client-aided HE. \begin{comment} In this context, ciphertext size is a key parameter, with its reduction reducing other costs of an HE scheme, including client costs, communication, and encrypted compute latency. Other work~\cite{CHET,LoLa} uses large ciphertexts to enable deeper arithmetic, which is not CHOCO\xspace's goal. Instead, CHOCO\xspace minimizes ciphertext size, by using rotational redundancy to eliminate encrypted operations. While CHOCO\xspace focuses on the client, better hardware will improve encrypted computation on the offload device~\cite{heax, HEAWS, heat}. \end{comment} \subsection{HE Hardware Support}\label{sec:rw:fhehw} Some prior work used hardware to accelerate kernels for lattice-based cryptography schemes~\cite{RLWEproc, RLWEsoftencrypt, VLSIRLWEproc, Ntt1}, including current state-of-art schemes~\cite{bfv1, bfv2, gentryFHE, ckks}. Some directly accelerate HE~\cite{heax, VLSIencrypt, HEAWS, bootstrapNTT}, focusing primarily on hardware NTT. As we show in Figure \ref{fig:clientwntt}, NTT acceleration helps but is insufficient. Our work is the first to {\em comprehensively} optimize HE cryptographic primitives, which is crucial in client-aided HE. Furthermore, unlike prior work targeting large, high-power GPUs \cite{cuHE, FVgpu, RNSBFVgpu} and FPGAs \cite{heax, HEAWS, VLSIencrypt, heat}, CHOCO\xspace opts for an ASIC implementation, directly addressing the need for low-power, energy-efficient operation at the client device. \begin{comment} \subsection{RNG Hardware}\label{sec:rw:rng} Ideas: Relation: Differences: \end{comment} \subsection{Hardware Security}\label{sec:rw:hwsecurity} \begin{comment} \cite{OISA, SecureEnclaves, SGX, nestedSGX, sidechanmetric, byteblacklist, DATS, sDIMM, ORAMdesign} Ideas: Hardware security work tries to hide the leakage of sensitive data through side channels or predictable memory accesses. Relation: Fully homorphic encryption also provides privacy guarantees for sensitive data. Differences: Privacy is guaranteed because the data itself is just a ciphertext. Privacy does not need to be provided by the microarchitecture because at that point the data looks like arbitrary bits anyway. Privacy is guaranteed through robust theoretical/mathematical guarantees of the encryption scheme... rather than threat specific michroarcitectural patches. Side channel threats with HE are significantly less, if not irrelevant, because functions operate on the full polynomials. Maybe you could still infer some info from rotations...? But it's not like individual encrypted byte accesses like ORAM addresses. Additionally, many of the threats that hardware security addresses are run against user code accessing user data. However, with FHE it is perfectly reasonable, and even intended, that the offload device run known code, even proprietary code... it is only the data that stays secret. Thus private user data can interact with public or proprietary hosted code. There is a decoupling available not accounted for by traditional hardware security. Trusted Execution Environments (TEEs)/Secure Enclaves/SGX also claim to provide encrypted computing by encrypting the data in memory, but that's only true for data still in memory. It's decrypted when it's residing/processing in the physical CPU. Still prone to side channels. DATS is getting closer to us, they allow control over your data even if someone else owns the program. \end{comment} Recent architectures offer privacy-preserving offloaded computation. Some techniques ensure data privacy, such as Trusted Execution Environments (TEEs) \cite{SGX, nestedSGX, SecureEnclaves} and memory access control and obfuscation \cite{ORAMdesign, byteblacklist, sDIMM, DATS}. While these prior techniques are vulnerable to side channel attacks, HE is not and data remain private while offloaded; HE is favorable thanks to its strong, proven privacy guarantee. Moreover, client-aided HE allows interactions between the client and server that are not allowed by TEEs~\cite{SGX}. \subsection{Low-Power ML Acceleration}\label{sec:rw:mlaccel} \begin{comment} \cite{EIE, Eyeriss} Ideas: If you're gonna build an accelerator, why not just accelerate/optimize the DNN inference directly. Relation: Another way to minimize client compute for performing DNN inference. Automatically private because all data is kept local. Differences: We minimize client burden by offloading the vast majority of it. Ideally zero responsibility/power/time/energy for the client, but communication overhead becomes a significant cost. However, our model also assumes/accomadates external proprietary models. The device might not even have access to the trained model... they just want to use it. Technically we don't hide the model because we're sending back intermediate results that could be reverse engineered but a) that can be addressed by adding garbled circuits if necessary and b) it doesn't necessarily have to be a proprietary/private model for it to be external... it may just be centrally trained/hosted/updated etc. Also, our accelerator can be used for any offloaded encrypted computation that you want. In particular, your private data may need to be centrally combined, say take the average, with other people's private data. This can be achieved with FHE (amongst other cryptographic protocols, again like garbled circuits(side thought, if we has had garbled circuits support you could address the private external model argument and also provide seamless support for either type of private computation offload.)), but nonetheless our accelerator can be used for that too (or anything else that people develop in the future... ideally something like encrypted search, retrieve, compare operations). You could also ammortize some costs (at least the initial communication) by having the server compute multiple networks on the same data. \end{comment} Client DNN inference performance is improving through software~\cite{Tensorflow2.2, PyTorch} and hardware optimization~\cite{Eyeriss, EIE}. One alternative to HE for private inference is to simply outfitting IoT devices with local ML acceleration and computing locally. However, as we argue in Section~\ref{sec:background}, local compute imposes tight resource limits and requires maintaining (i.e., updating) models on a potentially very large number of client devices, rather than an offload server's centralized model. In contrast, CHOCO\xspace targets encrypted offload of ML (and other) computations, imposing few restrictions on centrally managed models. Furthermore, CHOCO\xspace's support straightforwardly generalizes beyond ML: outfitting a device with a HE cryptographic acclerator, rather specialized DNN hardware, enables participating in \emph{any} client-aided, encrypted computation, not only ML. Encrypted applications research is an active, emerging area \cite{cryptorec, SecureML, HEsort, HEsort2, encryptQueries}; CHOCO-TACO\xspace benefits a broad set of existing and future encrypted applications. \begin{comment} This approach precludes the use of centrally managed models, CHOCO\xspace's intended use case. Furthermore, While plausible, such an approach lacks the generality provided by an encryption/decryption accelerator such as CHOCO-TACO\xspace. By supporting HE computations, CHOCO-TACO\xspace allows IoT devices to participate in arbitrary encrypted computations. This includes DNN inference where the model parameters are proprietary and/or externally hosted as well as statistical analysis computations that require the centralized interaction of private data between many clients. \end{comment} \section{Client-Optimized Client-Aided HE}\label{sec:system} CHOCO\xspace is a client-optimized system model and implementation for client-aided encrypted computation. The model assumes a resource-constrained client device and a more computationally capable, but untrusted, shared offload server. Typical of HE systems, we assume a semi-honest adversary model for the offload device: the adversary may be curious about the input data, but the system is trusted to faithfully perform the specified operations. In contrast to computationally expensive MPC protocols, CHOCO\xspace does not make any attempt to hide data on the offload device from the client, including pre-trained ML model data. Rather, the priority of CHOCO\xspace is to provide strong privacy guarantees for sensitive client data from IoT devices. \begin{comment} The model does not aim to hide data on the offload device from the client, including pre-trained ML model data used to process encrypted data received from the client. Our approach is a contrast to multi-party computation techniques~\cite{Gazelle} that hide data on the offload device at higher computational cost. \end{comment} \begin{figure}[!ht] \centering \includegraphics[width=\linewidth]{img/SystemFigure.pdf} \caption{System architecture for CHOCO\xspace. A resource-constrained sensor device and an untrusted offload device communicate via ciphertexts to collaboratively and securely process sensitive data.} \label{fig:sysdiagram} \end{figure} CHOCO\xspace implements client-aided HE offloading, partitioning work layer-by-layer between the client and the offload device. It optimizes cryptographic algorithms developed in prior work and tunes cryptographic parameters to make feasible the amount of client work performed. CHOCO\xspace introduces {\em rotational redundancy}, which is a new approach to permuting a vector of data encrypted in a cyphertext, which is useful for matrix manipulations such as convolution. The technique reduces the noise growth imposed by common rotation operations, allowing for smaller parameter selections and correspondingly smaller ciphertexts. \subsection{Selecting Efficient HE Parameters} \label{sec:system:params} Choosing appropriate HE parameters (as introduced in Section~\ref{sec:background:HE}) is a vital yet cumbersome step of encrypted application development \cite{CHET}. The selection of different parameters leads to different ciphertext size and noise characteristics, which, in turn, influence computation, encryption, decryption, and communication costs in the client-aided model. A system can achieve the same security level with different parameters (e.g. different ciphertext sizes). As such, CHOCO\xspace actively minimizes parameter selection via quantization and encrypted algorithm optimization. An HE scheme's plaintext modulus $t$ defines the number of bits in which to store each plaintext value within each element of an encrypted vector. CHOCO\xspace quantizes data into fewer bits before encrypting, because when tolerable, quantization to fewer bits allows the use of a smaller plaintext modulus. As shown by the varying $t$ values in Table \ref{tab:rotatenoise}, this increases a ciphertext's noise budget without changing its size, incentivizing the smallest possible $t$ that does not overflow~\cite{NNDistiller}. Our CHOCO\xspace prototype quantizes signed floating point input values to a 4-bit range. The sequentially applied HE operations of convolution then expand these values up to (but not over) our 23-bit prime coefficient modulus value. When a ciphertext is refreshed at layer boundaries the data is also requantized to 4-bits. \subsection{HE Algorithm Optimization} \label{sec:system:algos} CHOCO\xspace uses the cryptographic primitives from the SEAL encrypted computing library~\cite{SEAL3.4} to implement the HE algorithms developed in Gazelle~\cite{Gazelle}. These HE algorithms correspond to encrypted linear algebra operations used, for instance, in DNN inference. In CHOCO\xspace, all of these encrypted computations execute on the offload device. Introduced in Section~\ref{sec:background:algorithms}, Gazelle implements {\em packed} homomorphic algorithms which require permutations for rearranging input elements within an encrypted vector. In this way, elements are appropriately aligned for matrix manipulations such as 1-D, 2-D, and strided convolutions~\cite{Gazelle}. A key challenge presented by arbitrary permutations is that each requires a sequence of encrypted vector rotation and masking multiplication operations~\cite{HELibAlgs}. The depth of such operations quickly deplete the limited noise budget of a ciphertext. \begin{comment} This is particularly inefficient in the client-aided model which requires communication, decryption, and re-encryption to refresh a ciphertext's noise budget. Permutations implemented with rotations and multiplications are particularly inefficient in the client-aided model. Depleting the noise budget requires sending the encrypted vector back to the client to be decrypted, re-encrypted, and sent back to the offload device. \end{comment} \begin{figure}[!ht] \centering \includegraphics[width=0.9\linewidth]{img/rotations.pdf} \caption{Encrypted windowed rotation using arbitrary permutation (A) and rotational redundancy (B)} \label{fig:rotationalgs} \end{figure} Rotational redundancy is a new way to perform certain permutations on an encrypted vector. The technique targets {\em windowed rotation} permutations that rotate the elements in a sub-range of a vector, wrapping elements around from the top of the sub-range to the bottom and vice versa. This is in contrast to naturally supported HE rotations which can only rotate the vector in its entirety. Figure~\ref{fig:rotationalgs} shows a windowed rotation permutation on a ciphertext. The standard implementation (A) uses both rotations and masking multiplications, quickly exhausting the ciphertext's noise. In contrast, implementation (B), introduced in CHOCO\xspace, uses rotational redundancy to perform such a permutation with only a single relatively low-cost encrypted rotation. The key to rotational redundancy is to pack the window of values to be rotated with additional redundancy on either side {\em before} encryption. The redundancy contains the in-window elements that would ``wrap around'' when the permutation executes. After a series of windowed rotations and other operations, values outside the window of interest are simply ignored upon decryption. The amount of redundancy required for a windowed rotation corresponds to the amount of rotation to be performed, and, for the rotations used in convolutions, is typically a small fraction of the vector size. Rotational redundancy trades the use of more space in a vector for slower depletion of ciphertext noise, and in turn enables the use of smaller parameter selections. Table~\ref{tab:rotatenoise} quantifies these benefits. \input{table/rotatenoise2} In our neural network image classification implementation, a ciphertext vector is the concatenation of a vector per channel in the image. Executing inference requires windowed rotation within each channel. We pack images, adding rotational redundancy to each channel. By then packing channels into evenly spaced power-of-two slots in the ciphertext, the alignment of entire channels can also be achieved with simple encrypted rotations and no masking multiplies. Ultimately, convolution is achieved with optimal multiplication efficiency - a single multiplication of the weights with the inputs. \begin{comment} Like any HE operations, this multiplication and collection of rotation operations generate noise in the ciphertext. By the end of the encrypted layer computation, this noise entirely consumes one of the ciphertext prime residues. This residue, being useless in decryption, is discarded before communication the intermediate result ciphertext back to the client. \end{comment} After all algorithm and parameter optimizations, CHOCO\xspace utilizes freshly encrypted ciphertexts with only 2 prime residues, a 50\% reduction in ciphertext size from the SEAL default parameters for $N=8192$. Half of that improvement, the elimination of one entire residue, is from rotational redundancy alone. As discussed in Section \ref{sec:evaluation}, this reduction in ciphertext size has a direct and dramatic benefit in both computation and communication costs. \begin{comment} Additionally Gazelle's convolution algorithm requires swapping data of entire channels, all at once. CHOCO\xspace also accommodates these swap operations {\em without} masking multiplications. CHOCO\xspace packs input channel data into evenly spaced slots in a ciphertext. Each slot has a size that is the minimum power of two required to house an entire channel along with its rotational redundancy. Being slotted, channel boundaries align with ciphertext boundaries. The alignment allows using standard encrypted rotation (of the entire ciphertext) to avoid the need for masking multiplies. Ultimately, an entire convolution can be achieved with only one plaintext multiplication multiplication - the expected one to actually multiply the weights. This shallow arithmetic depth enables smaller parameter selections. \end{comment} \par
{'timestamp': '2021-03-12T02:27:02', 'yymm': '2103', 'arxiv_id': '2103.06743', 'language': 'en', 'url': 'https://arxiv.org/abs/2103.06743'}
arxiv
\section{Introduction} Software-defined networking (SDN) separates the control plane and data plane of network devices\cite{b1}, whose refined centralized control and network programmability bring unique advantages compared with traditional networks. Along with the explosive growth of network traffic and the emergence of network applications of big data, strictly centralized control planes can’t meet the requirements of the existing network, the semi-centralized or logically centralized control plane and the fully distributed control plane become the development trend of future enterprise network and carrier network architecture\cite{b2,b3}. The distributed deployment based on multiple controllers improves the scalability of the control plane and avoids single point failures in centralized deployment\cite{b4}. However, the distributed deployment method is likely to lead some controllers in the control plane to be overloaded while the other controllers are relatively idle\cite{b5,b6}. In order to make full use of the forwarding capability of the controller on the control plane, a SDN controller load balancing mechanism is proposed by migrating switch between controllers\cite{b7}. The selection algorithm selects a series of switch migration triples (the migrate-out domain, the migrate-in domain, and the migrating switch), then establishes an optimal migration model based on reinforcement learning in the switch migration decision phase \cite{b8}. From local optimization to total optimization, the final switch migration action can achieve the purpose of global load balancing. \section{Related Works} \subsection{Related Research Review} Research on SDN controller load balancing has been around for a long time, but the traditional switch migration mechanism can’t balance the relationship between load ratio deviation change and migration overhead between controllers. The survey found that the majority of the domestic and foreign literatures are based on switch migration when designing the load balancing mechanism. However, there are several problems in the migration of switches, staid migration selection objects, inefficient migration and migration conflicts. In order to solve the scalability problem of the SDN control plane better, the researchers have proposed a mechanism of the dynamic migration based on multiple controllers\cite{b9}, which avoids a single point of failure or excessive controller load when the controller is faulty or overloaded. A dynamic mapping can improve efficiency in managing traffic load variations\cite{b10,b11}, while the efficiency is increased, the probability of migration conflict and new overload is also great improved. A load balancing mechanism based on a strategy of load informing for multiple distributed controllers, load notifications bring a lot of communication overheads to the entire system \cite{b12}. Starting from the latest status of the research at home and abroad, this paper attempts to combine the reduction of the overall load deviation coefficient with the migration efficiency, which dynamically migrates switches in a distributed deployment control platform to avoid single point failure caused by controller overload, the SDN controller load balancing mechanism based on reinforcement learning achieves the following three objectives: (\romannumeral1). better load balancing, (\romannumeral2). without migration conflicts, (\romannumeral3). without new overload. \subsection{Load Balancing Mechanism} When a controller generates an overload, it is generally because a large number of switches cannot find a corresponding flow entry for the newly arrived packet\cite{b13}, thereby send a packet-in message to the default controller. This paper proposes a load balancing mechanism for the control plane. Each controller of the control plane shares the same network view and achieves load balancing through dynamic migration of the switch. The dynamic load balancing diagram is shown in Fig. 1, when a controller in the control plane (Controller ${C_1}$) has an overload trend, it will enter the switch migration phase, and part of the switch of the overload controller (Switch ${S_5}$ and Switch ${S_9}$) are migrating to the relatively idle controller (Controller ${C_2}$ and Controller ${C_3}$ ). \begin{figure}[htbp] \centering \includegraphics[height=8.2035cm,width=9cm]{1.pdf} \caption{Controller load diagram.} \end{figure} As the existing network environment is very complex, the real-time load ratio of the controller will change as the complex network environment changes\cite{b6}. The load balancing mechanism adopted by the SDN control platform shouldn’t simply change the load value of each controller. By obtaining the packet-in message processing situation of the controller\cite{b4}, the receiving rate of the controller's packet-in message, combined with the load capacity of each controller, the real-time load ratio of the controller can obtain. When the real-time load ratio of one or several controllers is greater than the rate of the mean load of all controllers so that the equilibrium state is broken, thereby going the switch migration phase. Under the constraint of without migration conflict and load capacity\cite{b13}, part of the switches of the overload controller is migrating to the relatively idle controller. Fig. 2 is the load balancing mechanism designed in this paper. \begin{figure}[htbp] \centering \includegraphics[height=8.5735cm,width=9cm]{2.pdf} \caption{Load balancing mechanism.} \end{figure} In the following chapters, the third chapter introduces the design of switch migration, including the judgment of SDN controller load balancing, switch migration efficiency and the selection process of the switch migration domain and migrating switch. The fourth chapter introduces the optimal migration model and the switch migration decision process based on reinforcement learning. The fifth chapter designs a targeted simulation experiment facing the load balancing mechanism proposed in this paper, gives and analyzes the results in comparison experimental. The sixth chapter gives a brief summary of the full text. \section{Switch Migration Design} Through the switch migration, the load ratio of the controller with overloading trend can be reduced\cite{b11,b12}, thereby reducing the probability of occurrence of the overloaded controller and maximizing the utilization of the resources in current controller to meet the service request from the switch. Controller’s load, controller’s load ratio, discrete coefficient and migration efficiency are defined in a series of switch migration models during the switch migration phase. The selection algorithms of migration domain and migrating switch are designed to select the migration triples, which can be used in the next step of the reinforcement learning process. Some of the mathematical symbols used in this section and their meanings are shown in Table \uppercase\expandafter{\romannumeral1}: \begin{table}[htbp] \caption{The Meaning of the Symbol} \begin{center} \begin{tabular}{cl} \hline \textbf{Symbol} & \textbf{Meaning}\\ \hline ${L_{{C_i}}}$ & the load of the controller $C_i$\\ ${C_{{C_i}}}$ & the load capacity of the controller $C_i$ \\ ${R_{{C_i}}}$ & the load ratio of the controller $C_i$ \\ ${L_{{S_k}}}$ & the packet-in message sending rate of the switch $S_k$ \\ $R$ & mean load ratio of all controllers \\ $D$ & load ratio deviation coefficient between two controllers \\ $E$ & migrate switch efficiency between controllers \\ ${H_{{S_k}}}$ & number of hops between the switch and the controller\\ \hline \end{tabular} \label{tab1} \end{center} \end{table} \subsection{Load Balancing} \paragraph{Controller’s Load} The load of the SDN controller mainly comes from the following aspects\cite{b6,b10,b12}: (\romannumeral1). The switch sends packet-in message to the controller while it can't find the corresponding forwarding flow entry. (\romannumeral2). Controllers communicate with each other in the control plane. (\romannumeral3). The controller installs flow entries for the switch. (\romannumeral4). All controllers maintain and share the same network view of the entire control platform. The number of packet-in messages received by the controller is the primary source of controller load, this article simplifies the controller load to the sum of the controller's packet-in message rates. \begin{equation} L_{C_{i}} = {\sum_{k = 1}^{l}L_{S_{k}}} \end{equation} \paragraph{Controller’s Load Ratio} Different controllers have different CPU performance, number of processors, memory size, etc., which results in different load capacities. The controllers’ load ratio $R_{C_i}$ is the ratio of the controller's real-time load $L_{C_i}$ to the controller's load capacity $C_{C_i}$: \begin{equation} R_{C_{i}} = {L_{C_{i}}/C_{C_{i}}} \end{equation} Obviously, the mean load ratio between two of the controllers: \begin{equation} \overset{-}{R_{(C_{i},~C_{j})}} = {\left. \left( R \right._{C_{i}} + R_{C_{j}} \right)/2} \end{equation} Furthermore, the mean load ratio of all controllers: \begin{equation} \overset{-}{R} = {\sum_{i = 1}^{n}{R_{C_{i}}/n}} \end{equation} \paragraph{Load Balancing Between Controllers} The discrete coefficient is used to describe the degree of discrete of the controller’s load ratio and the mean load ratio between controllers. Here, the two controller discrete coefficients can be defined as: \begin{equation} D_{{(C}_{i},~C_{j})} = {\left( \sqrt{{\sum\limits_{k = i,~j}\left( {R_{C_{k}} - \overset{-}{R_{C_{i},~C_{j}}}} \right)^{2}}/2} \right)/\overset{-}{R_{C_{i},~C_{j}}}} \end{equation} Similarly, it is extended to multiple controllers with discrete coefficients: \begin{equation} D = {\sqrt{\left( {{\sum_{i = 1}^{n}\left( {R_{C_{i}} - \overset{-}{R}} \right)^{2}}/n} \right)}/\overset{-}{R}} \end{equation} The discrete coefficient of all controllers is defined as the degree of the load balance of the entire control plane, which will become one of the indicators for evaluating the performance of the selection algorithm. The smaller the value is, the better the load balancing of the control plane. \subsection{Switch Migration Efficiency} If the switch is migrating between controllers, there will be migration overhead. Because the hop count $H_{S_k}$ between the switch and the controller is different, the load $L_{S_k}$ of the switch to the controller is different, the migration efficiency is expressed as follows. \begin{equation} E_{{(C}_{i},~S_{k})} = {L_{S_{k}}/H_{S_{k}}} \end{equation} The mean efficiency of migration in the next set of switches from the out-migration controller $C_i$ is as follows: \begin{equation} \left\{ \begin{matrix} \overset{-}{E_{({C_{i},S})}} = {\sum_{k = 1}^{l}{L_{S_{k}}/H_{S_{k}}}} \\ {S = \left\{ {S_{1},S_{2},\cdots\cdots S_{l}} \right\},~~\forall S_{k} \in C_{i}} \\ \end{matrix} \right. \end{equation} Where $S_{k} \in C_{i}$ is represented here as the controller of the switch $S_k$ is $C_i$. \subsection{Migration Tuples Selection} \paragraph{Migration domain selection} In a real-time changing network environment, the load of each controller also changes fast. The traditional method tends to strip the selection process of the out-migration domain and the in-migration domain, which introduces the probability of controller overload to some extents, while it is also easy to bring migration conflicts and migration jitter in the control plane. Next, a new selection algorithm will be proposed and which will add anti-collision mechanism in the judgment part to avoid the two consequences of the commonly bad migration. The switch migration domain selection algorithm is as follows: \begin{algorithm}[H] \caption{Selection Algorithm of Migration Domain} \hspace*{0.02in} {\bf Input:} Controllers’ load ratio $R = \left\{ {R_{C_{1}},R_{C_{2}},\cdots\cdots R_{C_{n}}} \right\}$,\\ \hspace*{0.20in} Mean load ratio of all controllers $\overset{-}{R}$,\\ \hspace*{0.20in} Discrete coefficient between the controllers $D$\\ \hspace*{0.02in} {\bf Output:} Out-migration domain $O$, in-migration domain $I$,\\ \hspace*{0.20in} migration queue $Q$\\ \hspace*{0.02in} {\bf Initialization:} Set $O$, $I$ and $Q$ to empty sets \begin{algorithmic}[1] \FOR{$R_{C_{i}},~R_{C_{j}} \in R = \left\{ {R_{C_{1}},R_{C_{2}},\cdots\cdots R_{C_{n}}} \right\}$} \STATE Calculate the discrete coefficients $D_{C_{i},~C_{j}}$ \IF{$D_{C_{i},C_{j}} > D~\&\&~R_{C_{i}} > \overset{-}{R}~\&\&~R_{C_{i}} > R_{C_{j}}$} \STATE Add $C_{i}$ to the out-migration domain $O$ \STATE Add $C_{j}$ to the in-migration domain $I$ \ENDIF \IF{$D_{C_{i},C_{j}} < D~\&\&~R_{C_{i}} < \overset{-}{R}~\&\&~R_{C_{i}} < R_{C_{j}}$} \STATE Add $C_{j}$ to the out-migration domain $O$ \STATE Add $C_{i}$ to the in-migration domain $I$ \ENDIF \STATE Add $\left( {C_{i},C_{j}} \right)$ to the migration queue $Q$ \ENDFOR \end{algorithmic} \end{algorithm} \paragraph{Migration switch selection} For each migration queue $Q$ that will be migrating, the migration switch selected by the algorithm is defined as the fastest reduction of the factor of the load ratio under the best efficiency $E_{C_i,S_k}$ in migration. The switches under the out-migration controller are sorted according to the migration efficiency, the higher the efficiency of the switch migration, the higher the possibility of being selected. The constraints for selecting a switch for migration are as follows: \begin{equation} \left\{ \begin{matrix} {R'}_{C_{x}} = R_{C_{x}} \mp {\sum_{k = 1}^{l}{{L'}_{{S'}_{k}} \times \left( {C_{i}/C_{j}} \right)}}\\ D_{{(C}_{i},~C_{j})} = {\left( \sqrt{{\sum\limits_{k = i,~j}\left( {{R'}_{C_{x}} - \overset{-}{R_{C_{i},~C_{j}}}} \right)^{2}}/2} \right)/\overset{-}{R_{C_{i},~C_{j}}}} \\ {argmin~D_{{(C}_{i},~C_{j})}} \\ \forall E_{({C_{i},{S^{'}}_{k}})} \geq \overset{-}{E_{({C_{i},S})}}\\ \forall E_{({C_{i},{S^{'}}_{k}})} \geq E_{({C_{i},{S^{'}}_{k + 1}})} \\ {x = i~or~j} \\ \end{matrix} \right. \end{equation} A switch combination managed by the out-migration controller, whose migration efficiency of each switch has greater than the average efficiency in migration and arranged by size, which is finding out by the selection algorithm. It is the optimal migration switch combination when it maximizes the reduction of the discrete coefficients between controllers. The specific algorithm of selecting migrating switch is shown as follows: \begin{algorithm}[H] \caption{Selection Algorithm of Migrating Switch } \hspace*{0.02in} {\bf Input:} Migration queue $Q$\\ \hspace*{0.02in} {\bf Output:} Switch collection $S'$, migration tuples $T$\\ \hspace*{0.02in} {\bf Initialization:} Set $T$ to an empty set, $n=0$ \begin{algorithmic}[1] \FOR{$q = \left\{ {C_{i},C_{j}} \right\} \in Q$} \FOR{$S_{k} \in C_{i}$} \STATE Calculate $E_{S_{k}}$ \STATE $\left. E_{C_{i},S}\leftarrow E_{C_{i},S} + E_{C_{i},S_{k}},~L\leftarrow E_{C_{i},S_{k}} \right.$ \ENDFOR \STATE sort L $//$ Sort the migration efficiency in $L$ \STATE $\left. \overset{-}{E_{C_{i},S}}\leftarrow{E_{C_{i},S}/n},~k = 1 \right.$ \WHILE{$E_{C_{i},S} \in L~\&\&~S_{k} \in S$} \STATE Calculate ${R'}_{C_{i}}$, ${R'}_{C_{j}}$ and ${D'}_{C_{i},C_{j}}$ \IF{$E_{C_{i},S_{k}} \geq \overset{-}{E_{C_{i},S}}~\&\&~{D^{'}}_{C_{i},C_{j}} < temp$} \STATE $k + +$, $\left. temp\leftarrow{D^{'}}_{C_{i},C_{j}} \right.$, add $S_k$ to S' \ELSE \STATE break $//$ Jump out of the loop \ENDIF \ENDWHILE \STATE $\left. T\leftarrow S' \right.$ $//$ Add collection to the tuples \ENDFOR \end{algorithmic} \end{algorithm} \section{Switch Migration Decision} \subsection{Optimal Switch Migration Model} With constantly searching strategy, an optimal migration model with the highest efficiency of switch migration and without migration conflicts is composed of the migration queue obtained in the previous chapter. When the migration efficiency can’t be optimized by using the greedy strategy only to make decisions\cite{b8,b14}, exploring non-greedy situations at the case of probability in each decision and combining $\varepsilon $-greedy and decision-making to select migration triples, so as to obtain global optimal switch migration decision based on reinforcement learning\cite{b15,b16}. Fig. 3 is the optimal model of switch migration. \begin{figure}[htbp] \centering \includegraphics[height=6.0524cm,width=9cm]{3.pdf} \caption{Optimal migration model based on reinforcement learning.} \end{figure} In this case, the decision-making process in reinforcement learning is defined as taking action based on the current state to obtain the return value as the core driving force for optimizing the migration model\cite{b17,b18}. Specifically, the migration domain is the state space to which the current state belongs, and the switch migration is the action taken. The return value of each migration triples is as follows: \begin{equation} R_{i,j} = {\left( {{D'}_{i,j} - D_{i,j}} \right)/{\sum_{t = 1}^{k}{Cost\left( S_{t} \right)}}} \end{equation} In the expression of the return value\cite{b16}, the numerator is the degree of change of the load balancing after migration, and the denominator is the sum of the migration costs of multiple groups of migrations in the migration decision. The larger the load balancing rate of reduction value is, the less the overhead and the greater the return value. The value of $Q\left( s,a \right)$ is iteratively updated by selecting the largest item in each row of the $\varepsilon$ greedy strategy, and Q is an evaluation matrix. The iteratively updated method of the valuation matrix is shown as follows: \begin{equation} \begin{split} Q{(s,a)_{t + 1}} = &Q{(s,a)_t} + \alpha (\gamma + \gamma \times {max}_{a}Q{(s',a')_t} \\ &- Q{(s,a)_t}) \end{split} \end{equation} The sum of the current return value $\gamma$ and the next largest maximum value ${max}_{a}Q\left( {s^{'},a'} \right)_{t}$ in the memory is used as the expected value of the valuation, and the incremental iterative learning is performed by using the difference between the expected expectation and the true estimate, so as to obtain the value of $Q\left( {s,a} \right)_{t}$ in the ${(t + 1)^{th}}$ round. It is a number greater than 0 and less than 1, the lager the value of the learning ratio R is, the smaller the result in previous training is, while the value of 0 means that the result in previous training is not considered. In addition, the greater the value of the discount factor $\gamma$ is, the greater consideration of long-term benefits, the smaller the size of the immediate consideration. In order to select the optimal set of migration triplet $\left\{ {C_{i},C_{j},S_{k}} \right\}$, the matrix $R$ with reward values iteratively updates the valuation matrix until it is stable, and the group with the largest value in $Q$ is the final switch migration set, which can guarantee the optimal migration efficiency and avoid migration conflicts. \subsection{Migration Decision Based on Reinforcement Learning} The core principle of reinforcement learning is applied to the SDN switch migration decision process, and an optimal migration model based on reinforcement learning is established, where the migration decision is represented by the migration action derived from reinforcement learning. Specifically, the process in migration decision based on reinforcement learning is as follows\cite{b16,b18}: \subsubsection{Initialization phase} Initialize the set $A$ in migration action, the evaluation matrix $Q$ and the reward matrix $R$, where all values in the $Q$ are initialized to 1. \subsubsection{Reinforcement learning phase} For each potential out-migration domain, it is necessary to determine in advance whether the in-migration domain in the migration triple has been added to the migration target in migration action. \paragraph{}Difference in load rate between two controllers in the migration matrix and the properties of the switches that are migrating in one migration loop, which will cause different real-time reward value $R$. In the next step, the migration matrix is searched to calculate the return value of the migration triplet, and the in-migration domain $C_{in}$ with the largest value is selected as the migration target of the out-migration domain $C_{out}$ in this phase. \paragraph{}The probability of selecting the largest estimate in round $t$ is $\varepsilon$, while the probability of exploring other valuations for its iterative operation is 1-$\varepsilon$, the migration triplet corresponding to the maximum estimate selected by probability $\varepsilon$ during this period will be used in the next step. \paragraph{}After the migration triple selected in the $t$-th iteration, the maximum valuation $Q\left( {{C'}_{out},{C'}_{in}} \right)_{t}$ of the next migration triple $\left\{ {{C'}_{i},{C'}_{j},{S'}_{k}} \right\}$ is selected by the maximum greedy strategy, and the expected value $r + r \times Q\left( {{C'}_{out},{C'}_{in}} \right)_{t}$ of the maximum estimate $Q\left( {C_{out},C_{in}} \right)_{t}$ is calculated by the discount factor $\gamma$. The iterative update formula is as follows: \begin{equation} \begin{split} Q{({C_{out}},{C_{in}})_{t + 1}} \leftarrow &Q{({C_{out}},{C_{in}})_t} + \alpha (\gamma + \gamma \\ &\times Q{({C_{out}},{C_{in}})_t} - Q{({C_{out}},{C_{in}})_t}) \end{split} \end{equation} The evaluation matrix $Q$ is calculated in the current state, if it is larger than the original value, the global migration optimal constraint is satisfied, otherwise, the other migration triplet will be selected; \paragraph{}Add the migration triplet $\left\{ {C_{i},C_{j},S_{k}} \right\}$ to the migration set $A$, and simultaneously update the migration state of the candidate migration matrix, and remove the migration set; \paragraph{}Returning to loop a), the migration action selection process based on reinforcement learning in this phase, which loops in turn until the evaluation matrix Q in loop c) is stable and no longer changes. \subsubsection{Ending phase} Through the reinforcement learning phase, the migration set $A$ is selected to perform the final switch migration. \section{Simulation Analysis} \subsection{Simulation Experiment Environment} In the simulation experiment environment of this paper, the performance of load balancing mechanism is analyzed by testing the multi-controller cluster. The controller in control plane is the open source controller RYU \cite{b19}, which is implemented by the Python language and supports all the mainstream Openflow protocols \cite{b20}. It can quickly develop the control that satisfies the load balancing mechanism this article. Mininet \cite{b21} build the network topology of the entire simulation experiment environment, and the experimental platform is a virtual machine, whose type is Ubuntu 16.04. Four RYU controllers C1, C2, C3, and C4 are deployed in the controller cluster, and 12 OpenvSwitch \cite{b22} are connected to four controllers. Each switch can connect one or more hosts. In the experiment, the host will use the iPerf \cite{b23} to simulate the data packet with different rates, and the simulation experiment topology is as follows in Fig. 4. \begin{figure}[htbp] \centering \includegraphics[height=6.5624cm,width=9.2cm]{4.pdf} \caption{Simulation experiment topology.} \end{figure} In the above environment, the load measurement module on the Mininet platform can measure the number of packet-in events sent to the controller per unit time, that is, the ratio of packet-in event sending, and the number of hops from the switch to the controller is defined in the topology file of the Mininet platform. \subsection{Simulation Experiment Analysis} In order to fully analyze the performance of the switch migration mechanism designed in this paper, a comparative experiment was specially added to the simulation experiment. According to the load balancing mechanism based on reinforcement learning (RL-LBM) proposed in this paper, two typical mechanisms of load balancing are selected as the comparison objects. One typical mechanism (DC-LBM) is to preferentially migrate the switch with the highest transmission rate of the packet-in event under the overload controller based on the deviation coefficient of the controllers' load rate. Another representative mechanism (MMO-LBM) is the load balancing of switch migration based on minimum migration overhead, that the overload controller migrates a part of the switch to the neighbor controller with the fewest hops to achieves. Compared with the above two comparison mechanisms, the experimental results show that the load balancing mechanism designed in this paper can effectively migrate the switch under the controller with trend overload to the relatively idle controller, which improves the utilization ratio of controllers' resource, reduces the response time of the packet-in event of the switch and improves the load balancing effect in the whole network environment. At the same time, the migration overhead caused by switch migration does not bring extra burden to the whole system, which verifies the superiority of the mechanism in this paper. \paragraph{Load balancing Ratio} When different mechanisms for load balancing are compared together, the ratio in load balancing is a key indicator to measure them, and each of them aims to reduce the rate in load balancing of the control plane. With the rate in different transmission of the iPref, the rate of load balancing of the three mechanisms in the same period is as follows in Fig. 5. \begin{figure}[htbp] \centering \includegraphics[height=7.2343cm,width=9cm]{5.pdf} \caption{Load balancing rate in control plane.} \end{figure} After using the mechanism of switch migration, the rate in load balancing of each controller is improved. As the packet-in message transmission rate continues to increase, whose value is reduced due to the constraints of the controller’s capability. \paragraph{Packet-in Processing Delay} When the switch migration is initiated, the controller in out-migration domain sends a flow-mod message to the controller in in-migration domain, and the management control of the switch will change when it arrives. Due to the change of the transmission link and the installation time of the new flow table, the delay in processing the packet-in message will inevitably increase. The specific performance of the various mechanisms is as follows: \begin{figure}[htbp] \centering \includegraphics[height=7.1721cm,width=9cm]{6.pdf} \caption{Processing delay of the packet-in message.} \end{figure} According to the experiment, the processing delay of the packet-in increases, as the transmission rate of the packet-in message increases. It can be seen from Fig. 6 that the switch-controller message response delay of the RL-LBM mechanism is reduced by 17.8$\%$ on average compared with the MMO-LBM. \paragraph{Packet-in Processing Delay} Switch migration inevitably brings migration overhead to the entire system, whose size is directly related to the number of migrations and the number of controller-to-switch hops, and continuous switch migration increases migration overhead with the operation of the load balancing mechanism. Fig. 7 shows the migration overhead of various mechanisms: \begin{figure}[htbp] \centering \includegraphics[height=6.827cm,width=9cm]{7.pdf} \caption{Switch migration overhead.} \end{figure} Under the same network conditions, switch action taken by different load balancing mechanisms will directly affect the overhead of the switch migration, which includes the controller's traffic overhead and controller synchronization delay. The experimental results in Fig. 7 show that the RL-LBM mechanism has obvious advantages over the other two, whether in a single controller or the entire system in terms of migration overhead. \section{Conclusion} This paper designs a selection algorithm in the phase of switch migration, which is used to select the out-migration domain, the in-migration domain and the switch to be migrating, as combined into one switch migration triplet. By using reinforcement learning, the load balancing mechanism chooses a set of switch migration queues that can achieve global optimization from local optimization. Simulation experimental results illustrate that the mechanism can make full use of the controllers' resources, quickly balance the load between controllers, reduce unnecessary migration overhead and get a faster response rate of the packet-in request. \section*{Acknowledgment} This work was supported in part by the National Science and Technology Major Project of the Ministry of Science and Technology of China under Grant 2017ZX03001015, Grant 2018ZX03001015 and Grant 2018ZX03001021.
{'timestamp': '2021-03-12T02:18:44', 'yymm': '2103', 'arxiv_id': '2103.06579', 'language': 'en', 'url': 'https://arxiv.org/abs/2103.06579'}
arxiv
\section{Introduction} \label{s:intro} \input{01-intro} \section{Related Work} \input{02-rw} \section{\textsc{DebIE}: System Description} \input{03-system_overview} \section{Ethical Considerations} \input{0x-ethics} \section{Conclusion} \input{06-conclusion} \section*{Acknowledgments} Anne Lauscher and Goran Glavaš are supported by the Eliteprogramm of the Baden-Württemberg Stiftung (AGREE grant). We would like to thank the anonymous reviewers for their helpful comments. \subsection{Implicit and Explicit Bias Specifications} \textsc{DebIE} supports measuring of \textit{implicit} or \textit{explicit} biases for a given word embedding space and, respectively, implicit or explicit \textit{debiasing} of the given space. Both implicit bias specifications $B_I$ and explicit bias specifications $B_E$ specify two sets of \textit{target} terms, $T_1$ and $T_2$ that capture the dimension of the bias. For example, if measuring a \textit{gender} bias, $T_1$ would contain male terms (e.g., \textit{man}, \textit{father}) and $T_2$ female terms (e.g., \textit{woman}, \textit{girl}, \textit{grandma}).\footnote{The bias measures implemented in \textsc{DebIE} do not require the terms between the target lists to be paired. Accordingly, the two lists also do not need to be of the same length.} While an implicit bias specification is fully specified with the two target lists, $B_I = (T_1, T_2)$, an explicit specification additionally requires two sets of attributes $A_1$ and $A_2$, $B_E = (T_1, T_2, A_1, A_2)$, capturing the groups of terms towards which the target groups are expected to exhibit significantly different level of association. For example, for a gender bias, one would expect male terms to be more strongly associated with career terms (e.g., $A_1$ could contain terms like \textit{programmer}), whereas female terms could be closer to family-related terms (e.g., $A_2$ could contain terms like \textit{homemaker}). The input for \textsc{DebIE} consists of an embedding space $\mathbf{X} \in \mathbb{R}^d$ and a bias specification, (implicit or explicit). Explicit debiasing methods (i.e., methods that operate on explicit bias specifications) cannot be executed when the provided bias specification is implicit ($B_I$).\footnote{Conversely, implicit debiasing methods, i.e., ones that require only $T_1$ and $T_2$, can be applied if an explicit specification is provided. In that case, we simply convert $B_E$ to $B_I$ by discarding the provided attribute sets.} \subsection{Bias Measures} \label{sec:measures} \textsc{DebIE} provides three measures that capture explicit bias (i.e., apply only if an explicit bias specification is provided), and two tests that measure implicit bias. Because debiasing methods (see \S\ref{sec:debiasing}) make perturbations to the embedding space, we additionally couple the bias tests with measures of semantic quality of the distributional space. \vspace{0.5em} \noindent\textbf{Word Embedding Association Test (WEAT).} Given an explicit bias test specification $B_E=(T_1,T_2,A_1,A_2)$, WEAT~\citep{Caliskan2017} computes the effect size quantifying the amount of bias as follows \small{ \begin{equation*} s(T_1, T_2, A_1, A_2) = \hspace{-0.5em}\sum_{t_1 \in T_1}{\hspace{-0.3em}s(t_1, A_1, A_2)} - \hspace{-0.5em}\sum_{t_2 \in T_2}{\hspace{-0.3em}s(t_2, A_1, A_2)}, \end{equation*}} \vspace{-1em} \normalsize \noindent with associative difference of term $t$ given as: \small{ \begin{equation*} s(t, A_1, A_2) \hspace{-0.1em}=\hspace{-0.1em} \frac{1}{|A_1|}\sum_{a_1 \in A_1}{\hspace{-0.5em}\textnormal{cos}(\mathbf{t}, \mathbf{a_1})} - \frac{1}{|A_2|}\sum_{a_2 \in A_2}{\hspace{-0.5em}\textnormal{cos}(\mathbf{t}, \mathbf{a_2})}, \end{equation*}} \normalsize \noindent with $\mathbf{t}$ as the word embedding of the target term $t$ and $\mathit{cos}$ as the cosine of the angle between the two vectors. To estimate the significance of the effect size, we follow \citet{Caliskan2017} and compute the non-parametric permutation test in which the $s(T_1, T_2, A_1, A_2)$ is compared to $s(X_1, X_2, A_1, A_2)$, where ($X_1$, $X_2$) denotes a random, equally-sized split of terms from $T_1 \cup T_2$. \vspace{0.5em} \noindent\textbf{Embedding Coherence Test (ECT).} Given an explicit bias specification with a single attribute set $B_E = (T_1, T_2, A)$ with $A=A_1\cup A_2$, ECT~\citep{Dev2019} quantifies the presence of the bias as the (lack of) correlation of the distances of the mean vectors of the target term sets $T_1$ and $T2$ with the attribute terms in $A$. The lower the correlation, the higher the bias. To this end, we compute the mean vectors $\mathbf{t_1}$ and $\mathbf{t_2}$ as averages of the vector representations of the terms in $T_1$ and $T_2$. Next, we compute two vectors containing the cosine similarities of each of the terms in $A$ with $\mathbf{t_1}$, as well as with $\mathbf{t_2}$, respectively. The final score is Spearman's rank correlation coefficient of the obtained vectors of cosine similarity scores. \vspace{0.5em} \noindent\textbf{Bias Analogy Test (BAT).} BAT~\citep{Lauscher2020} assesses the amount of biased analogies that can be retrieved from an embedding space based on the explicit bias specification $B_E = (T_1, T_2, A_1, A_2)$. We first create all possible biased analogies from $B_E$: $\mathbf{t}_1 - \mathbf{t}_2 \approx \mathbf{a}_1 - \mathbf{a}_2$ for $(t_1, t_2, a_1, a_2) \in T_1 \times T_2 \times A_1 \times A_2$. Next, from each of these analogies, two query vectors are computed: $\mathbf{q}_1 = \mathbf{t}_1 - \mathbf{t}_2 + \mathbf{a}_2$ and $\mathbf{q}_2 = \mathbf{a}_1 - \mathbf{t}_1 + \mathbf{t}_2$ for each 4-tuple $(t_1, t_2, a_1, a_2)$. We then rank all attribute vectors in $\mathbf{X}$ according to the Euclidean distance to the query vector. We report the percentage of cases in which: (1) $a_1$ is ranked higher than a term $a'_2 \in A_2\setminus\{a_2\}$ for $\mathbf{q}_1$ and (2) $a_2$ is ranked higher than a term $a'_1 \in A_1\setminus\{a_1\}$ for $\mathbf{q}_2$. \vspace{0.5em} \noindent\textbf{Implicit Bias Tests (IBT).} As proposed by \citet{Gonen2019}, the amount of implicit bias corresponds to the accuracy with which two target term sets can be separated. We report the score of two methods: (1) clustering accuracy with K-Means++~\cite{Arthur2007kmeans}, and (2) classification accuracy based on Support Vector Machines with Gaussian kernel. We carry out the latter via leave-one-out cross-validation (i.e., we train on all words from both target lists, leaving one term for prediction). \vspace{0.5em} \noindent\textbf{Semantic Quality Tests (SQ). } The debiasing models (\ref{sec:debiasing}) modify the embedding space. While they reduce the bias, they may reduce the general semantic quality of the embedding space, which could be detrimental for model performance in downstream applications. This is why we couple the bias tests with measures of semantic word similarity on two established word-similarity datasets: SimLex-999~\citep{hilldoi:10.1162} or WordSim-353 \cite{finkelstein2001placing}. We compute the Spearman correlation between the human similarity scores assigned to word pairs and corresponding cosines computed from the embedding space \subsection{Debiasing Methods} \label{sec:debiasing} \textsc{DebIE} encompasses implementations of two debiasing models from \cite{Lauscher2020}, for which an implicit bias specification suffices:\footnote{Note that any explicit bias specification is trivially reduced to an implicit one by discarding the attribute term sets.} \vspace{0.5em} \noindent\textbf{General Bias Direction Debiasing (GBDD).} As an extension of the linear projection model of \newcite{Dev2019}, GBDD relies on identifying the bias direction in the distributional space. Let $(t^i_1, t^j_2)$ be word pairs with $t^i_1 \in T_1$, $t^j_2 \in T_2$, respectively. First, we obtain partial bias direction vectors $\mathbf{b_{ij}}$ by computing the difference between the respective vectors for each pair $\bm{b_{ij}} = \bm{t^i_1}-\bm{t^j_2}$. We then stack all partial direction vector, obtaining the bias matrix $\bm{B}$. The global bias direction vector $\bm{b}$ then corresponds to the top singular value of $\bm{B}$, i.e., the first row of matrix $\bm{V}$, with $\bm{U\Sigma V^\top}$ as the singular value decomposition of $\bm{B}$. We then obtain the debiased version of the space $\bm{X}$ as: \vspace{-1em} \begin{equation*} \text{GBDD}(\mathbf{X}) = \mathbf{X} - \langle \mathbf{X}, \mathbf{b} \rangle \mathbf{b}, \end{equation*}} \vspace{-1.5em} \noindent with $\langle \bm{X}, \bm{b} \rangle$ denoting dot products between rows of $\bm{X}$ and $\bm{b}$. As such, the closer the word embedding is to the bias direction, the more it gets corrected. \vspace{0.5em} \noindent\textbf{Bias Alignment Model (BAM).} Inspired by previous work on projection-based cross-lingual word embedding spaces~\cite{smith2017offline, glavas2019properly}, BAM focuses on \emph{implicit} debiasing by treating the target term sets $T_1$, and $T_2$ of an implicit bias specification $B_I$ as ``translations'' of each other and learning the linear projection of the embedding spaces w.r.t. itself \cite{Lauscher2020}. First, we build all possible word pairs $(t^i_1, t^j_2)$, $t^i_1 \in T_1$, $t^j_2 \in T_2$ and stack the respective word vectors of the left and right pairs to obtain matrices $\bm{X}_{T_1}$ and $\bm{X}_{T_2}$. We then learn the orthogonal mapping matrix $\bm{W_X} = \bm{U}\bm{V}^\top$, with $\bm{U}\bm{\Sigma}\bm{V}^\top$ as the singular value decomposition of $\bm{X}_{T_2}\bm{X}_{T_1}^\top$. In the last step, the original space and its ``translation'' $\bm{X}= \bm{X}\bm{W_X}$ (which is equally biased), are averaged to obtain the debiased embedding space: \vspace{-0.5em} \begin{equation*} \text{BAM}(\bm{X}) = \frac{1}{2} (\bm{X} + \bm{X}\bm{W_X})\,. \end{equation*} \noindent Note that \textsc{DebIE} can trivially compose the two debiasing models -- the resulting space after applying GBDD (BAM) can be the input for BAM (GBDD). \subsection{Integrated Data} \label{sec:data} \setlength{\tabcolsep}{3pt} \begin{table*}[t] \centering {\scriptsize \begin{tabular}{c | lllll} \toprule \textbf{Test} & \textbf{Type} & \textbf{Target Set \#1} & \textbf{Target Set \#2} & \textbf{Attribute Set \#1} & \textbf{Attribute Set \#2} \\ \midrule 1 & Universal & Flowers (e.g.,~\emph{aster}, \emph{tulip}) & Insects (e.g.,~\emph{ant}, \emph{flea}) & Pleasant (e.g.,~\emph{health}, \emph{love}) & Unpleasant~(e.g., \emph{abuse}) \\ 2 & Militant & Instruments (e.g.,~\emph{cello}, \emph{guitar}) & Weapons (e.g.,~\emph{gun}, \emph{sword}) & Pleasant & Unpleasant\\ 3 & Racist & Euro-American names (e.g.,~\emph{Adam}) & Afro-American names (e.g.,~\emph{Jamel}) & Pleasant (e.g.,~\emph{caress}) & Unpleasant (e.g.,~\emph{abuse})\\ 4 & Racist & Euro-American names (e.g.,~\emph{Brad}) & Afro-American names (e.g.,~\emph{Hakim}) & Pleasant & Unpleasant \\ 5 & Racist & Euro-American name & Afro-American name & Pleasant (e.g.,~\emph{joy}) & Unpleasant (e.g.,~\emph{agony})\\ 6 & Gender & Male names (e.g.,~\emph{John}) & Female names (e.g.,~\emph{Lisa}) & Career (e.g. \emph{management} & Family (e.g.,~\emph{children}) \\ 7 & Gender & Math (e.g.,~\emph{algebra}, \emph{geometry}) & Arts (e.g.,~\emph{poetry}, \emph{dance}) & Male (e.g.,~\emph{brother}, \emph{son}) & Female (e.g.,~\emph{woman}, \emph{sister}) \\ 8 & Gender & Science (e.g.,~\emph{experiment}) & Arts & Male & Female\\ 9 & Disease & Physical condition (e.g.,~\emph{virus}) & Mental condition (e.g.,~\emph{sad}) & Long-term (e.g.,~\emph{always}) & Short-term (e.g.,~\emph{occasional})\\ 10 & Age & Older names (e.g.,~\emph{Gertrude}) & Younger names (e.g.,~\emph{Michelle}) & Pleasant & Unpleasant \\ \bottomrule \end{tabular} } \caption{WEAT bias test specifications provided by \textsc{DebIE}.} \label{tbl:weat} \end{table*} \textsc{DebIE} is designed as a general tool, which allows user to upload their own embedding spaces and define their own bias specifications for testing and/or debiasing. Nonetheless, we include into the platform a set of commonly used bias specifications and word embedding spaces. Concretely, \textsc{DebIE} includes the whole WEAT test collection~\citep{Caliskan2017}, containing the explicit bias specifications summarized in Table~\ref{tbl:weat}. \textsc{DebIE} also comes with three word embedding spaces, pretrained with different models: (1) fastText~\cite{Bojanowski:2017tacl},\footnote{\url{https://dl.fbaipublicfiles.com/fasttext/vectors-wiki/wiki.en.vec}} (2) GloVe~\cite{pennington2014glove},\footnote{\url{http://nlp.stanford.edu/data/glove.6B.zip}} and (3) CBOW~\cite{mikolov2013distributed}.\footnote{\url{https://drive.google.com/file/d/0B7XkCwpI5KDYNlNUTTlSS21pQmM/edit?usp=sharing}} All three spaces are 300-dimensional and their vocabularies are limited to 200K most frequent words. \subsection{System Architecture} \begin{figure*} \centering \includegraphics[scale=0.4]{img/architecture2.png} \caption{Software Architecture of the \textsc{DebIE} platform.}\label{fig:Architecture_Diagram} \vspace{-1em} \end{figure*} \textsc{DebIE}'s architecture, illustrated in Figure~\ref{fig:Architecture_Diagram}, adheres to the principles of modern extensible web application design and consists of four components: (1) the backend, (2) the frontend, which together represent the core of the application, (3) the data layer, and (4) the server layer facing the web. \paragraph{Backend.} \textsc{DebIE}'s backend consists of two main modules: (1) the bias evaluation engine, which computes the bias test scores (see \S\ref{sec:measures}), and (2) the debiasing engine, which runs the word embedding debiasing models (see \S\ref{sec:debiasing}). The backend interacts with the data layer for retrieving data (bias specifications and vectors from embedding spaces) and its functionality is exposed via a RESTful API, which offers endpoints for programmatically (i) uploading and retrieving data as well as for (ii) running bias evaluation and (iii) debiasing. There are dedicated controllers and handlers for each of this primary functionalities: vector retrieval, bias evaluation, and debiasing. These are responsible for computing results and delivering content to relevant web pages. The second group of controllers and handlers is responsible for retrieving data out of integrated and external embedding spaces and for parsing and generating JSON data. All bias measures and debiasing methods are implemented as separate modules so that the platform can be extended seamlessly with additional bias measures and debiasing models. A new bias measure or a new debiasing model can be integrated by simply adding the computation scripts (i.e., a function that implements the functionality) and adapting the responsible handler. The backend is purely implemented in Python. \paragraph{Frontend, Data Layer, and Server Layer.} The frontend is written in HTML and plain JavaScript, and relies on the Bootstrap library.\footnote{\url{https://getbootstrap.com/}} The \texttt{fetch} functionality is used for sending requests to the RESTful API of the backend. For the visualization of embedding spaces (see bottom part of Figure \ref{fig:landing_page}), we rely on the the \texttt{chart.js} library.\footnote{\url{https://www.chartjs.org/}} Embedding spaces are stored as two files: (1) the \textit{.vocab} file is the serialized dictionary that maps words to indices of the embedding matrix; (2) the \textit{.vectors} file is an embedding matrix (serialized 2D \texttt{numpy} array) rows of which are the actual word vectors. At the start of the web applicatiob, all bias specifications and intergated embedding spaces are fully loaded into the memory completely. \textsc{DebIE} is hosted on a Linux server, running Debian 10 as the operating system. The python WSGI-server \texttt{gunicorn} is used to serve the RESTful API. We opt for \texttt{nginx} as the web server for hosting the frontend and redirecting the API-requests to the internal endpoints of the WSGI-server. \subsection{Accessibility: Interfaces} Users can interact with \textsc{DebIE} through four different interfaces. The simplest way is by using the provided web interface. For programmatic access, we offer the RESTful-API accessible directly via HTTP requests. As a third option, a desktop version of the tool is available for download: this tools runs completely offline and, depending on the hardware, may perform faster. Finally, we offer a command-line interface intended for shell usage. \paragraph{Web User Interface.} \begin{figure} \centering \includegraphics[scale=0.55]{img/debie_webui.pdf} \caption{\textsc{DebIE's} web UI.} \label{fig:landing_page} \vspace{-1em} \end{figure} \textsc{DebIE} is primarily imagined as a web application with a full extendable web user interface (see Figure~\ref{fig:landing_page}). The web-UI enables users to evaluate and debias with predefined or custom bias specifications. Designed as a \textit{one-page application}, the web UI guides the user via five simple steps through the full process: \noindent\emph{Step 1: Selection of the Embedding Space.} In the first step, the user has to select with which embedding space to work. The users can select one of three integrated embedding spaces (\S\ref{sec:data}) uploaded or their own pretrained vector space. \vspace{0.25em} \noindent\emph{Step 2: Selection of the Bias Specification.} The user next chooses a bias specification: they can select one of the integrated WEAT bias specifications or define a bias specification of their own. \vspace{0.25em} \noindent\emph{Step 3: Selection and Computation of the Bias Tests.} The user next selects bias measures/scores (see \S\ref{sec:measures}) to be applied on the selected embedding space given the selected bias specification. The bias (and semantic similarity) scores are displayed in a table (see the upper part of Figure \ref{fig:landing_page}) and can also be exported as in the JSON format. \vspace{0.25em} \noindent\emph{Step 4: Selection and Execution of Debiasing Algorithms.} The user can next choose to debias the selected embedding space (Step 1) based on the selected bias specification (Step 2). To this effect, the user can choose between GBDD, BAM, or one of their compositions (GBDD$\circ$BAM or BAM$\circ$GBDD). The debiased embeddings space can be downloaded. To visualize the differences between the original (biased) and debiased embedding space, we visualize the 2D PCA-compressions of the terms from the bias specification in both spaces (see bottom part of Figure \ref{fig:landing_page}). \vspace{0.25em} \noindent\emph{Step 5: Computation of Bias Tests on the Debiased space.} Finally, the user can evalute the effects of debiasing with the desired set of bias measures. This is like Step 3, only now we subject to testing the debiased instead of the original embedding space. \paragraph{RESTful API.} For programmatic access, we offer a RESTful API. The API can deliver vector representations of words, compute and fetch the bias evaluation scores, as well as debiased word embeddings based on a provided bias specification. The API endpoints are accessible online.\footnote{\url{http://debie.informatik.uni-mannheim.de:8000/REST/}} API documentation is available in the \texttt{swagger} format on the \textsc{DebIE} website.\footnote{\url{http://debie.informatik.uni-mannheim.de:8000/swagger/}} \paragraph{Desktop Application.} We offer an adapted offline-version of the web application providing the same functionality, runnable on Windows OS. The desktop app has been created with the python module \texttt{flaskwebgui}, using the source files of the web application. The desktop application is available both as a windows executable file (\texttt{.exe}) and as a python script. \paragraph{Command-line Interface.} Finally, we expose \textsc{DebIE}'s functionality through a command-line interface, intended for shell (e.g., \texttt{bash}) usage. We employ the Python framework \texttt{click} to parse the command line arguments.
{'timestamp': '2021-03-12T02:19:42', 'yymm': '2103', 'arxiv_id': '2103.06598', 'language': 'en', 'url': 'https://arxiv.org/abs/2103.06598'}
arxiv
\section*{Abstract} For gene expression data measured in a crossover trial, a multivariate mixed effects model seems to be most appropriate. Standard statistical inference fails to provide reliable results when some responses are missing. Particularly for crossover studies, missingness is a serious concern as the trial requires a small number of participants. A Monte Carlo EM (MCEM) based technique has been adopted to deal with this situation. Along with estimation, a MCEM likelihood ratio test (LRTs) is developed for testing the fixed effects in such a multivariate crossover model with missing data. Intensive simulation studies have been carried out prior to the analysis of the gene expression data. \smallskip \noindent \textbf{Keywords:} Multivariate crossover trials; Monte Carlo EM algorithm; MCEM LRTs; \section{Introduction} In many clinical studies, we may come across crossover trials with two or more response variates with subject dropouts and incomplete data. For example, one may consider the measurement of both systolic (SBP)and diastolic (DBP) blood pressure in each period (\citet{Grender1993}) or recording blood sugar levels at multiple time points in each period (\citet{Putt1999}) or microarray gene expression profiles of subjects measured in each period (\citet{Leaker2016}) with incomplete data. Using conventional univariate crossover models based on only complete cases to analyse such missing and multivariate data, may lead to incorrect and biased parameter and variance estimates. In a crossover trial, usually a smaller number of participants as compared to cross-sectional studies are recruited as the same subjects are switched between all treatment groups. Thus, ignoring subject dropout information and performing a complete case analysis may lead to highly underpowered studies and biased estimates. Similarly, ignoring the correlated nature of the multiple responses recorded in each period and fitting separate crossover models to each response may lead us to inaccurate conclusions about the intra and inter subject variabilities. Thus, to address the issue of missing responses in a multivariate crossover setup, we propose a mixed effect model approach and an Monte Carlo EM (MCEM) based estimation method. For a detailed review of univariate crossover designs, refer to the books by (\citet{senn1993}; \citet{Jones}). In comparison, crossover trials with multiple responses measured in each period have been addressed by fewer researchers, namely (\citet{Grender1993}; \citet{chin1996}; \citet{Putt1999}; \citet{Tudor2000}). To tackle the presence of missing/incomplete data specifically for the $AB/BA$ design under the MAR or MNAR missing mechanism one may refer to (\citet{Patel1985}; \citet{Ho2012}; \citet{Matthews2013}). For more general univariate crossover designs with incomplete data references are namely, (\citet{Richardson1992}; \citet{Chow1997}; \citet{Basu2010}; \citet{Rosenkranz2015}). However, none of the works cited deal with missingness in a multivariate crossover design setup. In this article we model and analyse multivariate crossover studies in the presence of missing at random outcomes. This work is motivated by a $3\times 3$ crossover trial studying the effect of two single doses of oral prednisone (10 and 25 mg) with placebo on biomarkers of mucosal inflammation and transcriptomics (\citet{Leaker2016}). The gene expression changes of subjects were measured in each period of the trial giving rise to multiple responses in a crossover framework. A total of seventeen subjects assigned to three treatment sequences were enrolled in the crossover study, however some missing observations (particularly) in the third period were observed. Our task here is to fit an appropriate statistical model to the crossover trial with microarray expression data taking into account the multivariate structure of the data and the missing responses. A Monte Carlo EM based mixed model analysis is used to fit and estimate the treatment and gene effects along with the intra and inter subject variability in the presence of missing at random outcomes. The mixed model assumed, includes the fixed effects of treatment, period and genes, and their interactions while the random effects are subject and subject gene interaction effect. We used maximum likelihood estimation coupled with the MCEM algorithm to determine the estimated model parameters and variance components. For finding the asymptotic covariance matrix, multiple imputation method of (\citet{Goetghebeur2000}) was considered. Likelihood ratio tests (LRTs) based on the MCEM estimators were formulated. We used detailed simulations to study the properties of the estimators and power of the LRTs proposed. A real data example based on the gene expression levels measured in a $3\times 3$ crossover study is used to illustrate the statistical model and its estimation. To the best of our knowledge this is the first work involving multivariate crossover studies with missing responses. Though originally developed for agricultural sciences, crossover trials are nowadays frequently used in clinical trials and biological studies to evaluate treatment effects. These trials are most useful for comparing treatments for chronic or long term diseases, such as asthma, rheumatism, hypertension etc. Note that one useful advantage of crossover studies is that they require a smaller number of participants. However, due to smaller number of recruits, reliable statistical inference is harder to make when some responses are randomly missing. \section{Case study: multivariate crossover trial of oral prednisone} We use a gene expression dataset from (\citet{Leaker2016}) as a case study. The dataset is publicly available from the NCBI Gene Expression Omnibus (\citet{Clough2016}). In the gene expression study results from a randomized double-blind, placebo-controlled, three-period, crossover trial are considered to evaluate the effects of two single doses of oral prednisone (10 mg, 25 mg) on inflammatory mediators measured in nasal exudates after nasal allergen challenge in susceptible individuals with allergic rhinitis. All subjects have a history of seasonal asthma rhinitis to grass pollen and also a positive result from the intraepidermal skin prick test to grass pollen extract. There are a total of seventeen subjects enrolled in the study, assigned to three treatment sequences/groups. Some missing observations (particularly) in the third period are also recorded. The main interest here is to study the effect of treatments and genes on allergic reaction to grass pollen. The crossover trial consists of 3 distinct sequences of treatments assigned to a total of 17 subjects. The sequences of treatments are: Sequence 1 (10 mg, placebo, 25 mg), Sequence 2 (25 mg, 10 mg, placebo), Sequence 3 (placebo, 25 mg, 10 mg). Subject 1 to subject 6 are in sequence 1, subject 7 to subject 12 are in sequence 2 and subject 13 to subject 17 are in sequence 3. For each subject, 10 gene expressions are measured by giving treatments (10 mg prednisone, 25 mg prednisone and placebo) in three periods with a wash out period of 4 weeks. As an example, Sequence 1 indicates that 10 mg prednisone is given to the subjects (subject 1 to subject 6) at period 1 followed by a washout, period 2 placebo is given and again after a washout, 25 mg prednisone is given at period 3. The study comprises of missing responses in period 3 of various sequences. In sequence 1, response values of subjects 2, 5 are missing; in sequence 2, response values of subjects 8, 10 are missing and in sequence 3, response values from subject 14 are missing. The overall percentage of missing responses in the data is $9\%$, with $11\%$ missing in sequences 1 and 2, and $6\%$ in sequence 3. \begin{comment} We have analysed the data set by applying the normal crossover model and the skew normal crossover model with missing at random responses. Both the models are compared with the complete data analysis. When the subjects with missing responses are not examined in the analysis, we call it as complete case analysis. Let, sequence A=\{10 mg (trt 2), placebo (trt 1), 25 mg (trt 3)\}, sequence B=\{25 mg, 10 mg, placebo\} and sequence C=\{placebo, 25 mg, 10 mg\}. We have data on 10 gene expression values for 17 subjects (6 subjects in sequence A, B; 5 subjects in sequence C) over three periods. Also, observations from two subjects are missing in period three of sequence A and B, one subject is missing in period three of sequence C. \end{comment} Prior to model fitting we ran some exploratory analysis of the gene data using complete cases. The following facts were revealed: \begin{itemize} \item[(i)] Gene by treatment and gene by period interactions were seen to be almost absent for each treatment sequence, see \cref{fig:period trt by gene}. \item[(ii)] From \cref{fig:subject by gene} it is fair to assume no subject by gene interaction effect exists in our model. \begin{figure}[!htp] \centering \includegraphics[width=13cm]{interaction_allseq.png} \caption{\textbf{\small Period by gene and treatment by gene interaction plots; Plots on the left (A, B, C) is period by gene interaction plots for sequences 1, 2 and 3 respectively. Plots on the right (D, E, F) is treatment by gene interaction plots for sequences 1, 2 and 3 respectively.}} \label{fig:period trt by gene} \end{figure} \begin{figure}[!htp] \centering \includegraphics[width=13cm]{interacsub_allseq.png} \caption{\textbf{\small Subject by gene interaction plot; Plots A, B, C is subject by gene interaction plots for sequence 1, 2 and 3 respectively}} \label{fig:subject by gene} \end{figure} \end{itemize} Considering these two points, in the following section, we frame a specific model that pertains to the above microarray expression data. \section{Model and notation}\label{modelnotations} Suppose $y_{ijkl}$ denotes measurement of the $l^{\text{th}}$ gene expression from the $k^{\text{th}}$ subject in the $j^{\text{th}}$ period assigned to the $i^{\text{th}}$ treatment sequence, where $i = 1,2, \ldots, s$; $j = 1,2, \ldots, p$; $k = 1,2,\ldots, n_{i}$ and $l = 1,2, \ldots, m$. So there are in total $n$ subjects, where $n=\sum_{i=1}^{s}n_i$. Assuming a normal random effects model we may write, \newcommand\iid{i.i.d.} \newcommand\pN{{N}} \begin{equation}\label{eq:1} y_{ijkl}= \mu + \pi_{j}+\tau_{d[i,j]}+g_{l}+s_{ik}+e_{ijkl} \end{equation} where $\mu$ is an intercept, $\pi_{j}$ is the fixed effect of the $j$th period, $\tau_{d[i,j]},$ $(d[i,j]= 1, 2, \ldots, t)$ is the fixed effect associated with the treatment applied in period $j$ of the sequence $i$, $g_{l}$ is the fixed effect of the $l^{\text{th}}$ gene, $s_{ik}$ is a random effect associated with the $k^{\text{th}}$ subject in sequence $i$, and $e_{ijkl}$ is a random error. We assume that, $e_{ijkl} \overset{ind}{\sim} \pN(0, \sigma_{e}^2)\;\; \forall\, i,j,k,l$, and $s_{ik} \overset{ind}{\sim} \pN(0, \sigma_{s}^2)\;\; \forall\, i,k$. Also, $s_{ik}, e_{ijkl}$ are independent. Note, we have not considered an interaction effect of gene with period and treatment in the above model, in accordance with the exploratory analysis results for the case study data. Based on the above assumptions, we have $\text{var}(y_{ijkl})=\sigma_{e}^2+\sigma_{s}^2$, and $\text{cov}(y_{ijkl},y_{ij^{'}kl^{'}} )=\sigma_{s}^2$ for all $ j \neq j^{'}$, $l \neq l^{'}$. Thus, variance-covariance matrix corresponding to the $k^{\text{th}}$ subject administered the $i^{\text{th}}$ treatment sequence is given by, $$var(\bm{y}_{ik}) =(\bm{ \Sigma}_{ik})_{pm \times pm} = \begin{bmatrix} \sigma_{e}^2 \bm{R} & \sigma_{s}^2\bm{ 1}_{m}\bm{1}_{m}^{T} &.&.&.& \sigma_{s}^2 \bm{1}_{m}\bm{1}_{m}^{T} \\ \sigma_{s}^2 \bm{1}_{m}\bm{1}_{m}^{T} & \sigma_{e}^2\bm{ R} &.&.&.& \sigma_{s}^2 \bm{1}_{m}\bm{1}_{m}^{T} \\ \vdots\\ \sigma_{s}^2 \bm{1}_{m}\bm{1}_{m}^{T} & \sigma_{s}^2 \bm{1}_{m}\bm{1}_{m}^{T} &.&.&.& \sigma_{e}^2 \bm{ R} \end{bmatrix}$$ where, $\bm{R}=\bm{I}_{m}+\frac{\sigma_{s}^2}{\sigma_{e}^2}\bm{1}_{m}\bm{1}_{m}^{T}$ and $\bm{1}_{m}^{T}=(1,1,\ldots,1)_{1 \times m}$. Using matrix notations we rewrite equation \ref{eq:1} as \begin{equation}\label{eq:2} \bm{y}_{i}=\bm{ X}_{i}\bm{\beta}+\bm{Z}_{i}\bm{b}_{i}+\bm{e}_{i},~ i=1,2,\ldots,s \end{equation} where, \begin{itemize} \item[(i)] $\bm{y}_{i}=(\bm{y}_{i1}^{T},\bm{y}_{i2}^{T},\ldots,\bm{y}_{iq}^{T},\dots,\bm{y}_{in_{i}}^{T})^T$ is a response vector of length $pmn_{i}$, and \\ $ \bm{y}_{iq}=(y_{i1q1},\ldots, y_{ipqm})_{pm \times 1}^{T}$. \item[(ii)] $\bm{X}_{i}=(\bm{X}_{i1}^{T},\bm{X}_{i2}^{T},\ldots,\bm{X}_{iq}^{T},\ldots,\bm{X}_{in_{i}}^{T})^{T}_{pmn_{i}\times (p+t+m-2)}$ is the design matrix corresponding to the fixed effects, and $$\bm{X}_{iq}=(\bm{1}_{p}\otimes \bm{1}_{m},((\bm{I}_{p-1}\otimes \bm{1}_{m})^{T},\bm{0}_{m \times (p-1)}^{T})^{T}_{pm \times (p-1)},\bm{T}_{pm \times (t-1)},\bm{1}_{p}\otimes(\bm{I}_{m-1},\bm{0}_{m-1})^{T}).$$ The ${pm \times (t-1)}$ matrix of treatment effects is represented as $\bm{T}=(T_{1}^{T}, \ldots,T_{p}^{T})^{T}$, where $ T_{u}=(\bm{1}_{m} \otimes (a_{1},\ldots, a_{t-1}))_{m \times (t-1)}$ $\text{for u=}1, \ldots p$, and $a_l$ is an indicator variable which takes value $1$ if the $l$th treatment is assigned to the $u$th period and $0$ otherwise. \item[(iii)] $\bm{Z}_{i}=\bm{I}_{n_{i}} \otimes \bm{1}_{pm}$ is the design matrix corresponding to the random effects. \item[(iv)] Moreover, $\bm{b}_{i}=(s_{i1},s_{i2}, \ldots, s_{in_{i}})^{T}$ is the ${n_{i}\times 1}$ vector of random effects, and \\ $\bm{e}_{i}=(\bm{e}_{i1}^{T},\bm{e}_{i2}^{T},\ldots,\bm{e}_{iq}^{T},\ldots,\bm{e}_{in_{i}}^{T})^{T}$ is the ${pmn_{i} \times 1}$ random error vector, where $\bm{e}_{iq}=(e_{i1q1}, \ldots ,e_{ipqm})^{T}$, it is assumed \begin{equation*} \bm{e}_{i} \sim \pN(\bm{0},\sigma_{e}^2 \bm{I}_{pmn_{i}}); \;\; \bm{b}_{i} \sim \pN_{n_{i}}(\bm{0},\bm{D}_{i}), \; \bm{D}_{i}=\sigma_{s}^2\bm{I}_{n_{i}}. \end{equation*} \item[(v)] The parameters of interest are,\\ $\bm{\beta}=(\mu , \pi_{1} ,\dots \pi_{p-1}, \tau_{1},\ldots,\tau_{t-1}, g_{1},\ldots,g_{m-1})$ and $\sigma^2 =(\sigma_e^2,\sigma_s^2).$ \end{itemize} Under the above assumptions, the conditional distribution of $ \bm{y}_{i}$ given the random effects $\bm{b}_{i}$ is of the form \begin{equation*}\label{eq:3} \bm{y}_{i}|\bm{\beta},\sigma_{e}^2,\bm{b}_{i}\sim \pN_{pmn_{i}}(\bm{X}_{i}\bm{\beta}+\bm{Z}_{i}\bm{b}_{i},\sigma_{e}^2\bm{ I}_{pmn_{i}}), \end{equation*}\noindent while the marginal distribution of $\bm{y}_{i}$ is \begin{equation*}\label{eq:4} \bm{y}_{i}|\bm{\beta},\sigma_{e}^2,\bm{D}_{i} \sim \pN_{pmn_{i}}(\bm{X}_{i}\bm{\beta}, \bm{\Sigma}_{i}), \; \bm{\Sigma}_{i}=\bm{Z}_{i}\bm{D}_{i}\bm{Z}_{i}^{T}+\sigma_{e}^{2}\bm{I}_{pmn_{i}} \end{equation*} \section{Estimation with missing at random responses}\label{sec mle missing} In this section we illustrate how an EM type algorithm can be used for maximum likelihood estimation (MLE) in multivariate crossover model in a missing set up. We have used the MCEM algorithm of (\citet{Wei1990}) for parameter estimation. Note that for ignorable missing (MAR) assumption in the data, it is not necessary to incorporate the parametric model for the missing data mechanism into the complete data log likelihood. Therefore the complete data log likelihood for the $i$th sequence is given by $f(\bm{y}_i,\bm{b}_i)$, where $\bm{y}_i$ may contain missing values. We assume the covariates to be fully observed. In the E-step we calculate the expected value of the complete data log likelihood given the observed data and current parameter estimates. Suppose, $\bm{y}_{i}=(\bm{y}_{mis,i}^{T},\bm{y}_{obs,i}^{T})^{T}$ where $\bm{y}_{mis,i}$ is the $m_{i} \times 1$ vector of missing components of $\bm{y}_{i}$. Note, both $\bm{b}_{i}$ and $\bm{y}_{mis,i}$ are unobserved, and must be integrated over. To execute the EM algorithm the steps listed were followed from (\citet{Ibrahim2009}). Thus the E-step for $i$-th sequence at $(t+1)$th iteration. \begin{align*} Q_{i}(\bm{\gamma}|\bm{\gamma}^{(t)})&=E\left(l(\bm{\gamma};\bm{y}_{i},\bm{b}_{i}|\bm{y}_{obs,i},\bm{\gamma}^{(t)})\right)\\ &=\int \int \log \left[f(\bm{y}_{i}|\bm{\beta},\sigma_{e}^2,\bm{b}_{i}) \right]f(\bm{y}_{mis,i},\bm{b}_{i}|\bm{y}_{obs,i},\bm{\gamma}^{(t)}) d\bm{b}_{i} d\bm{y}_{mis,i}\\ &+\int \int \log \left[f(\bm{b}_{i}|D_{i}) \right]f(\bm{y}_{mis,i},\bm{b}_{i}|\bm{y}_{obs,i},\bm{\gamma}^{(t)}) d\bm{b}_{i} d\bm{y}_{mis,i}\\ & \equiv I_{1}+I_{2},\numberthis \label{eq:5} \end{align*} where $\bm{\gamma}^{(t)}=(\bm{\beta}^{(t)},\sigma_{e}^{2(t)},\sigma_{s}^{2(t)})$. To integrate out $\bm{b}_{i}$ from $I_{1}$ and $I_{2}$ we write \begin{align*} f(\bm{y}_{mis,i},\bm{b}_{i}|\bm{y}_{obs,i},\bm{\gamma}^{(t)})&=f(\bm{b}_{i}|\bm{y}_{i},\bm{\gamma}^{(t)})f(\bm{y}_{mis,i}|\bm{y}_{obs,i},\bm{\gamma}^{(t)}) \end{align*} \begin{equation*}\label{b giv y} \text{where,}\;\;\;\bm{b}_{i}|\bm{y}_{i},\bm{\gamma}^{(t)} \sim N(\bm{b}_{0i}^{(t)},\bm{ \Sigma}_{0i}^{(t)})\;\;\; \text{and,} \end{equation*} \begin{align*} \bm{b}_{0i}^{(t)}&=\bm{D}_{i}^{(t)}\bm{Z}_{i}^{'}(\bm{Z}_{i}\bm{D}_{i}^{(t)}\bm{Z}_{i}^{'}+\sigma_{e}^2 \bm{I}_{pmn_{i}})^{-1}(\bm{y}_{i}-\bm{X}_{i}\bm{\beta}^{(t)})\\ &=\bm{\Sigma}_{0i}^{(t)}\bm{Z}_{i}^{'}(\bm{y}_{i}-\bm{X}_{i}\bm{\beta}^{(t)})/\sigma_{e}^{2(t)}\\ \bm{\Sigma}_{0i}^{(t)}&=\bm{D}_{i}^{(t)}-\bm{D}_{i}^{(t)}\bm{Z}_{i}^{'}(\bm{Z}_{i}\bm{D}_{i}^{(t)}\bm{Z}_{i}^{'}+\sigma_{e}^2 \bm{I}_{pmn_{i}})^{-1}\bm{Z}_{i}\bm{D}_{i}^{(t)}\\ &=\left[\sigma_{e}^{-2(t)}\bm{Z}_{i}^{'}\bm{Z}_{i}+(\bm{D}_{i}^{(t)})^{-1}\right]^{-1}. \end{align*} Thus, \begin{comment} \begin{align*} \numberthis \label{eq:6} I_{1}&=\int \int \log \left[f(\bm{y}_{i}|\bm{\beta},\sigma_{e}^2,\bm{b}_{i}) \right]f(\bm{y}_{mis,i},\bm{b}_{i}|\bm{y}_{obs,i},\bm{\gamma}^{(t)}) d\bm{b}_{i} d\bm{y}_{mis,i}\\ &=\frac{-pmn_{i}}{2} \log 2\pi -\frac{pmn_{i}}{2}\log\sigma_{e}^2-\int \frac{1}{2 \sigma_{e}^2}\\&\bigg( \int (\bm{y}_{i}-\bm{X}_{i}\bm{\beta}-\bm{Z}_{i}\bm{b}_{i})^{T}(\bm{y}_{i}-\bm{X}_{i}\bm{\beta}-\bm{Z}_{i}\bm{b}_{i})f(\bm{b}_{i}|\bm{y}_{i},\bm{\gamma}^{(t)}) d\bm{b}_{i}\bigg)f(\bm{y}_{mis,i}|\bm{y}_{obs,i},\bm{\gamma}^{(t)}) d\bm{y}_{mis,i}. \end{align*} \textbf{Result 1:}(Khuri (2010) \citet{2017}) If $\bm{X}$ is any random vector with mean vector $\bm{\mu}$ and variance-covariance matrix $\bm{\Sigma}$ then, \begin{equation*}E(\bm{X}^{T}\bm{AX})=Tr(\bm{A\Sigma})+\bm{\mu}^{T}\bm{A\mu} \label{res 1}\end{equation*} \noindent To evaluate the integral with respect to $\bm{b}_{i}$ in $\cref{eq:6}$, we use $\cref{b giv y}$, \begin{align*} \numberthis \label{eq:7} E_{\bm{b}_{i}|\bm{y}_{i}}(\bm{y}_{i}-\bm{X}_{i}\bm{\beta}-\bm{Z}_{i}\bm{b}_{i})^{T}(\bm{y}_{i}-\bm{X}_{i}\bm{\beta}-\bm{Z}_{i}\bm{b}_{i})&=(\bm{y}_{i}-\bm{X}_{i}\bm{\beta})^{T}(\bm{y}_{i}-\bm{X}_{i}\bm{\beta})\\&-2E_{\bm{b}_{i}|\bm{y}_{i}}(\bm{y}_{i}-\bm{X}_{i}\bm{\beta})^{T}\bm{Z}_{i}\bm{b}_{i}+E_{\bm{b}_{i}|\bm{y}_{i}}(\bm{b}_{i}^{T}\bm{Z}_{i}^{T}\bm{Z}_{i}\bm{b}_{i}). \end{align*} \noindent Substituting $\cref{eq:7}$ into $\cref{eq:6}$, we have: \end{comment} \begin{align*} I_{1}&=\frac{-pmn_{i}}{2} \log 2\pi -\frac{pmn_{i}}{2}\log\sigma_{e}^2- \frac{1}{2 \sigma_{e}^2}(Tr(\bm{Z}_{i}^{T}\bm{Z}_{i}\bm{\Sigma}_{0i}^{(t)})\\&+\int(\bm{y}_{i}-\bm{X}_{i}\bm{\beta}-\bm{Z}_{i}\bm{b}_{0i}^{(t)})^{T}(\bm{y}_{i}-\bm{X}_{i}\bm{\beta}-\bm{Z}_{i}\bm{b}_{0i}^{(t)})f(\bm{y}_{mis,i}|\bm{y}_{obs,i},\bm{\gamma}^{(t)}) d\bm{y}_{mis,i}).\numberthis \label{eq:8} \end{align*} and, \begin{align*} I_{2}&=\frac{-(m+1)n_{i}}{2} \log 2\pi -\frac{1}{2} \log(\det \bm{D}_{i})-\frac{1}{2} Tr(\bm{D}_{i}^{-1}\bm{\Sigma}_{0i}^{(t)})\\&- \frac{1}{2} \int({\bm{b}_{0i}^{(t)}}^T\bm{D}_{i}^{-1}\bm{b }_{0i}^{(t)})f(\bm{y}_{mis,i}|\bm{y}_{obs,i},\bm{\gamma}^{(t)}) d\bm{y}_{mis,i}.\numberthis \label{eq:9} \end{align*} \begin{comment} Finally for $I_{3}$, $\bm{b}_{i}$ can be easily integrated out since $\log [f(\bm{r}_{i}|\bm{\phi},\bm{y}_{i})]$ does not depend on $\bm{b}_{i}$. Therefore $I_{3}$ can be simply written as \begin{equation}\label{eq:10} I_{3}=\int \log [f(\bm{r}_{i}|\bm{\phi},\bm{y}_{i})]f(\bm{y}_{mis,i}|\bm{y}_{obs,i},\bm{\gamma}^{(t)}) d\bm{y}_{mis,i}. \end{equation} The E-step expressed via $\cref{eq:8},\,\cref{eq:9},\,\cref{eq:10}$ does not involve $\bm{b}_{i}$. Thus \end{comment} \begin{comment} This distribution can be written up to a constant of proportionality as \begin{align*} \numberthis \label{eq:11} f(\bm{y}_{mis,i}|\bm{y}_{obs,i},\bm{r}_{i},\bm{\gamma}^{(t)}) &\propto f(\bm{r}_{i}|\bm{y}_{mis,i},\bm{y}_{obs,i},\bm{\gamma}^{(t)}) \times f(\bm{y}_{mis,i},\bm{y}_{obs,i}|\bm{\gamma}^{(t)})\\ & \propto f(\bm{r}_{i}|\bm{y}_{mis,i},\bm{y}_{obs,i},\bm{\gamma}^{(t)}) \times f(\bm{y}_{mis,i}|\bm{y}_{obs,i},\bm{\gamma}^{(t)})\times f(\bm{y}_{obs,i}|\bm{\gamma}^{(t)})\\ & \propto f(\bm{y}_{mis,i}|\bm{y}_{obs,i},\bm{\gamma}^{(t)})\;\; \text{(in case of MAR)}. \end{align*} \end{comment} We sample $v_{i1},v_{i2},\ldots v_{ic_{i}}$ from $[\bm{y}_{mis,i}|\bm{y}_{obs,i},\bm{\gamma}^{(t)}]$, which has the density of the form, \begin{equation}\label{eq:12} \bm{y}_{mis,i}|\bm{y}_{obs,i},\bm{\gamma}^{(t)} \sim \pN_{m_{i}}(\bm{\mu}_{1}+\bm{\Sigma}_{12}\bm{\Sigma}_{22}^{-1}(\bm{y}_{obs,i}-\bm{\mu}_{2}),\bm{\Sigma}_{11}-\bm{S}_{12}\bm{\Sigma}_{22}^{-1}\bm{\Sigma}_{21}). \end{equation} where, $$\begin{pmatrix} \bm{y}_{mis,i}\\ \bm{y}_{obs,i} \end{pmatrix}=\begin{pmatrix} \bm{X}_{i_{m_{i}\times 1}}^{(1)}\\ \bm{X}_{i_{l_{i} \times 1}}^{(2)} \end{pmatrix}\bm{\beta}+\begin{pmatrix} \bm{Z}_{i_{m_{i}\times 1}}^{(1)}\\ \bm{Z}_{i_{l_{i} \times 1}}^{(2)} \end{pmatrix}\bm{b_{i}}+\begin{pmatrix} \bm{e}_{m_{i}}\\ \bm{e}_{l_{i}} \end{pmatrix}; \; \; m_{i}+l_{i}=pmn_{i}$$ $$ \bm{y}_{i}= \begin{pmatrix} \bm{y}_{mis,i}\\ \bm{y}_{obs,i} \end{pmatrix} \sim \pN(\bm{\mu}, \bm{\Sigma}),$$ $$ \bm{\mu}=\begin{pmatrix} \bm{\mu}_{1}\\ \bm{\mu}_{2} \end{pmatrix} = \begin{pmatrix} \bm{X}_{i}^{(1)} \bm{\beta}\\ \bm{X}_{i}^{(2)} \bm{\beta} \end{pmatrix},$$ $$ \bm{\Sigma}= \begin{pmatrix} \bm{\Sigma}_{11}&\bm{\Sigma}_{12}\\ \bm{\Sigma}_{21}&\bm{\Sigma}_{22} \end{pmatrix}=\begin{pmatrix} \bm{Z}_{i}^{(1)}\bm{D}_{i}{\bm{Z}_{i}^{(1)}}^T&\bm{Z}_{i}^{(1)} \bm{D}_{i}{\bm{Z}_{i}^{(2)}}^T\\ \bm{Z}_{i}^{(2)} \bm{D}_{i}{\bm{Z}_{i}^{(1)}}^T& \bm{Z}_{i}^{(2)} \bm{D}_{i}{\bm{Z}_{i}^{(2)}}^T \end{pmatrix}+\sigma_{e}^2 \begin{pmatrix} \bm{I}_{m_{i}}&0\\ 0&\bm{I}_{l_{i}} \end{pmatrix}.$$ Using the data $\bm{y}_{i}^{(k)}=(\bm{v}_{ik}^{T},\bm{y}_{obs,i}^{T})^{T}$ and $\bm{b}_{0i}^{(tk)}=\bm{\Sigma}_{0i}^{(t)}\bm{Z}_{i}^{T}(\bm{y}_{i}^{(k)}-\bm{X}_{i}\bm{\beta}^{(t)})\sigma_{e}^{2(t)}$, \cref{eq:8}, \cref{eq:9} and \cref{eq:12} the $E$-step for the $i^{\text{th}}$ sequence (\cref{eq:5}) in the $(t+1)^{\text{th}}$ iteration takes the form \begin{align*} Q_{i}(\bm{\gamma}|\bm{\gamma}^{(t)})&=\frac{-pmn_{i}}{2} \log 2\pi -\frac{pmn_{i}}{2}\log\sigma_{e}^2\\&- \frac{1}{2 \sigma_{e}^2}\bigg(Tr(\bm{Z}_{i}^{T}\bm{Z}_{i}\bm{\Sigma}_{0i}^{(t)})+\frac{1}{c_{i}} \displaystyle\sum_{k=1}^{c_{i}}(\bm{y}_{i}^{(k)}-\bm{X}_{i}\bm{\beta}-\bm{Z}_{i}\bm{b}_{0i}^{(tk)})^{T}(\bm{y}_{i}^{(k)}-\bm{X}_{i}\bm{\beta}-\bm{Z}_{i}\bm{b}_{0i}^{(tk)})\bigg)\\ &-\frac{(m+1)n_{i}}{2} \log 2\pi -\frac{1}{2} \log(\det \bm{D}_{i})-\frac{1}{2} Tr(\bm{D}_{i}^{-1}\bm{\Sigma}_{0i}^{(t)})\\&- \frac{1}{2c_{i}} \displaystyle \sum_{k=1}^{c_{i}}{\bm{b}_{0i}^{(tk)}}^T \bm{D}_{i}^{-1}\bm{b}_{0i}^{(tk)}. \end{align*} Obviously, the E-step for all the sequences is given by $$Q(\bm{\gamma}|\bm{\gamma}^{(t)})=\displaystyle \sum_{i=1}^{s}Q_{i}(\bm{\gamma}|\bm{\gamma}^{(t)}).$$ In the M-step, we maximize $Q(\bm{\gamma}|\bm{\gamma}^{(t)})$. The closed forms are obtained for $(\bm{\beta},\sigma_{e}^2,\sigma_{s}^2)$ by computing $$\frac{\partial Q}{\partial \bm{\beta}}=0,~~~\frac{\partial Q}{\partial \sigma_{e}^2}=0, ~~~\frac{\partial Q}{\partial \sigma_{s}^2}=0$$ \begin{align*} \bm{\beta}^{(t+1)}&=\bigg(\displaystyle\sum_{i=1}^{s} \bm{X}_{i}^{T}\bm{X}_{i}\bigg)^{-1} \displaystyle\sum_{i=1}^{s}\bm{X}_{i}^{T}\frac{1}{c_{i}} \displaystyle\sum_{k=1}^{c_{i}}(\bm{y}_{i}^{(k)}-\bm{Z}_{i}\bm{b}_{0i}^{(tk)})\\ \sigma_{e}^{2(t+1)}&=\frac{1}{pmn}\displaystyle\sum_{i=1}^{s}\bigg(\frac{1}{c_{i}} \displaystyle\sum_{k=1}^{c_{i}}(\bm{y}_{i}^{(k)}-\bm{X}_{i}\bm{\beta}^{(t+1)}-\bm{Z}_{i}\bm{b}_{0i}^{(tk)})^{T}(\bm{y}_{i}^{(k)}-\bm{X}_{i}\bm{\beta}^{(t+1)}-\bm{Z}_{i}\bm{b}_{0i}^{(tk)})\\&+Tr(\bm{Z}_{i}^{T}\bm{Z}_{i}\bm{\Sigma}_{0i}^{(t)})\bigg)\\ \sigma_{s}^{2(t+1)}&=\frac{1}{n}\displaystyle\sum_{i=1}^{s}\bigg( Tr(\bm{\Sigma}_{0i}^{(t)})+ \frac{1}{c_{i}} \displaystyle \sum_{k=1}^{c_{i}}{\bm{b}_{0i}^{(tk)}}^T \bm{I}_{n_{i}}\bm{b}_{0i}^{(tk)}\bigg) \end{align*} \begin{comment} Find $\bm{\phi}^{(t+1)}$ to maximize \begin{equation}\label{eq:14} Q_{\bm{\phi}}=\displaystyle\sum_{i=1}^{s}\frac{1}{c_{i}}\displaystyle \sum_{k=1}^{c_{i}} \log [f(\bm{r}_{i}|\bm{\phi},\bm{y}^{(k)}_{i})]. \end{equation} \begin{align*} Q_{\sigma_{e}^{2}}&= \frac{pmn}{2}\log\sigma_{e}^2+\frac{1}{2 \sigma_{e}^2}\displaystyle\sum_{i=1}^{s}Tr(\bm{Z}_{i}^{T}\bm{Z}_{i}\bm{\Sigma}_{0i}^{(t)})\\&+\frac{1}{2 \sigma_{e}^2}\displaystyle\sum_{i=1}^{s}\frac{1}{c_{i}} \displaystyle\sum_{k=1}^{c_{i}}(\bm{y}_{i}^{(k)}-\bm{X}_{i}\bm{\beta}^{(t+1)}-\bm{Z}_{i}\bm{b}_{0i}^{(tk)})^{T}(\bm{y}_{i}^{(k)}-\bm{X}_{i}\bm{\beta}^{(t+1)}-\bm{Z}_{i}\bm{b}_{0i}^{(tk)}),\; n=n_{1}+n_{2}+\ldots+n_{s} \end{align*} which leads to,\begin{equation*}\label{eq:15} \sigma_{e}^{2(t+1)}=\frac{1}{pmn}\displaystyle\sum_{i=1}^{s}\left(\frac{1}{c_{i}} \displaystyle\sum_{k=1}^{c_{i}}(\bm{y}_{i}^{(k)}-\bm{X}_{i}\bm{\beta}^{(t+1)}-\bm{Z}_{i}\bm{b}_{0i}^{(tk)})^{T}(\bm{y}_{i}^{(k)}-\bm{X}_{i}\bm{\beta}^{(t+1)}-\bm{Z}_{i}\bm{b}_{0i}^{(tk)})+Tr(\bm{Z}_{i}^{T}\bm{Z}_{i}\bm{\Sigma}_{0i}^{(t)})\right) \end{equation*} \begin{align*} Q_{D}&=\frac{1}{2}\displaystyle\sum_{i=1}^{s} \log(\det \bm{D}_{i})+\frac{1}{2}\displaystyle\sum_{i=1}^{s} Tr(\bm{D}_{i}^{-1}\bm{\Sigma}_{0i}^{(t)})+ \frac{1}{2}\displaystyle\sum_{i=1}^{s}\frac{1}{c_{i}} \displaystyle \sum_{k=1}^{c_{i}}{\bm{b}_{0i}^{(tk)}}^T \bm{D}_{i}^{-1}\bm{b}_{0i}^{(tk)}\\ &=\frac{1}{2}\displaystyle\sum_{i=1}^{s} \log\left[\sigma_{s}^{2n_{i}}\right]+\frac{1}{2}\displaystyle\sum_{i=1}^{s} Tr(\bm{D}_{i}^{-1}\bm{\Sigma}_{0i}^{(t)})+ \frac{1}{2}\displaystyle\sum_{i=1}^{s}\frac{1}{c_{i}} \displaystyle \sum_{k=1}^{c_{i}}{\bm{b}_{0i}^{(tk)}}^T \bm{D}_{i}^{-1}\bm{b}_{0i}^{(tk)}, \end{align*} which yields, \begin{equation}\label{eq:16} \sigma_{s}^{2(t+1)}=\frac{1}{n}\left(\displaystyle\sum_{i=1}^{s} Tr(\bm{\Sigma}_{0i}^{(t)})+ \displaystyle \sum_{i=1}^{s}\frac{1}{c_{i}} \displaystyle \sum_{k=1}^{c_{i}}{\bm{b}_{0i}^{(tk)}}^T \bm{I}_{n_{i}}\bm{b}_{0i}^{(tk)}\right) \end{equation} \end{comment} The above $E$ and $M-$ steps are repeated until convergence is achieved. To find the asymptotic covariance matrix, the multiple imputation technique has been considered. For imputing a missing value we sampled from $[\bm{b}_{i},\bm{y}_{mis,i}|\hat{\bm{\gamma}},\bm{y}_{obs,i}]$ following the steps below, note $\hat{\bm{\gamma}}=(\hat{\bm{\beta}},\hat{\sigma_{e}}^2,\hat{\sigma_{s}}^2)$ are the MCEM estimates, \begin{enumerate} \item[(i)] Initial estimates $({\bm{b}_{i}}_{0}, {\bm{y}_{mis,i}}_{0})$ were taken from the respective marginal distributions i.e. $\bm{b}_{i} \sim N(\bm{0},\sigma_{s}^2 \bm{I}_{n_{i}})$ and \\ $\bm{y}_{mis,i}$ $\sim N(\bm{X}_{i}^{(1)} \bm{\beta},\bm{Z}_{i}^{(1)}\bm{D}_{i}{\bm{Z}_{i}^{(1)}}^T+\sigma_{e}^2 \bm{I}_{m_{i}})$. \item[(ii)] At the $k(\geq 1)$th iteration $({\bm{b}_{i}}_{k}, {\bm{y}_{mis,i}}_{k})$ were sampled using ${\bm{b}_{i}}_{k}$ from $\bm{b}_{i}|\bm{y}_{obs,i},{\bm{y}_{mis,i}}_{k-1}$ and ${\bm{y}_{mis,i}}_{k}$ from ${\bm{y}_{mis,i}}|\bm{y}_{obs,i},{\bm{b}_{i}}_{k}$. \end{enumerate} We generated $b$ such samples of $[\bm{b}_{i},\bm{y}_{mis,i}]$. The parameter estimates and their variances were computed based on the $b$ sets of imputed values. Repeating the procedure $m_0$ times the final variance estimates were taken to be: (mean of the imputed variances)+$(1+1/m_{0})$(empirical variances of the imputed point estimates). \section{Hypothesis testing and Power compuation}\label{power} A MCEM-LRT test is developed for testing the fixed effects in a multivariate crossover model with missing data. Here our interest is in testing the fixed effects, however the LRT procedure may also be used to test the variance components. Specifically, for testing the treatment effect we frame our hypotheses a \begin{equation*} H_{0}:\tau_1=\tau_2=\ldots=\tau_t \;\;\text{vs}\;\; H_{1}: \tau_1,\tau_2,\ldots,\tau_t \text{ are not all equal } \end{equation*} The LRT statistic is $\Lambda=2 \log L\big(\hat{\theta}_{f u l l}\big)-2 \log L\big(\hat{\theta}_{\text {reduced}}\big),$ where $\log L\big(\hat{\theta}_{\text {full}}\big)$ is the likelihood function for the full model containing all the parameters, and $\log L\big(\hat{\theta}_{\text {reduced}}\big)$ is the likelihood function value for the reduced model under $H_{0}$. Under the normality assumption and certain other regularity conditions (\citet{junshao}), when $H_0$ is true, $S^2$ follows a central $\chi^{2}_{d f}$ where $\mathrm{df}$ is the difference between the number of parameters in the full model and the reduced model. The null hypothesis, $H_0$, is rejected if the observed value of $S^2$ exceeds the $(1-\alpha)^{\text{th}}$ quantile of $\chi^{2}_{d f}$. For testing the period effect or the fixed effect of the response variates we may use the respective hypotheses, \begin{equation*} H_{0}:\pi_1=\pi_2=\ldots=\pi_p \;\;\text{vs}\;\; H_{1}: \pi_1,\pi_2,\ldots,\pi_p \text{ are not all equal}, \end{equation*} \begin{equation*} H_{0}:g_1=g_2=\ldots=g_m \;\;\text{vs}\;\; H_{1}: g_1,g_2,\ldots,g_m \text{ are not all equal }. \end{equation*} Note for EM-LRT we have assumed that the central limit theorem holds for the MCEM estimator. Thus, in the next section we carry out extensive simulations to assess the EM-LRT test and its power for various combinations of sample size and $\%$ of missingness. \section{Simulation study}\label{simstudy} We discuss a detailed simulation study to asses the performance of the MCEM estimators and the LRT test based on these estimators. For data generation, we assumed a crossover trial with two treatment sequences $\{AB,BA\}$ in two periods. In each period four response variates were measured. The model is represented as, \begin{align*} y_{i j k l}&=\beta_{0}+\beta_{\text{per}} \text {Period}_{1}+\beta_{\tau} \text {Trt}_{1}+\beta_{r_1} \text {Res}_{1}+\beta_{r_2} \text {Res}_{2}\\&+\beta_{r_3}\text {Res}_{3}+s_{i k} +e_{ijkl}; \quad i,j=1,2, \quad l=1,2,3,4, \quad k=1,2,\ldots 50 \label{model in regression} \end{align*} where $y_{i j kl}$ denotes the $l^{\text{th}}$ response value from the $k^{\text{th}}$ subject in the $j^{\text{th}}$ period of the $i^{\text{th}}$ sequence; $\beta_{0}$ is the intercept; Period$_{1}$ is an indicator variable corresponding to the first period effect; $\operatorname{Trt}_{1}$ is an indicator variable corresponding to the treatment effect $A$ and Res$_{1}$, Res$_{2}$, Res$_{3}$ are indicator variables corresponding to the response variates, where Res$_{i}=1$ for the $i^{\text{th}}$ response variate and $0$ otherwise for $i=1,2,3$. Also, as defined before $s_{i k}$ is the subject specific random effect and $e_{i j kl}$ is the error term. \[ s_{i k} \sim N\left(0, \sigma_{s}^{2}\right), \quad e_{i j kl} \sim N\left(0, \sigma_{e}^{2}\right);\; \; s_{ik} \perp e_{ijkl} \] In matrix notations, \begin{equation*}\label{eq:sim model} \bm{y}_{i}=\bm{ X}_{i}\bm{\beta}+\bm{Z}_{i}\bm{b}_{i}+\bm{e}_{i}, \end{equation*} where, for $i=1,2$, $\bm{e}_{i} \sim N_{400}(\bm{0},1.44 \bm{I})$, $\bm{b}_{i} \sim N_{50}(\bm{0},0.49\bm{I})$, $\bm{X}_{i}$ and $\bm{Z}_{i}$ matrices are constructed similarly as in \cref{eq:2}. The true values of the components of $\bm{\beta}$ are given in the first column of Table \ref{table simulated data}. We considered different probabilities of missingness $(15\%,\, 25\%,\, 35\%)$ in each sequence and the missing mechanism to be MAR. Since the non-response model is assumed to be ignorable (\citet{Laird1988}) we use a Bernoulli random variable with probability $0.15,\, 0.25, \,0.35$, respectively to generate the missing data. The MCEM algorithm discussed in \cref{sec mle missing} is used for parameter estimation and SEs (standard errors) of the estimators are obtained via the imputation method. At every iteration of the MCEM algorithm, one thousand samples were generated for missing observations. The simulations were repeated 500 times. \Cref{table simulated data} shows the average simulation results in terms of parameter estimates, SEs, bias, and empirical coverages for different missing percentages. Absolute average bias was computed as $|\frac{\sum_{w=1}^{500} (\hat{\beta}_{uw}-\beta_u)}{500}|$, where $\hat{\beta}_{uw}$ is the $u^\text{th}$ component of $\hat{\bm{\beta}}$ for the $w^\text{th}$ simulation and $\beta_u$ is the true value. Whereas, the empirical coverage probability (ECP) was taken to be the proportion of the times the $95\%$ asymptotic confidence interval of $\hat{\beta}_{uw}$ contained the true parameter value $\beta_u$ in $500$ simulations. To compute the SEs, one hundred imputations with a burn-in of $1000$ were used. From Table \ref{table simulated data}, one notes that absolute average biases for $15\%$ missing responses, ranges between 2$\%$ - 5$\%$. As we increase the $\%$ of missingness to $35\%$, the range of the average bias change to 4$\%$ - 11$\%$. The average MSEs of the estimates range from $1\% - 3\%$ for all three missing percentages, showing that the corresponding standard errors are also quite low. These simulation results imply that the MCEM estimators work well for finite samples. \begin{table}[htp] \tiny \begin{center} \caption{Simulation results based on five hundred samples} \label{table simulated data} \begin{tabular}{rlllll} \hline Parameter & MLE & SE & Bias &MSE&ECP\\ \hline &\multicolumn{5}{c}{\textit{15\% missing responses}}\\ \hline Intercept (4.50) & 4.53 & 0.11 & 0.03 & 0.03 & 0.91 \\ Period$_1$ (0.20) & 0.15 & 0.08 & 0.05 & 0.01 & 0.92 \\ Trt$_1$ (1.06) & 1.01 & 0.08 & 0.05 & 0.01 & 0.94 \\ Res$_1$ (0.46)& 0.44 & 0.11 & 0.02 & 0.03 & 0.94 \\ Res$_2$ (1.09)& 1.07 & 0.11 & 0.02 & 0.03 & 0.95 \\ Res$_3$ (0.50) & 0.47 & 0.11 & 0.03 & 0.03 & 0.96 \\ $\sigma_{e}^2$ (1.44)& 1.42 & 0.07 & 0.02 & 0.01 & 0.92 \\ $\sigma_{s}^2$ (0.49)& 0.52 & 0.08 & 0.03 & 0.02 & 0.93 \\ \hline &\multicolumn{5}{c}{\textit{25\% missing responses}}\\ \hline Intercept (4.50) & 4.54 & 0.10 & 0.04 & 0.02 & 0.90 \\ Period$_1$ (0.20) & 0.13 & 0.08 & 0.07 & 0.02 & 0.88 \\ Trt$_1$ (1.06) & 0.98 & 0.08 & 0.08 & 0.02 & 0.89 \\ Res$_1$ (0.46)& 0.42 & 0.11 & 0.04 & 0.02 & 0.93 \\ Res$_2$ (1.09)& 1.05 & 0.11 & 0.04 & 0.02 & 0.94 \\ Res$_3$ (0.50) & 0.46 & 0.11 & 0.04 & 0.02 & 0.95 \\ $\sigma_{e}^2$ (1.44) & 1.41 & 0.06 & 0.03 & 0.01 & 0.92 \\ $\sigma_{s}^2$ (0.49)& 0.54 & 0.08 & 0.05 & 0.02 & 0.92 \\ \hline &\multicolumn{5}{c}{\textit{35\% missing responses}}\\ \hline Intercept (4.50) & 4.55 & 0.10 & 0.05 & 0.02 & 0.89 \\ Period$_1$ (0.20) & 0.09 & 0.08 & 0.11 & 0.02 & 0.75 \\ Trt$_1$ (1.06) & 0.96 & 0.08 & 0.10 & 0.02 & 0.77 \\ Res$_1$ (0.46)& 0.40 & 0.10 & 0.06 & 0.02 & 0.91 \\ Res$_2$ (1.09)& 1.02 & 0.10 & 0.07 & 0.02 & 0.91 \\ Res$_3$ (0.50) & 0.43 & 0.10 & 0.07 & 0.02 & 0.93 \\ $\sigma_{e}^2$ (1.44)& 1.40 & 0.06 & 0.04 & 0.01 & 0.89 \\ $\sigma_{s}^2$ (0.49)& 0.58 & 0.09 & 0.09 & 0.02 & 0.92 \\ \hline \end{tabular} \end{center} \end{table} In order to check the asymptotic normality of the MCEM estimators, empirical probability density curve of each of the standardized estimator was compared with the standard normal density curve. \Cref{fig:asy norm} displays empirical PDF of the standardized MCEM estimates with varying missing percentages and number of simulations. From the \cref{fig:asy norm}, note as the number of simulations increase, the MCEM estimators (standardized one) are closer to asymptotic normality. The \texttt{R} programs are available on request from the first author. \begin{figure}[!htp] \centering \includegraphics[width=12cm]{figure_AN1.png} \caption{\textbf{\small Empirical PDF of standardized MCEM estimates; Plots (A, C) corresponds to cases with 100 simulated data sets when missingness is 15\% and 25\% respectively. Plots (B, D) corresponds to cases with 500 simulated data sets when missingness is 15\% and 25\% respectively. }} \label{fig:asy norm} \end{figure} Further, we tested the following hypotheses using the MCEM-LRT procedure detailed in \cref{power} and computed the power of the following tests: \begin{itemize} \item[(i)] Tests for response variate effects: $H_{0}: \beta_{r_1}=\beta_{r_2}=\beta_{r_3}=0$ versus $H_1$: At least one $\beta_{r_i}\neq 0$ for $i=1,2,3$. \item[(ii)] We also performed the pairwise tests of response variates, \item[(iii)] To test for the treatment effect we used, $H_{0}: \beta_{\tau}=0$ vs $H_{1}: \beta_{\tau} \neq 0$ \end{itemize} For empirical power computations we list the steps: \begin{itemize} \item[(a)] For data simulation we used the true values of the parameters from Table 1. The proposed MCEM algorithm was used to find the estimates of the unknown parameters and variance components, $\theta$, and denoted as $\hat{\theta}_{full}$. \item[(b)] To obtain the restricted estimates we maximised the Q- function under $H_{0}$, and computed $\hat{\theta}_{reduced}$. \item[(c)] Using $\hat{\theta}_{full}$ and $\hat{\theta}_{reduced}$, the test statistic $T=2 Q(\hat{\theta})-2 Q(\hat{\theta}_{0})$ was determined and compared with $C=\chi^2_{(1-\alpha, d f)}$, where df is the difference between the number of parameters in full and reduced model. \item[(d)] The steps (a) – (d) were repeated $1000$ times. \item[(e)] The empirical power was computed as the proportion of times $H_0$ is rejected. \end{itemize} Figures \ref{fig:power plots gene} and \ref{fig:power plots trt} show the variation in the power function with respect to sample size and $\%$ of missingness $(15\%, 25\%\;\text{and}\; 35\%)$. From these plots we note that power increases with sample size (or number of total subjects) and decreases with $\%$ of missingness. Note, power values in \Cref{fig:power plots gene} plot C are low due to the small effect size (difference between $\beta_{r_1}$ and $\beta_{r_3}$ is small). Similarly, in Figure \ref{fig:power plots trt} we see the power values decrease as we decrease the effect size (or as alternative value of $\beta_{\tau}$ decreases). \begin{figure}[!htp] \centering \includegraphics[width=10cm]{figure_gene.png} \caption{\textbf{\small Power values of MCEM LRTs; The points plotted indicate the empirical proportion of test (by use of a nominal level $\alpha$ = 0.05) that rejected the $H_0$ among 1000 simulated data sets. The plot on the left (A) correspond to the case with testing hypothesis on significance of response variates. Plots on the right (B, C, D) correspond to the case with testing hypothesis on pairwise comparison of response variates.}} \label{fig:power plots gene} \end{figure} \begin{figure}[!htp] \centering \includegraphics[width=10cm]{figure_Trt.png} \caption{\textbf{\small Power values of MCEM LRTs; The points plotted indicate the empirical proportion of test (by use of a nominal level $\alpha$ = 0.05) that rejected the $H_0$ among 1000 simulated data sets. Plots A, B, C, D correspond to the case with testing hypothesis on treatment when alternative value of treatment effect is 1.06, -0.7, 0.5, 0.2, respectively.}} \label{fig:power plots trt} \end{figure} \section{Gene case study results}\label{reldat} Based on the exploratory analysis discussed in Section 2, we fitted the following normal cross over model: \begin{align*} y_{i j k l}&=\beta_{0}+\beta_{1} \text {Period}_{2}+\beta_{2} \text {Period}_{3}+\beta_{3} \mathrm{Trt}_{2}+\beta_{4} \mathrm{Trt}_{3}+\beta_{5} \text {Gene}_{2}\\&+\beta_{6} \text {Gene}_{3}+\beta_{7} \text {Gene}_{4} +\beta_{8} \text {Gene}_{5}+\beta_{9} \text {Gene}_{6}+\beta_{10} \text {Gene}_{7}\\&+\beta_{11} \text {Gene}_{8}+\beta_{12} \text {Gene}_{9}+\beta_{13} \text {Gene}_{10}+s_{i k} +e_{i j k l} \numberthis \label{eq:11} \end{align*} where for the real data $i,j=1,2,3;\, l=1(1)10$ and $k=1(1)n_i$, where $n_1=n_2=6$ and $n_3=5$. The random effects $s_{i k}$ and $e_{i j k l}$ were assumed to be independent normal variates with variances $\sigma_{s}^{2}$ and $\sigma_{e}^{2}$, respectively. The period, treatment and gene effects were taken to be fixed and were represented by corresponding indicator variables. We assumed that the missing data mechanism is MAR. Table \ref{table real data} reports the maximum likelihood estimates of the parameters $(\bm{\beta},\sigma_{e}^2,\sigma_{s}^2)$ from the normal crossover model presented in \cref{eq:11}. For the MCEM algorithm, ANOVA estimates were used as initial values of the parameters. Standard errors of the estimates and their corresponding p-values obtained by the MCEM-LRT test procedure are also presented in \cref{sec mle missing}. One hundred imputations, each with burn-in of one thousand, were used for standard error estimation. In order to check the model adequacy computed the root mean square error (RMSE) of marginal residuals along with AIC and BIC values. The missing data estimates were compared with complete case analysis results. From \cref{table real data}, we observe that gene$_2$, gene$_3$, gene$_4$, gene$_5$ gene$_6$, gene$_7$, gene$_8$, gene$_9$, gene$_{10}$ were significant at level of significance $0.10$ in both complete case and missing case results. From the negative coefficients of the gene effects, we saw that the presence of that particular gene has a decreasing effect on the allergic reaction. Also, we note the AIC and BIC values of MAR responses model were much smaller as compared to complete case analysis. However, if instead of the responses we worked with log(responses) then the AIC, BIC values reduced further. From the RMSE of the residuals, we saw that the best fit was obtained by fitting the normal crossover model (\cref{eq:11}) to log(responses). We also artificially increased the number of missing responses from $9\%$ to $21\%$ and $24\%$. The corresponding results are given in \cref{table real data more missing}. We used a Bernoulli random variable for creating the artificially missing responses. For the $21\%$ case, we assumed that if there is a missing response for any gene in a specific period then all other responses are also missing. This mimicked the property of the actual real data set. However, in the $24\%$ missingness case we assumed that in a specific period only some gene responses (not necessarily all) were missing. Under the higher missing percentage also, the gene effects were seen to be highly significant. The AIC, BIC and RMSE values for responses and log(responses) were also computed. \begin{table}[!htp] \tiny \centering \caption{Results based on the Gene data} \label{table real data} \begin{tabular}{lrrrrrrrrr} \hline Variable & MLE &SE &p-value& MLE & SE&p-value& MLE & SE &p-value\\ \hline &\multicolumn{3}{c}{\textit{Complete Cases}} & \multicolumn{3}{c}{\textit{MAR Responses}}&\multicolumn{3}{c}{\textit{log MAR Responses}} \\ \hline Intercept & 3.49 & 0.02 &$<$0.0001 &3.49 & 0.02&$<$0.0001 &1.25&0.01 & $<$0.0001\\ Period$_2$ & 0.001 & 0.01 & 0.96 &-0.002 & 0.01& 0.73 &-0.003&0.01&0.58 \\ Period$_3$ & 0.01& 0.01 &0.40 & 0.01 & 0.01 & 0.39 &0.004&0.01&0.35\\ Trt$_2$ & -0.01 & 0.01 & 0.70 &-0.01 & 0.01& 0.58 &-0.003&0.01&0.57 \\ Trt$_3$ & 0.01 & 0.01 & 0.57 &0.01 & 0.01& 0.58 &0.002&0.01&0.61 \\ Gene$_2$ & -0.93 & 0.03 &$<$0.0001 &-0.94 & 0.02& $<$0.0001 &-0.32&0.01 &$<$0.0001 \\ Gene$_3$ & -1.59 & 0.03 &$<$0.0001 &-1.59 & 0.02& $<$0.0001&-0.61&0.01&$<$0.0001 \\ Gene$_4$ & -0.33 & 0.03 & $<$0.0001 &-0.33 & 0.02& $<$0.0001 &-0.10&0.01 &$<$0.0001\\ Gene$_5$ & -0.04 & 0.03 &0.14 &-0.04 & 0.02& 0.08 &-0.02&0.01&0.28 \\ Gene$_6$& -1.27 & 0.03 & $<$0.0001 &-1.27 & 0.02& $<$0.0001 &-0.45&0.01 &$<$0.0001\\ Gene$_7$ & -1.48 & 0.03 &$<$0.0001 &-1.47 & 0.02& $<$0.0001 &-0.55&0.01& $<$0.0001\\ Gene$_8$ & -2.03 & 0.03 &$<$0.0001 &-2.02 & 0.02& $<$0.0001&-0.87&0.01& $<$0.0001\\ Gene$_9$ & -0.82 & 0.03 & $<$0.0001 &-0.82 & 0.02&$<$0.0001 &-0.27&0.01&$<$0.0001 \\ Gene$_{10}$ & -0.65 & 0.03 &$<$0.0001 &-0.63 & 0.02&$<$0.0001 &-0.20&0.01& $<$0.0001\\ $\sigma_{e}^2$ & 0.01 & 0.001 & - &0.01 & 0.001& -&0.002&0.0001& -\\ $\sigma_{s}^2$ & 0.001 & 0.0004 &- &0.001 & 0.0004&- &0.0001&0.0001& -\\ \hline AIC &-545.5&&& -1853.84 &&& -2686.15 &\\ BIC &-483.3 &&& -1786.10 &&& -2618.40 &\\ RMSE &0.11 &&&0.11&&&0.05&\\ \hline \end{tabular} \end{table} \begin{table}[!htp] \tiny \centering \caption{Results based on the Gene data when we increase missing values} \label{table real data more missing} \begin{tabular}{lrrrrrr} \hline Variable & MLE &SE &p-value& MLE & SE&p-value\\ \hline &\multicolumn{5}{c}{\textit{21\% missing}} \\ \hline &\multicolumn{3}{c}{\textit{original responses}} & \multicolumn{3}{c}{\textit{log responses}} \\ \hline Intercept & 3.49 & 0.02 & $<$0.0001 & 1.25 & 0.01 &$<$0.0001 \\ Period$_2$ & -0.003 & 0.01 & 0.48 & -0.003 & 0.004 &0.39 \\ Period$_3$ & 0.01 & 0.01 & 0.28 & 0.005 & 0.004 &0.21 \\ Treatment$_2$ & -0.001 & 0.01 & 0.53 & -0.0004 & 0.004 & 0.57 \\ Treatment$_3$ & 0.003 & 0.01 &0.74 & 0.001 & 0.004 &0.53 \\ Gene$_2$ & -0.93 & 0.02 & $<$0.0001 & -0.31 & 0.01 & $<$0.0001 \\ Gene$_3$ & -1.60 & 0.02 & $<$0.0001 & -0.61 & 0.01 & $<$0.0001 \\ Gene$_4$ & -0.33 & 0.02 & $<$0.0001 & -0.09 & 0.01 &$<$0.0001 \\ Gene$_5$ & -0.04 & 0.02 &0.06 & -0.01 & 0.01 &0.19 \\ Gene$_6$ & -1.27 & 0.02 & $<$0.0001 & -0.45 & 0.01 & $<$0.0001 \\ Gene$_7$ & -1.47 & 0.02 & $<$0.0001 & -0.55 & 0.01 & $<$0.0001 \\ Gene$_8$ & -2.02 & 0.02 & $<$0.0001 & -0.86 & 0.01 & $<$0.0001 \\ Gene$_9$ & -0.82 & 0.02 & $<$0.0001 & -0.27 & 0.01 & $<$0.0001 \\ Gene$_{10}$ & -0.63 & 0.02 & $<$0.0001 & -0.20 & 0.01 & $<$0.0001 \\ $\sigma_e^{2}$ & 0.01 & 0.001 & - & 0.002 & 0.0001 &- \\ $\sigma_s^{2}$& 0.001 & 0.0003 & - & 0.0001 & 0.0001 & -\\ \hline AIC &-1907.4&&&-2758.3 &\\ BIC &-1839.6 &&& -2690.5&\\ RMSE &0.09 &&&0.04&\\ \hline & \multicolumn{5}{c}{\textit{24\% missing}} \\ \hline &\multicolumn{3}{c}{\textit{original responses}} & \multicolumn{3}{c}{\textit{log responses}} \\ \hline Intercept & 3.49 & 0.02 &$<$0.0001 &1.25 &0.01 &$<$0.0001 \\ Period$_2$ & -0.01 & 0.01 &0.24& -0.005&0.005 & 0.18 \\ Period$_3$ & 0.004 & 0.01 &0.45&0.002&0.005& 0.38 \\ Treatment$_2$ & -0.004 & 0.01 & 0.45&-0.002&0.005&0.42 \\ Treatment$_3$ & 0.01 & 0.01 &0.29&0.005&0.005&0.25 \\ Gene$_2$ & -0.93 & 0.02 & $<$0.0001&-0.31&0.01&$<$0.0001 \\ Gene$_3$ & -1.58 & 0.02 & $<$0.0001&-0.60&0.01& $<$0.0001 \\ Gene$_4$ & -0.33 & 0.02 &$<$0.0001 &-0.10&0.01& $<$0.0001 \\ Gene$_5$ & -0.03 & 0.02 &0.08 &-0.01&0.01&0.21 \\ Gene$_6$ & -1.26 & 0.02 & $<$0.0001&-0.45&0.01& $<$0.0001 \\ Gene$_7$ & -1.47 & 0.02 & $<$0.0001&-0.55&0.01&$<$0.0001 \\ Gene$_8$ & -2.02& 0.02 & $<$0.0001&-0.87&0.01& $<$0.0001 \\ Gene$_9$ & -0.82 & 0.02 & $<$0.0001&-0.27&0.01& $<$0.0001 \\ Gene$_{10}$ & -0.64 & 0.02 & $<$0.0001&-0.20&0.01& $<$0.0001 \\ $\sigma_e^{2}$ & 0.01 & 0.001 &- &0.003&0.0001& - \\ $\sigma_s^{2}$ & 0.001 & 0.0003 &- &0.0001&0.00004&- \\ \hline AIC &-1830.9&&& -2652.6 &\\ BIC &-1763.2 &&& -2584.8 &\\ RMSE &0.10 &&&0.04&\\ \hline \end{tabular} \end{table} \section{Concluding remarks} In this paper we studied statistical model to analyse incomplete data in multivariate crossover setup. We presented the MCEM-LRT to test the fixed effects in the proposed set up, and exhibited the power analysis. This idea can be extended to non-ignorable missing (NMAR) case, where the parametric model for missing or the the missing data mechanism needs to be incorporated into the complete data log likelihood. As a consequence the estimation problem becomes more complex.\\ \noindent {\bf{Acknowledgement}} We thank Dr. Atanu Bhattacharjee, Tata Memorial Center, Mumbai, India for his assistance in obtaining the gene data set. \vspace*{1pc} \noindent {\bf{Conflict of Interest}} \noindent {{The authors have declared no conflict of interest.}} \bibliographystyle{plainnat}
{'timestamp': '2021-03-12T02:18:17', 'yymm': '2103', 'arxiv_id': '2103.06567', 'language': 'en', 'url': 'https://arxiv.org/abs/2103.06567'}
arxiv
\section{Prior Work \& Background Information} It is necessary to discuss several results from prior work to provide context for the contribution of this article and to lay preliminary groundwork for the technical approach of the proposed algorithm. This section includes a discussion of how $(X,Y,Z)$ point clouds are computed from RGBD sensor data, the nature of RGBD sensor data noise, and a discussion of leading approaches for 3D planar surface estimation from point cloud data. \subsection{Point Cloud Reconstruction} Measured 3D $(X,Y,Z)$ positions of sensed surfaces can be directly computed from the intrinsic RGBD camera parameters and the measured depth image values. The $Z$ coordinate is directly taken as the depth value and the $(X,Y)$ coordinates are computed using the pinhole camera model. In a typical pinhole camera model, 3D $(X,Y,Z)$ points are projected to $(x,y)$ image locations, e.g., for the image columns the $x$ image coordinate is $x=f_{x}\frac{X}{Z}+c_{x}-\delta_{x}$. However, for a depth image, this equation is re-organized to ``back-project'' the depth into the 3D scene and recover the 3D $(X,Y)$ coordinates as shown by equation (\ref{eq:RGBD_reconstruction}) \begin{equation} \begin{array}{ccc} X & = & (x+\delta_{x}-c_{x})Z/f_{x}\\ Y & = & (y+\delta_{y}-c_{y})Z/f_{y}\\ Z & = & Z \end{array}\label{eq:RGBD_reconstruction} \end{equation} where $Z$ denotes the sensed depth at image position $(x,y)$, $(f_{x},f_{y})$ denotes the camera focal length (in pixels), $(c_{x},c_{x})$ denotes the pixel coordinate of the image center, i.e., the principal point, and $(\delta_{x},\delta_{y})$ denote adjustments of the projected pixel coordinate to correct for camera lens distortion. \subsection{Measurement Noise} Studies of accuracy for the Microsoft Kinect sensor show that a Gaussian noise model provides a good fit to observed measurement errors on planar targets where the distribution parameters are mean $0$ and standard deviation $\sigma_{Z}=\frac{m}{2f_{x}b}Z^{2}$ for depth measurements where $\frac{m}{f_{x}b}=-2.85e^{-3}$ is the linearized slope for the normalized disparity empirically found in \cite{s120201437}. Since 3D the coordinates for $(X,Y)$ are a function of both the pixel location and the depth, their distributions are also known as shown below: \begin{equation} \begin{array}{ccc} \sigma_{X} & = & \frac{x-c_{x}+\delta_{x}}{f_{x}}\sigma_{Z}=\frac{x-c_{x}+\delta_{x}}{f_{x}}(1.425e^{-3})Z^{2}\\ \sigma_{Y} & = & \frac{y-c_{y}+\delta_{y}}{f_{y}}\sigma_{Z}=\frac{y-c_{y}+\delta_{y}}{f_{y}}(1.425e^{-3})Z^{2}\\ \sigma_{Z} & = & \frac{m}{f_{x}b}Z^{2}\sigma_{d'}=(1.425e^{-3})Z^{2} \end{array}\label{eq:noise_models} \end{equation} These equations indicate that 3D coordinate measurement uncertainty increases as a quadratic function of the depth for all three coordinate values. However, the quadratic coefficient for the $(X,Y)$ coordinate standard deviation is at most half that in the depth direction, i.e., $(\sigma_{X},\sigma_{Y})\approx0.5\sigma_{Z}$ at the image periphery where $\frac{x-c_{x}}{f}\approx0.5$, and this value is significantly smaller for pixels close to the optical axis. \subsection{Implicit Plane Fitting to Point Cloud Data} This section discussed the typical approach for 3D plane fitting which estimated the plane when expressed as an implicit polynomial. We refer to this approach as the implicit fitting method which seeks to minimize the square of the perpendicular distance between $N$ measured $(X,Y,Z)$ data points and the estimated planar model, i.e., \begin{equation} \epsilon(a,b,c,d)=\min_{a,b,c,d}\sum_{i=1}^{N}\left\Vert aX_{i}+bY_{i}+cZ_{i}+d\right\Vert ^{2}\label{eq:implicit_plane_fitting_error} \end{equation} We re-write this objective function as a quadratic matrix-vector product by defining the vector $\mathbf{{\alpha}}=[\begin{array}{cccc} a & b & c & d\end{array}]^{t}$ as the vector of planar coefficients and the matrix $\mathbf{{M}}$ as the matrix of planar monomials formed from the measured $(X,Y,Z)$ surface data having $i^{th}$ row $\mathbf{{M}}_{i}=[\begin{array}{cccc} X_{i} & Y_{i} & Z_{i} & 1\end{array}]$. Using this notation, the optimization function becomes: \[ \epsilon(\mathbf{{\alpha}})=\min_{\mathbf{\alpha}}\mathbf{{\alpha}}^{t}\mathbf{M}^{t}\mathbf{M}\mathbf{{\alpha}} \] Solving for the unknown plane equation coefficients requires a constraint on the coefficient vector: $\left\Vert \mathbf{{\alpha}}\right\Vert ^{2}=\mathbf{{\alpha}}^{t}\mathbf{{\alpha}}=1$ to avoid the trivial solution $\mathbf{{\alpha}}=\mathbf{{0}}$. Equation (\ref{eq:quadratic_error_w_lagrange_multiplier}) incorporates this constraint as a Lagrange multiplier. \begin{equation} \epsilon(\mathbf{{\alpha}})=\min_{\mathbf{\alpha}}\left(\mathbf{{\alpha}}^{t}\mathbf{M}^{t}\mathbf{M}\mathbf{{\alpha}}-\lambda\left(\mathbf{{\alpha}}^{t}\mathbf{I}\mathbf{{\alpha}}-1\right)\right)\label{eq:quadratic_error_w_lagrange_multiplier} \end{equation} Taking the derivative of the error function then provides \begin{equation} \frac{d\epsilon(\mathbf{{\alpha}})}{d\mathbf{{\alpha}}}=\min_{\mathbf{\alpha}}\left(\left(\mathbf{M}^{t}\mathbf{M}-\lambda\mathbf{I}\right)\mathbf{{\alpha}}\right)\label{eq:derivative of error} \end{equation} Then from \cite{Fitzgibbon:1999:DLS:302943.302950,Taubin:Fitting:1991,Trucco:1998:ITC:551277} the minimizer is known to be $\mathbf{\widehat{{\alpha}}}$, the eigenvector associated with the smallest eigenvalue of the matrix $\mathbf{M}^{t}\mathbf{M}$ (also known as the scatter matrix). In general, $\mathbf{M}^{t}\mathbf{M}$ is a symmetric matrix and, for the monomials $\mathbf{{M}}_{i}=[\begin{array}{cccc} X_{i} & Y_{i} & Z_{i} & 1\end{array}]$, the elements of this matrix are \begin{equation} \mathbf{M}^{t}\mathbf{M}=\sum_{i=1}^{N}\left[\begin{array}{cccc} X_{i}^{2} & X_{i}Y_{i} & X_{i}Z_{i} & X_{i}\\ X_{i}Y_{i} & Y_{i}^{2} & Y_{i}Z_{i} & Y_{i}\\ X_{i}Z_{i} & Y_{i}Z_{i} & Z_{i}^{2} & Z_{i}\\ X_{i} & Y_{i} & Z_{i} & 1 \end{array}\right]\label{eq:XYZ_scattermatrix} \end{equation} Fitting implicit planar surfaces to point cloud data has become the de-facto standard for point cloud processing algorithms and is now part of many standard point cloud and image processing libraries, e.g., OpenCV and PCL (Point Cloud Library) \cite{itseez2015opencv,Rusu_ICRA2011_PCL}. It's popularity is due to it's relatively low computational cost and the fact that it is Euclidean invariant. \subsection{\label{subsec:Explicit_Plane_Fitting}Explicit Plane Fitting to Point Cloud Data} The explicit formulation seeks to minimize the square of the distance between the measured data points and the estimated planar model with respect to the plane at $Z=0$ or the $XY-$plane as shown by the objective function (\ref{eq:explicit_fit_std}). \begin{equation} \epsilon(a,b,c)=\min_{a,b,c}\sum_{i=1}^{N}\left(aX_{i}+bY_{i}+c-Z_{i}\right)^{2}\label{eq:explicit_fit_std} \end{equation} Note that, in contrast to equation (\ref{eq:implicit_plane_fitting_error}), this planar model has explicit form $f(X,Y)=Z$. Minimization of this error seeks to estimate the Z-offset, $c$, and slope of the plane with respect to the $x$-axis, $a$, and $y$-axis, \textbf{$b$.} To optimize this function, we re-write the objective function as a quadratic matrix-vector product by defining the vector $\mathbf{{\alpha}}=[\begin{array}{ccc} a & b & c\end{array}]^{t}$ as the vector of planar coefficients, the vector $\mathbf{b}=[\begin{array}{cccc} Z_{0} & Z_{1} & \ldots & Z_{N}]^{t}\end{array}$ which denotes the target depth values and the matrix $\mathbf{{M}}$ as the matrix of planar monomials formed from the 3D $(X,Y,Z)$ surface data having $i^{th}$ row $\mathbf{{M}}_{i}=[\begin{array}{ccc} X_{i} & Y_{i} & 1\end{array}]$. Using this notation, the optimization function becomes: \[ \epsilon(\mathbf{{\alpha}})=\min_{\mathbf{\alpha}}\left(\mathbf{{\alpha}}^{t}\mathbf{M}^{t}\mathbf{M}\mathbf{{\alpha}}-2\mathbf{{\alpha}}^{t}\mathbf{M}^{t}\mathbf{b}+\mathbf{b}^{t}\mathbf{b}\right) \] Taking the derivative of the error function and setting it to zero provides: \begin{equation} \frac{d\epsilon(\mathbf{{\alpha}})}{d\mathbf{{\alpha}}}=\mathbf{M}^{t}\mathbf{M}\mathbf{{\alpha}}-\mathbf{M}^{t}\mathbf{b}=0\label{eq:derivative of error-1} \end{equation} A solution to this system of equations is obtained via $\mathbf{\widehat{{\alpha}}}=\left(\mathbf{M}^{t}\mathbf{M}\right)^{-1}\mathbf{M}^{t}\mathbf{b}$. Again, $\mathbf{M}^{t}\mathbf{M}$ is a symmetric matrix and, for the monomials $\mathbf{{M}}_{i}=[\begin{array}{ccc} X_{i} & Y_{i} & 1\end{array}]$, the elements of the matrix-vector product are \begin{equation} \mathbf{M}^{t}\mathbf{M}=\sum_{i=1}^{N}\left[\begin{array}{ccc} X_{i}^{2} & X_{i}Y_{i} & X_{i}\\ X_{i}Y_{i} & Y_{i}^{2} & Y_{i}\\ X_{i} & Y_{i} & 1 \end{array}\right],\mathbf{M}^{t}\mathbf{b}=\sum_{i=1}^{N}Z_{i}\left[\begin{array}{c} X_{i}\\ Y_{i}\\ 1 \end{array}\right]\label{eq:XYZ_scattermatrix-1} \end{equation} Researchers have found that explicit fitting methods perform similarly to implicit methods when measurements of the surface are normally distributed. However, there is bias associated with the explicit fitting objective function. Specifically, errors for explicit fits are are measured along the $Z$ axis. This has the effect that, in contrast to the implicit fitting approach, the estimated coefficients are not Euclidean invariant. For this reason explicit fitting methods are less popular for point cloud data. \section{Methodology} Our new approach for 3D plane fitting suggests a rearrangement of the standard plane fitting error functions for RGBD sensor data. While standard planar representations adopt an implicit or explicit form of equation $aX+bY+cZ+d=0,$ our approach substitutes the RGBD 3D reconstruction equations of \S~\ref{eq:RGBD_reconstruction} for the variables $X$ and $Y$ and then simplifies the equation to forms that require less computational cost to solve. We start by investigating the RGBD reconstruction equations and grouping the parameters into two sets: (1) the RGBD camera calibration parameters $\left\{ f_{x},f_{y},c_{x}c_{y},\delta_{x},\delta_{y}\right\} $ and (2) the depth measurement $Z$. Fig. \ref{fig:tan_theta} shows the geometry of the RGBD depth measurement using these parameters. Here, we show the angle, $\theta_{x}$, that denotes the angle between the optical axis and line passing through the RGBD image pixel $(x,y)$ when viewed from the top-down. A similar angle, $\theta_{y}$, is obtained using the same geometric setup from a side-view. Hence, we make the substitutions shown in (\ref{eq:RGBD_reconstruction}) for the terms of the reconstruction equations resulting in the new reconstruction equations (\ref{eq:RGBD_reconstruction-1-1}): \begin{equation} \begin{array}{ccc} \tan\theta_{x} & = & (x+\delta_{x}-c_{x})/f_{x}\\ \tan\theta_{y} & = & (y+\delta_{y}-c_{y})/f_{y}\\ Z & = & Z \end{array}\label{eq:RGBD_reconstruction-1} \end{equation} \begin{equation} \begin{array}{ccc} X & = & Z\tan\theta_{x}\\ Y & = & Z\tan\theta_{y}\\ Z & = & Z \end{array}\label{eq:RGBD_reconstruction-1-1} \end{equation} \begin{figure} \begin{centering} \includegraphics[scale=0.33]{figs/tan_theta_fig} \par\end{centering} \caption{\label{fig:tan_theta} Note the relationship formed by the tangent of the angle \ensuremath{\theta}\protect\textsubscript{x}. A similar relationship exists in the y direction.} \end{figure} Back-substitution into the plane equation gives $aZ\tan\theta_{x}+bZ\tan\theta_{y}+cZ+d=0$. We now multiply this equation by $1/Z$ to arrive at the equation (\ref{eq:RGBD_space_plane_eq}): \begin{equation} a\tan\theta_{x}+b\tan\theta_{y}+c+\frac{d}{Z}=0\label{eq:RGBD_space_plane_eq} \end{equation} This re-arrangement of terms is the key to the contributions proposed in this article. The benefits of this rearrangement are as follows: \begin{itemize} \item Coefficients $a,b,c$ are functions of \emph{only the RGBD camera calibration parameters} which determine, for each RGBD image pixel, the values of $\tan\theta_{x}$ and $\tan\theta_{y}$. \item Coefficient $d$ is \emph{only }a linear function of the measured depth (inverse depth). \item Objective functions defined using equation (\ref{eq:RGBD_space_plane_eq}) separate uncertainty in camera calibration parameters (coefficients $a,b,c$) from uncertainty in the measured data $d$. \end{itemize} In contrast to prior work \cite{6233120,TitusJiaJieTang2011} which adopts the planar parameterization of equation (\ref{eq:prior_work_plane_equation}), \begin{equation} \frac{af\beta}{d}\frac{X}{Z}+\frac{bf\beta}{d}\frac{Y}{Z}+\frac{cf\beta}{d}=\frac{f\beta}{Z}\label{eq:prior_work_plane_equation} \end{equation} where $\beta$ is the horizontal baseline parameter, and $f$ is the (common) focal length, our parameterization isolates measured depth data from the RGBD camera calibration parameters. This provides computational benefits heretofore not discussed in published work. \subsection{Implicit Plane Fitting to RGBD Range Data} For implicit plane fitting using the re-organized equation (\ref{eq:RGBD_space_plane_eq}), the new monomial vector becomes $\mathbf{{M}}_{i}=[\begin{array}{cccc} \tan\theta_{x_{i}} & \tan\theta_{y_{i}} & 1 & \frac{1}{Z_{i}}\end{array}]$ and the scatter matrix has elements: \begin{equation} \mathbf{M}^{t}\mathbf{M}=\sum_{i=1}^{N}\left[\begin{array}{cccc} \tan\theta_{x_{i}}{}^{2}\\ \tan\theta_{x_{i}}\tan\theta_{y_{i}} & \tan\theta_{y_{i}}^{2}\\ \tan\theta_{x_{i}} & \tan\theta_{y_{i}} & 1\\ \frac{\tan\theta_{x_{i}}}{Z_{i}} & \frac{\tan\theta_{y_{i}}}{Z_{i}} & \frac{1}{Z_{i}} & \frac{1}{Z_{i}^{2}} \end{array}\right]\label{eq:tan_theta_scattermatrix} \end{equation} where the symmetric elements of the upper-triangular matrix have been omitted to preserve space. It is important to note that only 4 elements of this matrix, $[\begin{array}{cccc} \frac{\tan\theta_{x_{i}}}{Z_{i}} & \frac{\tan\theta_{y_{i}}}{Z_{i}} & \frac{1}{Z_{i}} & \frac{1}{Z_{i}^{2}}\end{array}]$, depend on the measured depth data and, as such, this matrix requires less (\textasciitilde{}50\% less) operations to compute. The key contribution of this article is to make the observation that the upper left 3x3 matrix of $\mathbf{M}^{t}\mathbf{M}$ \emph{does not depend upon the measured sensor data! }As such, once the calibration parameters of the camera are known, i.e., $(f_{x},f_{y})$, $(c_{x},c_{x})$, $(\delta_{x},\delta_{y})$, \emph{determine all of the elements of $\mathbf{M}^{t}\mathbf{M}$ and may be pre-computed before any data is measured} with the exception of the 4 elements in the bottom row. \subsection{Explicit Plane Fitting to RGBD Range Data} For explicit plane fitting using the re-organized equation (\ref{eq:RGBD_space_plane_eq}), the revised error function is shown below: \begin{equation} \epsilon(a,b,c,d)=\min_{a,b,c}\sum_{i=1}^{N}\left(a\tan\theta_{x_{i}}+b\tan\theta_{y_{i}}+c-\frac{1}{Z_{1}}\right)^{2}\label{eq:RGBD_explicit_fit} \end{equation} Let $\mathbf{{\alpha}}=[\begin{array}{ccc} a & b & c\end{array}]^{t}$ denote the vector of explicit plane coefficients, $\mathbf{b}=1/[\begin{array}{cccc} Z_{0} & Z_{1} & \ldots & Z_{N}]^{t}\end{array}$ denote the target depth values and $\mathbf{{M}}$ denote the matrix of planar monomials formed from the 3D $(X,Y,Z)$ surface data having $i^{th}$ row $\mathbf{{M}}_{i}=[\begin{array}{ccc} \tan\theta_{x_{i}} & \tan\theta_{y_{i}} & 1\end{array}]$. Then equation (\ref{eq:tan_theta_scattermatrix-1}) shows the scatter matrix, $\mathbf{M}^{t}\mathbf{M}$, needed to estimated the explicit plane coefficients where the symmetric elements of the upper-triangular matrix have been omitted to preserve space. \begin{equation} \mathbf{M}^{t}\mathbf{M}=\sum_{i=1}^{N}\left[\begin{array}{ccc} \tan\theta_{x_{i}}{}^{2}\\ \tan\theta_{x_{i}}\tan\theta_{y_{i}} & \tan\theta_{y_{i}}^{2}\\ \tan\theta_{x_{i}} & \tan\theta_{y_{i}} & 1 \end{array}\right]\label{eq:tan_theta_scattermatrix-1} \end{equation} It is important to note that \emph{none of the} \emph{elements of the scatter matrix depend on the measured depth data and, as such, this matrix requires a constant number of operations to compute for each measured image, i.e., it can be pre-computed given the RGBD camera parameters. }Hence, explicit plane fitting in the RGBD range space requires only computation of the vector $\mathbf{b}=1/[\begin{array}{cccc} Z_{0} & Z_{1} & \ldots & Z_{N}]\end{array}$ for each range image and the best-fit plane is given by a single matrix multiply: $\mathbf{\widehat{{\alpha}}}=\left(\mathbf{M}^{t}\mathbf{M}\right)^{-1}\mathbf{M}^{t}\mathbf{b}$. Where the value of $\mathbf{M}^{t}\mathbf{b}$ is given below: \[ \mathbf{M}^{t}\mathbf{b}=\sum_{i=1}^{N}\frac{1}{Z_{i}}\left[\begin{array}{c} \tan\theta_{x_{i}}\\ \tan\theta_{y_{i}}\\ 1 \end{array}\right] \] \subsection{\label{subsec:Integral_Images}Computational Savings via Integral Images} Integral images, first introduced in \cite{lewis1995fast} and popularized in the vision community by the work \cite{990517}, computes the cumulative distribution of values within an image. This technique is often applied for the purpose of efficiently computing sums over arbitrary rectangular regions of an image. This is often the case for normal estimation in range images. Here, integral images are computed for the $(X,Y,Z)$ values or perhaps for all values of the scatter matrix of equation (\ref{eq:XYZ_scattermatrix}). Computation of an integral image for a scalar value, e.g., intensity, requires 4 operations per pixel, i.e., for an image of $N$ pixels it has computational cost of $t=4N$ operations. More generally, computation of an integral image for an arbitrary function of the image pixel data $f(I(x,y))$ having computational cost $C$ has computational cost to $t=N(C+4)$. \subsection{\label{subsec:Implicit-Fitting-Cost}Implicit Fitting Computational Cost Analysis} Assuming that the images $(\tan\theta_{x}(x,y),\tan\theta_{y}(x,y))$ are pre-computed, the function $f()$ needed to compute $X$ and $Y$ coordinates requires one operation (a single multiplication) for each pixel, i.e., $C=1$ for these matrix elements. Likewise computation of $(X^{2},Y^{2},Z^{2},XY,XZ,YZ)$ from the $X$ and $Y$ coordinates requires an additional operation (again, multiplication), i.e., $C=1$ for these matrix elements. Since the depth is directly measured, computation of the depth integral image has no additional computational cost. Hence, computation of the integral images for the 9 unique elements of the scatter matrix of equation (\ref{eq:XYZ_scattermatrix}) requires $t_{std.}=8N(1+4)+4N=44N$ operations. Note that every element (except the constant) in this matrix is a function of the measured depth image data $Z$. In contrast, the scatter matrix of equation (\ref{eq:tan_theta_scattermatrix}) contains only 4 elements that depend on the depth data: $(\frac{\tan\theta_{x_{i}}}{Z_{i}},\frac{\tan\theta_{y_{i}}}{Z_{i}},\frac{1}{Z_{i}},\frac{1}{Z_{i}^{2}})$. As before, the function $f()$ needed to compute each term requires a single operation. Hence, integral images for all elements of the scatter matrix of equation (\ref{eq:tan_theta_scattermatrix}) requires $t_{new}=4N(1+4)=20N$ operations to compute where we do not include the cost of computing the constant integral images for the 5 elements of the matrix that do not depend on measured depth data (a cost of $t=20N$). Hence, analysis indicates that the computational cost of an integral-image based solution for the approach prescribed by equation (\ref{eq:XYZ_scattermatrix}) requires more than twice as many operations ($\frac{t_{std.}}{t_{new}}=2.2$) than the approach prescribed by equation (\ref{eq:tan_theta_scattermatrix}). Given that RGBD image data is captured at a resolution of $N=640\times480\approx307k$ and framerate of $30$ images/second these computational savings may significantly affect the runtime of real-time image processing algorithms for this class of image sensors. In a naive implementation using a square window containing $M$ pixels, each element of the scatter matrix requires ${\cal O}(M^{2})$ operations and the cost of computing these elements for an entire image of pixel data is ${\cal O}(NM^{2})$. In this case, the computational costs are $t_{std.}=8NM^{2}$ and $t_{new}=4NM^{2}$ (or a ratio $\frac{t_{std.}}{t_{new}}=2$) to implement equations (\ref{eq:XYZ_scattermatrix}) and (\ref{eq:tan_theta_scattermatrix}) respectively. \subsection{\label{subsec:Explicit-Fitting-cost}Explicit Fitting Computational Cost Analysis} Following the previous analysis and assuming an integral image implementation, the complexity of explicit fitting via equation (\ref{eq:XYZ_scattermatrix-1}) is $t_{std}=7N(4+1)+4N=39N$ and that of explicit fitting as in equation (\ref{eq:tan_theta_scattermatrix-1}) is $t_{new}=15N$. This suggests even larger computational savings than those found for implicit fitting, e.g., ($\frac{t_{std.}}{t_{new}}=2.6$), which may prove extremely beneficial for RGBD depth image processing, e.g., real-time surface analysis algorithms. Note that the computational complexity discussions for both implicit and explicit planar fits do not include the computational cost of computing eigenvectors or the matrix inverse respectively. In both cases the complexity of this operation is ${\cal O}(D^{3})$ where $D=3$ and this cost is not considered as it is common to all discussed methods. \section{Results} A series of timing experiments were performed using MATLAB on a 2.7 GHz i7-2620M processor to evaluate the runtime of the proposed fitting methods when compared to standard approaches. First, a 640x480 depth senor was modeled in terms of the parameters $(f_{x},f_{y})$, $(c_{x},c_{x})$, and $(\delta_{x},\delta_{y})$. A series of 3D rays was formed emanating from the center of each pixel through the focal point of the virtual camera. The intersection of these rays and an arbitrary 3D plane was computed and the resulting sample points perturbed with Gaussian noise in the direction of the measurement. Values for $\tan\theta_{x}(x,y)$ and $\tan\theta_{y}(x,y)$ were also computed during this process. These generated sample points and values for $\tan\theta_{x}(x,y)$, $\tan\theta_{y}(x,y)$ were then used in the following experiments. \subsection{Integral Image Implementation} Often, multiple planes are fit to subsets of a single frame of depth image data. It can be advantageous then, to employ integral images to more efficiently compute sums over arbitrary rectangular image regions as described in \S~\ref{subsec:Integral_Images}. Using this integral image implementation, fitting in RGBD range space is superior to the standard approach in terms of runtime. Fitting in RGBD range space has an advantage using this implementation due to the fact that integral images involving $\tan\theta_{x}(x,y)$ and $\tan\theta_{y}(x,y)$ can be pre-computed and do not change for a given sequence of range images. Therefore, fewer integral images need to be computed on a per image basis when compared to the standard approach using a similar integral image implementation. Fig. \ref{fig:Integral_Percent_Faster_vs_Iterations} compares the integral image implementations of both implicit and explicit RGBD range space fitting methods to their standard counterparts. For all integral methods, the time taken to compute the required integral images and fit a varying number of planes was compared. In the implicit case, integral image computation time was reduced by 45\% and individual plane fitting time was reduced by \textasciitilde{}15\% compared to the standard approach. Using explicit fitting, integral image computation time was reduced by 52\% and individual plane fitting time was reduced by \textasciitilde{}70\%. The reduction in integral image computation time is consistent with the analysis in \S~\ref{subsec:Implicit-Fitting-Cost} and \S~\ref{subsec:Explicit-Fitting-cost}. \begin{figure} \begin{centering} \includegraphics[width=7.75cm]{figs/Fit_Times_vs_Points_Combined_Integral} \par\end{centering} \caption{\label{fig:Integral_Times_vs_Points}Runtime comparison of implicit and explicit fitting approaches using the integral image implementation. This data includes time taken to compute these integral images and perform a single plane fit with a varying number of points. Note that the time taken to perform these operations is constant despite the increasing number of points used in each fit.} \end{figure} \begin{figure} \begin{centering} \includegraphics[width=7.75cm]{figs/Percent_Faster_Combined} \par\end{centering} \caption{\label{fig:Integral_Percent_Faster_vs_Iterations}Comparison of integral image RGBD range space plane fitting approaches vs integral image standard approaches for a single frame of depth image data. Computation of the integral images used in each method is included, with RGBD range space fitting approaches taking half as much time as time to compute the required integral images as their standard counterparts.} \end{figure} \begin{figure*} \begin{centering} \includegraphics[width=5.25cm]{figs/lab_corner_depth} \includegraphics[width=5.25cm]{figs/lab_corner_colormap_depth} \includegraphics[width=5.25cm]{figs/lab_corner_depth_segmented} \par\end{centering} \caption{\label{fig:Planar_Segmentation}Depth image planar segmentation of a room corner featuring a blackboard and window. Depth image (left), color mapped depth image (middle), and segmented image (right). The algorithm successfully fit 268 planes on the 512x424 image. Tiles with successful plane fits are shaded and outlined in green. Tiles with too many invalid points or high fit error are outlined in red and blue respectively.} \end{figure*} When performing implicit plane fitting in RGBD range space, precomputed values are used to fill the scatter matrix of equation (\ref{eq:tan_theta_scattermatrix}) directly, leaving only the 4 elements that depend on $\frac{1}{Z}$ to be computed for each image. In contrast, the standard plane fitting approach requires computation of all elements of the scatter matrix from equation (\ref{eq:XYZ_scattermatrix}). A similar implementation can be used for explicit plane fitting methods. When fitting in RGBD range space, there is a distinct advantage in terms of computation as the matrix elements of equation (\ref{eq:tan_theta_scattermatrix-1}) do not depend on the measured depth data. This matrix depends only on the camera's intrinsic parameters, and can be pre-computed. As shown in Fig. \ref{fig:Integral_Times_vs_Points} and \ref{fig:Integral_Percent_Faster_vs_Iterations}, these computational savings result in a 70\% speedup in fitting planes for each measured image. \subsection{Naive or ``Standard'' Implementation} The naive implicit fitting implementation computes the scatter matrix elements of equations (\ref{eq:XYZ_scattermatrix}) and (\ref{eq:tan_theta_scattermatrix}) through the multiplication $\mathbf{M}^{t}\mathbf{M}$. When constructing each monomial vector $\mathbf{{M}}$, the standard approach requires two multiplication operations to obtain the X and Y values of the 3D points, while fitting in RGBD range space requires a single division to obtain the values $\frac{1}{Z}$. Fit times for both methods as a function of the number of points used is shown in Fig. \ref{fig:Naive_Times_vs_Points}. Results show that implicit fitting in RGBD range space is slower by \textasciitilde{}15\% compared to the standard approach when using this naive implementation. This unexpected time difference is attributed to the significant difference in computational cost between a multiply operation (\textasciitilde{}1-3 clock cycles on contemporary CPUs) and the divide operation (\textasciitilde{}10-20 clock cycles). The large discrepancy in the cost of the division dominates and the savings afforded by having half as many operations as discussed in \S\ref{subsec:Implicit-Fitting-Cost} and \S\ref{subsec:Explicit-Fitting-cost} is superseded by this additional cost. Direct fitting using the disparity images which is directly proportional to inverse depth, $\frac{1}{Z}$, is very likely to alleviate these costs but investigation of these benefits is beyond the scope of this article. \begin{figure} \begin{centering} \includegraphics[width=7.75cm]{figs/Fit_Times_vs_Points_Combined} \par\end{centering} \caption{\label{fig:Naive_Times_vs_Points}Runtime comparison of implicit and explicit fitting approaches using the naive implementation (without integral image computation). For plane fits involving less than 10,000 points, explicit RGBD range space fitting is \textasciitilde{}10\% slower and implicit RGBD range space fitting is \textasciitilde{}15\% slower than the corresponding standard approaches.} \end{figure} Similarly, the naive implementation of the explicit fitting approaches described in \S~\ref{subsec:Explicit_Plane_Fitting} compute the matrices of equations (\ref{eq:XYZ_scattermatrix-1}) and (\ref{eq:tan_theta_scattermatrix-1}) through the multiplication $\mathbf{M}^{t}\mathbf{M}$. Using the standard explicit fitting approach, the X and Y values of the 3D points must be computed to construct the monomial vector. Explicit fitting in RGBD range space requires no additional computation to construct the monomial vector, as values for $\tan\theta_{x}(x,y)$ and $\tan\theta_{y}(x,y)$ can be pre-computed. However, the vector $\mathbf{b}=1/[\begin{array}{cccc} Z_{0} & Z_{1} & \ldots & Z_{N}]\end{array}$ in this case, so values for $\frac{1}{Z}$ must be computed. We observed explicit fitting in RGBD range space to be \textasciitilde{}10\% slower than the standard explicit approach using this naive implementation. \subsection{Integral Image vs. Standard Implementation Analysis} All implicit and explicit plane fitting methods were compared by examining runtime vs number of planes fit for a single depth image. Each plane was fit repeatedly to a 50x50 pixel subset of the overall image totaling 2500 points. For approaches involving integral images, computation of integral images was included in the overall runtime. As shown in Fig. \ref{fig:Runtime_Comparison} in both the implicit and explicit cases, fitting in RGBD range space using an integral image implementation is faster than all other methods. Fitting 200 planes, implicit integral image RGBD space fitting takes 37\% less time than the standard integral image approach and 28\% less time than naive standard fitting. Explicit integral image RGBD range space fitting takes 62\% less time than the standard explicit integral image approach and 50\% less time than even implicit integral image RGBD space fitting. \subsection*{Planar Segmentation Application} The integral image implementations of all plane fitting methods were compared by their application in a planar segmentation algorithm. The algorithm takes in a depth image and divides into an equally sized square grid. For each grid element, a plane is fit using each type of integral image plane fitting approach- integral image implementations of the standard and RGBD space fitting methods. \begin{figure}[h] \begin{raggedright} \subfloat[]{\begin{centering} \includegraphics[width=8cm]{figs/Comprehensive_Implicit} \par\end{centering} } \par\end{raggedright} \begin{raggedright} \subfloat[]{\begin{centering} \includegraphics[width=8cm]{figs/Comprehensive_Explicit} \par\end{centering} } \par\end{raggedright} \caption{\label{fig:Runtime_Comparison} (a,b) compare performance of implicit (a) and explicit (b) plane fitting methods for a single depth image. As the number of planes fit per image grows larger, the integral image implementation of RGBD range space fitting quickly surpasses all other plane fitting methods in terms of speed.} \end{figure} If the error in the fit is above a threshold value, the grid element is subdivided into 4 equally smaller elements, each with half the width and height of the parent. This subdivision and plane fitting process is then repeated for these child grid elements, up to a maximum number of subdivisions. K-means clustering was then applied to planar coefficients to classify and label similar planes. This process results in the planar segmentation of the depth image as shown in Fig. \ref{fig:Planar_Segmentation}. For this algorithm, time spent plane fitting and computing integral images for 30 frames of depth image data was recorded. As previous analysis indicated, the integral image implementation of implicit RGBD range space fitting demonstrated significant time savings compared to its standard counterpart, taking 22\% less time. In the explicit case, integral image RGBD range space fitting produced a 32\% reduction in runtime compared to standard integral image fitting. Between the two fitting formulations, the explicit RGBD range space fitting approach was the fastest, taking 66\% less time than implicit RGBD range space fitting. Extrapolation of these results indicate that over a five minute quadcopter flight the proposed algorithm would save over 30 seconds of processing time which may then be used for other on-board computational tasks. \section{Conclusion} The problem of real time surface fitting has shown itself to be an important challenge in the area of computer vision. In this work, we have introduced computationally efficient methods for least squares 3D plane fitting, which outperform the standard approaches when implemented using integral images. These methods improve upon existing approaches by separating the traditional fitting problem into components including the intrinsic camera parameters, which can be considered constant, and quantities related to the disparity of the incoming depth data. This article proposed a reformulation of standard 3D plane fitting which, when coupled with integral imaging techniques, significantly reduces the computational cost associated with plane fitting to 3D point cloud data. We have also demonstrated the practical advantages in employing such methods in terms of a planar segmentation algorithm, which showed a substantial reduction in runtime consistent with other experimental results. We feel these results show promise for application of the proposed surface fitting methods in real time RGBD vision systems. Future work may investigate a surface fitting approach dealing with the disparity data directly. After all, the quantity $\frac{1}{Z}$ is directly proportional to the sensed disparity. If depth information is not explicitly required, additional computational savings can be realized by working directly from measured disparities which may also eliminate the cost of depth computation which typically is performed by the sensor driver. It is also likely that surfaces of higher order can be estimated using a similar surface fitting formulation as proposed in this work, although it remains to be seen if such approaches would provide increased performance. \bibliographystyle{ieeetr}
{'timestamp': '2021-03-12T02:22:19', 'yymm': '2103', 'arxiv_id': '2103.06644', 'language': 'en', 'url': 'https://arxiv.org/abs/2103.06644'}
arxiv
\section*{Appendix} In Appendix, we provide the mathematical illustration of a simple binary classification example to show the significance of the level dependency. Let us assume, there are 10 samples $x_s$ evenly distributed in the feature space $F = \{f_1\}$ where $f_1 \in [0,10]$ as shown in Figure~\ref{fig:level_dep}(a). These classes are separated from $f_1=5$, such that the class labels $y_s$ are as follows: \begin{equation} y_s = \begin{cases} 1~ \text{if } f_1\leq 5\\ 2~ \text{otherwise } \end{cases} \end{equation} In this problem, $f_1^{min} = 0$ and $f_1^{max} = 10$. We select the first 9 samples for HDC training, and leave the last sample as a query point. We choose quantization level as $M=10$ such that the quantization intervals from $f_1^1$ to $f_1^{10}$ are $[0,1), [1,2),...,[9,10]$. \begin{figure}[h] \centering \includegraphics[width=0.9\linewidth]{figures/level_dependency.pdf} \caption{Simple binary classification example. a) Initial problem structure. b) Classification using orthogonal hypervectors. c) Classification using hypervectors with level dependency} \label{fig:level_dep} \end{figure} \noindent\textbf{Classification using orthogonal hypervectors as level hypervectors:} We assign random $D$-dimensional bipolar hypervectors $L_1^1$ to $L_1^{10}$ to these intervals. In high dimensions, random hypervectors are nearly orthogonal to each other~\cite{ge2020classification}. Given $x_s$, corresponding sample hypervector becomes $X_s = L_1^{q(x_s^1)}$ where $q(x_s^1)$ is the quantization level that contains value for the feature $f_1$ of the current sample $x_s$. Then, we generate class encoders $E_1$ and $E_2$ as: \begin{equation} \label{appeq:Ek} E_1 = \sum_{s=1}^5 X_s = \sum_{s=1}^5 L_1^{q(x_s^1)} ~\text{and~} E_2 = \sum_{s=6}^9 X_s = \sum_{s=6}^9 L_1^{q(x_s^1)} \end{equation} Given a query point $Q$ with value $10$, corresponding query hypervector becomes $Q=L_1^{q(x_{10}^1)}$. Classification is performed by calculating the cosine similarity between $Q$ and $E_1, E_2$. Since the generated level hypervectors are orthogonal to each other, the dot product operation in the cosine similarity calculation yields a value close to $0$, and thus, the decision becomes random and may give wrong results as shown in Figure~\ref{fig:level_dep}(b): \begin{align} & E_2\boldsymbol{\cdot}Q = E_1\boldsymbol{\cdot}Q \approx 0 \\ & \sum_{s=6}^{9} L_1^{q(x_s^1)}\boldsymbol{\cdot}L_1^{q(x_{10}^1)} \approx \sum_{s=1}^{5} L_1^{q(x_s^1)}\boldsymbol{\cdot}L_1^{q(x_{10}^1)} \approx 0 \end{align} \noindent\textbf{Classification using hypervectors with level dependency as level hypervectors:} A random $D$-dimensional bipolar hypervector $L_1^1$ is assigned to the interval $[0,1)$. Unlike the previous approach, we follow the baseline HDC implementation explained in Section~\ref{sec:hdc_overview} to obtain the rest of the level hypervectors. Thus, the level dependency between level hypervectors for $f_1$ is preserved. Then, we generate sample hypervectors and calculate the class encoders as in Equation~\ref{appeq:Ek}. Finally, classification is performed by calculating the cosine similarity between query hypervector and class encoders. Since the query hypervector is more similar to the sample hypervectors that is used to generate $E_2$ due to preserved level dependency, the classification is correct and the class label of the query point is predicted as 2 as shown in Figure~\ref{fig:level_dep}(c): \begin{equation} E_2\boldsymbol{\cdot}Q = \sum_{s=6}^{9} L_1^{q(x_s^1)}\boldsymbol{\cdot}L_1^{q(x_{10}^1)} > E_1\boldsymbol{\cdot}Q = \sum_{s=1}^{5} L_1^{q(x_s^1)}\boldsymbol{\cdot}L_1^{q(x_{10}^1)} \end{equation} \section{Conclusion} \label{sec:conclusion} IoT applications require light-weight learning algorithms to achieve high inference speed and accuracy within the computational power and energy constraints of edge devices. HDC is a computationally efficient learning algorithm due to its simple operations on high-dimensional vectors. This paper presents an optimized hypervector design approach to achieve higher accuracy and robustness using a significantly smaller model size. It formulates the hypervector design as a multi-objective optimization problem and presents an efficient algorithm for the first time in literature. Evaluations on four representative health applications show that the proposed approach boosts HDC's effectiveness by achieving more than one order of magnitude reduction in model size, inference time, and energy consumption while maintaining or increasing baseline HDC accuracy. It also optimizes the trade-off between accuracy and robustness of the model and achieves over $2\times$ higher robustness. \section{Experiments} \label{sec:experiments} \vspace{1mm} \begin{figure*}[b] \centering \vspace{2mm} \includegraphics[width=1\linewidth]{figures/gains_together.pdf} \vspace{-2mm} \caption{a) Compression ratio obtained using proposed hypervector design optimization. b) Weighted Accuracy Comparison. c) Total Accuracy Comparison.} \label{fig:gains} \end{figure*} \subsection{Benchmark Applications} \vspace{1mm} We perform our evaluations on four publicly available representative wearable health applications: Parkinson's Disease digital biomarker DREAM Challenge~\cite{PDFeature_dataset}, EEG error-related potentials~\cite{EEGerp_source_paper}, human activity recognition ~\cite{bhat2020w}, and cardiotocography~\cite{cardio_dataset}. All the training and test sets used in this work will be released to the public for the reproducibility of our results. \vspace{-7mm} \begin{itemize}[leftmargin=*] \item \textbf{Parkinson's Disease digital biomarker DREAM challenge dataset (PD Challenge)} provides the mPower dataset, which includes 35410 walking tasks with expert labels (positive or negative diagnosis). For each task, the winning team extracted 57 features that can be used by standard supervised learning algorithms, such as SVM, for accurate classification~\cite{PDFeature_dataset}. These features and the training/test data provided by this challenge are used to evaluate the proposed approach. \vspace{2mm} \item \textbf{EEG error-related potentials (ERPs) dataset} is collected from six subjects to study ERPs. User studies consist of two sessions, which are divided into ten blocks. Each block is further divided into 64-2000~ms long trials. During each trial, EEG is recorded from 64 electrodes with a sampling rate of 512 Hz. The first and second sessions are used for training and testing, respectively. Since the dataset provides raw EEG data, we follow the procedure outlined in~\cite{rahimi2017EEG} for the baseline HDC implementation. The reported accuracy is the average of all six subjects. \vspace{2mm} \item \textbf{Human activity recognition (HAR) dataset} provides stretch sensor and accelerometer readings of 22 subjects while they are performing eight activities: jump, lie down, sit, stand, walk, stairs up, stairs down, transition. It provides 120 comprehensive features extracted from the raw data. We choose a subset of 33 features using sequential feature selection~\cite{aha1996comparativeSFS}. The data is divided randomly into $80\%$ training and $20\%$ test sets. \vspace{2mm} \item \textbf{Cardiotocography (CTG) dataset} provides 21 features from 2126 fetal cardiotocograms, which are extracted to diagnose the fetal state. The fetal state is divided into three classes: normal, suspect, and pathological. We randomly chose $80\%$ of the data as the training set and $20\%$ as the test set. \end{itemize} \subsection{Accuracy -- Robustness Evaluation} \label{sec:evaluation_results} This section evaluates the proposed approach using the weighted accuracy ($wAcc$) and similarity ($avgSim$) metrics defined in Section \ref{sec:opt_formulation}. Note that the results obtained here is based on \emph{single-pass} HDC training. We first sweep the dimensionality of the hyperspace ($D\in \{128, ..., 8192\}$) to decide a dimension to be used in baseline HDC implementation for each dataset. Specifically, baseline dimensions are selected as $2048$, $2048$, $8192$, and $1024$ for PD Challenge, EEG ERP, HAR, and CTG datasets, respectively. Then, the proposed approach is used to minimize the number of dimensions while maintaining the baseline HDC accuracy. For example, baseline HDC achieves 85\% weighted accuracy with $D=2048$ dimensions for the PD Challenge dataset. Our approach reduces the number of dimensions to $D=32$ (i.e., by $64\times$) while achieving $86\%$ weighted accuracy, as shown in Figure~\ref{fig:gains}. Similarly, the proposed approach reduces the dimension significantly for other datasets while maintaining or slightly improving the weighted accuracy. Specifically, it decreases the dimension size by $32\times$, $128\times$, and $32\times$ for EEG ERP, HAR, and CTG datasets, respectively. Another commonly used metric in multi-class problems is the \textit{total accuracy}, which is the number of correct classifications divided by the total number of samples. Figure~\ref{fig:gains}(c) shows that the proposed approach also successfully maintains the total accuracy. We also apply a light-weight ML algorithm, linear SVM, to all datasets as a comparison point. HDC achieves competitive accuracy with SVM both for weighted and total accuracy, as shown in Figure~\ref{fig:gains}. Moreover, the proposed optimization approach yields higher weighted accuracy compared to other methods for imbalanced datasets with raw input data. We also note that linear SVM requires additional pre-processing steps on top of the necessary filtering operations, especially for biosignals acquired using many channels/electrodes. For example, canonical correlation analysis is applied to multi-channel EEG data to select the channels with a high signal-to-noise ratio such that the accuracy increases~\cite{spuler2013cca}. In contrast, HDC does not require such computationally intensive pre-processing steps. \noindent \textbf{Accuracy vs. robustness trade-off:} A unique strength of our approach is optimizing the trade-off between accuracy and robustness, which is not explored by prior work. Robustness is measured by the \textit{dissimilarity} between class encoders defined as $1-avgSim$ in terms of the average similarity metric introduced in Section~\ref{sec:opt_formulation}. It is a measure of how distant the clusters for different classes are in the hyperspace. Figure \ref{fig:pareto_soln} shows the Pareto front solutions in terms of the weighted accuracy ($x-$axis) and dissimilarity ($y-$axis). For all applications, the Pareto front solutions yield a more robust choice of hypervectors than the baseline HDC. For example, the weighted accuracy and robustness of the baseline HDC are $(70\%, 0.017)$ with $D=2048$ dimensions for the EEG ERP dataset, as shown with $\bigast$ in Figure~\ref{fig:pareto_soln}(b). The proposed approach increases both weighted accuracy and robustness to $(86\%, 0.035)$ using only $D=64$ dimensions, as shown by the arrow. It can also trade the accuracy off to improve the robustness to as high as $0.08$ while still achieving higher accuracy than the baseline HDC. Weighted accuracy and robustness for the Pareto front solutions range from $(86\%, 0.035)$ to $(78\%,0.08)$. Similarly, the proposed approach improves weighted accuracy and robustness for other datasets. It improves the weighted accuracy by $2\%$, $1\%$, and $6\%$ while also increasing the robustness by $3\times$, $2\times$, and $2\times$ for PD Challenge, HAR, and CTG datasets, respectively. At the same time, it can achieve $2\times$, $2.5\times$, and $6\times$ higher robustness while maintaining the accuracy of the baseline HDC. In summary, our approach provides a set of hypervector designs to choose from that can be used to achieve a specific objective based on the nature of the application. \begin{figure}[b] \centering \includegraphics[width=1\linewidth]{figures/pareto_solutions_test.pdf} \caption{The Pareto front solutions in terms of $wAcc$ and $1 - avgSim$. For EEG ERP, the values are obtained using subject one's data.} \label{fig:pareto_soln} \end{figure} \subsection{Evaluation on Hardware} \label{hardware_measurements} We evaluate the proposed approach by running the inference for all applications on the Odroid XU3 platform. Both the baseline HDC implementation and the HDC implementation using the level hypervectors obtained by the proposed hypervector design approach are implemented using the C programming language. The applications run on a single little core (A7) with the lowest frequency setting (200 MHz) since this setup is the closest configuration to a computationally limited edge device. \textit{We note that the model size is independent of this choice, while the relative savings in inference time is comparable to those obtained with other configurations}. Built-in sensors report the power consumption of little cores and memory separately. We plan to evaluate the proposed technique on low-power embedded processors and custom hardware accelerators as part of our future work. Table~\ref{tab:hardware_measurements_table} compares the baseline HDC implementation and the proposed approach in terms of the model size, power consumption, and inference time per sample for all applications. For example, for PD Challenge dataset, baseline HDC has a model size of 7.5 MB using hypervector dimension as $D=2048$. The proposed approach reduces the number of dimensions to $D=32$ (i.e., by $64\times$ as shown in Figure~\ref{fig:gains}(a)) and thus, reduces the model size to 120.9 kB (i.e., by $62\times$). This reduction in model size, which is independent of the hardware, leads to a $1.41\times$ reduction in power consumption and a $150\times$ reduction in inference time. Since the A7 core is a general-purpose core, we cannot observe a significant decrease in power consumption. The reason behind that is that the core is highly utilized with the lowest frequency setting. However, we can deduce that overall computation and the communication inside the hardware are decreased which yields a huge boost in inference time. Similarly, the proposed approach reduces the model size by $31\times$, $126\times$, $31\times$, power consumption by $1.34\times$, $1.51\times$, $1.23\times$, and inference time by $66\times$, $328\times$, $54\times$ for CTG, HAR, and EEG ERP datasets, respectively. Overall, it achieves more than $66\times$ energy efficiency while significantly reducing the model size to around 100 kB. By evaluating the proposed approach on a commercial hardware, we observe that it can boost the effectiveness of HDC by enabling more than one order of magnitude reduction in model compression. Hence, we conclude that hypervector design optimization is vital to enable light-weight and accurate HDC on edge devices with stringent energy and computational power constraints. \begin{table}[t] \centering \setlength{\tabcolsep}{1.8pt} \small \caption{Inference evaluation on Odroid XU3. The numbers in parenthesis shows the reduction we obtain using the proposed approach. *PD: PD Challenge, *HDC: Baseline HDC} \label{tab:hardware_measurements_table} \vspace{-4mm} \begin{tabular}{lllllll}\\ \hline & \multicolumn{2}{l}{\textbf{Model Size (kB})} & \multicolumn{2}{l}{\textbf{Power Cons. (mW)}} & \multicolumn{2}{l}{\textbf{Inf. Time (ms)}} \\ \hline & \textbf{HDC*} & \textbf{Proposed} & \textbf{HDC*} & \textbf{Proposed} & \textbf{HDC*} & \textbf{Proposed} \\ \hline \textbf{PD*} & 7508 & 120.9 ($62\times$) & 103 & 73 ($1.41\times$) & 36 & 0.24 ($150\times$) \\ \textbf{CTG} & 1420 & 45.1 \ \ ($31\times$) & 94 & 70 ($1.34\times$) & 6 & 0.09 ($66\times$) \\ \textbf{HAR} & 17828 & 141.4 ($126\times$) & 107 & 71 ($1.51\times$) & 128 & 0.39 ($328\times$) \\ \textbf{EEG ERP}& 558 & 17.6 \ \ ($31\times$) & 87 & 71 ($1.23\times$) & 14 & 0.26 ($54\times$) \\ \hline \end{tabular} \end{table} \section{\hspace{-2mm}Background on HDC} \label{sec:hdc_overview} \begin{figure*}[b] \centering \includegraphics[width=0.95\linewidth]{figures/HDL_Overview.pdf} \vspace{-3mm} \caption{Overview of baseline HDC. $D=16$ and $M=8$ are chosen for illustration purposes. Bit values are chosen arbitrarily.} \label{fig:hdc_overview} \end{figure*} \subsection{HDC Training} \label{sec:hdc_training} Training in HDC consists of three steps: \textcircled{\raisebox{-0.9pt}{1}} Quantization and mapping , \textcircled{\raisebox{-0.9pt}{2}} Construction of sample hypervectors and \textcircled{\raisebox{-0.9pt}{3}} Classifier encoding, as illustrated in Figure~\ref{fig:hdc_overview}. We refer to this architecture as the \textit{baseline HDC implementation} in the rest of the paper. \noindent\textbf{\textcircled{\raisebox{-0.9pt}{1}} Quantization and mapping:} The first step of HDC is to quantize the input space and represent it using $\mathbf{D}$-dimensional \textit{level hypervectors}. This is achieved in two steps: (i) quantization in low dimension, and (ii) mapping to high dimension. \noindent \textbf{Quantization in low dimension:} Let $F = \{f_1, f_2, ... , f_N\}$ denote the $N$-dimensional input feature, where $f_n \in \mathbb{R} $ corresponds to the $n^{th}$ feature. Suppose that there are $S$ training samples. Each training sample $x_s$ for $s \in \{1,...,S\}$ is an $N$-tuple $x_s = \{x_s^1, x_s^2, ..., x_s^N \}$, where $x_s^n \in \mathbb{R}$ is the value of feature $f_n$ in this sample for $n \in \{1,...,N\}$. Using the training set, we find the minimum ($f_n^{\min}$) and the maximum ($f_n^{\max}$) values of each feature. % Let $\mathcal{Q} = \{1,...,M\}$ be the set of quantization levels. The baseline HDC quantizes each feature space into $M$ uniform levels using a quantization function $q: \mathbb{R} \rightarrow \mathcal{Q}$ such that $q(x_s^n)$ returns the quantization level for feature $f_n$ in input sample $x_s$. \noindent \textbf{Mapping to the high dimension:} The minimum level of each feature $f_n^{\min}$ is assigned a random bipolar $D$-dimensional hypervector $L_n^1$, where $L\in\{-1,1\}^D$, and typically $D\geq1000$. The rest of the level hypervectors $L_n^2$ to $L_n^M$ are calculated by randomly flipping % $b=D/2(M-1)$ bits to generate each consecutive hypervector. This operation is denoted by $L_n^{m+1} = g(L_n^m, b)~\forall~m\in \mathcal{Q}$, where $g(u,v):\{(u,v)|~u\in\{-1,1\}^D, v\in\mathbb{N}\} \rightarrow \{-1,1\}^D$ is a nonlinear function that flips $v$ (scalar) indices of $u$ (vector). This process tracks the flipped bits and ensures that they do not flip again in subsequent levels. At the end, it produces $N\times M$ different \textit{level hypervectors} $L_n^m~\forall~n,m$ that represent the quantized features in the hyperspace. This process also ensures that hypervectors $L_n^1$ and $L_n^M$ orthogonal for each feature $f_n$~\cite{ge2020classification}. The notation is summarized in Table~\ref{tab:notation}. \begin{table*}[t] \small \renewcommand{\arraystretch}{1.1}% \centering \caption{Notation table. *HV: Hypervector} \vspace{-2mm} \label{tab:notation} \begin{tabular}{@{}llllllll@{}} \toprule Symb. & Description & Symb. & Description & Symb. & Description & Symb. & Description \\ \midrule $N$ & \# of features & $q(.)$ & Quantizer function & $x_s$ & Training sample $s$ & \multirow{2}{*}{$L_n^m$} & \multirow{2}{*}{\begin{tabular}[c]{@{}l@{}}$D$-dim level HV* for \\ m$^\text{th}$ level of $f_n$\end{tabular}} \\ $F$ & $N$-dim input space & $S$ & \# of training samples & $X_s$ & $D$-dim sample HV* for $x_s$ & & \\ $f_n$ & n$^\text{th}$ dimension of $F$ & $D$ & Hyperspace dimension & $Q$ & $D$-dim query HV* & \multirow{2}{*}{$b$} & \multirow{2}{*}{\begin{tabular}[c]{@{}l@{}}\# of flipped bits between \\ $L_n^m$ and $L_n^{m+1}$\end{tabular}} \\ $M$ & \# of quantization levels & $g(.)$ & Nonlinear bit-flip function & $K$ & \# of different classes & & \\ $y_s$ & Class label for $x_s$ & $E_k$ & Encoder for k$^\text{th}$ class & $\mathcal{Q}$ & \begin{tabular}[c]{@{}l@{}} Set of quantization intervals\end{tabular} & & \\ \bottomrule \end{tabular} \end{table*} \noindent\textbf{\textcircled{\raisebox{-0.9pt}{2}} Construction of sample hypervectors ($X_s$):} The next step is constructing the sample hypervectors using the input samples $x_s$ and level hypervectors found in step \textcircled{\raisebox{-0.9pt}{1}}. We first determine the quantization levels $q(x_s^n)$ that contain the value for each feature of the current sample $x_s$. Then, we fetch the level hypervectors $L_n^{q(x_s^n)}$ that correspond to these quantization levels and add them up: \vspace{-1mm} \begin{equation} \label{eq:Xs} X_s = \sum_{n = 1}^{N} L_n^{q(x_s^n)}~~\forall~~s \in \{1,2, ..., S\} \mathrm{, where~} X_s\in\mathbb{Z}^D \end{equation} \noindent \textbf{Toy example:} For a better understanding of steps \textcircled{\raisebox{-0.9pt}{1}} and \textcircled{\raisebox{-0.9pt}{2}}, we present a simple representative example. Consider a 2-D problem with $f_1 \in [0,1]$ and $f_2 \in [-10,0]$ with $M=10$ quantization levels and $D=1000$. The quantization intervals between $f_1^{\min}=0$ and $f_1^{\max}=1$ are $[0,0.1),[0.1,0.2),...,[0.9,1]$. Similarly, the quantization intervals for $f_2$ are $[-10,-9),[-9,-8),...,[-1,0]$. The intervals $[0,0.1)$ and $[-10,-9)$ are assigned random bipolar $1000$-dimensional hypervectors $L_1^1$ and $L_2^1$. To find the rest of the level hypervectors $L_1^2$ to $L_1^{10}$ and $L_2^2$ to $L_2^{10}$, we first calculate the number of bits to flip at each consecutive level as $b=D/2(M-1)=55$. Then, $L_1^2$ is found by $L_1^2=g(L_1^1,55)$ and the rest of $L_1^m$ and $L_2^m$ are calculated through the same procedure. As a result, we obtain 20 different \textit{level hypervectors} that represent the quantized $f_1$ and $f_2$. After finding the level hypervectors, input samples $x_s$ are mapped to their corresponding hypervectors $X_s$. For example, consider an arbitrary sample $x_3=\{0.17, -1.2\}$. We first find the quantization levels $0.17$ and $-1.2$ fall into. These levels are given by $q(x_3^1)=2$ and $q(x_3^2)=8$. Then, we find $X_3=L_1^2 + L_2^8$ using Equation~\ref{eq:Xs}. This procedure is repeated for all $x_s$ in the training set. \textbf{\textcircled{\raisebox{-0.9pt}{3}} Classifier encoding:} Suppose that there are $K$ classes with labels $1,2, ..., K$. The label of sample hypervector $X_s$ is given by $y_s \in \{1, ..., K\}$ for all samples $s \in \{1, ..., S\}$. The class hypervector $E_k \in \mathbb{Z}^D$ that represents class $k$ is found by adding all the sample hypervectors with label $k$: \begin{equation} \label{eq:Ek} E_k = \sum_{s = 1}^S X_s[y_s=k] \end{equation} where $[.]$ operation represents the Iverson Bracket that is equivalent to the indicator function~\cite{iverson1962programming}. \subsection{HDC Inference} During inference, the query samples with unknown class labels are first mapped to the hyperspace using the procedure defined in steps \textcircled{\raisebox{-0.9pt}{1}} and \textcircled{\raisebox{-0.9pt}{2}}. The resulting hypervectors are called \textit{query hypervectors} $Q$. Then, the cosine similarity between the query hypervectors and each class encoder $E_k$ given in Equation~\ref{eq:Ek} is calculated. Finally, the class $k$ with the highest similarity is decided as the class label of the query data point as follows: \begin{equation} \argmax_{k\in\{ 1,...,K \} } \frac{Q\boldsymbol{\cdot}E_k}{\left\|Q\right\|\left\|E_k\right\|} \quad \end{equation} \section{Introduction} \label{sec:introduction} The number of Internet of Things (IoT) devices and the data generated by them increase every year~\cite{capra2019edge,wang2020convergence}. Wearable IoT, which utilizes edge devices and applications for remote health monitoring~\cite{hiremath2014wearable}, has been a rapidly growing subfield of IoT in recent years~\cite{bhatt2017access, bhat2019openhealth,deb2021trends}. These devices fuse data from multiple sensors, such as inertial measurement units (IMU) and biopotential amplifiers, to achieve accurate real-time tracking. For example, assistive devices for Parkinson's Disease patients need to provide precisely timed audio cues to cope with gait disturbances~\cite{deb2021trends,ginis2018cueing}. Despite the intensity of sensor data, these devices must operate at a tight energy budget ($\sim \hspace{-1mm}\mu$W) due to limited battery capacity~\cite{bhat2020self,de2017feasibility}. Offloading the data to the cloud is not an attractive solution since it increases the communication energy~\cite{zhang2016communicationenergy} and raises privacy concerns~\cite{ozanne2018wearables}. Likewise, deep neural networks and other sophisticated algorithms are not viable due to the \emph{limited computation and energy capacity of wearable edge devices.} Therefore, there is a strong need for \emph{computationally light} learning algorithms that can provide high accuracy, real-time inference, and robustness to noisy sensor data~\cite{bhat2020self}. Brain-inspired hyperdimensional computing ~\cite{kanerva2009HDC} provides competitive accuracy to state-of-the-art machine learning (ML) algorithms with significantly lower computational requirements for various applications, such as human activity recognition, language processing, image recognition, and speech recognition~\cite{ge2020classification}. It models the human short-term memory~\cite{kanerva2009HDC, kim2018HARHDC} using high-dimensional representations of the data points, which is motivated by the large size of neuronal interactions in the brain to \textit{associate} a sensory input with the human memory. \emph{The main difference between HDC and conventional learning approaches is the primary data type.} HDC maps data points (raw samples or extracted input features) in the input space to random high-dimensional vectors, called \textit{sample hypervectors}. Then, the sample hypervectors that belong to the same class are combined linearly to obtain ensemble class hypervectors, called \textit{class encoders}. During inference, the input data is used to generate a \textit{query hypervector} ($Q$) in the same way as the sample hypervectors. The classifier simply finds the closest class hypervector to $Q$, generally using cosine similarity or the Hamming distance. Thanks to the simplicity of binary operations, as discussed in Section~\ref{sec:hdc_overview}, HDC lends itself to efficient hardware implementation. A recent study~\cite{datta2019humancentricIOT} shows that custom hardware implementations can provide high energy efficiency and inference speed while reducing the design complexity. However, HDC requires a large dimension (e.g. $D\geq1000$) to achieve a high inference accuracy~\cite{imani2018hierarchicalenergy} due to the \textit{random mapping} process. A sufficiently large dimension is needed to ensure, with a high probability, that the sample hypervectors are orthogonal to each other~\cite{datta2019humancentricIOT, ge2020classification}. A larger dimension implies higher energy consumption, longer inference time, and more hardware resources~\cite{imani2018hierarchicalenergy}. Consequently, redundant computations can undermine the benefits of using HDC over other learning algorithms. Therefore, there is a critical need to \textit{optimize the design of hypervectors} such that the performance of HDC is maintained with smaller dimensions. % This paper presents a novel optimization algorithm for representing the input data points in the hyperspace \textit{instead of relying on random mapping}. We conceptualize the mapping of the data points in the hyperspace by geometric notions. Using this insight and a novel \textit{non-uniform quantization} approach, we refine the distribution of randomly generated sample hypervectors in the hyperspace to achieve increased robustness to noise in smaller dimensions and similar accuracy levels to that of conventional HDC. To the best of our knowledge, this is the first technique that formulates \emph{hypervector design} as a multi-objective optimization problem to achieve higher accuracy and robustness using smaller dimensions (i.e., lower energy and computational resources). The proposed approach is evaluated using four representative health-oriented applications since health monitoring is an emerging and attractive field in wearable IoT literature: Parkinson's Disease diagnosis, electroencephalography (EEG) classification, human activity recognition, and fetal state diagnosis. \textit{The major contributions of the proposed approach are as follows}: \begin{itemize} [leftmargin=*] \item It boosts the effectiveness of HDC by enabling more than one order of magnitude model compression while maintaining similar performance to conventional HDC. Furthermore, hardware measurements show over $66\times$ higher energy efficiency. \item It introduces novel geometric concepts and illustrations to better understand the effect of HDC mapping from the input features to the hyperspace. \item % By optimizing the trade-off between accuracy and robustness to noise, it achieves 2$\times$ higher robustness while maintaining the same accuracy, or 1\%--16\% higher accuracy without sacrificing the robustness. \end{itemize} In the rest, Section \ref{sec:related_work} reviews the related work, while Section \ref{sec:hdc_overview} overviews HDC. Section \ref{sec:approach} presents the proposed hypervector design optimization. Section \ref{sec:experiments} presents the evaluation of the proposed approach and provides results on four applications. Finally, Section \ref{sec:conclusion} concludes the paper. \section{Optimized Hypervector Design} \label{sec:approach} \subsection{Motivation} \label{sec:opt_motivation} \noindent\textbf{Distance in the hyperspace:} Two samples from different classes may be close to each other, in the low dimensional input space, based on the extracted features or raw data. This proximity eventually decreases the accuracy and robustness of the classifier. From a geometrical perspective, we can consider the sample hypervectors, \textit{i.e.,} the mapping to the high-dimensional domain, as data points in the hyperspace. % Using this insight, the optimized hypervector design should achieve two objectives: 1) \textit{Spread sample hypervectors from different classes as far as possible}, 2) \textit{Cluster sample hypervectors of the same class close to each other}. \begin{figure*}[t] \centering \includegraphics[width=1\linewidth]{figures/motivational_example.pdf} \vspace{-3mm} \caption{Evaluation of the proposed approach on a motivational example. a) Initial problem structure. b) Baseline HDC ($D=8192$) classification result. c) HDC classification result obtained by separating significant levels for both features ($D=64$). d) Number of bits to flip for each feature and level.} \label{fig:motivational_example} \end{figure*} \noindent \textbf{Dependency between feature levels:} One can assign orthogonal hypervectors to each level hypervector during quantization to spread them far apart~\cite{kleyko2018classification}. This approach can provide high classification efficiency \textit{if all levels are represented in the training data}. However, if the training data has gaps, \textit{e.g.}, certain levels are underrepresented, then the classifier can make random choices. Hence, the hypervector optimization technique must maintain the dependency between the level hypervectors $L_n^m$ for each feature $n \in \{1,2,...,N\}$. We provide a mathematical illustration with a simple example in the Appendix to not distort the flow of the paper. \subsection{Illustration using a Motivational Example} \label{sec:motivatione} This section presents a motivational example to illustrate the significance of the proposed hypervector optimization. In this example, the data points are divided into four classes (C1, C2, C3, and C4) and represented by two features $F = \{f_1,f_2\}$, as shown in Figure~\ref{fig:motivational_example}(a). For the baseline HDC implementation, we choose $D=8192$ and $M=20$ and follow the procedure explained in Section~\ref{sec:hdc_overview} to represent the data points in the hyperspace. All data points are included in the training and test set for illustration purposes. The baseline HDC misclassifies a significant number of data points concentrated around the class boundaries, as shown in Figure~\ref{fig:motivational_example}(b). The specification in Figure~\ref{fig:motivational_example}(a) shows that the levels $6$, $11$, and $16$ are critical for the first feature ($x-$axis), while level $6$ and $16$ are critical for the second feature ($y-$axis). However, the baseline HDC ignores this fact and quantizes the levels uniformly, leading to misclassified points at the boundaries. In contrast to uniform quantization levels, the proposed approach emphasizes the distinctive levels in the training data. For example, Figure~\ref{fig:motivational_example}(d) shows that the number of bits flipped by the proposed approach between consecutive levels. The lower plot clearly shows that it allocates a significantly higher number of bits for levels $6$ and $16$, which precisely matches with our earlier observation. In general, the proposed approach flips a different number of bits at each consecutive level as opposed to the uniform $b=D/2(M-1)$ bits used by the baseline HDC. As a result, it achieves $100\%$ classification accuracy by judiciously separating the quantization levels of both dimensions, as illustrated in Figure~\ref{fig:motivational_example}(c). More remarkably, the proposed approach achieves a higher level of accuracy than the baseline HDC by using only $D=64$ dimensions, as opposed to $8192$. This result indicates that the number of dimensions can be significantly compressed while increasing the accuracy through optimized hypervector design. We also demonstrate a geometrical illustration on the same example using 2-D t-distributed stochastic neighbor embedding (t-SNE)~\cite{maaten2008tsne} representation of the sample hypervectors. t-SNE is a nonlinear dimensionality reduction algorithm that works especially well in visualizing high-dimensional data points. Figure~\ref{fig:motivational_example_tsne}(a) shows that the baseline HDC performs poorly in separating hypervectors for different classes despite a large number of dimensions ($D=8192$). In contrast, Figure~\ref{fig:motivational_example_tsne}(b) shows that the optimized sample hypervectors are separated well from each other according to their classes while using a much smaller $D=64$. The t-SNE and accuracy results illustrate the importance of the objectives set for the hypervector optimization presented in the next section. \begin{figure}[t] \centering \includegraphics[width=1\linewidth]{figures/motivational_example_tsne.pdf} \caption{t-SNE illustration of sample hypervectors in 2-D for the motivational example. } \label{fig:motivational_example_tsne} \end{figure} \subsection{Optimization Problem Formulation} \label{sec:opt_formulation} This section formulates the level hypervector design as an optimization problem where the number of bits to flip between each consecutive level hypervector, $b_n^m$, values are the optimization parameters. In contrast to baseline HDC which uses a uniform number of levels as $b=D/2(M-1)$, \textit{we use a variable number of bits} $b_n^m~\forall~n\in\{1,...,N\}$ and $m\in\{1,...,M\}$. The optimization parameters are defined as a matrix $B_{N\times M}$, which includes all $b_n^m$ values for $N$ features and $M$ levels. Suppose that there are $K$ classes in the dataset, and $T\hspace{-0.5mm}P_k$ and $F\hspace{-0.5mm}N_k$ represent the true positives and false negatives for class $k$, respectively. We construct the following multi-objective optimization problem with two objectives: (i) maximize the training accuracy and (ii) minimize the similarity between class encoders: \begin{align} \max_{B_{_{_{N\times M}}}} & \ wAcc = \frac{1}{K} \sum_{k=1}^{K} \hspace{1mm} \frac{T\hspace{-0.5mm}P_k}{T\hspace{-0.5mm}P_k+F\hspace{-0.5mm}N_k} \label{eq:obj1} \\ \min_{B_{_{_{N\times M}}}} & avgSim = \left(\prod_{k=1}^{K} \prod_{k^{\prime}=1}^{K} \frac{E_k\boldsymbol{\cdot}E_{k^\prime}}{\left\|E_k\right\|\left\|E_{k^\prime}\right\|}\right)^\frac{1}{K} \text{ for} \ \ k\neq k^\prime \label{eq:obj2} \\ \text{subject} & \text{ to} \quad \sum_{m=1}^{M} b_n^m \leq \frac{D}{2} \quad \text{where} \ \ n \in \{1,...N\} \label{eq:constraint} \end{align} where Equation~\ref{eq:constraint} ensures that the total number of bits flipped between $L_n^1$ and $L_n^M$ does not exceed $D/2$. This condition is critical to satisfy the orthogonality condition between distant values in the input space, as explained in Section~\ref{sec:hdc_training}. The proposed formulation uses the weighted accuracy ($wAcc$) instead of the total accuracy since the total accuracy calculation suffers from imbalanced datasets. $wAcc$ used in this work corresponds to the macro-averaged recall. Equation~\ref{eq:obj2} formulates the geometric mean of cosine similarity between each class encoder pairs. It provides a lumped similarity metric between class encoders. The effect of outliers (e.g. one class encoder is significantly different from the others) is greatly dampened in the geometric mean. The distance between different class encoders (\textit{i.e.}, $1-avgSim$) is used as a measure of robustness and maximized by Equation~\ref{eq:obj2}. \subsection{Optimization Problem Solution} The objective functions in the proposed formulation (Equations~\ref{eq:obj1} and \ref{eq:obj2}) are nonlinear functions that can be evaluated only at integral points. Furthermore, there are integer constraints since the optimization parameters are the number of bits flipped between each consecutive level hypervector. Hence, we need to solve a non-convex optimization problem with integer constraints, i.e., an NP-hard problem. One can employ gradient-based approaches to solve this problem by relaxing the integer constraints (e.g., using continuous variables and rounding them to the nearest integer to evaluate the objective functions). However, gradient-based approaches get stuck at a local minimum near the starting point. This obstruction occurs since the objective functions typically have many minimums, and rounding is used during evaluation. To overcome this limitation, we employed gradient approaches using multiple starting points. Nevertheless, the solutions are still not far from the original starting points, which are not close to the optimal solution. Hence, we conclude that gradient-based approaches are not suitable for our problem. We employ a genetic algorithm (GA), an evolutionary heuristic search approach, to find a solution close to the global minimum. Our aim is not only to obtain the best solution that gives the highest accuracy but also to optimize the trade-off between the accuracy and the robustness of the model. Since GA maintains a population of possible solutions at every generation and is a highly explorative algorithm, it is preferred in this work, considering the objective functions have many local minima. Algorithm~\ref{algo:opt_algo} describes the search approach to find the optimum hypervector design. The input to the algorithm is $P$ randomly generated $B_{_{N\times M}}$ matrices, where $P$ is the population size in GA. This input corresponds to the first generation in GA. First, the algorithm updates the level hypervectors based on the $b_n^m~\forall~n,m$ for each population. Then, the sample hypervectors and class encoders are updated using the new level hypervectors. Next, the objective functions are evaluated based on the updated hypervectors. Next, GA selects a new set of populations used in the next generation according to the values of the objectives. After a predefined number of generations, we obtain the Pareto front $B_{N\times M}$ set as an output of the algorithm. Our proposed approach utilizes the \textit{gamultiobj} function of MATLAB~\cite{MATLAB:2020}. For our evaluations, we use a population size of $P=1000$ and allow the search to run for at least $200$ generations with a fixed seed. \begin{algorithm}[h] \caption{Optimized hypervector design with GA} \label{algo:opt_algo} \SetAlgoVlined \SetNoFillComment \textbf{Input:} Randomly generated $B_{_{N\times M}}$ matrices for each population \\ \textbf{Output:} Pareto front $B_{_{N\times M}}$ set \\ $G$ = number of generations in GA \\ $\mathcal{P}$ = set of all populations\\ $\mathcal{L}$ = set of all level hypervectors\\ $\mathcal{X}$ = set of sample hypervectors \\ $E$ = set of class encoders\\ \For{i = \normalfont{1: |$G$|}} { \For{j = \normalfont{1: |$\mathcal{P}$|}} { $B_{_{_{N\times M}}}$ $\rightarrow \mathcal{L}$, $\mathcal{L}$ $\rightarrow \mathcal{X}$, $\mathcal{X}$ $\rightarrow E$ \\ Compute $wAcc$ and $avgSim$ \\%using Equations~\ref{eq:obj1}--\ref{eq:obj2} \\ Compute feasibility of the current solution \\ }Obtain new $\mathcal{P}$ for the next generation } Obtain Pareto front $B_{N\times M}$ set \end{algorithm} \section{Related Work} \label{sec:related_work} HDC utilizes high-dimensional vectors to map the input features to high-dimensional space. It achieves competitive results compared to other state-of-the-art ML approaches~\cite{ge2020classification}. However, HDC requires large dimensions ($D\geq1000$) to achieve high inference accuracy due to the random mapping process. In turn, large dimensions increase on-chip storage, computation, and energy requirements, which are limited in wearable edge devices. Hence, there is a critical need to optimize the mapping process in HDC to achieve similar or higher accuracy and robustness with smaller dimensions. One idea to remedy high-dimensional data is using dimensionality reduction techniques, which are linear/nonlinear transformations that map the high-dimensional data to a lower-dimensional space. Recently, nonlinear dimensionality reduction techniques or manifold learning algorithms, such as ISOMAP, local linear embedding (LLE), and Laplacian eigenmaps, have become widely used for dimensionality reduction~\cite{turchetti2019manifold}. These algorithms mainly focus on \textit{preserving the geometric information} of the high-dimensional data in the low dimensional space in contrast to another widely used linear technique, principal component analysis (PCA), which may distort the local proximities by mapping the data points that are distant in the original space to nearby positions in the lower dimensional space~\cite{kazor2016comparison}. However, the main drawback of the manifold learning methods is learning the low-dimensional representations of the high-dimensional input data samples implicitly. Explicit mapping from the input data manifold to the output embedding cannot be obtained after the training process ~\cite{turchetti2019manifold,qiao2012explicit} without compromising the memory and computational limitations of a wearable edge device. For instance, the ARM Cortex-M series is a widely used family of low-power processors for wearable edge devices~\cite{wang2020accurate}. This family offers an on-chip SRAM of a few KB and nonvolatile flash memory with a size of up to 2 MB~\cite{wang2020fann}. Considering a large amount of training data and the dimensionality in HDC ($D\geq1000$), the memory footprint of these low-power processors is not sufficient to obtain an explicit mapping. Therefore, an optimized representation of the data in smaller dimensions is necessary for these devices. A recent work investigated the impact of dimensionality on the classification accuracy and energy efficiency of HDC~\cite{imani2018hierarchicalenergy}. The authors show that energy consumption and inference time decrease with smaller dimensions. However, smaller dimensions yield lower accuracy values. Hersche \textit{et al.} propose a mapping technique based on the training of random projection to produce distinct hypervectors as part of learned projections~\cite{hersche2018exploring}. The learned projections are shown to be effective in terms of accuracy at lower dimensions. However, this mapping does not preserve the level dependency between level hypervectors in HDC, which is critical for robust classification, as elaborated in Section \ref{sec:opt_motivation}. Another study reduces the high-dimensionality of the class encoders by dividing it into multiple smaller dimensional segments and adding them up to form a lower-dimensional class encoder~\cite{morris2019comphd}. However, during inference, the query hypervector is formed using high-dimensional level hypervectors that need to be stored in memory and thus undermine the potential energy savings. In contrast to prior work, this paper focuses on optimizing hypervector design at the initial stage of HDC training. We formulate the hypervector design as a multi-objective optimization problem for the first time in literature. Moreover, none of the prior studies discuss the robustness to the noise of the HDC model. The proposed approach produces an efficient and robust representation of the data points in the hyperspace while preserving similarity between level hypervectors. It is also the first work that enables a trade-off between robustness and accuracy by providing a Pareto front set of hypervector design.
{'timestamp': '2021-03-12T02:25:33', 'yymm': '2103', 'arxiv_id': '2103.06709', 'language': 'en', 'url': 'https://arxiv.org/abs/2103.06709'}
arxiv
\section{Introduction}} \input{sections/1_intro} \section{Related works} \input{sections/2_previouswork} \section{Methodology} \input{sections/3_methodology} \section{Training data and automatic labelling} \input{sections/4_data} \section{Experimental framework} \input{sections/5_experiments} \section{Results and discussion} \input{sections/6_results} \section{Conclusions} \input{sections/8_conclusions} \section*{Acknowledgements} This research received partial support from the EU H2020 TrimBot2020 project (grant no. 688007). \\ We would like to thank the Center for Information Technology of the University of Groningen for their support and for providing access to the Peregrine HPC cluster. \\ Finally, we would like to thank Dr. Manuel López Antequera for his assistance with the MSLS dataset. \bibliographystyle{IEEEtran} \subsection{\revised{Metric learning for p}lace recognition} Traditional place recognition algorithms rely on local image features and holistic representations, such as Fisher Vectors~\cite{perronnin2010large,jegou2010fisher}, Bag of Words~\cite{bow2012,Torii-PAMI2015,philbin2007object} and VLAD~\cite{jegou2011VLAD,arandjelovic2013all}, or on exploiting image sequences~\cite{Milford2012,Sunderhauf2013} or panoramas~\cite{Torii-PAMI2015}. Deep learning methods achieved state-of-the-art results~\cite{zhang2020visual,masone2021survey}, initially using pre-trained CNNs as feature extractors~\cite{lopez2019place, babenko2015aggregating,chen2014convolutional,Sunderhauf2015,sharif2014cnn}, and subsequently as end-to-end trainable models. Several methods optimize a contrastive loss function~\cite{radenovic2018fine}, with pairs of positive and negative samples. In~\cite{thoma2020soft}, the authors demonstrate the benefits of using a ground truth based on soft assignments to positive and negative classes, \revised{based on the Euclidean distance between the annotated GPS coordinates of images in their dataset, without considering orientation. This leads to some discrepancies in the soft assignment, e.g. two images taken in very close places but facing opposite directions do not share visual cues. It makes the use of a hard mining strategy necessary for convergence.} \revised{In~\cite{kim2021embedding}, the authors propose a Contrastive Loss function that weights similar pairs of images and dissimilar images on the basis of the distance of their representations in the embedding space. As the weighing depends on the distance in the embedding space, it requires extra regularization during training. In~\cite{balntas2018relocnet}, the authors proposed to regress the 3D camera frustum overlap as part of an image retrieval pipeline for image localization, learning image retrieval and pose regression simultaneously. The authors of ~\cite{ding2019camnet} build further into the idea of frustum overlap based retrieval, learning a relocalization pipeline with two modules for coarse and fine localization.} Other methods are trained by optimizing a triplet loss function, with image tuples consisting of a query, a positive match and a negative match ~\cite{Lopez-Antequera2017}. NetVLAD~\cite{Arandjelovic2017} is trained using a triplet loss function with a query, a set of potential positive matches and a set of definite negative matches. They optimize a weak triplet loss function that enforces higher distances between the query and all the negative matches than between the query and any potential positive. PointNetVLAD~\cite{angelina2018pointnetvlad} exploits 3D information by combining PointNet~\cite{qi2017pointnet} and NetVLAD for large-scale place recognition. In~\cite{yu2019spatial}, the authors use spatial pyramid pooling to encode spatial and structural information into the NetVLAD descriptors, and a weighted triplet loss to maximize the distances between the negative pairs and maximize that between the positive pairs. \revised{In~\cite{liu2019stochastic}, the authors train a NetVLAD by optimizing a SARE (Stochastic Attraction-Repulsion Embedding) loss function, which aims to minimize the distance among similar scences while maximizing the distance among dissimilar scenes in a probabilistic framework. The use of the SARE loss function required a reformulation of hard-pair mining, which is also necessary for the training process to converge. In~\cite{kim2019deep}, a measure of the semantic degree of similarity between object pairs was incorporated into the learning process to optimize a novel log-ratio triplet loss, and applied to human pose, room layout, and caption-aware image retrieval. This approach, however, required the reformulation of the triplet mining strategy to perform dense sampling in the neighborhood of the anchor sample. In~\cite{revaud2019learning}, the global retrieval ranking is optimized, rather than a distance loss function for image retrieval, which was used for visual localization systems~\cite{benchmarking_ir3DV2020}. In~\cite{hausler2021patch}, the authors use the patch-level features of VLAD layer to do local feature matching and re-rank the retrieval predictions, obtaining an improvement in the recall.} Several challenges of visual place recognition in different environments were studied and several benchmark datasets were publicly released. The KITTI~\cite{Geiger2013}, Oxford RobotCar~\cite{Maddern2017}, \revised{RobotCar Seasons~\cite{sattler2018benchmarking},} Pittsburgh250K~\cite{Torii-CVPR2013} and TokyoTM~\cite{Arandjelovic2017} datasets contain images taken in urban environments. \revised{The CMU dataset~\cite{Badino2011} and the Extended CMU Seasons dataset~\cite{sattler2018benchmarking} contain images taken in urban, suburban and park environments.} Tokyo 24/7~\cite{Arandjelovic2017} and Aachen~\cite{Sattler2012} also provide images taken at day and night that depict drastic changes in illumination conditions. The Alderley dataset also includes weather variations~\cite{Milford2012}. The Mapillary Street Level Sequences dataset includes images taken with different cameras in 30 cities in six continents~\cite{msls}. It contains changes in viewpoint, weather, illumination and long-term variations, as well as urban, suburban and countryside environments. To the best of our knowledge, it is the largest dataset for long-term place recognition. The Norland dataset includes images taken in countryside and contains variations of weather conditions and season~\cite{Sunderhauf2013}. The TB-Places dataset was designed for place recognition in gardens~\cite{leyvavallina2019access,leyvavallina2019caip}. It includes challenging long-term variation, and viewpoint changes, as well as very repetitive textures and scenes dominated by objects of green color appearance. \subsection{Data annotation} CNNs, which constitute the current state-of-the-art in most computer vision tasks, are trained on large-scale annotated datasets, such as ImageNet~\cite{deng2009imagenet} and Places~\cite{zhou2017places} for object and scene classification, COCO~\cite{lin2014microsoft} and Pascal VOC~\cite{Everingham15} for object detection, and Pittsburgh250k~\cite{Torii-CVPR2013} and Mapillary Street Level Sequences~\cite{msls} for visual place recognition. The quality, diversity, and richness of the ground truth annotations have a direct impact on the performance of the trained models and contribute to the strength of their generalization capabilities~\cite{sun2017revisiting}. For instance, in~\cite{biasedai} it was shown that models trained using inaccurate ground truth data can lead to gender and racial biased predictions, as they fail to learn the actual distribution of the real-world problem. Thus, a correct, informative and complete definition of the ground truth labels is of utmost importance to learn more accurate and unbiased models. Previous works on data curation include dataset expansion, e.g. Places2~\cite{zhou2017places}, and manual re-annotations, e.g. Google Landmarks~\cite{weyand2020google}. Another trend in the literature is Multi-Task learning, which consists of learning two (or more) related but yet diverse tasks simultaneously, benefiting from their commonalities. This generally results in higher prediction accuracy for the individual tasks, compared to learning them separately~\cite{caruana1997multitask}. Recent works include the combination of semantic and geometric tasks for pose regression~\cite{kendall2018multi} or joint learning of semantic segmentation and image intrinsic decomposition~\cite{baslamisli2018joint}. Although its efficacy, Multi-Task learning is limited by the scarcity of adequate datasets, which are required to provide samples with multiple labels, for each task. Another option is to incorporate available complementary information in the training process, such as for SeqSLAM~\cite{Milford2012,Sunderhauf2013} where image sequences were used for Simultaneous Localization and Mapping. \subsection{Fully convolutional backbone and pooling} We deploy a siamese architecture with a fully convolutional backbone. Given an input image $x \in R^{w_n \times h_n \times d_n}$, we consider a convolutional network that computes a representation $f(x) \in R^{w_m \times h_m \times d_m}$, where $w_m$ and $h_m$ are the width and height of the last convolutional activation map, and $d_m$ corresponds to the number of kernels of the last convolutional layer. The output tensor of the last convolutional layer of the network is fed to a global pooling layer, which computes the image representation $\hat{f}(x)\in R^{d_m}$. In this work, we experiment with versions of the network with a Global Average Pooling and a GeM pooling layer~\cite{radenovic2018fine}. However, one can explore the use of other global pooling strategies, in accordance with the application at hand. Given a pair of images $(x_i, x_j)$, their representation is computed as $(\hat{f}(x_i), \hat{f}(x_j))$. We illustrate the architecture in Fig.~\ref{fig:siamese}. Our methodology can be applied using any convolutional architecture as backbone: in this work we use DenseNet~\cite{huang2017densely}, ResNet~\cite{he2016deep}\revised{, VGG16~\cite{simonyan2015very} and ResNeXt~\cite{xie2017aggregated}}. \begin{figure}[t!] \centering {\fontsize{7pt}{11pt} \def\textwidth{\columnwidth} \input{figures/3_methodology/Siamese_tex.pdf_tex}} \caption{Sketch of a siamese architecture where $x_i$ and $x_j$ are the input images, $\hat{f}$ represents the convolutional backbone with a pooling layer and $\hat{f}(x_i)$ and $\hat{f}(x_j)$ are the representations of the input images. They are used as input for the Generalized Contrastive Loss function $\mathcal{L}_{GCL}(\hat{f}(x_i), \hat{f}(x_j))$.} \label{fig:siamese} \end{figure} \subsection{Generalized Contrastive Loss} Siamese architectures are used to learn representations that disentangle the (dis-)similarity of pairs of input images. They consist of two identical networks (i.e. they share their weights) that process input image pairs. Applications include signature verification~\cite{bromley1994signature}, face identification~\cite{chopra2005learning}, visual place recognition~\cite{Arandjelovic2017,Lopez-Antequera2017,leyvavallina2019caip} and image retrieval~\cite{radenovic2018fine}. The training of a siamese architecture is generally carried out by optimizing a Contrastive Loss function. \subsubsection{Contrastive Loss function} Let us consider two input images $x_i$ and $x_j$, and their representations $\hat{f}(x_i)$ and $\hat{f}(x_j)$. We define the distance between the representations of the input images $x_i$ and $x_j$ in the latent space as $d(x_i, x_j) = \left \| \hat{f}(x_i)-\hat{f}(x_j) \right \|_2$. The Contrastive Loss~\cite{hadsell2006dimensionality} function $\mathcal{L}_{CL}$ is defined as: \begin{equation} \mathcal{L}_{CL}(x_i,x_j)=\begin{cases} \frac{1}{2}d(x_i, x_j)^2 ,& \text{if } y= 1\\ \frac{1}{2}\max(\tau-d(x_i, x_j),0)^2,& \text{if } y=0 \end{cases} \label{eq:contrastive} \end{equation} where $\tau$ is the margin, i.e. a threshold for the descriptor distance above which a pair of images is not considered as depicting the same place. The margin $\tau$ is an hyperparameter defined by the user. The ground truth label $y$ is such that $1$ indicates a pair of similar images, and $0$ a not-similar pair of images. Similarity, however, is not a binary attribute, and defining it as such may cause the trained models to produce unreliable predictions. Let us consider an example dataset consisting of three images, as depicted in Fig.~\ref{fig:toy_dataset}. The pairs ${(A,B)}$ and ${(B,C)}$ are labeled as similar, while the pair ${(A,C)}$ is labeled as not-similar. The aim of a siamese network is to learn a function $\hat{f}$ that maps similar images to points in a latent space that are close together, and non-similar image pairs to points with larger distance in the latent space. The optimization of the Contrastive Loss function aims at minimizing the distance between the representations of the similar image pairs ${(A,B)}$ and ${(B,C)}$, such that: \begin{equation} \nonumber \left \| \hat{f}(A)-\hat{f}(B) \right \|_2 \approx 0 \,\land\, \left \| \hat{f}(B)-\hat{f}(C) \right \|_2 \approx 0 \end{equation} \noindent that corresponds to: \begin{equation} \nonumber \hat{f}(A)\approx\hat{f}(B) \,\land\, \hat{f}(B)\approx\hat{f}(C) \end{equation} \begin{figure}[t!] \centering \subfloat[A]{ \fbox{\includegraphics[scale=0.075]{figures/3_methodology/toyexample/image_a.png}} \label{fig:image_a} } \subfloat[B]{ \fbox{\includegraphics[scale=0.075]{figures/3_methodology/toyexample/image_b.png}} \label{fig:image_b} } \subfloat[C]{ \fbox{\includegraphics[scale=0.075]{figures/3_methodology/toyexample/image_c.png}} \label{fig:image_c} } \caption{Example dataset consisting of three images. ${(A,B)}$ and ${(B,C)}$ are considered similar ($y=1$) because they share part of their content, while ${(A,C)}$ are dissimilar ($y=0$).} \label{fig:toy_dataset} \end{figure} Therefore, by the transitive property of equality, the Euclidean distance of the representation of $A$ and $C$ is also ensured to be close in the latent space: \begin{equation} \left [ \left ( \hat{f}(A) \approx \hat{f}(B) \right )\land \left (\hat{f}(B)\approx \hat{f}(C) \right )\right ] \rightarrow \hat{f}(C)\approx \hat{f}(A) \label{eq:dissimilar} \end{equation} In the example we considered, however, ${(A,C)}$ is labeled as dissimilar. The result of Eq.~\ref{eq:dissimilar} is in contrast with the optimization ensured by Eq.~\ref{eq:contrastive}, where the distance of the representation of dissimilar images is maximized. This inconsistency in the training process is due to the fact that the Contrastive Loss function does not take into account the partial similarity between the input pairs. \subsubsection{Generalized Contrastive Loss function} We propose a generalized formulation of the Contrastive Loss that relies on a definition of continuous, rather than binary, similarity. We define the Generalized Contrastive Loss function $ \mathcal{L}_{GCL}$ as: \begin{align} \begin{split} \mathcal{L}_{GCL}(x_i,x_j)= {}&\psi_{i,j}\cdot \frac{1}{2}d(x_i, x_j)^2 +\\ & (1-\psi_{i,j}) \cdot \frac{1}{2}\max(\tau-d(x_i, x_j),0)^2 \end{split} \label{eq:generalized_contrastive_loss} \end{align} where $x_i$ and $x_j$ denote the two input images, $\hat{f}(x)$ is the representation of the input $x$ and $\psi_{i,j} \in \left[0, 1 \right]$ is the ground truth degree of similarity of $x_i$ and $x_j$. \revised{In contrast to Eq.~\ref{eq:contrastive}, here the similarity $\psi_{i,j}$ is} a continuous value ranging from 0 (completely dissimilar) to 1 (identical). By minimising a Generalized Contrastive Loss function, the distance of each image pair in the latent space is optimized proportionally to the corresponding degree of similarity. \subsubsection{Gradient of the Generalized Contrastive Loss} In the training phase, the loss function is minimized by gradient descent optimization and the weights of the network are updated by backpropagation. In the case of the Constrastive Loss function, the gradient is: \begin{equation} \nabla \mathcal{L}_{CL}(x_i,x_j)=\begin{cases} d(x_i, x_j) ,& \text{if } y= 1\\ \min(d(x_i, x_j)-\tau,0),& \text{if } y=0 \end{cases} \label{eq:contrastive_loss_grad} \end{equation} It is worth noting that the $\min$ function ensures that the gradient is computed for the negative pairs whose distance in the latent space is lower than the margin $\tau$ (see the supplementary materials for the derivation of the gradient). The weights of the model are updated in order to minimize the distance between similar images, and to maximize the distance between dissimilar ones. A partial similarity is therefore not considered, and the training process may incur in learning inconsistent representations. In contrast, the proposed Generalized Constrastive loss function takes into account the degree of similarity between the input images during the training process. Its gradient is: \begin{equation} \nabla \mathcal{L}_{GCL}(x_i,\!x_j)\!=\!\begin{cases}d(x_i,\!x_j)\!+\!\tau(\psi_{i,j}\!-\!1),& \text{if } d(x_i,\!x_j)\!<\!\tau\\ d(x_i, x_j) \cdot \psi_{i,j},& \text{if } d(x_i,\!x_j)\!\geq\!\tau\\ \end{cases} \label{eq:generalized_contrastive_loss_grad} \end{equation} \noindent It is worth pointing out that the magnitude of the gradient of the Generalized Contrastive Loss function is modulated by the ground truth degree of similarity of the input image pairs, $\psi_{i,j}$. In the case the distance $d(x_i,x_j)$ is larger than the margin $\tau$, the weights of the network are updated proportionally to $\psi_{i,j}$. More interestingly, when the distance $d(x_i,x_j) < \tau$, the Generalized Contrastive Loss function has an intrinsic regularization effect of the learned latent space. The network weights are indeed updated so that the vector representations of the training images $x_i$ and $x_j$ are moved closer in the latent space if their ground truth degree of similarity is $\psi_{i,j} > 1-\frac{d(x_i,x_j)}{\tau}$, otherwise they are pushed away. For the boundary cases $\psi_{i,j}=0$ (completely dissimilar input images) and $\psi_{i,j}=1$ (same exact input images), the gradient is the same as in Eq.~\ref{eq:contrastive_loss_grad}. \subsection{Image search and place recognition} Let us consider a set $X$ of map images, for which the location in the environment of the camera that took them is known. We are presented with a set $Y$ of query images taken from unknown positions. In order to effectively localize the camera that took the query images in the environment, we are required to retrieve similar images to the query from the map set. We compute a representation of the map images $\hat{f}(x) \,\forall x \in X$, and of the query images $\hat{f}(y)\, \forall y \in Y$ using our network. For a given query representation $\hat{f}(y)$, image retrieval is performed by an exhaustive nearest neighbor search among the representations of the map set $\hat{f}(x)\, \forall x \in X$, retrieving the map images with the closest representations in the latent space. It is worth pointing out that in this paper we do not address the camera localization and pose estimation problems. We focus on training networks that are able to compute an effective representation for better retrieval results, which can further benefit the localization task. \subsection{2D Field-of-View overlap} \label{sec:2Dfov} \begin{figure*}[t!] \centering \subfloat[Query]{ \includegraphics[width=.22\textwidth]{figures/4_data/london_query_75_5.jpg} \label{fig:msls_london_query} } \subfloat[Query]{ \includegraphics[width=.22\textwidth]{figures/4_data/tokyo_query_50_31.jpg} \label{fig:msls_tokyo_query} } \subfloat[Query]{ \includegraphics[width=.22\textwidth]{figures/4_data/sf_query_16_78.jpg} \label{fig:msls_sf_query} } \subfloat[Query]{ \includegraphics[width=.22\textwidth]{figures/4_data/trondheim_q_0_0.jpg} \label{fig:msls_trondheim_query} } \subfloat[Positive match]{ \includegraphics[width=.22\textwidth]{figures/4_data/london_db_75_5.jpg} \label{fig:msls_london_db} } \subfloat[Positive match]{ \includegraphics[width=.22\textwidth]{figures/4_data/tokyo_db_50_31.jpg} \label{fig:msls_tokyo_db} } \subfloat[Soft negative match]{ \includegraphics[width=.22\textwidth]{figures/4_data/sf_db_16_78.jpg} \label{fig:msls_sf_db} } \subfloat[Hard negative match]{ \includegraphics[width=.22\textwidth]{figures/4_data/trondheim_db_0_0.jpg} \label{fig:msls_trondheim_db} } \subfloat[75.5\% FoV overlap]{ \includegraphics[width=.22\textwidth]{figures/4_data/london_fov_75_5.png} \label{fig:msls_london_fov} } \subfloat[Fov overlap 50.31\% ]{ \includegraphics[width=.22\textwidth]{figures/4_data/tokyo_fov_50_31.png} \label{fig:msls_tokyo_fov} } \subfloat[FoV overlap 16.78\%]{ \includegraphics[width=.22\textwidth]{figures/4_data/sf_fov_16_78.png} \label{fig:msls_sf_fov} } \subfloat[FoV overlap 0\%]{ \includegraphics[width=.22\textwidth, trim=1cm 1cm 1cm 1cm, clip]{figures/4_data/trondheim_fov_0.png} \label{fig:msls_trondheim_fov} } \caption{Example image pairs from the MSLS dataset. The first row shows the query images, the second row shows the corresponding matches from the map set, and the third row shows the estimated 2D FoV overlap. The query image is associated with the red camera, while the map image with the blue camera. The first column shows a positive match with 75.5\% FoV overlap, and many visual features in common. The second column shows a borderline pair: the two images have 50.31\% FoV overlap and some features in common. The third column shows a soft negative match, where the two images have FoV overlap of 16.78\%. The fourth column shows a hard negative match, where the two images are taken by cameras looking in opposite directions, and the FoV overlap is 0\%.} \label{fig:msls_fov} \end{figure*} We estimate the similarity of two images by approximating a measure of the overlap of their two-dimensional Field-of-View (FoV) in the horizontal plane. Let us consider a camera with a FoV defined by the angle $\theta$ and radius $r$, positioned in an environment according to a 2D translation vector $(t_0,t_1)$ with respect to the origin of the reference system. The camera is oriented at an angle $\alpha$ with respect to the north direction of the reference system. We define the 2D FoV as the sector of the circle denoted by the center $(t_0,t_1)$ and radius $r$ enclosed in the angle range delimited by $[\alpha - \frac{\theta}{2}, \alpha +\frac{\theta}{2}]$ (see Fig.~\ref{fig:fov_graph}). The 2D Field-of-View overlap between two images corresponds to the intersection-over-union (IoU) of their FoVs. \revised{Differently from~\cite{balntas2018relocnet,ding2019camnet} that compute the overlap of 3D camera frusta for camera localization, we relax this concept by only considering the overlap of the camera field-of-views in the horizontal plane.} We consider as positives the image pairs with determined ground truth FoV overlap higher than $50\%$, and the rest as negatives. More specifically, the negative pairs with a similarity higher than $0\%$ are soft negatives, while the pairs with a similarity degree equal to $0\%$ are hard negatives. \subsubsection{Weak 2D Field-of-View overlap} We \revised{present} the \emph{weak 2D Field-of-View overlap} to estimate the similarity of image pairs for which GPS position labels (UTM format) and compass angle information are available. We consider the UTM data as the translation vector $(t_0,t_1)$ and the compass angle as the orientation $\alpha$ necessary to estimate the 2D FoV of the cameras. We use the weak 2D Field-of-View overlap to re-annotate the Mapillary Street Level Sequences (MSLS) dataset~\cite{msls}, a large-scale outdoor visual place recognition dataset. It contains images of 30 cities across 6 continents that depict urban, suburban and countryside environments, and are annotated with the UTM position and compass angle. The FoV angle of the cameras and the intrinsics are not provided. We thus estimate the value of the FoV angle $\theta$ according to the following reasoning. The authors of MSLS define a positive match when the retrieved map image falls within 25m and $40^{\circ}$ from the query. We define a similarity measure that satisfies those constraints. Image pairs taken at locations that are closer than 25m and with orientation differences lower than $40^{\circ}$ are expected to have a similarity higher than $50\%$. Moreover, the borderline cases with distances close to 25m and/or orientation difference near to $40^{\circ}$ should have a similarity close to $50\%$. Hence, we define $r=25m\times2=50m$ and estimate a $\theta$ that gives approximately a $50\%$ FoV overlap for the borderline cases, i.e. 0m@$40^{\circ}$, and 25m@$0^{\circ}$. For the former, the optimal $\theta$ corresponds to $80^{\circ}$, and for the second latter to $102^{\circ}$. We settle for a value in the middle and define $\theta=90^{\circ}$, which gives $55.63\%$ and $45.01\%$ FoV overlaps, as shown in Fig.~\ref{fig:msls_0m_40deg} and~\ref{fig:msls_25m_0deg}. We display examples of the similarity ground truth for MSLS in Fig.~\ref{fig:msls_fov}. \revised{We compute the similarity ground truth for each possible query-map pair, per city.} \subsubsection{Strong 2D Field-of-View overlap} We \revised{present} the \emph{strong 2D Field-of-View overlap} to estimate the similarity of image pairs in the case 6DOF camera pose information is available together with the recorded images in the dataset. The translation vector $(t_0,t_1)$ and orientation angle $\alpha$ are extracted from the pose vector. This is the case of the TB-Places dataset~\cite{leyvavallina2019access}, for visual place recognition in garden environments, created for the Trimbot2020 project~\cite{strisciuglio2018trimbot2020}. It contains images taken in an experimental garden over three years and includes variations in illumination, season and viewpoint. Each image comes with a 6DOF camera pose, which allows us to estimate a very precise 2D FoV. According to the original paper of the TB-places dataset, we set the FoV angle of the cameras as $\theta = 90^{\circ}$ and the radius as $r=3.5m$. We thus estimate the 2D Field-of-View overlap and use it to re-label the pairs of images contained in the dataset. \revised{We provide the similarity ground truth for all possible pairs within W17, the training set.} We show some examples of image pairs and their 2D FoV overlap in Fig.~\ref{fig:tbplaces_fov}. \begin{figure} \centering \subfloat[Query]{ \includegraphics[width=.3\columnwidth]{figures/4_data/W18_positive_q.png} \label{fig:tbplaces_positive_query} } \subfloat[Map]{ \includegraphics[width=.3\columnwidth]{figures/4_data/W18_positive_db.png} \label{fig:tbplaces_positive_db} } \subfloat[FoV overlap (74\%)]{ \includegraphics[width=.33\columnwidth, trim=1cm 2cm 1cm 2cm, clip]{figures/4_data/w18_positive_74_21.png} \label{fig:tbplaces_positive_fov} }\\ \subfloat[Query]{ \includegraphics[width=.3\columnwidth]{figures/4_data/W18_negative_q.png} \label{fig:tbplaces_negative_query} } \subfloat[Map]{ \includegraphics[width=.3\columnwidth]{figures/4_data/W18_negative_db.png} \label{fig:tbplaces_negative_db} } \subfloat[FoV overlap (41\%)]{ \includegraphics[width=.33\columnwidth, trim=1cm 2cm 1cm 2cm, clip]{figures/4_data/w18_negative_40_74.png} \label{fig:tbplaces_negative_fov} } \caption{Example image pairs from the TB-Places dataset. The first row shows a positive pair with FoV overlap of 74\%. The second row depicts a soft negative pair with FoV overlap equal to 41\%. The red camera corresponds to the query image, while the blue one to the map image.} \label{fig:tbplaces_fov} \end{figure} \subsection{3D Field-of-View overlap} \label{sec:3Dfov} When a 3D reconstruction of a concerned environment is available, we propose to estimate the degree of similarity of image pairs by computing the \emph{3D Field-of-View overlap}. We project a given image with an associated 6DOF camera pose onto the reconstructed pointcloud of the environment. We select the subset of 3D points that falls within the boundaries of the image as the image 3D FoV. For an image pair, we compute their 3D FoV overlap as the intersection-over-union (IoU) of the sets of 3D points associated with the two images. \revised{This computation is similar to the \emph{maximum inliers} measure proposed in~\cite{radenovic2018fine}, where it was used as part of a pair-mining strategy that also involved the computation of a distance in the latent-space.} We consider, instead, the computed 3D FoV overlap as a measure of the degree of similarity of a pair of images\revised{, and use it to compute the graded ground truth.} We use the \emph{3D Field-of-View overlap} to re-annotate the 7Scenes dataset~\cite{Shotton2013}, an indoor localization benchmark, that contains RGBD images taken in seven environments. Each image has an associated 6DOF pose, and a 3D reconstruction of each scene is provided. \revised{We provide annotations for each possible pair within the training set per scene. We also compute the test-vs-train similarities for evaluation purposes. }We show some examples of the 3D FoV overlap in Fig.~\ref{fig:7scenes_fov}. We display the 3D FoV associated to the query image in red, that of the map image in blue and their overlap in magenta. \subsection{Selection of training pairs} \label{sec:training_pairs} Training a model for visual place recognition is usually formulated as a binary classification problem. The aim is to determine whether two images depict a similar (class 1) or dissimilar (class 2) place. To train binary classifiers, it is generally desirable to have balanced datasets, to ensure that the two classes are equally weighted. This is often not the case for visual place recognition, where the dissimilar image pairs significantly outnumber the positive pairs. Moreover, when training a siamese architecture, it is necessary to form batches with meaningful image pairs or triplets. For instance, if the training batch consists of pairs that are too easy, the learning process might stall, and the weights of the network not be updated. If the pairs are too difficult, the training dynamics can become unstable~\cite{shi2016embedding}. Hence, the selection of image pairs is a crucial element of the training. \begin{figure}[t] \centering \subfloat[Query]{ \includegraphics[width=.3\columnwidth]{figures/4_data/example_fov_heads_query.png} \label{fig:heads_query} } \subfloat[Map]{ \includegraphics[width=.3\columnwidth]{figures/4_data/example_fov_heads_map.png} \label{fig:heads_db} } \hspace{-4pt}\subfloat[3D FoV overlap (75\%)]{ \includegraphics[width=.35\columnwidth,trim=0 0 0 7cm, clip]{figures/4_data/example_fov_heads_noaxis.png} \label{fig:heads_fov} } \subfloat[Query]{ \includegraphics[width=.3\columnwidth]{figures/4_data/example_fov_pumpkin_query.png} \label{fig:pumpkin_query} } \subfloat[Map]{ \includegraphics[width=.3\columnwidth]{figures/4_data/example_fov_pumpkin_map.png} \label{fig:pumpkin_db} } \hspace{-4pt}\subfloat[3D FoV overlap (50\%)]{ \includegraphics[width=.35\columnwidth]{figures/4_data/example_fov_pumpkin_noaxis.png} \label{fig:pumpkin_fov} } \subfloat[Query]{ \includegraphics[width=.3\columnwidth]{figures/4_data/example_fov_fire_query.png} \label{fig:fire_query} } \subfloat[Map]{ \includegraphics[width=.3\columnwidth]{figures/4_data/example_fov_fire_map.png} \label{fig:fire_db} } \hspace{-4pt}\subfloat[3D FoV overlap (25\%)]{ \includegraphics[width=.35\columnwidth]{figures/4_data/example_fov_fire_noaxis.png} \label{fig:fire_fov} } \caption{3D Field-of-View overlap examples from the 7Scenes dataset. The first row shows a positive pair with 3D FoV overlap of 75\%. The second row depicts a borderline pair with 50\% 3D FoV overlap. The last row shows a soft negative image pair with 25\% 3D FoV overlap. The red pointcloud corresponds to the query 3D FoV, the blue one is the map, and the magenta represents the overlap between them.} \label{fig:7scenes_fov} \end{figure} Existing approaches use complex image pair mining strategies. In the case of NetVLAD~\cite{Arandjelovic2017} \revised{and NetVLAD-based methods like Patch-NetVLAD~\cite{hausler2021patch} or NetVLAD-SARE~\cite{liu2019stochastic}}, the authors use a Hard Negative Mining strategy. For each query image, they select a set of potential positive map images and a set with its 10 hardest negative map images. The best combination of positive and negative samples is selected by means of their contribution to a Triplet Ranking Loss function. This implies that all the images need to be forwarded to the network to compute the value of the loss function, although only three contribute to the learning. In~\cite{msls}, the authors deploy a similar strategy, selecting only the top-5 hardest negatives. For each triplet, many image latent representations are computed. Even with a caching strategy, bigger backbones like VGG cannot be trained in their entirety~\cite{Arandjelovic2017} and large training batches do not fit in the memory of a regular GPU. In~\cite{msls}, indeed, the authors use a batch size of 4 triplets. \revised{A continuous similarity ground truth can lead to improved learning~\cite{thoma2020soft}, but it does not dispense with the need for hard mining strategies by itself. When relying only on the GPS without taking in consideration the orientation, for instance, the ground truth annotations are likely to contain visual inaccuracies, i.e. two images taken 20cm apart facing in opposite directions will not be visually similar, despite having a high annotated similarity. These contradictions make necessary the use of further curation of the selected pairs or triplets by means of a costly hard mining strategy.} We argue that a better curated and more informative ground truth can replace these complicate mining techniques. We use our graded similarity annotations, presented in Sections~\ref{sec:2Dfov} and~\ref{sec:3Dfov} to select the image pairs that compose a training batch. For our training process, we ensure that each training batch contains a balanced amount of positive and negative pairs. In the case of the negative pairs, we also ensure that half of them are soft negatives (i.e. their annotated similarity is higher than 0). \revised{We explore several batch composition strategies and discuss them in Section~\ref{sec:discussion}.} This means that each selected image pair consist of a query and a match image, and we do not require complicated mining strategies or to compute any latent representations to form the pairs. Hence, we are able to train our models with a batch size of 64. \subsection{Datasets} \textbf{Mapillary Street Level Sequences (MSLS). } This is a large scale place recognition dataset that contains images taken in 30 different cities across six continents~\cite{msls}. It includes challenging variations of camera viewpoint, season, time and illumination. Moreover, the images have been taken with different cameras. The training set contains over 500k query images and 900k map images, taken in 22 cities. The validation set consists of 19k map images and 11k query images, taken in two cities, and the test set has 39k map images and 27k query images, taken in six different cities. We evaluate our models on the MSLS validation set and on the MSLS test set. For the former, we use the evaluation script published by the authors of the dataset. For the latter, since the ground truth is not publicly available, we submit our predictions to the official evaluation server. Following the protocol established by the authors of the dataset~\cite{msls}, two images are considered as similar if they are taken by cameras located within $25m$ of distance, and with less than $40^{\circ}$ of viewpoint variation. \textbf{Pittsburgh. } This dataset contains images of urban environments gathered from Google Street View in the city of Pittsburgh, Pennsylvania, USA~\cite{Torii-PAMI2015}, taken in the span of several years. We \revised{use the Pitts30k as test set~\cite{Arandjelovic2017}, a subset of the Pittsburgh dataset which consists of }10k map images and 7k query images, to evaluate the generalization of our models trained on MSLS. \textbf{Tokyo 24/7. } It consists of images taken in Tokyo, Japan, containing large variations of illumination, as they are taken during day and night~\cite{Torii-CVPR2013}. The query set consists of 315 images, and the map contains 76k photos. \revised{ \textbf{RobotCar Seasons v2.} This dataset~\cite{sattler2018benchmarking} is a subset of Oxford RobotCar~\cite{Maddern2017}, a visual localization dataset with images taken in the city of Oxford, UK, within the span of twelve months. Its query set contains 1872 images under different lighting and weather conditions, and its reference set consists of 21k images taken during at daytime, with overcast weather. \textbf{Extended CMU Seasons. } This is an expansion of the CMU Seasons dataset~\cite{sattler2018benchmarking}, which in turn is a subset of the CMU Dataset~\cite{Badino2011}. It contains images taken in urban, suburban and park environments, in the city of Pittsburgh, over a period of 1 year. Its query set contains 61k images, and its reference set contains 57k images. } \textbf{TB-Places. } This dataset was designed for place recognition in garden environments~\cite{leyvavallina2019access, leyvavallina2019caip}. It contains images taken by a rover robot in a garden at the University of Wageningen, the Netherlands, over the course of three years. The dataset was collected for the TrimBot2020 project~\cite{strisciuglio2018trimbot2020}. It includes drastic viewpoint variations, as well as illumination changes. The garden is a very challenging small environment with repetitive textures. \begin{figure}[t!] \centering \subfloat[]{ \includegraphics[width=.48\columnwidth]{figures/5_experiments/W18_W17_map_query.pdf} \label{fig:w17_18} }\hspace{-10pt}~\subfloat[]{ \includegraphics[width=.48\columnwidth]{figures/5_experiments/W18_map_query.pdf} \label{fig:w18_w18} } \caption{Configurations of the experiments on the TB-Places dataset. (a) W17 subset is the map set, and W18 is the query. (b) We divide W18 into map and query. For visualization purposes, the trajectories have been downsampled.} \label{fig:tb_places_test_sets} \end{figure} The dataset consists of three subsets, i.e. W16, that contains 41k images taken in 2016; W17, that includes 11k images taken in 2017; and W18, that has 23k images taken in 2018. As in~\cite{leyvavallina2019caip} we use the W17 subset to train our models. We design two experiments to evaluate our models. For the first one we establish W17 as map set (11k images) and W18 as query (23k images). With this configuration we aim to test the robustness of our models w.r.t. changes between the map and the query sets. For the second experiment, we divide W18 into query (17k images) and map (6k images) to test the generalization capabilities of our models in the case both map and query sets were not used for training. In Fig.~\ref{fig:tb_places_test_sets}, we show a sketch of the trajectory that the robot covered in the TrimBot2020 garden for the recording of the reference map (blue trajectory) and query (orange trajectory) images. It is worth pointing out that the query images were taken from locations not covered by map images, thus including substantial viewpoint variations. \textbf{7Scenes. } It is a benchmark dataset for indoor camera localization algorithms~\cite{Shotton2013}. It includes 26k training images and 17k test images, taken in seven different environments. Each image has an associated ground truth 6DOF camera pose. Additionally, a 3D reconstruction of each scene is available. We use it to test our models for visual place recognition in indoor environments. For evaluation purposes, we define an image pair as a positive match if their annotated degree of similarity is higher than $50\%$. We use the training set as map, and the test set as query. \subsection{Implementation details} We implemented our models using the PyTorch framework~\footnote{\url{http://pytorch.org/}} and trained them on a \revised{NVIDIA} V100 GPU card. We optimized the weights of our models with Stochastic Gradient Descent. To train the networks that use the binary Contrastive Loss function, we set an initial learning rate $l_0=0.01$. For those that deploy the Generalized Contrastive Loss function, we used as initial learning rate $l_0=0.1$. In both cases the learning rate is divided by $10$ after every \revised{250k pairs} for MSLS, or every 15 epochs for TB-Places and 7Scenes. We set the margin value $\tau=0.5$ and we use a batch size of 64. We trained the two last convolutional blocks of the backbone networks for all experiments. The necessary code to replicate the experiments is publicly available~\footnote{\url{http://github.com/marialeyvallina/generalized_contrastive_loss}}. \begin{table*}[t!] \centering \caption{\revised{Ablation study on the considered datasets: all the models are trained on the MSLS train set. CL stands for Contrastive Loss and while GCL for our Generalized Contrastive Loss. For the cases in which PCA whitening is applied we report the dimensionality that achieves the best results on the MSLS validation set. } } \label{tab:msls-ablation} \resizebox{\textwidth}{!}{% \setlength\tabcolsep{1.5pt} \revised{ \begin{tabular}{@{}llcc@{\hspace{4\tabcolsep}}ccc@{\hspace{4\tabcolsep}}ccc@{\hspace{4\tabcolsep}}ccc@{\hspace{4\tabcolsep}}ccc@{\hspace{4\tabcolsep}}ccc@{\hspace{4\tabcolsep}}ccc@{}} & & & & \multicolumn{3}{c}{\textbf{MSLS-Val}} & \multicolumn{3}{c}{\textbf{MSLS-Test}} & \multicolumn{3}{c}{\textbf{Pitts30k}} & \multicolumn{3}{c}{\textbf{Tokyo24/7}} & \multicolumn{3}{c}{\textbf{RobotCar Seasons v2}} & \multicolumn{3}{c}{\textbf{Extended CMU Seasons}} \\ \textbf{Method} & \textbf{Loss} & \textbf{PCA$_w$} & \textbf{Dim} & \textbf{R@1} &\textbf{ R@5} & \textbf{R@10} & \textbf{R@1} & \textbf{R@5} & \textbf{R@10} &\textbf{ R@1} & \textbf{R@5} & \textbf{R@10} & \textbf{R@1} & \textbf{R@5 }& \textbf{R@10} & \textbf{0.25m/2$\degree$} & \textbf{0.5m/5$\degree$} & \textbf{5.0m/10$\degree$} & \textbf{0.25m/2$\degree$} & \textbf{0.5m/5$\degree$} & \textbf{5.0m/10$\degree$} \\ \toprule \multirow{4}{*}{VGG-GeM} & CL & N & 512 & 47.0 & 60.3 & 65.5 & 27.9 & 40.5 & 46.5 & 51.2 & 71.9 & 79.7 & 24.1 & 39.4 & 47.0 & 3.1 & 13.2 & 55.0 & 2.8 & 8.6 & 44.5 \\ & GCL & N & 512 & 65.9 & 77.8 & 81.4 & 41.7 & 55.7 & 60.6 & 61.6 & 80.0 & 86.0 & 34.0 & 51.1 & 61.3 & 3.7 & 15.8 & 59.7 & 3.6 & 11.2 & 55.8 \\ & CL & Y & 512 & 61.4 & 75.1 & 78.5 & 36.3 & 49.0 & 54.1 & 64.7 & 81.5 & 86.8 & 36.2 & 54.0 & 57.8 & 4.2 & 18.7 & 62.5 & 4.4 & 13.4 & 56.5 \\ & GCL & Y & 512 & 72.0 & 83.1 & 85.8 & 47.0 & 60.8 & 65.5 & 73.3 & 85.9 & 89.9 & 47.6 & 61.0 & 69.2 & 5.4 & 21.9 & 69.2 & 5.7 & 17.1 & 66.3 \\ \midrule \multirow{4}{*}{ResNet50-GeM} & CL & N & 2048 & 51.4 & 66.5 & 70.8 & 29.7 & 44.0 & 50.7 & 61.5 & 80.0 & 86.9 & 30.8 & 46.0 & 56.5 & 3.2 & 15.4 & 61.5 & 3.2 & 9.6 & 49.5 \\ & GCL & N & 2048 & 66.2 & 78.9 & 81.9 & 43.3 & 59.1 & 65.0 & 72.3 & 87.2 & 91.3 & 44.1 & 61.0 & 66.7 & 2.9 & 14.0 & 58.8 & 3.8 & 11.8 & 61.6 \\ & CL & Y & 1024 & 63.2 & 76.6 & 80.7 & 37.9 & 53.0 & 58.5 & 66.2 & 82.2 & 87.3 & 36.2 & 51.8 & 61.0 & 5.0 & 21.1 & 66.5 & 4.7 & 13.4 & 51.6 \\ & GCL & Y & 1024 & 74.6 & 84.7 & 88.1 & 52.9 & 65.7 & 71.9 & 79.9 & 90.0 & 92.8 & 58.7 & 71.1 & 76.8 & 4.7 & 20.2 & 70.0 & 5.4 & 16.5 & 69.9 \\ \midrule \multirow{4}{*}{ResNet152-GeM} & CL & N & 2048 & 58.0 & 72.7 & 76.1 & 34.1 & 50.8 & 56.8 & 66.5 & 83.8 & 89.5 & 34.6 & 57.1 & 63.5 & 3.3 & 15.2 & 64.0 & 3.2 & 9.7 & 52.2 \\ & GCL & N & 2048 & 70.3 & 82.0 & 84.9 & 45.7 & 62.3 & 67.9 & 72.6 & 87.9 & 91.6 & 34.0 & 51.8 & 60.6 & 2.9 & 13.1 & 63.5 & 3.6 & 11.3 & 63.1 \\ & CL & Y & 2048 & 66.9 & 80.9 & 83.8 & 44.8 & 59.2 & 64.8 & 71.2 & 85.8 & 89.8 & 54.3 & 68.9 & 75.6 & \textbf{6.1 } & \textbf{23.5} & 68.9 & 4.8 & 14.2 & 55.0 \\ & GCL & Y & 2048 & 79.5 & 88.1 & 90.1 & 57.9 & 70.7 & 75.7 & \textbf{80.7} & \textbf{91.5} & \textbf{93.9} & \textbf{69.5} & \textbf{81.0} & \textbf{85.1} & 6.0 & 21.6 & 72.5 & 5.3 & 16.1 & 66.4 \\ \midrule \multirow{4}{*}{ResNeXt-GeM} & CL & N & 2048 & 62.6 & 76.4 & 79.9 & 40.8 & 56.5 & 62.1 & 56.0 & 77.5 & 85.0 & 37.8 & 54.9 & 62.5 & 1.9 & 10.4 & 54.8 & 2.9 & 9.0 & 52.6 \\ & GCL & N & 2048 & 75.5 & 86.1 & 88.5 & 56.0 & 70.8 & 75.1 & 64.0 & 81.2 & 86.6 & 37.8 & 53.6 & 62.9 & 2.7 & 13.4 & 65.2 & 3.5 & 10.5 & 58.8 \\ & CL & Y & 1024 & 74.3 & 87.0 & 89.6 & 49.9 & 63.8 & 69.4 & 70.9 & 85.7 & 90.2 & 50.8 & 67.6 & 74.3 & 3.8 & 17.2 & 68.2 & 4.9 & 14.4 & 61.7 \\ & GCL & Y & 1024 & \textbf{80.9} & \textbf{90.7} & \textbf{92.6} & \textbf{62.3} & \textbf{76.2} & \textbf{81.1} & 79.2 & 90.4 & 93.2 & 58.1 & 74.3 & 78.1 & 4.7 & 21.0 & \textbf{74.7} & \textbf{6.1} & \textbf{18.2} & \textbf{74.9} \\ \bottomrule \end{tabular} }} \end{table*} \begin{table*}[t!] \centering \caption{\revised{Comparison of our results with those of state-of-the-art approaches on the considered datasets. For each model, we report if PCA whitening is used and the dimensionality of the learned image latent vector.The best result by our method is underlined, and the overall best in presented in bold font.}} \label{tab:msls-sota} \resizebox{\textwidth}{!}{% \setlength\tabcolsep{1.5pt} \revised{ \begin{tabular}{@{}lcc@{\hspace{4\tabcolsep}}ccc@{\hspace{4\tabcolsep}}ccc@{\hspace{4\tabcolsep}}ccc@{\hspace{4\tabcolsep}}ccc@{\hspace{4\tabcolsep}}ccc@{\hspace{4\tabcolsep}}ccc@{}} & & & \multicolumn{3}{c}{\textbf{MSLS-Val}} & \multicolumn{3}{c}{\textbf{MSLS-Test}} & \multicolumn{3}{c}{\textbf{Pitts30k}} & \multicolumn{3}{c}{\textbf{Tokyo24/7}} & \multicolumn{3}{c}{\textbf{RobotCar Seasons v2}} & \multicolumn{3}{c}{\textbf{Extended CMU Seasons}} \\ \textbf{Method} & \textbf{PCA$_w$} & \textbf{Dim} & \textbf{R@1} & \textbf{R@5} & \textbf{R@10} & \textbf{R@1} & \textbf{R@5} & \textbf{R@10} & \textbf{R@1} & \textbf{R@5} & \textbf{R@10} & \textbf{R@1} & \textbf{R@5 }& \textbf{R@10} & \textbf{0.25m/2$\degree$} & \textbf{0.5m/5$\degree$ }& \textbf{5.0m/10$\degree$ }& \textbf{0.25m/2$\degree$ }& \textbf{0.5m/5$\degree$ }& \textbf{5.0m/10$\degree$} \\\toprule NetVLAD 64 Pitts & N & 32768 & 47.7 & 62.8 & 70.9 & 30.7 & 41.9 & 46.4 & 82.1 & 91.4 & 93.8 & 62.2 & 73.7 & 78.4 & 5.6 & 22.0 & 71.0 & 10.7 & 27.8 & 84.1 \\ NetVLAD 64 Pitts & Y & 4096 & 70.7 & 81.4 & 84.6 & 30.6 & 41.9 & 47.5 & 83.7 & 91.8 & 94.0 & 67.0 & 77.8 & 80.3 & 5.8 & 23.1 & 73.2 & 11.6 & 30.3 & 87.5 \\ NetVLAD 64 MSLS & N & 32768 & 44.6 & 61.1 & 66.4 & 28.8 & 44.0 & 50.7 & 40.4 & 64.5 & 74.2 & 11.4 & 24.1 & 31.4 & 2.0 & 9.2 & 45.5 & 1.3 & 4.5 & 31.9 \\ NetVLAD 64 MSLS & Y & 4096 & 70.1 & 80.8 & 84.9 & 45.1 & 58.8 & 63.7 & 68.6 & 84.7 & 88.9 & 34.0 & 47.6 & 57.1 & 4.2 & 18.0 & 68.1 & 3.9 & 12.1 & 58.4 \\ NetVLAD 16 MSLS & N & 8192 & 49.5 & 65.0 & 71.8 & 29.3 & 43.5 & 50.4 & 48.7 & 70.6 & 78.9 & 13.0 & 33.0 & 43.8 & 1.8 & 9.2 & 48.4 & 1.7 & 5.5 & 39.1 \\ NetVLAD 16 MSLS & Y & 4096 & 70.5 & 81.1 & 84.3 & 39.4 & 53.0 & 57.5 & 70.3 & 84.1 & 89.1 & 37.8 & 53.3 & 61.0 & 4.8 & 17.9 & 65.3 & 4.4 & 13.7 & 61.4 \\ Patch NetVLAD & Y & 4096 & 79.5 & 86.2 & 87.7 & 48.1 & 57.6 & 60.5 & \textbf{88.7} & \textbf{94.5} & \textbf{95.9} & \textbf{86.0} & \textbf{88.6} & \textbf{90.5} & \textbf{9.6} & \textbf{35.3} & \textbf{90.9} & \textbf{11.8} & \textbf{36.2} & \textbf{96.2} \\ ResNet101-AP-GeM & Y & 2048 & 64.1 & 75.0 & 78.2 & 33.7 & 44.5 & 49.4 & 80.7 & 91.4 & 94.0 & 11.4 & 22.9 & 30.5 & 5.1 & 20.5 & 66.1 & 4.9 & 14.7 & 65.2 \\ NetVLAD-SARE & Y & 4096 & 68.1 & 77.3 & 82.4 & 34.4 & 44.3 & 48.8 & 87.8 & 94.3 & \textbf{95.9} & 79.7 & 86.7 & 90.5 & 7.4 & 26.5 & 81.3 & 6.4 & 19.4 & 75.5 \\ \midrule VGG-GeM-GCL & N & 512 & 65.9 & 77.8 & 81.4 & 41.7 & 55.7 & 60.6 & 61.6 & 80.0 & 86.0 & 34.0 & 51.1 & 61.3 & 3.7 & 15.8 & 59.7 & 3.6 & 11.2 & 55.8 \\ VGG-GeM-GCL & Y & 512 & 72.0 & 83.1 & 85.8 & 47.0 & 60.8 & 65.5 & 73.3 & 85.9 & 89.9 & 47.6 & 61.0 & 69.2 & 5.4 & 21.9 & 69.2 & 5.7 & 17.1 & 66.3 \\ ResNet50-GeM-GCL & N & 2048 & 66.2 & 78.9 & 81.9 & 43.3 & 59.1 & 65.0 & 72.3 & 87.2 & 91.3 & 44.1 & 61.0 & 66.7 & 2.9 & 14.0 & 58.8 & 3.8 & 11.8 & 61.6 \\ ResNet50-GeM-GCL & Y & 1024 & 74.6 & 84.7 & 88.1 & 52.9 & 65.7 & 71.9 & 79.9 & 90.0 & 92.8 & 58.7 & 71.1 & 76.8 & 4.7 & 20.2 & 70.0 & 5.4 & 16.5 & 69.9 \\ ResNet152-GeM-GCL& N & 2048 & 70.3 & 82.0 & 84.9 & 45.7 & 62.3 & 67.9 & 72.6 & 87.9 & 91.6 & 34.0 & 51.8 & 60.6 & 2.9 & 13.1 & 63.5 & 3.6 & 11.3 & 63.1 \\ ResNet152-GeM-GCL & Y & 2048 & 79.5 & 88.1 & 90.1 & 57.9 & 70.7 & 75.7 & \underline{80.7} & \underline{91.5} & \underline{93.9} & \underline{69.5} & \underline{81.0} & \underline{85.1} & \underline{6.0} & \underline{21.6} & 72.5 & 5.3 & 16.1 & 66.4 \\ ResNeXt-GeM-GCL & N & 2048 & 75.5 & 86.1 & 88.5 & 56.0 & 70.8 & 75.1 & 64.0 & 81.2 & 86.6 & 37.8 & 53.6 & 62.9 & 2.7 & 13.4 & 65.2 & 3.5 & 10.5 & 58.8 \\ ResNeXt-GeM-GCL & Y & 1024 & \underline{\textbf{ 80.9}} & \underline{\textbf{90.7}} & \underline{\textbf{92.6}} & \underline{\textbf{62.3}} & \underline{\textbf{76.2}} & \underline{\textbf{81.1}} & 79.2 & 90.4 & 93.2 & 58.1 & 74.3 & 78.1 & 4.7 & 21.0 & \underline{74.7} & \underline{6.1} & \underline{18.2} & \underline{74.9} \\ \bottomrule \end{tabular} }} \end{table*} \begin{figure*}[t!] \centering \vspace{0.5cm} \subfloat[MSLS validation set]{ \begin{tikzpicture}[thick,scale=1, every node/.style={scale=.8}] \begin{axis} [xlabel=K, ylabel=Recall@K (\%), ylabel style={at={(axis description cs:-0.08,0.5)}}, legend pos =south east,grid, height=6cm, width=7.5cm] \addplot[magenta, mark size=2pt, thick , mark=triangle,mark options=dashed, style=dashed] table [x=k, y=r, col sep=comma] {plot_data/MSLS/val/Pitts_vgg16_NetVLAD_64_TL_results_latex.csv}; \addplot[magenta, mark size=2pt, thick , mark=triangle,mark options=solid, style=solid] table [x=k, y=r, col sep=comma] {plot_data/MSLS/val/Pitts_vgg16_NetVLAD_64_TL_pca_results_latex.csv}; \addplot[black, mark size=2pt, thick , mark=pentagon,mark options=dashed, style=dashed] table [x=k, y=r, col sep=comma] {plot_data/MSLS/val/MSLS_vgg16_NetVLAD_16_TL_results_latex.csv}; \addplot[black, mark size=2pt, thick , mark=pentagon,mark options=solid, style=solid] table [x=k, y=r, col sep=comma] {plot_data/MSLS/val/MSLS_vgg16_NetVLAD_16_TL_pca_results_latex.csv}; \addplot[black, mark size=2pt, thick , mark=triangle,mark options=dashed, style=dashed] table [x=k, y=r, col sep=comma] {plot_data/MSLS/val/MSLS_vgg16_NetVLAD_64_TL_results_latex.csv}; \addplot[black, mark size=2pt, thick , mark=triangle,mark options=solid, style=solid] table [x=k, y=r, col sep=comma] {plot_data/MSLS/val/MSLS_vgg16_NetVLAD_64_TL_pca_results_latex.csv}; \addplot[green, mark size=2pt, thick , mark=triangle,mark options=solid, style=solid] table [x=k, y=r, col sep=comma] {plot_data/MSLS/val/MSLS_vgg16_NetVLAD_64_SARE_results_latex.csv}; \addplot[red, mark size=2pt, thick , mark=triangle,mark options=dashed, style=dashed] table [x=k, y=r, col sep=comma] {plot_data/MSLS/val/MSLS_vgg16_GeM_480_GCL_results_latex.csv}; \addplot[red, mark size=2pt, thick , mark=triangle,mark options=solid, style=solid] table [x=k, y=r, col sep=comma] {plot_data/MSLS/val/MSLS_vgg16_GeM_480_GCL_PCA_results_latex.csv}; \addplot[red, mark size=2pt, thick , mark=square,mark options=dashed, style=dashed] table [x=k, y=r, col sep=comma] {plot_data/MSLS/val/MSLS_resnet50_GeM_480_GCL_results_latex.csv}; \addplot[red, mark size=2pt, thick , mark=square,mark options=solid, style=solid] table [x=k, y=r, col sep=comma] {plot_data/MSLS/val/MSLS_resnet50_GeM_480_GCL_PCA_results_latex.csv}; \addplot[red, mark size=2pt, thick , mark=*,mark options=dashed, style=dashed] table [x=k, y=r, col sep=comma] {plot_data/MSLS/val/MSLS_resnet152_GeM_480_GCL_results_latex.csv}; \addplot[red, mark size=2pt, thick , mark=*,mark options=solid, style=solid] table [x=k, y=r, col sep=comma] {plot_data/MSLS/val/MSLS_resnet152_GeM_480_GCL_PCA_results_latex.csv}; \addplot[red, mark size=2pt, thick , mark=diamond,mark options=dashed, style=dashed] table [x=k, y=r, col sep=comma] {plot_data/MSLS/val/MSLS_resnext_GeM_480_GCL_results_latex.csv}; \addplot[red, mark size=2pt, thick , mark=diamond,mark options=solid, style=solid] table [x=k, y=r, col sep=comma] {plot_data/MSLS/val/MSLS_resnext_GeM_480_GCL_PCA_results_latex.csv}; \addplot[blue, mark size=2pt, thick , mark=star,mark options=solid, style=solid] table [x=k, y=r, col sep=comma] {plot_data/MSLS/val/Pitts_ResNet101_GeM_480_apgem_results_latex.csv}; \end{axis} \end{tikzpicture}\label{fig:msls_recall_val} \subfloat[MSLS test set]{ \begin{tikzpicture}[thick,scale=1, every node/.style={scale=.8}] \begin{axis} [xlabel=K, legend pos =south east,grid, height=6cm, width=7.5cm] \addplot[magenta, mark size=2pt, thick , mark=triangle,mark options=dashed, style=dashed] table [x=k, y=r, col sep=comma] {plot_data/MSLS/test/Pitts_vgg16_netvlad_64_TL_latex.csv}; \addplot[magenta, mark size=2pt, thick , mark=triangle,mark options=solid, style=solid] table [x=k, y=r, col sep=comma] {plot_data/MSLS/test/Pitts_vgg16_netvlad_64_TL_pca_latex.csv}; \addplot[black, mark size=2pt, thick , mark=pentagon,mark options=dashed, style=dashed] table [x=k, y=r, col sep=comma] {plot_data/MSLS/test/MSLS_vgg16_netvlad_16_TL_latex.csv}; \addplot[black, mark size=2pt, thick , mark=pentagon,mark options=solid, style=solid] table [x=k, y=r, col sep=comma] {plot_data/MSLS/test/MSLS_vgg16_netvlad_16_TL_pca_latex.csv}; \addplot[black, mark size=2pt, thick , mark=triangle,mark options=dashed, style=dashed] table [x=k, y=r, col sep=comma] {plot_data/MSLS/test/MSLS_vgg16_netvlad_64_TL_latex.csv}; \addplot[green, mark size=2pt, thick , mark=triangle,mark options=dashed, style=dashed] table [x=k, y=r, col sep=comma] {plot_data/MSLS/test/MSLS_vgg16_netvlad_64_SARE_latex.csv}; \addplot[red, mark size=2pt, thick , mark=triangle,mark options=dashed, style=dashed] table [x=k, y=r, col sep=comma] {plot_data/MSLS/test/MSLS_vgg16_GeM_480_GCL_results_latex.csv}; \addplot[red, mark size=2pt, thick , mark=triangle,mark options=solid, style=solid] table [x=k, y=r, col sep=comma] {plot_data/MSLS/test/MSLS_vgg16_GeM_480_GCL_PCA_results_latex.csv}; \addplot[red, mark size=2pt, thick , mark=square,mark options=dashed, style=dashed] table [x=k, y=r, col sep=comma] {plot_data/MSLS/test/MSLS_resnet50_GeM_480_GCL_results_latex.csv}; \addplot[red, mark size=2pt, thick , mark=square,mark options=solid, style=solid] table [x=k, y=r, col sep=comma] {plot_data/MSLS/test/MSLS_resnet50_GeM_480_GCL_PCA_results_latex.csv}; \addplot[red, mark size=2pt, thick , mark=*,mark options=dashed, style=dashed] table [x=k, y=r, col sep=comma] {plot_data/MSLS/test/MSLS_resnet152_GeM_480_GCL_results_latex.csv}; \addplot[red, mark size=2pt, thick , mark=*,mark options=solid, style=solid] table [x=k, y=r, col sep=comma] {plot_data/MSLS/test/MSLS_resnet152_GeM_480_GCL_PCA_results_latex.csv}; \addplot[red, mark size=2pt, thick , mark=diamond,mark options=dashed, style=dashed] table [x=k, y=r, col sep=comma] {plot_data/MSLS/test/MSLS_resnext_GeM_480_GCL_results_latex.csv}; \addplot[red, mark size=2pt, thick , mark=diamond,mark options=solid, style=solid] table [x=k, y=r, col sep=comma] {plot_data/MSLS/test/MSLS_resnext_GeM_480_GCL_PCA_results_latex.csv}; \addplot[blue, mark size=2pt, thick , mark=triangledown,mark options=solid, style=solid] table [x=k, y=r, col sep=comma] {plot_data/MSLS/test/Pitts_ResNet101_GeM_480_apgem_results_latex.csv}; \end{axis} \end{tikzpicture} \label{fig:msls_recall_test} } \subfloat{ \begin{minipage}[t]{.65\columnwidth} \vspace{-5.15cm} \begin{tikzpicture}[thick, scale=1, every node/.style={scale=.8}] \begin{axis}[% hide axis, xmin=20, xmax=50, ymin=0, ymax=0.4, height=6cm, width=2cm, legend style={draw=white!15!black,legend cell align=left, font=\footnotesize} ] \addlegendimage{magenta, mark size=2pt, thick , mark=triangle, style=dashed,mark options=dashed} \addlegendentry{VGG-NetVLAD-TL-64-Pitts}; \addlegendimage{magenta, mark size=2pt, thick , mark=triangle, style=solid,mark options=solid} \addlegendentry{VGG-NetVLAD-TL-64-Pitts-PCA$_w$}; \addlegendimage{black, mark size=2pt, thick , mark=pentagon, style=dashed,mark options=dashed} \addlegendentry{VGG-NetVLAD-TL-16-MSLS}; \addlegendimage{black, mark size=2pt, thick , mark=pentagon, style=solid,mark options=solid} \addlegendentry{VGG-NetVLAD-TL-16-MSLS-PCA$_w$}; \addlegendimage{black, mark size=2pt, thick , mark=triangle, style=dashed,mark options=dashed} \addlegendentry{VGG-NetVLAD-TL-64-MSLS}; \addlegendimage{black, mark size=2pt, thick , mark=triangle, style=solid,mark options=solid} \addlegendentry{VGG-NetVLAD-TL-64-MSLS-PCA$_w$}; \addlegendimage{green, mark size=2pt, thick , mark=triangle, style=solid,mark options=solid} \addlegendentry{VGG-NetVLAD-SARE-64}; \addlegendimage{blue, mark size=2pt, thick , mark=star, style=solid,mark options=solid} \addlegendentry{ResNet101-GeM-AP}; \addlegendimage{red, mark size=2pt, thick , mark=triangle, style=dashed,mark options=dashed} \addlegendentry{VGG16-GeM-GCL}; \addlegendimage{red, mark size=2pt, thick , mark=triangle, style=solid,mark options=solid} \addlegendentry{VGG16-GeM-GCL-PCA$_w$}; \addlegendimage{red, mark size=2pt, thick , mark=square, style=dashed,mark options=dashed} \addlegendentry{ResNet50-GeM-GCL}; \addlegendimage{red, mark size=2pt, thick , mark=square, style=solid,mark options=solid} \addlegendentry{ResNet50-GeM-GCL-PCA$_w$}; \addlegendimage{red, mark size=2pt, thick , mark=*, style=dashed,mark options=dashed} \addlegendentry{ResNet152-GeM-GCL}; \addlegendimage{red, mark size=2pt, thick , mark=*, style=solid,mark options=solid} \addlegendentry{ResNet152-GeM-GCL-PCA$_w$}; \addlegendimage{red, mark size=2pt, thick , mark=diamond, style=dashed,mark options=dashed} \addlegendentry{ResNeXt-GeM-GCL}; \addlegendimage{red, mark size=2pt, thick , mark=diamond, style=solid,mark options=solid} \addlegendentry{ResNeXt-GeM-GCL-PCA$_w$}; \end{axis} \end{tikzpicture} \end{minipage} } \caption{Comparison of the results achieved by our methods with those of state-of-the-art methods and models trained with a binary contrastive loss for (a) MSLS validation and (b) MSLS test. TL stands for models trained with the Triplet Loss, CL for Contrastive Loss and GCL for Generalized Contrastive Loss. \revised{The results obtained by our models are displayed in red, with a solid line for those trained with a GCL function, and a dashed one for those trained with a CL function. }} \label{fig:msls_recall} \end{figure*} \subsection{Evaluation metrics} We followed a widely used place recognition evaluation protocol and considered a query as correctly identified if any of the top-k retrieved images are annotated as a positive match~\cite{Sattler2012, Arandjelovic2017,msls}. We computed the following metrics. \textbf{Top-k recall (R@k)} is the percentage of queries for which we retrieved at least a correct map image among their $k$ nearest neighbors. \revised{\textbf{Percentage of correctly localized queries} is the amount of images that are correctly retrieved for a given translation and rotation threshold. We use it for evaluating on the RobotCar Seasons v2 and the Extended CMU datasets.} \textbf{Average Precision (AP),} an approximation of the area under the precision-recall curve for the classification of all the possible pairs of images. We use this measure for the 7Scenes dataset~\cite{Shotton2013}. \subsection{Large scale outdoor place recognition} We trained several models on the MSLS training set and report results on the MSLS validation and test set. We evaluate the generalization capabilities of our models by also testing them on the Pittsburgh30k, Tokyo~24/7, \revised{RobotCar Seasons v2, and ExtendedCMU Seasons} datasets. In the following, we use the naming \mbox{\emph{backbone}-\emph{pooling}-\emph{loss}} for the considered models. For example, \mbox{ResNet50-GeM-GCL} indicates a ResNet50 backbone with GeM pooling trained using the Generalized Contrastive Loss function. \textbf{Mapillary Street Level Sequences.} We carried out experiments using \revised{four} backbones, namely \revised{VGG16}, ResNet50, ResNet152, and \revised{ResNeXt101-32x8d (hereinafter ResNeXt)}, and \revised{the GeM~\cite{radenovic2018fine}} global pooling layer. \revised{Additional results with an average global pooling layer are included in the supplementary material}. For each combination of backbone network and pooling layer, we optimize the models with the binary Contrastive Loss and with our Generalized Contrastive Loss. As shown in Table~\ref{tab:msls-ablation} and Fig.~\ref{fig:msls_recall}, the models trained with the GCL function consistently outperform their counterparts trained with the CL. For \revised{all models}, we also perform a postprocessing step consisting of PCA whitening and observe that it further boosts the performance. We compared the results of our models with those obtained by state-of-the-art methods\revised{, namely NetVLAD~\cite{Arandjelovic2017}, NetVLAD-SARE~\cite{liu2019stochastic}, AP-GeM~\cite{revaud2019learning} and Patch-NetVLAD~\cite{hausler2021patch}}. We achieved better results than existing approaches on the MSLS test set. We demonstrate that a simple\revised{r} architecture, \revised{consisting only of a convolutional backbone and a simple pooling layer arranged as a two-way siamese network,} trained using the proposed GCL loss function outperforms more complex architectures, which deploy triplet networks and VLAD layers. For instance, NetVLAD achieved a top-5 recall equal to \revised{44\%} on the MSLS test set~\cite{msls}\revised{, while our \mbox{VGG16-GeM-GCL} model, which uses the same backbone as NetVLAD, achieved a top-5 recall of 55.7\%. The superiority of our \mbox{VGG16-GeM-GCL} model holds also in the case we post-process the descriptors using PCA whitening.} For \mbox{ResNet50-GeM-GCL}, we obtained a top-5 recall equal to 59.2\%. Our \mbox{ResNet152-GeM-GCL} \revised{and our ResNeXt-GeM-GCL achieved a top-5 recall equal to 62.3\% and 70.8\%, respectively.} When whitening is applied, the performance of our models further improved, reaching a top-5 recall of \revised{60.8\% for \mbox{VGG-GeM-GCL},} 65.7\% for \mbox{ResNet50-GeM-GCL} 70.7\% for \mbox{ResNet152-GeM-GCL}, \revised{and 76.2\% for \mbox{ResNeXt-GeM-GCL}. Our results are higher than those of all the other methods on the MSLS dataset, including NetVLAD (with different configurations)~\cite{Arandjelovic2017}, NetVLAD-SARE~\cite{liu2019stochastic}, AP-GeM~\cite{revaud2019learning} and Patch-NetVLAD~\cite{hausler2021patch}. We used the models and code from the original papers, as also done in~\cite{benchmarking_ir3DV2020,hausler2021patch}}. It is worth pointing out that our learned representations have a size of 2048 \revised{for the ResNet50, ResNet152 and ResNeXt models, and 512 for the VGG16}, while the NetVLAD vectors consist of 32768 features \revised{when using 64 clusters or 8192 when using 16 clusters} \revised{before dimensionality reduction. When PCA whitening is applied, the NetVLAD-based representations are reduced to a size of 4096, while ours remain 512 for VGG16, 1024 for ResNet50 and ResNeXt, and 2048 for ResNet152}. \revised{\textbf{Generalization to Pittsburgh\revised{30K}, Tokyo 24/7, \revised{RobotCar-Seasons v2 and ExtendedCMU Seasons.}} In Table~\ref{tab:msls-ablation} and Table~\ref{tab:msls-sota}, we also report the results that our models achieved on the Pittsburgh30K, Tokyo 24/7, RobotCar Seasons v2 and Extended CMU Seasons datasets.} \revised{We compare our results with those achieved by different configurations of NetVLAD, trained on Pittsburgh30k with 64 clusters and trained on MSLS with 16 and 64 clusters. Additionally, we compare to ResNet101-AP-GeM, NetVLAD-SARE and Patch-NetVLAD.} \revised{As shown in Table~\ref{tab:msls-sota}, }the models trained with the GCL function on the MSLS dataset generalize well to unseen datasets, in some cases better than existing methods\revised{, despite using descriptors of lower dimensionality}. \revised{In the case of Pittsburgh30k, our models achieve competitive results, up to 91.5\% top-5 recall, which is very close to the 91.8\% reported by NetVLAD-64 trained on the Pittsburgh30k dataset itself, and slightly lower than NetVLAD-SARE, which reaches a top-5 recall of 94.3\%, and Patch-NetVLAD, with a top-5 recall of 94.5\% } \revised{In the case of Tokyo24/7 we record a lower performance, which we attribute to the drastic variations in illumination included in the dataset, with images taken at day and at night. Such conditions are underrepresented in the MSLS training set: only 4k query images are taken at night, out of 500k query images that compose the dataset. However, we observe that applying a whitening transform greatly enhances the generalization capabilities of our models, and it boosts the performance for all datasets. On Tokyo 24/7, we achieved an improvement of 28.2\% on the top-5 recall for the ResNet152-GeM-GCL model, up to 81\%, which outperforms NetVLAD and AP-GeM. NetVLAD-SARE and Patch-NetVLAD generalize better to this dataset, with top-5 recall of 86.7\% and 88.6\% respectively. Our models also generalize well to urban localization datasets like RobotCar Seasons V2 and Extended CMU Seasons, achieving up to 21.9\% and 19\% of correctly localized queries within 0.5m and 5$\degree$, respectively. For both datasets, the results are comparable to those obtained by NetVLAD trained on MSLS, but are outperformed by NetVLAD trained on Pittsburgh, AP-GeM, NetVLAD-SARE and Patch-NetVLAD. } \revised{Note that we do not perform 6DOF pose estimation, but estimate the pose of a query image by inheriting that of the best retrieved match. We thus do not aim at comparing with methods that perform refined pose estimation.} \subsection{Small scale outdoor place recognition} We trained our method on the TB-Places dataset and show the results that we achieved in Fig.~\ref{fig:tb_places_recall}. We considered three different backbones, namely ResNet18, ResNet34, and DenseNet161, which learn representations of size 512, 512 and 2208, respectively. We trained them with the binary Contrastive Loss function and with our Generalized Contrastive Loss function. Furthermore, we compare them with the NetVLAD off-the-shelf model. For these experiments we use only a Global Average Pooling, so this information is omitted from the names of the models. We report results of two experiments. For the first one, we used the training set (W17) as map, and the W18 set as query. With this experiment we tested the strength of our learned representations against significant variations between the query and the map set. We show the results that we obtained in Fig.~\ref{fig:w17_w18_recall}. For the second experiment, we divided the W18 set into map and query, to test the generalization capabilities when both map and query sets are unknown to the place recognition model (i.e. not seen during training). The results are displayed in Fig.~\ref{fig:w18_map_query_recall}. For both experiments the models trained with our GCL function and the proposed similarity ground truth consistently achieve better recall than the ones trained with the binary Contrastive Loss, with the exception of the ResNet18 model. In some cases the models trained with the binary ground truth do not outperform the NetVLAD model, even though this one is not trained on the TB-Places dataset. \begin{figure}[t!] \subfloat{ \begin{minipage}[t]{\columnwidth} \hspace{1.1cm} \begin{tikzpicture}[thick, scale=1, every node/.style={scale=.8}] \begin{axis}[% hide axis, xmin=10, xmax=50, ymin=0, ymax=0.4, height=6cm, width=\columnwidth, legend style={draw=white!15!black,legend columns=2,legend style={minimum width=.41\columnwidth}}, legend cell align={left} ] \addlegendimage{blue, thick, mark size=2pt, mark=square}; \addlegendentry{ResNet18-CL}; \addlegendimage{red, thick, mark size=2pt, mark=square}; \addlegendentry{ResNet18-GCL (ours)}; \addlegendimage{blue, thick, mark size=2pt, mark=o}; \addlegendentry{ResNet34-CL}; \addlegendimage{red, thick, mark size=2pt, mark=o}; \addlegendentry{ResNet34-GCL (ours)}; \addlegendimage{blue, thick, mark size=2pt, mark=diamond}; \addlegendentry{DenseNet161-CL}; \addlegendimage{red, thick, mark size=2pt, mark=diamond}; \addlegendentry{DenseNet161-GCL (ours)}; \addlegendimage{black, thick, mark size=2pt, mark=triangle}; \addlegendentry{NetVLAD off-the-shelf}; \end{axis} \end{tikzpicture} \end{minipage} } \vspace{-5pt} \centering \setcounter{subfigure}{0} \subfloat[Map: W17, Query: W18]{ \begin{tikzpicture}[thick, scale=1, every node/.style={scale=.8}] \begin{axis} [xlabel=K, ylabel=Recall@K (\%), ylabel style={at={(axis description cs:-0.08,0.5)}},grid, height=6cm, width=\columnwidth] \addplot[black, thick, mark size=2pt, mark=triangle] table [x=k, y=r, col sep=comma] {plot_data/TB_Places/TB_Places_W18_W17_NetVLAD_recalls.csv}; \addplot[red, thick, mark size=2pt, mark=square] table [x=k, y=r, col sep=comma] {plot_data/TB_Places/TB_Places_ResNet18_avg_2last_soft_siamese_w18_w17_recall_toplot.txt}; \addplot[blue, thick, mark size=2pt, mark=square] table [x=k, y=r, col sep=comma] {plot_data/TB_Places/TB_Places_ResNet18_avg_2last_binary_siamese_w18_w17_recall_toplot.txt}; \addplot[red, thick, mark size=2pt, mark=o] table [x=k, y=r, col sep=comma] {plot_data/TB_Places/TB_Places_ResNet34_avg_2last_soft_siamese_w18_w17_recall_toplot.txt}; \addplot[blue, thick, mark size=2pt, mark=o] table [x=k, y=r, col sep=comma] {plot_data/TB_Places/TB_Places_ResNet34_avg_2last_binary_siamese_w18_w17_recall_toplot.txt}; \addplot[blue, thick, mark size=2pt, mark=diamond] table [x=k, y=r, col sep=comma] {plot_data/TB_Places/TB_Places_W18_W17_CAIP_recalls.csv}; \addplot[red, thick, mark size=2pt, mark=diamond] table [x=k, y=r, col sep=comma] {plot_data/TB_Places/TB_Places_W18_W17_Soft_recalls.csv}; \end{axis} \end{tikzpicture} \label{fig:w17_w18_recall} } \\ \subfloat[Map: W18, Query: W18]{ \begin{tikzpicture}[thick, scale=1, every node/.style={scale=.8}] \begin{axis} [xlabel=K, ylabel=Recall@K (\%), ylabel style={at={(axis description cs:-0.08,0.5)}}, legend pos =south east,grid, height=6cm, width=\columnwidth] \addplot[black, thick, mark size=2pt, mark=triangle] table [x=k, y=r, col sep=comma] {plot_data/TB_Places/TB_Places_map_query_NetVLAD_recalls.csv}; \addplot[red, thick, mark size=2pt, mark=square] table [x=k, y=r, col sep=comma] {plot_data/TB_Places/TB_Places_ResNet18_avg_2last_soft_siamese_w18_map_query_recall_toplot.txt}; \addplot[blue, thick, mark size=2pt, mark=square] table [x=k, y=r, col sep=comma] {plot_data/TB_Places/TB_Places_ResNet18_avg_2last_binary_siamese_w18_map_query_recall_toplot.txt}; \addplot[red, thick, mark size=2pt, mark=o] table [x=k, y=r, col sep=comma] {plot_data/TB_Places/TB_Places_ResNet34_avg_2last_soft_siamese_w18_map_query_recall_toplot.txt}; \addplot[blue, thick, mark size=2pt, mark=o] table [x=k, y=r, col sep=comma] {plot_data/TB_Places/TB_Places_ResNet34_avg_2last_binary_siamese_w18_map_query_recall_toplot.txt}; \addplot[blue, thick, mark size=2pt, mark=diamond] table [x=k, y=r, col sep=comma] {plot_data/TB_Places/TB_Places_map_query_CAIP_recalls.csv}; \addplot[red, thick, mark size=2pt, mark=diamond] table [x=k, y=r, col sep=comma] {plot_data/TB_Places/TB_Places_map_query_Soft_recalls.csv}; \end{axis} \end{tikzpicture} \label{fig:w18_map_query_recall} }\\ \caption{Comparison of the results for the TB-Places dataset. In (a) we report the results when using W17 as map and W18 as query set. In (b), we show the top-k recall achieved when dividing W18 into map and query. The results achieved by our method are shown in red, the results of the models trained with the binary Contrastive Loss are in blue, and the results of NetVLAD are displayed in black.} \label{fig:tb_places_recall} \end{figure} \subsection{Indoor place recognition} \label{sec:results7scenes} \begin{figure*}[ht!] \centering \hspace{-5pt} \subfloat[heads]{ \begin{tikzpicture}[thick, scale=1, every node/.style={scale=.8}] \begin{axis} [xlabel=K, ylabel=Recall@K (\%), ylabel style={at={(axis description cs:-0.08,0.5)}},grid, height=4.75cm, width=.61\columnwidth,xtick distance=5, ytick distance=5] \addplot[black, thick, mark size=2pt, mark=triangle] table [x=k, y=r, col sep=comma] {plot_data/7Scenes/PR_7scenes_recallatk_50FOV_heads_NetVLAD_recalls.csv}; \addplot[blue, thick, mark size=2pt, mark=o] table [x=k, y=r, col sep=comma] {plot_data/7Scenes/PR_7scenes_recallatk_50FOV_heads_ResNet18_crisp_recalls.csv}; \addplot[red, thick, mark size=2pt, mark=o] table [x=k, y=r, col sep=comma] {plot_data/7Scenes/PR_7scenes_recallatk_50FOV_heads_ResNet18_soft_recalls.csv}; \addplot[blue, thick, mark size=2pt, mark=square] table [x=k, y=r, col sep=comma] {plot_data/7Scenes/PR_7scenes_recallatk_50FOV_heads_ResNet34_crisp_recalls.csv}; \addplot[red, thick, mark size=2pt, mark=square] table [x=k, y=r, col sep=comma] {plot_data/7Scenes/PR_7scenes_recallatk_50FOV_heads_ResNet34_soft_recalls.csv}; \end{axis} \end{tikzpicture} \label{fig:7Scenes_heads_recall} } \hspace{-7pt}~\subfloat[stairs]{ \begin{tikzpicture}[thick, scale=1, every node/.style={scale=.8}] \begin{axis} [xlabel=K,grid, height=4.75cm, width=.61\columnwidth,xtick distance=5, ytick distance=5] \addplot[black, thick, mark size=2pt, mark=triangle] table [x=k, y=r, col sep=comma] {plot_data/7Scenes/PR_7scenes_recallatk_50FOV_stairs_NetVLAD_recalls.csv}; \addplot[blue, thick, mark size=2pt, mark=o] table [x=k, y=r, col sep=comma] {plot_data/7Scenes/PR_7scenes_recallatk_50FOV_stairs_ResNet18_crisp_recalls.csv}; \addplot[red, thick, mark size=2pt, mark=o] table [x=k, y=r, col sep=comma] {plot_data/7Scenes/PR_7scenes_recallatk_50FOV_stairs_ResNet18_soft_recalls.csv}; \addplot[blue, thick, mark size=2pt, mark=square] table [x=k, y=r, col sep=comma] {plot_data/7Scenes/PR_7scenes_recallatk_50FOV_stairs_ResNet34_crisp_recalls.csv}; \addplot[red, thick, mark size=2pt, mark=square] table [x=k, y=r, col sep=comma] {plot_data/7Scenes/PR_7scenes_recallatk_50FOV_stairs_ResNet34_soft_recalls.csv}; \end{axis} \end{tikzpicture} \label{fig:7Scenes_stairs_recall} } \hspace{-7pt}~\subfloat[pumpkin]{ \begin{tikzpicture}[thick, scale=1, every node/.style={scale=.8}] \begin{axis} [xlabel=K, grid, height=4.75cm, width=.61\columnwidth,xtick distance=5, ytick distance=5] \addplot[black, thick, mark size=2pt, mark=triangle] table [x=k, y=r, col sep=comma] {plot_data/7Scenes/PR_7scenes_recallatk_50FOV_pumpkin_NetVLAD_recalls.csv}; \addplot[blue, thick, mark size=2pt, mark=o] table [x=k, y=r, col sep=comma] {plot_data/7Scenes/PR_7scenes_recallatk_50FOV_pumpkin_ResNet18_crisp_recalls.csv}; \addplot[red, thick, mark size=2pt, mark=o] table [x=k, y=r, col sep=comma] {plot_data/7Scenes/PR_7scenes_recallatk_50FOV_pumpkin_ResNet18_soft_recalls.csv}; \addplot[blue, thick, mark size=2pt, mark=square] table [x=k, y=r, col sep=comma] {plot_data/7Scenes/PR_7scenes_recallatk_50FOV_pumpkin_ResNet34_crisp_recalls.csv}; \addplot[red, thick, mark size=2pt, mark=square] table [x=k, y=r, col sep=comma] {plot_data/7Scenes/PR_7scenes_recallatk_50FOV_pumpkin_ResNet34_soft_recalls.csv}; \end{axis} \end{tikzpicture} \label{fig:7Scenes_pumpkin_recall} } ~\subfloat{ \begin{minipage}[c][2cm]{.47\columnwidth} \vspace{-120pt} \begin{tikzpicture}[thick, scale=1, every node/.style={scale=.8}] \begin{axis}[% hide axis, xmin=10, xmax=70, ymin=0, ymax=0.4, legend pos =north west, legend style={draw=white!20!black,legend cell align=left}, height=4.75cm, width=.61\columnwidth ] \addlegendimage{black, thick, mark size=2pt, mark=triangle} \addlegendentry{NetVLAD off-the-shelf}; \addlegendimage{blue, thick, mark size=2pt, mark=o} \addlegendentry{ResNet18-CL}; \addlegendimage{red, thick, mark size=2pt, mark=o} \addlegendentry{ResNet18-GCL (ours)}; \addlegendimage{blue, thick, mark size=2pt, mark=square} \addlegendentry{ResNet34-CL}; \addlegendimage{red, thick, mark size=2pt, mark=square} \addlegendentry{ResNet34-GCL (ours)}; \end{axis} \end{tikzpicture} \end{minipage} } \setcounter{subfigure}{3} \vspace{-5mm} \subfloat[fire]{ \begin{tikzpicture}[thick, scale=1, every node/.style={scale=.8}] \begin{axis} [xlabel=K, ylabel=Recall@K (\%), ylabel style={at={(axis description cs:-0.08,0.5)}},grid, height=4.75cm, width=.61\columnwidth,xtick distance=5, ytick distance=5] \addplot[black, thick, mark size=2pt, mark=triangle] table [x=k, y=r, col sep=comma] {plot_data/7Scenes/PR_7scenes_recallatk_50FOV_fire_NetVLAD_recalls.csv}; \addplot[blue, thick, mark size=2pt, mark=o] table [x=k, y=r, col sep=comma] {plot_data/7Scenes/PR_7scenes_recallatk_50FOV_fire_ResNet18_crisp_recalls.csv}; \addplot[red, thick, mark size=2pt, mark=o] table [x=k, y=r, col sep=comma] {plot_data/7Scenes/PR_7scenes_recallatk_50FOV_fire_ResNet18_soft_recalls.csv}; \addplot[blue, thick, mark size=2pt, mark=square] table [x=k, y=r, col sep=comma] {plot_data/7Scenes/PR_7scenes_recallatk_50FOV_fire_ResNet34_crisp_recalls.csv}; \addplot[red, thick, mark size=2pt, mark=square] table [x=k, y=r, col sep=comma] {plot_data/7Scenes/PR_7scenes_recallatk_50FOV_fire_ResNet34_soft_recalls.csv}; \end{axis} \end{tikzpicture} \label{fig:7Scenes_fire_recall} } \hspace{-7pt}~\subfloat[redkitchen]{ \begin{tikzpicture}[thick, scale=1, every node/.style={scale=.8}] \begin{axis} [xlabel=K,grid, height=4.75cm, width=.61\columnwidth,xtick distance=5, ytick distance=5] \addplot[black, thick, mark size=2pt, mark=triangle] table [x=k, y=r, col sep=comma] {plot_data/7Scenes/PR_7scenes_recallatk_50FOV_redkitchen_NetVLAD_recalls.csv}; \addplot[blue, thick, mark size=2pt, mark=o] table [x=k, y=r, col sep=comma] {plot_data/7Scenes/PR_7scenes_recallatk_50FOV_redkitchen_ResNet18_crisp_recalls.csv}; \addplot[red, thick, mark size=2pt, mark=o] table [x=k, y=r, col sep=comma] {plot_data/7Scenes/PR_7scenes_recallatk_50FOV_redkitchen_ResNet18_soft_recalls.csv}; \addplot[blue, thick, mark size=2pt, mark=square] table [x=k, y=r, col sep=comma] {plot_data/7Scenes/PR_7scenes_recallatk_50FOV_redkitchen_ResNet34_crisp_recalls.csv}; \addplot[red, thick, mark size=2pt, mark=square] table [x=k, y=r, col sep=comma] {plot_data/7Scenes/PR_7scenes_recallatk_50FOV_redkitchen_ResNet34_soft_recalls.csv}; \end{axis} \end{tikzpicture} \label{fig:7Scenes_redkitchen_recall} } \hspace{-7pt}~\subfloat[chess]{ \begin{tikzpicture}[thick, scale=1, every node/.style={scale=.8}] \begin{axis} [xlabel=K,grid, height=4.75cm, width=.61\columnwidth,xtick distance=5, ytick distance=2] \addplot[black, thick, mark size=2pt, mark=triangle] table [x=k, y=r, col sep=comma] {plot_data/7Scenes/PR_7scenes_recallatk_50FOV_chess_NetVLAD_recalls.csv}; \addplot[blue, thick, mark size=2pt, mark=o] table [x=k, y=r, col sep=comma] {plot_data/7Scenes/PR_7scenes_recallatk_50FOV_chess_ResNet18_crisp_recalls.csv}; \addplot[red, thick, mark size=2pt, mark=o] table [x=k, y=r, col sep=comma] {plot_data/7Scenes/PR_7scenes_recallatk_50FOV_chess_ResNet18_soft_recalls.csv}; \addplot[blue, thick, mark size=2pt, mark=square] table [x=k, y=r, col sep=comma] {plot_data/7Scenes/PR_7scenes_recallatk_50FOV_chess_ResNet34_crisp_recalls.csv}; \addplot[red, thick, mark size=2pt, mark=square] table [x=k, y=r, col sep=comma] {plot_data/7Scenes/PR_7scenes_recallatk_50FOV_chess_ResNet34_soft_recalls.csv}; \end{axis} \end{tikzpicture} \label{fig:7Scenes_chess_recall} } \hspace{-7pt}~\subfloat[office]{ \begin{tikzpicture}[thick, scale=1, every node/.style={scale=.8}] \begin{axis} [xlabel=K,grid, height=4.75cm, width=.61\columnwidth,xtick distance=5, ytick distance=5] \addplot[black, thick, mark size=2pt, mark=triangle] table [x=k, y=r, col sep=comma] {plot_data/7Scenes/PR_7scenes_recallatk_50FOV_office_NetVLAD_recalls.csv}; \addplot[blue, thick, mark size=2pt, mark=o] table [x=k, y=r, col sep=comma] {plot_data/7Scenes/PR_7scenes_recallatk_50FOV_office_ResNet18_crisp_recalls.csv}; \addplot[red, thick, mark size=2pt, mark=o] table [x=k, y=r, col sep=comma] {plot_data/7Scenes/PR_7scenes_recallatk_50FOV_office_ResNet18_soft_recalls.csv}; \addplot[blue, thick, mark size=2pt, mark=square] table [x=k, y=r, col sep=comma] {plot_data/7Scenes/PR_7scenes_recallatk_50FOV_office_ResNet34_crisp_recalls.csv}; \addplot[red, thick, mark size=2pt, mark=square] table [x=k, y=r, col sep=comma] {plot_data/7Scenes/PR_7scenes_recallatk_50FOV_office_ResNet34_soft_recalls.csv}; \end{axis} \end{tikzpicture} \label{fig:7Scenes_office_recall} } \caption{Recall@K results achieved on the 7 Scenes dataset. The results of the models trained with our Generalized Contrastive Loss are shown in red, while those of the models trained with the binary Contrastive Loss are shown in blue. The Recall@K achieved by NetVLAD off-the-shelf is plotted in black.} \label{fig:recallat_k_7scenes} \end{figure*} We report the results that we achieved on the seven sets of the 7scenes dataset in Fig.~\ref{fig:recallat_k_7scenes}. We used the ResNet18 and ResNet34 architectures as backbones with a Global Average Pooling layer and we compare them to NetVLAD off-the-shelf. Since we only use one type of pooling for this experiments this information is omitted from the model names. We achieved generally higher Recall@K results for the models trained using the GCL function, for all scenes. The cases of the \emph{stairs} (Fig.~\ref{fig:7Scenes_stairs_recall}), \emph{chess} (Fig.~\ref{fig:7Scenes_chess_recall}) and \emph{office} (Fig.~\ref{fig:7Scenes_office_recall}) scenes are particularly interesting, since with the GCL descriptors we are able to retrieve positive matches for nearly all the query images, with a top-5 recall for \mbox{ResNet34-GCL} of 98.1\%, 98.2\% and 99.7\%, respectively. Furthermore, we report the average precision results in Table~\ref{tab:ap-7scenes}. This measure is an approximation of the area under the precision-recall curve and measures the number of pairs that can be correctly discriminated into positive and negative on the whole dataset. The models trained with the GCL function achieved higher AP than their corresponding models trained with the binary CL function. We achieved an average AP equal to 0.89 using the ResNet34-GCL model. \revised{Following the general expectation that improved retrieval results would contribute to a better localization, we performed a small-scale localization experiment to compare the contribution of the GCL and CL training to the localization performance of an InLoc pipeline~\cite{taira2018inloc}. We report the results in the supplementary materials.} \subsection{Discussion} \label{sec:discussion} \begin{table}[t!] \centering \caption{Average Precision results obtained by the networks trained with the proposed Generalized Contrastive loss function on the 7Scenes dataset, compared with those achieved by the same network architectures trained using the binary Contrastive loss function and by the NetVLAD off-the-shelf model. } \label{tab:ap-7scenes} \renewcommand{\arraystretch}{1.0} \begin{tabular}{@{\extracolsep{4pt}}lccccc@{}} \toprule \textbf{} & \textbf{NetVLAD} & \multicolumn{2}{c}{\textbf{ResNet18}} & \multicolumn{2}{c}{\textbf{ResNet34}} \\ \cmidrule{2-2} \cmidrule{3-4} \cmidrule{5-6} \textbf{Scene} & \textbf{off-the-shelf} & \textbf{CL} & \textbf{GCL} & \textbf{CL} & \textbf{GCL} \\ \midrule Heads & 0.587 & 0.739 & 0.807 & 0.759 & \textbf{0.853} \\ Stairs & 0.533 & 0.855 & 0.883 & 0.884 & \textbf{0.944} \\ Pumpkin & 0.491 & 0.768 & 0.849 & 0.782 & \textbf{0.914} \\ Fire & 0.539 & 0.786 & \textbf{0.811} & 0.796 & 0.803 \\ Redkitchen & 0.439 & 0.790 & 0.876 & 0.782 & \textbf{0.902} \\ Chess & 0.645 & 0.943 & 0.964 & 0.945 & \textbf{0.974} \\ Office & 0.399 & 0.794 & 0.890 & 0.802 & \textbf{0.896} \\ \midrule \textit{Mean } & 0.519 & 0.811 & 0.868 & 0.821 & \textbf{0.898} \\ \bottomrule \end{tabular} \end{table} State-of-the-art visual place recognition pipelines rely on difficult pair and triplet mining strategies for training~\cite{Arandjelovic2017,msls}. Their goal is to compose batches of training images that substantially contribute to the learning process, evaluating their potential impact on the loss function, at the cost of GPU memory and computing time. As we discussed in Section~\ref{sec:training_pairs}, we opted for a na\"{i}ve mining strategy, based only on the annotated graded similarity of image pairs and not on their embedded representations. \revised{ \textbf{Pair selection in na\"ive mining.} The composition of the training batches, in terms of distribution of image pairs with different ground truth graded similarity, resulting from the na\"ive mining strategy plays an important role in the effective convergence of the training process. In order to test the influence that different pair sampling strategies have on the effectiveness of the training process and accuracy of retrieval results, we carried out several experiments (using the four considered backbones), for which we report results in Table~\ref{tab:batch}. We thus defined four strategies of na\"ive mining for the composition of training batches, which we refer to as strategy A, B, C and D. For strategy A, we compose a training batch including 50\% of positive pairs ($\psi \in [0.5, 1]$), 25\% of soft negative pairs ($\psi \in (0, 0.5)$) and 25\% of hard negative pairs ($\psi=0$). For strategy B, we select 25\% hard positive pairs ($\psi \in [0.75, 1]$), 25\% soft positive pairs ($\psi \in [0.5, 0.75)$), 25\% of soft negative pairs ($\psi \in (0, 0.5)$) and 25\% of hard negative pairs ($\psi=0$). For strategy C, we prepare the batches by selecting 33.3\% positive pairs ($\psi \in [0.5, 1]$), 33.3\% of soft negative pairs ($\psi \in (0, 0.5)$) and 33.3\% of hard negative pairs ($\psi=0$). Finally, for strategy D we randomly sample 50\% positive pairs ($\psi \in [0.5, 1]$) and 50\% negative pairs ($\psi \in [0, 0.5)$). In Fig.~\ref{fig:batch_composition}, we show histograms of the pair similarity distribution of the composition of training batches resulting from the four considered na\"ive mining strategies. The results in Table~\ref{tab:batch} clearly indicate that the most important factor to consider when composing the training batches is to select an adequate number of soft negative pairs, i.e. at least 25\% of the pairs included in a batch have similarity $\psi \in (0, 0.5)$, as done for strategy A, B and C. For strategy D, we can observe an improvement with respect to the binary similarity case (i.e. with only pairs with similarity $\psi=1$ and $\psi=0$, respectively), due to the use of soft positive samples. However, the use of soft- and hard positive pairs (i.e. pairs with similarity $\psi \in (0.5, 1]$) together with hard negatives only in strategy D does not guarantee optimal performance. Due to the very large amount of hard positive pairs in the dataset, sampling randomly among negatives does ensure the presence of soft negative pairs in the training batches and results in a non-uniform distribution of pair similarity (see Fig.~\ref{fig:batch_composition}d). The generalized contrastive optimization that we proposed, instead, largely benefits from a fairly uniform distribution of soft positive and soft negative pairs in the composition of the training batches.} \begin{table}[t!] \centering \revised{\caption{Recall@5 in the MSLS validation and test sets for GCL models when using different batch composition strategies. Strategy A is 50\% $\psi \in [0.5, 1]$, 25\% $\psi \in (0, 0.5)$ and 25\% $\psi=0$. B is 25\% $\psi \in [0.75, 1]$, 25\% $\psi \in [0.5, 0.75)$, 25\% $\psi \in (0, 0.5)$ and 25\% $\psi=0$. For C, we have 33.3\% $\psi \in [0.5, 1]$, 33.3\% $\psi \in (0, 0.5)$ and 33.3\% $\psi=0$. Finally, for strategy D we have 50\% $\psi \in [0.5, 1]$ and 50\% $\psi \in [0, 0.5)$. } \label{tab:batch} \begin{tabular}{@{}llcc@{}} \toprule Model & Strategy & Val & Test \\ \midrule \multirow{4}{*}{VGG-GeM-GCL} & A & 77.8 & \textbf{55.7} \\ & B & \textbf{78.8} & 54.9 \\ & C & 78.2 & 56 \\ & D & 73.4 & 49.3 \\ \midrule \multirow{4}{*}{ResNet50-GeM-GCL} & A & \textbf{78.9} & \textbf{59.1} \\ & B & 76.5 & 54.5 \\ & C & 75.7 & 52.4 \\ & D & 75.4 & 54.7\\\midrule \multirow{4}{*}{ResNet152-GeM-GCL} & A & \textbf{82} & \textbf{62.3} \\ & B & 80.4 & 59.7 \\ & C & 78.6 & 58.4 \\ & D & 78.5 & 64.8\\ \midrule \multirow{4}{*}{Resnext-GeM-GCL} & A & 86.1 & 70.8 \\ & B & 86.2 & 70.7 \\ & C & \textbf{87.3} & \textbf{72.4} \\ & D & 81.9 & 64.8\\ \bottomrule \end{tabular}% } \end{table} \begin{figure}[t!] \centering \subfloat[Composition A]{\includegraphics[width=.5\columnwidth]{figures/7_discussion/pairs_50_25_25.pdf}\label{fig:pairs_50_25_25}} \subfloat[Composition B]{\includegraphics[width=.5\columnwidth]{figures/7_discussion/pairs_25_25_25_25.pdf}\label{fig:pairs_25_25_25_25}}\\ \subfloat[Composition C]{\includegraphics[width=.5\columnwidth]{figures/7_discussion/pairs_33_33_33.pdf}\label{fig:pairs_33_33_33}} \subfloat[Composition D]{\includegraphics[width=.5\columnwidth]{figures/7_discussion/pairs_50_50.pdf}\label{fig:pairs_50_50}} \caption{Similarity ground truth distribution for 10000 randomly selected pairs in the MSLS train set when using different batch composition strategies. The vertical axis is in log scale.} \label{fig:batch_composition} \end{figure} We have demonstrated that a na\"{i}ve mining strategy can be as effective as or better than a more complex one, provided that the ground truth is informative enough. The results that we achieved are attributable to the use of the proposed GCL function, which allows a graded similarity ground truth to be considered. Furthermore, since our na\"{i}ve strategy is much less resource demanding, it is possible to use it while training big CNN backbones in their entirety, and with batch size up to 512. \begin{table}[t] \centering \caption{Results achieved on the MSLS validation set by our models trained by backpropagating the gradient only partially through the network. The \emph{last trained layer} column indicates the block of the backbone until which the gradient is backpropagated.} \label{tab:partialtraining} \begin{tabular}{@{}lcccccc@{}} \toprule & \multicolumn{3}{c}{\textbf{ResNet50-GeM}} & \multicolumn{3}{c}{\textbf{ResNet152-GeM}} \\ \textbf{Last trained layer} & \textbf{R@1} & \textbf{R@5} & \textbf{R@10} & \textbf{R@1} & \textbf{R@5} & \textbf{R@10} \\\midrule Off-the-shelf & 27.2 & 41.9 & 47.4 & 26.5 & 39.9 & 44.5 \\ Layer4 & 50.1 & 64.6 & 70 & 40.9& 56.4& 63.8 \\ Layer3 & \textbf{66.2} & \textbf{78.9} & \textbf{81.9} & \textbf{70.3} & \textbf{82} & \textbf{84.9} \\ Layer2 & 60.3 & 74.2 & 77.4 & 65.4& 77.4& 80 \\ Full & 65 & 75.8 & 81.1 & 66.6 & 79.2 & 81.8 \\ \bottomrule \end{tabular} \end{table} \revised{\textbf{Partial training. }}We studied the effects that training different layers of the \revised{ResNet50 and ResNet152} backbones with the GCL function has on the performance of our models. We report the results that we achieved on the MSLS validation set in Table~\ref{tab:partialtraining}. The models pre-trained on the ImageNet dataset~\cite{deng2009imagenet} achieved reasonable results. However, we obtained the highest results when the networks were further trained on the MSLS training set until Layer 3 (i.e. updating the weights of the two last convolutional blocks). Training more layers leads to overfitting. \revised{\textbf{Whitening and dimensionality reduction.} }The learned representations are of a relatively small size (2048 for ResNet50, ResNet152~\revised{and ResNeXt, 512 for VGG16}) compared to NetVLAD (size of 32768). The dimensionality of the latent space representation influences the performance of image retrieval and place recognition systems. Techniques for dimensionality reduction have been explored~\cite{Arandjelovic2017, radenovic2018fine}, usually combined with whitening, which has been demonstrated to have positive effects on image retrieval, especially in the case of CNN-learned representations~\cite{babenko2015aggregating, sharif2014cnn}. It can be learned end-to-end or used as a postprocessing step. We evaluated the effect of whitening and dimensionality reduction on our learned descriptors by using PCA as postprocessing. We compute the PCA components on the descriptors of the map images and use them to project both map and query image descriptors. We perform experiments with PCA whitening with different number of dimensions, from 32 to 2048. We applied this strategy to the \revised{VGG16-GeM-GCL, }ResNet50-GeM-GCL, ResNet152-GeM-GCL \revised{ and ResNeXt-GeM-GCL} models (trained on MSLS) and \revised{tested} them on the \revised{validation and test sets of MSLS and the test sets of Pittsburgh30k and Tokyo 24/7}. We observe that PCA whitening further improves the performance of the image representations learned by our models and boosts their generalization capabilities. As shown in Fig.~\ref{fig:whitening}, the whitened descriptors with higher dimensionality achieve \revised{better} results on the considered datasets\revised{. It is worth noting that the ResNeXt-GeM-GCL maintains the same performance when reduced down to 256 dimensions, and that VGG16-GeM-GCL reaches peak top-5 recall when reduced to 256 features}. When using the whitening transform combined with PCA dimensionality reduction down to 128 dimensions of the latent space, our models achieved results comparable to those of \revised{models with full-size dimensions (2048 for ResNet and ResNeXt, and 512 for VGG)}, which outperform their non-whithened counterpart on all the considered datasets. We observed up to a 28.2\% of improvement in the case of Tokyo 24/7 and 12.8\% on the MSLS validation set. \revised{ \textbf{Training time.} The proposed GCL function and the partial similarity labels contribute to training effective models in a much more efficient way than NetVLAD-based ones, as shown in Table~\ref{tab:training-time}. The training time per epoch of our models is less than that of NetVLAD, as we do not perform hard-pair mining. Furthermore, we train our GCL models for only one epoch on the MSLS dataset, while NetVLAD-16 and NetVLAD-64 converged after 22 and 7 epochs, respectively. } \section{Gradient computations} Let us consider two input images $x_i$ and $x_j$, their latent representations $\hat{f}(x_i)$ and $\hat{f}(x_j)$, and define $ d(x_i, x_j)$ the Euclidean distance between the representations, such as: \begin{equation} \nonumber d(x_i, x_j) = \left \| \hat{f}(x_i)-\hat{f}(x_j) \right \|_2 \end{equation} For simplicity of notation, hereinafter we refer to $d(x_i, x_j)$ as $d$. \subsection{Contrastive loss} \noindent The Contrastive Loss function is defined as: \begin{equation} \nonumber \mathcal{L}_{CL}=\begin{cases} \frac{1}{2} d ^2 ,& \text{if } y= 1\\ \frac{1}{2}\max(\tau- d ,0)^2,& \text{if } y=0 \end{cases} \end{equation} \noindent where $y$ corresponds to the binary ground truth label and $\tau$ corresponds to the margin. \noindent In order to compute the gradient for this function, we consider three cases, depending on the ground truth label $y$ and the value of the distance $d$. \noindent \textbf{Case 1) $y=1$} \noindent The loss function becomes: \begin{equation} \nonumber \mathcal{L}_{CL}=\frac{1}{2} d ^2 \end{equation} \noindent and its derivative with respect to $d$ is: \begin{align} \nonumber \begin{split} \nabla \mathcal{L}_{CL} = \frac{\partial}{\partial d} \left( \mathcal{L}_{CL} \right) =\frac{\partial}{\partial d} \left( \frac{1}{2} d^2 \right)= d \end{split} \end{align} \noindent \textbf{Case 2) $y=0, d < \tau$} \noindent The loss function becomes: \begin{equation} \nonumber \mathcal{L}_{CL}=\frac{1}{2}(\tau- d)^2 \end{equation} \noindent and its derivative with respect to $d$ is: \begin{align*} \nonumber \begin{split} \nabla {} \mathcal{L}_{CL}=& \frac{\partial}{\partial d} \left( \mathcal{L}_{CL} \right) =\frac{\partial}{\partial d} \left[ \frac{1}{2}(\tau- d)^2 \right]=\\ &=(\tau-d)(-1)= d-\tau \end{split} \end{align*} \noindent \textbf{Case 3) $y=0, d \geq \tau$} \begin{equation} \nonumber \mathcal{L}_{CL} = 0 \end{equation} and the gradient $\mathcal{L}_{CL} = 0$ as well. Thus, case 2 and case 3, for $y=0$, can be grouped as: \begin{equation} \nonumber \nabla \mathcal{L}_{CL}=\begin{cases} d-\tau ,& \text{if } d < \tau\\ 0 ,& \text{if } d \geq \tau \end{cases} \end{equation} \noindent and simplified as: \begin{equation} \nonumber \nabla \mathcal{L}_{CL}=\min( d-\tau,0) \end{equation} \noindent Finally, the \textbf{gradient of the Contrastive Loss function} is: \begin{equation} \nonumber \nabla \mathcal{L}_{CL}=\begin{cases} d ,& \text{if } y= 1\\ \min( d-\tau,0) ,& \text{if } y=0 \end{cases} \end{equation} \subsection{Generalized Contrastive loss} We defined the Generalized Contrastive Loss function as: \begin{equation} \nonumber \mathcal{L}_{GCL}= \psi_{i,j}\cdot \frac{1}{2}d^2 + (1-\psi_{i,j}) \cdot \frac{1}{2}\max(\tau-d,0)^2 \end{equation} \noindent where $\psi_{i,j}$ is the ground truth degree of similarity between the input images $x_i$ and $x_j$, and its values are in the interval $[0,1]$. To compute the gradient of the GCL function we consider two cases, namely when 1) the distance $d$ between the representations is lower than the margin $\tau$ and 2) the alternative case when $d$ is larger than $\tau$. \noindent \textbf{Case 1) $d < \tau$} \noindent The Generalized Contrastive loss function becomes: \begin{equation} \nonumber \mathcal{L}_{GCL}= \psi_{i,j}\cdot \frac{1}{2}d^2 + (1-\psi_{i,j}) \cdot \frac{1}{2}(\tau-d)^2 \end{equation} \noindent and its derivative with respect to $d$ is: \begin{align*} \nonumber \nabla \mathcal{L}_{GCL}= \\ & = \frac{\partial}{\partial d} \mathcal{L}_{GCL}=\\ & = \frac{\partial}{\partial d} \left[ \psi_{i,j} \cdot \frac{1}{2} d^2 + (1 - \psi_{i,j}) \cdot \frac{1}{2}(\tau - d)^2 \right]= \\&=\psi_{i,j} \cdot d + (1-\psi_{i,j}) (\tau-d)(-1)= \\&=\psi_{i,j} \cdot d + d - \tau- \psi_{i,j} \cdot d + \psi_{i,j} \cdot \tau = \\&=d+\tau(\psi_{i,j} -1) \end{align*} \noindent \textbf{Case 2) $d \geq \tau$} \noindent The Generalized Contrastive loss function becomes: \begin{equation} \nonumber \mathcal{L}_{GCL}= \psi_{i,j}\cdot \frac{1}{2}d^2 + (1-\psi_{i,j}) \cdot \frac{1}{2}(0)^2 = \psi_{i,j}\cdot \frac{1}{2}d^2 \end{equation} \noindent and its derivative with respect to $d$ is: \begin{align*} \nonumber \nabla \mathcal{L}_{GCL}= \\&=\frac{\partial}{\partial d}\mathcal{L}_{GCL}= \\&=\frac{\partial}{\partial d} \left[ \psi_{i,j}\cdot \frac{1}{2} d^2 \right] \\&=d \cdot \psi_{i,j} \end{align*} \noindent Finally, the \textbf{gradient of the Generalized Contrastive Loss function} is: \begin{equation} \nabla \mathcal{L}_{GCL}=\begin{cases}d+\tau(\psi_{i,j}-1),& \text{if } d<\tau\\ d \cdot \psi_{i,j},& \text{if } d \geq \tau\\ \end{cases} \end{equation} \section{Additional results} In the following, we report extra results and observations on the performance of the proposed methods. In particular, we show how the Generalized Contrastive Loss function contributes to learn representations that better characterize the relevant parts of the input images for a robust computation of their similarity. Furthermore, we presents insights about how the GCL function contributes to a better regularization of the learned latent space. \revised{We studied the effect of a different pooling layer by training our models on the MSLS dataset using a Global Average Pooling layer and report the results that we obtained. Furthermore, we evaluate our MSLS models on the Pittsburgh250k~\cite{Torii-PAMI2015} and TokyoTM~\cite{Torii-PAMI2015} benchmarks, and provide detailed results for the Extended CMU Seasons~\cite{sattler2018benchmarking} and RobotCar Seasons V2 datasets~\cite{sattler2018benchmarking}, divided by environment and weather condition. We also provide a comparison with the work of Thoma et al~\cite{thoma2020soft} on the CMU Seasons dataset. } We study the effect that different threshold values for the ground truth similarity associated to the images have on the performance of our models. We consider two ground truth thresholds: one based on the GPS distance in meters between the locations in which images were taken, and another based on the annotated degree of similarity, $\psi$. \revised{Finally, we provide extended results on the 7Scenes dataset, including the precision recall curves and a small test to evaluate our descriptors in a visual localization pipeline.} \begin{figure}[!b] \centering \subfloat[ResNet50-GeM-CL]{ \label{fig:tsneCL} \includegraphics[width=.45\columnwidth]{figures/appendix/tsne/resnet50-GeM-CL-nowhitening-tsne-cph.jpg}}~\subfloat[ResNet50-GeM-GCL]{ \label{fig:tsneGCL} \includegraphics[width=.45\columnwidth]{figures/appendix/tsne/resnet50-GeM-GCL-nowhitening-tsne-cph.jpg}} \caption{Visualization of the learned embedded space. We selected 1000 random positive pairs and 1000 random negative pairs from the MSLS Copenhagen set, computed the differences between their representations and projected them into a 2D space using T-SNE.} \label{fig:tsne} \end{figure} \subsection{Learned latent space } In Fig.~\ref{fig:tsne}, we show the 2D projection of the vectors representing the difference of the latent space representation of 2000 image pairs (1000 positive and 1000 negative) randomly selected from the Copenhagen set of the MSLS dataset. For each pair, we compute the difference between the map and the query image latent representation. We use this as input to the t-SNE algorithm~\cite{tsne}, which projects the representations onto a 2D space. We visualize the vectors produced by two models with a ResNet50-GeM backbone, one trained using the CL function (Fig.~\ref{fig:tsneCL}) and the other using the GCL (Fig.~\ref{fig:tsneGCL}) function. The effect of the proposed GCL function is evident in the better regularized latent space, where the representation of similar image pairs (blue dots) are more consistently distributed towards the center of the space. The representations learned using the CL function, instead, form a more scattered and noisy distribution. \begin{figure*}[!t] \centering {\fontsize{8pt}{11pt} \def\textwidth{\textwidth} \input{figures/appendix/activations.pdf_tex}} \caption{CNN activations for the ResNet50-GeM and the VGG16-GeM models with CL and GCL for several input image pairs. The first two pairs, corresponding to the first four columns, are part of the MSLS test set. The third and fourth belong to the Pittsburgh30k and Tokyo 24/7 test set, respectively. We show the activations for the last layer of the backbone overlapped with the input images.} \label{fig:activations} \end{figure*} \begin{table*}[t!] \centering \caption{Ablation study on the considered datasets: all the models are trained on the MSLS train set and deploy a global average pooling layer. CL stands for Contrastive Loss and while GCL for our Generalized Contrastive Loss. For the cases in which PCA whitening is applied we report the dimensionality that achieves the best results on the MSLS validation set.} \label{tab:ablation-avg} \resizebox{\textwidth}{!}{% \setlength\tabcolsep{1.5pt} \begin{tabular} {@{}lcccccccccccccccccccc@{}} \toprule \textbf{} & \textbf{} & \textbf{} & \multicolumn{3}{c}{\textbf{MSLS-Val}} & \multicolumn{3}{c}{\textbf{MSLS-Test}} & \multicolumn{3}{c}{\textbf{Pittsburgh30k}} & \multicolumn{3}{c}{\textbf{Tokyo24/7}} & \multicolumn{3}{c}{\textbf{RobotCar Seasons V2}} & \multicolumn{3}{l}{\textbf{Extended CMU Seasons}} \\ \textbf{Method} & \textbf{PCA$_w$} & \textbf{Dim} & \textbf{R@1} & \textbf{R@5} & \textbf{R@10} & \textbf{R@1} & \textbf{R@5} & \textbf{R@10} & \textbf{R@1} & \textbf{R@5} & \textbf{R@10} & \textbf{R@1} & \textbf{R@5} & \textbf{R@10} & \textbf{0.25m/2$\degree$} & \textbf{0.5m/5$\degree$} & \textbf{5.0m/10$\degree$} & \textbf{0.25m/2$\degree$} & \textbf{0.5m/5$\degree$} & \textbf{5.0m/10$\degree$} \\ \midrule VGG-avg-CL & No & 512 & 28.8 & 47.0 & 53.9 & 16.9 & 30.5 & 36.4 & 28.9 & 53.7 & 64.8 & 10.5 & 24.1 & 35.6 & 1.0 & 6.4 & 34.4 & 0.9 & 3.0 & 22.7 \\ VGG-avg-GCL & No & 512 & 48.8 & 67.8 & 73.1 & 21.5 & 31.4 & 37.9 & 42.1 & 66.9 & 77.3 & 20.0 & 42.5 & 52.1 & 2.3 & 12.5 & 51.7 & 2.3 & 7.2 & 43.3 \\ VGG-avg-CL & Yes & 128 & 35.0 & 53.4 & 60.1 & 35.2 & 47.3 & 54.1 & 47.1 & 69.5 & 78.3 & 16.2 & 28.9 & 40.0 & 2.3 & 10.0 & 42.0 & 2.1 & 6.6 & 34.9 \\ VGG-avg-GCL & Yes & 256 & 54.5 & 72.6 & 78.2 & 32.9 & 49.0 & 56.5 & 56.2 & 76.7 & 83.9 & 28.6 & 45.7 & 54.9 & 3.6 & 15.3 & 57.1 & 3.7 & 11.2 & 52.5 \\ \midrule ResNet50-avg-CL & No & 2048 & 44.3 & 60.3 & 65.9 & 24.9 & 39.0 & 44.6 & 54.0 & 75.7 & 83.1 & 20.6 & 40.0 & 50.2 & 3.1 & 12.6 & 51.0 & 2.6 & 7.8 & 43.4 \\ ResNet50-avg-GCL & No & 2048 & 59.6 & 72.3 & 76.2 & 35.8 & 52.0 & 59.0 & 62.5 & 82.7 & 88.4 & 24.1 & 44.1 & 54.6 & 2.9 & 12.9 & 56.3 & 3.1 & 9.7 & 55.1 \\ ResNet50-avg-CL & Yes & 2048 & 58.8 & 71.4 & 75.8 & 33.1 & 46.5 & 53.3 & 65.8 & 82.6 & 88.2 & 48.6 & 63.2 & 70.5 & 5.9 & 22.8 & 62.7 & 4.7 & 13.8 & 50.8 \\ ResNet50-avg-GCL & Yes & 1024 & 69.5 & 81.2 & 85.5 & 44.2 & 57.8 & 63.4 & 73.3 & 87.1 & 91.2 & 52.1 & 68.9 & 72.7 & 5.9 & 23.1 & 69.6 & 5.4 & 16.2 & 66.5 \\ \midrule ResNet152-avg-CL & No & 2048 & 53.1 & 70.1 & 75.4 & 29.7 & 44.2 & 51.3 & 59.7 & 80.3 & 87.0 & 27.0 & 48.6 & 58.4 & 2.5 & 13.1 & 56.6 & 3.0 & 9.2 & 49.9 \\ ResNet152-avg-GCL & No & 2048 & 65.1 & 80.0 & 83.8 & 43.5 & 59.2 & 65.2 & 69.3 & 87.2 & 91.3 & 32.1 & 52.1 & 62.2 & 3.3 & 13.5 & 59.9 & 3.6 & 11.0 & 61.2 \\ ResNet152-avg-CL & Yes & 1024 & 63.0 & 77.7 & 81.5 & 37.7 & 51.6 & 56.9 & 68.8 & 85.9 & 90.4 & 49.8 & 67.3 & 74.3 & 5.4 & 22.2 & 64.8 & 4.8 & 14.3 & 59.9 \\ ResNet152-avg-GCL & Yes & 2048 & 75.8 & 87.4 & 89.7 & 52.7 & 68.1 & 74.2 & \textbf{77.9} & \textbf{90.4} & \textbf{93.5} & \textbf{64.4} & \textbf{77.8} & \textbf{83.2} & \textbf{6.2} & \textbf{23.9} & 70.0 & \textbf{5.7} & \textbf{17.0} & 66.5 \\ \midrule ResNeXt-avg-CL & No & 2048 & 58.9 & 75.1 & 79.9 & 34.5 & 50.1 & 57.7 & 51.3 & 73.6 & 81.9 & 24.8 & 47.3 & 56.8 & 2.7 & 10.9 & 61.0 & 2.0 & 6.1 & 40.0 \\ ResNeXt-avg-GCL & No & 2048 & 72.2 & 85.1 & 87.3 & 51.5 & 66.9 & 71.7 & 62.9 & 81.0 & 87.1 & 39.4 & 58.1 & 68.9 & 2.7 & 12.4 & 63.1 & 3.3 & 10.2 & 57.7 \\ ResNeXt-avg-CL & Yes & 1024 & 71.6 & 84.7 & 88.0 & 46.5 & 62.9 & 68.9 & 69.2 & 85.3 & 89.6 & 44.8 & 63.5 & 73.6 & 4.8 & 20.4 & \textbf{70.6} & 4.6 & 13.4 & 58.6 \\ ResNeXt-avg-GCL & Yes & 1024 & \textbf{79.3} & \textbf{89.2} & \textbf{90.3} & \textbf{57.8} & \textbf{72.3} & \textbf{77.1} & 74.8 & 88.2 & 91.8 & 53.0 & 76.2 & 80.6 & 2.7 & 10.9 & 61.0 & 5.6 & 16.6 & \textbf{70.7} \\ \bottomrule \end{tabular}% } \end{table*} \subsection{Network activation} In Fig.~\ref{fig:activations}, we show the activation maps of the last convolutional layer of our models with a \revised{VGG16-GeM and a} ResNet50-GeM backbone, both trained using the Contrastive Loss function (CL) and the proposed Generalized Contrastive Loss (GCL) function. We selected two example image pairs from the MSLS test set~\cite{msls} corresponding to the cities of Kampala and Stockholm, one from the Pittsburgh30k test set~\cite{Arandjelovic2017}, and one from the Tokyo 24/7 dataset~\cite{Torii-CVPR2013}. For all cases, we observed that the model trained with the GCL function produces higher activation for the common visual features of the images, and lower for the irrelevant parts (i.e. the road or the sky), in contrast to the model trained with the binary CL, which focuses less in the concerned areas of the pictures. In the example from Stockholm we can observe that our model does not respond to the cars (which vary from picture to picture), while it does respond strongly to the cranes (which are a more permanent feature). The example from Tokyo 24/7 is also particularly interesting: our model trained with the GCL function has high responses on the common parts of the images even under big changes of illumination. \revised{We observed that ResNet architectures tend to produce a peak of activation on the top left corner of the images. This does not seem to occur with the VGG architecture, so our intuition is that this artifact is due to the residuals. } \revised{\subsection{Results with Global Average Pooling} In addition to using GeM, we also trained the considered backbones (i.e. VGG16, ResNet50, ResNet152 and ResNeXt) using a Global Average Pooling on the MSLS dataset. We show the results in Table~\ref{tab:ablation-avg}. We observed that our method can reach good results with an even simpler pooling layer as is a Global Average Pooling, although a GeM layer usually leads to better results (see main paper). Our methods reaches good results on the validation and test sets of MSLS and generalizes well to unseen datasets such as Pittsburgh30k~\cite{Arandjelovic2017}, Tokyo24/7~\cite{Arandjelovic2017}, RobotCar Seasons V2~\cite{sattler2018benchmarking} and Extended CMU Seasons~\cite{sattler2018benchmarking}. As we observed also with the GeM models, the Global Average Pooling models can reach better performance when PCA whitening is applied, up to a 72.3\% top-5 recall on the test set of MSLS. } \begin{table}[t!] \centering \caption{Generalization results of the models trained on the MSLS dataset for the Pittsburgh250k and TokyoTM benchmarks.} \label{tab:ablation-pitts250k} \resizebox{\columnwidth}{!}{% \begin{tabular}{@{}lcccccccc@{}} \toprule \textbf{} & \textbf{} & \textbf{} & \multicolumn{3}{c}{\textbf{Pittsburgh250k}} & \multicolumn{3}{c}{\textbf{TokyoTM}} \\ \textbf{Method} & \textbf{PCA$_w$} & \textbf{Dim} & \textbf{R@1} & \textbf{R@5} & \textbf{R@10} & \textbf{R@1} & \textbf{R@5} & \textbf{R@10} \\\midrule VGG-avg-CL & No & 512 & 20.2 & 38.0 & 47.2 & 38.9 & 58.5 & 67.2 \\ VGG-avg-GCL & No & 512 & 32.1 & 53.4 & 62.7 & 65.6 & 80.8 & 85.2 \\ VGG-avg-CL & Yes & 128 & 39.3 & 58.9 & 67.4 & 66.0 & 80.3 & 85.0 \\ VGG-avg-GCL & Yes & 256 & 51.3 & 71.0 & 78.0 & 78.6 & 87.7 & 90.8 \\ VGG-GeM-CL & No & 512 & 44.5 & 63.1 & 70.1 & 67.7 & 80.8 & 85.0 \\ VGG-GeM-GCL & No & 512 & 53.3 & 72.4 & 79.2 & 75.5 & 85.4 & 88.6 \\ VGG-GeM-CL & Yes & 512 & 65.1 & 81.2 & 85.8 & 83.7 & 91.1 & 93.3 \\ VGG-GeM-GCL & Yes & 512 & 73.4 & 86.4 & 89.9 & 88.2 & 93.2 & 94.7 \\\midrule ResNet50-avg-CL & No & 2048 & 45.1 & 65.8 & 73.6 & 69.7 & 83.0 & 87.5 \\ ResNet50-avg-GCL & No & 2048 & 56.2 & 77.1 & 83.8 & 72.3 & 84.8 & 88.4 \\ ResNet50-avg-CL & Yes & 2048 & 70.6 & 85.4 & 89.5 & 90.5 & 94.8 & 96.0 \\ ResNet50-avg-GCL & Yes & 1024 & 74.6 & 87.9 & 91.6 & 91.7 & 95.7 & 96.8 \\ ResNet50-GeM-CL & No & 2048 & 54.8 & 74.2 & 80.7 & 73.3 & 85.4 & 89.2 \\ ResNet50-GeM-GCL & No & 2048 & 68.2 & 84.6 & 89.2 & 80.1 & 88.8 & 91.6 \\ ResNet50-GeM-CL & Yes & 1024 & 72.4 & 86.6 & 90.4 & 88.7 & 93.9 & 95.4 \\ ResNet50-GeM-GCL & Yes & 1024 & 80.9 & 91.4 & 94.3 & 92.2 & 95.6 & 96.8 \\\midrule ResNet152-avg-CL & No & 2048 & 51.3 & 73.0 & 80.1 & 73.5 & 86.4 & 89.9 \\ ResNet152-avg-GCL & No & 2048 & 64.0 & 83.6 & 89.2 & 78.9 & 89.0 & 91.9 \\ ResNet152-avg-CL & Yes & 1024 & 69.6 & 85.9 & 90.6 & 90.7 & 95.1 & 96.3 \\ ResNet152-avg-GCL & Yes & 2048 & 80.9 & 92.2 & 95.3 & \textbf{94.0} & \textbf{96.7} & \textbf{97.3} \\ ResNet152-GeM-CL & No & 2048 & 60.7 & 79.0 & 85.1 & 77.8 & 88.3 & 91.2 \\ ResNet152-GeM-GCL & No & 2048 & 68.0 & 84.9 & 89.8 & 81.5 & 90.3 & 92.8 \\ ResNet152-GeM-CL & Yes & 2048 & 76.2 & 89.9 & 93.4 & 91.1 & 95.3 & 96.4 \\ ResNet152-GeM-GCL & Yes & 2048 & \textbf{83.8} & \textbf{93.7} & \textbf{96.1} & 93.1 & 96.1 & 96.8 \\\midrule ResNeXt-avg-CL & No & 2048 & 44.2 & 65.8 & 73.9 & 69.0 & 82.3 & 86.3 \\ ResNeXt-avg-GCL & No & 2048 & 57.9 & 76.1 & 82.6 & 77.7 & 86.9 & 89.7 \\ ResNeXt-avg-CL & Yes & 1024 & 69.6 & 85.4 & 89.8 & 88.9 & 94.1 & 95.6 \\ ResNeXt-avg-GCL & Yes & 1024 & 74.7 & 88.0 & 91.7 & 89.6 & 94.6 & 95.9 \\ ResNeXt-GeM-CL & No & 2048 & 50.2 & 70.8 & 78.8 & 66.1 & 78.5 & 82.7 \\ ResNeXt-GeM-GCL & No & 2048 & 58.6 & 76.2 & 81.8 & 78.7 & 87.1 & 90.1 \\ ResNeXt-GeM-CL & Yes & 1024 & 70.3 & 85.2 & 89.6 & 87.2 & 93.1 & 94.5 \\ ResNeXt-GeM-GCL & Yes & 1024 & 78.2 & 90.1 & 93.1 & 91.8 & 95.4 & 96.6 \\ \bottomrule \end{tabular}% } \end{table} \revised{\subsection{Results on Pittsburgh250k and TokyoTM} We evaluated the generalization of our models trained on MSLS to the Pittsburgh250k~\cite{Torii-PAMI2015} and TokyoTM~\cite{Arandjelovic2017} datasets. The test set of the former consists of 83k map and 8k query images taken over the span of several years in Pittsburgh, Pennsylvania, USA. The TokyoTM dataset consists of images collected using the Time Machine tool on Google Street View in Tokyo over several years. Its validation set is divided into a map and a query set, with 49k and 7k images. The results that we obtained are in line with those reported in the main paper. Our models trained with a GCL function consistently generalize better to unseen datasets than their counterpart trained with a binary Contrastive Loss function. Their performance is further boosted if PCA whitening is applied, up to a top-5 recall of 93.7\% on Pittsburgh250k and 96.7\% on TokyoTM. } \begin{table}[t!] \centering \caption{Detailed results on the Extended CMU dataset. The symbol $^\star$ denotes the models for which PCA whitening has been applied. } \label{tab:cmu_detailed} \resizebox{\columnwidth}{!}{% \setlength\tabcolsep{1.5pt} \begin{tabular}{@{}lcccc@{}} \toprule \textbf{} & \textbf{Mean} & \textbf{Urban} & \textbf{Suburban} & \textbf{Park} \\ \textbf{Method} & \textbf{\begin{tabular}[c]{@{}c@{}}0.25/0.5/10m \\ 2/5/10$\degree$\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}0.25/0.5/10m \\ 2/5/10$\degree$\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}0.25/0.5/10m \\ 2/5/10$\degree$\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}0.25/0.5/10m \\ 2/5/10$\degree$\end{tabular}} \\\midrule NetVLAD-64-Pitts30k & 5.3 / 15.9 / 66.3 & 10.7 / 27.8 / 84.1 & 2.9 / 11.2 / 63.5 & 2.4 / 8.9 / 50.1 \\ NetVLAD-64-Pitts30k$^\star$ & 5.8 / 17.6 / 70.3 & 11.6 / 30.3 / 87.5 & 3.3 / 12.5 / 68 & 2.7 / 10.2 / 54.2 \\ NetVLAD-64-MSLS & 1.3 / 4.5 / 31.9 & 2.9 / 8.4 / 49.6 & 0.8 / 3.4 / 29.7 & 0.3 / 1.6 / 15.2 \\ NetVLAD-64-MSLS$^\star$ & 3.9 / 12.1 / 58.4 & 7.6 / 20.3 / 77.2 & 2.6 / 9.7 / 58.9 & 1.6 / 6.3 / 37.0 \\ NetVLAD-16-MSLS & 1.7 / 5.5 / 39.1 & 3.7 / 10.0 / 57.3 & 1.1 / 4.5 / 38.6 & 0.4 / 1.9 / 19.8 \\ NetVLAD-16-MSLS$^\star$ & 4.4 / 13.7 / 61.4 & 8.4 / 22.1 / 76.9 & 3.0 / 11.4 / 63.1 & 1.9 / 7.4 / 41.9 \\ AP-GeM$^\star$ & 4.9 / 14.7 / 65.2 & 9.8 / 25.2 / 82.6 & 2.8 / 10.9 / 65.3 & 2.1 / 8 / 45.9 \\ NetVLAD-SARE$^\star$ & \textbf{6.4} / \textbf{19.4} / \textbf{75.5} & \textbf{12.5} / \textbf{32.4 }/ \textbf{90.7} & \textbf{3.9} / \textbf{14.7 }/ \textbf{76.3} & 3.0 / 11.3 / 57.6 \\\midrule VGG-avg-CL & 0.9 / 3.0 / 22.7 & 2.0 / 5.8 / 39.4 & 0.6 / 2.3 / 21 & 0.2 / 0.7 / 6.5 \\ VGG-avg-GCL & 2.3 / 7.2 / 43.3 & 4.7 / 13.0 / 64.3 & 1.6 / 5.8 / 43.4 & 0.7 / 2.5 / 19.8 \\ VGG-avg-CL$^\star$ & 2.1 / 6.6 / 34.9 & 4.4 / 12.3 / 54.1 & 1.1 / 4.4 / 30.5 & 0.9 / 3.1 / 19.4 \\ VGG-avg-GCL$^\star$ & 3.7 / 11.2 / 52.5 & 7.2 / 19.1 / 70.8 & 2.1 / 8.2 / 50.4 & 1.8 / 6.2 / 35.1 \\ VGG-GeM-CL & 2.8 / 8.6 / 44.5 & 5.7 / 15.2 / 63.7 & 1.6 / 6.4 / 44.9 & 1.1 / 4.2 / 22.8 \\ VGG-GeM-GCL & 3.6 / 11.2 / 55.8 & 6.8 / 18.5 / 73.6 & 2.5 / 9.2 / 57.3 & 1.5 / 5.6 / 34.2 \\ VGG-GeM-CL$^\star$ & 4.4 / 13.4 / 56.5 & 8.4 / 21.5 / 72.1 & 2.6 / 10 / 55.2 & 2.3 / 8.7 / 40.8 \\ VGG-GeM-GCL$^\star$ & 5.7 / 17.1 / 66.3 & 10.4 / 26.8 / 82.2 & 3.8 / 13.8 / 67.8 & 2.8 / 10.7 / 46.7 \\\midrule ResNet50-avg-CL & 2.6 / 7.8 / 43.4 & 5.6 / 14.9 / 64.6 & 1.4 / 5.5 / 42.6 & 0.8 / 2.9 / 21.1 \\ ResNet50-avg-GCL & 3.1 / 9.7 / 55.1 & 6 / 16.7 / 73.6 & 2.0 / 7.7 / 56.8 & 1.2 / 4.7 / 32.5 \\ ResNet50-avg-CL$^\star$ & 4.7 / 13.8 / 50.8 & 9.5 / 24.1 / 70.5 & 2.7 / 9.7 / 48.8 & 2.1 / 7.6 / 31.7 \\ ResNet50-avg-GCL$^\star$ & 5.4 / 16.2 / 66.5 & 10.2 / 26.5 / 81.8 & 3.5 / 12.5 / 69.8 & 2.6 / 9.6 / 45.3 \\ ResNet50-GeM-CL & 3.2 / 9.6 / 49.5 & 6.5 / 17.3 / 70.7 & 1.9 / 7.0 / 49.3 & 1.2 / 4.3 / 26.3 \\ ResNet50-GeM-GCL & 3.8 / 11.8 / 61.6 & 7.4 / 19.9 / 79.2 & 2.4 / 9.4 / 64.8 & 1.5 / 6.1 / 38.1 \\ ResNet50-GeM-CL$^\star$ & 4.7 / 13.4 / 51.6 & 9.5 / 23.9 / 73.5 & 2.8 / 9.6 / 49.7 & 1.9 / 6.8 / 30.0 \\ ResNet50-GeM-GCL$^\star$ & 5.4 / 16.5 / 69.9 & 10.1 / 26.3 / 84.5 & 3.5 / 13.4 / 74.1 & 2.6 / 9.8 / 48.2 \\\midrule ResNet152-avg-CL & 3.0 / 9.2 / 49.9 & 6.2 / 16.4 / 70.4 & 1.9 / 6.9 / 48.7 & 1.0 / 4.1 / 28.9 \\ ResNet152-avg-GCL & 3.6 / 11.0 / 61.2 & 7.0 / 18.9 / 78.8 & 2.3 / 8.4 / 62.6 & 1.4 / 5.5 / 39.9 \\ ResNet152-avg-CL$^\star$ & 4.8 / 14.3 / 59.9 & 9.4 / 24 / 77.3 & 3.0 / 10.9 / 61 & 2 / 8 / 39.3 \\ ResNet152-avg-GCL$^\star$ & 5.7 / 17.0 / 66.5 & 10.8 / 27.3 / 82.0 & 3.7 / 13.5 / 68.9 & 2.6 / 10.1 / 46.3 \\ ResNet152-GeM-CL & 3.2 / 9.7 / 52.2 & 6.7 / 17.7 / 73.9 & 2.1 / 7.3 / 52.8 & 0.9 / 4.1 / 27.6 \\ ResNet152-GeM-GCL & 3.6 / 11.3 / 63.1 & 6.9 / 18.8 / 79.3 & 2.5 / 9.0 / 64.3 & 1.3 / 6.0 / 43.6 \\ ResNet152-GeM-CL$^\star$ & 4.8 / 14.2 / 55.0 & 9.6 / 24.5 / 75.2 & 3.0 / 10.5 / 54.3 & 1.9 / 7.5 / 33.6 \\ ResNet152-GeM-GCL$^\star$ & 5.3 / 16.1 / 66.4 & 9.9 / 25.8 / 81.6 & 3.5 / 12.8 / 69.3 & 2.4 / 9.7 / 46 \\\midrule ResNext-avg-CL & 2.0 / 6.1 / 40.0 & 4.6 / 12.2 / 63.6 & 1.2 / 4.4 / 38.5 & 0.3 / 1.7 / 16.0 \\ ResNext-avg-GCL & 3.3 / 10.2 / 57.7 & 6.7 / 17.9 / 77.8 & 2.1 / 8.1 / 58.1 & 1.2 / 4.4 / 35.0 \\ ResNext-avg-CL$^\star$ & 4.6 / 13.4 / 58.6 & 9.3 / 23.2 / 78 & 2.8 / 10.1 / 59 & 1.7 / 6.7 / 36.5 \\ ResNext-avg-GCL$^\star$ & 5.6 / 16.6 / 70.7 & 10.4 / 26.6 / 85.1 & 3.7 / 13.4 / 73.2 & 2.6 / 9.8 / 51.6 \\ ResNext-GeM-CL & 2.9 / 9.0 / 52.6 & 5.9 / 15.6 / 70.2 & 1.7 / 6.8 / 53.0 & 1.2 / 4.7 / 32.6 \\ ResNext-GeM-GCL & 3.5 / 10.5 / 58.8 & 6.5 / 17.7 / 77.8 & 2.5 / 8.7 / 59.7 & 1.3 / 5.0 / 36.6 \\ ResNext-GeM-CL$^\star$ & 4.9 / 14.4 / 61.7 & 9.4 / 24 / 80.2 & 3.1 / 11.1 / 63.8 & 2.2 / 8.0 / 38.6 \\ ResNext-GeM-GCL$^\star$ & 6.1 / 18.2 / 74.9 & 11.1 / 28.7 / 87.4 & 4.2 / 14.6 / 77.4 & \textbf{3.1} / \textbf{11.1} / \textbf{57.7 }\\ \bottomrule \end{tabular} } \end{table} \begin{table*}[] \centering \caption{Detailed results on the RobotCar Seasons v2 dataset, divided by wheather and ilumination conditions. The symbol $^\star$ denotes the models for which PCA whitening has been applied.} \label{tab:robotcar_extended} \resizebox{\textwidth}{!}{% \setlength\tabcolsep{1.75pt} \begin{tabular}{@{}l|c|c|c|c|c|c|c|c|c|c|c|c@{}} \toprule \textbf{} & \textbf{night rain} & \textbf{night} & \textbf{night all} & \textbf{overcast winter} & \textbf{sun} & \textbf{rain} & \textbf{snow} & \textbf{dawn} & \textbf{dusk} & \textbf{overcast summer} & \textbf{day all} & \textbf{mean} \\ \textbf{Method} & \textbf{\begin{tabular}[c]{@{}c@{}}0.25/0.5/10m \\ 2/5/10$\degree$\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}0.25/0.5/10m \\ 2/5/10$\degree$\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}0.25/0.5/10m \\ 2/5/10$\degree$\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}0.25/0.5/10m \\ 2/5/10$\degree$\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}0.25/0.5/10m \\ 2/5/10$\degree$\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}0.25/0.5/10m \\ 2/5/10$\degree$\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}0.25/0.5/10m \\ 2/5/10$\degree$\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}0.25/0.5/10m \\ 2/5/10$\degree$\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}0.25/0.5/10m \\ 2/5/10$\degree$\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}0.25/0.5/10m \\ 2/5/10$\degree$\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}0.25/0.5/10m \\ 2/5/10$\degree$\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}0.25/0.5/10m \\ 2/5/10$\degree$\end{tabular}} \\ \midrule NetVLAD-64-Pitts30k & 1.5 / 1.5 / 10.3 & 0.4 / 1.8 / 8.0 & 0.9 / 1.6 / 9.1 & 1.2 / 23.8 / 97.0 & 5.4 / 14.3 / 74.1 & 10.2 / 44.4 / 99.5 & 9.3 / 31.6 / 94.9 & 9.7 / 26.4 / 82.8 & 5.1 / 26.4 / 92.4 & 6.6 / 30.3 / 88.6 & 7.0 / 28.1 / 89.4 & 5.6 / 22 / 71 \\ NetVLAD-64-Pitts30k$^\star$ & 2.0 / 3.9 / 13.3 & 0.0 / 1.3 / 11.5 & 0.9 / 2.6 / 12.4 & 1.2 / 22.6 / \textbf{100.0} & 4.9 / 18.8 / 80.8 & 9.3 / 42.4 / 98.5 & 10.2 / 32.6 / 94.9 & \textbf{11.5 / 29.5 / 85.5} & 5.6 / 27.9 / 92.4 & 7.1 / 30.3 / 90.0 & 7.3 / 29.2 / 91.3 & 5.8 / 23.1 / 73.2 \\ NetVLAD-64-MSLS & 0.5 / 1.0 / 5.9 & 0.0 / 0.4 / 4.4 & 0.2 / 0.7 / 5.1 & 0.0 / 11.6 / 67.7 & 0.9 / 4.5 / 28.6 & 4.4 / 22.0 / 91.2 & 4.7 / 13.0 / 60.5 & 3.1 / 8.4 / 32.6 & 2.5 / 14.2 / 78.7 & 1.4 / 9.5 / 51.7 & 2.5 / 11.7 / 57.5 & 2 / 9.2 / 45.5 \\ NetVLAD-64-MSLS$^\star$ & 0.0 / 1.5 / 11.8 & 0.0 / 1.3 / 12.4 & 0.0 / 1.4 / 12.1 & 0.0 / 15.2 / 87.2 & 3.1 / 12.1 / 66.5 & 8.8 / 35.6 / 99.0 & 7.0 / 28.4 / 90.2 & 9.3 / 21.6 / 77.5 & 4.1 / 25.4 / 98.0 & 5.2 / 21.3 / 77.7 & 5.5 / 22.9 / 84.7 & 4.2 / 18 / 68.1 \\ NetVLAD-16-MSLS & 0.0 / 0.0 / 3.4 & 0.0 / 0.9 / 5.3 & 0.0 / 0.5 / 4.4 & 1.2 / 10.4 / 78.0 & 0.9 / 6.2 / 33.0 & 5.9 / 25.4 / 93.7 & 3.3 / 10.7 / 62.8 & 1.8 / 6.6 / 29.1 & 1.5 / 16.2 / 86.8 & 1.4 / 8.1 / 57.8 & 2.3 / 11.8 / 61.5 & 1.8 / 9.2 / 48.4 \\ NetVLAD-16-MSLS$^\star$ & 0.0 / 0.0 / 1.0 & 0.0 / 0.9 / 7.1 & 0.0 / 0.5 / 4.2 & 1.8 / 19.5 / 90.2 & 4.9 / 11.6 / 67.4 & 10.7 / 34.1 / 96.1 & 6.5 / 24.7 / 89.8 & 7.9 / 24.2 / 74.4 & 2.5 / 23.4 / 93.9 & 7.6 / 24.6 / 77.3 & 6.2 / 23.1 / 83.6 & 4.8 / 17.9 / 65.3 \\ AP-GeM & 0.0 / 2.0 / 14.3 & 0.0 / 0.9 / 10.6 & 0.0 / 1.4 / 12.4 & 1.2 / 26.2 / 89.6 & 4.0 / 17.4 / 62.1 & 13.7 / 41.0 / 98.0 & 7.0 / 26.0 / 87.9 & 8.4 / 24.7 / 71.8 & 5.1 / 25.4 / 94.4 & 5.7 / 23.7 / 75.8 & 6.6 / 26.2 / 82.1 & 5.1 / 20.5 / 66.1 \\ NetVLAD-SARE$^\star$ & 3.4 / 8.9 / 38.9 & 0.9 / 4.4 / 31.4 & 2.1 / 6.5 / 35.0 & 2.4 / \textbf{29.3} / 97.6 & \textbf{8.9 / 22.3 / 92.9} & 13.2 / 43.9 / \textbf{100.0} & \textbf{12.1 / 36.3 / 98.1} & 10.6 / 28.2 / 89.9 & \textbf{5.6 / 30.5 / 95.9} & \textbf{8.5 / 36.5 / 91.9} & \textbf{9.0 / 32.4 / 95.0} &\textbf{ 7.4 / 26.5 / 81.3} \\ \midrule VGG-avg-CL & 0.0 / 0.0 / 2.5 & 0.0 / 0.0 / 1.3 & 0.0 / 0.0 / 1.9 & 0.0 / 7.9 / 54.9 & 0.0 / 2.2 / 14.3 & 4.9 / 23.9 / 85.4 & 3.3 / 8.8 / 49.8 & 0.9 / 1.3 / 14.5 & 0.0 / 12.2 / 66.5 & 0.0 / 3.3 / 31.8 & 1.3 / 8.3 / 44.0 & 1 / 6.4 / 34.4 \\ VGG-avg-GCL & 0.0 / 0.5 / 3.9 & 0.0 / 0.0 / 1.8 & 0.0 / 0.2 / 2.8 & 0.6 / 15.2 / 82.9 & 2.2 / 6.7 / 44.6 & 7.8 / 31.7 / 95.1 & 4.2 / 19.5 / 73.0 & 0.4 / 5.7 / 33.9 & 2.0 / 21.8 / 86.3 & 3.8 / 13.7 / 57.8 & 3.0 / 16.1 / 66.3 & 2.3 / 12.5 / 51.7 \\ VGG-avg-CL$^\star$ & 0.0 / 0.0 / 0.0 & 0.0 / 0.0 / 0.0 & 0.0 / 0.0 / 0.0 & 0.0 / 11.0 / 61.6 & 0.4 / 4.0 / 20.5 & 5.9 / 26.3 / 85.4 & 5.1 / 13.5 / 64.2 & 3.1 / 8.4 / 40.1 & 4.1 / 17.3 / 76.6 & 1.9 / 11.8 / 40.3 & 3.0 / 13.0 / 54.5 & 2.3 / 10 / 42 \\ VGG-avg-GCL$^\star$ & 0.0 / 0.0 / 1.0 & 0.0 / 0.0 / 0.4 & 0.0 / 0.0 / 0.7 & 0.6 / 17.1 / 79.3 & 3.1 / 11.2 / 49.1 & 9.3 / 34.6 / 97.6 & 6.5 / 17.7 / 80.0 & 3.5 / 16.3 / 56.4 & 5.6 / 25.4 / 90.9 & 3.8 / 18.0 / 69.7 & 4.7 / 19.9 / 73.9 & 3.6 / 15.3 / 57.1 \\ VGG-GeM-CL & 0.0 / 0.0 / 2.0 & 0.0 / 0.4 / 1.8 & 0.0 / 0.2 / 1.9 & 0.0 / 14.6 / 80.5 & 2.2 / 6.7 / 45.5 & 8.3 / 31.2 / 94.1 & 6.0 / 20.0 / 77.7 & 3.5 / 11.5 / 47.1 & 2.0 / 17.8 / 89.8 & 4.7 / 18.0 / 68.2 & 4.0 / 17.0 / 70.8 & 3.1 / 13.2 / 55 \\ VGG-GeM-GCL & 0.0 / 0.5 / 7.4 & 0.0 / 0.0 / 0.9 & 0.0 / 0.2 / 4.0 & 0.6 / 16.5 / 82.3 & 2.2 / 11.6 / 61.2 & 10.2 / 38.0 / 99.0 & 7.9 / 23.3 / 83.7 & 2.6 / 11.5 / 51.1 & 2.0 / 22.3 / 90.9 & 7.1 / 20.9 / 70.6 & 4.8 / 20.4 / 76.2 & 3.7 / 15.8 / 59.7 \\ VGG-GeM-CL$^\star$ & 0.0 / 0.5 / 2.0 & 0.0 / 0.0 / 0.0 & 0.0 / 0.2 / 0.9 & 0.6 / 18.9 / 84.8 & 2.7 / 13.4 / 60.3 & 8.3 / 36.6 / 98.5 & 8.4 / 27.0 / 85.1 & 6.6 / 22.5 / 70.5 & 5.6 / 29.9 / 95.9 & 4.7 / 21.3 / 74.9 & 5.4 / 24.2 / 80.8 & 4.2 / 18.7 / 62.5 \\ VGG-GeM-GCL$^\star$ & 0.5 / 1.0 / 6.4 & 0.0 / 1.3 / 6.6 & 0.2 / 1.2 / 6.5 & 1.2 / 23.2 / 90.9 & 6.7 / 21.4 / 78.1 & 11.2 / 42.4 / \textbf{100.0} & 9.3 / 32.6 / 95.3 & 7.5 / 20.7 / 76.7 & 4.6 / 28.9 / 97.5 & 6.2 / 27.0 / 79.6 & 6.9 / 28.0 / 87.9 & 5.4 / 21.9 / 69.2 \\ \midrule ResNet50-avg-CL & 0.5 / 1.0 / 9.4 & 0.4 / 2.2 / 11.1 & 0.5 / 1.6 / 10.3 & 0.0 / 13.4 / 71.3 & 1.8 / 6.2 / 30.4 & 8.8 / 32.7 / 97.6 & 5.6 / 18.6 / 64.7 & 4.4 / 15.4 / 53.7 & 3.0 / 14.7 / 79.2 & 2.8 / 10.4 / 51.7 & 3.9 / 15.9 / 63.1 & 3.1 / 12.6 / 51 \\ ResNet50-avg-GCL & 1.0 / 2.0 / 12.8 & 0.4 / 1.3 / 8.4 & 0.7 / 1.6 / 10.5 & 0.6 / 18.3 / 80.5 & 1.3 / 6.7 / 43.8 & 8.3 / 34.1 / 96.1 & 4.7 / 15.3 / 72.6 & 2.6 / 11.0 / 51.1 & 2.0 / 16.2 / 88.8 & 4.3 / 14.2 / 64.0 & 3.5 / 16.3 / 69.9 & 2.9 / 12.9 / 56.3 \\ ResNet50-avg-CL$^\star$ & 0.0 / 0.0 / 3.0 & 0.0 / 0.4 / 1.8 & 0.0 / 0.2 / 2.3 & 2.4 / 26.2 / 89.6 & 3.6 / 14.3 / 53.1 & \textbf{14.6 / 45.4 }/ 98.0 & 8.4 / 30.7 / 84.2 & 10.1 / 31.7 / 75.3 & 5.6 / 24.9 / 93.4 & 7.6 / 33.6 / 76.8 & 7.6 / 29.5 / 80.7 & 5.9 / 22.8 / 62.7 \\ ResNet50-avg-GCL$^\star$ & 0.0 / 1.0 / 6.4 & 0.4 / 0.4 / 10.2 & 0.2 / 0.7 / 8.4 & \textbf{3.0} / 28.0 / 98.2 & 4.0 / 15.6 / 68.8 & 13.2 / 41.5 / 97.6 & 8.4 / 31.2 / 87.9 & 8.4 / 30.4 / 84.1 & 5.6 / 27.9 / 96.4 & 9.5 / 33.6 / 86.3 & 7.6 / 29.7 / 87.8 & 5.9 / 23.1 / 69.6 \\ ResNet50-GeM-CL & 0.5 / 1.5 / 11.8 & 0.4 / 1.3 / 8.0 & 0.5 / 1.4 / 9.8 & 0.0 / 16.5 / 82.9 & 0.9 / 9.8 / 61.2 & 9.8 / 33.7 / 97.1 & 5.6 / 23.7 / 81.4 & 3.1 / 15.0 / 62.6 & 1.5 / 19.8 / 93.4 & 6.2 / 18.5 / 64.9 & 4.0 / 19.5 / 76.9 & 3.2 / 15.4 / 61.5 \\ ResNet50-GeM-GCL & 0.5 / 2.0 / 9.9 & 0.0 / 1.3 / 11.9 & 0.2 / 1.6 / 11.0 & 1.8 / 21.3 / 84.8 & 1.8 / 10.3 / 47.3 & 8.8 / 33.7 / 97.1 & 5.1 / 18.1 / 80.9 & 1.8 / 8.8 / 49.8 & 2.0 / 17.8 / 91.9 & 4.7 / 16.6 / 69.7 & 3.7 / 17.7 / 73.4 & 2.9 / 14 / 58.8 \\ ResNet50-GeM-CL$^\star$ & 0.5 / 0.5 / 3.9 & 0.0 / 0.4 / 2.7 & 0.2 / 0.5 / 3.3 & \textbf{3.0} / 28.0 / 95.1 & 2.2 / 13.8 / 56.7 & 9.8 / 37.6 / 98.5 & 8.4 / 32.6 / 94.0 & 7.0 / 23.8 / 83.7 & 5.6 / 24.9 / 94.4 & 8.1 / 30.8 / 79.6 & 6.4 / 27.2 / 85.3 & 5 / 21.1 / 66.5 \\ ResNet50-GeM-GCL$^\star$ & 0.0 / 0.0 / 8.4 & 0.0 / 0.0 / 9.3 & 0.0 / 0.0 / 8.9 & \textbf{3.0} / 25.6 / 95.7 & 3.1 / 14.7 / 69.2 & 9.3 / 34.6 / 98.0 & 6.5 / 28.4 / 90.7 & 9.3 / 28.6 / 86.3 & 3.6 / 25.9 / 96.4 & 7.1 / 26.1 / 83.9 & 6.1 / 26.2 / 88.1 & 4.7 / 20.2 / 70 \\ \midrule ResNet152-avg-CL & 0.0 / 0.0 / 8.4 & 0.0 / 0.0 / 8.0 & 0.0 / 0.0 / 8.2 & 1.2 / 17.1 / 86.0 & 1.8 / 11.2 / 51.3 & 6.8 / 34.1 / 92.7 & 4.7 / 15.8 / 74.0 & 2.6 / 11.9 / 53.3 & 3.0 / 17.3 / 82.7 & 2.4 / 13.3 / 64.0 & 3.3 / 17.0 / 71.0 & 2.5 / 13.1 / 56.6 \\ ResNet152-avg-GCL & 0.0 / 1.5 / 11.3 & 0.4 / 0.4 / 10.2 & 0.2 / 0.9 / 10.7 & 1.8 / 20.1 / 90.2 & 3.6 / 8.5 / 52.7 & 9.3 / 29.3 / 95.6 & 4.7 / 19.1 / 84.2 & 2.6 / 12.8 / 47.6 & 3.0 / 16.8 / 88.8 & 4.3 / 16.1 / 70.6 & 4.2 / 17.3 / 74.5 & 3.3 / 13.5 / 59.9 \\ ResNet152-avg-CL$^\star$ & 3.0 / 10.9 / 61.0 & 4.3 / 13.6 / 57.6 & 9.4 / 24.0 / 77.3 & 2.0 / 8.0 / 39.3 & 5.1 / 14.0 / 60.8 & 4.9 / 14.2 / 58.1 & 4.8 / 14.1 / 59.8 & 4.5 / 13.3 / 55.1 & 5.3 / 17.0 / 69.7 & 3.6 / 12.3 / 53.7 & 5.5 / 16.2 / 67.2 & 5.4 / 22.2 / 64.8 \\ ResNet152-avg-GCL$^\star$ & \textbf{3.7 / 13.5 / 68.9} & \textbf{5.3 / 16.6 / 65.0} & \textbf{10.8 / 27.3 / 82.0} & 2.6 / 10.1 / 46.3 & 6.1 / 16.7 / 68.2 & 5.7 / 16.8 / 63.1 & 5.6 / 16.4 / 65.0 & 5.7 / 16.4 / 63.9 & 6.1 / 19.6 / 74.9 & 4.3 / 14.6 / 61.6 & 6.2 / 18.5 / 73.6 & 6.2 / 23.9 / 70 \\ ResNet152-GeM-CL & 2.1 / 7.3 / 52.8 & 3.0 / 9.8 / 53.9 & 6.7 / 17.7 / 73.9 & 0.9 / 4.1 / 27.6 & 3.2 / 8.9 / 52.2 & 3.3 / 9.2 / 47.4 & 3.1 / 8.9 / 47.9 & 3.3 / 9.9 / 53.0 & 3.4 / 11.5 / 61.0 & 1.9 / 7.9 / 45.6 & 3.7 / 11.0 / 56.3 & 3.3 / 15.2 / 64 \\ ResNet152-GeM-GCL & 2.5 / 9.0 / 64.3 & 3.3 / 11.0 / 63.8 & 6.9 / 18.8 / 79.3 & 1.3 / 6.0 / 43.6 & 4.1 / 11.4 / 62.9 & 3.5 / 11.2 / 58.9 & 3.5 / 10.8 / 60.1 & 3.7 / 11.2 / 62.9 & 3.6 / 12.6 / 70.4 & 2.5 / 9.4 / 58.9 & 3.8 / 11.9 / 68.4 & 2.9 / 13.1 / 63.5 \\ ResNet152-GeM-CL$^\star$ & 3.0 / 10.5 / 54.3 & 4.4 / 13.6 / 53.2 & 9.6 / 24.5 / 75.2 & 1.9 / 7.5 / 33.6 & 4.9 / 13.4 / 53.9 & 5.0 / 14.1 / 53.5 & 4.9 / 13.7 / 54.6 & 4.4 / 12.9 / 50.0 & 5.6 / 17.5 / 65.6 & 3.9 / 12.5 / 47.1 & 5.5 / 15.9 / 62.2 & 6.1 / 23.5 / 68.9 \\ ResNet152-GeM-GCL$^\star$ & 3.5 / 12.8 / 69.3 & 4.8 / 16.0 / 65.4 & 9.9 / 25.8 / 81.6 & 2.4 / 9.7 / 46.0 & 5.6 / 15.6 / 67.0 & 5.3 / 15.5 / 62.8 & 5.2 / 15.2 / 64.7 & 5.1 / 15.6 / 63.7 & 5.7 / 19.5 / 75.8 & 4.0 / 14.8 / 62.3 & 6.1 / 17.9 / 74.0 & 6 / 21.6 / 72.5 \\ \midrule ResNext-avg-CL & 1.0 / 3.4 / 29.1 & 0.0 / 1.3 / 15.5 & 0.5 / 2.3 / 21.9 & 1.2 / 12.8 / 86.0 & 1.3 / 4.9 / 55.8 & 6.8 / 20.5 / 97.6 & 6.5 / 16.7 / 80.0 & 2.2 / 9.7 / 44.5 & 2.5 / 17.8 / 84.8 & 2.8 / 13.3 / 66.8 & 3.4 / 13.5 / 72.6 & 2.7 / 10.9 / 61 \\ ResNext-avg-GCL & 0.0 / 0.5 / 11.8 & 0.0 / 0.9 / 15.9 & 0.0 / 0.7 / 14.0 & 1.2 / 19.5 / 91.5 & 2.7 / 8.9 / 60.3 & 6.8 / 25.4 / 96.6 & 4.2 / 15.3 / 78.1 & 2.6 / 11.9 / 63.4 & 2.5 / 16.2 / 93.9 & 4.3 / 15.6 / 66.8 & 3.5 / 15.9 / 77.7 & 2.7 / 12.4 / 63.1 \\ ResNext-avg-CL$^\star$ & 1.0 / 1.5 / 12.3 & 0.0 / 0.9 / 12.8 & 0.5 / 1.2 / 12.6 & 0.6 / 25.6 / 97.6 & 4.9 / 17.0 / 79.9 & 9.3 / 35.1 / 99.0 & 8.4 / 29.8 / 93.0 & 7.0 / 23.8 / 72.7 & 5.6 / 24.9 / 94.4 & 5.7 / 27.0 / 82.9 & 6.1 / 26.1 / 87.9 & 4.8 / 20.4 / 70.6 \\ ResNext-avg-GCL$^\star$ & 1.0 / 3.4 / 29.1 & 0.0 / 1.3 / 15.5 & 0.5 / 2.3 / 21.9 & 1.2 / 12.8 / 86.0 & 1.3 / 4.9 / 55.8 & 6.8 / 20.5 / 97.6 & 6.5 / 16.7 / 80.0 & 2.2 / 9.7 / 44.5 & 2.5 / 17.8 / 84.8 & 2.8 / 13.3 / 66.8 & 3.4 / 13.5 / 72.6 & 2.7 / 10.9 / 61 \\ ResNext-GeM-CL & 0.0 / 1.5 / 6.9 & 0.0 / 0.4 / 8.0 & 0.0 / 0.9 / 7.5 & 0.0 / 17.1 / 82.3 & 1.3 / 5.4 / 56.7 & 3.9 / 20.5 / 96.6 & 3.7 / 12.6 / 74.9 & 2.2 / 7.0 / 29.5 & 2.0 / 21.3 / 90.4 & 2.8 / 11.4 / 60.7 & 2.4 / 13.2 / 68.9 & 1.9 / 10.4 / 54.8 \\ ResNext-GeM-GCL & 0.0 / 2.5 / 22.2 & 0.4 / 1.3 / 19.9 & 0.2 / 1.9 / 21.0 & 1.2 / 15.2 / 84.8 & 0.9 / 7.6 / 68.8 & 7.3 / 28.3 / 98.5 & 5.1 / 20.0 / 84.2 & 2.2 / 11.0 / 55.5 & 4.1 / 20.8 / 90.9 & 3.3 / 16.1 / 71.6 & 3.5 / 16.8 / 78.4 & 2.7 / 13.4 / 65.2 \\ ResNext-GeM-CL$^\star$ & 0.5 / 2.5 / 10.3 & 0.0 / 0.0 / 11.9 & 0.2 / 1.2 / 11.2 & 1.8 / 20.1 / 92.1 & 4.9 / 15.6 / 79.0 & 7.8 / 31.2 / \textbf{100.0} & 7.0 / 26.0 / 93.0 & 3.5 / 15.0 / 67.0 & 4.6 / 26.9 / 95.9 & 3.8 / 19.4 / 73.0 & 4.9 / 21.9 / 85.1 & 3.8 / 17.2 / 68.2 \\ ResNext-GeM-GCL$^\star$ & 2.5 / 5.4 / 38.4 & 1.8 / 3.5 / 28.3 & 2.1 / 4.4 / 33.1 & 1.2 / 26.8 / 93.9 & 3.6 / 15.2 / 77.2 & 9.8 / 40.0 / 98.5 & 7.9 / 29.3 / 91.2 & 4.8 / 19.8 / 82.4 & 5.1 / 25.9 / 92.9 & 5.7 / 26.1 / 76.8 & 5.5 / 25.9 / 87.1 & 4.7 / 21 / 74.7 \\ \bottomrule \end{tabular}% } \end{table*} \begin{table*}[t!] \setlength\tabcolsep{1.5pt} \centering \caption{Comparison with Thoma et al.~\cite{thoma2020soft}, that outperformed several triplet-based loss functions on the CMU Seasons dataset.} \label{tab:comparisonwiththoma} \begin{tabular*}{\textwidth}{@{}lcccccccccccc@{}} \toprule & \multicolumn{3}{c}{\textbf{All}} & \multicolumn{3}{c}{\textbf{Urban}} & \multicolumn{3}{c}{\textbf{Suburban}} & \multicolumn{3}{c}{\textbf{Park}} \\ \textbf{Method} & \textbf{0.25m/2$\degree$} & \textbf{0.5m/5$\degree$} & \textbf{5.0m/10$\degree$} & \textbf{0.25m/2$\degree$} & \textbf{0.5m/5$\degree$} & \textbf{5.0m/10$\degree$} & \textbf{0.25m/2$\degree$} & \textbf{0.5m/5$\degree$} & \textbf{5.0m/10$\degree$} & \textbf{0.25m/2$\degree$} & \textbf{0.5m/5$\degree$} & \textbf{5.0m/10$\degree$} \\\midrule \textbf{Thoma et al~\cite{thoma2020soft}} & 8.0 & 20.5 & 70.4 & 12.7 & 30.7 & 84.6 & 5.1 & 14.9 & 67.9 & 4.5 & 12.6 & 56.8 \\ \textbf{VGG-GeM-GCL} & 5.9 & 15.4 & 58.9 & 9.6 & 24.1 & 76.4 & 3.1 & 9.8 & 56.3 & 3.3 & 9.0 & 42.0 \\ \textbf{VGG-GeM-GCL+PCA$_w$} & 9.2 & 22.8 & 65.8 & 14.7 & 34.2 & 82.6 & 5.7 & 16.1 & 64.6 & 5.1 & 14.0 & 49.1 \\ \textbf{Resnet50-GeM-GCL} & 6.3 & 16.3 & 62.8 & 10.4 & 25.5 & 81.2 & 3.8 & 11.2 & 63.9 & 3.2 & 9.0 & 43.3 \\ \textbf{Resnet50-GeM-GCL+PCA$_w$} & 9.0 & 22.5 & 69.3 & 14.3 & 33.8 & 85.1 & 6.1 & 17.0 & 71.1 & 4.9 & 13.4 & 52.2 \\ \textbf{Resnet152-GeM-GCL} & 6.2 & 16.2 & 66.2 & 10.1 & 24.8 & 82.0 & 4.1 & 12.2 & 66.4 & 3.1 & 9.2 & 49.9 \\ \textbf{Resnet152-GeM-GCL+PCA$_w$} & 8.8 & 21.6 & 64.0 & 14.1 & 32.4 & 80.0 & 5.9 & 16.8 & 65.2 & 4.7 & 12.7 & 47.0 \\ \textbf{ResNeXt-GeM-GCL} & 5.8 & 15.1 & 63.0 & 9.5 & 24.0 & 81.0 & 3.5 & 10.5 & 62.5 & 2.9 & 7.9 & 44.7 \\ \textbf{ResNeXt-GeM-GCL+PCA$_w$} & \textbf{9.9} & \textbf{24.3} & \textbf{75.5} & \textbf{15.4} & \textbf{36.0} & \textbf{89.6} & \textbf{6.7} & \textbf{18.4} & \textbf{76.8} & \textbf{5.6} & \textbf{14.9} & \textbf{60.3} \\ \bottomrule \end{tabular*}% \end{table*} \begin{figure*}[t!] \centering \subfloat[]{ \begin{tikzpicture}[thick,scale=1, every node/.style={scale=.8}] \begin{axis} [xlabel=Distance (m), ylabel=Recall@5 (\%), ylabel style={at={(axis description cs:-0.08,0.5)}}, legend pos =south east,grid, height=6cm, width=7.5cm] \addplot[blue, mark size=2pt, thick , mark=square,mark options=solid, style=dashdotted] table [x=p, y=r, col sep=comma] {plot_data/appendix/MSLS/MSLS_ResNet50_avg_480_CL_recall_vs_dist.txt}; \addplot[red, mark size=2pt, thick , mark=square,mark options=solid, style=dashdotted] table [x=p, y=r, col sep=comma] {plot_data/appendix/MSLS/MSLS_ResNet50_avg_480_GCL_recall_vs_dist.txt}; \addplot[blue, mark size=2pt, thick , mark=o,mark options=solid, style=dashdotted] table [x=p, y=r, col sep=comma] {plot_data/appendix/MSLS/MSLS_ResNet50_GeM_480_CL_recall_vs_dist.txt}; \addplot[red, mark size=2pt, thick , mark=o,mark options=solid, style=dashdotted] table [x=p, y=r, col sep=comma] {plot_data/appendix/MSLS/MSLS_ResNet50_GeM_480_GCL_recall_vs_dist.txt}; \addplot[blue, mark size=2pt, thick , mark=square,mark options=solid, style=solid] table [x=p, y=r, col sep=comma] {plot_data/appendix/MSLS/MSLS_ResNet152_avg_480_CL_recall_vs_dist.txt}; \addplot[red, mark size=2pt, thick , mark=square,mark options=solid, style=solid] table [x=p, y=r, col sep=comma] {plot_data/appendix/MSLS/MSLS_ResNet152_avg_480_GCL_recall_vs_dist.txt}; \addplot[blue, mark size=2pt, thick , mark=o,mark options=solid, style=solid] table [x=p, y=r, col sep=comma] {plot_data/appendix/MSLS/MSLS_ResNet152_GeM_480_CL_recall_vs_dist.txt}; \addplot[red, mark size=2pt, thick , mark=o,mark options=solid, style=solid] table [x=p, y=r, col sep=comma] {plot_data/appendix/MSLS/MSLS_ResNet152_GeM_480_GCL_recall_vs_dist.txt}; \end{axis} \end{tikzpicture}\label{fig:msls_dist} \subfloat[]{ \begin{tikzpicture}[thick,scale=1, every node/.style={scale=.8}] \begin{axis} [xlabel=$\psi$, legend pos =south east,grid, height=6cm, width=7.5cm] \addplot[blue, mark size=2pt, thick , mark=square,mark options=solid, style=dashdotted] table [x=p, y=r, col sep=comma] {plot_data/appendix/MSLS/MSLS_ResNet50_avg_480_CL_recall_vs_psi.txt}; \addplot[red, mark size=2pt, thick , mark=square,mark options=solid, style=dashdotted] table [x=p, y=r, col sep=comma] {plot_data/appendix/MSLS/MSLS_ResNet50_avg_480_GCL_recall_vs_psi.txt}; \addplot[blue, mark size=2pt, thick , mark=o,mark options=solid, style=dashdotted] table [x=p, y=r, col sep=comma] {plot_data/appendix/MSLS/MSLS_ResNet50_GeM_480_CL_recall_vs_psi.txt}; \addplot[red, mark size=2pt, thick , mark=o,mark options=solid, style=dashdotted] table [x=p, y=r, col sep=comma] {plot_data/appendix/MSLS/MSLS_ResNet50_GeM_480_GCL_recall_vs_psi.txt}; \addplot[blue, mark size=2pt, thick , mark=square,mark options=solid, style=solid] table [x=p, y=r, col sep=comma] {plot_data/appendix/MSLS/MSLS_ResNet152_avg_480_CL_recall_vs_psi.txt}; \addplot[red, mark size=2pt, thick , mark=square,mark options=solid, style=solid] table [x=p, y=r, col sep=comma] {plot_data/appendix/MSLS/MSLS_ResNet152_avg_480_GCL_recall_vs_psi.txt}; \addplot[blue, mark size=2pt, thick , mark=o,mark options=solid, style=solid] table [x=p, y=r, col sep=comma] {plot_data/appendix/MSLS/MSLS_ResNet152_GeM_480_CL_recall_vs_psi.txt}; \addplot[red, mark size=2pt, thick , mark=o,mark options=solid, style=solid] table [x=p, y=r, col sep=comma] {plot_data/appendix/MSLS/MSLS_ResNet152_GeM_480_GCL_recall_vs_psi.txt}; \end{axis} \end{tikzpicture} \label{fig:msls_psi} } \subfloat{ \begin{minipage}[t]{.65\columnwidth} \vspace{-5.15cm} \begin{tikzpicture}[thick, scale=1, every node/.style={scale=.8}] \begin{axis}[% hide axis, xmin=20, xmax=50, ymin=0, ymax=0.4, height=6cm, width=2cm, legend style={draw=white!15!black,legend cell align=left} ] \addlegendimage{blue, mark size=2pt, thick , mark=square, style=solid,mark options=solid} \addlegendentry{ResNet50-avg-CL}; \addlegendimage{red, mark size=2pt, thick , mark=square, style=solid,mark options=solid} \addlegendentry{ResNet50-avg-GCL (ours)}; \addlegendimage{blue, mark size=2pt, thick , mark=square, style=dashdotted,mark options=solid} \addlegendentry{ResNet152-avg-CL}; \addlegendimage{red, mark size=2pt, thick , mark=square, style=dashdotted,mark options=solid} \addlegendentry{ResNet152-avg-GCL (ours)}; \addlegendimage{blue, mark size=2pt, thick , mark=o, style=solid,mark options=solid} \addlegendentry{ResNet50-GeM-CL}; \addlegendimage{red, mark size=2pt, thick , mark=o, style=solid,mark options=solid} \addlegendentry{ResNet50-GeM-GCL (ours)}; \addlegendimage{blue, mark size=2pt, thick , mark=o, style=dashdotted,mark options=solid} \addlegendentry{ResNet152-GeM-CL}; \addlegendimage{red, mark size=2pt, thick , mark=o, style=dashdotted,mark options=solid} \addlegendentry{ResNet152-GeM-GCL (ours)}; \end{axis} \end{tikzpicture} \end{minipage} } \caption{Comparison of the results achieved by methods trained with GCL and CL for (a) different distance thresholds and (b) different $\psi$ threshold values. GCL-based methods are plotted in red, while CL-based methods are shown in blue.} \label{fig:msls_psi_dist} \end{figure*} \revised{\subsection{Detailed results on RobotCar Seasons v2 and Extended CMU Seasons} We provide results divided by type of environment for the Extended CMU Dataset and display them in Table~\ref{tab:cmu_detailed}. We observed that all models (ours and SoTA ones) tend to reach a higher performance on the urban images. This is logical, as they are all trained on datasets with images depicting mainly urban areas. We also provide detailed results for the RobotCar Seasons v2 dataset, organized by weather and illumination conditions, in Table~\ref{tab:robotcar_extended}. We observe that all methods obtain a higher successful localization rate on day conditions, but our methods tend to outperform the state-of-the-art on the night-time subsets. The MSLS train dataset includes images taken at night, but those are heavily underrepresented, so it is very interesting that GCL based models can localize images under these conditions. } \revised{\subsection{Comparison to Thoma et al~\cite{thoma2020soft}} In Table~\ref{tab:comparisonwiththoma}, we show the results that we obtained on the first version of the CMU dataset, and we compare our performance to the one achieved by the method presented in~\cite{thoma2020soft}. Our method is trained on the MSLS dataset, while the model of~\cite{thoma2020soft} is a NetVLAD model trained on the Oxford RobotCar dataset~\cite{Maddern2017}. We observe that our method generalizes as well as~\cite{thoma2020soft} to this unseen dataset with the same VGG backbone, and significantly better when using a bigger backbone like ResNeXt. It is worth noting that our method uses a simple pooling method (namely GeM~\cite{radenovic2018fine}), while~\cite{thoma2020soft} deploys a VLAD layer.} \begin{figure*}[t] \subfloat[heads]{ \centering \includegraphics[width=.25\textwidth]{figures/appendix/7Scenes/headsprcurve.pdf} }\hspace{-0.5cm} \subfloat[stairs]{ \centering \includegraphics[width=.25\textwidth]{figures/appendix/7Scenes/stairsprcurve.pdf} }\hspace{-0.5cm} \subfloat[pumpkin]{ \centering \includegraphics[width=.25\textwidth]{figures/appendix/7Scenes/pumpkinprcurve.pdf} } \subfloat{ \centering \includegraphics[width=.25\textwidth]{figures/appendix/7Scenes/legendprcurve.pdf} } \setcounter{subfigure}{3} \hspace{-0.5cm}\subfloat[fire]{ \centering \includegraphics[width=.25\textwidth]{figures/appendix/7Scenes/fireprcurve.pdf} }\hspace{-0.5cm} \subfloat[redkitchen]{ \centering \includegraphics[width=.25\textwidth]{figures/appendix/7Scenes/redkitchenprcurve.pdf} }\hspace{-0.5cm} \subfloat[chess]{ \centering \includegraphics[width=.25\textwidth]{figures/appendix/7Scenes/chessprcurve.pdf} }\hspace{-0.5cm} \subfloat[office]{ \centering \includegraphics[width=.25\textwidth]{figures/appendix/7Scenes/officeprcurve.pdf} } \caption{Precision-recall curves achieved on the 7Scenes dataset by ResNet18 and ResNet34 models trained using the Contrastive Loss function (CL, blue lines) and the proposed Generalized Contrastive loss (GCL, red lines) function.} \label{fig:7scenes_pr} \end{figure*} \begin{table*}[t!] \centering \caption{Median translation and rotation errors (in cm and degrees, respectively) on the 7Scenes dataset using the descriptors computed using the models trained with the binary Contrastive Loss and the Generalized Contrastive Loss for retrieval and InLoc for localization.} \label{tab:7scenes_loc} \setlength\tabcolsep{2.5pt} \begin{tabular*}{\textwidth}{@{}l@{\extracolsep{\fill}}llllllll@{}} \toprule \textbf{Model} & \textbf{heads} & \textbf{stairs} & \textbf{pumpkin} & \textbf{fire} & \textbf{redkitchen} & \textbf{office} & \textbf{chess} & \textbf{Mean} \\ \midrule NetVLAD-DensePE & 2cm 1.16$\degree$ & 9cm 2.47$\degree$ & 5cm 1.55$\degree$ & 3cm 1.07$\degree$ &4cm 1.31$\degree$ & 3cm 1.05$\degree$ & 3cm 1.05$\degree$& 4.14cm 1.38$\degree$\\ ResNet34-CL & 2.98cm 2.44$\degree$ & 36.03cm 4.28$\degree$ & 7.12cm 1.97$\degree$ & 5.87cm 2.39$\degree$ & 6.53cm 2.12$\degree$ & 5.62cm 1.85$\degree$ & 6.01cm 1.99$\degree$ & 10.02cm 2.43$\degree$ \\ ResNet34-GCL & 2.53cm 2.3$\degree$ & 32.13cm 3.9$\degree$ & 6.4cm 1.95$\degree$ & 5.13cm 2.11$\degree$ & 5.38cm 2.0$\degree$ & 5.16cm 1.7$\degree$ & 5.66cm 1.93$\degree$ & 8.91cm 2.27$\degree$ \\ \bottomrule \end{tabular*} \end{table*} \subsection{Performance for different ground truths} We performed an evaluation of the performance that the models that we train achieved when varying the ground truth threshold, i.e. when applying different cut values on the criteria that define two images as similar or not. We report results on the MSLS validation dataset. First, we consider the distance, computed using the GPS coordinates associated to image pairs, between the location from where the images were taken and define a threshold on this value. For instance, we consider as similar all the image pairs that were taken from places with a distance lower than $D$, and vary $D$ between $5$ meters to $50$ meters. We report the result in Fig.~\ref{fig:msls_dist}. An image is considered as correctly identified if at least one of the top-5 retrieved images is at a distance smaller than the considered threshold. Furthermore, we consider the defined graded similarity $\psi$ and threshold it with values between $0$ and $0.9$. An image is considered as correctly identified if at least one of the top-5 retrieved images is labeled with a similarity greater than the considered threshold. We report the results in Fig.~\ref{fig:msls_psi_dist}. In both cases, the models trained using the GCL function are more robust than those trained using the CL function to variations of the criteria and values used to establish the ground truth similarity between image pairs. \subsection{Extra results on 7Scenes} \textbf{Precision-recall curve.} We report the precision recall curves that we obtained on the 7Scenes dataset in Fig.~\ref{fig:7scenes_pr}. The models trained with the GCL function (red lines) consistently outperform their counterpart trained with the CL function (blue lines), when they deploy both the ResNet18 and ResNet34 backbones. The results are consistent for all the sub-sets of the 7Scenes dataset. The case of the \emph{chess} scene is particularly interesting, for which the ResNet34-GCL model achieved near-perfect performance. \revised{ \textbf{Localization. } We tested the impact that a model trained with the GCL function and graded similarity has on the performance of a camera localization pipeline. We compared it to the case when the same model trained with the original binary Contrastive Loss function is used for the image retrieval task, and report the localization error that we obtained in Table~\ref{tab:7scenes_loc}. This experiment is meant only to demonstrate that the general expectation of better retrieval results contribute to better localization' is satisfied by the improved retrieval results achieved using the proposed GCL. For this experiment, we employed the InLoc algorithm~\cite{taira2018inloc}, using our learned representations with the ResNet34 backbone for the retrieval step. The images retrieved using the representation learned with GCL consistently led to an improvement of the localization accuracy w.r.t. the case in which the CL function is used. The enhanced performance of the retrieval task has a positive effect on the precision of localization algorithms. We also report the results of the original InLoc pipeline, based on and optimized to work with a NetVLAD backbone. While the GCL function contributes indirectly to better localization w.r.t. its binary CL counterpart, it requires more work to be effectively embedded in a localization pipeline. } \begin{comment} \subsection{Performance for smaller input images} \begin{table}[t] \centering \caption{Additional results on the MSLS test set for images of input size 224x224.} \label{tab:msls-224} \setlength\tabcolsep{4pt} \begin{tabular}{@{}lllllcc@{}} \toprule \textbf{\textbf{Backbone}} & \textbf{\textbf{Input size}} & \textbf{\textbf{Pooling}} & \textbf{\textbf{Loss}} & \textbf{\textbf{R@1}} & \textbf{\textbf{R@5}} & \textbf{\textbf{R@10}} \\ \midrule \multirow{10}{*}{ResNet50} & \multirow{2}{*}{224x224} & \multirow{2}{*}{avg} & CL & 15.6 & 27.8 & 34.9 \\ & & & GCL & 26.1 & 42 & 48.5 \\ \cmidrule(l){2-7} & \multirow{2}{*}{480x640} & \multirow{2}{*}{avg} & CL & 24.9 & 39.0 & 44.6 \\ & & & GCL & 35.8 & 52.0 & 59.0 \\ \cmidrule(l){2-7} & \multirow{4}{*}{224x224} & \multirow{4}{*}{GeM} & TL~\cite{warburg2020bayesian} & 37.2 & 52.2 & 58.2 \\ & & & Bayes TL~\cite{warburg2020bayesian} & 36.6 & 51.3 & 57.4 \\ & & & CL & 17.3 & 31.8 & 37.9 \\ & & & GCL & 28.7 & 44.1 & 50.3 \\ \cmidrule(l){2-7} & \multirow{2}{*}{480x640} & \multirow{2}{*}{GeM} & CL & 29.7 & 44.0 & 50.7 \\ & & & GCL & 43.3 & 59.1 & 65.0 \\ \midrule \multirow{8}{*}{ResNet152} & \multirow{2}{*}{224x224} & \multirow{2}{*}{avg} & CL & 18.9 & 32.2 & 38.2 \\ & & & GCL & 30.8 & 44.9 & 52.8 \\ \cmidrule(l){2-7} & \multirow{2}{*}{480x640} & \multirow{2}{*}{avg} & CL & 29.7 & 44.2 & 51.3 \\ & & & GCL & 43.5 & 59.2 & 65.2 \\ \cmidrule(l){2-7} & \multirow{2}{*}{224x224} & \multirow{2}{*}{GeM} & CL & 22.5 & 37.6 & 43.8 \\ & & & GCL & 32.1 & 47.3 & 54.3 \\ \cmidrule(l){2-7} & \multirow{2}{*}{480x640} & \multirow{2}{*}{GeM} & CL & 34.1 & 50.8 & 56.8 \\ & & & GCL & \textbf{45.7} & \textbf{62.3} & \textbf{67.9} \\ \bottomrule \end{tabular} \end{table} Complex models are often trained using lower resolution images, in order to better use the hardware resources used for the training process within their physical limitations. We report the results that we achieved on the MSLS test set by training models with the CL and GCL function on images of resolution $224\times224$. We achieved lower results than other methods that use the triplet or Bayes triplet loss function. Although the GCL function contributes to a consistent improvement of performance w.r.t. when the CL function is used, we attribute the decrease of performance of our methods to the less and lower resolution information that we can exploit to learn robust representation for image similarity. However, as the memory requirements of our method are much lower than those of other more complicate methods, and we do not need to perform a memory-intensive mining process to select training pairs, we can train our methods using bigger images and use large batches of images (up to 512 images on an Nvidia V100 GPU). \end{comment} \section{Field-of-View overlap} We studied the relation among translation distance, rotation difference and the resulting FoV overlap measure. For that, we selected a subset of pairs of the MSLS training set and measured how the value of the FoV overlap varies with respect to the position and orientation difference of the image pairs. In Fig.~\ref{fig:supp_fov_tr}, we plot the relationship between the translation distance and the value of the FoV overlap. We observed a somewhat linear relationship between increasing translation distance and decreasing FoV overlap. Moreover, many of the image pairs with FoV overlap of approximately 50\% were taken at a distance of about 25m. The variance that we observed in Fig.~\ref{fig:supp_fov_tr} can be attributed to the changes in orientation. Indeed, the relation between FoV overlap and orientation difference is less clear (see Fig.~\ref{fig:supp_fov_rot}). However, in general, the pairs with smaller orientation distance tend to have a higher FoV overlap. We plot the relation of the FoV overlap with both translation and orientation distance in a 3-dimensional plane in Fig.~\ref{fig:supp_fov_3d}, and as a heatmap in Fig.~\ref{fig:supp_fov_colormap}. Rotation and translation distance jointly influence the FoV overlap: the smaller the translation and orientation distance, the higher the similarity. Furthermore, as one of the distances has a higher value, the computer FoV overlap decreases, resulting in a lower annotated ground truth similarity. } \begin{figure}[!t] \subfloat[]{\centering \includegraphics[width=.45\columnwidth]{figures/appendix/fov/fov_tr.pdf} \label{fig:supp_fov_tr} }~\subfloat[]{\centering \includegraphics[width=.45\columnwidth]{figures/appendix/fov/fov_rot.pdf} \label{fig:supp_fov_rot} }\\ \subfloat[]{\centering \includegraphics[width=.45\columnwidth]{figures/appendix/fov/fov_3d.pdf} \label{fig:supp_fov_3d} }~\subfloat[]{\centering \includegraphics[width=.45\columnwidth]{figures/appendix/fov/fov_colormap.pdf} \label{fig:supp_fov_colormap} } \caption{Relation of 2D FoV overlap with translation and orientation distance. This data is computed from a subset of the MSLS training set.} \label{fig:supp_fov} \end{figure}
{'timestamp': '2022-01-25T02:35:00', 'yymm': '2103', 'arxiv_id': '2103.06638', 'language': 'en', 'url': 'https://arxiv.org/abs/2103.06638'}
arxiv
\section{Introduction} Task-oriented dialogue systems help users achieve their goals in specific domains via conversation. In multi-domain dialogues, the goals are not limited to just one domain; instead, the domain of the conversation changes as the conversation progresses. Thus, the dialogue systems should catch the domain of the current conversation and track the flow of the entire dialogue. Typical task-oriented dialogue systems use a pipeline architecture that consists of four sequential modules of natural language understanding (NLU), dialogue state tracking (DST), dialogue policy (POL), and natural language generation (NLG). The NLU module extracts important information from the conversations. The DST module tracks the belief state representing constraints on user goals. Furthermore, the output of the DST module is used to query a task-specific database (DB). The POL module determines the next system actions to generate appropriate responses or call APIs. The NLG module generates system responses based on system actions. Recently, researchers have attempted to use methods based on neural dialogue systems, which are trainable in an end-to-end manner. They use the entire dialogue history accumulated through multiple conversational turns for abundant contextual information. However, as the conversation progresses, the dialogue history becomes longer, increasing memory usage and computational costs. In this paper, we propose the \textbf{Do}main State \textbf{T}racking for a \textbf{S}implified Dialogue System (DoTS), which is an efficient multi-domain task-oriented dialogue system with a simplified input context using the domain state. The novelty of our approach is that DoTS only uses a current user statement instead of the entire dialogue history. To prevent any loss of contextual information, DoTS uses the domain state for the input context, so it can track the flow of conversations from the perspective of domains in a multi-domain dialogue. By removing the entire dialogue history, DoTS uses a memory that is almost constant and less regardless of the length of the conversations; therefore, it can be stably and efficiently trained using long conversations. DoTS achieves state-of-the-art results without a dialogue history on the standard benchmark datasets MultiWOZ 2.0 and MultiWOZ 2.1, improving the inform rate by 1.09 points and success rate by 1.24 points on MultiWOZ 2.0, and the inform rate by 1.65 points and success rate by 3.68 points on MultiWOZ 2.1. These results show that DoTS performs well without using the entire dialogue history, and that tracking the domain state is helpful for multi-domain dialogue systems. \begin{figure*} \centering \includegraphics[width=0.80\textwidth]{figure1} \caption{Overview of DoTS. The context encoder is shared between the belief state, system action, and system response. $\oplus$ indicates concatenation.} \label{figure1} \end{figure*} \section{Related Work} Existing end-to-end task-oriented dialogue systems consist of NLU, DST, POL, and NLG modules using the entire dialogue history \citep{mehri2019structured, zhang2020task, le2020uniconv, zhang2020probabilistic}. Recent studies have attempted to use pre-trained language models, such as BERT \citep{devlin2019bert} and GPT-2 \citep{radfordlanguage}, in task-oriented dialogue systems \citep{hosseini2020simple, peng2020soloist}. \citet{peng2020soloist} demonstrated a dialogue system as a large-scale language model instead of a neural pipeline. \section{Method} In this section, we describe DoTS, including the architecture, domain state tracking, and context representation. Figure \ref{figure1} presents an overview of DoTS. \begin{figure*} \centering \includegraphics[width=0.80\textwidth]{figure2} \caption{$C^R_t$, the input context for response generation. $D_t$ and $B_t$ involve all domains and all slots, respectively. $DB_t$ includes the number of matched entries of only the activated domains.} \label{figure2} \end{figure*} \subsection{Neural Pipeline of DoTS} DoTS consists of a context encoder, domain state tracker, belief tracker, DB operator, action generator, and response generator. The BERT-based context encoder extracts important information from the input context and generate a context output from \texttt{[CLS]} special token. The encoder is shared between the belief state, system action, and system response, and it receives a different input context for each step to calculate the context output. The entire DoTS process is as follows: \begin{enumerate} \item The encoder makes context output $O^B_t$ from input context $C^B_t$ that comprises current user utterance $U_t$, previous domain state $D_{t-1}$, and belief state $B_{t-1}$. \begin{align} C^B_t &= U_t \oplus D_{t-1} \oplus B_{t-1} \\ O^B_t &= \texttt{ContextEncoder}(C^B_t) \end{align} \item Based on $O^B_t$, the domain state tracker classifies new domain state $D_t$, and the belief tracker generates new belief state $B_t$. \begin{align} D_t &= \texttt{DomainStateTracker}(O^B_t) \\ B_t &= \texttt{BeliefTracker}(O^B_t) \end{align} \item The DB operator queries the task-specific DB based on $B_t$ and obtains DB result $DB_t$, indicating the number of matched entries. \begin{align} DB_t &= \texttt{DBOperator}(B_t) \end{align} \item The encoder makes context output $O^A_t$ from new input context $C^A_t$ that contains $D_t$ and $B_t$ instead of $D_{t-1}$ and $B_{t-1}$, respectively. \begin{align} C^A_t &= U_t \oplus D_t \oplus B_t \oplus DB_t \\ O^A_t &= \texttt{ContextEncoder}(C^A_t) \end{align} \item The action generator generates system action $A_t$ based on $O^A_t$. \begin{align} A_t &= \texttt{ActionGenerator}(O^A_t) \end{align} \item The encoder makes context output $O^R_t$ from new input context $C^R_t$ that additionally contains $A_t$. \begin{align} C^R_t &= U_t \oplus D_t \oplus B_t \oplus DB_t \oplus A_t \\ O^R_t &= \texttt{ContextEncoder}(C^R_t) \end{align} \item The response generator generates system response $R_t$ based on $O^R_t$. \begin{align} R_t &= \texttt{ResponseGenerator}(O^R_t) \end{align} \end{enumerate} We represent the domain state, belief state, DB result, and system action in the form of a sequence of tokens. $\oplus$ indicates concatenation of the sequences, and $t$ indicates the index of conversational turn. \subsection{Domain State Tracking} DoTS tracks the domain state in addition to the belief state. The domain state consists of binary values indicating whether domains are activated or not in the current conversation. The domain state tracker classifies the current domain state based on the previous domain state and the current user utterance. The domain state contains the binary values of all domains because it has one or more activated domains. To represent domain state $D_t$ in the form of a sequence of tokens, we substitute the binary values with special tokens \texttt{[ON]} and \texttt{[OFF]}. Furthermore, domains such as \texttt{hotel} and \texttt{taxi} are represented as special tokens. Thus, the domain state is represented as follows: $$D_t = \texttt{[hotel][ON]...[taxi][OFF]}$$ The domain state enables DoTS to track the flow of the entire dialogue from the perspective of domains. Thus, tracking the domain state can compensate for the loss of contextual information due to neglecting the entire dialogue history. \begin{table*} \centering \begin{tabular}{l|c|ccc} \Xhline{5\arrayrulewidth} Model & History & Inform$\uparrow$ & Success$\uparrow$ & BLEU$\uparrow$ \\ \hline SFN+RL \citep{mehri2019structured} & \checkmark & 73.80 & 58.60 & \textbf{16.88} \\ DAMD+augmentation \citep{zhang2020task} & \checkmark & 76.30 & 60.40 & 16.60 \\ SimpleTOD \citep{hosseini2020simple} & \checkmark & 84.40 & 70.10 & 15.01 \\ SOLOIST \citep{peng2020soloist} & \checkmark & 85.50 & 72.90 & 16.54 \\ \hline DoTS & & \textbf{86.59} & \textbf{74.14} & 15.06 \\ DoTS (w/o Domain State) & & 84.30 & 68.70 & 15.29 \\ \Xhline{5\arrayrulewidth} \end{tabular} \caption{End-to-end evaluation on the MultiWOZ 2.0 test set.} \label{table1} \end{table*} \begin{table*} \centering \begin{tabular}{l|c|ccc} \Xhline{5\arrayrulewidth} Model & History & Inform$\uparrow$ & Success$\uparrow$ & BLEU$\uparrow$ \\ \hline UniConv \citep{le2020uniconv} & \checkmark & 72.60 & 62.90 & \textbf{19.80} \\ LABES-S2S \citep{zhang2020probabilistic} & \checkmark & 78.07 & 67.06 & 18.13 \\ SimpleTOD \citep{hosseini2020simple} & \checkmark & 85.00 & 70.50 & 15.23 \\ \hline DoTS & & \textbf{86.65} & \textbf{74.18} & 15.90 \\ DoTS (w/o Domain State) & & 84.36 & 68.74 & 14.86 \\ \Xhline{5\arrayrulewidth} \end{tabular} \caption{End-to-end evaluation on MultiWOZ 2.1 test set.} \label{table2} \end{table*} \subsection{Context Representation} Input contexts $C^B_t$, $C^A_t$, and $C^R_t$ are sequences of tokens, including some special tokens. Figure \ref{figure2} presents an example of the input context for response generation, $C^R_t$. For the BERT-based encoder, we use the special tokens \texttt{[CLS]}, which represents the entire sequence, and \texttt{[SEP]}, which separates the sequence into a user utterance and other information. \texttt{-} is the delimiter, which distinguishes the domain, slot, value, and system action. \section{Experiments} \subsection{Datasets} We used the well-known benchmark datasets, MultiWOZ 2.0 \citep{budzianowski2018multiwoz} and MultiWOZ 2.1 \citep{eric2020multiwoz}. These datasets contain approximately 8,000 training, 1,000 validation, and 1,000 test sets, including annotations for end-to-end dialogue systems. MultiWOZ 2.1 is an improved version of MultiWOZ 2.0, where some annotation errors have been corrected. The evaluation metrics for end-to-end systems are the inform rate, success rate, and BLEU score. The inform rate indicates how many entries provided by the system meet the goals. The success rate additionally measures how many user requests are provided by the system. The BLEU score measures the similarity between the generated response and the true response in the datasets. \begin{figure} \centering \includegraphics[width=0.95\columnwidth]{figure3} \caption{Lengths of the input context of DoTS and entire dialogue history for the number of conversational turns in MultiWOZ.} \label{figure3} \end{figure} \subsection{Training Details} We used BERT-base-uncased\footnote{https://github.com/huggingface/transformers} for the context encoder, a fully connected layer for the domain state tracker, and one-layer GRUs \citep{cho2014properties} for the belief tracker, action generator, and response generator. We fine-tuned the pre-trained BERT and trained other modules from scratch. We simultaneously trained all the modules by minimizing the cross entropy losses using an Adam optimizer \citep{DBLP:journals/corr/KingmaB14} with a learning rate of $3\times10^{-5}$, $\beta_1 = 0.9$, and $\beta_2 = 0.999$. We applied an early stopping method; that is, we stopped the training when the sum of inform rate and success rate does not improve over five epochs. \begin{figure} \centering \includegraphics[width=0.95\columnwidth]{figure4} \caption{Memory usage of each language model based on input length.} \label{figure4} \end{figure} \subsection{Results} The evaluation results on the MultiWOZ 2.0 and MultiWOZ 2.1 test sets, as shown in Table \ref{table1} and Table \ref{table2}, respectively, show that DoTS performs well with only the simplified input context, without using the entire dialogue history. The results also show that tracking the domain state is meaningful for multi-domain dialogue systems. We report the means across 10 runs due to randomness. We conducted another experiment to confirm that the input context of DoTS is simpler than the entire dialogue history. Figure \ref{figure3} shows a comparison of the lengths for the number of turns. The input context of DoTS has an almost constant length regardless of the number of turns. On the other hand, the dialogue history becomes increasingly longer as the number of turns increases. Figure \ref{figure4} shows a comparison of the memory usage of three language models based on input length. They have 12 layers with hidden size of 768, however, GPT-2 has larger vocabulary. Same increment of input length more increases memory usage on larger model. The memory usage indicates allocated amount of memory on GPU, except the model size, after an input with batch size 8 passes through the language models. \begin{figure} \centering \includegraphics[width=0.95\columnwidth]{figure5} \caption{Example of dialogue.} \label{figure5} \end{figure} \section{Discussion} Recently, using a pre-trained language model has been a trend in NLP field and has improved performances on various tasks including task-oriented dialogue system. However, the pre-trained language models such as BERT and GPT-2 have many parameters and accelerate training cost. Therefore, it is important to summarize input context on large-scale models. However, summarizing some long text generally causes a loss of contextual information. Thus, we attempted to use domain state and belief state instead of entire history. Belief state indicates the constraints of user accumulated through multiple turns, therefore, it has the summarized information from dialogue history. However, belief state is not perfect summary of history. Figure \ref{figure5} shows an example of dialogue. In the above dialogue, the system should look up DB and find a cheap restaurant in east area. However, the system cannot distinguish that the \texttt{cheap} means cheap restaurant or cheap hotel in multi domain setting without the previous utterances. By tracking domain state and using it as a part of input context in addition to belief state, the system can follow the flow of dialogue from domain perspective and tackle the above scenario without previous history. \section{Conclusion} In this paper, we presented DoTS, a simplified task-oriented dialogue system with domain state tracking. Experimental results demonstrate that task-oriented dialogue systems perform well without the entire dialogue history, and tracking the domain state is helpful for multi-domain dialogue systems. Using large networks has recently become a trend in natural language processing (NLP) tasks; therefore, large memory and computational costs are required. Thus, the importance of efficiency has increased. We hope that DoTS can inspire the NLP community to explore new, more efficient methods for task-oriented dialogue systems. DoTS uses some special tokens that are important for specific domains; therefore, it is difficult to transfer it to another domain. As part of our future work, we plan to explore a more universal dialogue system that can be easily transferred to other domains.
{'timestamp': '2021-03-12T02:22:39', 'yymm': '2103', 'arxiv_id': '2103.06648', 'language': 'en', 'url': 'https://arxiv.org/abs/2103.06648'}
arxiv
\section{Introduction} \label{illusion} Let ${\cal F}$ be a finite non-empty collection of non-empty graphs. In the \textsc{$\mathcal{F}$-M-Deletion} (resp. \textsc{$\mathcal{F}$-TM-Deletion}) problem, we are given a graph $G$ and an integer $k$, and the objective is to decide whether there exists a set $S \subseteq V(G)$ with $|S| \leq k$ such that $G \setminus S$ does not contain any of the graphs in ${\cal F}$ as a minor (resp. topological minor). Instantiations of these problems correspond to several well-studied problems. For instance, the cases ${\cal F}= \{K_2\}$, ${\cal F}= \{K_3\}$, and ${\cal F}= \{K_5,K_{3,3}\}$ of \textsc{$\mathcal{F}$-M-Deletion} (or \textsc{$\mathcal{F}$-TM-Deletion}) correspond to \textsc{Vertex Cover}, \textsc{Feedback Vertex Set}, and \textsc{Vertex Planarization}, respectively. We are interested in the parameterized complexity of both problems when the parameter is the treewidth of the input graph. By Courcelle's theorem~\cite{Courcelle90}, \textsc{$\mathcal{F}$-M-Deletion} \textsc{$\mathcal{F}$-TM-Deletion} can be solved in time $f({\sf{tw}})\cdot n^{\mathcal{O}(1)}$ on $n$-vertex graphs with treewidth at most ${\sf{tw}}$, where $f$ is some computable function. Our objective is to determine, for a fixed collection ${\cal F}$, which is the {\sl smallest} such function $f$ that one can (asymptotically) hope for, subject to reasonable complexity assumptions. This line of research has attracted some attention in the parameterized complexity community during the last years. For instance, \textsc{Vertex Cover} is easily solvable in time $2^{\mathcal{O}({\sf{tw}})}\cdot n^{\mathcal{O}(1)}$, called \emph{single-exponential}, by standard dynamic-programming techniques, and no algorithm with running time $2^{o({\sf{tw}})}\cdot n^{\mathcal{O}(1)}$ exists, unless the Exponential Time Hypothesis ({\sf ETH}\xspace)\footnote{The {\sf ETH}\xspace states that 3-\textsc{SAT} on $n$ variables cannot be solved in time $2^{o(n)}$; see~\cite{ImpagliazzoP01} for more details.} fails~\cite{ImpagliazzoP01}. For \textsc{Feedback Vertex Set}, standard dynamic programming techniques give a running time of $2^{\mathcal{O}({\sf{tw}} \cdot \log {\sf{tw}})}\cdot n^{\mathcal{O}(1)}$, while the lower bound under the {\sf ETH}\xspace~\cite{ImpagliazzoP01} is again $2^{o({\sf{tw}})}\cdot n^{\mathcal{O}(1)}$. This gap remained open for a while, until Cygan et al.~\cite{CyganNPPRW11} presented an optimal algorithm running in time $2^{\mathcal{O}({\sf{tw}})}\cdot n^{\mathcal{O}(1)}$, introducing the celebrated \emph{Cut{\sl \&}Count} technique. This article triggered several other techniques to obtain single-exponential algorithms for so-called \emph{connectivity problems} on graphs of bounded treewidth, mostly based on algebraic tools~\cite{BodlaenderCKN15,FominLPS16}. Concerning \textsc{Vertex Planarization}, Jansen et al.~\cite{JansenLS14} presented an algorithm of time $2^{\mathcal{O}({\sf{tw}} \cdot \log {\sf{tw}})}\cdot n^{\mathcal{O}(1)}$ as a subroutine in an {\sf FPT}-algorithm parameterized by $k$. Marcin Pilipczuk~\cite{Pili15} proved that this running time is {\sl optimal} under the {\sf ETH}\xspace. This lower bound was acheived by using the framework introduced by Lokshtanov et al.~\cite{permuclique,LokshtanovMS11} for obtaining superexponential lower bounds (namely, of the form $2^{\Omega(k \cdot \log k)}\cdot n^{\mathcal{O}(1)}$, in particular for problems parameterized by treewidth), which has proved very successful in recent years~\cite{CyganNPPRW11,Pili15,BasteS15}. We also use this framework in the current article. \newpage \noindent \textbf{Our results and techniques}. We present lower bounds under the {\sf ETH}\xspace for \textsc{$\mathcal{F}$-M-Deletion} and \textsc{$\mathcal{F}$-TM-Deletion} parameterized by treewidth, several of them being tight. We first prove that for any connected\footnote{A \emph{connected} collection $\mathcal{F}$ is a collection containing only connected graphs of size at least two.} $\mathcal{F}$, neither \textsc{$\mathcal{F}$-M-Deletion} nor \textsc{$\mathcal{F}$-TM-Deletion} can be solved in time $2^{o({\sf{tw}})}\cdot n^{\mathcal{O}(1)}$, even if the input graph $G$ is planar (cf.~Theorem~\ref{temporis} and Corollary~\ref{patterns}). The main contribution of this article consists of superexponential lower bounds for a number of collections $\mathcal{F}$, which we proceed to describe. Let $\mathcal{C}$ be the set of all connected graphs that contain a block (i.e., a biconnected component) with at least five edges, let $\mathcal{Q}$ be the set containing $P_5$ and all connected graphs that are {\sl not} minors of the {\sf banner}\xspace (that is, the graph consisting of a $C_4$ plus a pendent edge), and let $\mathcal{S} = \{K_{1,i} \mid i \geq 4 \}$. We prove that, assuming the {\sf ETH}\xspace, \begin{itemize} \item for every finite non-empty subset $\mathcal{F} \subseteq \mathcal{C}$, neither \textsc{$\mathcal{F}$-M-Deletion} nor \textsc{$\mathcal{F}$-TM-Deletion} can be solved in time $2^{o({\sf{tw}} \log {\sf{tw}})}\cdot n^{\mathcal{O}(1)}$ (cf.~Theorem~\ref{hardgene}), \item for every $H \in \mathcal{Q}$, \textsc{$\{H\}$-M-Deletion} cannot be solved in time $2^{o({\sf{tw}} \log {\sf{tw}})}\cdot n^{\mathcal{O}(1)}$ (cf.~Theorem~\ref{hardminor}), and \item for every $H \in \mathcal{Q} \setminus \mathcal{S}$, \textsc{$\{H\}$-TM-Deletion} cannot be solved in time $2^{o({\sf{tw}} \log {\sf{tw}})}\cdot n^{\mathcal{O}(1)}$ (cf.~Theorem~\ref{hardtminor}). \end{itemize} \medskip The general lower bound of $2^{o({\sf{tw}})}\cdot n^{\mathcal{O}(1)}$ for connected collections is based on a simple reduction from \textsc{(Planar) Vertex Cover}. The superexponential lower bounds, namely $2^{o({\sf{tw}} \cdot \log {\sf{tw}})}\cdot n^{\mathcal{O}(1)}$, are based on the ideas presented by Bonnet et al.~\cite{BonnetBKM-IPEC17} for generalized feedback vertex set problems. We provide two hardness results that apply to different families of collections $\mathcal{F}$, both based on a general framework described in Section~\ref{supexpgencons}, consisting of a reduction from the {\sc $k\times k$ Permutation Independent Set} problem introduced by Lokshtanov et al.~\cite{permuclique}. Namely, we prove, in Theorem~\ref{hardgene} (applying to both the minor and topological minor versions), the lower bound when $\mathcal{F}$ is any finite non-empty subset of all connected graphs that contain a block with at least five edges. We then prove, in Theorem~\ref{hardminor} (for minors) and Theorem~\ref{hardtminor} (for topological minors), the lower bound when $\mathcal{F}$ contains a single graph $H$ that is either $P_5$ or is not a minor of the ${\sf banner}\xspace$, with the exception of $K_{1,i}$ mentioned above for the topological minor version. The proofs of the latter two theorems are considerably longer, as we need to distinguish several cases according to certain properties of the graph $H$ (cf. Lemma~\ref{cycletwocut} up to Lemma~\ref{crickbistm}). We would like to mention that in previous versions of this article (in particular, in the conference version presented in~\cite{BasteST17}), we presented another family of reductions inspired by a reduction of Pilipczuk~\cite{Pili15} for \textsc{Vertex Planarization}, that is, for $\mathcal{F} = \{K_5, K_{3,3}\}$. Afterwards, we found a more general unifying reduction along the lines of Bonnet et al.~\cite{BonnetBKM-IPEC17}, which is the one we present here. This reduction generalizes the hardness results presented in~\cite{BasteST17} and in~\cite{BasteST18} (also inspired by~\cite{BonnetBKM-IPEC17}, and that can be seen as a weaker version of the current reduction), as well as the lower bound of Pilipczuk~\cite{Pili15}, which is a corollary of one of our hardness results, namely Theorem~\ref{hardgene}. \medskip \noindent\textbf{Results in other articles of the series and discussion}. In the first article of this series~\cite{monster1}, we show, among other results, that for every connected $\mathcal{F}$ containing at least one planar graph (resp. subcubic planar graph), \textsc{$\mathcal{F}$-M-Deletion} (resp. \textsc{$\mathcal{F}$-TM-Deletion}) can be solved in time $2^{\mathcal{O}({\sf{tw}} \cdot \log {\sf{tw}})}\cdot n^{\mathcal{O}(1)}$. In the second article of this series~\cite{monster2}, we provide single-exponential algorithms for \textsc{$\{H \}$-M-Deletion} for all the graphs $H$ for which the superexponential lower bounds given in this article do not apply, namely those on the left of Figure~\ref{shifting}: $P_3$, $P_4$, $C_4$, the {\sf claw}\xspace, the {\sf paw}\xspace, the {\sf chair}\xspace (sometimes also called \emph{fork} in the literature), and the {\sf banner}\xspace. Note that the cases $H = P_2$~\cite{ImpagliazzoP01,CyganFKLMPPS15}, $H = P_3$~\cite{P3-cover,P3-cover-improved}, and $H = C_3$~\cite{CyganNPPRW11,BodlaenderCKN15} were already known (nevertheless, for completeness we provide in~\cite{monster2} a simple algorithm when $H = P_3$). In the fourth article of this series~\cite{BasteST20-SODA} (whose full version is~\cite{SODA-arXiv}), we present an algorithm for \textsc{$\mathcal{F}$-M-Deletion} in time $\mathcal{O}^*(2^{O({\sf{tw}} \cdot \log {\sf{tw}})})$ for {\sl any} collection $\mathcal{F}$. \begin{figure}[h!] \begin{center \includegraphics[width=.87\textwidth]{small-graphs-new.pdf} \end{center}\vspace{-.25cm} \caption{Classification of the complexity of \textsc{$\{H\}$-M-Deletion} for all connected simple graphs $H$ with $2 \leq |V(H)|\leq 5$: for the nine graphs on the left (resp. 21 graphs on the right, and all the larger ones), the problem is solvable in time $2^{\Theta({\sf{tw}})} \cdot n^{\mathcal{O}(1)}$ (resp. $2^{\Theta({\sf{tw}} \cdot \log {\sf{tw}})} \cdot n^{\mathcal{O}(1)}$). For \textsc{$\{H\}$-TM-Deletion}, $K_{1,4}$ should be on the left. This figure also appears in~\cite{monster2}.} \label{shifting} \vspace{.35cm} \end{figure} The lower bounds presented in this article, together with the algorithms given in~\cite{monster2,SODA-arXiv,BasteST20-SODA}, cover all the cases of \textsc{$\mathcal{F}$-M-Deletion} where $\mathcal{F}$ contains a single connected graph, as discussed in Section~\ref{secsupexp}. Namely, we obtain the following theorem. \begin{theorem} Let $H$ be a connected graph of size at least two. Then the \textsc{$\{H\}$-M-Deletion} problem can be solved in time \begin{itemize} \item $2^{\Theta({\sf{tw}} )}\cdot n^{\mathcal{O}(1)}$, if $H$ is a minor of the {\sf banner}\xspace that is different from $P_5$, and \item $2^{\Theta({\sf{tw}} \cdot \log {\sf{tw}})}\cdot n^{\mathcal{O}(1)}$, otherwise. \end{itemize} \end{theorem} Note that the graphs $H$ described in the first item can be equivalently characterized as those that can be obtained by the {\sf chair}\xspace or the {\sf banner}\xspace by contracting edges. In the above statement, we use the $\Theta$-notation to indicate that these algorithms are {\sl optimal} under the {\sf ETH}\xspace. This dichotomy is depicted in Figure~\ref{shifting}, containing all connected graphs $H$ with $2 \leq |V(H)| \leq 5$; note that if $|V(H)| \geq 6$, then $H$ is not a minor of the {\sf banner}\xspace, and therefore the second item above applies. See~\cite{monster2} for a discussion about the role played by the {\sf banner}\xspace in this dichotomy. The single-exponential algorithms given in~\cite{monster2} also apply to \textsc{$\{H \}$-TM-Deletion} for which, in addition, we provide a single-exponential algorithm when $H=K_{1,i}$ for every $i \geq 1$. By Theorem~\ref{hardminor}, a single exponential-algorithm for \textsc{$\{K_{1,i}\}$-M-Deletion} when $i \geq 4$ is unlikely to exist. To the best of our knowledge, this is the first example of a collection $\mathcal{F}$ for which the complexity of \textsc{$\mathcal{F}$-M-Deletion} and \textsc{$\mathcal{F}$-TM-Deletion} differ. \medskip \noindent \textbf{Organization of the paper}. In Section~\ref{banality} we give some preliminaries. In Section~\ref{struggle} we present the single-exponential lower bound for any connected $\mathcal{F}$, and in Section~\ref{secsupexp} the superexponential lower bounds. We conclude the article in Section~\ref{upheaval} with some open questions for further research. \section{Preliminaries} \label{banality} In this section we provide some preliminaries to be used in the following sections. \bigskip \noindent \textbf{Sets, integers, and functions.} We denote by $\mathbb{N}$ the set of every non-negative integer and we set $\mathbb{N}^+=\mathbb{N}\setminus\{0\}$. Given two integers $p$ and $q$, the set $\intv{p,q}$ refers to the set of every integer $r$ such that $p \leq r \leq q$. Moreover, for each integer $p \geq 1$, we set $\mathbb{N}_{\geq p} = \Bbb{N}\setminus\intv{0,p-1}$. In the set $\intv{1,k}\times \intv{1,k}$, a \emph{row} is a set $\{i\} \times \intv{1,k}$ and a \emph{column} is a set $\intv{1,k} \times \{i\}$ for some $i\in \intv{1,k}$. We use $\emptyset$ to denote the empty set and $\varnothing$ to denote the empty function, i.e., the unique subset of $\emptyset\times\emptyset$. Given a function $f:A\to B$ and a set $S$, we define $f|_{S}=\{(x,f(x))\mid x\in S\cap A\}$. Moreover if $S \subseteq A$, we set $f(S) = \bigcup_{s \in S} \{f(s)\}$. Given a set $S$, we denote by ${S \choose 2}$ the set containing every subset of $S$ that has cardinality two. We also denote by $2^{S}$ the set of all the subsets of $S$. If ${\cal S}$ is a collection of objects where the operation $\cup$ is defined, then we denote $\pmb{\pmb{\cup}}{\cal S}=\bigcup_{X\in{\cal S}}X$. Let $p\in\Bbb{N}$ with $p\geq 2$, let $f:\Bbb{N}^{p}\rightarrow\Bbb{N}$, and let $g:\Bbb{N}^{p-1}\rightarrow\Bbb{N}$. We say that $f(x_{1},\ldots,x_{p})=\mathcal{O}_{x_p}(g(x_{1},\ldots,x_{p-1}))$ if there is a function $h:\Bbb{N}\rightarrow\Bbb{N}$ such that \\ $f(x_{1},\ldots,x_{p})=\mathcal{O}(h(x_p)\cdot g(x_{1},\ldots,x_{p-1}))$. \bigskip \noindent \textbf{Graphs}. All the graphs that we consider in this paper are undirected, finite, and without loops or multiple edges. We use standard graph-theoretic notation, and we refer the reader to~\cite{Die10} for any undefined terminology. Given a graph $G$, we denote by $V(G)$ the set of vertices of $G$ and by $E(G)$ the set of the edges of $G$. We call $|V(G)|$ {\em the size} of $G$. A graph is {\em the empty} graph if its size is zero. We also denote by $\textsf{leaf}(G)$ the set of the vertices of $G$ that have degree exactly one in the case where $|V(G)| \geq 2$, and $\textsf{leaf}(G) = V(G)$ if $|V(G)| = 1$. If $G$ is a tree (i.e., a connected acyclic graph) then $\textsf{leaf}(G)$ is the set of the {\em leaves} of $G$. A {\em vertex labeling} of $G$ is some injection $\rho: V(G)\to\Bbb{N}^{+}$. {Given a vertex $v \in V(G)$, we define the \emph{neighborhood} of $v$ as $N_G(v) = \{u \mid u \in V(G), \{u,v\} \in E(G)\}$ and the \emph{closed neighborhood} of $v$ as $N_G[v] = N_G(v) \cup \{v\}$.} If $X\subseteq V(G)$, then we write $N_{G}(X)=(\bigcup_{v\in X}N_{G}(v))\setminus X$. The {\em degree} of a vertex $v$ in $G$ is defined as $\degs{G}{v}=|N_{G}(v)|$. A graph is called {\em subcubic} if all its vertices have degree at most three. A \emph{subgraph} $H = (V_H,E_H)$ of a graph $G$ is a graph such that $V_H \subseteq V(G)$ and $E_H \subseteq E(G) \cap {V_H \choose 2}$. If $S \subseteq V(G)$, the subgraph of $G$ \emph{induced by} $S$, denoted $G[S]$, is the graph $(S, E(G) \cap {S \choose 2})$. We also define $G \setminus S$ to be the subgraph of $G$ induced by $V(G) \setminus S$. If $S \subseteq E(G)$, we denote by $G \setminus S$ the graph $(V(G), E(G) \setminus S)$. If $s,t\in V(G)$ are two distinct vertices, an {\em $(s,t)$-path} of $G$ is any connected subgraph $P$ of $G$ with maximum degree two and where $s,t\in \textsf{leaf}(P)$, and a \emph{path} is an $(s,t)$-path for some vertices $s$ and $t$. We finally denote by ${\cal P}(G)$ the set of all paths of $G$. {Given $P \in \mathcal{P}(G)$, we say that $v \in V(P)$ is an \emph{internal vertex} of $P$ if $\degs{P}{v} = 2$.} {Given an integer $i$ and a graph $G$, we say that $G$ is $i$-connected if for each $\{u,v\} \in {V(G) \choose 2}$, there exists a set $\mathcal{P}' \subseteq \mathcal{P}(G)$ of $(u,v)$-paths of $G$ such that $|\mathcal{P}'| = i$ and for each $P_1,P_2 \in \mathcal{P}'$ such that $P_1 \not = P_2$, $V(P_1) \cap V(P_2) = \{u,v\}$.} We denote by $K_{r}$, $P_r$, and $C_r$ the complete graph, the path, and the cycle on $r$ vertices, respectively, and by $K_{r_{1},r_{2}}$ the complete bipartite graph where the one part has $r_{1}$ vertices and the other $r_{2}$. \bigskip \noindent \textbf{Block-cut trees.} A connected graph $G$ is \emph{biconnected} if for any $v \in V(G)$, $G \setminus \{v\}$ is connected. Notice that $K_{2}$ is the only biconnected graph that it is not $2$-connected and that $K_1$ is not biconnected. A \emph{block} of a graph $G$ is a maximal biconnected subgraph of $G$. We name $\textsf{block}(G)$ the set of all blocks of $G$ and we name $\textsf{cut}(G)$ the set of all cut vertices of $G$. If $G$ is connected, we define the \emph{block-cut tree} of $G$ to be the tree $\textsf{bct}(G) = (V,E)$ such that \begin{itemize} \item $V = \textsf{block}(G) \cup \textsf{cut}(G)$ and \item $E = \{\{B,v\} \mid B \in \textsf{block}(G), v \in \textsf{cut}(G) \cap V(B)\}$. \end{itemize} Note that $\textsf{leaf}(\textsf{bct}(G)) \subseteq \textsf{block}(G)$. It is worth mentioning that the block-cut tree of a graph can be computed in linear time using depth-first search~\cite{HopcroftT73}. Basic properties of block-cut trees can be found, for instance, in~\cite{BondyM08} (where they are called \emph{block trees}). \medskip Let $\mathcal{F}$ be a set of connected graphs on at least two vertices. Given $H \in \mathcal{F}$ and $B \in \textsf{leaf}(\textsf{bct}(H))$, we say that $(H,B)$ is an \emph{essential pair} if for each $H' \in \mathcal{F}$ and each $B' \in \textsf{leaf}(\textsf{bct}(H'))$, $|E(B)| \leq |E(B')|$. Given an essential pair $(H,B)$ of $\mathcal{F}$, we define the \emph{first vertex} of $(H,B)$ to be, if it exists, the only cut vertex of $H$ contained in $V(B)$, or an arbitrarily chosen vertex of $V(B)$ otherwise. We define the \emph{second vertex} of $(H,B)$ to be an arbitrarily chosen vertex of $V(B)$ that is a neighbor in $H[B]$ of the first vertex of $(H,B)$. Note that such a vertex always exists, as a block has at least two vertices. Given an essential pair $(H,B)$ of $\mathcal{F}$, we assume that the choices for the first and second vertices of $(H,B)$ are fixed. Moreover, given an essential pair $(H,B)$ of $\mathcal{F}$, we define the \emph{core} of $(H,B)$ to be the graph $H \setminus (V(B) \setminus \{a\})$ where $a$ is the first vertex of $(H,B)$. Note that $a$ is a vertex of the core of $(H,B)$. \bigskip \noindent \textbf{Minors and topological minors.} Given two graphs $H$ and $G$ and two functions $\phi: V(H)\to V(G)$ and $\sigma: E(H)\to{\cal P}(G)$, we say that $(\phi,\sigma)$ is {\em a topological minor model of $H$ in $G$} if \begin{itemize} \item for every $\{x,y\}\in E(H),$ $\sigma(\{x,y\})$ is an $(\phi(x),\phi(y))$-path in $G$ and \item if $P_{1},P_{2}$ are two distinct paths in $\sigma(E(H))$, then none of the internal vertices of $P_{1}$ is a vertex of $P_{2}$. \end{itemize} The {\em branch} vertices of $(\phi,\sigma)$ are the vertices in $\phi(V(H))$, while the {\em subdivision} vertices of $(\phi,\sigma)$ are the internal vertices of the paths in $\sigma(E(H))$. We say that $G$ contains $H$ as a \emph{topological minor}, denoted by $H\preceq_{\sf tm} G$, if there is a topological minor model $(\phi,\sigma)$ of $H$ in $G$. Given two graphs $H$ and $G$ and a function $\phi: V(H)\to 2^{V(G)}$, we say that $\phi$ is {\em a minor model of $H$ in $G$} if \begin{itemize} \item for every $x,y \in V(H)$ such that $x \not = y$, $\phi(x) \cap \phi(y) = \emptyset$, \item for every $x \in V(H)$, $G[\phi(x)]$ is a connected non-empty graph and \item for every $\{x,y\} \in E(H)$, there exist $x' \in \phi(x)$ and $y' \in \phi(y)$ such that $\{x',y'\} \in E(G)$. \end{itemize} We say that $G$ contains $H$ as a \emph{minor}, denoted by $H\preceq_{\sf m} G$, if there is a minor model $\phi$ of $H$ in $G$. \medskip \noindent \textbf{Graph separators and (topological) minors.} Let $G$ be a graph and $S\subseteq V(G)$. Then for each connected component $C$ of $G\setminus S$, we define the \emph{cut-component} of the triple $(C,G,S)$ to be the graph whose vertex set is $V(C) \cup S$ and whose edge set is $E(G[V(C) \cup S])$. \begin{lemma} \label{reifying} Let $i\geq 2$ be an integer, let $H$ be an $i$-connected graph, let $G$ be a graph, and let $S \subseteq V(G)$ such that $|S| \leq i-1$. If $H$ is a topological minor (resp. a minor) of $G$, then there exists a connected component $G'$ of $G\setminus S$ such that $H$ is a topological minor (resp. a minor) of the cut-component of $(G',G,S)$. \end{lemma} \begin{proof} We prove the lemma for the topological minor version, and the minor version can be proved with similar arguments. Let $i$, $H$, $G$, and $S$ be defined as in the statement of the lemma. Assume that $H \preceq_{\sf tm} G$ and let $(\phi,\sigma)$ be a topological minor model of $H$ in $G$. If $S$ is not a separator of $G$, then the statement is trivial, as in that case the cut-component of $(G\setminus S,G,S)$ is $G$. Suppose henceforth that $S$ is a separator of $G$, and assume for contradiction that there exist two connected components $G_1$ and $G_2$ of $G\setminus S$ and two distinct vertices $x_1$ and $x_2$ of $H$ such that $\phi(x_1) \in V(G_1)$ and $\phi(x_2) \in V(G_2)$. Then, as $H$ is $i$-connected, there should be $i$ internally vertex-disjoint paths from $\phi(x_1)$ to $\phi(x_2)$ in $G$. As $S$ is a separator of size at most $i-1$, this is not possible. Thus, there exists a connected component $G'$ of $G\setminus S$ such that for each $x \in V(H)$, $\phi(x) \in V(G') \cup S$. This implies that $H$ is a topological minor of the cut-component of $(G',G,S)$. \end{proof} \begin{lemma} \label{captured} Let $G$ be a connected graph, let $v$ be a cut vertex of $G$, and let $V$ be the vertex set of a connected component of $G \setminus \{v\}$. If $H$ is a connected graph such that $H \preceq_{\sf tm} G$ and for each leaf $B$ of $\mbox{\rm \textsf{bct}}(H)$, $B \not \preceq_{\sf tm} G[V \cup \{v\}]$, then $H \preceq_{\sf tm} G \setminus V$. \end{lemma} \begin{proof} Let $G$, $v$, $V$, and $H$ be defined as in the statement of the lemma. Let $B \in \textsf{leaf}(\textsf{bct}(H))$. If $B$ is a single edge, then the condition $B \not \preceq_{\sf tm} G[V \cup \{v\}]$ implies that $V = \emptyset$. But $V$ is the vertex set of a connected component of $G \setminus \{v\}$ and so $V \not = \emptyset$. This implies that the case $B$ is a single edge cannot occur. If $B$ is not a simple edge, then by definition $B$ is $2$-connected and then, by Lemma~\ref{reifying}, $B \preceq_{\sf tm} G \setminus V$. This implies that there is a topological minor model $(\phi,\sigma)$ of $H$ in $G$ such that for each $B \in \textsf{leaf}(\textsf{bct}(H))$ and for each $b \in B$, $\phi(b)\not \in V$. We show now that for each $x \in V(H)$, $\phi(x)\not \in V$. If $ V(H) \setminus (\bigcup_{B \in \textsf{leaf}(\textsf{bct}(H))} V(B)) = \emptyset$ then the result is already proved. Otherwise, let $x \in V(H) \setminus (\bigcup_{B \in \textsf{leaf}(\textsf{bct}(H))} V(B))$. By definition of the block-cut tree, there exist $b_1$ and $b_2$ in $\bigcup_{B \in \textsf{leaf}(\textsf{bct}(H))} V(B)$ such that $x$ lies on a $(b_1,b_2)$-path $P$ of $\mathcal{P}(H)$. Let $P_i$ be the $(b_i,x)$-subpath of $P$ for each $i \in \{1,2\}$. By definition of $P$, we have that $V(P_1) \cap V(P_2) = \{x\}$. This implies that there exists a $(\phi(b_1),\phi(x))$-path $P'_1$ and a $(\phi(b_2),\phi(x))$-path $P'_2$ in $\mathcal{P}(G)$ such that $V(P'_1) \cap V(P'_2) = \{\phi(x)\}$. Then, as $v$ is a cut vertex of $G$, it follows that $\phi(x) \not \in V$. Thus, for each $x \in V(H)$, $\phi(x) \not \in V$. Let $\{x,y\}$ be an edge of $E(H)$. As $\sigma(\{x,y\})$ is a simple $(\phi(x),\phi(y))$-path, both $\phi(x)$ and $\phi(y)$ are not in $V$ and $v$ is a cut vertex of $G$, we have, with the same argumentation that before that, for each $z \in V(\sigma(\{x,y\})$, $z \not \in V$. This concludes the proof. \end{proof} Using the same kind of argumentation with minors instead of topological minors, we also obtain the following lemma. \begin{lemma} \label{floppies} Let $G$ be a connected graph, let $v$ be a cut vertex of $G$, and let $V$ be the vertex set of a connected component of $G \setminus \{v\}$. If $H$ is a graph such that $H \preceq_{\sf m} G$ and for each leaf $B$ of $\textsf{bct}(H)$, $B \not \preceq_{\sf m} G[V \cup \{v\}]$, then $H \preceq_{\sf m} G \setminus V$. \end{lemma} In the above two lemmas, we have required graph $H$ to be connected so that $\textsf{bct}(H)$ is well-defined, but we could relax this requirement, and replace in both statements ``for each leaf $B$ of $\textsf{bct}(H)$'' with ``for each connected component $H'$ of $H$ and each leaf $B$ of $\textsf{bct}(H')$''. \bigskip \noindent \textbf{Graph collections.} Let ${\cal F}$ be a collection of graphs. From now on instead of ``collection of graphs'' we use the shortcut ``collection''. If ${\cal F}$ is a non-empty finite collection and all its graphs are non-empty, then we say that ${\cal F}$ is a {\em proper collection}. For any proper collection ${\cal F}$, we define ${\sf size}({\cal F})=\max\{\{|V(H)|\mid H\in \cal F\}\cup\{|{\cal F}|\}\}$. Note that if the size of ${\cal F}$ is bounded, then the size of the graphs in ${\cal F}$ is also bounded. We say that ${\cal F}$ is a {\em planar collection} (resp. {\em planar subcubic collection}) if it is proper and {\sl at least one} of the graphs in ${\cal F}$ is planar (resp. planar and subcubic). We say that ${\cal F}$ is a {\em connected collection} if it is proper and {\sl all} the graphs in ${\cal F}$ are connected and of size at least two. We say that $\mathcal{F}$ is a {\em (topological) minor antichain} if no two of its elements are comparable via the (topological) minor relation. Let $\mathcal{F}$ be a proper collection. We extend the (topological) minor relation to $\mathcal{F}$ such that, given a graph $G$, $\mathcal{F} \preceq_{\sf tm} G$ (resp. $\mathcal{F} \preceq_{\sf m} G$) if and only if there exists a graph $H \in \mathcal{F}$ such that $H \preceq_{\sf tm} G$ (resp. $H \preceq_{\sf m} G$). \bigskip \noindent\textbf{Tree and path decompositions.} A \emph{tree decomposition} of a graph $G$ is a pair ${\cal D}=(T,{\cal X})$, where $T$ is a tree and ${\cal X}=\{X_{t}\mid t\in V(T)\}$ is a collection of subsets of $V(G)$ such that: \begin{itemize} \item $\bigcup_{t \in V(T)} X_t = V(G)$, \item for every edge $\{u,v\} \in E$, there is a $t \in V(T)$ such that $\{u, v\} \subseteq X_t$, and \item for each $\{x,y,z\} \subseteq V(T)$ such that $z$ lies on the unique path between $x$ and $y$ in $T$, $X_x \cap X_y \subseteq X_z$. \end{itemize} We call the vertices of $T$ {\em nodes} of ${\cal D}$ and the sets in ${\cal X}$ {\em bags} of ${\cal D}$. The \emph{width} of a tree decomposition ${\cal D}=(T,{\cal X})$ is $\max_{t \in V(T)} |X_t| - 1$. The \emph{treewidth} of a graph $G$, denoted by ${\sf{tw}}(G)$, is the smallest integer $w$ such that there exists a tree decomposition of $G$ of width at most $w$. For each $t \in V(T)$, we denote by $E_t$ the set $E(G[X_t])$. A \emph{path decomposition} of a graph $G$ is a tree decomposition ${\cal D}=(T,{\cal X})$ of $G$ such that $T$ is a path, and the \emph{pathwidth} of a graph $G$, denoted by ${\sf{pw}}(G)$, is the smallest integer $w$ such that there exists a path decomposition of $G$ of width at most $w$. Note that, by definition, for every graph $G$ it holds that ${\sf{pw}}(G) \geq {\sf{tw}}(G)$. \bigskip \noindent\textbf{Parameterized complexity.} We refer the reader to~\cite{DF13,CyganFKLMPPS15} for basic background on parameterized complexity, and we recall here only some very basic definitions. A \emph{parameterized problem} is a language $L \subseteq \Sigma^* \times \mathbb{N}$. Integer $k$ is called the \emph{parameter} of an instance $I=(x,k) \in \Sigma^* \times \mathbb{N}$. A parameterized problem is \emph{fixed-parameter tractable} ({\sf FPT}) if there exists an algorithm $\mathcal{A}$, a computable function $f$, and a constant $c$ such that given an instance $I=(x,k)$, $\mathcal{A}$ (called an {\sf FPT} \emph{algorithm}) correctly decides whether $I \in L$ in time bounded by $f(k) \cdot |I|^c$. \bigskip \noindent \textbf{Definition of the problems.} Let ${\cal F}$ be a proper collection. We define the parameter ${\bf tm}_{\cal F}$ as the function that maps graphs to non-negative integers as follows: \begin{eqnarray} \label{overlaid} {\bf tm}_{\cal F}(G) & = & \min\{|S|\mid S\subseteq V(G)\wedge \mathcal{F} \npreceq_{\sf tm} G\setminus S \}. \end{eqnarray} The parameter ${\bf m}_{\cal F}$ is defined analogously, just by replacing $\mathcal{F} \npreceq_{\sf tm} G\setminus S$ with $\mathcal{F} \npreceq_{\sf m} G\setminus S$. The main objective of this paper is to study the problem of computing the parameters ${\bf tm}_{\cal F}$ and ${\bf m}_{\cal F}$ for graphs of bounded treewidth under several instantiations of the collection ${\cal F}$. The corresponding decision problems are formally defined as follows. \medskip\medskip\medskip \hspace{-.6cm}\begin{minipage}{6.7cm} \paraprobl{\textsc{$\mathcal{F}$-TM-Deletion}} {A graph $G$ and an integer $k\in \mathbb{N}$.} {Is ${\bf tm}_\mathcal{F}(G)\leq k$?} {The treewidth of $G$.}{6.7} \end{minipage}~~~~~ \begin{minipage}{6.7cm} \paraprobl{\textsc{$\mathcal{F}$-M-Deletion}} {A graph $G$ and an integer $k\in \mathbb{N}$.} {Is ${\bf m}_\mathcal{F}(G)\leq k$?} {The treewidth of $G$.}{6.7} \end{minipage} \medskip\medskip Note that in both above problems, we can always assume that ${\cal F}$ is an antichain with respect to the considered relation. Indeed, if ${\cal F}$ contains two graphs $H_{1}$ and $H_{2}$ where $H_{1}\preceq_{\sf tm} H_{2}$, then ${\bf tm}_{\cal F}(G)={\bf tm}_{{\cal F}'}(G)$ where ${\cal F}'={\cal F}\setminus\{H_{2}\}$ (similarly for the minor relation). Throughout the article, we let $n$ and ${\sf{tw}}$ be the number of vertices and the treewidth of the input graph of the considered problem, respectively. \section{Single-exponential lower bound for any connected $\mathcal{F}$} \label{struggle} In this section we prove the following result. \begin{theorem} \label{temporis} Let $\mathcal{F}$ be a connected collection. Neither \textsc{$\Fcal$-TM-Deletion}\xspace nor \textsc{$\Fcal$-M-Deletion}\xspace can be solved in time $2^{o({\sf{tw}})} \cdot n^{\mathcal{O}(1)}$ unless the {\sf ETH}\xspace fails. \end{theorem} \begin{proof} Let $\mathcal{F}$ be a connected collection. We present a reduction from {\sc Vertex Cover} to \textsc{$\Fcal$-TM-Deletion}\xspace, both parameterized by the treewidth of the input graph, and then we explain the changes to be made to prove the lower bound for \textsc{$\Fcal$-M-Deletion}\xspace. {\sc Vertex Cover} cannot be solved in time $2^{o(w)} \cdot n^{\mathcal{O}(1)}$ unless the {\sf ETH}\xspace fails~\cite{ImpagliazzoP01} (in fact, it cannot be solved even in time $2^{o(n)}$), where $w$ is the treewidth of the input graph. It is worth mentioning that our reduction bears some similarity with the classical reduction of Yannakakis~\cite{Yannakakis78} for general vertex-deletion problems. Without loss of generality, we can assume that $\mathcal{F}$ is a topological minor antichain. First we select an essential pair $(H,B)$ of $\mathcal{F}$. Let $a$ be the first vertex of $(H,B)$, $b$ be the second vertex of $(H,B)$, and $A$ be the core of $(H,B)$. For convenience, we also refer to $a$ and $b$ as vertices of the copies of $A$. Let $G$ be the input graph of the {\sc Vertex Cover} problem and let $<$ be an arbitrary total order on $V(G)$. We build a graph $G'$ starting from $G' = (V(G),\emptyset)$. For each vertex $v$ of $G$, we add a copy of $A$, which we call $A^v$, and we identify the vertices $v$ and $a$. For each edge $e = \{v,v'\} \in E(G)$ with $v < v'$, we remove $e$, we add a copy of $B$, which we call $B^e$, and we identify the vertices $v$ and $a$ and the vertices $v'$ and $b$. This concludes the construction of $G'$. Note that $|V(G')| = |V(G)| \cdot |V(A)| + |E(G)| \cdot |V(B) \setminus \{a,b\}|$ and that ${\sf{tw}}(G') = \max\{{\sf{tw}}(G),{\sf{tw}}(H)\}$. For completeness, we provide a proof of the latter fact. For each $v \in V(G)$, we define $\mathcal{D}^v = (T^v,\mathcal{X}^v)$ to be a tree decomposition of $A^v$ and we fix $r_v \in V(T^v)$ such that $X^v_{r_v} \in \mathcal{X}^v$ contains the copy of $a$ in $A^v$. For each $e \in E(G)$, we define $\mathcal{D}^{e} = (T^{e},\mathcal{X}^{e})$ to be a tree decomposition of $B^{e}$ and we fix $r_{e} \in V(T^{e})$ such that $X^{e}_{r_{e}} \in \mathcal{X}^{e}$ contains the copy of $a$ and $b$ in $A^v$. We know that this bag exists as $\{a,b\} \in E(H)$. Let $\mathcal{D}^G = (T^G,\mathcal{X}^G)$ be a tree decomposition of $G$. We can then define a tree decomposition of $G'$ as follows. Start from $\mathcal{D} = (T,\mathcal{X})$ where $T$ is the union of $T^G$, of each $T^v$, $v \in V(G)$, and each $T^{e}$, $e \in E(G)$, and $\mathcal{X}$ is the union of $\mathcal{X}^G$, of each $\mathcal{X}^v$, $v \in V(G)$, and each $\mathcal{X}^{e}$, $e \in E(G)$. Then for each $v \in V(G)$, we arbitrarily choose $t_v \in V(T^G)$ such that $v \in \mathcal{X}^G_{t_v}$ and connect $t_v$ and $r_v$ in $T$. Then for each $e \in E(G)$, we arbitrarily choose $t_{e} \in V(T^G)$ such that $e \subseteq \mathcal{X}^G_{t_v}$ and connect $t_{e}$ and $r_{e}$ in $T$. This concludes the construction of a tree decomposition of $G'$. As for each $v \in V(G)$ and each $e \in E(G)$, the tree decompositions of $A^v$ and of $B^{e}$ are just smaller parts of a tree decomposition of $H$, we obtain that each bag of $\mathcal{D}$ is of size at most ${\sf{tw}}(G)$ if it comes from $\mathcal{X}^G$, or of size at most ${\sf{tw}}(H)$ if it comes from $\mathcal{X} \setminus \mathcal{X}^G$. Thus ${\sf{tw}}(G') = \max\{{\sf{tw}}(G),{\sf{tw}}(H)\}$. We claim that there exists a solution of size at most $k$ of {\sc Vertex Cover} in $G$ if and only if there is a solution of size at most $k$ of \textsc{$\Fcal$-TM-Deletion}\xspace in $G'$. In one direction, assume that $S$ is a solution of \textsc{$\Fcal$-TM-Deletion}\xspace in $G'$ with $|S| \leq k$. By definition of the problem, for each $e=\{v,v'\} \in E(G)$ with $v < v'$, either $B^e$ contains an element of $S$ or $A^v$ contains an element of $S$. Let $S' = \{v \in V(G) \mid \exists v' \in V(G) : v<v', e=\{v,v'\} \in E(G), (V(B^e) \setminus \{v,v'\}) \cap S \not = \emptyset\} \cup \{v \in V(G) \mid V(A^v) \cap S \not = \emptyset\} $. Then $S'$ is a solution of {\sc Vertex Cover} in $G$ and $|S'| \leq |S| \leq k$. In the other direction, assume that we have a solution $S$ of size at most $k$ of {\sc Vertex Cover} in $G$. We want to prove that $S$ is also a solution of \textsc{$\Fcal$-TM-Deletion}\xspace in $G'$. For this, we fix an arbitrary $H' \in \mathcal{F}$ and we show that $H'$ is not a topological minor of $G' \setminus S$. First note that the connected components of $G' \setminus S$ are either of the shape $A^v \setminus \{v\}$ if $v \in S$, $B^e \setminus e$ if $e \subseteq S$, or the union of $A^v$ with zero, one, or more graphs $B^{\{v,v'\}}\setminus \{v'\}$ such that $\{v,v'\} \in E(G)$ if $v \in V(G) \setminus S$. As $\mathcal{F}$ is a topological minor antichain, for any $v \in V(G)$, $H' \not \preceq_{\sf tm} A^v \setminus \{v\}$ and for any $e \in E(G)$, $H' \not \preceq_{\sf tm} B^e \setminus e$. Moreover, let $v \in V(G) \setminus S$ and let $K$ be the connected component of $G' \setminus S$ containing $v$. $K$ is the union of $A^v$ and of every $B^{\{v,v'\}}\setminus \{v'\}$ such that $\{v,v'\} \in E(G)$. As, for each $v' \in V(G)$ such that $\{v,v'\} \in E(G)$, $v'$ is not an isolated vertex in $B^{\{v,v'\}}$, by definition of $B$, for any $B' \in \textsf{leaf}(\textsf{bct}(H'))$, $|E(B^{\{v,v'\}}\setminus \{v'\})| < |E(B')|$. This implies that for each leaf $B'$ of $\textsf{bct}(H')$ and for each $\{v,v'\} \in E(G)$, $B' \not \preceq_{\sf tm} B^{\{v,v'\}}\setminus \{v'\}$. It follows by definition of $\mathcal{F}$ that $H' \not \preceq_{\sf tm} A^v$. This implies by Lemma~\ref{captured} that $H'$ is not a topological minor of $K$. Moreover, as $H'$ is connected by hypothesis, it follows that that $H'$ is not a topological minor of $G' \setminus S$ either. This concludes the proof for the topological minor version. Finally, note that the same proof applies to \textsc{$\Fcal$-M-Deletion}\xspace as well, just by replacing \textsc{$\Fcal$-TM-Deletion}\xspace with \textsc{$\Fcal$-M-Deletion}\xspace, topological minor with minor, $\preceq_{\sf tm}$ with $\preceq_{\sf m}$, and Lemma~\ref{captured} with Lemma~\ref{floppies}. \end{proof} From Theorem~\ref{temporis} we can easily get the following corollary on planar graphs. \begin{corollary}\label{patterns} Let $\mathcal{F}$ be a connected planar collection. Neither \textsc{$\Fcal$-TM-Deletion}\xspace nor \textsc{$\Fcal$-M-Deletion}\xspace can be solved on planar graphs in time $2^{o({\sf{tw}})} \cdot n^{\mathcal{O}(1)}$ unless the {\sf ETH}\xspace fails. \end{corollary} \begin{proof} We can assume that all the graphs in $\mathcal{F}$ are planar, since an input planar graph $G$ does not contain any nonplanar graph as a (topological) minor. We reduce from {\sc Planar Vertex Cover} to \textsc{$\Fcal$-TM-Deletion}\xspace on planar graphs, both parameterized by the treewidth of the input graph, and the construction of $G'$ is the same as above. Note that since all the graphs in $\mathcal{F}$ are planar, so is the essential pair $(H,B)$, and therefore the graph $G'$ is easily checked to be planar. Since {\sc Planar Vertex Cover} cannot be solved in time $2^{o(w)} \cdot n^{\mathcal{O}(1)}$ unless the {\sf ETH}\xspace fails~\cite{ImpagliazzoP01,Lic82}, where $w$ is the treewidth of the input graph, the result follows. Finally, the changes to be made for the minor version are the same as those in the proof of Theorem~\ref{temporis}. \end{proof} \section{Superexponential lower bounds} \label{secsupexp} Let $\mathcal{C}$ be the set of all connected graphs that contain a block with at least five edges, let $\mathcal{Q}$ be the set containing $P_5$ and all connected graphs that are {\sl not} minors of the {\sf banner}\xspace, and let $\mathcal{S} = \{K_{1,s} \mid s \geq 4 \}$. In this section, we prove the following theorems. Note that, by definition, it holds that $\mathcal{C} \subseteq \mathcal{Q}$, but we consider both sets because we will prove a stronger result for the set $\mathcal{C}$ (Theorem~\ref{hardgene}, which applies to every subset of $\mathcal{C}$) than for the set $\mathcal{Q}$ (Theorems~\ref{hardminor} and~\ref{hardtminor}, which apply to families containing a single graph $H$). \begin{theorem} \label{hardgene} Let $\mathcal{F}$ be a finite non-empty subset of $\mathcal{C}$. Unless the {\sf ETH}\xspace fails, neither \textsc{$\mathcal{F}$-M-Deletion} nor \textsc{$\mathcal{F}$-TM-Deletion} can be solved in time $2^{o({\sf{tw}} \log {\sf{tw}})}\cdot n^{\mathcal{O}(1)}$. \end{theorem} \begin{theorem} \label{hardminor} Let $H \in \mathcal{Q}$. Unless the {\sf ETH}\xspace fails, \textsc{$\{H\}$-M-Deletion} cannot be solved in time $2^{o({\sf{tw}} \log {\sf{tw}})}\cdot n^{\mathcal{O}(1)}$. \end{theorem} \begin{theorem} \label{hardtminor} Let $H \in \mathcal{Q}\setminus \mathcal{S}$. Unless the {\sf ETH}\xspace fails, \textsc{$\{H\}$-TM-Deletion} cannot be solved in time $2^{o({\sf{tw}} \log {\sf{tw}})}\cdot n^{\mathcal{O}(1)}$. \end{theorem} Note that if $H$ is a connected graph such that $H \notin \mathcal{Q}$ (resp. $H \notin \mathcal{Q} \setminus \mathcal{S}$), then \textsc{$\{H\}$-M-Deletion} (resp. \textsc{$\{H\}$-TM-Deletion}) can be solved in time $2^{\mathcal{O}({\sf{tw}})}\cdot n^{\mathcal{O}(1)}$ by the single-exponential algorithms presented in~\cite{monster2}. On the other hand, if $H$ is a connected (resp. planar subcubic) graph, then \textsc{$\{H\}$-M-Deletion} and \textsc{$\{H\}$-TM-Deletion}) can be solved in time $2^{\mathcal{O}({\sf{tw}} \log {\sf{tw}})}\cdot n^{\mathcal{O}(1)}$ by the algorithms presented in~\cite{monster1,SODA-arXiv,BasteST20-SODA}. In particular, note that these results altogether settle completely the asymptotic complexity of \textsc{$\{H\}$-M-Deletion} when $H$ is a connected graph; see Figure~\ref{shifting} for an illustration. We first provide in Section~\ref{supexpgencons} a general framework that will be used in every reduction and then we explain how to modify this framework depending on the family $\mathcal{F}$ we are considering. \subsection{The general construction} \label{supexpgencons} In order to prove Theorem~\ref{hardgene}, Theorem~\ref{hardminor}, and Theorem~\ref{hardtminor}, we will provide reductions from the following problem, which is closely related to the \textsc{$k\times k$ Permutation Clique} problem defined by Lokshtanov et al.~\cite{permuclique}. \paraprobl {\sc $k\times k$ Permutation Independent Set} {An integer $k$ and a graph $G$ with vertex set $\intv{1,k} \times \intv{1,k}$.} {Is there an independent set of size $k$ in G with exactly one element from each row and exactly one element from each column?} {$k$.}{14.3} \begin{theorem}[Lokshtanov et al.~\cite{permuclique}] \label{borrowing} The {\sc $k\times k$ Permutation Independent Set} problem cannot be solved in time $2^{o(k \log k)}$ unless the {\sf ETH}\xspace fails. \end{theorem} Let $\mathcal{F}$ be a finite family of non-empty graphs. The framework we are going to present follows the ideas of the construction given by Bonnet et al.~\cite{BonnetBKM-IPEC17}. This framework mostly depends on $h := \min_{H \in \mathcal{F}}|V(H)|$ but also on an integer $t_\mathcal{F}$ whose value will be defined later. Let $(G,k)$ be an instance of {\sc $k\times k$ Permutation Independent Set}. As we are asking for an independent set that contains exactly one vertex in each row, we will assume without loss of generality that, for each pair $(i,j)$, $(i,j')$ in $V(G)$ with $j \neq j'$, $\{(i,j),(i,j')\} \in E(G)$. We proceed to construct a graph $F$ that contains one gadget for each edge of the graph $G$. These gadgets are arranged in a cyclic way, separated by some other gadgets ensuring the consistency of the selected solution. Formally, we first define the graph $K := K_{h-1}$. For each $e \in E(G)$, and each $(i,j) \in \intv{1,k}^2$, we define the graph $B^e_{i,j}$ to be the disjoint union of $n_h$ copies of $K$, for some integer $n_h$, whose value will be $2$ in the minor case and ${h \choose 2}$ in the topological minor case, two new vertices $a^e_{i,j}$ and $b^e_{i,j}$, and $t_\mathcal{F}$ other new vertices called \emph{$B$-extra vertices}. The graph $B^e_{i,j}$ is depicted in Figure~\ref{new-renegades}. \begin{figure}[htb] \centering \scalebox{1}{\begin{tikzpicture}[scale=1] \node at (1,0) {$K$}; \node at (2,0) {$K$}; \node at (0,1.3) {\footnotesize{$a^{e}_{i,j}$}}; \node at (3,1.3) {\footnotesize{$b^e_{i,j}$}}; \vertex{0,1}; \vertex{1,1}; \vertex{2,1}; \vertex{3,1}; \draw (-0.5,-0.5) -- (3.5,-0.5) -- (3.5,2) -- (-0.5,2) -- (-0.5,-0.5); \end{tikzpicture}} \caption{The graph $B^e_{i,j}$ for $e\in E(G)$ and $(i,j) \in \intv{1,k}^2$ when $n_h=2$ and $t_\mathcal{F} = 2$.} \label{new-renegades} \end{figure} Informally, the graph $B^e_{i,j}$, for every $e \in E(G)$, will play in $F$ the role of the vertex $(i,j)$ in $G$. For each $e \in E(G)$ and each $j \in \intv{1,k}$, we define the graph $C^e_j$ obtained from the disjoint union of every $B^e_{i,j}$, $i \in \intv{1,k}$, such that two graphs $B^e_{i_1,j}$ and $B^e_{i_2,j}$, $i_1 \not = i_2$, are {\em complete} to each other, that is, for every $i_1 \not = i_2$, if $v_1 \in V( B^e_{i_1,j})$ and $v_2 \in V(B^e_{i_2,j})$, then $\{v_1,v_2\} \in {E(C^e_{j})}$. Informally, for a fixed $j \in \intv{1,k}$, the graph $C^e_j$, for every $e \in E(G)$, corresponds to the column $j$ of $G$. For every $e \in E(G)$, we also define the \emph{gadget graph} $D^e$ obtained from the disjoint union of every $C^e_{j}$, $j \in \intv{1,k}$, by adding, if $e = \{(i,j),(i',j')\}$, every edge $\{v_1,v_2\}$ such that $v_1 \in V(B^e_{i,j})$ and $v_2 \in V(B^e_{i',j'})$. The graph $D^e$ is depicted in Figure~\ref{flattered}. \begin{figure}[htb] \centering \scalebox{1}{\begin{tikzpicture}[scale=1] \draw[line width=3pt] (2,2) -- (4,4); \foreach \x in {1,2,3} { \node[circle] at (2*\x,7.5) {$C^e_{\x}$}; \draw[line width=3pt] (2*\x,2) -- (2*\x,6); \draw[line width=3pt] (2*\x,2) -- (2*\x-0.6,2.6) -- (2*\x-0.6,5.4) -- (2*\x,6); \foreach \y in {1,2,3} { \node[circle,fill = white, minimum size=7.5mm] at (2*\x,2*\y) {$$}; \node[circle] at (2*\x,2*\y) {$B^e_{\y,\x}$}; } } \foreach \x in {1,2,3,4} { \draw[dotted] (2*\x-1,1) -- (2*\x-1,8); } \draw[dotted] (1,7) -- (7,7); \draw[dotted] (1,8) -- (7,8); \draw[dotted] (1,1) -- (7,1); \end{tikzpicture}} \caption{The gadget graph $D^e$ for $ e = \{(1,1),(2,2)\} \in E(G)$ where $k = 3$. A bold edge means that two graphs $B$ are connected in a complete bipartite way.} \label{flattered} \end{figure} Informally, the graph $D^e$, $e\in E(G)$, encodes the edge $e$ of the graph $G$. For every $e \in E(G)$, we also define $J^e$ such that $V(J^e) = \{c^e_{j} \mid j \in \intv{1,k}\} \cup \{r^e_{i} \mid i \in \intv{1,k}\}$ is a set of new vertices and $E(J^e) = \emptyset$. It will be helpful to associate the $c^e_{j}$'s with ``columns'' and the $r^{e}_{i}$'s with ``rows''. Note that, in the following, $J^e$ may be enhanced, by adding vertices called \emph{$J$-extra vertices}, whose number depends on the family $\mathcal{F}$ we are working with, but will always be linear in $k$. The graphs $J^e$, $e \in E(G)$, are the \emph{separator gadgets} that will ensure the consistency of the selected solution. Finally, the graph $F$ is obtained from the disjoint union of every $D^e$, $e \in E(G)$, and every $J^e$, $e \in E(G)$. Moreover, we fix a cyclic permutation $\sigma$ of the elements of $E(G)$, agreeing that $\sigma^{-1}(e)$ and $\sigma(e)$ is the edge before and after $e$, respectively, in this cyclic ordering. For each $e \in E(G)$, and each $(i,j) \in \intv{1,k}^2$, we add to $F$ the edges $$ \{b^{\sigma^{-1}(e)}_{i,j},c^e_j\}, \{b^{\sigma^{-1}(e)}_{i,j},r^e_i\}, \{r^e_i,a^e_{i,j}\}, \mbox{~and~} \{c^e_j,a_{i,j}^{e}\}.$$ This concludes the definition of the framework graph $F$, which is depicted in Figure~\ref{rejecting} (a similar figure appears in~\cite{BonnetBKM-IPEC17}). \begin{figure}[htb] \centering \scalebox{1}{\begin{tikzpicture}[scale=1] \draw[rounded corners=4mm] (0,0) -- (10,0) -- (10,1) -- (0,1) -- (0,0); \node[circle, draw, fill=white] at (0,0) {$J^{e_1}$}; \node[circle, draw, fill=white] at (2,0) {$D^{e_1}$}; \node[circle, draw, fill=white] at (4,0) {$J^{e_2}$}; \node[circle, draw, fill=white] at (6,0) {$D^{e_2}$}; \node[circle, draw, fill=white] at (8,0) {$J^{e_3}$}; \node[circle, draw, fill=white] at (10,0) {$D^{e_3}$}; \end{tikzpicture}} \caption{ The shape of the framework graph $F$ assuming that $k = 3$, $G$ contains only the three edges $e_1$, $e_2$, and $e_3$, and $\sigma$ is the cyclic permutation $(e_1, e_2,e_3)$.} \label{rejecting} \end{figure} Note that in later constructions a gadget graph $D^e$, $e \in E(G)$, will only be connected to the (enhanced) separator gadgets $J^e$ and $J^{\sigma(e)}$ in a way that will be specified later and that depends on the family $\mathcal{F}$. Let $\ell := (n_h(h-1)+2+t_\mathcal{F})(k-1)k{m}$, where $m=|E(G)|$. Note that $z = (n_h(h-1)+2+t_\mathcal{F})$ is the number of vertices of a $B^e_{i,j}$, $i,j \in \intv{1,k}$, $e \in E(G)$ and that $\ell$ is the budget needed to select the vertex set of exactly $k-1$ graphs $B^e_{i,j}$, $i \in \intv{1,k}$ in each graph $C^e_j$, $j \in \intv{1,k}$, $e \in E(G)$. The pair $(F,\ell)$ is called the \emph{$\mathcal{F}$-M-framework} of $(G,k)$ when $n_h = 2$, and the \emph{$\mathcal{F}$-TM-framework} of $(G,k)$ when $n_h = {h \choose 2}$. When the value $n_h$ is not relevant, the pair $(F,\ell)$ is simply called the \emph{$\mathcal{F}$-framework} of $(G,k)$. For convenience, we always assume some prespecified permutation $\sigma$ associated with the graph $F$. For each family $\mathcal{F}$, given an input $(G,k)$ of {\sc $k\times k$ Permutation Independent Set}, we will consider $(F,\ell)$, the $\mathcal{F}$-framework of $(G,k)$, and create another pair $(F_\mathcal{F},\ell)$, called the \emph{enhanced $\mathcal{F}$-framework}, where $F_\mathcal{F}$ is a graph obtained from $F$ by adding some new vertices and edges. The added vertices will be $B$-extra vertices {or} {$J$-extra vertices}. The added edges will be either inside some (enhanced) $B_{i,j}^{e}$, or from some $D^{e}$ to the (enhanced) $J^{e}$ and $J^{\sigma(e)}$. More formally, the additional edges will be from the set $$\Big(\bigcup_{e \in E(G),\atop i,j\in \intv{1,k}} V(B^e_{i,j}) \times V(B^e_{i,j})\Big) \cup \Big(\bigcup_{e \in E(G)} V(D^e) \times V(J^e) \Big)\cup \Big(\bigcup_{e \in E(G)} V(D^e) \times V(J^{\sigma(e)})\Big),$$ by interpreting ordered pairs as edges. Note that $F$ will always be a subgraph of $F_\mathcal{F}$. We will claim that there exists a solution of {\sc $k\times k$ Permutation Independent Set} on $(G,k)$ if and only if there exists a solution of \textsc{$\mathcal{F}$-M-Deletion} (resp. \textsc{$\mathcal{F}$-TM-Deletion}) on {$(F_\mathcal{F},\ell)$}. In order to do this, we first prove a generic lemma, namely Lemma~\ref{reimitation}, and then provide a property, namely Property~\ref{new-wealthierm} (resp. Property~\ref{new-wealthiertm}), which we will prove for each family $\mathcal{F}$ depending on the enhanced $\mathcal{F}$-framework $F_\mathcal{F}$ Let us now provide an upper bound on the treewidth (in fact, the pathwidth) of $F_\mathcal{F}$. Let $\{e_1,\ldots, e_m\} = E(G)$ such that for each $i \in \intv{1,m}$, $\sigma(e_i) = e_{i+1}$ with the convention that $e_{m+1} = e_1$. First note that, for each $e \in E(G)$, the set $V(J^e) \cup V(J^{\sigma(e)})$ disconnects the vertex set $V(D^e)$ from the rest of $F_\mathcal{F}$. Moreover, if $e = \{(i,j),(i',j')\}$, then the bags \begin{itemize} \item[] $V(J^{e_1}) \cup V(J^e) \cup V(J^{\sigma(e)}) \cup V(C^e_1) \cup V(B^e_{i,j}) \cup V(B^e_{i',j'})$, \item[] $V(J^{e_1}) \cup V(J^e) \cup V(J^{\sigma(e)}) \cup V(C^e_2) \cup V(B^e_{i,j}) \cup V(B^e_{i',j'})$, $\ldots$, \item[] $V(J^{e_1}) \cup V(J^e) \cup V(J^{\sigma(e)}) \cup V(C^e_k) \cup V(B^e_{i,j}) \cup V(B^e_{i',j'})$ \end{itemize} form a path decomposition of $G[V(J^e) \cup V(J^{\sigma(e)}) \cup V(D^e)]$ of width $(n_h(h-1)+2+t_\mathcal{F})(k+1)-1 + 3\cdot |V(J^{e_1})|$ (using the fact that $|V(J^{e})| = |V(J^{e_1})|$ for each $e \in E(G)$). Let denote by $P^e$ this decomposition. By concatenating the path decompositions $P^{e_1}$, $P^{e_2}$, $\ldots$, and $P^{e_m}$, we obtain a path decomposition of $F_\mathcal{F}$ whose width, by using the fact that $|V(J^{e_1})| = \mathcal{O}(k)$, is linear in $k$. We start by proving that for each column $C_j^e$, $e \in E(G)$, $j \in \intv{1,k}$, containing a minimum number of vertices of the solution, all the remaining vertices belong to the same row of this column. \begin{lemma} \label{colu} Let $\mathcal{F}$ be a family of graphs and let $(F,\ell)$ be the $\mathcal{F}$-TM-framework of an input $(G,k)$ of {\sc $k\times k$ Permutation Independent Set}. Let $S$ be a solution of \textsc{$\mathcal{F}$-TM-Deletion} on $(F,\ell)$ and let $e \in E(G)$ and $j \in \intv{1,k}$ such that the quantity $|V(C^e_j) \setminus S|$ is maximized, i.e., for all $e' \in E(G)$ and $j' \in \intv{1,k}$\ $|V(C^e_j) \setminus S|\geq |V(C^{e'}_{j'}) \setminus S|$. Then there exists $i \in \intv{1,k}$ such that $V(C^e_j) \setminus S \subseteq V(B^e_{i,j})$. \end{lemma} \begin{proof} We set $z=({h \choose 2}(h-1)+2+t_\mathcal{F})$ and observe that $|S|\leq \ell=z(k-1)km$. Let $h = \min_{H \in \mathcal{F}}|V(H)|$, and note that we can always assume that $h \geq 2$ as otherwise the problem is trivial. Choose $e \in E(G)$ and $j \in \intv{1,k}$ so that the quantity $|V(C^e_j) \setminus S|$ is maximized. In order to prove the lemma, we show that the assumption that there exist $i_1,i_2 \in \intv{1,k}$, with $i_1 \not = i_2$ such that $(V(C^e_j) \setminus S) \cap V(B^e_{i_1,j}) \not = \emptyset$ and $(V(C^e_j) \setminus S) \cap V(B^e_{i_2,j}) \not = \emptyset$ implies that $F \setminus S$ contains $K_h$ as a topological minor, for any value of $t_\mathcal{F} \in \mathbb{N}$. We claim that $|V(C^e_j) \setminus S|\geq z$. Indeed, if $|V(C^e_j) \setminus S|<z$, by the maximality in the choice of $e$ and $j$, it follows that $|V(C^{e'}_{j'}) \setminus S|\leq z-1$, for all $e'\in E(G)$ and $j'\in[1,k]$. This implies that $|S\cap V(C_{j'}^{e'})|\geq |V(C_{j'}^{e'})|-(z-1)=kz-z+1=z(k-1)+1$ for all $e'\in E(G)$ and $j'\in[1,k]$. As there are $m$ choices for $e'$ and $k$ choices for $i'$ we have that $$|S|\geq \bigcup_{e'\in E(G)\atop i'\in[1,k]}|S\cap V(C_{j'}^{e'})|\geq (z(k-1)+1)km>z(k-1)km=\ell,$$ a contradiction. We just proved that \begin{eqnarray} |V(C^e_j) \setminus S| & \geq & {h \choose 2}(h-1)+2+t_\mathcal{F}.\label{sdafdfds} \end{eqnarray} We next pick $U_M$ as a set $V(B^e_{i,j}) \setminus S$, $i \in \intv{1,k}$, with the maximum number of elements. We claim that, if $|U_M| \leq h-1$, then $F\setminus S$ contains $K_{h}$ as a topological minor. We fist observe that at least $h$ of the sets in ${\cal Z}=\{V(B^e_{i,j}) \setminus S\mid i \in \intv{1,k\}}$ are non-empty. To verify this, suppose to the contrary that the set ${\cal Z}'$, consisting of the non-empty elements of ${\cal Z}$, has cardinality at most $h-1$. By the maximality of the choice of $U_M$, we obtain that each set in ${\cal Z}'$ has at most $|U_M|$ elements. We then observe that $|V(C^e_j) \setminus S|=|\pmb{\pmb{\cup}} {\cal Z}'|=(h-1)\cdot |U_M|\leq (h-1)^2$, a contradiction to~\eqref{sdafdfds}, as $ (h-1)^2<{h \choose 2}(h-1)+2+t_\mathcal{F}$. We just proved that $|{\cal Z}'|\geq h$. By picking one vertex from each set in ${\cal Z}'$, we conclude that $F \setminus S$ contains a clique of size $h$ as a subgraph and the claim follows.\medskip From now on, we assume that $h \leq |U_M|$. In fact, we claim that if $|U_M| \leq {h \choose 2}(h-1)+2+t_\mathcal{F} - {h \choose 2}$, then $F\setminus S$ contains $K_{h}$ as a topological minor. For this, let $Q$ be any set of $h$ vertices of $U_M$ and let $Z$ be a set of ${h \choose 2}$ vertices of $V(C^e_j) \setminus (S \cup U_M)$ (this set exists because of~\eqref{sdafdfds}). As each vertex of $Z$ is a neighbor of each vertex of $Q$, we obtain that $F[Q \cup Z]$, which is a subgraph of $F\setminus S$, contains $K_h$ as a topological minor.\medskip According to the previous claim, we can assume that $|U_M| > {h \choose 2}(h-1)+2+t_\mathcal{F} - {h \choose 2}$ or, equivalently \begin{eqnarray} {h \choose 2}(h-2)+2+t_\mathcal{F} < |U_{M}|.\label{sddsfads} \end{eqnarray} Let $a$ be the size of the largest clique $K_a$ in $F[U_M]$. We claim that $a\geq h-1$. For this, observe that if the biggest clique in $F[U_M]$ has size at most $h-2$, then $|U_{M}|\leq {h \choose 2}(h-2)+2+t_\mathcal{F}$, contradicting~\eqref{sddsfads}. \medskip We just derived that $F[U_M]$ contains a clique $K_{h-1}$. By our initial assumption, we have that $U_A=(V(C^e_j) \setminus S) \cap V(B^e_{i',j}) \not = \emptyset$ for some $i'\neq i$. By combining $K_a$ with any vertex of $U_A$, we obtain $K_h$ as a subgraph of $F \setminus S$, and the lemma follows. \end{proof} Note that Lemma~\ref{colu} is also valid for the minor version with the same $\mathcal{F}$-TM-framework. However, for our future constructions, we need this statement to hold for the (smaller) $\mathcal{F}$-M-framework as well, where $n_{h}=2$. \begin{lemma} \label{colu2} Let $\mathcal{F}$ be a family of graphs and let $(F,\ell)$ be the $\mathcal{F}$-M-framework of an input $(G,k)$ of {\sc $k\times k$ Permutation Independent Set}. Let $S$ be a solution of \textsc{$\mathcal{F}$-M-Deletion} on $(F,\ell)$ and let $e \in E(G)$ and $j \in \intv{1,k}$ such that the quantity $|V(C^e_j) \setminus S|$ is maximized, i.e., for all $e' \in E(G)$ and $j' \in \intv{1,k}$\ $|V(C^e_j) \setminus S|\geq |V(C^{e'}_{j'}) \setminus S|$. Then there exists $i \in \intv{1,k}$ such that $V(C^e_j) \setminus S \subseteq V(B^e_{i,j})$. \end{lemma} \begin{proof} Let $h = \min_{H \in \mathcal{F}}|V(H)|$. Recall that $\ell = (2(h-1)+2+t_\mathcal{F})(k-1)km$. Again, in order to prove the lemma, we show that the assumption that there exist $i_1,i_2 \in \intv{1,k}$, with $i_1 \not = i_2$ such that $(V(C^e_j) \setminus S) \cap V(B^e_{i_1,j}) \not = \emptyset$ and $(V(C^e_j) \setminus S) \cap V(B^e_{i_2,j}) \not = \emptyset$ implies that $F \setminus S$ contains $K_h$ as a minor, for any value of $t_\mathcal{F} \in \mathbb{N}$. Let us fix the value of $t_\mathcal{F} \in \mathbb{N}$. Let $e \in E(G)$ and $j \in \intv{1,k}$ be such that $|V(C^e_j) \setminus S|$ is maximized.\medskip We claim that $|V(C^e_j) \setminus S|\geq 2h+t_\mathcal{F}$. Indeed, if $|V(C^e_j) \setminus S|<2h+t_\mathcal{F}$, by the maximality in the choice of $e$ and $j$, it follows that $|V(C^{e'}_{j'}) \setminus S|\leq 2h+t_\mathcal{F}-1$, for all $e'\in E(G)$ and $j'\in[1,k]$. This implies that $|S\cap V(C_{j'}^{e'})|\geq |V(C_{j'}^{e'})|-(2h+t_\mathcal{F}-1)=k(2(h-1)+t_\mathcal{F}+2)-(2h+t_\mathcal{F}-1)=(2h+t_{\mathcal{F}})(k-1)+1$ for all $e'\in E(G)$ and $j'\in[1,k]$. As there are $m$ choices for $e'$ and $k$ choices for $i'$ we have that $$|S|\geq \bigcup_{e'\in E(G)\atop i'\in[1,k]}|S\cap V(C_{j'}^{e'})|\geq ((2h+t_{\mathcal{F}})(k-1)+1)km>(2h+t_{\mathcal{F}})(k-1)km=\ell,$$ a contradiction. We just proved that \begin{eqnarray} |V(C^e_j) \setminus S| & \geq &2h+t_\mathcal{F}.\label{sdafdfdss} \end{eqnarray} An edge $e\in E(C^e_j)$ is \emph{transversal} if there is no $i\in[1,k]$ such that both endpoints of $e$ belong to $B^e_{i,j}$. The important property of a transversal edge $e = \{v_1,v_2\}$ is that $N_{C^e_j}(\{v_1,v_2\}) = V(C^e_j) \setminus \{v_1,v_2\}$. A \emph{transversal matching} of $C^e_j$ is a matching that contains only transversal edges. Note that if there exists a transversal matching $M$ of size $h$ over a set of vertices $T \subseteq V(C^e_j)\setminus S$, then, by contracting every edge of $M$, it follows that $C^e_j[T]$, and therefore $F\setminus S$ as well, contains $K_h$ as a minor. Let $U_M$ be a set $V(B^e_{i,j}) \setminus S$, $i \in \intv{1,k}$, with the maximum number of elements. If $|U_M| \leq h+t_\mathcal{F}$, then, because of~\eqref{sdafdfdss}, the graph $C_j^e \setminus S$ contains a transversal matching of size at least $h$. This can be seen, for instance, by considering the complete $k$-partite graph where each part contains the vertices in $V(B^e_{i,j}) \setminus S$, for $i \in \intv{1,k}$, and noting that it admits a perfect matching (which defines a transversal matching in $C_j^e \setminus S$ of size at least $h$) by applying Tutte's criterion~\cite{Die10} on the existence of a perfect matching in a general graph (recall that a graph $G$ contains a perfect matching if and only if there is no set $S \subseteq V(G)$ whose removal generates more than $|S|$ odd-sized components). Thus $C_j^e \setminus S$, and therefore $F\setminus S$ as well, contains a clique of $h$ vertices as a minor. Assume now that $h+t_\mathcal{F} < |U_M|$. Let $a$ be the maximum size of a clique in $C^e_j[U_M]$. {As $h\geq 1$} we have that $|U_M| \geq t_\mathcal{F}+2$, therefore \begin{eqnarray} a & \geq & \left\lceil \frac{|U_M|-(t_\mathcal{F}+2)}{2} \right\rceil.\label{ki6ykl} \end{eqnarray} We claim that, if $|U_M|< 2h+t_\mathcal{F}$, then $F\setminus S$ contains a clique of $h$ vertices as a minor. For this, we set $U_A := V(C^e_j) \setminus (S \cup U_M)$ and we distinguish two cases, depending on the parity of the quantity $|U_M|-t_{\cal F}$.\medskip \noindent{\sl Case 1:} $|U_M| = t_\mathcal{F} + 2u$, with $h < 2u < 2h$. Then, from~\eqref{ki6ykl}, $a\geq (2u-2)/2$, therefore $C^e_j[U_M]$ contains a clique $K^*$ of size $u-1$ while the vertices of $C^e_j[U_M]$ that are not in $K^*$ are $t_\mathcal{F}+u+1$. Moreover, by~\eqref{sdafdfdss}, $ |U_A| \geq (2h+t_\mathcal{F}) -(t_\mathcal{F} + 2u) = 2h-2u$, so $C^e_j\setminus (S \cup V(K^*))$ contains a transversal matching of size at least $q:=\min\{2h-2u, t_\mathcal{F}+u+1\}$, which, when contracted, creates a clique $K^+$ of size at least $q$ whose vertices are connected with all $u-1$ vertices of $K^*$. Also, using the inequality $h < 2u < 2h$, we obtain \begin{eqnarray*} (u-1) + (t_\mathcal{F}+u+1) \geq 2u & >& h\mbox{~and~}\\ (u-1) + (2h-2u) = 2h-(u+1) & \geq & h, \end{eqnarray*} therefore, in any case, $(u-1)+q\geq h$. Thus, by taking $K^*$ with $K^+$ and all the edges between them, we deduce that $C^e_j\setminus S$, and therefore $F\setminus S$ as well, contains a clique of size at least $h$ as a minor. \medskip \noindent{\sl Case 2:} $|U_M| = t_\mathcal{F} + 2u+1$, with $h < 2u+1 < 2h$. Then $C^e_j[U_M]$ contains a clique $K^*$ of size $u$ and $t_\mathcal{F}+u+1$ vertices outside this clique $K^*$. Moreover, again by~\eqref{sdafdfdss}, $|U_A| \geq 2h-2u-1$, so $C^e_j\setminus (S \cup V(K^*))$ contains a transversal matching of size at least $q:=\min\{2h-2u-1, t_\mathcal{F}+u+1\}$. On the other hand, using the inequality $h < 2u+1 < 2h$, we know that \vspace{-9mm} \begin{eqnarray*} u + (t_\mathcal{F}+u+1) \geq 2u+1 & > & h \mbox{~and~} \\ u + (2h-2u-1) = 2h-(u+1) & \geq & h. \end{eqnarray*} Thus $u+q\geq h$, and, as in the previous case, we deduce that $C^e_j\setminus S$, and therefore $F\setminus S$ as well, contains a clique of size $h$ as a minor. The claim follows.\medskip Therefore, what remains is to examine the case where $|U_M| \geq 2h+t_\mathcal{F}$. In this case, because of \eqref{ki6ykl}, $C^e_j[U_M]$ contains a clique of size $a\geq (2h-2)/{2}=h-1$. Combining this clique with any vertex in a set $(V(C^e_j) \setminus S) \cap V(B^e_{i',j})$ that, because of our initial assumption, is non-empty for some $i'\neq i$, we obtain $K_h$ as a subgraph of $F \setminus S$, and the lemma follows. \end{proof} The purpose of Lemma~\ref{colu} and Lemma~\ref{colu2} is to obtain Lemma~\ref{reimitation} that states that for any solution $S$ of \textsc{$\mathcal{F}$-M-Deletion} (resp. \textsc{$\mathcal{F}$-TM-Deletion}) and for any $B^e_{i,j}$, $e \in E(G)$ and $(i,j) \in \intv{1,k}^2$, either $V(B^e_{i,j}) \cap S = \emptyset$ or {$V(B^e_{i,j}) \subseteq S$}. Moreover, there is exactly one $B^e_{i,j}$ such that $V(B^e_{i,j}) \cap S = \emptyset$ in each column $C^e_j$, $e \in E(G)$, $j \in \intv{1,k}$. \begin{lemma} \label{reimitation} Let $\mathcal{F}$ be a family of graphs and let $(F,\ell)$ be the $\mathcal{F}$-M-framework (resp. $\mathcal{F}$-TM-framework) of an input $(G,k)$ of {\sc $k\times k$ Permutation Independent Set}. For every solution $S$ of \textsc{$\mathcal{F}$-M-Deletion} (resp. \textsc{$\mathcal{F}$-TM-Deletion}) on $(F,\ell)$, for every $e \in E(G)$ and every $j \in \intv{1,k}$, there exists $i \in \intv{1,k}$ such that $V(C^e_j)\setminus S = V(B^e_{i,j})$. Moreover, for every $e \in E(G)$, $V(J^e) \cap S = \emptyset$. \end{lemma} \begin{proof} Let $S$ be a solution of \textsc{$\mathcal{F}$-M-Deletion} (resp. \textsc{$\mathcal{F}$-TM-Deletion}) on $(F,(n_h(h-1) +2 + t_\mathcal{F})(k-1)km)$. By Lemma~\ref{colu2} (resp. Lemma~\ref{colu}), we know that for every $e \in E(G)$ and every $j \in \intv{1,k}$, there is some $i$ such that for every $i'\in[1,k]\setminus\{i\}$, $B_{i',j}^{e}\subseteq S$. As each $B_{i,j}^{e}$ has $n_h(h-1) +2 + t_\mathcal{F}$ vertices, we obtain that $|V(C^e_j) \cap S| \geq (n_h(h-1) +2 + t_\mathcal{F})(k-1)$. As there are exactly $m$ edges and $k$ columns, the budget is tight and we obtain that $|V(C^e_j) \cap S| = (n_h(h-1) +2 + t_\mathcal{F})(k-1)$. This implies that $|V(C^e_j) \setminus S| = n_h(h-1) +2 + t_\mathcal{F}$, corresponding to the size of a set $B^e_{i,j}$, for some $i \in \intv{1,k}$. Moreover, as all the vertices of $S$ are vertices in the sets $D^e$, we also have that for every $e \in E(G)$, $V(J^e) \cap S = \emptyset$. The lemma follows. \end{proof} Using Lemma~\ref{reimitation}, for every edge $e\in E(G)$, it will be possible to make a correspondence between a permutation corresponding to a solution of {\sc $k\times k$ Permutation Independent Set} and the $k$ pairs $(i,j)$ in $\intv{1,k}^2$ for which $V(B^e_{i,j}) \cap S = \emptyset$. In order to ensure the consistency of the selected solution among the gadget graphs $D^e$, $e \in E(G)$, we need to show that given $(i,j) \in \intv{1,k}^2$, if there exists $e \in E(G)$ such that $V(B^e_{i,j}) \cap S = \emptyset$, then for every $e' \in E(G)$, we have $V(B^{e'}_{i,j}) \cap S = \emptyset$. For this, we state two properties, namely Property~\ref{new-wealthierm} and Property~\ref{new-wealthiertm}, applying to the minor and topological minor version of the problem, respectively. Then we prove Lemma~\ref{lemmasol}, stating that if the corresponding property holds, then we indeed have the desired consistency for the corresponding problem, which allows to find a solution of \textsc{$k\times k$ Permutation Independent Set}. \begin{prope} \label{new-wealthierm} Let $\mathcal{F}$ be a family of graphs and let $(F_\mathcal{F},\ell)$ be the enhanced $\mathcal{F}$-M-framework of an input $(G,k)$ of {\sc $k\times k$ Permutation Independent Set}. Let $S$ be a solution of \textsc{$\mathcal{F}$-M-Deletion} on $(F_\mathcal{F},\ell)$. For every $e \in E(G)$, and for every $i,j \in \intv{1,k}$, if $b^e_{i,j} \not \in S$ then for every $i'\in \intv{1,k} \setminus \{i\}$, we have $a^{\sigma(e)}_{i',j} \in S$. \end{prope} \begin{prope} \label{new-wealthiertm} Let $\mathcal{F}$ be a family of graphs and let $(F_\mathcal{F},\ell)$ be the enhanced $\mathcal{F}$-TM-framework of an input $(G,k)$ of {\sc $k\times k$ Permutation Independent Set}. Let $S$ be a solution of \textsc{$\mathcal{F}$-TM-Deletion} on $(F_\mathcal{F},\ell)$. For every $e \in E(G)$, and for every $i,j \in \intv{1,k}$, if $b^e_{i,j} \not \in S$ then for every $i'\in \intv{1,k} \setminus \{i\}$, we have $a^{\sigma(e)}_{i',j} \in S$. \end{prope} The above properties state that the choices of the vertices $a_{i,j}^e, b_{i,j}^e$ are consistent through the graph $F_\mathcal{F}$. \begin{lemma} \label{lemmasol} Let $\mathcal{F}$ be a family of graphs, let $(F_\mathcal{F},\ell)$ be the enhanced $\mathcal{F}$-M-framework (resp. enhanced $\mathcal{F}$-TM-framework) of an input $(G,k)$ of {\sc $k\times k$ Permutation Independent Set}. If Property~\ref{new-wealthierm} (resp. Property~\ref{new-wealthiertm}) holds and there exists a solution $S$ of \textsc{$\mathcal{F}$-M-Deletion} (resp. \textsc{$\mathcal{F}$-TM-Deletion}) on $(F_\mathcal{F},\ell)$, then, for any $e \in E(G)$, the set $T^e=\{(i,j) \mid V(B^e_{i,j}) \cap S = \emptyset\}$ is a solution of \textsc{$k\times k$ Permutation Independent Set} on $(G,k)$. Moreover, for any $e_1,e_2 \in E(G)$, $T^{e_1} = T^{e_2}$. \end{lemma} \begin{proof} Let $S$ be a solution of \textsc{$\mathcal{F}$-M-Deletion} (resp. \textsc{$\mathcal{F}$-TM-Deletion}) on $(F_\mathcal{F},\ell)$. Note that this implies that $S$ is also a solution of \textsc{$\mathcal{F}$-M-Deletion} (resp. \textsc{$\mathcal{F}$-TM-Deletion}) on $(F,\ell)$, the $\mathcal{F}$-M-framework (resp. $\mathcal{F}$-TM-framework) of $(G,k)$, and so, Lemma~\ref{reimitation} can be applied. Let $\sigma$ be the cyclic permutation associated with $F_\mathcal{F}$. For each $e \in E(G)$, let $T^e = \{(i,j) \mid V(B^e_{i,j}) \cap S = \emptyset\}$. By Lemma~\ref{reimitation}, for each $e \in E(G)$, $T^e$ contains exactly one element from each column. We first show that for any $e \in E(G)$, $T^e = T^{\sigma(e)}$. Let $e \in E(G)$ and let $(i,j) \in T^e$. As $(i,j) \in T^e$, we have that $b^e_{i,j} \not \in S$. By Property~\ref{new-wealthierm} (resp. Property~\ref{new-wealthiertm}), for each $i' \in \intv{1,k} \setminus \{i\}$ it holds that $a^{\sigma(e)}_{i',j} \in S$, and thus $(i',j) \not \in T^{\sigma(e)}$. As $T^{\sigma(e)}$ contains exactly one element from each column it follows that $(i,j) \in T^{\sigma(e)}$. As both $T^e$ and $T^{\sigma(e)}$ are of size exactly $k$, we obtain that $T^e = T^{\sigma(e)}$. By repeating the above argument iterating cyclically along the permutation $\sigma$, we obtain that for any $e_1,e_2 \in E(G)$, $T^{e_1} = T^{e_2}$. Let $(i,j),(i',j') \in T^{e_{1}}$. The existence of an edge $e = \{(i,j),(i',j')\}$ in $E(G)$ implies that in $D^e$, there is a vertex in $B^e_{i',j'}$ (in fact, any vertex of $B^e_{i',j'}$) that is fully connected to a copy of $K = K_{h-1}$ that is in $B^e_{i,j}$ (in fact, to all such copies), and so $D^e$ contains the clique $K_h$ as a subgraph. As $h = \min_{H \in \mathcal{F}}|V(H)|$, this is not possible, and therefore {$T^{e}$} is an independent set in $G$ of size $k$. Moreover, by the construction of $G$, {$T^e$} contains at most one vertex per row and by Lemma~\ref{reimitation}, it contains exactly one vertex per column. The lemma follows. \end{proof} Given a solution $P$ of {\sc $k\times k$ Permutation Independent Set} on $(G,k)$, we define $S_P = \{v \in V(F_\mathcal{F}) \mid v \in B^e_{i,j} : e \in E(G), (i,j) \in \intv{1,k}^2\setminus P\}$, where $(F_\mathcal{F},\ell)$ is the enhanced $\mathcal{F}$-framework of $(G,k)$. Note that $|S_P| = \ell$. In what follows we will prove that $S_{P}$ is a solution of \textsc{$\mathcal{F}$-M-Deletion} (or \textsc{$\mathcal{F}$-TM-Deletion}) on $(F_\mathcal{F},\ell)$ for each instantiation of $F_{\cal F}$ that we will consider. We now proceed to describe how to complete, starting from $F$, the construction of the enhanced $\mathcal{F}$-M-framework (or enhanced $\mathcal{F}$-TM-framework) $F_\mathcal{F}$, depending on ${\cal F}$, towards proving Theorems~\ref{hardgene},~\ref{hardminor}, and~\ref{hardtminor}. \subsection{The reduction for $\mathcal{F} \subseteq \mathcal{C}$} \label{globred} In order to prove Theorem~\ref{hardgene}, we will need some extra definitions. Given a finite graph $H$, we define the \emph{block edge size function} ${\sf besf}_H: \mathbb{N} \to \mathbb{N}$ to be such that for any $x \in \mathbb{N}$, ${\sf besf}_H(x)$ equals the number of edges of $H$ that are contained in a block with at least $x$ edges. Note that this function is a decreasing function and, as we only deal with finite graphs, for any finite graph $H$, there exists $x_0 \in \mathbb{N}$ such that ${\sf besf}_H(x_0) = 0$ (notice that the minimum such $x_0$ is one more than the maximum number of edges of a block of $H$). Given two block edge size functions $f$ and $g$, corresponding to two graphs, we say that $f \prec g$ if there exists an $x_0$, called a \emph{witness} of the inequality, such that $f(x_0) < g(x_0)$ and for each $x \geq x_0$, $f(x) \leq g(x)$. It can be verified that $\prec$ is a {total} order on the set $\{{\sf besf}_H\mid H\mbox{~is a finite graph}\}$. Note also that given two graphs $H$ and $H'$, if ${\sf besf}_H \prec {\sf besf}_{H'}$ then $H'$ cannot be a minor of $H$. Intuitively, if one considers only the blocks of $H'$ with at least $x_0$ edges, then there are too many edges to fit within the blocks of $H$ with at least $x_0$ edges, where $x_0$ is a witness of the inequality. Given an integer $k$ and a graph $H$ that contains at least one block with at least $k$ edges, a \emph{$k$-edges leaf block cut} is a tuple $(X,Y,B,v)$, where \begin{itemize} \item $B$ is a block with at least $k$ edges, \item $v\in V(B)$ is a cut vertex, or, in case $H$ is $2$-connected, any vertex of $H=B$, \item $X$ and $Y$ are two subsets of $V(H)$ such that $X \cup Y = V(H)$ and $X \cap Y = \{v\}$, \item $Y \setminus \{v\}$ is the vertex set of the connected component of $H \setminus \{v\}$ that contains $V(B) \setminus \{v\}$, and \item $H[Y]$ contains only one block with at least $k$ edges (which is precisely $B$). \end{itemize} Intuitively, $B$ would be a leaf of the block-cut tree of the graph $H'$ obtained from $H$ by iteratively removing every leaf block with at most $k-1$ edges from $\textsf{bct}(H)$, $v$ is the unique remaining neighbor of $B$ in $\textsf{bct}(H')$, $Y$ consists of $B$, and $X$ is the rest of the remaining graph together with $v$. Note that as long as $H$ contains at least one block with at least $k$ edges, there exists a $k$-edges leaf block cut. We are now ready to prove Theorem~\ref{hardgene}. \begin{proof}[Proof of Theorem~\ref{hardgene}] Let $\mathcal{F} \subseteq \mathcal{C}$ and let $(F,\ell)$ be the $\mathcal{F}$-M-framework (resp. $\mathcal{F}$-TM-framework) of an input $(G,k)$ of {\sc $k\times k$ Permutation Independent Set}, where $t_\mathcal{F} = 0$. Let $H\in \mathcal{F}$ be {a} graph that minimizes ${\sf besf}_H$ with regard to the relation $\prec$ over all the graphs of $\mathcal{F}$. Let $(X,Y,B,v)$ be a $5$-edge leaf block cut of $H$. Let $b = |{E}(B)|$, let $H_X = H[X]$, and let $H_Y = H[Y]$. Let $v'$ be a neighbor of $v$ in $B$ and $H^-_Y$ be the graph obtained from $H_Y$ by removing $\{v, v'\}$. Note that $H_X$ and $H_Y^-$ are connected and $H_Y$ contains only one block with at least five edges, and this block is precisely $B$. We are now ready to describe the graph $F_\mathcal{F}$. All the new vertices are $J$-extra vertices. Namely, starting from $F$, for each $e \in E(G)$, we add a copy of $H_X$, and we denote by $q^e$ the copy of $v$. For each $e \in E(G)$ and for each $i \in \intv{1,k}$, we add a copy of $H_Y^-$ where we identify $v$ and $q^e$, and $u$ and $r_i^e$. This completes the definition of $F_\mathcal{F}$. We stress that in this construction there are no $B$-extra vertices, i.e., $t_{\cal F}=0$. Let $P$ be a solution of {\sc $k\times k$ Permutation Independent Set} on $(G,k)$. Then every connected component of $F_\mathcal{F} \setminus S_P$ is either a copy of the graph $K$, which is of size $h-1$ (recall that $h = \min_{H \in \mathcal{F}}|V(H)|$), or the graph $Z$ depicted in Figure~\ref{reallocatedstretch}. We claim that ${\sf besf}_Z \prec {\sf besf}_H$ with witness $b$. Indeed, since $|E(H_{Y}^{-})|<|E(H_{Y})|$, $|E(B)| \geq 5$, and the blocks of $Z$ that are not copies of $H_{X}$ or $H_{Y}^{-}$ have four edges, it follows that ${\sf besf}_Z(b)<{\sf besf}_{H}(b)$, and ${\sf besf}_Z(b')\leq {\sf besf}_{H}(b')$ for all $b'>b$. Therefore, ${\sf besf}_Z \prec {\sf besf}_H$ with witness $b$. This in turn implies, because of the choice of $H$, that ${\sf besf}_Z \prec {\sf besf}_H'$ for each $H' \in \mathcal{F}$. Therefore, no $H'\in \mathcal{F}$ is a minor of the graph $Z$. Thus $S_P$ is a solution of \textsc{$\mathcal{F}$-M-Deletion} (resp. \textsc{$\mathcal{F}$-TM-Deletion}) of size $\ell$. \begin{figure}[htb] \centering \scalebox{1}{\begin{tikzpicture}[scale=1] \draw[white] (0,2) -- (-2,4) node[pos=0.5]{\textcolor{black}{\footnotesize{$H_Y^-$}}}; \draw[white] (0,4) -- (-2,4) node[pos=0.5]{\textcolor{black}{\footnotesize{$H_Y^-$}}}; \draw[white] (0,6) -- (-2,4) node[pos=0.5]{\textcolor{black}{\footnotesize{$H_Y^-$}}}; \node at (0.3,2.5) {\footnotesize{$r^{\sigma(e)}_{1}$}}; \node at (0.3,4.5) {\footnotesize{$r^{\sigma(e)}_{2}$}}; \node at (0.3,6.5) {\footnotesize{$r^{\sigma(e)}_{3}$}}; \node at (2,6.9) {\footnotesize{$a^{\sigma(e)}_{3,2}$}}; \node at (2,5.8) {\footnotesize{$b^{e}_{3,2}$}}; \node at (2,4.9) {\footnotesize{$a^{\sigma(e)}_{2,3}$}}; \node at (2,3.8) {\footnotesize{$b^{e}_{2,3}$}}; \node at (2,2.9) {\footnotesize{$a^{\sigma(e)}_{1,1}$}}; \node at (2,1.8) {\footnotesize{$b^{e}_{1,1}$}}; \node at (4,2.4) {\footnotesize{$c^{\sigma(e)}_{1}$}}; \node at (4,4.4) {\footnotesize{$c^{\sigma(e)}_{3}$}}; \node at (4,6.4) {\footnotesize{$c^{\sigma(e)}_{2}$}}; \node at (-2,4.5) {\footnotesize{$q^{\sigma(e)}$}}; \foreach \x in {2,4,6} { \vertex{2,\x+0.5}; \vertex{2,\x-0.5}; \vertex{4,\x}; \draw (0,\x) -- (2, \x+0.5) -- (4,\x) -- (2, \x-0.5) -- (0,\x); } \vertex{0,2}; \vertex{0,4}; \vertex{0,6}; \vertex{-2,4}; \draw[rounded corners=4mm] (-2.3,4) -- (-1,4.3) -- (0.2,4) -- (-1,3.7) -- cycle; \draw[rounded corners=4mm] (-2.2,3.8) -- (-1,5.4) -- (0.2,6.2) -- (-1,4.6) -- cycle; \draw[rounded corners=4mm] (-2.2,4.2) -- (-1,3.4) -- (0.2,1.8) -- (-1,2.6) -- cycle; \draw[rounded corners=4mm] (-1.5,4) -- (-3.5,4.7) -- (-3.5,3.3) -- cycle; \node at (-3,4) {\footnotesize{$H_X$}}; \end{tikzpicture}} \caption{A connected component $Z$ of $F_H \setminus S$ that is not a copy of $K$, with $T^e = \{(1,1), (2,3), (3,2)\}$. } \label{reallocatedstretch} \end{figure} Assume now that $S$ is a solution of \textsc{$\mathcal{F}$-M-Deletion} (resp. \textsc{$\mathcal{F}$-TM-Deletion}) on $F_{\cal F}$ of size $\ell$. Let $e \in E(G)$ and let $i,j \in \intv{1,k}$ such that $b^e_{i,j} \not \in S$. Let $i' \in \intv{1,k}$ such that $i \not = i'$. If $a^{\sigma(e)}_{i',j} \not \in S$, then, since by Lemma~\ref{reimitation} it holds that $S \cap V(J^{\sigma(e)}) = \emptyset$, we have that the copy of $H_X$, the copy of $H_Y^-$ between $q^{\sigma(e)}$ and $r^{\sigma(e)}_{i'}$, and the path that starts at $q^{\sigma(e)}$, goes through the corresponding copy of $H_Y^-$ until $r^{\sigma(e)}_{i}$, and continues with the vertices $b^e_{i,j}, c^{\sigma(e)}_{j}, a^{\sigma(e)}_{i',j}$, and $r^{\sigma(e)}_{i'}$, induce a graph that contains $H$ as a topological minor. This implies that if $a^{\sigma(e)}_{i',j} \not \in S$, $H$ is a topological minor of $F_\mathcal{F}\setminus S$. As this is not possible by definition of $S$, we have that $a^{\sigma(e)}_{i',j} \in S$. Thus Property~\ref{new-wealthierm} (resp. Property~\ref{new-wealthiertm}) holds and the theorem follows from Lemma~\ref{lemmasol}. \end{proof} \subsection{The reduction for \textsc{$\{H\}$-Deletion}} This section is dedicated to the proofs of Theorem~\ref{hardminor} and Theorem~\ref{hardtminor}, which we restate here for better readability. \begin{T4} Let $H \in \mathcal{Q}$. Unless the {\sf ETH}\xspace fails, \textsc{$\{H\}$-M-Deletion} cannot be solved in time $2^{o({\sf{tw}} \log {\sf{tw}})}\cdot n^{\mathcal{O}(1)}$. \end{T4} \begin{T5} Let $H \in \mathcal{Q}\setminus \mathcal{S}$. Unless the {\sf ETH}\xspace fails, \textsc{$\{H\}$-TM-Deletion} cannot be solved in time $2^{o({\sf{tw}} \log {\sf{tw}})}\cdot n^{\mathcal{O}(1)}$. \end{T5} Thus, we will focus on cases where the family $\mathcal{F}$ contains only one graph $H$. We start with a number of lemmas, namely Lemma~\ref{cycletwocut} up to Lemma~\ref{crickbisminor}, in which we distinguish several cases according to properties of $H$ such that its number of cut vertices and the presence of certain cycles and vertices of degree one. Altogether, these cases will cover all the possible graphs $H$ considered in Theorem~\ref{hardminor} and Theorem~\ref{hardtminor}. The proofs of each of these lemmas are quite similar and follow the same structure. Namely, we first describe the graph $F_{\{H\}}$, and then we prove the equivalence between the existence of solutions of {\sc $k\times k$ Permutation Independent Set} and \textsc{$\{H\}$-M-Deletion} (or \textsc{$\{H\}$-TM-Deletion}). In the reverse direction, we will prove that Property~\ref{new-wealthierm} and Property~\ref{new-wealthiertm} hold, and therefore we can apply Lemma~\ref{lemmasol}. Thanks to Theorem~\ref{hardgene}, we can assume that each block of $H$ contains at most four edges, i.e., each block of $H$ is an edge, a $C_3$, or a $C_4$. In this setting, we have $h = |V(H)|$. \begin{lemma} \label{cycletwocut} Let $H$ be a connected graph such that the number of cycles (of size three or four) in $H$ with at least two cut vertices is exactly one. Neither \textsc{$\{H\}$-M-Deletion} nor \textsc{$\{H\}$-TM-Deletion} can be solved in time $2^{o({\sf{tw}} \log {\sf{tw}})}\cdot n^{\mathcal{O}(1)}$ unless the {\sf ETH}\xspace fails. \end{lemma} \begin{proof} Let $(F,\ell)$ be the $\{H\}$-M-framework (resp. $\{H\}$-TM-framework) of an input $(G,k)$ of {\sc $k\times k$ Permutation Independent Set}, where $t_\mathcal{F} = 0$. Let $B$ be the block of $H$ with at least three edges and two cut vertices, and let $\{v,v'\}$ be an edge of $B$. Let $H^-$ be the graph $H$ where the edge $\{v,v'\}$ has been removed. We are now ready to describe the graph $F_{\{H\}}$. Starting from $F$, for each $e \in E(G)$ , we introduce a new vertex $q^e$. For each $e \in E(G)$ and each $i \in \intv{1,k}$, we add a copy of $H^-$ where we identify $v$ and $r_i^e$, and $v'$ and $q^e$. This completes the definition of $F_{\{H\}}$. Let $P$ be a solution of {\sc $k\times k$ Permutation Independent Set} on $(G,k)$. Then every connected component of $F_{\{H\}} \setminus S_P$ is either a copy of the graph $K$, which is of size $h-1$, or the graph $Z$ depicted in Figure~\ref{reallocatedbiss}. As $Z$ does not contain any cycle that contains at least two cut vertices, we obtain that $H$ is not a minor of $Z$. Thus $S_P$ is a solution of \textsc{$\{H\}$-M-Deletion} (resp. \textsc{$\{H\}$-TM-Deletion}) of size $\ell$. \begin{figure}[htb] \centering \scalebox{1}{\begin{tikzpicture}[scale=1] \node at (0,3.5) {\footnotesize{$r^{\sigma(e)}_{1}$}}; \node at (0,5.5) {\footnotesize{$r^{\sigma(e)}_{2}$}}; \node at (0,7.5) {\footnotesize{$r^{\sigma(e)}_{3}$}}; \node at (2,7.9) {\footnotesize{$a^{\sigma(e)}_{3,2}$}}; \node at (2,6.8) {\footnotesize{$b^{e}_{3,2}$}}; \node at (2,5.9) {\footnotesize{$a^{\sigma(e)}_{2,3}$}}; \node at (2,4.8) {\footnotesize{$b^{e}_{2,3}$}}; \node at (2,3.9) {\footnotesize{$a^{\sigma(e)}_{1,1}$}}; \node at (2,2.8) {\footnotesize{$b^{e}_{1,1}$}}; \node at (4,3.4) {\footnotesize{$c^{\sigma(e)}_{1}$}}; \node at (4,5.4) {\footnotesize{$c^{\sigma(e)}_{3}$}}; \node at (4,7.4) {\footnotesize{$c^{\sigma(e)}_{2}$}}; \node at (-3.5,5) {\footnotesize{$q^{\sigma(e)}$}}; \foreach \x in {3,5,7} { \vertex{2,\x+0.5}; \vertex{2,\x-0.5}; \vertex{4,\x}; \draw (0,\x) -- (2, \x+0.5) -- (4,\x) -- (2, \x-0.5) -- (0,\x); \draw (-3,5) -- (0,\x) node[pos=0.6, circle, draw, fill=white]{\footnotesize{$H^-$}}; } \vertex{0,3}; \vertex{0,5}; \vertex{0,7}; \vertex{-3,5}; \end{tikzpicture}} \caption{A connected component $Z$ of $F_{\{H\}} \setminus S_P$ that is not a copy of $K$, with $T^e = \{(1,1), (2,3), (3,2)\}$.} \label{reallocatedbiss} \end{figure} \begin{figure}[htb] \centering \scalebox{1}{\begin{tikzpicture}[scale=1] \node at (0.3,3.5) {\footnotesize{$r^{\sigma(e)}_{1}$}}; \node at (0.3,5.5) {\footnotesize{$r^{\sigma(e)}_{2}$}}; \node at (0.3,7.5) {\footnotesize{$r^{\sigma(e)}_{3}$}}; \node at (2,7.9) {\footnotesize{$a^{\sigma(e)}_{3,2}$}}; \node at (2,6.8) {\footnotesize{$b^{e}_{3,2}$}}; \node at (2,5.9) {\footnotesize{$a^{\sigma(e)}_{2,3}$}}; \node at (2,4.8) {\footnotesize{$b^{e}_{2,3}$}}; \node at (2,3.9) {\footnotesize{$a^{\sigma(e)}_{1,1}$}}; \node at (2,2.8) {\footnotesize{$b^{e}_{1,1}$}}; \node at (4,3.4) {\footnotesize{$c^{\sigma(e)}_{1}$}}; \node at (4,5.4) {\footnotesize{$c^{\sigma(e)}_{3}$}}; \node at (4,7.4) {\footnotesize{$c^{\sigma(e)}_{2}$}}; \node at (-2.5,5) {\footnotesize{$q^{\sigma(e)}$}}; \draw[white] (0,3) -- (-2,5) node[pos=0.5]{\textcolor{black}{\footnotesize{$H^-$}}}; \draw[white] (0,5) -- (-2,5) node[pos=0.5]{\textcolor{black}{\footnotesize{$H^-$}}}; \draw[white] (0,7) -- (-2,5) node[pos=0.5]{\textcolor{black}{\footnotesize{$H^-$}}}; \draw[rounded corners=4mm] (-2.3,5) -- (-1,5.3) -- (0.2,5) -- (-1,4.7) -- cycle; \draw[rounded corners=4mm] (-2.2,4.8) -- (-1,6.4) -- (0.2,7.2) -- (-1,5.6) -- cycle; \draw[rounded corners=4mm] (-2.2,5.2) -- (-1,4.4) -- (0.2,2.8) -- (-1,3.6) -- cycle; \foreach \x in {3,5,7} { \vertex{2,\x+0.5}; \vertex{2,\x-0.5}; \vertex{4,\x}; \draw (0,\x) -- (2, \x+0.5) -- (4,\x) -- (2, \x-0.5) -- (0,\x); } \vertex{0,3}; \vertex{0,5}; \vertex{0,7}; \vertex{-2,5}; \end{tikzpicture}} \caption{A connected component $Z$ of $F_{\{H\}} \setminus S_P$ that is not a copy of $K$, with $T^e = \{(1,1), (2,3), (3,2)\}$.} \label{reallocatedbissstretch} \end{figure} Assume now that $S$ is a solution of \textsc{$\{H\}$-M-Deletion} (resp. \textsc{$\{H\}$-TM-Deletion}) on $F_{\{H\}}$ of size $\ell$. Let $e \in E(G)$ and let $i,j \in \intv{1,k}$ such that $b^e_{i,j} \not \in S$. Let $i' \in \intv{1,k}$ such that $i \not = i'$. If $a^{\sigma(e)}_{i',j} \not \in S$, then, since by Lemma~\ref{reimitation} it holds that $S \cap V(J^{\sigma(e)}) = \emptyset$, we have that the path $ r^{\sigma(e)}_{i}, b^e_{i,j}, c^{\sigma(e)}_{j}, a^{\sigma(e)}_{i',j}, r^{\sigma(e)}_{i'}$ together with the two copies of $H^-$ attached to $q^{\sigma(e)}$ and $r^{\sigma(e)}_{i}$ and to $q^{\sigma(e)}$ and $r^{\sigma(e)}_{i'}$ induce a graph that contains $H$ as a topological minor. This implies that if $a^{\sigma(e)}_{i',j} \not \in S$, $H$ is a topological minor of $F_{\{H\}}\setminus S$. As this is not possible by definition of $S$, we have that $a^{\sigma(e)}_{i',j} \in S$. Thus Property~\ref{new-wealthierm} (resp. Property~\ref{new-wealthiertm}) holds and the lemma follows from Lemma~\ref{lemmasol}. \end{proof} We now assume that $H$ contains at least three cut vertices. In particular, this applies to the case where $H=P_{5}$. \begin{lemma} \label{threecut} Let $H$ be a connected graph that contains at least three cut vertices. Neither \textsc{$\{H\}$-M-Deletion} nor \textsc{$\{H\}$-TM-Deletion} can be solved in time $2^{o({\sf{tw}} \log {\sf{tw}})}\cdot n^{\mathcal{O}(1)}$ unless the {\sf ETH}\xspace fails. \end{lemma} \begin{proof} Let $(F,\ell)$ be the $\{H\}$-M-framework (resp. $\{H\}$-TM-framework) of an input $(G,k)$ of {\sc $k\times k$ Permutation Independent Set}, where $t_\mathcal{F}$ will be precised later. By Lemma~\ref{cycletwocut} and the fact that $H$ has at least three cut vertices, we can assume that $H$ contains at least three cut vertices that do not belong to the same block. Therefore, we can find three cut vertices $a$, $c$, $b$ and four blocks $B_a$, $B_{a,c}$, $B_{c,b}$, $B_b$ such that $B_a$ is a leaf of the block-cut tree of $H$ and $B_a$, $a$, $B_{a,c}$, $c$, $B_{c,b}$, $b$, $B_b$ is a path in this block-cut tree. Let $a'$ be a vertex of $V(B_a) \setminus \{a\}$ and $r$ be a vertex of $V(B_b) \setminus \{b\}$. We define $R_a$ to be the connected component of $H \setminus \{a',c\}$ that contains $a$, $R_b$ to be the connected component of $H \setminus \{c,r\}$ that contains $b$, $R_c$ to be the connected component of $H \setminus (R_a \cup R_b)$ that contains $c$, and $R_r$ to be the connected component of $H \setminus R_b$ that contains $r$. Note that $\{a'\}$, $V(R_a)$, $V(R_c)$, $V(R_b)$, and $V(R_r)$ form a partition of $V(H)$. This decomposition of $H$ is depicted in Figure~\ref{decomph}. \begin{figure}[htb] \centering \scalebox{1}{ \begin{tikzpicture} \draw (-1,1) -- (1,1); \draw (3,1) -- (4,1); \draw (-4,1) -- (-3, 1); \draw[rounded corners=4mm] (0,0.6) -- (1,3) -- (-1,3) -- cycle; \draw[rounded corners=4mm] (4,0.6) -- (5,3) -- (3,3) -- cycle; \vertex{0,1}; \vertex{4,1}; \node at (1.3,1) {{$R_b$}}; \node at (-2.7,1) {{$R_a$}}; \node at (0,2.3) {{$R_c$}}; \node at (4,2.3) {{$R_r$}}; \node at (0,0.65) {{$c$}}; \node at (4,0.65) {{$r$}}; \vertex{-2,1}; \vertex{2,1}; \node at (-2,0.7) {{$a$}}; \node at (2,0.7) {{$b$}}; \vertex{-4,1}; \node at (-4.2,1) {{$a'~$}}; \draw[rounded corners=4mm] (1,2) -- (1,0) -- (2,1.1) -- (3,0) -- (3,2) -- (2,0.9) -- cycle; \draw[rounded corners=4mm] (-3,2) -- (-3,0) -- (-2,1.1) -- (-1,0) -- (-1,2) -- (-2,0.9) -- cycle; \end{tikzpicture} } \caption{The decomposition of the graph $H$ where $a$, $c$, and $b$ are three cut vertices.} \label{decomph} \end{figure} We are now ready to describe the graph $F_{\{H\}}$. Starting from $F$, for each $e \in E(G)$ and each $i \in \intv{1,k}$, we add a copy of $R_c$ where we identify $c$ and $c^e_i$, and a copy of $R_r$ where we identify $r$ and $r^e_i$. Moreover, for each $e \in E(G)$ and each $i,j \in \intv{1,k}$ we add a copy of $R_a$ where we identify $a$ and $a^e_{i,j}$ and we connect the vertices $N_H(a') \cap R_a$ to $r^e_i$ and the vertices $N_H(c) \cap R_a$ to $c^e_j$. We also add a copy of $R_b$ where we identify $b$ and $b^e_{i,j}$ and we connect the vertices $N_H(c) \cap R_b$ to $c^{\sigma(e)}_j$ and the vertices $N_H(r) \cap R_b$ to $r^{\sigma(e)}_i$. Note that the vertices of the copies of $R_a$ and $R_b$ are $B$-extra vertices, and the vertices of the copies of $R_c$ and $R_r$ are $J$-extra vertices. In particular, we have $t_\mathcal{F} = |V(R_a) \cup V(R_b)| -2$ and, for each $e \in E(G)$, $|V(J^e)| = |V(R_c) \cup V(R_r)|\cdot k$. This completes the definition of $F_{\{H\}}$. Let $P$ be a solution of {\sc $k\times k$ Permutation Independent Set} on $(G,k)$. Then every connected component of $F_{\{H\}} \setminus S_P$ is either a copy of the graph $K$, which is of size $h-1$, or the graph $Z$ depicted in Figure~\ref{reallocatedbis}. As $Z$ contains $h-1$ vertices (both vertices $a'$ and $r$ of $H$ are mapped to $r^e_{i}$), we obtain that $H$ is not a minor of $F_{\{H\}} \setminus S_P$. Thus $S_P$ is a solution of \textsc{$\{H\}$-M-Deletion} (resp. \textsc{$\{H\}$-TM-Deletion}) of size $\ell$. \begin{figure}[htb] \centering \scalebox{1}{\begin{tikzpicture}[scale=1] \node at (0.2,0.5) {\footnotesize{$r^{\sigma(e)}_{2}$}}; \node at (2,2.3) {\footnotesize{$a^{\sigma(e)}_{2,3}$}}; \node at (2,-2.3) {\footnotesize{$b^{e}_{2,3}$}}; \node at (4,0.5) {\footnotesize{$c^{\sigma(e)}_{3}$}}; \vertex{2,1.5}; \vertex{2,-1.5}; \vertex{4,0}; \draw (0,0) -- (2, 1.5) -- (4,0) -- (2, -1.5) -- (0,0); \vertex{0,0}; \draw[rounded corners=4mm] (0.5,0) -- (-1.5,1) -- (-1.5,-1) -- cycle; \node at (-1,0){\footnotesize{$R_r$}}; \draw[rounded corners=4mm] (3.5,0) -- (5.5,1) -- (5.5,-1) -- cycle; \node at (5,0){\footnotesize{$R_c$}}; \draw (2,1.5) -- (4,0) node[pos=0, circle, draw, fill=white]{{$R_a$}}; \draw (2,-1.5) -- (4,0) node[pos=0, circle, draw, fill=white]{{$R_b$}}; \end{tikzpicture}} \caption{A connected component $Z$ of $F_{\{H\}} \setminus S$ that contains $b_{2,3}^e$ with $(2,3) \in T^e$.} \label{reallocatedbis} \end{figure} Assume now that $S$ is a solution of \textsc{$\{H\}$-M-Deletion} (resp. \textsc{$\{H\}$-TM-Deletion}) on $F_{\{H\}}$ of size $\ell$. Let $e \in E(G)$ and let $i,j \in \intv{1,k}$ such that $b^e_{i,j} \not \in S$. Let $i' \in \intv{1,k}$ such that $i \not = i'$. If $a^{\sigma(e)}_{i',j} \not \in S$, then, since by Lemma~\ref{reimitation} it holds that $S \cap V(J^{\sigma(e)}) = \emptyset$, we have that the vertex $r^{\sigma(e)}_{i'}$, the copy of $R_a$ attached to $a^{\sigma(e)}_{i',j}$, the copy of $R_c$ attached to $c^{\sigma(e)}_{j}$, the copy of $R_b$ attached to $ b^e_{i,j}$, and the copy of $R_r$ attached to $r^{\sigma(e)}_{i}$ induce the graph $H$. This implies that if $a^{\sigma(e)}_{i',j} \not \in S$, $H$ is a subgraph of $F_{\{H\}}\setminus S$. As this is not possible by definition of $S$, we have that $a^{\sigma(e)}_{i',j} \in S$. Thus Property~\ref{new-wealthierm} (resp. Property~\ref{new-wealthiertm}) holds and the lemma follows from Lemma~\ref{lemmasol}. \end{proof} In the next lemma, we consider the case where $H$ is a particular type of tree that covers the case where $H=K_{1,4}$ for the \textsc{$\{H\}$-M-Deletion} problem. \begin{lemma} \label{twocut} Let $H$ be a tree with at most two cut vertices and at least four vertices of degree one. \textsc{$\{H\}$-M-Deletion} cannot be solved in time $2^{o({\sf{tw}} \log {\sf{tw}})}\cdot n^{\mathcal{O}(1)}$ unless the {\sf ETH}\xspace fails. \end{lemma} \begin{proof} Let $(F,\ell)$ be the $\{H\}$-M-framework of an input $(G,k)$ of {\sc $k\times k$ Permutation Independent Set}, where $t_\mathcal{F}$ will be specified later. If $H$ has two cut vertices $x$ and $y$, then we set $s_x$ (resp. $s_y$) to be the number of vertices pendent to $x$ (resp. $y$). If $H$ has only one cut vertex, we set $s_x = p-2$ and $s_y = 2$, where $p$ is the number of vertices of degree one. We are now ready to describe the graph $F_{\{H\}}$. Starting from $F$, for each $e\in E(G)$ and each $i,j \in \intv{1,k}$, we add $s_x-1$ (resp. $s_y-1$) pendent vertices to $a^e_{i,j}$ (resp. $b^e_{i,j}$). Note that the pendent vertices are $B$-extra vertices. In particular we have $t_\mathcal{F} = p-2$ and, for each $e \in E(G)$, $|V(J^e)| = 2k$, i.e., there are no $J$-extra vertices. This completes the definition of $F_{\{H\}}$. Let $P$ be a solution of {\sc $k\times k$ Permutation Independent Set} on $(G,k)$. Then every connected component of $F_{\{H\}} \setminus S_T$ is either a copy of the graph $K$, which is of size $h-1$, or the subgraph induced by $a^e_{i,j}$, $r^e_i$, $b^{\sigma^{-1}(e)}_{i,j}$, $c_j^e$, and the vertices that are pendent to $a^e_{i,j}$ and $b^{\sigma^{-1}(e)}_{i,j}$, for every $(i,j) \in T$. It can be easily verified that, as by hypothesis, $s_x+s_y\geq 4$, this latter subgraph, depicted in Figure~\ref{reoffending}, does not contain $H$ as a minor. Thus $F_{\{H\}} \setminus S_T$ does not contain $H$ as a minor and $S_P$ is a solution of \textsc{$\{H\}$-M-Deletion} of size $\ell$. \begin{figure}[htb] \centering \scalebox{1}{\begin{tikzpicture}[scale=1] \node at (0,-0.4) {\footnotesize{$c^{\sigma(e)}_{j}$}}; \node at (0,2.3) {\footnotesize{$r^{\sigma(e)}_{i}$}}; \node at (-2.2,1.3) {\footnotesize{$b^e_{i,j}$}}; \node at (2.2,1.3) {\footnotesize{$a^{\sigma(e)}_{i,j}$}}; \vertex{0,0}; \vertex{0,2}; \vertex{-2,1}; \vertex{2,1}; \vertex{2,0.5}; \draw (2,1) -- (2,0.5); \draw (0,0) -- (-2,1) -- (0,2); \draw (0,0) -- (2,1) -- (0,2); \vertex{2.2,0.5}; \vertex{-2.2,0.5}; \vertex{-2,0.5}; \vertex{-1.8,0.5}; \draw (-2,1) -- (-2,0.5); \draw (-2,1) -- (-1.8,0.5); \draw (-2,1) -- (-2.2,0.5); \draw (2,1) -- (2.2,0.5); \node at (-2.2,0.1) {\scriptsize{$s_y-1$} pendent vertices}; \node at (2.2,0.1) {\scriptsize{$s_x-1$} pendent vertices}; \end{tikzpicture}} \caption{A connected component of $F_{\{H\}} \setminus S$ that is not a copy of $K$, with $s_x = 3$ and $s_y = 4$.} \label{reoffending} \end{figure} Assume now that $S$ is a solution of \textsc{$\{H\}$-M-Deletion} on $F_{\{H\}}$ of size $\ell$. Let $e \in E(G)$ and let $i,j \in \intv{1,k}$ such that $b^e_{i,j} \not \in S$. Let $i' \in \intv{1,k}$ such that $i \not = i'$. If $a^{\sigma(e)}_{i,'j} \not \in S$, then, as by Lemma~\ref{reimitation} it holds that $S \cap V(J^{\sigma(e)}) = \emptyset$, we have that the path $r^{\sigma(e)}_{i'},a^{\sigma(e)}_{i',j},c^{\sigma(e)}_{j},b^e_{i,j},r^e_{i}$ combined with the $s_x-1$ vertices pendent to $a^{\sigma(e)}_{i',j}$ and the $s_y-1$ vertices pendent to $b^e_{i,j}$ induce a graph $Z$ that contains $H$ as a minor. As, by definition of $S$, $F_{\{H\}} \setminus S$ does not contain $H$ as a minor, we have that $a^{\sigma(e)}_{i',j} \in S$. Thus Property~\ref{new-wealthierm} holds and the lemma follows from Lemma~\ref{lemmasol}. \end{proof} Observe that in the end of the above proof, if $H$ contains two cut vertices, then $Z$ also contains $H$ as a topological minor, but this is not true if $H$ is a star; this is consistent with the single-exponential algorithms given in~\cite{monster2}. Therefore, we obtain the following lemma for topological minors. \begin{lemma} \label{twocuttm} Let $H$ be a tree with exactly two cut vertices and at least four vertices of degree one. \textsc{$\{H\}$-TM-Deletion} cannot be solved in time $2^{o({\sf{tw}} \log {\sf{tw}})}\cdot n^{\mathcal{O}(1)}$ unless the {\sf ETH}\xspace fails. \end{lemma} \begin{lemma} \label{cyclestartwocut} Let $H$ be a connected graph that contains exactly two cut vertices and each cut vertex is part of a cycle. Neither \textsc{$\{H\}$-M-Deletion} nor \textsc{$\{H\}$-TM-Deletion} can be solved in time $2^{o({\sf{tw}} \log {\sf{tw}})}\cdot n^{\mathcal{O}(1)}$ unless the {\sf ETH}\xspace fails. \end{lemma} \begin{proof} Let $(F,\ell)$ be the $\{H\}$-M-framework (resp. $\{H\}$-TM-framework) of an input $(G,k)$ of {\sc $k\times k$ Permutation Independent Set}, where $t_\mathcal{F}= 0$. Thanks to Lemma~\ref{cycletwocut}, we can assume that the block containing both cut vertices is not a cycle, hence it is an edge. Let $v$ and $v'$ be the two cut vertices and let $H^-$ be the graph obtained from $H$ by contracting the edge $\{v,v'\}$. We denote by $w$ the new vertex. We are now ready to describe the graph $F_{\{H\}}$. We set $t_{\cal F}=0$. Starting from $F$, for each $e \in E(G)$ and each $i \in \intv{1,k}$ we add a copy of $H^-$ where we identify $w$ and $r^e_i$. In particular, for each $e \in E(G)$, $|V(J^e)| = (|V(H^-)|+1)\cdot k$. This completes the definition of $F_{\{H\}}$. Let $P$ be a solution of {\sc $k\times k$ Permutation Independent Set} on $(G,k)$. Then every connected component of $F_{\{H\}} \setminus S_P$ is either a copy of the graph $K$, which is of size $h-1$, or the graph $Z$ depicted in Figure~\ref{reallocatedbisss}. As $Z$ has only one cut vertex and every block of this graph is a minor of $C_4$, while $H\not \preceq_{\sf m} C_{4}$, we obtain that $H$ is not a minor of it. Thus $S_P$ is a solution of \textsc{$\{H\}$-M-Deletion} (resp. \textsc{$\{H\}$-TM-Deletion}) of size $\ell$. \begin{figure}[htb] \centering \scalebox{1}{\begin{tikzpicture}[scale=1] \node at (0,4.5) {\footnotesize{$r^{\sigma(e)}_{2}$}}; \node at (2,4.9) {\footnotesize{$a^{\sigma(e)}_{2,3}$}}; \node at (2,3.8) {\footnotesize{$b^{e}_{2,3}$}}; \node at (4,4.4) {\footnotesize{$c^{\sigma(e)}_{3}$}}; \foreach \x in {4} { \vertex{2,\x+0.5}; \vertex{2,\x-0.5}; \vertex{4,\x}; \draw (0,\x) -- (2, \x+0.5) -- (4,\x) -- (2, \x-0.5) -- (0,\x); } \vertex{0,4}; \draw (-1,4) -- (0,4) node[pos=0, circle, draw, fill=white]{\footnotesize{$B_b$}}; \end{tikzpicture}} \caption{A connected component $Z$ of $F_{\{H\}} \setminus S$ that is not a copy of $K$, that contains $b^e_{2,3}$ with $(2,3) \in P$, where $B_b$ means that we have attached $b\geq 2$ cycles to the vertex $r^{\sigma(e)}_{2}$.} \label{reallocatedbisss} \end{figure} Assume now that $S$ is a solution of \textsc{$\{H\}$-M-Deletion} (resp. \textsc{$\{H\}$-TM-Deletion}) on $F_{\{H\}}$ of size $\ell$. Let $e \in E(G)$ and let $i,j \in \intv{1,k}$ such that $b^e_{i,j} \not \in S$. Let $i' \in \intv{1,k}$ such that $i \not = i'$. If $a^{\sigma(e)}_{i',j} \not \in S$, then, since by Lemma~\ref{reimitation} it holds that $S \cap V(J^{\sigma(e)}) = \emptyset$, we have that the path $r^{\sigma(e)}_{i}, b^e_{i,j}, c^{\sigma(e)}_{j}, a^{\sigma(e)}_{i',j}, r^{\sigma(e)}_{i'}$ together with the copies of $H^-$ attached to $r^{\sigma(e)}_{i}$ and $r^{\sigma(e)}_{i'}$ induce a graph that contains $H$ as a minor. This implies that if $a^{\sigma(e)}_{i',j} \not \in S$, $H$ is a topological minor of $F_{\{H\}}\setminus S$. As this is not possible by definition of $S$, we have that $a^{\sigma(e)}_{i',j} \in S$. Thus Property~\ref{new-wealthierm} (resp. Property~\ref{new-wealthiertm}) holds and the lemma follows from Lemma~\ref{lemmasol}. \end{proof} \begin{lemma}\label{commander} Let $H$ be a connected graph with exactly two cut vertices such that exactly one of the two cut vertices is part of a cycle. Neither \textsc{$\{H\}$-M-Deletion} nor \textsc{$\{H\}$-TM-Deletion} can be solved in time $2^{o({\sf{tw}} \log {\sf{tw}})}\cdot n^{\mathcal{O}(1)}$ unless the {\sf ETH}\xspace fails. \end{lemma} \begin{proof} Let $(F,\ell)$ be the $\{H\}$-M-framework (resp. $\{H\}$-TM-framework) of an input $(G,k)$ of {\sc $k\times k$ Permutation Independent Set}, where $t_\mathcal{F} $ will be defined later. By assumption, the block containing both cut vertices is an edge. Let $x$ and $y$ be the two cut vertices. Let $C$ be a block that is a cycle, and without loss of generality we may assume that $x \in V(C)$. Let $H_x$ (resp. $H_y$) be the connected component of $H \setminus ((V(C) \cup \{y\}) \setminus \{x\})$ (resp. $H \setminus \{x\}$) that contains $x$ (resp. $y$) (see Figure~\ref{rlo4rtp}). \begin{figure}[htb] \centering \scalebox{1}{\begin{tikzpicture}[scale=0.9] \vertex{0,0}; \vertex{2,0}; \vertex{3.5,0.5}; \vertex{3.5,-0.5}; \vertex{3,-1}; \vertex{3,1}; \vertex{-1,0}; \draw (3.5,0.5) -- (2,0) -- (3.5,-0.5); \draw (3,1) -- (2,0) -- (3,-1); \draw (-1,0) -- (2,0); \node at (2,0.3) {{$y$}}; \node at (0.2,0.3) {{$x$}}; \node at (-0.25,1.3) {{$C$}}; \draw[rounded corners=4mm, dashed] (1.7,-0.5) -- (1.7, 0.5) -- (3,1.5) -- (4.1,0.5) -- (4.1,-0.5) -- (3,-1.5) -- cycle; \draw[rounded corners=1mm] (0,0) -- (0,1) -- (-0.5,1) -- (0,0); \draw[rounded corners=1mm] (0,0) -- (0,-1) -- (-0.5,-1) -- (0,0); \draw[rounded corners=1mm] (0,0) -- (-1,-1) -- (-1,-0.5) -- (0,0); \draw[rounded corners=4mm, dashed] (0.2,0.3) -- (-1.2, 0.3) -- (-1.2,-1.2) -- (0.2,-1.2) -- cycle; \node at (4.3,-0.7) {{$H_y$}}; \node at (-1.7,-0.7) {{$H_x$}}; \end{tikzpicture} } \caption{A visualization of $C$, $H_{x}$, and $H_{y}$ in $H$.} \label{rlo4rtp} \end{figure} We are now ready to describe the graph $F_{\{H\}}$. Starting from $F$, we add, for each $e \in E(G)$ and each $i,j \in \intv{1,k}$, a vertex $\overline{a}^e_{i,j}$ and the edges $\{\overline{a}^e_{i,j},r^e_i\}$ and $\{c^e_j,\overline{a}^{e}_{i,j}\}$. Moreover, for each $e \in E(G)$ and each $j \in \intv{1,k}$, we add a copy of $H_x$ where we identify $x$ and $c^e_j$, and a copy of $H_y$ where we identify $y$ and $r^e_{j}$. The vertices in the copies of $H_x$ and the copies of $H_y$ are $J$-extra vertices and the vertices $\overline{a}^e_{i,j}$, $e \in E(G)$ and $i,j \in \intv{1,k}$ are $B$-extra vertices. In particular, we have $t_\mathcal{F} = 1$ and, for each $e \in E(G)$, $|V(J^e)| = (|V(H_x)|+|V(H_y)|)\cdot k$. This completes the definition of $F_{\{H\}}$. Let $P$ be a solution of {\sc $k\times k$ Permutation Independent Set} on $(G,k)$. The connected components of $F_{\{H\}} \setminus S_P$ are either copies of the graph $K$, which is of size $h-1$, or the graph $Z$ depicted in Figure~\ref{pic1-cobannerbis}. Since $H_{y}$ has no cycles and $H_{x}$ has one cycle less than $H$, it follows that if $Z$ contains $H$ as a minor, then there is a cycle of this minor that contains both $c_j^{\sigma(e)}$ and $r_i^{\sigma(e)}$. But in that case we cannot find in $Z$ a block consisting of one edge whose both endpoints are cut vertices, corresponding to the edge $\{x,y\}$. We obtain that $H$ is not a minor of the depicted graph. Thus $F_{\{H\}} \setminus S_P$ does not contain $H$ as a minor and $S_P$ is a solution of \textsc{$\{H\}$-M-Deletion} (resp. \textsc{$\{H\}$-TM-Deletion}) of size $\ell$. \begin{figure}[htb] \centering \scalebox{1}{\begin{tikzpicture}[scale=0.9] \node at (0,4.5) {\footnotesize{$r^{\sigma(e)}_{i}$}}; \node at (2.4,0.5) {\footnotesize{$c^{\sigma(e)}_{j}$}}; \node at (1.6,2.6) {\footnotesize{$a^{\sigma(e)}_{i,j}$}}; \node at (3.5,3) {\footnotesize{$\overline{a}^{\sigma(e)}_{i,j}$}}; \node at (-2.5,2) {\footnotesize{$b^{e}_{i,j}$}}; \vertex{0,4}; \vertex{2,3}; \vertex{3,3}; \vertex{2.5,1}; \vertex{-2,2}; \draw (0,4) -- (2,3) -- (2.5,1) -- (-2,2) -- (0,4) -- (3,3) -- (2.5,1); \draw[rounded corners=4mm] (2,1) -- (4,0.3) -- (4,1.7) -- cycle; \node at (3.5,1) {\footnotesize{$H_x$}}; \draw[rounded corners=4mm] (0.5,4) -- (-1.5,4.7) -- (-1.5,3.3) -- cycle; \node at (-1,4) {\footnotesize{$H_y$}}; \end{tikzpicture}} \caption{A connected component $Z$ of $F_{\{H\}} \setminus S$ that is not a copy of $K$. } \label{pic1-cobannerbis} \end{figure} Assume now that $S$ is a solution of \textsc{$\{H\}$-M-Deletion} (resp. \textsc{$\{H\}$-TM-Deletion}) on $F_{\{H\}}$ of size $\ell$. Let $e \in E(G)$ and let $i,j \in \intv{1,k}$ such that $b^e_{i,j} \not \in S$. Let $i' \in \intv{1,k}$ such that $i \not = i'$. If $a^{\sigma(e)}_{i',j} \not \in S$ then, as by Lemma~\ref{reimitation} $S \cap V(J^{\sigma(e)}) = \emptyset$, it follows that the $C_{4}$ induced by $r^{\sigma(e)}_{i'},a^{\sigma(e)}_{i',j},c^{\sigma(e)}_{j},\overline{a}^{\sigma(e)}_{i',j},$ the path $c^{\sigma(e)}_{j},b^e_{i,j},r^{\sigma(e)}_{i}$, together with the copy of $H_x$ attached to $c^{\sigma(e)}_{j}$ and the copy of $H_y$ attached to $r^{\sigma(e)}_{i}$ induce a subgraph of $F_{\{H\}}\setminus S$ that contains $H$ as a topological minor. This subgraph, together with an extra copy of $H_{y}$ attached to $r_{i'}^{\sigma(e)}$, is depicted in Figure~\ref{pic2-cobannerbis}. As this is forbidden by definition of $S$, we have that $a^{\sigma(e)}_{i',j} \in S$. Thus Property~\ref{new-wealthierm} (resp. Property~\ref{new-wealthiertm}) holds and the lemma follows from Lemma~\ref{lemmasol}. \end{proof} \vspace{-.2cm} \begin{figure}[htb] \centering \scalebox{1}{\begin{tikzpicture}[scale=0.75] \node at (0,4.5) {\footnotesize{$r^{\sigma(e)}_{i}$}}; \node at (0.2,6.5) {\footnotesize{$r^{\sigma(e)}_{i'}$}}; \node at (2.5,0.5) {\footnotesize{$c^{\sigma(e)}_{j}$}}; \node at (1.5,4.6) {\footnotesize{$a^{\sigma(e)}_{i',j}$}}; \node at (3.6,5) {\footnotesize{$\overline{a}^{\sigma(e)}_{i',j}$}}; \node at (-2.5,3) {\footnotesize{$b^{e}_{i,j}$}}; \vertex{0,4}; \vertex{0,6}; \vertex{2,5}; \vertex{3,5}; \vertex{2.5,1}; \vertex{-2,3}; \draw (0,6) -- (2,5) -- (2.5,1) -- (-2,3) -- (0,4); \draw (0,6) -- (3,5) -- (2.5,1); \draw[rounded corners=4mm] (2,1) -- (4,0.3) -- (4,1.7) -- cycle; \node at (3.5,1) {\footnotesize{$H_x$}}; \draw[rounded corners=4mm] (0.5,6) -- (-1.5,6.7) -- (-1.5,5.3) -- cycle; \node at (-1,6) {\footnotesize{$H_y$}}; \draw[rounded corners=4mm] (0,4.5) -- (0.7,2.5) -- (-0.7,2.5) -- cycle; \node at (0,3) {\footnotesize{$H_y$}}; \end{tikzpicture}} \caption{A connected component $Z$ of $F_{\{H\}} \setminus S$ if $b^e_{i,j} \not \in S$ and $a^{\sigma(e)}_{i',j} \not \in S$ for some $e \in E(G)$, $i,i',j \in \intv{1,k}$, $i \not = i'$.} \label{pic2-cobannerbis} \end{figure} \begin{lemma}\label{butternutbis} Let $H$ be a connected graph with exactly one cut vertex and at least two cycles. Neither \textsc{$\{H\}$-M-Deletion} nor \textsc{$\{H\}$-TM-Deletion} can be solved in time $2^{o({\sf{tw}} \log {\sf{tw}})}\cdot n^{\mathcal{O}(1)}$ unless the {\sf ETH}\xspace fails. \end{lemma} \begin{proof} Let $(F,\ell)$ be the $\{H\}$-M-framework (resp. $\{H\}$-TM-framework) of an input $(G,k)$ of {\sc $k\times k$ Permutation Independent Set}, where $t_\mathcal{F}$ will be specified later. Let $x$ be the cut vertex of $H$, and let $B_1$ and $B_2$ be two blocks that are cycles. We define the graph $H_x$ to be $H \setminus (V(B_1 \cup B_2) \setminus \{x\})$. We are now ready to describe the graph $F_{\{H\}}$. Starting from $F$, we add, for each $e \in E(G)$ and each $i,j \in \intv{1,k}$, two new vertices $\overline{a}_{i,j}^{e}$ and $\overline{b}_{i,j}^{e}$ and the edges $\{\overline{a}^e_{i,j},r^e_i\}$, $\{r^e_i,\overline{b}^{\sigma^{-1}(e)}_{i,j}\}$, $\{\overline{b}^{\sigma^{-1}(e)}_{i,j},c^e_j\}$, and $\{c^e_j,\overline{a}_{i,j}\}$. Then for each $e \in E(G)$ and each $j \in \intv{1,k}$ we add a copy of $H_x$ where we identify $x$ with $c^e_j$. The vertices in the copies of $H_x$ are $J$-extra vertices and the vertices $\overline{a}_{i,j}^{e}$ and $\overline{b}_{i,j}^{e}$, $i,j \in \intv{1,k}$ and $e \in E(G)$, are $B$-extra vertices. In particular we have $t_\mathcal{F} = 2$ and, for each $e \in E(G)$, $|V(J^e)| = (|V(H_x)|+1)\cdot k$. This completes the definition of $F_{\{H\}}$. Let $P$ be a solution of {\sc $k\times k$ Permutation Independent Set} on $(G,k)$. Then every connected component of $F_{\{H\}} \setminus S_P$ is either a copy of the graph $K$, which is of size $h-1$, or the graph $Z$ depicted in Figure~\ref{butbis}. Since $Z$ has only one block more than $H_{x}$, it follows that $Z$ does not contain $H$ as a minor. Thus $F \setminus S_T$ does not contain $H$ as a minor, and $S_P$ is a solution of \textsc{$\{H\}$-M-Deletion} (resp. \textsc{$\{H\}$-TM-Deletion}) of size $\ell$. \begin{figure}[htb] \centering \scalebox{1}{\begin{tikzpicture}[scale=0.8] \node at (0,4.5) {\footnotesize{$r^{\sigma(e)}_{i}$}}; \node at (2.2,0.5) {\footnotesize{$c^{\sigma(e)}_{j}$}}; \node at (1.6,2.6) {\footnotesize{$a^{\sigma(e)}_{i,j}$}}; \node at (3.6,3) {\footnotesize{$\overline{a}^{\sigma(e)}_{i,j}$}}; \node at (-3.45,3) {\footnotesize{$b^{e}_{i,j}$}}; \node at (-1.2,3) {\footnotesize{$\overline{b}^{e}_{i,j}$}}; \vertex{0,4}; \vertex{2,3}; \vertex{3,3}; \vertex{2.5,1}; \vertex{-2,3}; \vertex{-3,3}; \draw (0,4) -- (2,3) -- (2.5,1) -- (-2,3) -- (0,4) -- (3,3) -- (2.5,1) -- (-3,3) -- (0,4); \draw[rounded corners=4mm] (2,1) -- (4,0.3) -- (4,1.7) -- cycle; \node at (3.5,1) {\footnotesize{$H_x$}}; \end{tikzpicture}} \caption{A connected component $Z$ of $F_{\{H\}} \setminus S$ that is not a copy of $K$.} \label{butbis} \end{figure} Assume now that $S$ is a solution of \textsc{$\{H\}$-M-Deletion} on $F_{\{H\}}$ of size $\ell$. Let $e \in E(G)$ and let $i,j \in \intv{1,k}$ such that $b^e_{i,j} \not \in S$. Let $i' \in \intv{1,k}$ such that $i \not = i'$. If $a^{\sigma(e)}_{i',j} \not \in S$ then, as by Lemma~\ref{reimitation} $S \cap V(J^{\sigma(e)}) = \emptyset$, we have that the graph induced by the two paths $r^{\sigma(e)}_{i'},a^{\sigma(e)}_{i',j},c^{\sigma(e)}_{j},b^e_{i,j},r^{\sigma(e)}_{i}$ and $r^{\sigma(e)}_{i'},\overline{a}^{\sigma(e)}_{i',j},c^{\sigma(e)}_{j},\overline{b}^e_{i,j},r^{\sigma(e)}_{i}$, together with the copy of $H_x$ attached to $c^{\sigma(e)}_{j}$, depicted in Figure~\ref{countdownbis}, is a subgraph of $F\setminus S$ containing $H$ as a topological minor. As this is forbidden by definition of $S$, we have that $a^{\sigma(e)}_{i',j} \in S$. Thus Property~\ref{new-wealthierm} (resp. Property~\ref{new-wealthiertm}) holds and the lemma follows from Lemma~\ref{lemmasol}. \begin{figure}[htb] \centering \scalebox{1}{\begin{tikzpicture}[scale=0.7] \node at (0,4.5) {\footnotesize{$r^{\sigma(e)}_{i}$}}; \node at (0,6.5) {\footnotesize{$r^{\sigma(e)}_{i'}$}}; \node at (2.2,0.5) {\footnotesize{$c^{\sigma(e)}_{j}$}}; \node at (1.5,4.6) {\footnotesize{$a^{\sigma(e)}_{i',j}$}}; \node at (3.7,5) {\footnotesize{$\overline{a}^{\sigma(e)}_{i',j}$}}; \node at (-3.5,3) {\footnotesize{$b^{e}_{i,j}$}}; \node at (-1.,3) {\footnotesize{$\overline{b}^{e}_{i,j}$}}; \vertex{0,4}; \vertex{0,6}; \vertex{2,5}; \vertex{3,5}; \vertex{2.5,1}; \vertex{-2,3}; \vertex{-3,3}; \draw (0,6) -- (2,5) -- (2.5,1) -- (-2,3) -- (0,4); \draw (0,6) -- (3,5) -- (2.5,1) -- (-3,3) -- (0,4); \draw[rounded corners=4mm] (2,1) -- (4,0.3) -- (4,1.7) -- cycle; \node at (3.5,1) {\footnotesize{$H_x$}}; \end{tikzpicture}} \caption{A connected component $Z$ of $F_{\{H\}} \setminus S$, if $b^e_{i,j} \not \in S$ and $a^{\sigma(e)}_{i',j} \not \in S$ for some $e \in E(G)$, $i,i',j \in \intv{1,k}$, $i \not = i'$.} \label{countdownbis} \end{figure} \end{proof} In the next two lemmas, namely Lemma~\ref{crickbisminor} and Lemma~\ref{crickbistm}, we deal separately with the minor and topological minor versions, respectively. \begin{lemma}\label{crickbisminor} Let $H$ be a connected graph with exactly one cut vertex and exactly one cycle such that $H$ is not a minor of the {\sf banner}\xspace. \textsc{$\{H\}$-M-Deletion} cannot be solved in time $2^{o({\sf{tw}} \log {\sf{tw}})}\cdot n^{\mathcal{O}(1)}$ unless the {\sf ETH}\xspace fails. \end{lemma} \begin{proof} Let $(F,\ell)$ be the $\{H\}$-M-framework of an input $(G,k)$ of {\sc $k\times k$ Permutation Independent Set}, where $t_\mathcal{F}$ will be specified later. Let $s$ be the number of vertices of degree one in $H$. As $H$ is not a minor of the {\sf banner}\xspace and (because of ~Theorem~\ref{hardgene}) we can assume that each block of $H$ contains at most four edges, we have that $s \geq 2$. We are now ready to describe the graph $F_{\{H\}}$. Starting from $F$, we add, for each $e \in E(G)$ and each $j \in \intv{1,k}$, three new vertices $d^e_j$, $f^e_j$, and $g^e_j$ and the edges $\{d^e_j,f^e_j\}$ and $\{f^e_j,g^e_j\}$. Moreover, for each $e \in E(G)$ and each $i,j \in \intv{1,k}$, we add the edges $\{b^{\sigma^{-1}(e)}_{i,j},d^e_j\}$ and $\{g^e_j,a_{i,j}\}$, and $s-2$ vertices pendent to $b^e_{i,j}$. The vertices $d^e_j$, $f^e_j$, and $g^e_j$, $j \in \intv{1,k}$ and $e \in E(G)$, are $J$-extra vertices, and the pendent vertices are $B$-extra vertices. In particular we have $t_\mathcal{F} = s-2$ and, for each $e \in E(G)$, $|V(J^e)| = 5 k$. This completes the definition of $F_{\{H\}}$. Let $P$ be a solution of {\sc $k\times k$ Permutation Independent Set} on $(G,k)$. Then every connected component of $F_{\{H\}} \setminus S_P$ is either a copy of the graph $K$, which is of size $h-1$, or the graph $Z$ depicted in Figure~\ref{cowbis}. Note that $Z$ contains three different cycles, but for each of them some pendent edge is missing in order to find $H$ as a minor. Thus $F \setminus S_P$ does not contain $H$ as a minor, and $S_P$ is a solution of \textsc{$\{H\}$-M-Deletion}. \begin{figure}[htb] \centering \scalebox{1}{\begin{tikzpicture}[scale=0.9] \node at (0,4.5) {\footnotesize{$r^{\sigma(e)}_{i}$}}; \node at (1,0.5) {\footnotesize{$c^{\sigma(e)}_{j}$}}; \node at (2,0.5) {\footnotesize{$d^{\sigma(e)}_{j}$}}; \node at (3,0.5) {\footnotesize{$f^{\sigma(e)}_{j}$}}; \node at (4,0.5) {\footnotesize{$g^{\sigma(e)}_{j}$}}; \node at (3,3) {\footnotesize{$a^{\sigma(e)}_{i,j}$}}; \node at (-2.5,3) {\footnotesize{$b^{e}_{i,j}$}}; \vertex{0,4}; \vertex{2.5,3}; \vertex{1,1}; \vertex{2,1}; \vertex{3,1}; \vertex{4,1}; \vertex{-2,3}; \vertex{-2,2}; \vertex{-2.4,2}; \draw (-2,3) -- (-2,2); \draw (-2,3) -- (-2.4,2); \node at (-2.2,1.5) {\scriptsize{$s-2$} pendent vertices}; \draw (-2,3) -- (1,1) -- (2.5,3) -- (0,4) -- (-2,3) -- (2,1) -- (4,1) -- (2.5,3); \end{tikzpicture}} \caption{A connected component $Z$ of $F_{\{H\}} \setminus S$ that is not a copy of $K$ with $s = 4$.} \label{cowbis} \end{figure} Assume now that $S$ is a solution of \textsc{$\{H\}$-M-Deletion}. Let $e \in E(G)$ and let $i,j \in \intv{1,k}$ such that $b^e_{i,j} \not \in S$. Let $i' \in \intv{1,k}$ such that $i \not = i'$. If $a^{\sigma(e)}_{i',j} \not \in S$ then, as by Lemma~\ref{reimitation} $S \cap V(J^{\sigma(e)}) = \emptyset$, we have that the graph $Z$ induced by the two paths $r^{\sigma(e)}_{i'},a^{\sigma(e)}_{i',j},c^{\sigma(e)}_{j},b^e_{i,j},r^{\sigma(e)}_{i}$ and ${a}^{\sigma(e)}_{i',j},g^{\sigma(e)}_{j}, f^{\sigma(e)}_{j}, {d}^{\sigma(e)}_{j}, {b}^e_{i,j}$, and the $s-2$ vertices pendent to ${b}^e_{i,j}$, depicted in Figure~\ref{supercowbis}, is a subgraph of $F_{\{H\}}\setminus S$ containing $H$ as a minor. As this is forbidden by definition of $S$, we have that $a^{\sigma(e)}_{i',j} \in S$. Thus Property~\ref{new-wealthierm} holds and the lemma follows from Lemma~\ref{lemmasol}. \begin{figure}[htb] \centering \scalebox{1}{\begin{tikzpicture}[scale=0.85] \node at (0,4.5) {\footnotesize{$r^{\sigma(e)}_{i}$}}; \node at (0,6.5) {\footnotesize{$r^{\sigma(e)}_{i'}$}}; \node at (1,0.5) {\footnotesize{$c^{\sigma(e)}_{j}$}}; \node at (2,0.5) {\footnotesize{$d^{\sigma(e)}_{j}$}}; \node at (3,0.5) {\footnotesize{$f^{\sigma(e)}_{j}$}}; \node at (4,0.5) {\footnotesize{$g^{\sigma(e)}_{j}$}}; \node at (3.1,5) {\footnotesize{$a^{\sigma(e)}_{i',j}$}}; \node at (-2.5,3) {\footnotesize{$b^{e}_{i,j}$}}; \vertex{0,4}; \vertex{0,6}; \vertex{2.5,5}; \vertex{1,1}; \vertex{2,1}; \vertex{3,1}; \vertex{4,1}; \vertex{-2,3}; \draw (-2,3) -- (1,1) -- (2.5,5) -- (0,6); \draw (0,4) -- (-2,3) -- (2,1) -- (4,1) -- (2.5,5); \vertex{-2,2}; \vertex{-2.4,2}; \draw (-2,3) -- (-2,2); \draw (-2,3) -- (-2.4,2); \node at (-2.2,1.5) {\scriptsize{$s-2$} pendent vertices}; \end{tikzpicture}} \caption{A connected component $Z$ of $F_{\{H\}} \setminus S$, if $b^e_{i,j} \not \in S$ and $a^{\sigma(e)}_{i',j} \not \in S$ for some $e \in E(G)$, $i,i',j \in \intv{1,k}$, $i \not = i'$ where $s = 4$.} \label{supercowbis} \end{figure} \end{proof} \begin{lemma}\label{crickbistm} Let $H$ be a connected graph with exactly one cut vertex and exactly one cycle such that $H$ is not a minor of the {\sf banner}\xspace. \textsc{$\{H\}$-TM-Deletion} cannot be solved in time $2^{o({\sf{tw}} \log {\sf{tw}})}\cdot n^{\mathcal{O}(1)}$ unless the {\sf ETH}\xspace fails. \end{lemma} \begin{proof} Let $(F,\ell)$ be the $\{H\}$-TM-framework of an input $(G,k)$ of {\sc $k\times k$ Permutation Independent Set}, where $t_\mathcal{F}$ will be specified later. Let $s$ be the number of vertices of degree one in $H$. As in Lemma~\ref{crickbisminor}, since $H$ is not a minor of the {\sf banner}\xspace and (because of ~Theorem~\ref{hardgene}) we can assume that each block of $H$ contains at most four edges, we have that $s \geq 2$. We are now ready to describe the graph $F_{\{H\}}$. Starting from $F$, we add, for each $e \in E(G)$, a vertex $q^{e}$ and $s$ vertices pendent to $q^e$, and for each $e \in E(G)$ and each $j \in \intv{1,k}$, the edge $\{q^e, r^e_{j}\}$. The vertices $q^e$, $e \in E(G)$, and the pendent vertices are $J$-extra vertices. In particular we have $t_\mathcal{F} = 0$ and, for each $e \in E(G)$, $|V(J^e)| = 2k+s+1$. This completes the definition of $F_{\{H\}}$. Note that this construction is similar to the construction provided in Section~\ref{globred} with $H_x$ being a star with $s$ leaves, $x$ the non-leaf vertex, and $H_Y^-$ an edge. Let $P$ be a solution of {\sc $k\times k$ Permutation Independent Set} on $(G,k)$. Then every connected component of $F_{\{H\}} \setminus S_P$ is either a copy of the graph $K$, which is of size $h-1$, or the graph $Z$ depicted in Figure~\ref{reallocatedbissstretchnew}. Note that each vertex of $Z$ contained in a cycle is of degree at most three. Since $s\geq 2$, there is a vertex in $H$ of degree at least four contained in a cycle. Thus $F \setminus S_P$ does not contain $H$ as a topological minor, and $S_P$ is a solution of \textsc{$\{H\}$-TM-Deletion}. \begin{figure}[htb] \centering \scalebox{1}{\begin{tikzpicture}[scale=1] \node at (0.3,3.5) {\footnotesize{$r^{\sigma(e)}_{1}$}}; \node at (0.3,5.5) {\footnotesize{$r^{\sigma(e)}_{2}$}}; \node at (0.3,7.5) {\footnotesize{$r^{\sigma(e)}_{3}$}}; \node at (2,7.9) {\footnotesize{$a^{\sigma(e)}_{3,2}$}}; \node at (2,6.8) {\footnotesize{$b^{e}_{3,2}$}}; \node at (2,5.9) {\footnotesize{$a^{\sigma(e)}_{2,3}$}}; \node at (2,4.8) {\footnotesize{$b^{e}_{2,3}$}}; \node at (2,3.9) {\footnotesize{$a^{\sigma(e)}_{1,1}$}}; \node at (2,2.8) {\footnotesize{$b^{e}_{1,1}$}}; \node at (4,3.4) {\footnotesize{$c^{\sigma(e)}_{1}$}}; \node at (4,5.4) {\footnotesize{$c^{\sigma(e)}_{3}$}}; \node at (4,7.4) {\footnotesize{$c^{\sigma(e)}_{2}$}}; \node at (-2.5,5) {\footnotesize{$q^{\sigma(e)}$}}; \foreach \x in {3,5,7} { \vertex{2,\x+0.5}; \vertex{2,\x-0.5}; \vertex{4,\x}; \draw (0,\x) -- (2, \x+0.5) -- (4,\x) -- (2, \x-0.5) -- (0,\x); \draw (-2,5) -- (0,\x); } \vertex{0,3}; \vertex{0,5}; \vertex{0,7}; \vertex{-2,5}; \vertex{-2,4}; \vertex{-2.4,4}; \draw (-2,5) -- (-2,4); \draw (-2,5) -- (-2.4,4); \node at (-2.5,3.5) {\scriptsize{$s$} pendent vertices}; \end{tikzpicture}} \caption{A connected component $Z$ of $F_{\{H\}} \setminus S_P$ that is not a copy of $K$, with $T^e = \{(1,1), (2,3), (3,2)\}$ and $s=2$.} \label{reallocatedbissstretchnew} \end{figure} Assume now that $S$ is a solution of \textsc{$\{H\}$-TM-Deletion}. Let $e \in E(G)$ and let $i,j \in \intv{1,k}$ such that $b^e_{i,j} \not \in S$. Let $i' \in \intv{1,k}$ such that $i \not = i'$. If $a^{\sigma(e)}_{i',j} \not \in S$ then, as by Lemma~\ref{reimitation} $S \cap V(J^{\sigma(e)}) = \emptyset$, we have that the graph $Z$ induced, by the cycle $q^{\sigma(e)},r^{\sigma(e)}_{i'},a^{\sigma(e)}_{i',j},c^{\sigma(e)}_{j},b^e_{i,j},r^{\sigma(e)}_{i}, q^{\sigma(e)}$ and the $s$ vertices pendent to $q^{\sigma(e)}$, is a subgraph of $F_{\{H\}}\setminus S$ containing $H$ as a topological minor. This situation is depicted in Figure~\ref{reallocatedbissstretchnewbis}. As this is forbidden by definition of $S$, we have that $a^{\sigma(e)}_{i',j} \in S$. Thus Property~\ref{new-wealthiertm} holds and the lemma follows from Lemma~\ref{lemmasol}. \begin{figure}[htb] \centering \scalebox{1}{\begin{tikzpicture}[scale=1] \node at (0.3,3.5) {\footnotesize{$r^{\sigma(e)}_{1}$}}; \node at (0.3,5.5) {\footnotesize{$r^{\sigma(e)}_{2}$}}; \node at (0.3,7.5) {\footnotesize{$r^{\sigma(e)}_{3}$}}; \node at (2,7.9) {\footnotesize{$a^{\sigma(e)}_{3,2}$}}; \node at (2,6.8) {\footnotesize{$b^{e}_{3,3}$}}; \node at (2,5.9) {\footnotesize{$a^{\sigma(e)}_{2,3}$}}; \node at (1.9,4.8) {\footnotesize{$b^{e}_{2,2}$}}; \node at (2,3.9) {\footnotesize{$a^{\sigma(e)}_{1,1}$}}; \node at (2,2.8) {\footnotesize{$b^{e}_{1,1}$}}; \node at (4,3.4) {\footnotesize{$c^{\sigma(e)}_{1}$}}; \node at (4,5.4) {\footnotesize{$c^{\sigma(e)}_{3}$}}; \node at (4,7.4) {\footnotesize{$c^{\sigma(e)}_{2}$}}; \node at (-2.5,5) {\footnotesize{$q^{\sigma(e)}$}}; \foreach \x in {3,5,7} { \vertex{2,\x+0.5}; \vertex{2,\x-0.5}; \vertex{4,\x}; \draw (-2,5) -- (0,\x); } \draw (0,7) -- (2, 7.5) -- (4,7) -- (2,4.5) -- (0,5); \draw (0,5) -- (2, 5.5) -- (4,5) -- (2,6.5) -- (0,7); \draw (0,3) -- (2, 3+0.5) -- (4,3) -- (2, 3-0.5) -- (0,3); \vertex{0,3}; \vertex{0,5}; \vertex{0,7}; \vertex{-2,5}; \vertex{-2,4}; \vertex{-2.4,4}; \draw (-2,5) -- (-2,4); \draw (-2,5) -- (-2.4,4); \node at (-2.5,3.5) {\scriptsize{$s$} pendent vertices}; \end{tikzpicture}} \caption{A connected component $Z$ of $F_{\{H\}} \setminus S_P$ that is not a copy of $K$, with $T_{e} = \{(1,1), (2,2), (3,3)\}$, $T_{\sigma(e)} = \{(1,1), (2,3), (3,2)\}$, and $s=2$.} \label{reallocatedbissstretchnewbis} \end{figure} \end{proof} We are now ready to prove Theorem~\ref{hardminor} and Theorem~\ref{hardtminor}. \begin{proof}[Proof of Theorem~\ref{hardminor} and Theorem~\ref{hardtminor}] Let $H$ be a graph in $\mathcal{Q}$. If $H$ is a star with at least four leaves, then by Lemma~\ref{twocut} \textsc{$\{H\}$-M-Deletion} cannot be solved in time $2^{o({\sf{tw}} \log {\sf{tw}})}\cdot n^{\mathcal{O}(1)}$ unless the {\sf ETH}\xspace fails. In the following we assume that $H$ is not a star. This permits us to proceed with the proofs of both theorems in a unified way. If $H$ contains at least one block with at least five vertices, then such a block would have at least five edges as well (by definition of a block), hence by Theorem~\ref{hardgene}, the theorems hold. We can now assume that $H$ does not contain any block with at least five vertices. Therefore, every block of $H$ is either an edge, a $C_{3}$, or a $C_{4}$. If $H$ contains at least three cut vertices that do not belong to the same block, then Lemma~\ref{threecut} can be applied. We can now assume that $H$ contains at most two cut vertices. Assume now that $H$ contains exactly two cut vertices and let $B$ the block that contains both of them. If $B$ is not an edge, then Lemma~\ref{cycletwocut} can be applied. Otherwise, we distinguish cases depending on the shape of the two connected components of $H$ after removing the only edge of $B$. If both connected components contain a cycle then Lemma~\ref{cyclestartwocut} can be applied, if only one of them contains a cycle then Lemma~\ref{commander} can be applied, and if none of them contains a cycle then, as $H$ is not a minor of the {\sf banner}\xspace, Lemma~\ref{twocut} can be applied. Assume now that $H$ contains exactly one cut vertex. As $H$ is not a star, then either $H$ contains at least two cycles, and so Lemma~\ref{butternutbis} can be applied, or $H$ contains exactly one cycle (and is not a minor of the {\sf banner}\xspace) and therefore Lemma~\ref{crickbisminor} or Lemma~\ref{crickbistm} can be applied. The theorems follow. \end{proof} \section{Conclusions and further research} \label{upheaval} We provided lower bounds for \textsc{$\mathcal{F}$-M-Deletion} and \textsc{$\mathcal{F}$-TM-Deletion} parameterized by the treewidth of the input graph, several of them being tight. In particular, the results of this article together with those of~\cite{monster1,monster2,BasteST20-SODA,SODA-arXiv} settle completely the complexity of \textsc{$\{H\}$-M-Deletion} when $H$ is connected. Concerning the topological minor version, in order to establish a dichotomy for \textsc{$\{H\}$-TM-Deletion} when $H$ is planar and connected, it remains to obtain algorithms in time $2^{\mathcal{O}({\sf{tw}} \cdot \log {\sf{tw}})}\cdot n^{\mathcal{O}(1)}$ for the graphs $H$ with maximum degree at least four, like the {\sf gem}\xspace or the {\sf dart}\xspace (see Figure~\ref{shifting}), as for those graphs the algorithm in time $2^{\mathcal{O}({\sf{tw}} \cdot \log {\sf{tw}})}\cdot n^{\mathcal{O}(1)}$ given in~\cite{monster1} cannot be applied. It is easy to check that the lower bounds presented in this article also hold for {\sl treedepth} (as it is the case in~\cite{Pili15}) which is a parameter more restrictive than treewidth~\cite{BougeretS16}. Also, it is worth mentioning that \textsc{$\mathcal{F}$-M-Deletion} and \textsc{$\mathcal{F}$-TM-Deletion} are unlikely to admit polynomial kernels parameterized by treewidth for essentially any collection $\mathcal{F}$, by using the framework introduced by Bodlaender et al.~\cite{BodlaenderDFH09} (see~\cite{BougeretS16} for an explicit proof for any problem satisfying a generic condition). Finally, let us mention that Bonnet et al.~\cite{BonnetBKM-IPEC17} recently studied generalized feedback vertex set problems parameterized by treewidth, and showed that excluding $C_4$ plays a fundamental role in the existence of single-exponential algorithms. This is related to our dichotomy for cycles illustrated in Figure~\ref{shifting} (which we proved independently in~\cite{BasteST17} building on the work of Pilipczuk~\cite{Pili15}), namely that \textsc{$\{C_i\}$-Deletion} can be solved in single-exponential time if and only if $i \leq 4$. \vspace{.3cm} \noindent \textbf{Acknowledgements}. We would like to thank the referees of the two conference versions containing some of the results of this article for helpful remarks that improved the presentation of the manuscript, and \href{http://www.lamsade.dauphine.fr/~bonnet/}{Édouard Bonnet}, \href{http://www.lamsade.dauphine.fr/~kim/}{Eun Jung Kim}, and \href{https://mat-web.upc.edu/people/juan.jose.rue/}{Juanjo Rué} for insightful discussions on the topic of this paper. \bibliographystyle{abbrv}
{'timestamp': '2021-03-12T02:20:23', 'yymm': '2103', 'arxiv_id': '2103.06614', 'language': 'en', 'url': 'https://arxiv.org/abs/2103.06614'}
arxiv
\section{Introduction} \label{sec:introduction} In recent years, the progress on various aspects of autonomous robots makes it possible to accomplish complex, systematic tasks. When executing tasks, robots usually equip sensors to obtain external environment information. However, the sensors usually have a limited field of view (FOV), especially for quadrotors under the size, weight, and power (SWaP) constraints. Therefore, the robot's position and orientation should be adjusted to obtain better visibility to the target. Visibility is of vital importance in a variety of applications. We take three scenarios as instances: \textbf{1)} For visual-inertial state estimation, enhancing the visibility of co-visible features can increase the state estimation accuracy significantly\cite{murali2019perception, zhang2018perception}. \textbf{2)} For exploration tasks, the target's visibility determines the quality and confidence of obtained information \cite{ly2019autonomous, freitag2018interactive}. \textbf{3)} For tracking, keeping high visibility of target is the key to avoid target loss which is the main reason for mission failure\cite{zhou2020raptor,bandyopadhyay2009motion}. In conclusion, different circumstances put forward the same requirement: visibility-aware trajectory planning. However, only a few works take visibility into account in trajectory planning. Most of them use probabilistic or deterministic searching methods with visibility cost to deal with the problem. Whereas these methods suffer from inherent inaccuracy caused by discretization. Besides, when the dimension of state increases, the computational complexity rises exponentially. These adverse properties lead to planning failures, especially with a limited time budget. Additionally, yaw planning approaches for visibility are usually absent. A group of works directly set facing-target yaw as expectation input in control level \cite{BJ2020ICRA, JC2016tracking}. However, in practice, the robot's yaw rate, named as yaw feasibility in this paper, can not be changed suddenly, same as the velocity and acceleration of position. (The feasibility mentioned in the following includes yaw feasibility by default) The above control-level strategy fails to reach the expected yaw sometimes due to physical limits. Some other works plan yaw after position, which omits the coupling relationship between them when considering visibility. To summarize, an efficient trajectory planning method that takes visibility into consideration comprehensively is rare. \begin{figure}[t] \vspace{0.2cm} \centering \includegraphics[width=1\linewidth]{pdf/figure_tou} \captionsetup{font={small}} \caption{ The real-world experiment of the aerial tracking application using our method. } \label{pic:tou2} \vspace{-0.6cm} \end{figure} \begin{figure}[t] \vspace{0.0cm} \centering \includegraphics[width=1\linewidth]{pdf/figure_1} \captionsetup{font={small}} \caption{ Illustration of the visibility-aware trajectory result in the application of aerial tracking. } \label{pic:tou} \vspace{-1.3cm} \end{figure} To bridge this gap, we propose a general optimization-based visibility-aware trajectory planning method. This method uses a continuous and differentiable polynomial that prevents dimension explosion when the planning problem scales up. Furthermore, our method optimizes yaw jointly with position considering visibility, safety, and feasibility. The visibility is defined for a specific target or an area of interest. According to practical experience, we summarize three parts of the visibility criteria: \begin{itemize} \item [a)] \textit{Distance of observation (DO)}: A moderate distance from target is expected. \item [b)] \textit{Angle of observation (AO)}: The axis of the sensor's FOV is expected to be straight towards the target. \item [c)] \textit{Occlusion effect against obstacles (OE)}: The trajectory prevents the line of sight towards the target from occlusion. Without considering \textit{OE}, occlusion is prone to happen, as in Fig.\ref{pic:visibility_com}, for instance. \end{itemize} \begin{figure}[t] \centering \includegraphics[width=1\linewidth]{pdf/figure_2} \captionsetup{font={small}} \caption{ Comparison of trajectories with and without visibility-awareness. The balls on the trajectory represent the position in time. Without considering visibility, the orange trajectory is easy to lose target because of occlusion, especially when the target makes movements that are hard to predict. (a): the trajectory without visibility-awareness. (b): the trajectory with visibility-awareness. } \label{pic:visibility_com} \vspace{-0.6cm} \end{figure} To provide a gradient of visibility in trajectory optimization, we design a differentiable visibility cost considering the above parts. To guarantee the joint optimality of position and observation angle, we design a joint optimizer that simultaneously optimizes position and yaw using the visibility cost, safety, and feasibility cost. The planned motions provide the robot with better visibility to a target, as Fig.\ref{pic:tou} is shown. Finally, to prove that our method is practical and generic, we integrate the proposed method into a customized quadrotor tracking system, with a kinodynamic occlusion-avoid searching front-end to generate an initial path. We compare the tracking system using our method with the cutting-edge tracking works. The experimental results show that our visibility-aware planner performs more robustly in tracking. The contributions of this paper are: \begin{itemize} \item [1)] A general differentiable visibility cost taking the aforementioned \textit{DO}, \textit{AO} and \textit{OE} into account. \item [2)] Considering visibility, safety and dynamic feasibility, a joint trajectory optimizer optimizes position and yaw of a robot simultaneously. \item [3)] Simulations and real-world tests in aerial tracking application validate that our method is practical and generic. Moreover, we make our method open source \footnote{https://github.com/ZJU-FAST-Lab/visPlanner}. \end{itemize} \section{Related Work} \label{sec:related_works} The related works of trajectory planning to maximize visibility can be divided into two groups: local control based methods and trajectory generation based methods. \subsection{Local Control Based Methods} Several previous works formulate the trajectory planning and control integrally as a local control problem. Penin et al. \cite{BP2018elli} replan the trajectory online considering the \textit{OE} constraint by solving an optimization problem in the image space. Merging re-active control and planning, this method directly obtains the optimal control command. Lacking the environmental perception, this approach requires complete knowledge of the environment, thus not applicable in real applications. Andersen et al. \cite{andersen2017trajectory} consider \textit{OE} in trajectory planning to get more information for vehicle overtaking. They generate motions by maximizing the visibility ahead of obstacles with an MPC receding horizon planner. However, this task-specific method is hard to extend to other scenarios. Nägeli et al. \cite{TN2017elli} also take \textit{OE} and collision simultaneously into account in an MPC planner. A modular cost function based on the re-projection error of targets is designed to account for visibility. While this method fails to maintain its safety against obstacles with arbitrary shape since it assumes that all the obstacles are shaped by ellipsoid. \subsection{Trajectory Generation Based Methods} Trajectory generation based methods take the visibility into account and guarantee the smoothness and feasibility simultaneously. Bonatti et al.\cite{Bonatti2018AutonomousDC} present a real-time covariant gradient descent method to trade-off smoothness, obstacle avoidance, and \textit{OE} in tracking trajectory planning. Their \textit{OE} cost requires the connection line between the target and the robot to be free of obstacles within a certain range. However, this \textit{OE} cost does not take the conical FOV shape of most sensors into account. Bandyopadhyay et al.\cite{bandyopadhyay2009motion} define the shortest distance that the target escapes from the chasing robot's visible region as a risk function for \textit{OE}. Nevertheless, the precise geometry of the robot's visible region is required. In contrast to\cite{bandyopadhyay2009motion}, several researches\cite{BJ2019IROS, BJ2020ICRA} design the minimum value of the Euclidean Signed Distance Field (ESDF) on the line between the target and the robot as visibility metric for \textit{OE}. However, because this metric is not differentiable, it is not capable of being used to optimize visibility directly. To deal with visibility, even if the metric is differentiable, Jeon et al. \cite{BJ2020ICRA} propose a bi-level tracking planner. They search a graph incorporating safety and \textit{OE} metric to obtain a chasing corridor used for trajectory generation. However, building and traversing a graph is time-consuming. Typically, even with a low speed (1.2m/s) and coarse grid map (0.5 m) resolution, this graph-search based method takes over 200 ms\cite{han2020fast}. With similar \textit{OE} metric, Zhou et al. \cite{zhou2020raptor} propose a risk-aware trajectory refining strategy. Instead of explicitly optimizing \textit{OE}, to achieve risk-awareness, they use a task-specific method that guarantees sufficient distance to stop if the trajectory passes over a previously unknown obstacle. However, we formulate our general visibility metric into a differentiable cost, enabling us to optimize visibility explicitly. Most works of trajectory optimization considering visibility only take \textit{OE} into account, while as mentioned in Sec.\ref{sec:introduction}, rare works plan a trajectory for \textit{AO} and \textit{DO}. Some works \cite{BJ2020ICRA, JC2016tracking} greedily choose the yaw angle facing the target all the time, omitting the yaw feasibility. Other methods such as Zhou et al. \cite{zhou2020raptor} optimize the yaw trajectory that passes through a yaw sequence searched by a graph while never joints with the position. There is a strong mutual influence between position and yaw when considering visibility. Our method considers \textit{AO}, with which we are capable of optimizing yaw with position jointly. \section{Preliminaries} \label{sec:Preliminaries} \subsection{Problem Statement} \label{sec:bezier_prediction} Given the sequence of a chosen target position in time, the joint optimizer's goal is to generate a trajectory that maximizes the target's visibility, guaranteeing safety and dynamic feasibility. Here the visibility is defined as the three parts above: \textit{DO}, \textit{AO} and \textit{OE}. We consider the problem based on the following assumptions: \begin{itemize} \item [1)] Only one target can be chosen at the same time. \item [2)] The target is static or has smooth and bounded velocity and acceleration. \item [3)] The sensor equipped directly in front of robot has conical limited field of view. \end{itemize} \subsection{Analytical Visibility Metric} Notating the position of the robot $\mathbf{p}=[x_p,y_p,z_p] \in \mathbb{R}^{3}$, Euler-yaw angle of the robot $\psi_p \in SO(2)$ and the position of the target $\mathbf{c}=[x_c,y_c,z_c] \in \mathbb{R}^{3}$, we formulate the details of the three parts of visiblity metric as follows. \subsubsection{DO} The target is expected to be observed in a proper distance range from the robot denoted by \begin{equation}\label{equ:do} od_{min} < ||{\mathbf{p}-\mathbf{c}}|| < od_{max}, \end{equation} where the $od_{min}$ and $od_{max}$ are the lower and upper bounds of the optimal distance of observation. \subsubsection{AO} In order to keep the axis of the sensor's FOV straight towards the target, the yaw angle is expected to be equal to $\psi_{best}$ defined as Eq.\ref{equ:ao}. \begin{equation}\label{equ:ao} \psi_{best} = {\rm atan2} \left(\boldsymbol e_y^T (\mathbf{p}-\mathbf{c}), \boldsymbol e_x^T (\mathbf{p}-\mathbf{c}) \right), \end{equation} where $\boldsymbol e_x = [1, 0, 0]^T$ and $\boldsymbol e_y = [0,1,0]^T$. \subsubsection{OE} \label{sec:OE} As the two-dimension profile illustrates in Fig.\ref{pic:visi_metric}, the blue range represents the FOV of the robot. The blue dashed enveloped area represents the \textbf{confident FOV} which we expect the target within and no obstacles included. However, this requirement cannot be represented analytically. Therefore, we approximate the confident FOV with a sequence of ball-shaped areas $\{ \mathcal{B}_1,\mathcal{B}_2,...,\mathcal{B}_M \}$. A ball $\mathcal{B}_i$ is shown as the red circle with its center $\mathbf c_i$ and radius $r_i$ calculated by \begin{align}\label{eq:pi} \mathbf c_i &= \mathbf{p} + \lambda_i(\mathbf{c}-\mathbf{p}), \\ r_i &= \rho \cdot \lambda_i \cdot ||{\mathbf{p}-\mathbf{c}}||, \label{eq:r_i} \end{align} where $\lambda_i = i/M \in [0, 1]$, and $\rho$ is a constant determined by the size of confident FOV. Then we can guarantee OE analytically for each ball by \begin{equation} \label{eq:oe} r_i < \Xi(\mathbf c_i), \end{equation} where $\Xi(\mathbf c_i): \mathbb R^3 \rightarrow \mathbb{R}$ is the distance to the closest obstacle. \begin{figure}[t] \centering \includegraphics[width=1\linewidth]{pdf/figure_3} \captionsetup{font={small}} \caption{ Illustration of the definition of \textit{OE} metric. A robot at position $\mathbf{p}$ observes the target $\mathbf{c}$. A sequence of ball-shaped areas in orange are used to approximate the confident FOV expected to be obstacle-free. } \label{pic:visi_metric} \vspace{-0.5cm} \end{figure} \section{Visibility-aware Trajectory Optimization} \subsection{Trajectory Representation} \label{sec:Trajectory Representation} We require a joint trajectory optimizer, which can generate a dynamic-feasible and collision-free trajectory considering smoothness and visibility simultaneously. The trajectory is parameterized by a four-dimensional unclamped uniform B-spline curve, which is a piecewise polynomial uniquely determined by its degree \emph{p}$_b$, a knot span $\Delta t$, and \emph{N}$_c$ control points $\{\mathbf Q_i, \Phi_i\} \in \mathbb{R}^3 \times SO(2)$. We follow the work of [15] to plan the control points of positions $\mathbf Q_i$ and yaw angles $\Phi_i$ in a reduced space of the four selected differentially flat outputs $\{x,y,z,\psi\}$. \subsection{Objective Functions} In practice, we choose $p_b = 3$, then the total duration of the trajectory is $(N_c-3)\cdot \Delta t$. Since some of the objective functions are represented by the expressions of each waypoint $\{\mathbf p_{k}, \psi_{p,k}\}$ and distance $d_k$ to the corresponding target $\mathbf c_k$, they should be calculated in advance: \begin{align}\label{eq:waypoint} \mathbf{p_{k}} &= \frac{1}{6} (\mathbf{Q}_{k} + 4\mathbf{Q}_{k+1} + \mathbf{Q}_{k+2}), \end{align} \begin{align} d_k &= ||\mathbf p_k-\mathbf c_k||, k \in \{1,2,...,N_c-2\}. \end{align} Besides, $\psi_{p,k}$ can be calculated by yaw control point $\Phi_k$ similarly as Eq.\ref{eq:waypoint}. Additionally, we use a $C^2$ penalty function $g(x)=\max\{0, x\}^3$ to convert all constraints to penalty terms, and the final unconstrained optimization problem is given by \begin{equation} \min _{\mathrm{Q, \psi}} J= [J_{DO}, J_{AO}, J_{OE}, J_f, J_{f_\Phi} J_s, J_{s_\Phi}, J_c] \cdot \boldsymbol{\omega}, \end{equation} where $\boldsymbol{\omega}$ is a weighing vector for trading off each cost: \subsubsection{DO Cost} To achieve proper observation distance, each waypoint $\mathbf{p_{k}}$ is required to satisfy \textit{DO} constraint defined by Eq.\ref{equ:do}. The \textit{DO} cost is written by: \begin{equation} J_{DO}=\sum_{k=1}^{N_c-2} g\left( od_{min}^2-d_k^2 \right) + g\left( d_k^2 - od_{max}^2 \right). \end{equation} \subsubsection{AO Cost} The yaw angle is expected to be close to the best yaw $\psi_{best}$ defined by Eq.\ref{equ:ao}. The \textit{AO} cost is written by: \begin{equation} J_{AO} = \sum_{k=1}^{N_c-2}(\psi_{p,k} - \psi_{best,k})^2. \end{equation} Different from other costs, this gradient affects both position $\mathbf {p_k}$ and yaw $\psi_{p,k}$: \begin{equation} \frac{\partial{J_{AO}}}{\partial{\psi_{p,k}}} = 2(\psi_{p,k} - \psi_{best,k}), \end{equation} \begin{equation} \frac{\partial{J_{AO}}}{\partial{\mathbf{p_k}}} = \left[\frac{\partial{J_{AO}}}{\partial{x_{p,k}}},\frac{\partial{J_{AO}}}{\partial{y_{p,k}}},0 \right]^T, \end{equation} where \begin{equation} \frac{\partial{J_{AO}}}{\partial{x_{p,k}}} = \frac{2(\psi_{p,k} - \psi_{best,k})}{(\boldsymbol e_x^T\mathbf{L})^2 + (\boldsymbol e_y^T\mathbf{L})^2} \cdot \boldsymbol e_y^T\mathbf{L}, \end{equation} $\partial{J_{AO}}/\partial{y_{p,k}}$ can be calculated similarly. With Eq.\ref{eq:waypoint}, we can propagate the gradient back to control points. \subsubsection{OE Cost} To satisfy the requirement defined by Eq.\ref{eq:oe}, the \textit{OE} cost is written by: \begin{equation} J_{OE} = \sum_{k=1}^{N_c-2}\sum_{i=1}^{M}g\left(F_{OE}(\mathbf{p_k})\right), \end{equation} \begin{equation} F_{OE}(\mathbf{p_k}) = (r^2_{k,i} - \Xi^2(\mathbf c_{k,i})), \end{equation} where $\Xi(\mathbf c_{k,i})$ is obtained from ESDF, and $M$ is the number of ball-shaped areas mentioned in Sec.\ref{sec:OE}. The gradient of $F_{OE}$ cost can be written as: \begin{equation} \begin{aligned} \frac{\partial{F_{OE}}}{\partial{\mathbf{p_k}}} = & 2 \left[\rho r_{k,i} \lambda_i \cdot \frac{\partial{d_k}}{\partial{\mathbf{p_{k}}}} -(1-\lambda_i)\Xi(\mathbf c_{k,i}) \frac{\partial{\Xi(\mathbf{c}_{k,i})}}{\partial{\mathbf{c}_{k,i}}} \right], \end{aligned} \end{equation} where $\partial\Xi(\mathbf c_{k,i})/\partial\mathbf{c}_{k,i}$ is easily obtained from ESDF. The term $\lambda_i$ acts as a lever for the gradient. Then we use Eq.\ref{eq:waypoint} to propagate the gradient back to control points. \subsubsection{Dynamic Feasibility Cost} The control points of velocity $\textbf V_i$, acceleration $\textbf A_i$ and jerk $\textbf J_i$ are calculated by \begin{align} \textbf{V}_i = \frac{\textbf{Q}_{i+1} - \textbf{Q}_i}{\Delta t}, \textbf{A}_i = \frac{\textbf{V}_{i+1} - \textbf{V}_i}{\Delta t}, \textbf{J}_i = \frac{\textbf{A}_{i+1} - \textbf{A}_i}{\Delta t}. \end{align} The control points of yaw velocity $V_{\Phi,i}$, yaw acceleration $A_{\Phi,i}$ and yaw jerk $J_{\Phi,i}$ can also be calculated by $\Phi$ similarly. Benefiting from the convex-hull property, dynamic feasibility of the whole trajectory can be guaranteed sufficiently by \begin{align} J_f = \sum_{i=1}^{N_c-1} g(||\textbf{V}_{i}||^2-v_{m}^2) + \sum_{i=1}^{N_c-2} g(||\textbf{A}_{i}||^2-a_{m}^2), \label{cost function} \end{align} where $v_{m}, a_{m}$ are the limits on velocity and acceleration. Similarly, the yaw feasibility cost can be written as: \begin{align} J_{f_\Phi} = \sum_{i=1}^{N_c-1} g(||V_{\Phi,i}||^2-v_{\Phi,m}^2) + \sum_{i=1}^{N_c-2} g(||A_{\Phi,i}||^2-a_{\Phi,m}^2), \end{align} where $v_{\Phi,m}, a_{\Phi,m}$ are the limits on velocity and acceleration of yaw. \subsubsection{Smoothness Cost} Benefiting from the convex hull property, we minimize the control points of high order derivatives of the B-spline trajectory to guarantee the smoothness: \begin{equation} J_{s}=\sum_{i=1}^{N_{c}-3}\left\|\mathbf{J}_{i}\right\|_{2}^{2}, \end{equation} Similarly, we define smoothness cost of yaw $J_{s_\Phi}$ using $J_{\Phi,i}$. \subsubsection{Collision Cost} To guarantee that the entire trajectory is collision-free, the collision penalty serves as the repulsive force that pushes the control points away from obstacles. \begin{equation} J_{c}=\sum_{i=1}^{N} g(d^2_{t h r} - \Xi^2(\mathbf{Q}_{i}))\left(\Xi\left(\mathbf{Q}_{i}\right)\right), \end{equation} where $d_{thr}$ is the safety threshold distance. \begin{figure*}[t] \centering \includegraphics[width=1\linewidth]{pdf/figure_5} \captionsetup{font={small}} \caption{ The real-world experiment. Four moments \ding{172}, \ding{173}, \ding{174}, \ding{175} are extracted from the entire experiment. \textbf{Top}: the snapshots of the tracking quadrotor and the target quadrotor. \textbf{Middle}: the visualization of the algorithm and the experiment. For the tracking quadrotor, the red curve denotes the executed trajectory, the orange curve denotes the planned trajectory, and the green arrows represent the yaw trajectory. Blue balls depict the predicted trajectory of the target. The red pyramid stands for FOV. \textbf{Bottom}: the first-person perspective of the tracking quadrotor. The target is boxed out by the red dotted box. } \label{pic:snapshot11} \vspace{-0.3cm} \end{figure*} \section{Application on Quadrotor Tracking} \subsection{Motivation and Methodology} For tracking, keeping high visibility of target is critical to preventing target loss which is the main reason for failures. Although with a requirement of visibility in the existing tracking systems, they rarely consider the complete metrics we summarize through practical experiments. To validate our method, we integrate the proposed optimizer into our previous work\cite{han2020fast}, a customized quadrotor tracking system. Its back-end is replaced by the proposed method to generate trajectory considering visibility and yaw feasibility. The predicted target position is generated by the same method based on Bézier regression in our previous work. \begin{figure}[t] \vspace{-0.0cm} \centering \includegraphics[width=1\linewidth]{pdf/figure_4} \captionsetup{font={small}} \caption{ Illustration of the kinodynamic occlusion-avoid searching method. The expanded node will be rejected if the connection line between the node and the target is occluded, such as the red cross. } \label{pic:front-end} \vspace{-0.6cm} \end{figure} \subsection{Implementation Details} For the front-end, we use the kinodynamic occlusion-avoid searching method based on hybrid-state A* algorithm \cite{dolgov2010path}. It uses motion primitives to expand nodes and evaluates them for a safe and dynamically feasible trajectory. To guarantee the topological equivalence between the planning path and the target's predicted path, we design a feasibility check function that prevents occlusion between the robot and the target, as Fig.\ref{pic:front-end} is shown. For the back-end, we apply our visibility-aware joint optimization method. Furthermore, a safe tracking cost $\omega_v \cdot J_v$ is added to keep the soon-to-arrive environment known. This cost tends to restrict the velocity direction into the quadrotor's FOV: \begin{equation} J_{v}=\sum_{k=1}^{N_c-2} g\left( (\psi_{v,k}-\psi_{p,k})^2-\psi_{thr}^2 \right), \end{equation} where $\psi_v$ is the velocity direction that equals to the tangent direction of the trajectory at the point $\mathbf{p}$, and $\psi_{thr}$ is the maximum allowable deviation angle from FOV axis. \section{Results} \label{sec:results} \begin{table}[b] \vspace{-0.5cm} \centering \caption{Parameters of Optimization.} \setlength{\tabcolsep}{5.0mm} \renewcommand\arraystretch{1.2} { \begin{tabular}{|c|c|c|c|} \hline $od_{min}$ & $od_{max}$ & $\rho$ & $M$ \\ \hline $2.5m $ & $3.5m$ & $0.8$ & $10$ \\ \hline \end{tabular}} \label{tab:planner_cmp} \vspace{-0.1cm} \end{table} \begin{table}[b] \centering \caption{Parameters for Experiments.} \setlength{\tabcolsep}{1.5mm} \renewcommand\arraystretch{1.2} { \begin{tabular}{|c|c|c|} \hline & \tabincell{c}{Target Quadrotor \\ Max Velocity} & \tabincell{c}{Tracking Quadrotor \\ Max Velocity}\\ \hline Real-world & $1.5 m/s$ & $2.5 m/s$ \\ \hline Simulation & $2.5 m/s$ & $5.0 m/s$ \\ \hline \end{tabular}} \label{tab:planner_cmp2} \vspace{-0.2cm} \end{table} We incorporate our method into a quadrotor tracking system for testing. We set another high-speed quadrotor as the target. Due to the unknown intent of the target, the future position is predicted by history. The quadrotor performs real-time mapping since the environment is unknown. The goal of the tracking system is to follow the target and keep it in FOV. The parameters of optimization are shown in Tab.\ref{tab:planner_cmp}. We conduct two cases and general tests in the simulation and deploy the system on a quadrotor for real-world experiments. For simulation, we benchmark Fast-Tracker\cite{han2020fast} for its cutting-edge performance in tracking. Two special cases are conducted to demonstrate the performance of the proposed method. Case.1 and Case.2 present the validity of our method under \textit{OE} and \textit{AO} metric, respectively. In the general tests, the tracking system runs for a long time in several randomly generated complex environments to comprehensively test our method's visibility effect and robustness. We further demonstrate the practical performance of the algorithm through real-world experiments. \begin{figure*}[t] \vspace{-0.0cm} \centering \includegraphics[width=1.0\linewidth]{pdf/figure_6} \captionsetup{font={small}} \caption{ The simulation results for Case 1. The trajectory of the tracking quadrotor and the target quadrotor are denoted as red and blue, respectively. The yellow lines connect their positions at the corresponding time. \textbf{We use the same color scheme in the following figures of simulation experiments.} The bottom snapshots show the situation at two corners where occlusion can easily occur. (a): the result of Fast-Tracker. (b): the result of our method. } \label{pic:EO} \vspace{-0.9cm} \end{figure*} \subsection{Real-World Experiments} \label{sec:experiment} Real-world experiments are presented on the same quadrotor platform of \cite{zhou2020ego}, which is localized by a robust visual-inertial state estimator \cite{qin2018vins}. The tracking quadrotor is equipped with an Intel Realsense D435 that has FOV (H × V) = 86° × 57° and an onboard computer DJI Manifold 2C. The target is an autonomous quadrotor as well broadcasting its location to avoid the impact of the identification, since our proposed method mainly focuses on visibility-aware trajectory generation. In this experiment, the max velocities of the target and the tracking quadrotor are set as Tab.\ref{tab:planner_cmp2}. In the experiment scene, the target swerves behind an obstacle, which easily causes target loss. As Fig.\ref{pic:snapshot11} shows, to avoid the line of sight toward the target being occluded, the tracking quadrotor adjusts its trajectory to keep the confident FOV obstacle-free. According to the tracking quadrotor camera data, the target is in the the FOV throughout the whole experiment. Furthermore, the tracking trajectory keeps smooth and dynamic feasible. Snapshots and visualization of the experiment can be found in Fig.\ref{pic:snapshot11}. We refer readers to the video for more information\footnote{https://www.youtube.com/watch?v=PhhrOBx54YY}. \subsection{Simulation and Benchmark Comparisons} \label{sec:benchmark} We benchmark our method with Fast-Tracker presented in the \cite{han2020fast} in simulation. In Fast-Tracker, they searches for a safe tracking trajectory heuristically by a target informed kinodynamic searching method as the front-end. The back-end optimizer then refines the trajectory into a local spatial-temporal optima trajectory\cite{wang2020generating}. To compare the tracking performance fairly, we set both of them the same target motion prediction and an appropriate FOV (H × V) = 80° × 65°. Furthermore, we define the target is lost when occlusion occurs or it is out of the FOV. \subsubsection{Case 1} \textit{OE} metric is validated. In this scene, the target makes sharp turns behind obstacles. Fast-Tracker never takes occlusion into account, which causes that the target is easily obstructed by obstacles as shown in Fig.\ref{pic:EO}(a). In contrast, considering \textit{OE}, the planner with our method generates a trajectory that prevents the line of sight towards the target from occlusion, as shown in Fig.\ref{pic:EO}(b). \begin{figure}[t] \vspace{0.3cm} \centering \includegraphics[width=1\linewidth]{pdf/figure_7} \captionsetup{font={small}} \caption{ The test environment of Case 2 for \textit{AO} and \textit{DO}. (a): the result of Fast-Tracker. (b): the result of our method. } \label{pic:AO_env} \vspace{-0.3cm} \end{figure} \begin{figure}[t] \vspace{0.4cm} \centering \includegraphics[width=1\linewidth]{pdf/figure_8} \captionsetup{font={small}} \caption{ Comparison of the tracking angle error . The tracking angle error of our method is remarkably less than Fast-Tracker. For our method, $\psi_{err}$ is below FOV boundary for the whole time. In contrast, in Fast-Tracker, the target is always out of FOV bounds, which leads to target loss. } \label{pic:ao} \vspace{-0.2cm} \end{figure} \subsubsection{Case 2} \textit{AO, DO} metric are validated. In this scene, the target makes large turns that are always more than $90 ^{\circ}$. Omitting a moderate distance and yaw angle to observe the target, Fast-Tracker loses it easily when turning, as shown in Fig.\ref{pic:AO_env}. In contrast, taking AO and DO into account, our method jointly optimizes position and yaw, which makes the quadrotor quickly turn toward the target even if there are many big turns. For comparision, we define tracking angle error $\psi_{err} = | \psi_p - \psi_{best} |$. Fig.\ref{pic:ao} shows the comparison of $\psi_{err}$ in the whole time. The FOV boundary equals half of the FOV angle. Consequently, our method ensures the target in FOV. However, Fast-Tracker almost has the target out of FOV at every turn. Furthermore, as is shown in Fig.\ref{pic:allheat}, we count the target positions projected to x-y plane in the tracking quadrotor's FOV. The heat map shows the distribution of the target positions, relative to the tracking quadrotor. For better visualization, we replace the count number $N$ in each heat map grid by $log(N+1)$. Consequently, our method keeps the target in a moderate area of FOV, which is conducive for observation, while Fast-Tracker always loses the target. \subsubsection{General Test} To prove that our method is generic, we compare both methods in an environment generated with randomly deployed obstacles as shown in Fig.\ref{pic:test_env}. In a variety of applications, we may be incapable to obtain the target location directly, which requires the quadrotor to identify the target’s location. As a result, we define the tracking mission as a failure when the tracking quadrotor loses the target. In tests, the tracking quadrotor follows the target moving along a random trajectory that lasts for 100s. For comparison, we further define failure time $T_{fast}$ and $T_{our}$ are the time when the mission fails. The result is shown in Tab.\ref{tab:fail_time}. $V_{max}$ is the max velocity set to the target, and we set double $V_{max}$ to the tracking quadrotor. The failure time are compared in 10 tracking missions for each scenario. Consequently, in general environment, our method maintains a higher success rate, while Fast-Tracker fails easily. \begin{figure}[t] \vspace{0.3cm} \centering \includegraphics[width=1\linewidth]{pdf/figure_10} \captionsetup{font={small}} \caption{ Heat map comparison. The heat map shows the distribution of the target positions relative to the tracking quadrotor on x-y plane. The red sector represents the FOV of the tracking quadrotor. The closer it is to yellow, the more frequently the target appears. Our approach always restricts the target to the central area. (a): heat map of Fast-Tracker. (b): heat map of our method. } \label{pic:allheat} \vspace{0.4cm} \end{figure} \begin{figure}[t] \vspace{-0.2cm} \centering \includegraphics[width=1\linewidth]{pdf/figure_9} \captionsetup{font={small}} \caption{ The random environment in general test. } \label{pic:test_env} \vspace{-1.6cm} \end{figure} \begin{table}[h] \vspace{-0.2cm} \centering \caption{Comparision of Failure Time in General Tests.} \setlength{\tabcolsep}{5.0mm} \renewcommand\arraystretch{1.2} { \begin{tabular}{|c|c|c|c|} \hline $V_{max}$ $(m/s)$ & 0.5 & 1.5 & 2.5 \\ \hline $T_{fast}$ $(s)$ & 39.1 & 66.25 & 11.0 \\ \hline $T_{our}$ $(s)$ & 100 & 100 & 85.7 \\ \hline \end{tabular}} \label{tab:fail_time} \vspace{-0.1cm} \end{table} \section{Conclusion} \label{sec:conclusion} \vspace{-0.14cm} In this paper, we summarize three metrics \textit{DO, AO, OE} to evaluate the visibility according to practical experience. Under these metrics, we design differentiable visibility costs and propose a general visibility-aware trajectory optimization method. An joint optimizer is proposed to adjust the position and yaw simultaneously. To validate the visibility effect of our method, we integrate the optimizer into the back-end of a quadrotor tracking system and benchmark it against a state-of-the-art tracking planner. Simulation comparisons and real-world experiments validate that it is robust and efficient. In the future, our visibility-aware trajectory optimization method will be extended to active slam and exploration areas. As for aerial tracking, we will continue to improve the prediction method to make it a more robust system. \begin{figure*} \centering \includegraphics[width=0.95\linewidth]{pdf/figure11.png} \captionsetup{font={small}} \caption{ Comparision of the trajectories in one of the general tests. (a): the result of our method. (b): the result of Fast-Tracker. } \label{pic:complex} \vspace{0.0cm} \end{figure*} \newlength{\bibitemsep}\setlength{\bibitemsep}{0.0\baselineskip} \newlength{\bibparskip}\setlength{\bibparskip}{0pt} \let\oldthebibliography\thebibliography \renewcommand\thebibliography[1]{% \oldthebibliography{#1}% \setlength{\parskip}{\bibitemsep}% \setlength{\itemsep}{\bibparskip}% }
{'timestamp': '2021-03-12T02:27:01', 'yymm': '2103', 'arxiv_id': '2103.06742', 'language': 'en', 'url': 'https://arxiv.org/abs/2103.06742'}
arxiv
\section{INTRODUCTION} Models for multi-step prediction yield a sequence of future system states given the initial system state and a sequence of control inputs. Control methods, such as model predictive control \cite{Li2020,Wu2020}, rely on the predictions of future states for computing optimal control inputs given a set of objectives like heading, speed or minimal fuel consumption. Multi-step prediction models should be accurate and, in addition, they should be interpretable such that a domain expert can understand their predictions and identify their limitations, e.g. their failure states. Interpretability is considered a crucial safety concern for ML systems by governmental entities, e.g. the European Commission \cite{EU2020}, or technical inspection and product certification services, e.g. the Technical Inspection Association (TÜV) \cite{Tuv2018}. This paper develops a model for multi-step prediction, which is accurate and interpretable, to allow for future certification and usage in vehicle control. Traditional multi-step prediction models use physical (motion) models \cite{Fossen2011,Schoukens2019}, which are commonly based on first-principles or linear regression. The parameters of these models correspond to physical parameters of the system, which makes these approaches interpretable. However, physical models suffer from the high cost and difficulty of measuring parameters concerning, e.g., aero- or hydrodynamics. Although these costs can be reduced by applying simplifications, such as linearization of the model around a task-dependent operating point (e.g. a constant speed for manoeuvring \cite{Fossen2011}), these simplifications introduce prediction errors, which aggregate over multiple prediction steps causing the predicted states to diverge from the actual states \cite{Mohajerin2019}. The lack of accuracy can be reduced by deep neural networks (DNN), which have shown to be capable at simulating dynamical systems over large time spans for various domains, such as unmanned aerial vehicles \cite{Chen2017,Mohajerin2019,Punjani2015}, ships \cite{Li2017b,Woo2018}, engines \cite{Schuerholz2019}, aerodynamics \cite{Li2019}, and lake temperatures \cite{Jia2019}. DNN-based models require little domain knowledge in comparison to physical models. In addition, they are less expensive to build, as the parameters are automatically learned from the data. However, DNNs suffer from low interpretability, as their parameters do not directly correspond to the parameters of the system and are therefore not physically meaningful (\textbf{Challenge C1: Interpretability}). As a consequence, they may not be used without further developments in practice, as certification bodies will not licence such technologies for use in autonomous vehicles \cite{Tuv2018}, at least in the current state. In order to benefit from both approaches, hybrid models combine physical models and DNN, while minimizing the respective disadvantages. Improved interpretability compared to deep learning is achieved by partially retaining the interpretability of the physical model via certain structures in the model architecture or by constraining the dynamics of the DNN. Recent approaches have employed a residual hybrid architecture, in which the DNN is trained to compensate for the error residual of the physical model \cite{Chattha2019,Mohajerin2019,Woo2018}. \cite{Chattha2019} and \cite{Woo2018} achieve a higher interpretability compared to DNN due to the combination of physical model and DNN output for the overall prediction. \cite{Mohajerin2019} feeds the output of an additional DNN as input to the physical model. This has a negative impact on the interpretability compared to \cite{Chattha2019} and \cite{Woo2018}, since the input-output relation of the physical model is obscured by the DNN. However, the approach allows the inclusion of unknown parameters, which are identified during training of the DNN, which makes it more flexible than \cite{Chattha2019} and \cite{Woo2018}. However, all these three approaches only consider purely linear models as physical models, which is a considerable limitation, since most vehicle dynamics are non-linear (\textbf{Challenge C2: Non-linear physical models}). The training of hybrid models that use non-linear or inaccurate physical models for multi-step prediction is difficult (\textbf{Challenge C3: Trainability of hybrid models}). Due to feedback of the predicted state as input to the physical model, errors in the prediction aggregate over time, which causes divergence in the weights of the DNN. Another limitation of the existing work is its evaluation in use cases with low environmental disturbances, such as quadcopters operated indoors or unmanned surface vehicles operated on lakes \cite{Mohajerin2019,Woo2018}. Environmental disturbances have a large effect on vehicle dynamics due to strong coupling between states (\textbf{Challenge C4: Environmental disturbances}). To address these challenges, we propose a novel hybrid method for multi-step prediction of vehicle states consisting of a residual hybrid architecture with a respective training procedure. Our proposed hybrid architecture combines long short-term memory networks (LSTM) and physical models similar to \cite{Chattha2019}, but with the capacity to model a large variety of physical models composed of first-principles and regression models (\textbf{C2}). Using our two-phase training procedure, we address the existing problem of divergence during training of hybrid models in multi-step prediction, thus allowing for inaccurate and non-linear physical models as part of the hybrid model (\textbf{C3}). Our procedure ensures convergence of the DNN by training it to correct the single-step error of the physical model and the aggregated error over multiple prediction steps. In addition, we guarantee interpretability of our approach by applying a constraint on the output range of the LSTM (\textbf{C1}). This enables a trade-off between interpretability of the hybrid model and accuracy by varying the strictness of the constraint. Finally, we evaluate our approach on the use-case of ship motion under environmental disturbances (\textbf{C4}) and on the use-case of quadcopter motion without disturbances. \section{RELATED WORK}\label{section:related_work} We have identified three families of related approaches that merge knowledge of a physical system with deep learning. \parabold{Network architectures.} Deep feedforward neural networks (FNN) are frequently used to approximate complex non-linear dynamics \cite{Nichiforov2017,Punjani2015}. These FNN are known as non-linear auto-regressive exogenous (NARX) networks. They are given a fixed window of prior states and control inputs and predict subsequent states. Because the size of their input window is fixed, NARX networks do not cope well with long-term dynamics. Recurrent neural networks (RNN) are a superior alternative to FNNs for simulating dynamical systems, as their recurrent structure permits them to model complex non-linear dynamics over large time spans \cite{Feng2019,Li2019,Mohajerin2018a,Woo2018}. The hidden state of RNN can learn latent temporal dependencies, e.g. environmental effects such as waves, which are not directly measurable with sensors. Thus, RNNs may provide more accurate state predictions than FNNs. A network architecture that models the physical processes of the system can also improve prediction accuracy. Sch\"urholz et al. \cite{Schuerholz2019} employs a recurrent architecture with additional forward connections between recurrent units, which correspond to the physical information flow between components further improving the prediction accuracy. \parabold{Physics-based loss functions.} Loss functions can encode known dynamics and physical parameters as regularization terms. In \cite{Jia2019} and \cite{Muralidhar2018} physics-based restrictions motivated by the law of energy conservation are used on the loss function to simulate lake temperatures with FNNs and RNNs. Their evaluations show that this method allows the network to converge faster than a network with unmodified loss. Approaches dealing with object tracking \cite{Ren2018,Stewart2017} employ loss functions for semi-supervised learning by encoding dynamics in the loss function and punishing trivial solutions. Including knowledge about the physical system in loss functions reduces the amount of data and time required for training the DNN and results in physically plausible predictions. However, physics-based loss functions do not improve interpretability, as they only affect the training of the neural network. \parabold{Hybrid models.} Hybrid models combine different types of models, such as physical models and DNN. In a serial architecture, approaches like \cite{Cranmer2012} and \cite{Mohajerin2018a} either give the output of a DNN as input to a physical model or vice versa. In either variant, the output of the second model is returned as overall prediction. The rationale underlying these architectures is that certain inputs to a physical model, such as hydrodynamic forces, are difficult to model with first-principles, but can be predicted by a DNN from control inputs and the system state. The serial connection limits the interpretability of the hybrid model, as the input-output relation is obscured by the neural network. On the other hand, a parallel architecture adds the output of a physical model and the output layer of a DNN into an overall prediction \cite{Cranmer2012,Woo2018}. This approach retains the interpretability of the physical model, if the DNN contribution is sufficiently small in comparison. Recent work uses residual architectures, which employ serial and parallel connections in joint \cite{Chattha2019,Mohajerin2018a}. The serial connection, which gives the output of the physical model as input to the DNN, allows the network to rectify errors of the physical model and improve accuracy over multiple prediction steps. The parallel connection sums the error residual predicted by the DNN and the physical model output for the overall prediction thereby ensuring the interpretability of the prediction. Lastly, current approaches utilize physical models, which are either relatively accurate but expensive \cite{Chattha2019} or use simplifications such as linear models \cite{Mohajerin2018a,Woo2018}. The former type of model is expensive to develop, while the latter limits the possible parameters present in the physical model. \section{HYBRID MODEL AND TRAINING FOR MULTISTEP PREDICTION}\label{section:model} Our proposed approach consists of a hybrid architecture and a two-phase training procedure. We combine a physical model with an LSTM, which predicts the error residual of the physical model. The physical model and LSTM are described in Sections~\ref{section:whitebox} and~\ref{section:blackbox}, respectively. The goal of the two-phase training process is to achieve convergence. In the first phase, we reduce the one-step prediction error by teacher-forcing \cite{Lamb2016}, i.e. at each time step, the hybrid model receives the true prior state as input. In the second phase, we train with multistep prediction feeding back each predicted state as input for the next prediction. The variables used for the model definition are summarized in Table~\ref{table:notation}. \begin{table}[t] \input{table-variables} \end{table} \subsection{Overall Architecture}\label{section:overall_arch} As shown in Figure~\ref{fig:hybrid_model}, the hybrid model consists of an LSTM and a physical model. The physical model can be a regression or first-principles component, as well as a combination of both. A first-principles component is a set of differential equations derived directly from Newton's second law of motion. A regression component allows learning of an interpretable model from data, which is useful estimating hydrodynamical coefficients \cite{Fossen2011}. It is common practice to combine both approaches to yield more accurate physical models. The physical model $\vect{z}_{t+1}^{\;\text{phy}}$ computes its prediction from the control input $\vect{c}_t$ and the previous state $\vect{z}_{t}$. The LSTM $\vect{z}^{\;\text{lstm}}_{t+1}$ predicts the error residual of the physical model given the previous hidden state $\vect{h}_{t}$, the control input $\vect{c}_t$, and the current state prediction of the physical model $\vect{z}_{t+1}^{\;\text{phy}}$. The previous state $\vect{z}_{t}$ is not needed as input, since it is composed of the prior physical model output $\vect{z}_{t}^{\;\text{phy}}$, which was provided as input, and its own output $\vect{z}^{\;\text{lstm}}_{t}$. Accordingly, this information is already encoded in the hidden state and its inclusion yielded no performance improvements in our initial experiments. The state prediction of the hybrid model $\hat{\vect{z}}_{t+1}$ is the sum of $\vect{z}_{t+1}^{\;\text{phy}}$ and $\vect{z}^{\;\text{lstm}}_{t+1}$. During multi-step prediction, the auto-regressive loop, represented by the dashed arrow, feeds back this state prediction $\hat{\vect{z}}_{t+1}$ as input to the physical model. Because of the feedback loop, the multi-step prediction error may aggregate over time. The forward computation for our hybrid model for the time step $t+1$ is defined as follows: \begin{align} \begin{split} \vect{z}^{\;\text{phy}}_{t+1} &= \text{Regression}(\vect{c}_{t}, \vect{z}_{t}) + \text{1st-Principles}(\vect{c}_{t}, \vect{z}_{t}) \end{split} \label{eq:physical_true}\\ \vect{h}_{t+1} &= \text{LSTM}(\vect{c}_t, \vect{z}^{\;\text{phy}}_{t+1}, \vect{h}_{t}) \\ \vect{z}^{\;\text{lstm}}_{t+1} &= \matr{W}^{\text{hx}} \, \vect{h}_{t+1} \\ \begin{split} \hat{\vect{z}}_{t+1} &= \vect{z}^{\;\text{phy}}_{t+1} + \vect{z}^{\;\text{lstm}}_{t+1} \\ \end{split} \end{align} \begin{figure}[t] \input{fig-hybrid_model} \label{fig:hybrid_model} \end{figure} \parabold{Training.} The training of the hybrid approach is divided into training of the physical model and training of the LSTM. The regression component is fit on the residual of the first-principles model for the single-step objective: \begin{align} \begin{split} \mathcal{L}^{\text{reg}}(\vect{\theta}) =& \text{MSE}(\vect{z}_{t+1} - \text{1st-Principles}(\vect{c}_{t}, \vect{z}_{t}),\\ &\phantom{\text{MSE}(}\text{Regression}(\vect{c}_t, \vect{z}_{t}; \vect{\theta}) ) \end{split} \end{align} If no first-principles component is used, the regression fits on the task of predicting the system state instead of the first-principles residual. The training of the LSTM on the multi-step prediction objective, i.e. predicting the state over multiple time steps given a sequence of control inputs, is difficult, because each next-step prediction of the physical model depends on the inaccurate previous prediction. Thus, the error aggregates over several time steps causing divergence between predicted state and true state. LSTMs are trained with backpropagation-through-time (BPTT), which is sensitive to large errors. A combination of increasingly large errors and BPTT causes exploding gradients and prevents successful training of the network. We solve this problem with our two-phase training procedure, which enables training hybrid models with divergent and inaccurate physical models. \parabold{First phase.} In the first phase, we employ teacher forcing, where the physical model receives the true state $\vect{z}_{t}$ as input at each time step $t+1$. This mechanism enables the LSTM to learn the one-step error of the physical model, which occurs due to missing parameters or simplifications. The loss function for the first phase is defined as: \begin{align} \hspace*{-0.8em}\mathcal{L}^\text{lstm}(\vect{\theta}) = \sum_{t=1}^{T} \text{MSE}(\vect{z}_{t+1} - \vect{z}^{\;\text{phy}}_{t+1}, \text{LSTM}(\vect{c}_t, \vect{z}^{\;\text{phy}}_{t+1}, \vect{h}_{t}; \vect{\theta})) \end{align} where $T$ is the number of time steps and MSE is the mean squared error. The first training phase is only performed to reduce the estimation error until feedback of the state prediction does not cause divergence during multi-step prediction. Therefore the first-phase loss function is only employed for a limited number of epochs. \parabold{Second phase.} In this phase, the model learns to predict states over multiple time steps without receiving true states as input. This is achieved by using the state prediction from the previous time step as input in the current prediction step. The training remains effective, because the first-phase ensured that the hybrid model achieves sufficiently accurate predictions to prevent the strong divergence of DNN gradients. The loss function for the second phase only differs from the first-phase in the physical model prediction $\vect{z}^{\;\text{phy}}_{t+1}$, as the prediction now depends on the predicted prior state $\hat{\vect{z}}_t$ and not on the true prior state: \begin{align} \vect{z}^{\;\text{phy}}_{t+1} &= \text{1st-Principles}(\vect{c}_t, \hat{\vect{z}}_{t}) + \text{Regression}(\vect{c}_t, \hat{\vect{z}}_{t}) \end{align} \subsection{Physical Models}\label{section:whitebox} We define (cf. \cite{Fossen2011,Schoukens2019}) physical models for ships combining a first-principles model with a regression model. The simple dynamics are modelled precisely using the corresponding physical equations. The complex system dynamics are approximated using least squares regression. \parabold{First-principles.} The models of motion are represented by differential equations, which define the equilibrium of forces resulting in the acceleration of a vehicle. We use the motion model for surface vessels developed by Fossen~\cite{Fossen2011}: \begin{align} \deriv{\eta} &= \matr{J}(\vect{\eta}) \vect{v} \label{eq:kinematics} \\ \deriv{v} &= \matr{M}^{{-1}} (\force{control} + \force{env} - \matr{D}(\vect{v})\vect{v} - \matr{C}_\rb(\vect{v})\vect{v} - \vect{g}(\vect{\eta})) \label{eq:kinetics} \end{align} Equation~\ref{eq:kinematics} defines the kinematics of the vessel, as it describes the mapping of velocities in the ship's body frame to a motion in the inertial reference frame, i.e. earth. The ship's kinetics represented by Equation~\ref{eq:kinetics} define the relation of forces affecting the vessel and the resulting acceleration. Developing first-principles models is challenging due to the high cost and difficulty associated with measuring their physical parameters. Additionally, environmental variables, such as the sea state, cannot be measured during the operation of a vehicle, which makes their prediction with first-principles models infeasible. Due to these limitations, we consider two examples of incomplete first-principles models, which entirely omit immeasurable parameters. First, the \textbf{minimal model} (\texttt{Min}) uses only parameters that are easy to measure or approximate, such as those related to the vessel's mass, inertia and geometry. The restoring forces are linearized as $\matr{G}\vect{\eta}$ around a roll angle of $0$ yielding a good approximation with fewer parameters \cite{Fossen2011}: \begin{align} \deriv{v} &= \matr{M}^{{-1}} (-\matr{C}_\rb(\vect{v})\vect{v} - \matr{G} \vect{\eta})) \end{align} All the other parameters that are expensive to measure are set to $0$, e.g. ones concerning hydrodynamic forces. Second, a \textbf{propulsion-based model} (\texttt{Pro}), which extends the minimal model by parameters for propulsion and steering forces. This model includes $\force{control}$, which represents the control forces generated by propellers and rudders: \begin{align} \deriv{v} &= \matr{M}^{{-1}} (\force{control}(\vect{c}, \vect{v})-\matr{C}_\rb(\vect{v})\vect{v} - \matr{G} \vect{\eta})) \end{align} The model for control forces $\force{control}$ is highly dependent on the propulsion system of the modeled vessel, as it depends on the thruster configuration and the type of steering mechanism. The implementation details of a standard propeller and rudder may be found in the MSS toolbox \cite{Fossen2004}. \parabold{Linear regression.} We employ linear regression in two models components as a coarsely approximating physical model \cite{Ljung2019}. The \textbf{linear regression model} (\texttt{Lin}) receives prior system state $\vect{z}_{t}$ and control input $\vect{c}_{t}$: \begin{align} \hat{\vect{z}}_{t+1} &= \matr{Q} \vect{c}_{t} + \matr{P} \vect{z}_{t} + \vect{b}\label{eq:linear} \end{align} with input matrix $\matr{Q}$, system matrix $\matr{P}$, and bias vector $\vect{b}$. Second, we extend the linear model with a non-linear input mapping $f$ to better approximate hydrodynamic forces: \begin{align} \hat{\vect{z}}_{t+1} &= \matr{Q} \vect{c}_{t} +\matr{P} f(\vect{z}_{t}) + \vect{b} \end{align} We use the set of non-linear features developed by \cite{Blanke1993} consisting of polynomial and absolute terms, which are well-suited for modeling the damping and drag effects of a ship hull with the surrounding fluid. \begin{comment} We adapt their features for our \textbf{hydrodynamic regression model} (\texttt{Hyd}) as follows: \begin{align} u_{t+1} &= \vect{a}_{u}^\intercal \, [ u_{t} \hspace{0.4em} \abs{u_{t}}u_{t} \hspace{0.4em} w_{t}r_{t}]^\intercal \\ v_{t+1} &= \vect{a}_{w}^\intercal \, [ w_{t} \hspace{0.4em} \abs{u_{t}}w_{t} \hspace{0.4em} u_{t}r_{t} \hspace{0.4em} \abs{w_{t}}w_{t} \hspace{0.4em} \abs{r_{t}}w_{t} \hspace{0.4em} \abs{w_{t}}r_{t} \hspace{0.4em} \abs{u_{t}w_{t}}\phi \hspace{0.4em} u_{t}^2\phi ]^\intercal\\ p_{t+1} &= 0\\ r_{t+1} &= \vect{a}_{r}^\intercal \, [ r_{t} \ \abs{u_{t}}w_{t} \hspace{0.4em} \abs{w_{t}}r_{t} \hspace{0.4em} \abs{u_{t}}r_{t} \hspace{0.4em} \abs{r_{t}}r_{t}\hspace{0.4em} \abs{u_{t}\phi_{t}}\phi_{t} \hspace{0.4em} \abs{r_{t}}u_{t}\phi_{t} \hspace{0.4em} \abs{u_{t}}u_{t-1}\phi_{t} ]^\intercal\\ \phi_{t+1} &= \vect{a}_{\phi}^\intercal \, [ p_{t} \hspace{0.4em} \phi_{t} ]^\intercal \end{align} where weights for each state are encoded by the vectors $\vect{a}_u$, $\vect{a}_w$, $\vect{a}_p$, $\vect{a}_r$, and $\vect{a}_\phi$. The vertical bars, e.g. $\abs{u_t}$, denote the absolute value of a scalar. \end{comment} \subsection{Recurrent Neural Network}\label{section:blackbox} We employ a stacked LSTM including an initialization mechanism as DNN component in our hybrid model, as it is capable of memorizing long-term dynamics and of modeling dynamics at different time scales \cite{Graves2013}. The latter capability is important for modeling ships, since waves and control inputs introduce dynamics with different frequencies. The models for multi-step prediction, such as a LSTMs, rely on an initial state to yield accurate predictions. Thus, the initial state should encode all available information about the system and the surrounding environment, e.g. the velocity and position of a ship but also the sea state. The state of an LSTM is its cell and hidden state. An LSTM can be initialized at $t=0$ by providing a cell and hidden state. Mohajerin et al. \cite{Mohajerin2019} propose the initialization with an additional LSTM acting as initializer. The initializer receives as input a window of system states and control inputs, which precede the predicted time frame. The recurrence of the initializer enables it to extract latent dynamics from the data, which cannot be directly measured such as the sea state. The prediction model is then initialized with the final hidden state of the initializer. \section{EVALUATION}\label{section:evaluation} The proposed method is evaluated extensively for modeling dynamics of a patrol ship under environmental disturbances (Section~\ref{section:expsetup} and~\ref{section:results}). To prove generalizability Section~\ref{section:quadcopter} summarizes results for quadcopter motion. \subsection{Experiment Setup}\label{section:expsetup} \parabold{Dataset.} The dataset is generated with a 4 degrees-of-freedom (DOF) maneuvering model of a patrol ship, which simulates the horizontal plane motion and rolling due to waves. The original model and physical parameters are provided by Perez et al. \cite{Perez2006} and can be found in the MSS toolbox \cite{Fossen2004}. The model is extended to include wind forces according to Isherwood \cite{Isherwood1972}, ocean waves generated with the JONSWAP spectrum \cite{Hasselmann1973}, and corresponding wave forces computed with force response amplitude operators. Two symmetrically-placed fixed-pitch rudder propellers are implemented for control of heading and speed of the vessel. Control inputs to the simulation model are generated via an open-control loop, which mimic a human operator. The measurements of the vessel are sampled with a rate of \SI{1}{\hertz}. The dataset consists of $96$ hours separated into $\SI{1}{\hour}$ simulations, where each simulation is initialized with a random sea state and control inputs. The dataset is split into training, validation, and test set with a 60-10-30 split. \parabold{Metrics.} The prediction performance is measured with regards to state and trajectory prediction over a time span of $\SI{15}{\minute}$ or $900$ time steps. A window containing $\SI{1}{\minute}$ of prior control inputs and state variables is provided as initial state. The five predicted states are the velocities for surge $u$, sway $w$, roll $p$, and yaw $r$, as well as the roll angle $\phi$. The root mean squared error (RMSE) is averaged over all time steps for each state to measure the state prediction performance. The trajectory RMSE measures the average distance between the predicted and true trajectory for each time step. The trajectory error emphasizes surge, sway, and yaw, as they have the largest impact on the trajectory. Interpretability is measured using an output range constraint enforced on the LSTM. An unconstrained LSTM results in no interpretability, while an increasingly smaller output range increases interpretability. We employ the relative threshold applied to the LSTM as measure of interpretability. The relative threshold is the ratio between the sizes of the LSTM output range and the expected output range of the physical model. The expected output range of the physical model is the $95\%$ range of its outputs computed on the training and validation set. For example, a physical model has an expected range of $[-5, 5]$ and the LSTM is constrained to a range of $[-1, 1]$, then the relative threshold is $20\%$. A lower relative threshold implies a higher degree of interpretability. \parabold{Model selection.} Hyperparameter search is performed via grid search on the validation set. The best model per class is chosen based on the RMSE summed over each state. Quadratic control lag (\texttt{QLag}) is a regression model developed by \cite{Punjani2015} as best-performing physical baseline in their work. It uses a window of prior control inputs and states, and includes control inputs as quadratic terms to model the relation between propulsion and velocity. Stacked LSTM with an LSTM initializer (\texttt{LSTM}, \cite{Mohajerin2019}) is used as DNN baseline. Hybrid models are trained with each potential physical model configuration using the default one-phase training and the proposed two-phase training (\{\texttt{Min}, \texttt{Pro}\}+\{\texttt{Lin}, \texttt{Pro}\}-\{\texttt{1P}, \texttt{2P}\}). This allows us to evaluate whether our two-phase training can successfully train hybrid models with incomplete and non-linear physical models. The models are denoted by abbreviations as defined in the previous text. \texttt{Lin-1P} is similar to the hybrid model by \cite{Woo2018}. \subsection{Results}\label{section:results} \begin{table}[htbp] \input{table-scores_ship.tex} \end{table} \begin{figure*}[htbp] \input{fig-states_time.tex} \end{figure*} \parabold{State prediction.} Table~\ref{table:rmse} shows the state prediction performance of the baselines \texttt{QLag} and \texttt{LSTM}, as well as each variation of the hybrid model. Error values across different state variables are not directly comparable, as they are not normalized and each variable has a different magnitude. \texttt{Min-1P} is the only hybrid model without two-phase training that outperforms its counterpart with two-phase training. However, \texttt{Min-1P} performs worse overall compared to all other two-phase hybrid models. For all other configurations, the hybrid model with one-phase training performs worse by a large factor. For \texttt{Hyd-1P}, no model was identified to be capable of simulating the vessel without diverging completely. These results indicate that the proposed two-step training procedure allows integration of a large range of physical models with DNN compared to the default training procedure. \texttt{Lin-2P} achieves the lowest error for three state variables. Additionally, it achieves a trajectory error comparable to \texttt{Min+Lin-2P} as their confidence intervals overlap. We therefore consider \texttt{Lin-2P} as the best performing model in our evaluation. Overall, most hybrid models achieve performance comparable to or better than the DNN baseline \texttt{LSTM}. Hybrid models that employ \texttt{Lin} show better results on average. We hypothesize that the resulting loss function for the LSTM is less complex due to the linearity of \texttt{Lin} compared to more complex non-linear physical models and therefore easier to learn. Figure~\ref{fig:states_over_time} visualizes a single test sample of predicted and true states over a time span of $\SI{15}{\minute}$. Performance between \texttt{LSTM} and \texttt{Lin-2P} are similar and outperform \texttt{QLag} and \texttt{Min+Lin-1P}. Prediction of surge speed $u$ is very accurate over \SI{15}{\minute} for \texttt{QLag}, \texttt{LSTM}, \texttt{Min+Lin-2P}. It is the easiest state to predict, since the effect of propulsion outweighs all other dynamics. However, sway $w$ and yaw rate $r$ are non-linearly coupled and strongly influenced by external forces, which makes them to difficult to predict. The impact of waves on the yaw rate $r$ is observable in the oscillations of the predicted and true state. \texttt{LSTM} and \texttt{Lin-2P} successfully predict the mean yaw rate, but fail to predict the wave-induced oscillations due to its randomness. \texttt{QLag} has the best performance predicting roll rate $p$. However, the time series plot shows that the prediction is not accurate and tends towards predicting a value of $0$. Accordingly, none of the evaluated methods are suited for use-cases with strong waves, which can be attributed to the randomness of ocean waves. \begin{figure*}[htbp] \input{fig-trajectory.tex} \end{figure*} \begin{figure*}[htbp] \input{fig-threshold_error.tex} \end{figure*} \parabold{Trajectory prediction.} The results for trajectory prediction are summarized in the last of column of Table~\ref{table:rmse}. The errors mirror the results for state prediction. Hybrid models with two-phase training and \texttt{LSTM} achieve similar trajectory errors. The hybrid models \texttt{Min-Lin-2P}, \texttt{Lin-2P} and \texttt{Pro+Lin-2P} perform significantly better than all other models. Two-phase training provides better trajectory prediction compared to one-phase training for all cases but \texttt{Min-1P}. Figure~\ref{fig:rmse_over_time} shows boxplots for the trajectory error per minute for the baseline model \texttt{LSTM} and the best-performing hybrid model \texttt{Lin-2P}. Our hybrid approach achieves a lower mean and standard deviation in the trajectory error than the \texttt{LSTM}. Accordingly, the approach is more reliable for trajectory prediction over long time frames than a pure deep learning method. An example of a trajectory prediction is visualized in Figure~\ref{fig:trajectory_pred_true}. The trajectories are computed from the state predictions in Figure~\ref{fig:states_over_time}. \texttt{LSTM} and \texttt{Lin-2P} predict similar trajectories, which are very close to the true trajectory. The divergence from the true trajectory in each model occurs due to the difficulty of predicting yaw rate $r$, i.e. rotation around the z-axis, since the divergence occurs as a result of changing the heading of the vessel. This difficulty can be observed specifically for \texttt{QLag}, as it underpredicts the yaw rate $r$, as shown in Figure~\ref{fig:qlag_states} starting at approx. \SI{300}{\second}, and consequently diverges from the true trajectory. \parabold{Interpretability.} We apply a threshold to the output range of the LSTM to create an interpretable hybrid model. Figure~\ref{fig:threshold_error} shows the RMSE of our best-performing hybrid model \texttt{Lin-2P} for surge $u$, sway $v$ and yaw rate $r$ for various relative thresholds in orange. The blue horizontal line indicates the error of the model without constraints. The figure shows that a relative threshold of ${\sim} 15\%$ is sufficient to achieve prediction accuracy similar to the corresponding unconstrained model for all three state variables. Therefore, the loss in interpretability due to the LSTM can be limited effectively. The LSTM applies small adjustments to correct errors introduced by the physical model, which matches the training objective. In summary, \texttt{Lin-2P} outperforms all other models including \texttt{LSTM} and the other hybrid model variants w.r.t. ship state and trajectory prediction. We show that \texttt{Lin-2P} can be constrained effectively to achieve model interpretability with no loss in accuracy. Accordingly, our hybrid approach enables interpretable and accurate multistep predictions in the use of case of predicting ship motion. \subsection{Generalizability}\label{section:quadcopter} \begin{table}[htbp] \input{table-scores_quadcopter.tex} \end{table} \begin{figure*}[htbp] \input{fig-quadcopter_threshold_error.tex} \end{figure*} To show generalizability of our approach, we summarize our results for the task of quadcopter motion with the dataset used in \cite{Mohajerin2019}. \parabold{Dataset.} The dataset by \cite{Mohajerin2019} consists of multiple acrobatic maneuvers performed by an expert pilot in an indoor environment. The sampling rate is $\delta = \SI{100}{\hertz}$. Compared to the ship motion use case, measurements are more precise and frequent due to lack of environmental disturbances and use of a motion capture system. Unlike a ship, motion of the quadcopter is mainly determined by its propulsion, as its mass and surface area are low and therefore inertial and aerodynamic forces are small. Due to the performed aerobatics, the control inputs are irregular unlike the ship use case, where control inputs were generated to simulate routine operation. The state vector is defined as $\vect{z} = \begin{bmatrix}\dot{x} & \dot{y} & \dot{z} & p & q & r\end{bmatrix}$, which are velocities along each axis in the inertial frame and the angular rates for roll, pitch, and yaw. \parabold{Quadcopter Models.} We perform a train-validation-test split of 60-10-30 and use grid-search to optimize hyperparameters. As suggested by \cite{Mohajerin2019}, the evaluated prediction horizon is \SI{1}{\second} corresponding to $100$ time steps. Similar to \texttt{Min}, we develop a minimal physical model \texttt{MinQ} for quadcopters, which models rigid-body forces and gravity. We reuse the linear regression model \texttt{Lin} (Equation~\ref{eq:linear}). We introduce a quadratic regression model \texttt{Qua}, which includes the square of each control input and each state to more effectively represent forces, such as air resistance. \texttt{QLag}\cite{Punjani2015} and \texttt{LSTM}\cite{Mohajerin2019} are again used as baseline models. \parabold{Results.} Table~\ref{table:rmse_quadcopter} shows state and trajectory prediction performance of the baseline models and each hybrid model using two-phase training for the quadcopter dataset. \texttt{LSTM} outperforms all other models in state and trajectory prediction. All hybrid models achieve similar results and outperform \texttt{QLag}. The best performing hybrid model is \texttt{MinQ+Qua-2P}. Figure~\ref{fig:quadcopter_threshold_error} shows that \texttt{MinQ+Qua-2P} constrained to a relative threshold of ${\sim} 8\%$ achieves comparable results to the unconstrained model. The results confirm that our hybrid models are preferable w.r.t. accuracy over physical models (\texttt{QLag}). The hybrid models perform slightly worse than pure deep learning for the quadcopter motion, but allows more interpretable predictions. \section{CONCLUSIONS} In this paper, we developed a residual hybrid model including a two-phase training procedure. We define relative threshold as a metric for interpretability and employ constraints on the LSTM to achieve interpretable predictions. Our approach is more flexible than existing work as it is capable of employing a large variety of physical models, such as models with missing parameters and non-linearities (\textbf{C2}: Non-linear physical models). Our results indicate that linear models are preferable as physical models w.r.t. accuracy, as they achieve the best results for ship motion prediction. The proposed two-phase training procedure enables accurate predictions over large time spans for various physical models, while the default training approach either fails to train the network or results in worse prediction accuracy (\textbf{C3: Trainability of hybrid models}). The developed hybrid models outperform pure deep learning for ship motion with environmental disturbances (\textbf{C4: Environmental disturbances}) and performs only slightly worse for quadcopter motion. The licensing of our method as part of a control system requires that the DNN contribution has to be low to ensure interpretability. Additionally, failure conditions of the DNN have to be understood to ensure safety. While we achieve the former requirement with a constraint on the DNN output range without loss of accuracy (\textbf{C1: Interpretability}), the latter one requires future research that answers what dynamics are learned by the DNN. Additionally, our current approach only uses a simple constraint that applies to the output. Mathematical properties desirable in models for control are, for example, Lipschitz continuity and bounded-input, bounded-output stability, as they allow integration within robust model-based control frameworks. These properties require that a relation between input and output of the model is enforced. Future work will extend our hybrid approach with such model properties to integrate with model-based control frameworks. \\\\ \noindent \parabold{Acknowledgments.} Funded by Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) under Germany's Excellence Strategy - EXC 2075 - 390740016. We acknowledge the support by the Stuttgart Center for Simulation Science (SimTech). \bibliographystyle{IEEEtran} \section{INTRODUCTION} Models for multi-step prediction yield a sequence of future system states given the initial system state and a sequence of control inputs. Control methods, such as model predictive control \cite{Li2020,Wu2020}, rely on the predictions of future states for computing optimal control inputs given a set of objectives like heading, speed or minimal fuel consumption. Multi-step prediction models should be accurate and, in addition, they should be interpretable such that a domain expert can understand their predictions and identify their limitations, e.g. their failure states. Interpretability is considered a crucial safety concern for ML systems by governmental entities, e.g. the European Commission \cite{EU2020}, or technical inspection and product certification services, e.g. the Technical Inspection Association (TÜV) \cite{Tuv2018}. This paper develops a model for multi-step prediction, which is accurate and interpretable, to allow for future certification and usage in vehicle control. Traditional multi-step prediction models use physical (motion) models \cite{Fossen2011,Schoukens2019}, which are commonly based on first-principles or linear regression. The parameters of these models correspond to physical parameters of the system, which makes these approaches interpretable. However, physical models suffer from the high cost and difficulty of measuring parameters concerning, e.g., aero- or hydrodynamics. Although these costs can be reduced by applying simplifications, such as linearization of the model around a task-dependent operating point (e.g. a constant speed for manoeuvring \cite{Fossen2011}), these simplifications introduce prediction errors, which aggregate over multiple prediction steps causing the predicted states to diverge from the actual states \cite{Mohajerin2019}. The lack of accuracy can be reduced by deep neural networks (DNN), which have shown to be capable at simulating dynamical systems over large time spans for various domains, such as unmanned aerial vehicles \cite{Chen2017,Mohajerin2019,Punjani2015}, ships \cite{Li2017b,Woo2018}, engines \cite{Schuerholz2019}, aerodynamics \cite{Li2019}, and lake temperatures \cite{Jia2019}. DNN-based models require little domain knowledge in comparison to physical models. In addition, they are less expensive to build, as the parameters are automatically learned from the data. However, DNNs suffer from low interpretability, as their parameters do not directly correspond to the parameters of the system and are therefore not physically meaningful (\textbf{Challenge C1: Interpretability}). As a consequence, they may not be used without further developments in practice, as certification bodies will not licence such technologies for use in autonomous vehicles \cite{Tuv2018}, at least in the current state. In order to benefit from both approaches, hybrid models combine physical models and DNN, while minimizing the respective disadvantages. Improved interpretability compared to deep learning is achieved by partially retaining the interpretability of the physical model via certain structures in the model architecture or by constraining the dynamics of the DNN. Recent approaches have employed a residual hybrid architecture, in which the DNN is trained to compensate for the error residual of the physical model \cite{Chattha2019,Mohajerin2019,Woo2018}. \cite{Chattha2019} and \cite{Woo2018} achieve a higher interpretability compared to DNN due to the combination of physical model and DNN output for the overall prediction. \cite{Mohajerin2019} feeds the output of an additional DNN as input to the physical model. This has a negative impact on the interpretability compared to \cite{Chattha2019} and \cite{Woo2018}, since the input-output relation of the physical model is obscured by the DNN. However, the approach allows the inclusion of unknown parameters, which are identified during training of the DNN, which makes it more flexible than \cite{Chattha2019} and \cite{Woo2018}. However, all these three approaches only consider purely linear models as physical models, which is a considerable limitation, since most vehicle dynamics are non-linear (\textbf{Challenge C2: Non-linear physical models}). The training of hybrid models that use non-linear or inaccurate physical models for multi-step prediction is difficult (\textbf{Challenge C3: Trainability of hybrid models}). Due to feedback of the predicted state as input to the physical model, errors in the prediction aggregate over time, which causes divergence in the weights of the DNN. Another limitation of the existing work is its evaluation in use cases with low environmental disturbances, such as quadcopters operated indoors or unmanned surface vehicles operated on lakes \cite{Mohajerin2019,Woo2018}. Environmental disturbances have a large effect on vehicle dynamics due to strong coupling between states (\textbf{Challenge C4: Environmental disturbances}). To address these challenges, we propose a novel hybrid method for multi-step prediction of vehicle states consisting of a residual hybrid architecture with a respective training procedure. Our proposed hybrid architecture combines long short-term memory networks (LSTM) and physical models similar to \cite{Chattha2019}, but with the capacity to model a large variety of physical models composed of first-principles and regression models (\textbf{C2}). Using our two-phase training procedure, we address the existing problem of divergence during training of hybrid models in multi-step prediction, thus allowing for inaccurate and non-linear physical models as part of the hybrid model (\textbf{C3}). Our procedure ensures convergence of the DNN by training it to correct the single-step error of the physical model and the aggregated error over multiple prediction steps. In addition, we guarantee interpretability of our approach by applying a constraint on the output range of the LSTM (\textbf{C1}). This enables a trade-off between interpretability of the hybrid model and accuracy by varying the strictness of the constraint. Finally, we evaluate our approach on the use-case of ship motion under environmental disturbances (\textbf{C4}) and on the use-case of quadcopter motion without disturbances. \section{RELATED WORK}\label{section:related_work} We have identified three families of related approaches that merge knowledge of a physical system with deep learning. \parabold{Network architectures.} Deep feedforward neural networks (FNN) are frequently used to approximate complex non-linear dynamics \cite{Nichiforov2017,Punjani2015}. These FNN are known as non-linear auto-regressive exogenous (NARX) networks. They are given a fixed window of prior states and control inputs and predict subsequent states. Because the size of their input window is fixed, NARX networks do not cope well with long-term dynamics. Recurrent neural networks (RNN) are a superior alternative to FNNs for simulating dynamical systems, as their recurrent structure permits them to model complex non-linear dynamics over large time spans \cite{Feng2019,Li2019,Mohajerin2018a,Woo2018}. The hidden state of RNN can learn latent temporal dependencies, e.g. environmental effects such as waves, which are not directly measurable with sensors. Thus, RNNs may provide more accurate state predictions than FNNs. A network architecture that models the physical processes of the system can also improve prediction accuracy. Sch\"urholz et al. \cite{Schuerholz2019} employs a recurrent architecture with additional forward connections between recurrent units, which correspond to the physical information flow between components further improving the prediction accuracy. \parabold{Physics-based loss functions.} Loss functions can encode known dynamics and physical parameters as regularization terms. In \cite{Jia2019} and \cite{Muralidhar2018} physics-based restrictions motivated by the law of energy conservation are used on the loss function to simulate lake temperatures with FNNs and RNNs. Their evaluations show that this method allows the network to converge faster than a network with unmodified loss. Approaches dealing with object tracking \cite{Ren2018,Stewart2017} employ loss functions for semi-supervised learning by encoding dynamics in the loss function and punishing trivial solutions. Including knowledge about the physical system in loss functions reduces the amount of data and time required for training the DNN and results in physically plausible predictions. However, physics-based loss functions do not improve interpretability, as they only affect the training of the neural network. \parabold{Hybrid models.} Hybrid models combine different types of models, such as physical models and DNN. In a serial architecture, approaches like \cite{Cranmer2012} and \cite{Mohajerin2018a} either give the output of a DNN as input to a physical model or vice versa. In either variant, the output of the second model is returned as overall prediction. The rationale underlying these architectures is that certain inputs to a physical model, such as hydrodynamic forces, are difficult to model with first-principles, but can be predicted by a DNN from control inputs and the system state. The serial connection limits the interpretability of the hybrid model, as the input-output relation is obscured by the neural network. On the other hand, a parallel architecture adds the output of a physical model and the output layer of a DNN into an overall prediction \cite{Cranmer2012,Woo2018}. This approach retains the interpretability of the physical model, if the DNN contribution is sufficiently small in comparison. Recent work uses residual architectures, which employ serial and parallel connections in joint \cite{Chattha2019,Mohajerin2018a}. The serial connection, which gives the output of the physical model as input to the DNN, allows the network to rectify errors of the physical model and improve accuracy over multiple prediction steps. The parallel connection sums the error residual predicted by the DNN and the physical model output for the overall prediction thereby ensuring the interpretability of the prediction. Lastly, current approaches utilize physical models, which are either relatively accurate but expensive \cite{Chattha2019} or use simplifications such as linear models \cite{Mohajerin2018a,Woo2018}. The former type of model is expensive to develop, while the latter limits the possible parameters present in the physical model. \section{HYBRID MODEL AND TRAINING FOR MULTISTEP PREDICTION}\label{section:model} Our proposed approach consists of a hybrid architecture and a two-phase training procedure. We combine a physical model with an LSTM, which predicts the error residual of the physical model. The physical model and LSTM are described in Sections~\ref{section:whitebox} and~\ref{section:blackbox}, respectively. The goal of the two-phase training process is to achieve convergence. In the first phase, we reduce the one-step prediction error by teacher-forcing \cite{Lamb2016}, i.e. at each time step, the hybrid model receives the true prior state as input. In the second phase, we train with multistep prediction feeding back each predicted state as input for the next prediction. The variables used for the model definition are summarized in Table~\ref{table:notation}. \begin{table}[t] \input{table-variables} \end{table} \subsection{Overall Architecture}\label{section:overall_arch} As shown in Figure~\ref{fig:hybrid_model}, the hybrid model consists of an LSTM and a physical model. The physical model can be a regression or first-principles component, as well as a combination of both. A first-principles component is a set of differential equations derived directly from Newton's second law of motion. A regression component allows learning of an interpretable model from data, which is useful estimating hydrodynamical coefficients \cite{Fossen2011}. It is common practice to combine both approaches to yield more accurate physical models. The physical model $\vect{z}_{t+1}^{\;\text{phy}}$ computes its prediction from the control input $\vect{c}_t$ and the previous state $\vect{z}_{t}$. The LSTM $\vect{z}^{\;\text{lstm}}_{t+1}$ predicts the error residual of the physical model given the previous hidden state $\vect{h}_{t}$, the control input $\vect{c}_t$, and the current state prediction of the physical model $\vect{z}_{t+1}^{\;\text{phy}}$. The previous state $\vect{z}_{t}$ is not needed as input, since it is composed of the prior physical model output $\vect{z}_{t}^{\;\text{phy}}$, which was provided as input, and its own output $\vect{z}^{\;\text{lstm}}_{t}$. Accordingly, this information is already encoded in the hidden state and its inclusion yielded no performance improvements in our initial experiments. The state prediction of the hybrid model $\hat{\vect{z}}_{t+1}$ is the sum of $\vect{z}_{t+1}^{\;\text{phy}}$ and $\vect{z}^{\;\text{lstm}}_{t+1}$. During multi-step prediction, the auto-regressive loop, represented by the dashed arrow, feeds back this state prediction $\hat{\vect{z}}_{t+1}$ as input to the physical model. Because of the feedback loop, the multi-step prediction error may aggregate over time. The forward computation for our hybrid model for the time step $t+1$ is defined as follows: \begin{align} \begin{split} \vect{z}^{\;\text{phy}}_{t+1} &= \text{Regression}(\vect{c}_{t}, \vect{z}_{t}) + \text{1st-Principles}(\vect{c}_{t}, \vect{z}_{t}) \end{split} \label{eq:physical_true}\\ \vect{h}_{t+1} &= \text{LSTM}(\vect{c}_t, \vect{z}^{\;\text{phy}}_{t+1}, \vect{h}_{t}) \\ \vect{z}^{\;\text{lstm}}_{t+1} &= \matr{W}^{\text{hx}} \, \vect{h}_{t+1} \\ \begin{split} \hat{\vect{z}}_{t+1} &= \vect{z}^{\;\text{phy}}_{t+1} + \vect{z}^{\;\text{lstm}}_{t+1} \\ \end{split} \end{align} \begin{figure}[t] \input{fig-hybrid_model} \label{fig:hybrid_model} \end{figure} \parabold{Training.} The training of the hybrid approach is divided into training of the physical model and training of the LSTM. The regression component is fit on the residual of the first-principles model for the single-step objective: \begin{align} \begin{split} \mathcal{L}^{\text{reg}}(\vect{\theta}) =& \text{MSE}(\vect{z}_{t+1} - \text{1st-Principles}(\vect{c}_{t}, \vect{z}_{t}),\\ &\phantom{\text{MSE}(}\text{Regression}(\vect{c}_t, \vect{z}_{t}; \vect{\theta}) ) \end{split} \end{align} If no first-principles component is used, the regression fits on the task of predicting the system state instead of the first-principles residual. The training of the LSTM on the multi-step prediction objective, i.e. predicting the state over multiple time steps given a sequence of control inputs, is difficult, because each next-step prediction of the physical model depends on the inaccurate previous prediction. Thus, the error aggregates over several time steps causing divergence between predicted state and true state. LSTMs are trained with backpropagation-through-time (BPTT), which is sensitive to large errors. A combination of increasingly large errors and BPTT causes exploding gradients and prevents successful training of the network. We solve this problem with our two-phase training procedure, which enables training hybrid models with divergent and inaccurate physical models. \parabold{First phase.} In the first phase, we employ teacher forcing, where the physical model receives the true state $\vect{z}_{t}$ as input at each time step $t+1$. This mechanism enables the LSTM to learn the one-step error of the physical model, which occurs due to missing parameters or simplifications. The loss function for the first phase is defined as: \begin{align} \hspace*{-0.8em}\mathcal{L}^\text{lstm}(\vect{\theta}) = \sum_{t=1}^{T} \text{MSE}(\vect{z}_{t+1} - \vect{z}^{\;\text{phy}}_{t+1}, \text{LSTM}(\vect{c}_t, \vect{z}^{\;\text{phy}}_{t+1}, \vect{h}_{t}; \vect{\theta})) \end{align} where $T$ is the number of time steps and MSE is the mean squared error. The first training phase is only performed to reduce the estimation error until feedback of the state prediction does not cause divergence during multi-step prediction. Therefore the first-phase loss function is only employed for a limited number of epochs. \parabold{Second phase.} In this phase, the model learns to predict states over multiple time steps without receiving true states as input. This is achieved by using the state prediction from the previous time step as input in the current prediction step. The training remains effective, because the first-phase ensured that the hybrid model achieves sufficiently accurate predictions to prevent the strong divergence of DNN gradients. The loss function for the second phase only differs from the first-phase in the physical model prediction $\vect{z}^{\;\text{phy}}_{t+1}$, as the prediction now depends on the predicted prior state $\hat{\vect{z}}_t$ and not on the true prior state: \begin{align} \vect{z}^{\;\text{phy}}_{t+1} &= \text{1st-Principles}(\vect{c}_t, \hat{\vect{z}}_{t}) + \text{Regression}(\vect{c}_t, \hat{\vect{z}}_{t}) \end{align} \subsection{Physical Models}\label{section:whitebox} We define (cf. \cite{Fossen2011,Schoukens2019}) physical models for ships combining a first-principles model with a regression model. The simple dynamics are modelled precisely using the corresponding physical equations. The complex system dynamics are approximated using least squares regression. \parabold{First-principles.} The models of motion are represented by differential equations, which define the equilibrium of forces resulting in the acceleration of a vehicle. We use the motion model for surface vessels developed by Fossen~\cite{Fossen2011}: \begin{align} \deriv{\eta} &= \matr{J}(\vect{\eta}) \vect{v} \label{eq:kinematics} \\ \deriv{v} &= \matr{M}^{{-1}} (\force{control} + \force{env} - \matr{D}(\vect{v})\vect{v} - \matr{C}_\rb(\vect{v})\vect{v} - \vect{g}(\vect{\eta})) \label{eq:kinetics} \end{align} Equation~\ref{eq:kinematics} defines the kinematics of the vessel, as it describes the mapping of velocities in the ship's body frame to a motion in the inertial reference frame, i.e. earth. The ship's kinetics represented by Equation~\ref{eq:kinetics} define the relation of forces affecting the vessel and the resulting acceleration. Developing first-principles models is challenging due to the high cost and difficulty associated with measuring their physical parameters. Additionally, environmental variables, such as the sea state, cannot be measured during the operation of a vehicle, which makes their prediction with first-principles models infeasible. Due to these limitations, we consider two examples of incomplete first-principles models, which entirely omit immeasurable parameters. First, the \textbf{minimal model} (\texttt{Min}) uses only parameters that are easy to measure or approximate, such as those related to the vessel's mass, inertia and geometry. The restoring forces are linearized as $\matr{G}\vect{\eta}$ around a roll angle of $0$ yielding a good approximation with fewer parameters \cite{Fossen2011}: \begin{align} \deriv{v} &= \matr{M}^{{-1}} (-\matr{C}_\rb(\vect{v})\vect{v} - \matr{G} \vect{\eta})) \end{align} All the other parameters that are expensive to measure are set to $0$, e.g. ones concerning hydrodynamic forces. Second, a \textbf{propulsion-based model} (\texttt{Pro}), which extends the minimal model by parameters for propulsion and steering forces. This model includes $\force{control}$, which represents the control forces generated by propellers and rudders: \begin{align} \deriv{v} &= \matr{M}^{{-1}} (\force{control}(\vect{c}, \vect{v})-\matr{C}_\rb(\vect{v})\vect{v} - \matr{G} \vect{\eta})) \end{align} The model for control forces $\force{control}$ is highly dependent on the propulsion system of the modeled vessel, as it depends on the thruster configuration and the type of steering mechanism. The implementation details of a standard propeller and rudder may be found in the MSS toolbox \cite{Fossen2004}. \parabold{Linear regression.} We employ linear regression in two models components as a coarsely approximating physical model \cite{Ljung2019}. The \textbf{linear regression model} (\texttt{Lin}) receives prior system state $\vect{z}_{t}$ and control input $\vect{c}_{t}$: \begin{align} \hat{\vect{z}}_{t+1} &= \matr{Q} \vect{c}_{t} + \matr{P} \vect{z}_{t} + \vect{b}\label{eq:linear} \end{align} with input matrix $\matr{Q}$, system matrix $\matr{P}$, and bias vector $\vect{b}$. Second, we extend the linear model with a non-linear input mapping $f$ to better approximate hydrodynamic forces: \begin{align} \hat{\vect{z}}_{t+1} &= \matr{Q} \vect{c}_{t} +\matr{P} f(\vect{z}_{t}) + \vect{b} \end{align} We use the set of non-linear features developed by \cite{Blanke1993} consisting of polynomial and absolute terms, which are well-suited for modeling the damping and drag effects of a ship hull with the surrounding fluid. \begin{comment} We adapt their features for our \textbf{hydrodynamic regression model} (\texttt{Hyd}) as follows: \begin{align} u_{t+1} &= \vect{a}_{u}^\intercal \, [ u_{t} \hspace{0.4em} \abs{u_{t}}u_{t} \hspace{0.4em} w_{t}r_{t}]^\intercal \\ v_{t+1} &= \vect{a}_{w}^\intercal \, [ w_{t} \hspace{0.4em} \abs{u_{t}}w_{t} \hspace{0.4em} u_{t}r_{t} \hspace{0.4em} \abs{w_{t}}w_{t} \hspace{0.4em} \abs{r_{t}}w_{t} \hspace{0.4em} \abs{w_{t}}r_{t} \hspace{0.4em} \abs{u_{t}w_{t}}\phi \hspace{0.4em} u_{t}^2\phi ]^\intercal\\ p_{t+1} &= 0\\ r_{t+1} &= \vect{a}_{r}^\intercal \, [ r_{t} \ \abs{u_{t}}w_{t} \hspace{0.4em} \abs{w_{t}}r_{t} \hspace{0.4em} \abs{u_{t}}r_{t} \hspace{0.4em} \abs{r_{t}}r_{t}\hspace{0.4em} \abs{u_{t}\phi_{t}}\phi_{t} \hspace{0.4em} \abs{r_{t}}u_{t}\phi_{t} \hspace{0.4em} \abs{u_{t}}u_{t-1}\phi_{t} ]^\intercal\\ \phi_{t+1} &= \vect{a}_{\phi}^\intercal \, [ p_{t} \hspace{0.4em} \phi_{t} ]^\intercal \end{align} where weights for each state are encoded by the vectors $\vect{a}_u$, $\vect{a}_w$, $\vect{a}_p$, $\vect{a}_r$, and $\vect{a}_\phi$. The vertical bars, e.g. $\abs{u_t}$, denote the absolute value of a scalar. \end{comment} \subsection{Recurrent Neural Network}\label{section:blackbox} We employ a stacked LSTM including an initialization mechanism as DNN component in our hybrid model, as it is capable of memorizing long-term dynamics and of modeling dynamics at different time scales \cite{Graves2013}. The latter capability is important for modeling ships, since waves and control inputs introduce dynamics with different frequencies. The models for multi-step prediction, such as a LSTMs, rely on an initial state to yield accurate predictions. Thus, the initial state should encode all available information about the system and the surrounding environment, e.g. the velocity and position of a ship but also the sea state. The state of an LSTM is its cell and hidden state. An LSTM can be initialized at $t=0$ by providing a cell and hidden state. Mohajerin et al. \cite{Mohajerin2019} propose the initialization with an additional LSTM acting as initializer. The initializer receives as input a window of system states and control inputs, which precede the predicted time frame. The recurrence of the initializer enables it to extract latent dynamics from the data, which cannot be directly measured such as the sea state. The prediction model is then initialized with the final hidden state of the initializer. \section{EVALUATION}\label{section:evaluation} The proposed method is evaluated extensively for modeling dynamics of a patrol ship under environmental disturbances (Section~\ref{section:expsetup} and~\ref{section:results}). To prove generalizability Section~\ref{section:quadcopter} summarizes results for quadcopter motion. \subsection{Experiment Setup}\label{section:expsetup} \parabold{Dataset.} The dataset is generated with a 4 degrees-of-freedom (DOF) maneuvering model of a patrol ship, which simulates the horizontal plane motion and rolling due to waves. The original model and physical parameters are provided by Perez et al. \cite{Perez2006} and can be found in the MSS toolbox \cite{Fossen2004}. The model is extended to include wind forces according to Isherwood \cite{Isherwood1972}, ocean waves generated with the JONSWAP spectrum \cite{Hasselmann1973}, and corresponding wave forces computed with force response amplitude operators. Two symmetrically-placed fixed-pitch rudder propellers are implemented for control of heading and speed of the vessel. Control inputs to the simulation model are generated via an open-control loop, which mimic a human operator. The measurements of the vessel are sampled with a rate of \SI{1}{\hertz}. The dataset consists of $96$ hours separated into $\SI{1}{\hour}$ simulations, where each simulation is initialized with a random sea state and control inputs. The dataset is split into training, validation, and test set with a 60-10-30 split. \parabold{Metrics.} The prediction performance is measured with regards to state and trajectory prediction over a time span of $\SI{15}{\minute}$ or $900$ time steps. A window containing $\SI{1}{\minute}$ of prior control inputs and state variables is provided as initial state. The five predicted states are the velocities for surge $u$, sway $w$, roll $p$, and yaw $r$, as well as the roll angle $\phi$. The root mean squared error (RMSE) is averaged over all time steps for each state to measure the state prediction performance. The trajectory RMSE measures the average distance between the predicted and true trajectory for each time step. The trajectory error emphasizes surge, sway, and yaw, as they have the largest impact on the trajectory. Interpretability is measured using an output range constraint enforced on the LSTM. An unconstrained LSTM results in no interpretability, while an increasingly smaller output range increases interpretability. We employ the relative threshold applied to the LSTM as measure of interpretability. The relative threshold is the ratio between the sizes of the LSTM output range and the expected output range of the physical model. The expected output range of the physical model is the $95\%$ range of its outputs computed on the training and validation set. For example, a physical model has an expected range of $[-5, 5]$ and the LSTM is constrained to a range of $[-1, 1]$, then the relative threshold is $20\%$. A lower relative threshold implies a higher degree of interpretability. \parabold{Model selection.} Hyperparameter search is performed via grid search on the validation set. The best model per class is chosen based on the RMSE summed over each state. Quadratic control lag (\texttt{QLag}) is a regression model developed by \cite{Punjani2015} as best-performing physical baseline in their work. It uses a window of prior control inputs and states, and includes control inputs as quadratic terms to model the relation between propulsion and velocity. Stacked LSTM with an LSTM initializer (\texttt{LSTM}, \cite{Mohajerin2019}) is used as DNN baseline. Hybrid models are trained with each potential physical model configuration using the default one-phase training and the proposed two-phase training (\{\texttt{Min}, \texttt{Pro}\}+\{\texttt{Lin}, \texttt{Pro}\}-\{\texttt{1P}, \texttt{2P}\}). This allows us to evaluate whether our two-phase training can successfully train hybrid models with incomplete and non-linear physical models. The models are denoted by abbreviations as defined in the previous text. \texttt{Lin-1P} is similar to the hybrid model by \cite{Woo2018}. \subsection{Results}\label{section:results} \begin{table}[htbp] \input{table-scores_ship.tex} \end{table} \begin{figure*}[htbp] \input{fig-states_time.tex} \end{figure*} \parabold{State prediction.} Table~\ref{table:rmse} shows the state prediction performance of the baselines \texttt{QLag} and \texttt{LSTM}, as well as each variation of the hybrid model. Error values across different state variables are not directly comparable, as they are not normalized and each variable has a different magnitude. \texttt{Min-1P} is the only hybrid model without two-phase training that outperforms its counterpart with two-phase training. However, \texttt{Min-1P} performs worse overall compared to all other two-phase hybrid models. For all other configurations, the hybrid model with one-phase training performs worse by a large factor. For \texttt{Hyd-1P}, no model was identified to be capable of simulating the vessel without diverging completely. These results indicate that the proposed two-step training procedure allows integration of a large range of physical models with DNN compared to the default training procedure. \texttt{Lin-2P} achieves the lowest error for three state variables. Additionally, it achieves a trajectory error comparable to \texttt{Min+Lin-2P} as their confidence intervals overlap. We therefore consider \texttt{Lin-2P} as the best performing model in our evaluation. Overall, most hybrid models achieve performance comparable to or better than the DNN baseline \texttt{LSTM}. Hybrid models that employ \texttt{Lin} show better results on average. We hypothesize that the resulting loss function for the LSTM is less complex due to the linearity of \texttt{Lin} compared to more complex non-linear physical models and therefore easier to learn. Figure~\ref{fig:states_over_time} visualizes a single test sample of predicted and true states over a time span of $\SI{15}{\minute}$. Performance between \texttt{LSTM} and \texttt{Lin-2P} are similar and outperform \texttt{QLag} and \texttt{Min+Lin-1P}. Prediction of surge speed $u$ is very accurate over \SI{15}{\minute} for \texttt{QLag}, \texttt{LSTM}, \texttt{Min+Lin-2P}. It is the easiest state to predict, since the effect of propulsion outweighs all other dynamics. However, sway $w$ and yaw rate $r$ are non-linearly coupled and strongly influenced by external forces, which makes them to difficult to predict. The impact of waves on the yaw rate $r$ is observable in the oscillations of the predicted and true state. \texttt{LSTM} and \texttt{Lin-2P} successfully predict the mean yaw rate, but fail to predict the wave-induced oscillations due to its randomness. \texttt{QLag} has the best performance predicting roll rate $p$. However, the time series plot shows that the prediction is not accurate and tends towards predicting a value of $0$. Accordingly, none of the evaluated methods are suited for use-cases with strong waves, which can be attributed to the randomness of ocean waves. \begin{figure*}[htbp] \input{fig-trajectory.tex} \end{figure*} \begin{figure*}[htbp] \input{fig-threshold_error.tex} \end{figure*} \parabold{Trajectory prediction.} The results for trajectory prediction are summarized in the last of column of Table~\ref{table:rmse}. The errors mirror the results for state prediction. Hybrid models with two-phase training and \texttt{LSTM} achieve similar trajectory errors. The hybrid models \texttt{Min-Lin-2P}, \texttt{Lin-2P} and \texttt{Pro+Lin-2P} perform significantly better than all other models. Two-phase training provides better trajectory prediction compared to one-phase training for all cases but \texttt{Min-1P}. Figure~\ref{fig:rmse_over_time} shows boxplots for the trajectory error per minute for the baseline model \texttt{LSTM} and the best-performing hybrid model \texttt{Lin-2P}. Our hybrid approach achieves a lower mean and standard deviation in the trajectory error than the \texttt{LSTM}. Accordingly, the approach is more reliable for trajectory prediction over long time frames than a pure deep learning method. An example of a trajectory prediction is visualized in Figure~\ref{fig:trajectory_pred_true}. The trajectories are computed from the state predictions in Figure~\ref{fig:states_over_time}. \texttt{LSTM} and \texttt{Lin-2P} predict similar trajectories, which are very close to the true trajectory. The divergence from the true trajectory in each model occurs due to the difficulty of predicting yaw rate $r$, i.e. rotation around the z-axis, since the divergence occurs as a result of changing the heading of the vessel. This difficulty can be observed specifically for \texttt{QLag}, as it underpredicts the yaw rate $r$, as shown in Figure~\ref{fig:qlag_states} starting at approx. \SI{300}{\second}, and consequently diverges from the true trajectory. \parabold{Interpretability.} We apply a threshold to the output range of the LSTM to create an interpretable hybrid model. Figure~\ref{fig:threshold_error} shows the RMSE of our best-performing hybrid model \texttt{Lin-2P} for surge $u$, sway $v$ and yaw rate $r$ for various relative thresholds in orange. The blue horizontal line indicates the error of the model without constraints. The figure shows that a relative threshold of ${\sim} 15\%$ is sufficient to achieve prediction accuracy similar to the corresponding unconstrained model for all three state variables. Therefore, the loss in interpretability due to the LSTM can be limited effectively. The LSTM applies small adjustments to correct errors introduced by the physical model, which matches the training objective. In summary, \texttt{Lin-2P} outperforms all other models including \texttt{LSTM} and the other hybrid model variants w.r.t. ship state and trajectory prediction. We show that \texttt{Lin-2P} can be constrained effectively to achieve model interpretability with no loss in accuracy. Accordingly, our hybrid approach enables interpretable and accurate multistep predictions in the use of case of predicting ship motion. \subsection{Generalizability}\label{section:quadcopter} \begin{table}[htbp] \input{table-scores_quadcopter.tex} \end{table} \begin{figure*}[htbp] \input{fig-quadcopter_threshold_error.tex} \end{figure*} To show generalizability of our approach, we summarize our results for the task of quadcopter motion with the dataset used in \cite{Mohajerin2019}. \parabold{Dataset.} The dataset by \cite{Mohajerin2019} consists of multiple acrobatic maneuvers performed by an expert pilot in an indoor environment. The sampling rate is $\delta = \SI{100}{\hertz}$. Compared to the ship motion use case, measurements are more precise and frequent due to lack of environmental disturbances and use of a motion capture system. Unlike a ship, motion of the quadcopter is mainly determined by its propulsion, as its mass and surface area are low and therefore inertial and aerodynamic forces are small. Due to the performed aerobatics, the control inputs are irregular unlike the ship use case, where control inputs were generated to simulate routine operation. The state vector is defined as $\vect{z} = \begin{bmatrix}\dot{x} & \dot{y} & \dot{z} & p & q & r\end{bmatrix}$, which are velocities along each axis in the inertial frame and the angular rates for roll, pitch, and yaw. \parabold{Quadcopter Models.} We perform a train-validation-test split of 60-10-30 and use grid-search to optimize hyperparameters. As suggested by \cite{Mohajerin2019}, the evaluated prediction horizon is \SI{1}{\second} corresponding to $100$ time steps. Similar to \texttt{Min}, we develop a minimal physical model \texttt{MinQ} for quadcopters, which models rigid-body forces and gravity. We reuse the linear regression model \texttt{Lin} (Equation~\ref{eq:linear}). We introduce a quadratic regression model \texttt{Qua}, which includes the square of each control input and each state to more effectively represent forces, such as air resistance. \texttt{QLag}\cite{Punjani2015} and \texttt{LSTM}\cite{Mohajerin2019} are again used as baseline models. \parabold{Results.} Table~\ref{table:rmse_quadcopter} shows state and trajectory prediction performance of the baseline models and each hybrid model using two-phase training for the quadcopter dataset. \texttt{LSTM} outperforms all other models in state and trajectory prediction. All hybrid models achieve similar results and outperform \texttt{QLag}. The best performing hybrid model is \texttt{MinQ+Qua-2P}. Figure~\ref{fig:quadcopter_threshold_error} shows that \texttt{MinQ+Qua-2P} constrained to a relative threshold of ${\sim} 8\%$ achieves comparable results to the unconstrained model. The results confirm that our hybrid models are preferable w.r.t. accuracy over physical models (\texttt{QLag}). The hybrid models perform slightly worse than pure deep learning for the quadcopter motion, but allows more interpretable predictions. \section{CONCLUSIONS} In this paper, we developed a residual hybrid model including a two-phase training procedure. We define relative threshold as a metric for interpretability and employ constraints on the LSTM to achieve interpretable predictions. Our approach is more flexible than existing work as it is capable of employing a large variety of physical models, such as models with missing parameters and non-linearities (\textbf{C2}: Non-linear physical models). Our results indicate that linear models are preferable as physical models w.r.t. accuracy, as they achieve the best results for ship motion prediction. The proposed two-phase training procedure enables accurate predictions over large time spans for various physical models, while the default training approach either fails to train the network or results in worse prediction accuracy (\textbf{C3: Trainability of hybrid models}). The developed hybrid models outperform pure deep learning for ship motion with environmental disturbances (\textbf{C4: Environmental disturbances}) and performs only slightly worse for quadcopter motion. The licensing of our method as part of a control system requires that the DNN contribution has to be low to ensure interpretability. Additionally, failure conditions of the DNN have to be understood to ensure safety. While we achieve the former requirement with a constraint on the DNN output range without loss of accuracy (\textbf{C1: Interpretability}), the latter one requires future research that answers what dynamics are learned by the DNN. Additionally, our current approach only uses a simple constraint that applies to the output. Mathematical properties desirable in models for control are, for example, Lipschitz continuity and bounded-input, bounded-output stability, as they allow integration within robust model-based control frameworks. These properties require that a relation between input and output of the model is enforced. Future work will extend our hybrid approach with such model properties to integrate with model-based control frameworks. \\\\ \noindent \parabold{Acknowledgments.} Funded by Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) under Germany's Excellence Strategy - EXC 2075 - 390740016. We acknowledge the support by the Stuttgart Center for Simulation Science (SimTech). \bibliographystyle{IEEEtran}
{'timestamp': '2021-03-15T01:10:54', 'yymm': '2103', 'arxiv_id': '2103.06727', 'language': 'en', 'url': 'https://arxiv.org/abs/2103.06727'}
arxiv
\section{Introduction} High spatial resolution (HSR) remote sensing images contain various geospatial objects, including airplanes, ships, vehicles, buildings, etc. Understanding these objects from HSR remote sensing imagery has great practical value for urban monitoring and management. Aerial Image segmentation is an important task in remote sensing understanding that can provide semantic and localization information cues for interest targets. It is a specific semantic segmentation task that aims to assign a semantic category to each image pixel. \begin{figure}[t] \centering \includegraphics[width=1.0\linewidth]{fig/teaser_pfnet.pdf} \caption{ \small Illustration of an aerial image segmentation example and our proposed module. The first row presents the input image and ground truth with complex backgrounds and small objects. The second row indicates the schematic diagram on {\it dense affinity propagation} and our proposed {\it point-based propagation} module. } \label{fig:teaser} \end{figure} However, besides the large scale variation problems in most semantic segmentation datasets~\cite{Cityscapes,ADE20K,pcontext-data,coco_stuff}, aerial images have their own challenging problems including high background complexity~\cite{farSeg_iSAID}, background and foreground imbalance~\cite{iSAID}, tiny foreground objects in high resolution images. As shown in the first row of Fig.\ref{fig:teaser}, the red boxes show the tiny objects in the scene while the yellow box and blue box show the complex background context, including houses and trees receptively. Current general semantic segmentation methods mainly focus on scale variation in the natural scene by building multi-scale feature representation~\cite{pspnet,deeplabv3} or enhancing the object boundaries with specific design module~\cite{kirillov2019pointrend,gated-scnn}. They fail to work well due to the lack of explicit modeling for the foreground objects. For example, several dense affinity-based methods~\cite{DAnet,ocnet} also obtain inferior results mainly because the imbalanced and complex background will fool the affinity learning on small objects. For example, both yellow boxes and blue boxes have the same semantic meaning of background but with a huge appearance change. Dense affinity learning forces pixels on small objects to absorb such noisy context which leads to inferior segmentation results. FarSeg~\cite{farSeg_iSAID} adopts FPN-like~\cite{fpn} design and solve the background and foreground imbalance problems by introducing a foreground-aware relation module. However, for small objects, there still exist some semantic gaps in different features in FPN. Namely, the gap is between the high-resolution features with low semantic information and low-resolution features with high semantic information. As shown in Fig.\ref{fig:teaser}, tiny objects like cars need more semantic information in lower layers with high resolution. In this paper, we propose a point-based information propagation module to handle the previous problems stated above. We propose PointFlow Module (PFM), a novel and efficient module for specific semantic points propagation between adjacent features. Our module is based on the FPN framework~\cite{fpn, kirillov2019panoptic} to bridge the semantic gap. As shown in the last row of Fig.\ref{fig:teaser}, rather than simple fusion or dense affinity propagation on each point as the previous work non-local module~\cite{Nonlocal}, PointFlow selects the several representative points between any adjacent feature pyramid levels. In particular, we design Dual Point Matcher by selecting matched point features from the salient area and object boundaries receptively. The former is obtained from explicit max pooling operation on the learned salient map. The latter is conditioned on the predicted object boundaries where we adopt a subtraction-based prediction. Then the point-wise affinity is estimated according to the point features that are sampled from both adjacent features. Finally, the higher layer points are fused into lower layers according to the affinity map. Our PFMs select and propagate points on foreground objects and sampled background areas to simultaneously handle both the semantic gap and foreground-background imbalance problem. Then we carry out detailed studies and analysis on PFM in the experiment part, where it improves the various methods by a large margin with negligible GFlops increase. Based on the FPN framework, by inserting PFMs between feature pyramids, we propose the PFNet. In particular, PFNet surpasses the previous method FarSeg~\cite{farSeg_iSAID} by \textbf{3.2\%} point on iSAID~\cite{iSAID}. Moreover, we also benchmark the recent state-of-the-art general semantic segmentation methods~\cite{HRNet,ocnet,EMAnet} on three aerial segmentation datasets including iSAID, Vaihingen and Postdam for the community. Benefited from efficient FPN design~\cite{kirillov2019panoptic}, our PFNet also achieves the best speed and accuracy on three benchmarks. Finally, we further verify the effectiveness of PFM on general semantic segmentation benchmarks, including Cityscapes~\cite{Cityscapes}, ADE-20k~\cite{ADE20K}, and BDD~\cite{yu2020bdd100k} and it achieves considerable results with previous work~\cite{deeplabv3,ocnet} with fewer GFLOPs. Our main contributions are three-fold: 1) We propose PointFlow Module (PFM), a novel and efficient module for poise-wised affinity learning, and we design a Dual Point Matcher to select the matched sparse points from salient areas and boundaries in a complementary manner. 2) We append PFM into FPN architecture and build a pyramid propagation network called PFNet. 3) Extensive experiments and analysis indicate the efficacy of PFM. We benchmark 15 state-of-the-art general segmentation methods on three aerial benchmarks. Our PFNet achieves state-of-the-art results on those benchmarks also with the best speed and accuracy trade-off. We further prove the generality of our method on three general semantic segmentation datasets. \section{Related Work} \noindent \textbf{General Semantic Segmentation} The general semantic segmentation has been eminently motivated by the fully-convolutional networks (FCNs)~\cite{fcn}. The following works~\cite{pspnet,deeplabv2,deeplabv3,deeplabv3p,denseaspp,HRNet,li2019gald} mainly exploit the spatial context to overcome the limited receptive field of convolution layer which leads to the multi-scale feature representation. For example, ASPP~\cite{deeplabv3} utilizes atrous convolutions~\cite{dilation} with different atrous rate to extract features with the different receptive field, while PPM~\cite{pspnet} generates pyramidal feature maps via pyramid pooling. Several work~\cite{unet,segnet,upernet,Exfuse,densedecoder,kirillov2019panoptic,xiangtl_gff} use the encoder-decoder architecture to refine the output details. Recent works~\cite{EMAnet,ocnet,ccnet,ACFNet,CoCurrentNet,annet,OCRnet,glore_gcn,beyond_grids,zhang2019dual,Zhang_2020_CVPR_dgmn,Li2020SRNet,yu2020representativeGNN,li2020spatial} propose to use non-local-like operators or losses ~\cite{transformer,non_local,Li_2021_CVPR,yu2020context_prior} to harvest the global context of input images. Meanwhile, several works~\cite{kirillov2019pointrend,gated-scnn,yuan2020segfix,li2020improving} propose to refine the object boundaries via specific designed processing. These general semantic segmentation methods ignore the special issues including imbalanced foreground-background pixels for modeling the context and increased small foreground objects in the Aerial Imagery. Thus these methods get inferior results which will be shown in the next section. \noindent \textbf{Semantic Segmentation of Aerial Imagery} Several earlier works~\cite{kaiser2017learning_aerial,marmanis2018classification,marcos2018land} focus on using multi-level semantic features on local patterns of images using deep CNN. Also, there exist a lot of applications, such as land use~\cite{huang2018urban}, building or road extraction~\cite{building_extraction,road_boundary_extraction,xu2018building_extraction,bastani2018roadtracer}, agriculture vision~\cite{agriculture}. They design specific methods based on existing semantic segmentation methods for special application scenario. In particular, relation net~\cite{relation_aerial} captures long-range spatial relationships between entities by proposing spatial and channel relation modules. Recently, FarSeg~\cite{farSeg_iSAID} propose relation-based and optimization-based foreground modeling to handle the foreground-background imbalance problems in remote sensing imagery. However, the missing explicit exploration of semantics propagation between adjacent features limits the performance on the segmentation of small objects. \noindent \textbf{Multi Scale Feature Fusion} Based on the FPN framework~\cite{fpn}, rather than simple top-down additional fusion, several works propose to fuse feature through gates~\cite{ding2018context,xiangtl_gff}, neural architecture search~\cite{nasfpn}, pixel-level alignment~\cite{sfnet} or adding bottom up path~\cite{PANet}, dense affinity learning propagation\cite{feature_pyramid_transformer}. Such full fusion methods may emphasize background objects like roads where the imbalance problem exists widely in aerial images. Our proposed PFM follows the design of FPN by propagating the semantics from the top to bottom. In contrast, rather than full fusion like previous works, our methods are based on point-level which select the several representative points to overcome the pixel imbalance problems in aerial imagery and leads to better results. \section{Method} In this section, we will first introduce some potential issues on dense point affinity learning for aerial segmentation task. Then we will provide detailed descriptions of our PointFlow module(PFM) to resolve the issues by selecting key semantic points for propagation efficiently. Finally, we will present our PFNet for aerial imagery segmentation. \begin{table}[!t]\setlength{\tabcolsep}{6pt} \centering \begin{threeparttable} \scalebox{0.75}{ \begin{tabular}{l c c c } \toprule[0.15em] Method & OS & mIoU & $\Delta$ \\ \toprule[0.15em] dialated FCN\cite{fcn,dilation}(baseline) & 8 & 59.0 & -\\ DAnet\cite{pspnet} & 8& 30.3 & 28.7$\downarrow$\\ OCnet(ASP-OC)~\cite{ocnet} & 8 & 40.2 & 18.8$\downarrow$ \\ DAnet+FPN~\cite{fpn} & 8& 59.3 & 0.3$\uparrow$\\ DAnet+our PFNet decoder & 8& 65.6 & 6.6$\uparrow$\\ \hline SemanticFPN~\cite{kirillov2019panoptic}(baseline) & 32 & 61.3 & -\\ +dense affinity~\cite{feature_pyramid_transformer}& 32 & 58.9& 2.4$\downarrow$\\ +our PFM & 32 & 65.0 & 3.7$\uparrow$ \\ \bottomrule[0.1em] \end{tabular}} \caption{ \small Simple experiment results on iSAID validation dataset. The dense affinity results in inferior results over various baselines. Appending our proposed PointFlow module results in a significant gain. OS: Output Stride in backbone. } \label{tab:results_on_iSAID_datasets_dense_affinity_methods} \end{threeparttable} \end{table} \subsection{Preliminary} Recent dense affinity based methods~\cite{Nonlocal,ocnet,DAnet,transformer,feature_pyramid_transformer} have shown progressive results for semantic segmentation. The core idea of these methods is to model the pixel-wised relationship to harvesting the global context. As shown in Equ.~\ref{equ:dense_affinity}, in the view of self-attention~\cite{transformer}, each pixel $p$ in 2-D input feature $F$ $\in \mathbb{R}^{C \times H \times W}$ is connected to all the other pixels to calculate the pixel-wised affinity where $A$ is the affinity function and it outputs affinity matrix $\in \mathbb{R}^{HW \times HW}$. $C$, $H$, and $W$ denote the channel dimension, height, and width, respectively. Note that definitions of $A$ can be different; we use the same label for simplicity. \begin{equation} F^{r}(p) = A(F(p), F(p)) {F(p)} \label{equ:dense_affinity} \end{equation} However, applying these methods directly on the iSAID dataset leads to inferior results even compared with various baseline methods, as shown in Tab.~\ref{tab:results_on_iSAID_datasets_dense_affinity_methods} whether such module is appended after FCN backbone or is inserted into feature pyramids. The reason has two folds: (1) There exist extremely imbalanced foreground-background objects in the iSAID dataset. Explicit affinity modeling on complex background brings noise for outputs. (2) Too many small objects exist on the iSAID dataset, which requires high resolution and high semantic representation. To solve the first problem, rather than dense affinity modeling, we can use a point sampler $\beta$ to select matched representative points $\hat{p}$ to balance the background context ratio while keeping efficiency. For the second problem, to fill the semantic gap on small objects, we adopt the FPN framework and change the inputs of $A$ by using adjacent features in a top-down manner shown in Equ.~\ref{equ:point_affinity}: \begin{equation} F^{r}(\hat{p}) = A(\beta(F_{l}(\hat{p})), \beta(F_{l-1}(\hat{p}))) \beta(F_{l}(\hat{p}))) \label{equ:point_affinity} \end{equation} where $F_{l}$ and $F_{l-1}$ are adjacent features in the FPN framework and $\hat{p}$ is sampled pixels for affinity modeling. We will detail the $\beta$ in the following part. As shown in Tab.\ref{tab:results_on_iSAID_datasets_dense_affinity_methods}, our method improves the baselines by a significant margin. \subsection{PointFlow Module} \noindent \textbf{Motivation and Overview} As the previous section shows the limitation of dense affinity on aerial image segmentation, we argue that unnecessary background pixels context may bring noises for foreground objects. Considering this, we propose to propagate context information through selective points, which can keep the efficiency in both speed and memory. Meanwhile, the semantic gap problems can also be fixed after propagation leading to high-resolution feature representation with high semantics, which is why we adopt FPN-framework design~\cite{fpn} in a top-down manner. Since our framework works in a top-down manner, and the semantics flow into low-level features through points, we name our module PointFlow. Our PointFlow is built on the FPN framework~\cite{fpn}, where the feature map of each level is compressed into the same channel depth through two 1$\times$1 convolution layers before entering the next level. Our module takes two adjacent feature maps as inputs $F_{l-1} \in \mathbb{R}^{C \times H \times W}$ and $F_{l} \in \mathbb{R}^{C\times H/2 \times W/2}$ as the inputs where $l$ means the index of feature pyramid and output refined $F_{l-1}^{r} \in \mathbb{R}^{C \times H \times W}$. For modeling $\beta$, we propose the Dual Point Matcher to select the points, and then the point-wise affinity can be calculated between adjacent points. Finally, the points with high-resolution and low semantics can be enhanced by the points with low-resolution high semantics according to the estimated affinity map. The process is shown in Fig.~\ref{fig:network}(a). \begin{figure*} \centering \includegraphics[width=1.0\linewidth]{fig/network.pdf} \caption{ (a), The overal pipeline of our proposed PointFlow Module. Left: Two adjacent features with one salient map are sent to the Dual Index Generator to obtain the sampled indexes. Right: The sampled point features are propagated from top to the bottom and finally scattered into the low level features point-wisely. (b), The detailed operation on proposed Dual Index Generator. (c), We design the PF Network Architecture by inserting PF modules into FPN-like framework. } \label{fig:network} \end{figure*} \noindent \textbf{Dual Point Matcher} The critical issue is how to find the corresponding points between two adjacent maps. We argue that most salient areas can be represented as key points for balanced pixel-level propagation due to the unbalanced pixels between the foreground and background. Meanwhile, since there are many small objects in aerial scenes that need more fine-grained location cues, the boundary areas can also be considered the key points. Thus we design a novel Dual Point Matcher to consider the most salient part of inputs and object boundaries at the same time. The Dual Point Matcher has two steps: (1) Generate the salient map. (2) Generate sampled indexes from Dual Index Generator. For the first step, we combine the input feature maps where the high-resolution part $F_{l-1}$ is downsampled into the same low resolution through bilinear interpolation. The resized feature is denoted as $\widetilde F_{l-1}$. Then we perform one $3 \times 3$ convolution following with sigmoid function to generate the saliency map $M_{l}$. The process is shown as follows: \begin{equation} M_{l} = Sigmoid(\text{conv}_l(\text{Concat}(F_{l}, \widetilde F_{l-1}))), \label{equ:salient_points_sample} \end{equation} For the second step, we take $F_{l}$ and $M_{l}$ as the inputs of the Dual Index Generator. We perform the adaptive max pooling on such map to obtain the most salient points. To highlight the salient part of foreground objects, we multiply such map on $F_{l}$ with residual design as attention map shown in Equ.~\ref{equ:salient_points_attention}: \begin{equation} F_{l}^{s} = MaxPool(M_{l}) \times F_{l} + F_{l}, \label{equ:salient_points_attention} \end{equation} We simply choose the salient indexes from $MaxPool(M_{l})$. $K$ is the number of pooled points, and it equals to the product of adaptive pooling kernels. We denote the salient indexes as $I(s)$ for short. For boundary point selection, rather than simply using the binary supervision on the input feature $F_{l}$ or $F_{l-1}$ for boundary prediction, we propose to adopt residual prediction on the $F_{l}$. Our method is motivated by Laplacian pyramids in image processing~\cite{adelson1984pyramid,burt1981fast_pyramid}. In Laplacian pyramids, the edge part of original images can be obtained by subtracting the smoothed upsampled images. Motivated by that, we use the average pooling on saliency map $M_{l}$ and multiply the pooled map on $F_{l}$ for smoothing inner content, then we subtract the such smoothed part from $F_{l}$ to generate the sharpened feature $\widetilde F_{l}^{b}$ for boundary prediction. The process is shown in Equ.~\ref{equ:boundary_point_matcher}: \begin{equation} \widetilde F_{l}^{b} = F_{l} - AvgPool(M_{l}) \times F_{l}, \label{equ:boundary_point_matcher} \end{equation} After the boundary prediction using $\widetilde F_{l}^{b}$, we obtain the boundary map $B_{l}$. Following the previous step, we simply sample Top-K points from the edge maps(K=128 by experiment) according to their confidence scores. We denote the boundary indices $I(b)$ for short. In total, the Dual Index Generator samples the key points in an orthogonal way by selecting points from specific regions according to the salient map $M_{l}$. The total process of Dual Index Generator is shown in Fig.~\ref{fig:network}(b). \noindent \textbf{Dual Region Propagation} After the point matcher, we obtain the indexes $I(s)$ and $I(b)$, respectively. Then we sample the points from map from salient feature $F_{l}^{s} $ and original input feature $F_{l-1}$. For each selected point, a point-wise feature representation is extracted on both adjacent input features. Note that features $f$ for a real-value point are computed by bilinear interpolation of 4 nearest neighbors that are on the regular grid. We use normalized girds during the implementation. We denote $f_{l}^{s}$ and $f_{l}^{b}$ as sampled feature point at stage $l$ for salient part and boundary part. We propagate those sampled points independently. For each sampled point $\hat{p}$, the top-down propagation process is shown in Equ~\ref{equ:pointflow_formulation}. \begin{equation} f_{l-1}(\hat{p})^{r} = \sum_{i\in{\{I(b),I(s)\}}} A(f_{l-1}^{i}(\hat{p}), f_{l}^{i}(\hat{p})) f_{l}^{i}(\hat{p}) + f_{l-1}^{i}(\hat{p}) , \label{equ:pointflow_formulation} \end{equation} where $A$ is affinity function, $i$ means the indexes whether from $I(s)$ or $I(b)$. For $A$, we use the point-wise matrix multiplication along with softmax function for normalization. Following the previous work~\cite{resnet}, we adopt the residual design for easier training. We calculate the sampled high semantic points through point-wise affinity according to the semantic similarity on sampled points with low semantics, which avoids the redundant background information in the aerial scene. Since we propagate semantics two times independently, we term two flows as {\it salient point flow} and {\it boundary point flow}, respectively. Finally, the refined feature $F_{l-1}^{r} $ is obtained by scattering the $f_{l-1}^{r}$ into $F_{l-1}$ according to the indices $I(s)$ and $I(b)$. \subsection{Network Architecture} \noindent \textbf{Overview} Fig.~\ref{fig:network} illustrates the our network architecture, which contains a bottom-up pathway as the encoder and a top-down pathway as the decoder. The encoder is backbone network with multiple feature pyramid outputs while the decoder is lightweight FPN equipped with our PFMs. \noindent \textbf{Network Architecture} The encoder uses the ImageNet pretrained backbone with OS 32 rather dilation stragety with OS 8 for efficient inference. We additionally adopt the Pyramid Pooling Module (PPM)~\cite{pspnet} for its superior efficiency and effectiveness to capture contextual information. In our setting, the output of PPM has the same resolution as that of the last stage. PFNet decoder takes feature maps from the encoder and uses the refined feature pyramid for final aerial segmentation according to previous work design~\cite{farSeg_iSAID,kirillov2019panoptic}. By simply replacing normal bilinear up-sampling with our PF module in top-down pathway of FPN, the PFNet decoder finally concatenates all the refined $F_{l}^{r}$(where $l$ ranges from 2 to 5) by upsampling the inputs to the same resolution(1/4 resolution of input) and perform prediction. Note that our module can also be integrated into other architectures including Deeplabv3~\cite{deeplabv3} with a slight modification by appending such decoder after its head. More details can be found in the experiment part. \noindent \textbf{Loss Function} For edge prediction in each PFM, we adopt binary BCE loss $L_{bce}$. For final segmentation prediction, we adopt the cross-entropy loss. The two losses are weighted to 1 by default. \section{Experiments} \noindent \textbf{Overview:} We will firstly perform ablation studies on iSAID dataset and give detailed analysis and comparison on PFM. Then we benchmark several recent works on Vaihingen and Potsdam datasets. Finally, we prove the generalizability of our module on general segmentation datasets. \subsection{Aerial Image Segmentation} \noindent \textbf{DataSets:} We use iSAID~\cite{iSAID} dataset for ablation studies and report results on remaining datasets. iSAID~\cite{iSAID} consists of 2,806 HSR images. The iSAID dataset provides 655,451 instances annotations over 15 categories of the object and it is the largest dataset for instance segmentation in the HSR remote sensing imagery. We also use Vaihingen and Postdam datasets\footnote{https://www2.isprs.org/commissions/comm2/wg4/benchmark/} for benchmarking. \noindent \textbf{Implementation detail and Metrics:} We adopt ResNet-50~\cite{resnet} by default. Following the same setting~\cite{farSeg_iSAID}, for all the experiments, these models are trained with 16 epoch on cropped images. For data augmentation, horizontal and vertical flip, rotation of 90 · k (k = 1, 2, 3) degree were adopted during training. For data preprocessing, we crop the image into a fixed size of (896, 896) using a sliding window striding 512 pixels. We use the mean intersection over union (mIoU) as the main metric for object segmentation to evaluate the proposed method if not specified. The baseline for ablation studies is Semantic-FPN~\cite{kirillov2019panoptic} with OS 32. \begin{table*}[t] \begin{minipage}[!t]{\linewidth} \centering \begin{minipage}{.38\linewidth} \subfloat[Effect of dual flow propagation on baseline.]{ \resizebox{1\textwidth}{!}{% \centering \begin{tabular}{ c c c l l } \toprule[0.15em] +PPM & +salient point flow & + boundary point flow & mIoU(\%) \\ \toprule[0.15em] - & - & - & 61.3 \\ \checkmark & - & - & 63.8 \\ \- & \checkmark & \checkmark & 65.0 \\ \checkmark &\checkmark & - & 64.8 \\ \checkmark & - & \checkmark & 66.2 \\ \checkmark &\checkmark &\checkmark & 66.9 \\ \hline \end{tabular}}}\hspace{3mm} \end{minipage} \hspace{2mm} \begin{minipage}{.32\linewidth} \subfloat[Effect of Insertion Position. $\hat{\mathbf{F}_l}$ means the position between $\mathbf{F}_l$ and $\mathbf{F}_l-1$. ]{ \resizebox{0.85\textwidth}{!}{% \centering \begin{tabular}{c c c c l} \toprule[0.15em] Method & $\hat{\mathbf{F}_3}$ & $\hat{\mathbf{F}_4}$ & $\hat{\mathbf{F}_5}$ & mIoU(\%) \\ \toprule[0.15em] Baseline+PPM & & & & 63.8 \\ & \checkmark & & & 65.8 \\ & & \checkmark & & 65.6 \\ & & & \checkmark & 65.5 \\ \midrule & &\checkmark &\checkmark & 66.5 \\ &\checkmark &\checkmark &\checkmark & 66.9 \\ \hline \end{tabular} }}\hspace{3mm} \end{minipage} \hspace{2mm} \begin{minipage}{.24\linewidth} \subfloat[Comparison with Other Propagation Methods.]{ \footnotesize \resizebox{0.95\textwidth}{!}{% \begin{tabular}{l|c} \toprule[0.15em] Settings & mIoU(\%) \\ \toprule[0.15em] baseline+PPM & 63.8 \\ \hline +DCNv1~\cite{deformable} & 65.2 \\ \hline +DCNv2~\cite{deformablev2} & 65.6 \\ \hline +desne affinity flow~\cite{non_local} & 62.0 \\ \hline +FAM~\cite{sfnet} & 65.7 \\ \hline + Ours & 66.9 \\ \hline \end{tabular}}} \end{minipage} \end{minipage} \vspace{3pt} \begin{minipage}[!t]{\linewidth} \centering \begin{minipage}{.24\linewidth} \subfloat[Effect of salient point sampling in Dual Index Generator. \label{expr:ablation_norm}]{ \footnotesize \resizebox{0.85\textwidth}{!}{% \begin{tabular}{l|c } \toprule[0.15em] Sampling Method & mIoU(\%) \\ \toprule[0.15em] baseline+PPM & 63.8 \\ uniform random & 64.0 \\ attention based & 64.2 \\ Our max pooling & 64.8 \\ \hline \end{tabular}}} \end{minipage} \begin{minipage}{.20\linewidth} \subfloat[Effect of propagation direction.]{ \footnotesize \resizebox{0.85\textwidth}{!}{% \begin{tabular}{l|c} \toprule[0.15em] Settings & mIoU(\%) \\ \toprule[0.15em] baseline + PPM & 63.8 \\ \hline top-down(td) & 66.9 \\ \hline bottom-up(bu) & 47.3 \\ \hline td then bu & 54.5 \\ \hline \end{tabular}}} \end{minipage} \begin{minipage}{.20\linewidth} \subfloat[Effect of edge generation module in Dual Index Generator.]{ \footnotesize \resizebox{0.95\textwidth}{!}{% \begin{tabular}{l|c } \toprule[0.15em] Settings & mIoU(\%) \\ \toprule[0.15em] baseline+PPM & 63.8 \\ \hline direct prediction & 65.7 \\ \hline addition prediction & 65.5 \\ \hline Our subtraction based & 66.2 \\ \hline \end{tabular}}} \end{minipage} \begin{minipage}{.32\linewidth} \subfloat[Application on Other Architectures. \label{expr:ablation_placement}]{ \footnotesize \resizebox{0.85\textwidth}{!}{% \begin{tabular}{l|c c c} \toprule[0.20em] Network & Backbone & mIoU(\%) & GFlops \\ \toprule[0.20em] Deeplabv3~\cite{deeplabv3} & ResNet50 & 60.4 & 168.4 \\ Deeplabv3~\cite{deeplabv3} & ResNet101 & 61.5 & 264.1 \\ \hline +FPN & ResNet50 & 62.3 & 183.4 \\ +PF decoder & ResNet50 & 65.6 & 185.2 \\ \hline CCNet~\cite{ccnet} & ResNet50 & 58.3 & 206.5 \\ \hline +FPN & ResNet50& 60.2 & 220.8 \\ +PF decoder & ResNet50 & 65.3 & 223.2 \\ \hline \end{tabular}}} \end{minipage} \end{minipage} \caption{\textbf{Ablation studies.} We first verify the effect of each module and comparison results in the first row. Then we verify several design choices and generality of our module in the second row.}\label{tab:ablations} \end{table*} \noindent \textbf{Effectiveness on baseline models:} In Tab.~\ref{tab:ablations}(a), adopting our PFMs leads to better results than appending PPM~\cite{pspnet} shown in both 2nd and 3rd rows with about 1.2 \% gap. After applying both PPM and PFM, there is a significant gain over the baseline models shown in the last row. Only applying boundary flow is slightly better than applying salient point flow which indicates the small object problems are more severe than foreground-background imbalance problems in this dataset. In Tab.~\ref{tab:ablations} (b), we explore the effect on insertion position with our PFMs. From the first three rows, PF improves all stages and gets the greatest improvement at the first stage, which shows that the semantic gap is more severe for small objects in lower layers. After appending all FPMs, we achieve the best result shown in the last row. \noindent \textbf{Comparison with feature fusion methods:} Tab.~\ref{tab:ablations}(c) give several feature fusion methods~\cite{deformable, sfnet, feature_pyramid_transformer} used on scene understanding tasks. For all the methods, we replace these modules into the same position on PFnet decoder as in Fig~\ref{fig:network}(c) for fair comparison. Compared with DCN-like methods~\cite{deformable,deformablev2,sfnet}, our method leads to significant gain over them since our method can better handle the foreground semantics propagation. \noindent \textbf{Ablation on design choices:} We give more detailed design studies in the second row of Tab.~\ref{tab:ablations}. Tab.~\ref{tab:ablations}(d) explores several sampling methods for salient points sampling. Attention based method is directly selecting top-K(K=128) points from $M_{l}$ while uniform random sample is done by randomly selecting one pixels from $7\times7$ neighbor region of $M_{l}$(We report average result of 10 times experiments). Our max pooling based methods work the best among them. Tab.~\ref{tab:ablations}(e) shows the propagation direction of PFM. Adding bottom up fusing leads to bad results mainly because more background context is introduced into the head which verifies our motivation of flowing semantics into the bottom. Tab.~\ref{tab:ablations} (f) shows the effect results on edge prediction. Our subtraction based prediction has better results mainly due to better boundary prediction. This is also verified in Tab.~\ref{tab:results_semantic_boundaries}. \begin{figure} \centering \includegraphics[width=\linewidth]{fig/max_pool.pdf} \caption{ \small Ablation studies on the number of sampled point for both point flows. Best view it in color and zoom in. } \label{fig:sampled_points} \end{figure} \noindent \textbf{Ablation on Number of Sampled Points:} We first verify the best number of sampled points on boundary point flow in Fig.~\ref{fig:sampled_points}(a) by increasing the number of sampled pixels where we find the best number is 128. Sampling more points leads to inferior results which indicates missing background context is also important. Appending the boundary flow as the strong baseline, we explore the kernel size of salient point flow where we find the best kernel size 14 $\times$ 14 (256 points in total) in Fig.~\ref{fig:sampled_points}(b). After selecting more points (24$\times$24, 576 points in total), the performance drops a lot since the imbalance problems exist. This verifies the same conclusion that the dense affinity leads to bad results. \noindent \textbf{Application on Various Methods:} Our PFM can be easily adopted into several existing networks by extending PFNet decoder (shown in Fig.~\ref{fig:network}(c) yellow box) after their heads. More details can be referred to supplementary. In Tab.~\ref{tab:ablations}(g), we verify two work including Deeplabv3\cite{deeplabv3} and CCNet~\cite{ccnet} where we obtain significant gains over these baselines. This proves the generalization of our methods. Our method outperforms ResNet101-based models which indicates the improvement is not obtained by extra parameters introduced by PFM. \begin{table}[!t]\setlength{\tabcolsep}{6pt} \centering \begin{threeparttable} \scalebox{0.75}{ \begin{tabular}{l c c c c c c } \toprule[0.15em] Method & mIoU & F1(12px) & F(9px) & F1(5px) & F1(3px) \\ \toprule[0.15em] baseline+PPM & 63.8 & 88.2 & 86.2 & 85.6 & 84.3 \\ +salient point flow: & 64.8 & 88.9 & 88.1 & 87.0 & 85.4 \\ +boundary point flow & 66.2 & 93.2 & 91.2 & 89.0 & 88.4 \\ +both & 66.9 & 94.2 & 93.2 & 90.2 & 89.0 \\ \hline direct prediction & 65.7 & 89.6 & 87.5 & 86.4 & 85.8 \\ subtraction prediction & 66.2 & 93.2 & 91.2 & 89.0 & 88.4 \\ \bottomrule[0.1em] \end{tabular}} \caption{Ablation study on semantic boundaries where we adopt 4 different thresholds for evaluation. } \label{tab:results_semantic_boundaries} \end{threeparttable} \end{table} \noindent \textbf{Effectiveness on Segmentation Boundaries:} We further verify the boundary improvements using F1-score metric~\cite{VOS_benchmark} with different pixel thresholds in Tab.~\ref{tab:results_semantic_boundaries}. Appending boundary point flow leads to more significant improvements than salient point flow due to the explicit supervision and propagation on boundary pixels. Adopting both flows leads to the best results and it indicates the complemented property of our approach. Moreover, as shown in the last row of Tab.~\ref{tab:results_semantic_boundaries}, our subtraction based edge prediction results better than direct prediction where it has better mask boundary. We include boundary prediction results in supplementary. \begin{figure} \centering \includegraphics[width=0.95\linewidth]{fig/sampled_points.pdf} \caption{ \small Visualization of sampled points for both point flows. Top: Salient Flow points. Bottom: Boundary Flow points. Best view it on screen. } \label{fig:vis_sampled_points} \end{figure} \noindent \textbf{Balanced foreground-background Points:} We analyze the ratio of sampled points on fore-ground parts over total sampled points by adding all three PFMs using validation images. Compared with baseline unbalanced points with 2.89\% computed by ground truth mask, our method improves the ratio on foreground to 7.83\% during the inference which resolves the problems of imbalanced points aggregation. We use the best model found in ablation part. \noindent \textbf{Visualization of Sampled Points:} In Fig.~\ref{fig:vis_sampled_points}, we show several visual examples on sampled points on the original images. The first row gives the salient point results while the second row shows the boundary point results. We visualize the points from the PFM in the last stage. As shown in Fig.~\ref{fig:vis_sampled_points}, the salient points uniformly locate around the foreground objects and several of them are on the background sparsely. The boundary points are mainly on the boundary of large foreground objects and the inner regions on small objects because the downsampled feature representation makes it hard to predict small object boundaries. More visual examples can be found in supplementary. \noindent \textbf{Benchmarking recent works on aerial images datasets:} Recent work FarSeg~\cite{farSeg_iSAID} reports results of several segmentation methods~\cite{pspnet,kirillov2019panoptic,deeplabv3} on iSAID datasets. We extend more representative work~\cite{ccnet,DAnet,EMAnet,kirillov2019pointrend} on iSAID, Vaihingen and Postdam datasets under the same experiment setting. Note that, for all methods, we use ResNet50 as backbone for fair comparison except for HRNet~\cite{HRNet}. The work~\cite{relation_aerial} also reports results on Vaihingen and Postdam using weak VGG-backbone~\cite{vgg}. Due to the lack of comparison with recent work, we re-implement this method using ResNet50 backbone and trained on larger cropped images and report mIoU as metric.\footnote{We will opensource all the models and code for further research.} All the methods use the single scale inference on cropped images for testing. \begin{table}[!t]\setlength{\tabcolsep}{6pt} \centering \begin{threeparttable} \scalebox{0.60}{ \begin{tabular}{l c c c } \toprule[0.15em] Method & Backbone & mIoU & OS \\ \toprule[0.15em] DenseASPP~\cite{denseaspp} & RenNet50 & 57.3 & 8 \\ Deeplabv3~\cite{deeplabv3} & ResNet50 & 60.4 & 8\\ Deeplabv3+ ~\cite{deeplabv3p} & ResNet50 & 61.2 & 8\\ RefineNet ~\cite{refinenet} & ResNet50 & 60.2 & 32 \\ PSPNet~\cite{pspnet} & ResNet50 & 60.3 & 8\\ OCNet-(ASP-OC)~\cite{ocnet} & ResNet50 & 40.2 & 8 \\ EMANet~\cite{EMAnet} & ResNet50 & 55.4 & 8\\ CCNet~\cite{ccnet} & ResNet50 & 58.3 & 8\\ EncodingNet~\cite{context_encoding} & ResNet50 & 58.9 & 8 \\ SemanticFPN~\cite{kirillov2019panoptic} & ResNet50 & 62.1 & 32 \\ UPerNet~\cite{kirillov2019panoptic} & ResNet50 & 63.8 & 32 \\ HRNet\cite{upernet} & HRNetW18 & 61.5 & 4 \\ SFNet\cite{sfnet} & ResNet50 & 64.3 & 32 \\ GSCNN\cite{gated-scnn} & ResNe50 & 63.4 & 8 \\ RANet\cite{relation_aerial} & ResNet50 & 62.1 & 8 \\ FarSeg~\cite{farSeg_iSAID} & ResNet50 & 63.7 & 32\\ \hline PFNet & ResNet50 & \bf{66.9} & 32 \\ \bottomrule[0.1em] \end{tabular}} \caption{\small Comparison with the state-of-the-art results on iSAID dataset. } \label{tab:results_on_iSAID_datasets} \end{threeparttable} \end{table} \noindent \textbf{Comparison with the state-of-the-arts on iSAID:} We first benchmark more results on iSAID dataset in Tab.~\ref{tab:results_on_iSAID_datasets} and then compare our PFNet with previous work. Our PFNet achieves the state-of-the-art result among all previous work by a large margin. Our method outperforms previous state-of-the-art FarSeg~\cite{farSeg_iSAID} by 3.2\%. \noindent \textbf{Experiments on Vaihingen and Potsdam:} Rather than the previous work~\cite{relation_aerial} cropping the images into small patches, we adopt large patches as the iSAID dataset and use more validation images for testing. That makes the segmentation more challenging. The details of train and validation splitting can be found in the supplementary. For the Vaihingen dataset, we preprocess the images by cropping into 768$\times$ 768 patches. We adopt the same training setting with iSAID dataset except for 200 epochs and larger learning rate with 0.01. For the experiments on the Potsdam dataset, the images are cropped into 896$\times$896 patches. The total training epoch is set to 80 with the initial learning rate of 0.01. As shown in Tab.~\ref{tab:results_on_aerial_datasets}, we benchmark recent segmentation methods with two metrics including mIoU and mean-$F_1$. Our PFNet achieves state-of-the-art results on two benchmarks. \begin{figure*} \centering \includegraphics[width=0.90\linewidth]{fig/speed_miou.pdf} \caption{ \small Speed (Inference Time) versus Accuracy (mIoU) on three aerial segmentation datasets. The radius of circles represents the number of parameters. All the methods are tested with one V-100 GPU card for fair comparison. Our PFNet achieves the best speed and accuracy trade-off on three benchmark. Real time is within 50ms. Best view it on screen and Zoom in. } \label{fig:speed_acc} \end{figure*} \begin{figure*} \centering \includegraphics[width=0.90\linewidth]{fig/pointflow_results.pdf} \caption{\small Visual results on iSAID validation set. Compared with previous works, our method obtains better segmentation results. Best view on the screen. More visual results can be found in supplementary. } \label{fig:vis_res_on_iSAID} \end{figure*} \noindent \textbf{Efficiency Comparison:} In Fig.~\ref{fig:speed_acc}, we further benchmark the speed and parameters of our methods on above datasets. Compared with previous work, PFNet achieves the best speed and accuracy trade-off on those three benchmarks with fewer parameters without bells and whistles. Note that PFNet can also run in real-time setting and also achieves a significant margin compared with previous real-time methods\cite{kirillov2019panoptic,sfnet,farSeg_iSAID}. \noindent \textbf{Visual Results Comparison:} In Fig.~\ref{fig:vis_res_on_iSAID}, we compare our method results with several state-of-the-art methods~\cite{deeplabv3p,kirillov2019pointrend,kirillov2019panoptic} on the iSAID validation set. Our PFNet has better segmentation results on handling false positives of small objects and has fine-grain object mask boundaries. \begin{table}[!t]\setlength{\tabcolsep}{6pt} \centering \begin{threeparttable} \scalebox{0.60}{ \begin{tabular}{l | c c | c c} \toprule[0.15em] Method & mIoU & mean-$F_1$ & mIoU & mean-$F_1$ \\ \toprule[0.15em] PSPNet~\cite{pspnet} & 65.1 & 76.8 & 73.9 & 83.9\\ FCN~\cite{fcn} & 64.2 & 75.9 & 73.1 & 83.1 \\ OCnet(ASP-OC)~\cite{ocnet} & 65.7 & 77.4 &74.2 &84.1 \\ Deeplabv3+~\cite{deeplabv3p} & 64.3 & 76.0 & 74.1 & 83.9 \\ DAnet~\cite{DAnet} & 65.3 & 77.1 & 74.0 & 83.9\\ CCnet\cite{ccnet} & 64.3 & 75.9 & 73.8 & 83.8 \\ SemanticFPN~\cite{kirillov2019panoptic} & 66.3 & 77.6 & 74.3 & 84.0\\ UPerNet~\cite{upernet} & 66.9 & 78.7 & 74.3 & 84.0 \\ PointRend~\cite{kirillov2019pointrend} & 65.9 & 78.1 & 72.0 & 82.7 \\ HRNet-W18~\cite{HRNet} & 66.9 & 78.2 & 73.4 & 83.4 \\ GSCNN~\cite{gated-scnn} & 67.7 & 79.5 & 73.4 & 84.1 \\ SFNet~\cite{sfnet} & 67.6 & 78.6 & 74.3 & 84.0\\ EMANet~\cite{EMAnet} & 65.6 & 77.7 &72.9 & 83.1\\ RANet~\cite{relation_aerial} & 66.1 &78.2 & 73.8 & 83.9 \\ EncodingNet~\cite{context_encoding} & 65.5 & 77.4 & 73.4 & 83.5\\ Denseaspp~\cite{denseaspp} & 64.7 & 76.4 & 73.9 & 83.9\\ \hline PFNet & \bf{70.4} & \bf{81.9} & \bf{75.4} & \bf{84.8} \\ \bottomrule[0.1em] \end{tabular}} \caption{\small Comparison with the state-of-the-art results on Vahihigen(left) and Potsdam(right) datasets. } \label{tab:results_on_aerial_datasets} \end{threeparttable} \end{table} \subsection{Results on general segmentation benchmarks:} \noindent We further verify our approach on general segmentation benchmarks including Cityscapes~\cite{Cityscapes}, ADE-20k~\cite{ADE20K} and BDD~\cite{yu2020bdd100k} for only verification purpose. We only report the results due to the limited space. More implementation details and visual results can be found in the supplementary file. We train both our baseline model and PFnet model on train datasets and report results on validation datasets under the same setting. \begin{table}[!t]\setlength{\tabcolsep}{6pt} \centering \begin{threeparttable} \scalebox{0.65}{ \begin{tabular}{l c c c c c} \toprule[0.15em] Method & Cityscapes & ADE20k & BDD & Param(M) & GFlops(G) \\ \toprule[0.15em] PSPNet~\cite{pspnet} & 78.0 & 41.3 & 61.3 & 31.1 & 120.4 \\ OCNet~\cite{ocnet} & 79.2 & 41.8 & 62.1 & 64.7 & 290.4 \\ Deeplabv3+~\cite{deeplabv3p} & 79.4 & 42.0 & 61.0 & 40.5 & 189.8 \\ \hline baseline +PPM & 78.8 & 40.9 & 61.1 & 32.9 & 83.1 \\ Our PFnet & 80.3 & 42.4 & 62.7 & 33.0 & 85.8 \\ \bottomrule[0.1em] \end{tabular}} \caption{\small Experiment results on general datasets including Cityscapes, ADE20k, BDD validation datasets. All the methods are trained under the same training setting and the results are reported with single scale inputs. The GFlops is calculated with $512 \times 512 $ as input. All the methods use the ResNet50 backbone.} \label{tab:results_on_general_datasets} \end{threeparttable} \end{table} \noindent \textbf{Comparison with the Baseline Methods:} As shown in the last two rows of Tab.~\ref{tab:results_on_general_datasets}, our method improves the baseline model on various datasets about 1\% mIoU with fewer parameters and GFlops increase. Compared with the previous work~\cite{pspnet,ocnet,deeplabv3p}, our method achieves better results with much less computation cost. \section{Conclusion} In this paper, we propose PointFlow Module to solve both imbalanced foreground-background objects and semantic gaps between feature pyramids problems for aerial image segmentation. We design a novel Dual Point Matcher to sampled the matched points from salient areas and boundaries accordingly. Extensive experiments have shown that our PF module can improve various baselines significantly on aerial benchmark. Based on the FPN framework, we build an efficient PFNet which achieves the best speed and accuracy trade-off on three public aerial benchmarks. Further experiments on three general segmentation datasets also prove the generality of our method. \section{Supplementary} \noindent \textbf{Overview:} In this supplementary, we will present more experiments details on Aerial datasets in the first section. Then we will provide detailed descriptions and visualization results on general semantic segmentation datasets. \subsection{Experiments on Aerial Datasets} In this section, we give supplementary aerial dataset experiments for the main paper due to the space limitation. \noindent \textbf{Application on Various Methods:} For Deeplabv3~\cite{deeplabv3}, we append our PFNet decoder after the ASPP output which makes the total network as an encoder-decorder framework like U-net~\cite{unet}. For CCnet~\cite{ccnet}, we follow the same pipeline of Deeplabv3 by replacing ASPP head with CC-head. The GFlops in the table are calculated with $512 \times 512 $ image inputs. \noindent \textbf{Effectiveness on Segmentation Boundaries:} We present the our subtraction based boundary prediction in Fig.~\ref{fig:iSAID_boundary_vis_sup}. As shown in the figure, our subtraction based prediction leads to thinner and sharpen prediction in the first row and second row of Fig.~\ref{fig:iSAID_boundary_vis_sup} and avoids the inner part noise shown in the third row of Fig.~\ref{fig:iSAID_boundary_vis_sup}. \noindent \textbf{Effect of Context Head:} We also verify the effectiveness of context head by replacing PPM~\cite{pspnet} into ASPP~\cite{deeplabv3} where we obtain 66.0 mIoU (0.9 mIoU drop compared with PPM head). Due to the efficiency of PPM, we choose it as our final context head. \noindent \textbf{Foreground Points Ratio of Propagation:} We count the sampled points from the three different PFMs by finding the \textbf{intersection} of all matched points from Dual Point Matcher in each PFM. We match all the indexes into the high resolution map during the calculation. Thus the propagated points with no-overlap are considered. \noindent \textbf{More Visualization on iSAID dataset:} Fig.\ref{fig:iSAID_vis_sup} provides more visualization results on iSAID datasets. Compared with previous work, our method has better segmentation results and less false positives in the scene. Fig.~\ref{fig:iSAID_points_vis_sup} shows more matched points visualization on full cropped images. \noindent \textbf{Detailed Results:} Tab.~\ref{tab:results_iSAID_dataset} reports the per-class results on iSAID datasets. From that table, our PFNet achieves best results on 14 classes (total 15 classes). Tab.~\ref{tab:results_Postdam_dataset} and Tab.~\ref{tab:results_Vaihingen_dataset} report per-class results on Postdam and Vaihingen dataset receptively. Our PFNet also achieves top performance. \noindent \textbf{Dataset Split on Potsdam and Vaihingen:} We provide the detailed dataset split as following: \noindent The Potsdam dataset consists of 38 high resolution aerial images. To train and evaluate networks, we utilize 24 images for training and 14 images for testing. For training set, the image IDs are 2\_10, 2\_11, 2\_12, 3\_10, 3\_11, 3\_12, 4\_10, 4\_11, 4\_12, 5\_10, 5\_11, 5\_12, 6\_7, 6\_8, 6\_9, 6\_10, 6\_11, 6\_12, 7\_7, 7\_8, 7\_9, 7\_10, 7\_11, 7\_12. For test set, the image IDs are 2\_13, 2\_14, 3\_13, 3\_14, 4\_13, 4\_14, 4\_15, 5\_13, 5\_14, 5\_15, 6\_13, 6\_14, 6\_15, 7\_13. \noindent The Vaihingen dataset has 33 high resolution aerial images. We selects 16 images for trainand and another 17 images as the testset to evaluate the models. The image IDs for training set are 1, 3, 5, 7, 11, 13, 15, 17, 21, 23, 26, 28, 30, 32, 34, 37 and image IDs for test set are 2, 4, 6, 8, 10, 12, 14, 16, 20, 22, 24, 27, 29, 31, 33, 35, 38. \noindent \textbf{Speed test details:} We test our models on single V100 GPU by averaging inference time with 100 image. The Pytorch version is 1.5 with CUDA-10.1. \begin{figure*}[!h] \centering \includegraphics[width=1.0\linewidth]{fig/more_vis_results_pfnet.pdf} \caption{\small Visualization results on iSAID validation dataset. Best view it on screen.} \label{fig:iSAID_vis_sup} \end{figure*} \begin{figure*}[!h] \centering \includegraphics[width=0.80\linewidth]{fig/boundaries_pfnets.pdf} \caption{\small Visualization boundary results on iSAID validation dataset. Best view it on screen.} \label{fig:iSAID_boundary_vis_sup} \end{figure*} \begin{figure*}[!h] \centering \includegraphics[width=0.80\linewidth]{fig/sampled_point_vis_sup.pdf} \caption{\small Visualization sampled points on iSAID validation dataset. Best view it on screen.} \label{fig:iSAID_points_vis_sup} \end{figure*} \begin{table*}\setlength{\tabcolsep}{4pt} \centering \begin{threeparttable} \scalebox{0.75}{ \begin{tabular}{l | c | c | c c c c c c c c c c c c c c c} \toprule[0.15em] \multirow{2}{*}{Method} & \multirow{2}{*}{backbone} & \multirow{2}{*}{mIoU(\%)} & \multicolumn{14}{c}{IoU per category(\%)} & \\ \cline{4-18} \multirow{1}{*}{ } & \multirow{1}{*}{ } & \multirow{1}{*}{ } & Ship & ST & BD &TC &BC &GTF &Bridge & LV &SV &HC &SP & RA &SBF &Plane &Harbor \\ \hline DenseASPP~\cite{denseaspp} & RenNet50 & 57.3 & 55.7 & 63.5 & 67.2 & 81.7 & 54.8 & 52.6 & 34.7 & 55.6 & 36.3 & 33.4 & 37.5 & 53.4 & 73.3 & 74.7 & 46.7 \\ RefineNet ~\cite{refinenet} & ResNet50 & 60.2 & 63.8 & 58.6 & 72.3 & 85.3 & 61.1 & 52.8 & 32.6 & 58.2 & 42.4 & 23.0 & 43.4 & 65.6 & 74.4 & 79.9 & 51.1 \\ PSPNet~\cite{pspnet} & ResNet50 & 60.3 & 65.2 & 52.1 & 75.7 & 85.6 & 61.1 & 60.2 & 32.5 & 58.0 & 43.0 & 10.9 & 46.8 & 68.6 & 71.9 & 79.5 & 54.3\\ OCNet-(ASP-OC)~\cite{ocnet} & ResNet50 & 40.2 & 47.3 & 40.2 & 44.4 & 65.0 & 24.1 & 29.9 & 2.71 & 46.3 & 13.6 & 10.3 & 34.6 & 37.9 & 41.4 & 68.1 & 38.0 \\ EMANet~\cite{EMAnet} & ResNet50 & 55.4 & 63.1 & 68.4 & 66.2 & 82.7 & 56.0 & 18.8 & 42.1 & 58.2 & 41.0 & 33.4 & 38.9 & 46.9 & 46.4 & 78.5 & 47.5 \\ CCNet~\cite{ccnet} & ResNet50 & 58.3 & 61.4 & 65.7 & 68.9 & 82.9 & 57.1 & 56.8 & 34.0 & 57.6 & 38.3 & 31.6 & 36.5 & 57.2 & 75.0 & 75.8 & 45.9\\ EncodingNet~\cite{context_encoding} & ResNet50 & 58.9 & 59.7 & 64.9 & 70.0 & 84.2 & 55.2 & 46.3 & 36.8 & 57.2 & 38.7 & 34.8 & 42.4 & 59.8& 69.8 & 76.1 & 48.0 \\ SemanticFPN~\cite{kirillov2019panoptic} & ResNet50 & 62.1 & 68.9 & 62.0 & 72.1 & 85.4 & 54.1 & 48.9 & 44.9 & 61.0 & 48.6 & 37.4 & 42.8 & 70.2 & 58.6 & 84.7 & 54.9 \\ UPerNet~\cite{kirillov2019panoptic} & ResNet50 & 63.8 & 68.7 & 71.0 & 73.1 & 85.5 & 55.3 & 57.3 & 43.0 & 61.3 & 45.6 & 30.3 & 45.7 & 68.7 & 75.1 & 84.3 & 56.2 \\ HRNet\cite{upernet} & HRNetW18 & 61.5 & 65.9 & 68.9 & 74.0 & 86.9 & 59.4 & 61.5 & 33.8 & 62.1 & 46.9 & 14.9 & 44.2 & 52.9 & 75.6 & 81.7 & 52.2 \\ SFNet\cite{sfnet} & ResNet50 & 64.3 & 68.8 & 71.3 & 72.1 & 85.6& 58.8 & 60.9 & 43.1 & 62.9 & 47.7 & 30.4 & 47.8 & 69.8 & 75.1 & 83.1 & 57.3 \\ GSCNN\cite{gated-scnn} & ResNe50 & 63.4 & 65.9 & 71.2 & 72.6 & 85.5 & 56.1 & 58.4 & 40.7 & 63.8 & 51.1 & 33.8 & 48.8 & 58.5 & 72.5 & 83.6 & 54.4 \\ RANet\cite{relation_aerial} & ResNet50 & 62.1 & 67.1 & 61.3 & 72.5 & 85.1 & 53.2 & 47.1 & 45.3 & 60.1 & 49.3 & 38.1 & 41.8 & 70.5 & 58.8 & 83.1 & 55.6 \\ FarSeg~\cite{farSeg_iSAID} & ResNet50 & 63.7 & 65.4 & 61.8 & 77.7 & 86.4 & 62.1 & 56.7 & 36.7 & 60.6 & 46.3 & 35.8 & \bf{51.2} & 71.4 & 72.5 & 82.0 & 53.9 \\ \hline PFNet & ResNet50 & \bf{66.9} & \bf{70.3} & \bf{74.7} & \bf{77.8} & \bf{87.7} & \bf{62.2} & \bf{59.5} & \bf{45.2} & \bf{64.6} & \bf{50.2} & \bf{37.9} & 50.1 & \bf{71.7} & \bf{75.4} & \bf{85.0} & \bf{59.3} \\ \bottomrule[0.1em] \end{tabular}} \caption{Experimental results on iSAID $val$ set. The bold values in each column mean the best entries. The category are defined as: ship (Ship), storage tank (ST), baseball court (BC), ground field track (GTF), bridge (Bridge), large vehicle (LV), small vehicle (SV), helicopter (HC), swimming pool (SP), roundabout (RA), soccerball field (SBF), plane (Plane), harbor (Harbor). All the models are trained under the same setting following the FarSeg~\cite{farSeg_iSAID}.} \label{tab:results_iSAID_dataset} \end{threeparttable} \end{table*} \begin{table*}\setlength{\tabcolsep}{6pt} \centering \begin{threeparttable} \scalebox{0.9}{ \begin{tabular}{l | c | c | c c c c c c} \toprule[0.15em] \multirow{2}{*}{Method} & \multirow{2}{*}{mIoU(\%)} & \multirow{2}{*}{mean-$F_1$} & \multicolumn{5}{c}{$F_1$ per category} & \\ \cline{4-9} \multirow{1}{*}{ } & \multirow{1}{*}{ } & \multirow{1}{*}{ } & Imp.surf. & Build. & Low veg. &Tree & Car & Cluster \\ \hline PSPNet~\cite{pspnet} & 65.1 & 76.8 & 88.4 & 92.8 & 79.2 & 85.9 & 73.5 & 41.0 \\ FCN~\cite{fcn} & 64.2 & 75.9 & 87.6 & 91.6 & 77.8 & 84.6 & 73.5 & 40.3 \\ OCNet(ASP-OC)~\cite{ocnet} & 65.7 & 77.4 & 88.8 & 92.9 & 79.2 & 85.8 & 73.9 & 43.8 \\ Deeplabv3+~\cite{deeplabv3p} & 64.3 & 76.0 & 88.7 & 92.8 & 78.9 & 85.6 & 72.4 & 37.6 \\ DANet~\cite{DAnet} & 65.3 & 77.1 & 88.5 & 92.7 & 78.8 & 85.7 & 73.7 & 43.2 \\ CCNet~\cite{ccnet} & 64.3 & 75.9 & 88.3 & 92.5 & 78.8 & 85.7 & 73.9 & 36.3 \\ SemanticFPN~\cite{kirillov2019panoptic} & 66.3 & 77.6 & 89.6 & 93.6 & 79.7 & \bf{86.3} & 75.7 & 40.7\\ UPerNet~\cite{upernet} & 66.9 & 78.7 & 89.2 & 93.0 & 79.4 & 86.0 & 74.9 & 49.7 \\ PointRend~\cite{kirillov2019pointrend} & 65.9 & 78.1 & 88.2 & 92.4 & 78.9 & 84.5 & 73.5 & 51.1 \\ HRNet-W18~\cite{HRNet} & 66.9 & 78.2 & 89.2 & 92.6 & 78.7 & 85.7 & 77.1 & 45.9 \\ GSCNN~\cite{gated-scnn} & 67.7 & 79.5 & 89.4 & 92.6 & 78.8 & 85.4 & 77.9 & 52.9 \\ SFNet~\cite{sfnet} & 67.6 & 78.6 & 90.0 & \bf{94.0} & \bf{80.3} & 86.5 & 78.9 & 41.9\\ EMANet~\cite{EMAnet} & 65.6 & 77.7 & 88.2 & 92.7 & 78.0 & 85.7 & 72.7 & 48.9\\ RANet~\cite{relation_aerial} & 66.1 & 78.2 & 88.0 & 92.3 & 79.1 & 86.0 & 78.8 & 53.1 \\ EncodingNet~\cite{context_encoding} & 65.5 & 77.4 & 88.6 & 92.5 & 78.5 & 85.7 & 73.6 & 45.5\\ Denseaspp~\cite{denseaspp} & 64.7 & 76.4 & 87.3 & 91.1 & 76.2 & 83.4 & 77.1 & 43.3 \\ \hline PFNet & \bf{70.4} & \bf{81.9} & \bf{90.1} & 93.6 & 77.7 & 85.4 & \bf{80.0} & \bf{64.6} \\ \bottomrule[0.1em] \end{tabular}} \caption{Experimental results on the Vaihingen Dataset. The results are reported with single scale input. The bold values in each column mean the best entries. The category are defined as: impervious surfaces (Imp.surf.), buildings (Build), low vegetation (Low veg), trees (Tree), cars (Car), cluster/background (Cluster).} \label{tab:results_Vaihingen_dataset} \end{threeparttable} \end{table*} \begin{table*}\setlength{\tabcolsep}{6pt} \centering \begin{threeparttable} \scalebox{0.9}{ \begin{tabular}{l | c | c | c c c c c c} \toprule[0.15em] \multirow{2}{*}{Method} & \multirow{2}{*}{mIoU(\%)} & \multirow{2}{*}{mean-$F_1$} & \multicolumn{5}{c}{$F_1$ per category} & \\ \cline{4-9} \multirow{1}{*}{ } & \multirow{1}{*}{ } & \multirow{1}{*}{ } & Imp.surf. & Build. & Low veg. &Tree & Car & Cluster \\ \hline PSPNet~\cite{pspnet} & 73.9 & 83.9 & 90.8 & 95.4 & 84.5 & 86.1 & 88.6 & 58.0 \\ FCN~\cite{fcn} & 73.1 & 83.1 & 90.2 & 94.7 & 84.1 & 85.6 & 89.2 & 54.8 \\ OCnet(ASP-OC)~\cite{ocnet} & 74.2 & 84.1 & 90.9 & 95.5 & 84.8 & 86.0 & 89.2 & 58.2 \\ Deeplabv3+~\cite{deeplabv3p} & 74.1 & 83.9 & 91.0 & 95.6 & 84.6 & 86.0 & 90.0 & 56.2 \\ DAnet~\cite{DAnet} & 74.0 & 83.9 & 91.0 & 95.6 & 84.9 & 86.2 & 88.7 & 57.0 \\ CCnet\cite{ccnet} & 73.8 & 83.8 & 90.7 & 95.5 & 84.7 & 86.0 & 88.5 & 57.3 \\ SemanticFPN~\cite{kirillov2019panoptic} & 74.3 & 84.0 & 91.0 & 95.5 & 84.9 & 85.9 & 90.4 & 56.3 \\ UPerNet~\cite{upernet} & 74.3 & 84.0 & 90.9 & 95.7 & 85.0 & 86.0 & 90.2 & 56.2 \\ PointRend~\cite{kirillov2019pointrend} & 72.0 & 82.7 & 89.8 & 94.6 & 82.8 & 85.2 & 85.2 & 58.6 \\ HRNet-W18~\cite{HRNet} & 73.4 & 83.4 & 90.4 & 94.9 & 84.2 & 85.4 & 90.0 & 55.5 \\ GSCNN~\cite{gated-scnn} & 73.4 & 84.1 & 91.4 & 95.5 & 84.8 & 85.8 & \bf{91.2} & 55.9 \\ SFNet~\cite{sfnet} & 74.3 & 84.0 & 91.0 & 95.5 & 85.1 & 86.0 & 90.9 & 55.5 \\ EMANet~\cite{EMAnet} & 72.9 & 83.1 & 90.4 & 94.9 & 84.2 & 85.7 & 88.3 & 55.1 \\ RANet~\cite{relation_aerial} & 73.8 & 83.9 & 90.8 & 92.1 & 84.3 & 86.8 & 88.9 & 56.0 \\ EncodingNet~\cite{context_encoding} & 73.4 & 83.5 & 90.6 & 95.1 & 84.5 & 86.0 & 88.2 & 56.6 \\ Denseaspp~\cite{denseaspp} & 73.9 & 83.9 & 90.8 & 95.4 & 84.6 & 86.0 & 88.5 & 58.1 \\ \hline PFNet & \bf{75.4} & \bf{84.8} & \bf{91.5} & \bf{95.9} & \bf{85.4} & \bf{86.3} & 91.1 & \bf{58.6} \\ \bottomrule[0.1em] \end{tabular}} \caption{Experimental results on Postdam Dataset. The results are reported with single scale input. The bold values in each column mean the best entries. The category are defined as: impervious surfaces (Imp.surf.), buildings (Build), low vegetation (Low veg), trees (Tree), cars (Car), cluster/background (Cluster).} \label{tab:results_Postdam_dataset} \end{threeparttable} \end{table*} \subsection{Experiments on Generation Segmentation Dataset} In this section, we will first give the implementation details on Cityscapes~\cite{Cityscapes}, BDD~\cite{yu2020bdd100k} and ADE20k~\cite{ADE20K}. \noindent \textbf{Implementation Details} \noindent \textbf{Cityscapes} dataset is composed of a large set of high-resolution $(2048 \times 1024)$ images in street scenes. This dataset has 5,000 images with high quality pixel-wise annotations for 19 classes, which is further divided into 2975, 500, and 1525 images for training, validation and testing. We only use the fine-data for training. Following the common practice, the ``poly'' learning rate policy is adopted to decay the initial learning rate by multiplying $(1 -\frac{\text{iter}}{\text{total}\_\text{iter}})^{0.9}$ during training. Data augmentation contains random horizontal flip, random resizing with scale range of $[0.75, ~2.0]$, and random cropping with crop size of $864 \times 864$ and we train totally 300 epochs for strong baseline. \noindent \textbf{BDD} is a new road scene benchmark consisting $7,000$ images for training and $1,000$ images for validation. We follow the same setting as Cityscapes dataset. \noindent \textbf{ADE20k} is a more challenging scene parsing dataset annotated with 150 classes, and it contains 20K/2K images for training and validation. It has the various objects in the scene. We train the network for 120 epochs with batch size 16, crop size 512 and initial learning rate 1e-2. For final testing, we perform multi-scale testing with horizontal flip operation. \noindent \textbf{Visualization and Comparison Results} We provide visualization and comparison results on Cityscapes and ADE-20k in Fig.~\ref{fig:city_vis_sup} and Fig.~\ref{fig:ade_vis_sup}. From both figures, our PFM can better handle the segmentation tails and missing objects in the scene. \begin{figure*}[!h] \centering \includegraphics[width=1.0\linewidth]{fig/pfnet_city_vis_res_sup.pdf} \caption{Visualization results on Cityscapes dataset. Best view it on screen. } \label{fig:city_vis_sup} \end{figure*} \begin{figure*}[hp] \centering \includegraphics[width=0.8\linewidth]{fig/pfnet_ade_vis_res_sup.pdf} \caption{Visualization results on ADE20k dataset. Best view it on screen. } \label{fig:ade_vis_sup} \end{figure*} \section{Acknowledgement} Much thanks to the SenseTime Research's GPU servers for benchmarking semantic segmentation results on these aerial datasets. Y. Tong is supported by the National Key Research and Development Program of China (No.2020YFB2103402). Z. Lin is supported by NSF China (grant no.s 61625301 and 61731018), Major Scientific Research Project of Zhejiang Lab (grant no.s 2019KB0AC01 and 2019KB0AB02), Beijing Academy of Artificial Intelligence, and Qualcomm.
{'timestamp': '2021-03-12T02:17:54', 'yymm': '2103', 'arxiv_id': '2103.06564', 'language': 'en', 'url': 'https://arxiv.org/abs/2103.06564'}
arxiv
\section{Introduction} Data-driven partial differential equation (PDE) discovery may link classical methods and modern machine learning methods. If the data-driven model is expressed in the form of differential equations, on the one hand, the classical analysis methods are applied. On the other hand, such a form is understandable by scientists in various application fields. Single PDE discovery algorithms are usually applied sparse regression to the pre-defined library of terms. We proposed the evolutionary-based algorithm that allows combining evolutionary optimization and sparse regression to solve symbolic regression problems effectively. Transfer to the multi-objective optimization makes the resulting model form more flexible. For example, the model's complexity may be controlled, and the Pareto frontier of the model with different complexity and data reproduction levels may be obtained. In a more general multi-objective discovery algorithm case, the partial differential equations systems may be obtained. Modern equation discovery methods usually treat systems as a single equation in a vector form \cite{b6}. However, this restricts the application of the system discovery. Systems overall are not interesting since their amount used in modern physics is established and restricted. It is often of interest to obtain the forcing function or additional parametrizing equation, which is impossible in the vector form case. Regression methods are hardly applicable in non-vectorizable system discovery. Evolutionary multi-objective system discovery may give space for various applications since the system equations are discovered separately. The paper describes the combined method that uses multi-objective co-evolutionary optimization (simultaneous equations and the system evolution) and the sparse regression to obtain the partial differential equations system. The paper is structured as follows: Sec.~\ref{sec:literature_rewiev} contains a brief review of the equation and their systems discovery algorithms; Sec.~\ref{sec:problem_statement} is dedicated to the mathematical description of the multi-objective system discovery; Sec.~\ref{sec:algorithm_description} describes the particular realization of the algorithm; Sec.~\ref{sec:experiment} briefly highlights the results obtained on a synthetic data - two-dimensional Navier-Stokes equation solution; Sec.~\ref{sec:conclusion} outlines the paper and also sketches the future work directions. All required data and code that are required to reproduce the results are available from the URL placed in Sec.~\ref{sec:repo} \section{Related work} \label{sec:literature_rewiev} Single differential equation discovery is of interest of many references \cite{b1,b2,b3,b4}. There are two main directions of differential equation discovery: sparse regression \cite{b1,b2} and neural networks \cite{b3,b4}. Sparse regression consists of differential terms library definition and following sparse regression on the defined set. This approach has a speed drawback since the terms library should be as extensive as possible to cover all the possible differential equation types. The larger the set is, the slower is optimization process in sparse regression. However, this approach is well-developed and has different application areas. One of the main advantages of the sparse regression methods is the straightforward mechanism of the equation discovery. In particular, by changing the sparsity hyperparameter, one may obtain the trade-off between complexity vs. quality equation. Neural networks are fast and popular since there are a lot of established frameworks for neural network learning that allows the scientist to build the neural network without in-depth knowledge in the field \cite{keras}. However, they are susceptible to the training data. Thus, an additional filter network is required for the PDE discovery algorithm to be functional \cite{b3}. As a drawback, the results cannot be tuned to obtain the model with desired parameters. Also, the way to obtain the result is hardly interpretable, and the obtained equation is formed using ``blackbox'' in the form of the neural network. We proposed the algorithm for the single equation discovery \cite{b5} that combines evolutionary optimization to obtain new terms for the sub-libraries that define the form of the equation and the sparse regression to filter out the insignificant terms in the sub-library to keep it as small as possible. Such an approach may be considered a symbolic regression version with additional evolutionary operators to obtain new terms. The PDE systems are usually discovered as the equations in the vector form \cite{b6} meaning the methods for the single equation are applied to the vector values. The vector form restricts the type and the form of the obtained equation. Nevertheless, the ODE field situation is more straightforward, and we know the solution to obtain ``pure'' systems of the differential equations. It should be emphasized that the problem of ordinary differential equation (ODE) systems in ``pure'' form solution is partially shown in \cite{b7}. However, due to the non-Markovian models' specificity, this approach cannot be applied to the general ODE and PDE systems discovery. \section{Problem statement} \label{sec:problem_statement} The standard problem formulation of the data-driven equation discovery assumes that equation is restored from the discrete datafield $D=\{(u_1(\vec{x}_i),...,u_n(\vec{x}_i)),i=1,2,...,M\}$, where $M$ is the number of the observation datapoints $\vec{x}_i \in \Omega \subset R^m$ avaliable. It is assumed that $D$ is the discrete analogue of the continuous field $\vec{u}(\vec{x})=(u_1(\vec{x}),...,u_n(\vec{x})) \,, \vec{u}: R^m \to R^n $ that represent the observation recordings of a physical process. Resulting discovered equation's system of $k$ equations has the form: \begin{equation} S(\vec{u})=\left\{\begin{array}{cc} L_1(\vec{u})=0 \\ ... \\ L_k(\vec{u})=0 \end{array} \right. \label{eq:cont_system} \end{equation} In Eq.~\ref{eq:cont_system} single differential operator $L_i \in Eq$ represents the single differential equation, $Eq$ is the set of all possible equations that could be obtained with the given algorithm. Since Eq.~\ref{eq:cont_system} is assumed to be the system, all equation are assumed to be fullfiled simultaneously. In general, equation system $\bar{S}$ discovery task in an optimization problem formulated as: \begin{equation} \label{eq:theoretical_formulation} \bar{S}=\text{arg} \min \limits_{S \in Eq^k} S(\vec{u}) \end{equation} In Eq.~\ref{eq:theoretical_formulation} $Eq^k=Eq \times ...\times Eq$ is the cartesian product of the sets of the possible equations. We emphasize that since only the discrete number of the points given, the operators are replaced with the discrete analogs such as finite differences. And the minimization task is reformulated as \begin{equation} \forall i \, \bar{S}=\text{arg} \min \limits_{S \in Eq^k} S(\vec{u}_i) \, ,\vec{u}_i \in D \label{eq:min_global} \end{equation} In practice, such formulation (Eq.~\ref{eq:min_global}) is hard to apply to the given method. Therefore, it is often rewritten as \begin{equation} \bar{S}=\text{arg} \min \limits_{S \in Eq^k} \sum \limits_{i=1}^{i=M} || S(\vec{u}_i) || \label{eq:min_practical} \end{equation} In Eq.~\ref{eq:min_practical} norm $||\cdot||$ is chosen concerning problem specifics. Introducing the multi-objective formulation allows tuning the discovered system in various ways. For example, for some problems, the data reproduction precision is less critical than the equation complexity. The first group of the objectives we refer to as ``quality''. For a given equation $L$, the quality metric is the data reproduction norm that is represented as \begin{equation} Q(L_j)= \sum \limits_{i=1}^{i=M} || L_j(\vec{u}_i) || \label{eq:norm_quality} \end{equation} The second group of objectives we refer to as ``complexity''. For a given equation $L$, the complexity metric is bound to the number of the differential terms in the equation that is denoted as $\#(L)$ \begin{equation} C(L_j)= \#(L_j) \label{eq:norm_complexity} \end{equation} Two functions for every of the $k$ equations in the system form the space of the multi-objective optimization objectives. The next step is to define multi-objective optimization operator Eq.~\ref{eq:multiobj_op} and solve multi-objective optimization problem. \begin{multline} F(L_1,...,L_k)=G(Q(L_1),C(L_1),...,Q(L_k),C(L_k)), \\ F: R^{2k}->R^l \label{eq:multiobj_op} \end{multline} Usually, case $l=2k$ is considered. It means that the objectives remain without changes and form the space for multi-objective optimization. In this case $G=E$, where $E$ is the equality operator. The section below contains the particular realization used to obtain the PDE system using a combined evolutionary algorithm and sparse regression. \section{Algorithm description} \label{sec:algorithm_description} The developed algorithm of differential equation/system of differential equation discovery is composed of two elements: the tool for constructing a single equation (system of equations) according to the specific parameters and data, and the multi-objective optimization procedure, that detects the Pareto frontier of trade-offs between the previously introduced "quality" of the process representation and the "complexity" metrics of individual equations. The resulting algorithm is co-evolutionary and consists of two parts shown in the general scheme Fig.~\ref{fig:main_scheme}. \begin{figure*}[ht] \centering \includegraphics[width=0.7\textwidth]{Figures/Main_scheme_KEK.png} \caption{Principal scheme of the algorithm. Colors are representing the two different parts of the co-evolutionary algorithm.} \label{fig:main_scheme} \end{figure*} The single equation discovery part is a single-objective evolutionary algorithm that is described in detail in Sec.~\ref{sec:single_equation_discovery}, and the system discovery part is multi-objective and described in Sec.~\ref{sec:system_discovery}. Both parts are used simultaneously and form co-evolution. \subsection{Evolutionary algorithm of equation discovery} \label{sec:single_equation_discovery} The construction of every equation begins with the definition of a set of function, i.e. tokens $T = \{T_1, T_2, \; ... \; , T_n\}$, where each subset $T_j$ represents a separate class of function with specific properties, for example, derivatives of a specific components of velocity vector across all axes: $T_k = \{u, \frac{\partial u}{\partial x}, \frac{\partial u}{\partial y}, \frac{\partial u}{\partial z}, \frac{\partial u}{\partial t}, \frac{\partial^2 u}{\partial x^2}, \; ... \}$. The tokens will be used as the differential operator elements (most commonly - factors in the term) as in Eq.~\ref{eq:token_struct_equation}. The evolutionary algorithm of a single equation discovery, performs the construction of the data-driven equation in regards to minimization of discrepancy: $L_k \longrightarrow 0$. The pseudo-code for the procedure of system of equations discovery is presented on the Algorithm \ref{alg:ESTAR}. \begin{equation} L_k =\sum_{i = 1}^{n\_terms} \alpha_i \prod_{j = 1}^{n\_factors} t_{ij}, \; t_{ij} \in T \label{eq:token_struct_equation} \end{equation} The encoding of the evolutionary algorithm individual is done in the following manner: a chromosome represents a candidate equation, where its elements, genes, representing factors of the equation, are divided into groups of random size (up to a specific limit) to represent the terms. Each factor can have alterable parameters that are also optimized during the equation construction (for example, a sine function can be used as a token, and it contains parameters: frequency, axis, along with that the sine is taken, and power). During the initialization of the algorithm, a set of candidate equations is randomly created. The example of the single equation is shown in Fig.~\ref{fig:single_xover}. The weights $\alpha_i$ represent the candidate equation's coefficients and shall be optimized by additional technique. The weight vector's desired property is its sparsity, and it can be achieved with the sparse regression operator. When the equation structure is obtained from the evolutionary operator's step, each of the terms is approximated with the other terms taken as features by the LASSO regression, and the term with the best approximation is selected as the final "right side" of the equation. The non-zero coefficients with the corresponding terms compose the desired equation. This approach is introduced to exclude the unavoidable trivial structures with zero weights vectors, appearing with zero-valued right part approximation. Also, it is used to view all possible equations containing the same structure. However, LASSO regression can only obtain intermediate values of the equation coefficients $\beta$ due to the necessity to have data-centered and normalized. So, we have to solve the problems of minimizing the function Eq.~\ref{eq:Lasso} in respect to the coefficients $\beta$ for each equation term, selected as ``target''. Here, in the problem of approximation of $k$-th term, we have to evaluate the terms of the equation in points with known values to form the matrix $\mathbf{F}_k$ and vector of target term values ${F}_{target,k}$. \begin{equation} \label{eq:Lasso} \Vert{\mathbf{F}_{k}}\beta -{{F}_{target,k}}\Vert_{2}^{2}+\lambda {\Vert{\beta }\Vert_{1}} \longrightarrow \min \limits_\beta \end{equation} After calculating coefficients $\beta$, we need to initiate the linear regression on original data to discover the correct values of the coefficients $\alpha$. The fitness function is the inverse value of a norm of the best equation term approximation error as in Eq.~\ref{eq:fitness_val}. By maximizing that error, we perform the differential operator's search, which is close to zero. \begin{equation} \begin{split} f_{fitness} &= (|| L_k ||_2)^{-1} \\ &= (|| \sum_{i = 1, i \neq t\_idx}^{n\_terms} \alpha_i \prod_{j = 1}^{n\_factors} t_{ij} - \\ &- \prod_{j = 1}^{n\_factors} t_{t\_idx \; j} ||_2)^{-1} \end{split} \label{eq:fitness_val} \end{equation} Both recombination and mutation are used as variation operators to improve the quality of the population. The recombination operator (Fig.~\ref{fig:single_xover}) operated differently on genes of two offspring, depending on the similarities of the parents' ones. \begin{figure}[h!] \centering \includegraphics[width=0.45\textwidth]{Figures/CEC_xover.png} \caption{Individual form and recombination scheme of the single equation part of the algorithm. Grey and red colors are representing two different individuals.} \label{fig:single_xover} \end{figure} All terms are separated into three groups: the terms with the same tokens with the same parameters, the terms with the same tokens, the different parameters, and terms with unique tokens. The first group is not affected by crossover, the offspring duplicates of the terms from the second group have values of parameters as a proportion between their parent ones, and the terms of the third group can be swapped with defined probability. The mutation operator is implemented in two types. First, the gene can be changed to a new one, resulting in the change of an equation term or a factor inside a term as shown in Fig.~\ref{fig:single_mutation_a}. \begin{figure}[h!] \centering \includegraphics[width=0.45\textwidth]{Figures/CEC_mutation_a.png} \caption{Mutation operator of the first kind. In this case whole term in the equation is replaced with another.} \label{fig:single_mutation_a} \end{figure} Next, the mutation is used for the optimization of token parameters: if a token has alterable parameters (i.e., frequency of a sine function), a random increment from the normal distribution $\mathcal{N}(0, \sigma)$, with $\sigma$ as a fraction of allowed range for parameter, can be added as shown in Fig.~\ref{fig:single_mutation_b}. \begin{figure}[h!] \centering \includegraphics[width=0.45\textwidth]{Figures/CEC_mutation_b.png} \caption{Mutation operator of the second kind. In this case term remains the same, however, either the parameters or differential order and variable may be altered or additional differential term may be inserted in the product.} \label{fig:single_mutation_b} \end{figure} Several challenges appear with the shift from discovering a single equation to the derivation of differential equations systems. The construction of the system of equations is done in sequential order by equations. To avoid isolated equations, where each of the equations describes a separate variable with a probably overtrained structure, we try to connect the system's equations by introducing the variable change held by the resulting equation. After obtaining the value of "equation error" $L_i$, it is subtracted from the values of the new tokens as in Eq.~\ref{eq:variable_change}. \begin{equation} t_{ij} |_{k+1} = t_{ij} |_k - L_k = t_{ij} - \sum_{n=1}^{k}L_n \label{eq:variable_change} \end{equation} Also, we have introduced restrictions on the duplicated appearance of equations, describing the same variable, and only it (for example, a pair of equations $\frac{\partial f}{\partial x} + \frac{\partial f}{\partial y} = 0$, and $\frac{\partial f}{\partial t} = 0$), to force the equations to connect the variables. By penalizing the fitness value ($f_{fitness} = 0$, if it repeatedly only describes the same variable, as any of the previous equations) of such equations, we force the evolutionary to promote equations that describe all variables of a dynamic system. \begin{algorithm}[ht!] \label{alg:ESTAR} \KwData{set of tokens $T = \{T_1, T_2, \; ...\; T_n\}$, where subsets are divided into dependent and independent variables, sparsity constant for each equation $(\lambda_1, \; ... \;, \lambda_{n\_eq})$} \KwResult{system of differential equations} \For{$equation\_idx = 1$ to $n\_var_{dependent}$}{ Randomly generate initial population of candidate equations from tokens from set $T$\; \For{individual in population}{ $right\_part\_idx = 0$\; $max\_fitness\_val = - inf$\; \For{target\_idx = 0 to terms\_number}{ Apply sparse (LASSO) regression to find intermediate coefficients $\beta$\; Apply linear regression to find correct coefficients of the equations \& get fitness value $fit_val$\; \eIf{$fit\_val > max\_fitness\_val$}{ $max\_fitness\_val = fit\_val$\; $right\_part\_idx = target\_idx$\; }{pass} } } \For{epoch = 1 to epoch\_number}{ population.sort()\; Remove worst solutions to maintain population size\; Tournament selection of parents for recombination\; Apply recombination and mutation operators\; \For{new\_individual in offsprings}{ Use LASSO operator and linear regression to find best partition into left \& right parts and calculate fitness (as above)\; } Add new solutions into population\; } Replace variables: $t' = t - Lu, \; t \in T$ } \caption{The pseudo-code of system of equations discovery} \end{algorithm} \subsection{Obtaining the Pareto frontier of the equation systems} \label{sec:system_discovery} In the previous developments, we have examined that by altering the algorithms' hyperparameters, mainly the LASSO regression's sparsity constant, utilized in the discovery of terms, we can shift the trade-off between quality and complexity. The problem of multi-objective optimization in space, created by the equations' quality and complexity metric, is solved by the Many-Objective Optimization Evolutionary Algorithm Based on Dominance and Decomposition (MOEA/DD), proposed in \cite{b8}. In other words, the multi-objective optimization algorithm operates as the meta-optimization for the main algorithm of system discovery. In this evolutionary process, the individuals represent systems of differential equations. The encoding operates as follows: the sparsity constants for each equation are combined into a vector $(\lambda_1, \lambda_2, ..., \lambda_{n\_eq},\; \lambda_i \in R^{+})$ (due to the properties of LASSO operator, sparsity constants are positive real values), which is considered an evolutionary algorithm chromosome and is affected by evolutionary operators during the search process. This representation's motivation is based on the notion that the equation discovery algorithm converges to the single solution with the specified hyperparameters. Therefore, with enough epochs for equation discovery, a vector of sparsity constants unequivocally defines a system of differential equations. In the initial stage of the evolution, according to the standard workflow of the MOEA/DD algorithm, we have to evaluate the best possible value for each of the objective functions: for complexity metric, it is reasonable to set the value to 0, while for the process representation quality (L2 norm of the vector of error in the grid points) the same assumption can be made only to a certain degree: the possible stochastic nature of processes or noise, present in measurements, limit the resulting quality. Therefore, a testing run of an equation discovery algorithm can be held to approximate the best possible quality of a solution. Next, to start the evolutionary search, we generate the population of solutions by finding systems with randomized sparsity constants and divide the search space into sections by weights vectors in the manner proposed in \cite{b9}. With the weights mechanism, the algorithm can preserve diversity in the population and cover the Pareto frontier with candidate points. We use the conventional variation techniques with the introduced representation of individuals: mutation and recombination (crossover) operators. The mutation operator involves changing a candidate from the population with the addition of an increment from a normal distribution $\mathcal{N}(0, \sigma)$ to the specific sparsity constant in its gene with a pre-defined probability $p_{mut} \in (0, 1)$, as in the Eq.~\ref{eq:mutation_sys}. \begin{equation} \begin{array}{cc} (\lambda_1, \lambda_2, \; ... \;, \lambda_{n\_eq}) \longrightarrow (\lambda'_1, \lambda'_2, \; ... \;, \lambda'_{n\_eq}) \\ p_i \sim U(0,1) \\ \text{if} \; p_i < p_{mut} \;\; \text{then} \; \lambda'_i = \lambda_i + \delta, \; \delta \sim \mathcal{N}(0, \sigma) \\ \text{else} \; \lambda'_i = \lambda_i \end{array} \label{eq:mutation_sys} \end{equation} The recombination operator involves the creation of new individuals using the selected parents. The offsprings should have characteristics resembling both their parents, which is implemented by the selection of offsprings genes' values in the diapason between their parents: the new values for each of the gene in the offsprings' chromosomes are selected as a weighted sum of their parents' ones, having coefficient $\alpha \in U(0, 1)$. The systems' recombination scheme is shown in Eq.~\ref{eq:xover_sys}. \begin{equation} \begin{array}{cccl} (\lambda^{1}_1, \lambda^{1}_2, \; ... \;, \lambda^{1}_{n\_eq}) \longrightarrow (\lambda'^{1}_1, \lambda'^{1}_2, \; ... \;, \lambda'^{1}_{n\_eq}) \\ (\lambda^{2}_1, \lambda^{2}_2, \; ... \;, \lambda^{2}_{n\_eq}) \longrightarrow (\lambda'^{2}_1, \lambda'^{2}_2, \; ... \;, \lambda'^{2}_{n\_eq}) \\ p_i \sim U(0,1)\\ \text{if} \; p_i < p_{xover} \, \text{then} \, \lambda'^{1}_i = \alpha*\lambda^{1}_i + (1 - \alpha) * \lambda^{2}_i\\ \text{else} \, \lambda'^{1}_i = \lambda^{1}_i, \; \lambda'^{2}_i = \lambda^{2}_i \end{array} \label{eq:xover_sys} \end{equation} The selection of parents for the crossover is held for each objective function space region, defined by weights vectors. With a specified probability of maintaining the parents' selection, we can select an individual outside the processed subregion to partake in the recombination. In other cases, if there are candidate solutions in the region associated with the weights vector, we make a selection among them. The final element of MOEA/DD is population update after creating new solutions, which is held without significant modifications. \begin{algorithm}[h!] \label{alg:MOEADD} \KwData{set of tokens $T = \{T_1, T_2, \; ...\; T_n\}$; subsets are divided into dependent and independent variables; objective functions: quality and complexity of systems} \KwResult{Pareto frontier, composed of systems of differential equations} Create a set of weight vectors $\mathbf{w} = (w^1, ..., w^{n\_weights}), \; w^i=(w^i_1, \; ..., \; w^i_{n\_eq + 1}) $\; \For{weight\_vector in weights}{ Select K nearest weight vectors to the weight\_vector\; } Randomly generate a set of candidate systems of equations (using Alg.~\ref{alg:ESTAR}) \& divide them into non-dominated levels\; Divide the initial population into groups by subregion, to which they belong\; \For{epoch = 1 to epoch\_number}{ \For{weight\_vector in weights}{ Parent selection\; Apply recombination to parents pool and mutation to individuals inside the region of weights\; \For{offspring in new\_solutions}{ Optimize the structure of systems of equations for offspring\; Get values of objective functions for offspring\; } Update population\; } } \caption{The pseudo-code of Pareto frontier construction, using adapted MOEA/DD algorithm} \end{algorithm} Both algorithms Alg.~\ref{alg:ESTAR} and Alg.~\ref{alg:MOEADD} are used simultaneously in a co-evolution manner to obtain the Pareto frontier of the systems based on observational input data. \section{Experimental studies} \label{sec:experiment} To analyze the algorithm's performance, we have applied it to the synthetic data set, representing a solution to the known system of partial differential equations. For that task, we have selected a Navier-Stokes system of equations with assumptions of an incompressible fluid, displayed on Eq.~\ref{eq:Navier_Stokes}, that describes relations between velocity (with velocity components $u, \; v$), and pressure $p$, and describes a flow of liquid in a pipe. Here, $\Delta = \frac{\partial^2}{\partial x^2} + \frac{\partial^2}{\partial y^2}$ is the del operator, and $\nabla = \frac{\partial}{\partial x} + \frac{\partial}{\partial y}$ is the Laplace operator, $\rho$ is density, that is assumed to be constant in the domain, and $\mathbf{F} = (\vec{F}_x, \vec{F}_y)$ is the mass force. \begin{equation} \left\{\begin{array}{cc} \frac{\partial u}{\partial t}=\frac{1}{\rho} \nu \nabla^2 u + \vec{F}_x - \frac{1}{\rho} \frac{\partial p}{\partial x}\\ \frac{\partial v}{\partial t}=\frac{1}{\rho} \nu \nabla^2 v + \vec{F}_y - \frac{1}{\rho} \frac{\partial p}{\partial y} \\ \Delta p = g \end{array} \right. \label{eq:Navier_Stokes} \end{equation} The system of equations was solved on the domain of 0 to 100 with 100 grid nodes at each spatial domain, and from 0 to 10 with 400 grid points in time. The initial conditions for the velocity are set in Eq.~\ref{u_inital} \& Eq.~\ref{v_inital}, while boundary conditions on area limits $\Gamma$ were set as $u|_{\Gamma} = 0$; $v|_{\Gamma} = 0$. Other parameters have the following values: $F_x = F_y = 0.01$; density $\rho = \frac{1}{10}$; viscosity $\nu = 1.0$. Boundary condition for pressure was set as $p|_{y = 0; \;y = 100}=4.9*x^2 - 490x$; $p|_{x = 0; \;x = 100} = 0$. \begin{multline} u |_{t=0} = 10^3 \sin{(\frac{1}{10^4} x (100-x))} \\ \sin{(\frac{1}{10^4} y (100-y))} \sin{(\frac{pi}{25} x)} \label{u_inital} \end{multline} \begin{multline} v |_{t=0} = 10^3 \sin{(\frac{1}{10^4} x (100-x))} \\ \sin{(\frac{1}{10^4} y (100-y))} \sin{(\frac{\pi}{25} y)} \label{v_inital} \end{multline} From the numerical solution to the system (matrices of velocity components and pressure values, calculated for a grid in the studied domain), the algorithm's input data, represented by values of derivatives, evaluated on the grid's points obtained by numerical differentiation. Earlier works have shown that the least errors in the derivatives' values are achieved in the experiments, where the differentiation is done with the analytical differentiation of polynomials, fit to the data. Thus, the building blocks of the equations are represented by functions $u, v, p$, and their derivatives across two spatial axes and time up to 3-rd order $\frac{\partial u}{\partial x}, \frac{\partial u}{\partial y}, \frac{\partial u}{\partial t}, \frac{\partial v}{\partial x}, \; ... \;, \frac{\partial^3 p}{\partial t^3}$. However, with the blind inclusion of all derivatives, we can face issues with the discovery of simplified equations in the forms of $\frac{\partial f}{\partial x_i} = 0$, when the function $f$ does not depend on the variable $x_i$. For example, in our case, the pressure field is static. Thus some equations like Eq.~\ref{eq:static_pressure} with arbitrary order of derivative $n$ can be discovered with very high fitness values. \begin{equation} \frac{\partial^n p}{\partial t^n} = 0 \label{eq:static_pressure} \end{equation} The analysis of the obtained Pareto frontier and the comparison between discovered equations indicate that the experiment data can be described with multiple equations with different quality degrees. In Fig.~\ref{fig:pareto_equations}, the complexity metric shows a number of terms except for constant across all equations of the discovered system, while the error indicates the sum of L2-norms of a discrepancy of the corresponding equation of the systems. \begin{figure}[ht!] \includegraphics[width=0.49\textwidth]{Figures/Eq_Pareto.png} \caption{The Pareto frontier of quality (total L2-norm of the equations)-complexity (total number of terms in the equations) trade-offs for systems of equations} \label{fig:pareto_equations} \end{figure} Before analyzing the Pareto frontier, we note that when the equations contain only one term except constant, the most straightforward case provides the system description's highest error. More complex systems describe the dynamics with higher quality, while after the construction of momentum conservation law from the Navier-Stokes system of equation, coupled with an equation for pressure, the addition of new terms does not reduce the model's error. However, the correct equation for pressure was not constructed due to the equation's good quality containing the time derivative of pressure. The three cases in Fig.~\ref{fig:pareto_equations} show the possibility of tuning the resulting system. With the modern regression methods, we may obtain the Navier-Stokes vector equation in the form Eq.~\ref{eq:vector_Navier_Stokes}. \begin{equation} \frac{\partial \vec{u}}{\partial t}-\frac{1}{\rho} \nu \vec{\nabla}^2 \vec{u}=const \label{eq:vector_Navier_Stokes} \end{equation} We can obtain the additional pressure equation. However, the expert is required to show that the third pressure equation exists. We note that the proposed algorithm works autonomously. First system highlighted in Pareto frontier has the form Eq.~\ref{eq:res_pareto_1}. \begin{equation} \begin{cases} \frac{\partial p}{\partial t} = 0; \\ \frac{\partial^3 v}{\partial x^3} = 0; \\ \frac{\partial^3 u}{\partial x^3} = const; \end{cases} \label{eq:res_pareto_1} \end{equation} System Eq.~\ref{eq:res_pareto_1} shows the case described above. Simple trivial equations have the lowest possible complexity and good quality since the analytical differentiation methods result in zero fields. However, since the numerical differentiation is used, non-zero fields are obtained, and overall non-zero quality results from the differentiation error. It cannot be filtered out automatically since it is unknown whether the system is simple or the numerical differentiation scheme introduces the error. Second highlighted system has the form Eq.~\ref{eq:res_pareto_2}. \begin{equation} \begin{cases} \frac{\partial p}{\partial t} = 0; \\ \frac{\partial^2 v}{\partial x^2} + \alpha_{1 \; 1} u + \alpha_{1 \; 2} \frac{\partial^3 v}{\partial t^3} + \alpha_{1 \; 3} \frac{\partial p}{\partial x} = const; \\ \frac{\partial^2 u}{\partial y^2} + \alpha_{2 \; 1} \frac{\partial u}{\partial y} = const; \end{cases} \label{eq:res_pareto_2} \end{equation} At the point on the Pareto frontier that gives the system Eq.~\ref{eq:res_pareto_2}, the separate pressure equation is discovered. The two other equations represent the data-specific equations, which give higher quality than the Navier-Stokes system. However, their form is very sensitive to the changes in data such as noise, and this system may not be considered as the stable one. The third highlighted system has the form Eq.~\ref{eq:res_pareto_3} which is similar to the Navier-Stokes system Eq.~\ref{eq:Navier_Stokes}. \begin{equation} \begin{cases} \frac{\partial p}{\partial t} = 0; \\ \frac{\partial u}{\partial t} + \alpha_{1 \; 1} \nabla p + \alpha_{1 \; 2} \nabla^2 u = const;\\ \frac{\partial v}{\partial t} + \alpha_{2 \; 1} \nabla p + \alpha_{2 \; 2} \nabla^2 u = const; \\ \end{cases} \label{eq:res_pareto_3} \end{equation} We achieve the automatic pressure equation separation together with the complete set of component-wise equations. As seen, the analysis of the Pareto frontier makes the interpretation of the system discovery process clear. We may change the optimization in a more precise manner to obtain the system, representing the general data-driving laws such as the Navier-Stokes equations. \section{Conclusion} \label{sec:conclusion} In this paper, we have proposed an algorithm of differential equations systems discovery. We combine the evolutionary algorithm of obtaining a system with the multi-objective optimization problem to provide better insight into a discovered equation's ability to model the studied process. While the introduced algorithm of equation or system of equations derivation can get the best structure possible with the defined input tokens. In ideal conditions, we will determine which resulting equation we would like to use for further simulation during the physical process modeling. The algorithm has the following properties: \begin{itemize} \item The equations are obtained in a non-vector form that allows tuning the models more subtly. Moreover, it allows to control the process of the equation discovery; \item Introduced evolutionary operators allow to avoid the pre-defined library of differential terms that increases the variety of resulting equations; \item Multi-objective optimization allows to tune every equation in the system and obtain Pareto frontier of the models that increase the expert interpretation possibilities. \end{itemize} The further work on the related topic will be based mainly on the area of algorithm convergence to the complete structures that describe a process, avoiding overtraining as well as simplified solutions, such as the ones faced in the experiments, and the area of improving links between the equations of the system. Also, algorithm performance shall be addressed to make its application easier for the researcher with ordinary computational powers. \section{Code and Data availability} \label{sec:repo} The numerical solution data and the Python code that partially reproduce the experiments are available at the GitHub repository \footnote{https://github.com/ITMO-NSS-team/FEDOT.Algs/blob/master/estar/}.
{'timestamp': '2021-03-12T02:26:57', 'yymm': '2103', 'arxiv_id': '2103.06739', 'language': 'en', 'url': 'https://arxiv.org/abs/2103.06739'}
arxiv
\section{Introduction} \begin{figure}[t] \centering \includegraphics[width=.6\columnwidth]{teaser.pdf} \caption{For fully supervised action segmentation, each frame in the training videos is annotated with an action label (top). This process is time-consuming since it requires an accurate annotation of the start and end frame of each action. To reduce the annotation effort, we propose to use timestamps as supervision (bottom). In this case, only one arbitrary frame needs to be annotated for each action and the annotators do not need to search for the start and end frames, which is the most time-consuming annotation part.} \label{fig:teaser} \vspace{-3.5mm} \end{figure} Analyzing and understanding video content is very important for many applications, such as surveillance or intelligent advertisement. Recently, several approaches have been very successful in analyzing and segmenting activities in videos~\cite{lea2017temporal, lei2018temporal, farha2019ms, mac2019learning, wang2020boundary}. Despite the success of the previous approaches, they rely on fully annotated videos where the start and end frames of each action are annotated. This level of supervision, however, is very time consuming and hard to obtain. Furthermore, as the boundaries between action segments are usually ambiguous, this might result in inconsistencies between annotations obtained from different annotators. To alleviate these problems, many researchers start exploring weaker levels of supervision in the form of transcripts~\cite{bojanowski2014weakly, richard2018neuralnetwork, li2019weakly} or even sets~\cite{richard2018action, fayyaz2020set, li2020set}. For transcript-level supervision, the videos are annotated with an ordered list of actions occurring in the video without the starting and ending time of each action. Whereas for the set-level supervision, only the set of actions are provided without any information regarding the order or how many times each action occurs in the videos. While transcript-level and set-level supervision significantly reduce the annotation effort, the performance is not satisfying and there is still a gap compared to fully supervised approaches. In this paper, inspired by the recently introduced timestamp supervision for action recognition~\cite{moltisanti2019action}, we propose to use timestamp supervision for the action segmentation task to address the limitations of the current weakly supervised approaches. For timestamp supervision, only one frame is annotated from each action segment as illustrated in Fig.~\ref{fig:teaser}. Such timestamps annotations can be obtained with comparable effort to transcripts, and yet it provides more supervision. Besides the ordered list of actions occurring in the video, timestamps annotations give partial information about the location of the action segments, which can be utilized to further improve the performance. Given the timestamps annotations, the question is how to train a segmentation model with such level of supervision. A naive approach takes only the sparsely annotated frames for training. This, however, ignores most of the information in the video and does not achieve good results as we will show in the experiments. Another strategy is to iterate the process and consider frames with high confidence scores near the annotations as additional annotated frames and include them during training~\cite{moltisanti2019action}. Furthermore, frames that are far away from the annotations can be considered as negative samples~\cite{ma2020sf}. For temporal action segmentation, which is comparable to semantic image segmentation, however, all frames need to be annotated and there are no large parts of the video that can be used to sample negative examples. Furthermore, relying only on frames with high confidence discards many of the video frames that occur during an action and focuses only on the most distinctive frames of an action, which can be sufficient for action recognition or detection but not for action segmentation. In this work, we therefore propose a different approach where all frames of the videos are used. Instead of detecting frames of high confidences, we aim to identify changes of actions in order to divide the videos into segments. Since for each action change the frames before the change should be assigned to the previous timestamp and after the change to the next timestamp, we find the action changes by minimizing the variations of the features within each of the two clusters of frames. While we can then train the model on all frames by assigning the label of the timestamp to the corresponding frames, it does not guarantee that all frames of an action are effectively used. We therefore introduce a loss function that enforces a monotonic decrease in the class probabilities as the distance to the timestamps increases. This loss encourages the model to predict higher probabilities for low confident regions that are surrounded by high confident frames and therefore to use all frames and not only the most distinctive frames. Our contribution is thus three folded. \begin{enumerate} \item We propose to use timestamp supervision for the temporal action segmentation task, where the goal is to predict frame-wise action labels for untrimmed videos. \item We introduce an approach to train a temporal action segmentation model from timestamp supervision. The approach uses the model predictions and the annotated timestamps for estimating action changes. \item We propose a novel confidence loss that forces the model confidence to decrease monotonically as the distance to the timestamp increases. \end{enumerate} We evaluate our approach on four datasets: 50Salads~\cite{stein2013combining}, Breakfast~\cite{kuehne2014language}, BEOID~\cite{damen2014you}, and Georgia Tech Egocentric Activities (GTEA)~\cite{fathi2011learning}. We show that training an action segmentation model is feasible with only timestamp supervision without compromising the performance compared to the fully supervised approaches. On the 50Salads dataset, for instance, we achieve 97\% of the accuracy compared to fully supervised learning, but at a tiny fraction of the annotation costs. \footnote{The source code for our model and the timestamps annotations are publicly available at \url{https://github.com/ZheLi2020/TimestampActionSeg}.} \section{Related Work} We briefly discuss the related work for the temporal action segmentation task at different levels of supervision. \vspace{-.4mm} \paragraph{Fully Supervised Action Segmentation.} Temporal action segmentation has received an increasing interest recently. In contrast to action recognition where the goal is to classify trimmed videos~\cite{simonyan2014two, carreira2017quo, feichtenhofer2019slowfast}, temporal action segmentation requires capturing long-range dependencies to classify each frame in the input video. To achieve this goal, many approaches combined frame-wise classifiers with grammars~\cite{vo2014stochastic, pirsiavash2014parsing} or with hidden Markov models (HMMs)~\cite{lea2016segmental, kuehne2016end, kuehne2020hybrid}. Despite the success of these approaches, their performance was limited and they were slow both at training and inference time. Recent approaches, therefore, utilized temporal convolutional networks to capture long-range dependencies for the temporal action segmentation task~\cite{lea2017temporal, lei2018temporal}. While such approaches managed to generate accurate predictions, they suffer from an over-segmentation problem. To alleviate this problem, current state-of-the-art methods follow a multi-stage architecture with dilated temporal convolutions~\cite{farha2019ms, wang2020boundary, li2020ms, ishikawa2020alleviating, huang2020improving}. These approaches rely on fully annotated datasets that are expensive to obtain. On the contrary, we address the temporal action segmentation task in a weakly supervised setup. \paragraph{Weakly Supervised Action Segmentation.} Weakly supervised action segmentation has been an active research area recently. Earlier approaches apply discriminative clustering to detect actions using movie scripts~\cite{bojanowski2014weakly, duchenne2009automatic}. However, these approaches ignored the action ordering information and only focused on distinguishing action segments from background, which is a common practice for the temporal action localization task~\cite{lee2020background, lee2021weakly}. Bojanowski~\etal~\cite{bojanowski2014weakly} extended these ideas to segment actions in videos using transcripts in the form of an ordered list of actions as supervision. Recently, many researchers addressed the task by aligning the video frames and the transcripts using connectionist temporal classification~\cite{huang2016connectionist}, dynamic time warping~\cite{chang2019d3tw}, or energy-based learning~\cite{li2019weakly}. Other approaches generate pseudo ground truth labels for the training videos and iteratively refine them~\cite{kuehne2017weakly, richard2017weakly, ding2018weakly, kuehne2020hybrid}. In~\cite{richard2018neuralnetwork}, a frame-wise loss function is combined with the Viterbi algorithm to generate the target labels. While these approaches have been very successful, they suffer from a slow inference time as they iterate over all the training transcripts and select the one with the highest score. Souri~\etal~\cite{souri2019fast} addressed this issue by predicting the transcript besides the frame-wise scores at inference time. While these approaches rely on a cheap transcript supervision, their performance is much worse than fully supervised approaches. In contrast to these approaches, we propose a higher level of supervision in the form of timestamps that can be obtained with comparable effort to the transcript supervision, and yet reduces the gap to the fully supervised approaches. There is another line of research addressing the action segmentation task from set-level supervision~\cite{richard2018action, fayyaz2020set, li2020set}. These approaches opt for a weaker level of supervision at the cost of performance. In contrast to these approaches, we propose a good compromise between supervision level and performance. \paragraph{Timestamp Supervision for Recognizing Activities.} Timestamp supervision has not yet received much attention from the action recognition community. Initial attempts were inspired by the success of point supervision for semantic segmentation~\cite{bearman2016s}. Mettes~\etal~\cite{mettes2016spot} apply multiple instance learning for spatio-temporal action localization using points annotation on a sparse subset of frames. Ch{\'e}ron~\etal~\cite{cheron2018flexible} use discriminative clustering to integrate different types of supervision for the spatio-temporal action localization task. Recently, Moltisanti~\etal~\cite{moltisanti2019action} proposed a sampling distribution based on a plateau function centered around temporal timestamps annotations to train a fine-grained action classifier. This approach relies on the classifier response to sample frames around the annotated timestamps and uses them for training. The method was tested for classifying trimmed videos and also showed promising results for temporal action localization. Ma~\etal~\cite{ma2020sf} extended the action localization setup by mining action frames and background frames for training. \section{Temporal Action Segmentation} Temporal action segmentation is the task of predicting frame-wise action labels for a given input video. Formally, given a sequence of video frames $X=[x_1, \dots ,x_T]$, where $T$ is the number of frames, the goal is to predict a sequence of frame-wise action labels $[a_1, \dots ,a_T]$. In contrast to the fully supervised approaches, which assume that the frame-wise labels are given at training time, we consider a weaker level of supervision in the form of timestamps. In Section~\ref{sec:timestamps_supervision} we introduce the timestamp supervision for the temporal action segmentation task. Then, we describe the proposed framework for learning from timestamp supervision in Section~\ref{sec:method}. Finally, we provide the details of the loss function in Section~\ref{sec:loss}. \subsection{Timestamp Supervision} \label{sec:timestamps_supervision} In a fully supervised setup, the frame-wise labels \mbox{$[a_1, \dots ,a_T]$} of the training videos are available. On the contrary, for timestamp supervision, only a single frame for each action segment is annotated. Given a training video $X$ with $T$ frames and $N$ action segments, where $N << T$, only $N$ frames are annotated with labels \mbox{$A_{TS}=[a_{t_1}, \dots ,a_{t_N}]$}, where frame $t_i$ belongs to the $i\mbox{-}th$ action segment. To annotate timestamps, one can go fast forward through a video and press a button when an action occurs. This does not take more time than annotating transcripts. Whereas annotating the start and end frames of each action requires going slowly back and forth between the frames. As reported in~\cite{ma2020sf}, annotators need 6 times longer to annotate the start and end frame compared to annotating a single timestamp. While timestamps are much easier to obtain compared to the full annotation of the video frames, they provide much more information compared to weaker forms of supervision such as transcripts. Fig.~\ref{fig:teaser} illustrates the difference between timestamp supervision and full supervision. \begin{figure}[tb] \centering \includegraphics[width=.6\columnwidth]{framework_v3.pdf} \caption{The framework of the proposed approach for training with timestamp supervision. Given the output of the segmentation model and the timestamps annotations, we generate action labels for each frame in the input video by estimating where the action labels change. A loss function is then computed between the predictions and the generated labels.} \label{fig:Framework_new} \vspace{-4mm} \end{figure} \subsection{Action Segmentation from Timestamp Supervision} \label{sec:method} Given an action segmentation model $\cal{M}$ and a set of training videos with timestamps annotations, the goal is to train the model $\cal{M}$ to predict action labels for each frame in the input video. If the frame-wise labels are available during the training, as in the fully supervised case, then it is possible to apply a classification loss on the output of the model $\cal{M}$ for each frame in the input video. However, in timestamp supervision, only a sparse set of frames are annotated. To alleviate this problem, we propose to generate frame-wise labels for the training videos, and use them as a target for the loss function as illustrated in Fig.~\ref{fig:Framework_new}. \paragraph{Detecting Action Changes.} Given the timestamps annotations \mbox{$A_{TS}=[a_{t_1}, \dots ,a_{t_N}]$} for a video $X$, we want to generate frame-wise action labels \mbox{$\hat{A}=[\hat{a}_{1}, \dots ,\hat{a}_{T}]$} for each frame in that video such that $\hat{a}_{t_i} = a_{t_i}$ for $i \in [1, N]$. As for each action segment there is an annotated frame, finding the frame-wise labels can be reduced to finding the action change between each consecutive annotated timestamps. To this end, we pass the input video $X$ to the segmentation model $\cal{M}$, which will be described in Section~\ref{sec:implementation_details}, and use the output of the penultimate layer $H$ combined with the timestamps annotations to estimate where the action labels change between the timestamps. To generate the labels, all the frames that lie between an annotated timestamp and an estimated time of action change are assigned with the same action label as the annotated timestamp as illustrated in Fig.~\ref{fig:pseudo_gt}. To detect the action change between two timestamps $t_{i}$ and $t_{i+1}$, we find the time $t_{b_i}$ that minimizes the following stamp-to-stamp energy function \begin{equation} \label{eqn:s2s_energy} \begin{split} & t_{b_i} = \operatornamewithlimits{arg\,min}_{\hat{t}} \sum_{t=t_i}^{\hat{t}} d(h_{t}, c_i) + \sum_{t=\hat{t}+1}^{t_{i+1}} d(h_{t}, c_{i+1}), \\ s.t. & \\ & c_i = \frac{1}{\hat{t} - t_i + 1} \sum_{t=t_i}^{\hat{t}} h_{t}, \\ & c_{i+1} = \frac{1}{t_{i+1} - \hat{t}} \sum_{t=\hat{t}+1}^{t_{i+1}} h_{t}, \\ & t_i \leq \hat{t} < t_{i+1}, \end{split} \end{equation} where $d(.,.)$ is the Euclidean distance, $h_{t}$ is the output of the penultimate layer at time $t$, $c_i$ is the average of the output between the first timestamp $t_i$ and the estimate $\hat{t}$, and $c_{i+1}$ is the average of the output between the estimate $\hat{t}$ and the second timestamp $t_{i+1}$. \Ie, we find the time $t_{b_i}$ that divides the frames between two timestamps into two clusters with the minimum distance between frames and the corresponding cluster center. \paragraph{Forward-Backward Action Change Detection.} In (\ref{eqn:s2s_energy}), the stamp-to-stamp energy function considers only the frames between the annotated timestamps to estimate where the actions change. Nonetheless, if we already have an estimate for $t_{b_{i-1}}$, then we already know that frames between the estimate $t_{b_{i-1}}$ and the next timestamp $t_{i}$ will be assigned to action label $a_{t_{i}}$. This information can be used to estimate the time of action change for the next action segment $t_{b_{i}}$. The same argument also holds if we start estimating the boundaries in reverse order. \Ie, if we already know $t_{b_{i+1}}$, then frames between $t_{i+1}$ and $t_{b_{i+1}}$ can be used to estimate $t_{b_{i}}$. We call the former estimate a forward estimate for the $i\mbox{-}th$ action change, whereas the later is called the backward estimate. The final estimate for $t_{b_{i}}$ is the average of these two estimates. Formally \begin{equation} \label{eqn:forward_backward} \begin{split} & t_{b_i} = \frac{t_{b_i, FW} + t_{b_i, BW}}{2} \\ s.t. &\\ & t_{b_i, FW} = \operatornamewithlimits{arg\,min}_{\hat{t}} \sum_{t=t_{b_{i-1}}}^{\hat{t}} d(h_{t}, c_i) + \sum_{t=\hat{t}+1}^{t_{i+1}} d(h_{t}, c_{i+1}), \\ & t_{b_i, BW} = \operatornamewithlimits{arg\,min}_{\hat{t}} \sum_{t=t_i}^{\hat{t}} d(h_{t}, c_i) + \sum_{t=\hat{t}+1}^{t_{b_{i+1}}} d(h_{t}, c_{i+1}). \\ \end{split} \end{equation} \begin{figure}[tb] \centering \includegraphics[trim={0cm 0cm 0cm 1.0cm},clip,width=.9\columnwidth]{pseudo_gt_generic_v2.pdf} \caption{Given the timestamps annotations, we first estimate where the actions change between consecutive timestamps. To generate the frame-wise labels, all the frames that lie between an annotated timestamp and an estimated time of action change are assigned with the same action label as the annotated timestamp.} \label{fig:pseudo_gt} \end{figure} \subsection{Loss Function} \label{sec:loss} Recent fully supervised approaches for action segmentation use a combination of a classification loss and a smoothing loss~\cite{farha2019ms, ishikawa2020alleviating, wang2020boundary}. Besides these losses, we further introduce a novel confidence loss for the timestamp supervision. In the following, we describe in detail each loss function. \textbf{Classification Loss.} We use a cross entropy loss between the predicted action probabilities and the corresponding generated target label \begin{equation}\label{cross entropy} \mathcal{L}_{cls} = \frac{1}{T} \sum_t{-log(\tilde{y}_{t,\hat{a}})}, \end{equation} where $\tilde{y}_{t,\hat{a}}$ is the predicted probability for the target label $\hat{a}$ at time $t$. \textbf{Smoothing Loss.} As the classification loss treats each frame independently, it might result in an undesired over-segmentation effect. To encourage a smooth transition between frames and reduce over-segmentation errors, we use the truncated mean squared error~\cite{farha2019ms} as a smoothing loss \begin{align} \begin{split}\label{smoothingloss} & \mathcal{L}_{T-MSE} = \frac{1}{TC} \sum_{t,a} \Tilde{\Delta}_{t,a}^2, \end{split}\\ \begin{split}\label{trancated} & \Tilde{\Delta}_{t,a}=\left\{ \begin{array}{ll} \Delta_{t,a} &: \Delta_{t,a} \leq \tau \\ \tau &: otherwise \\ \end{array} \right. \end{split},\\ & \Delta_{t,a}=|\log \tilde{y}_{t,a} - \ \log \tilde{y}_{t-1,a}|, \label{logdifferences} \end{align} where $T$ is the video length, $C$ is the number of action classes, and $\tilde{y}_{t,a}$ is the probability of action $a$ at time $t$. \textbf{Confidence Loss.} Our approach relies on the model output to detect action changes. Nonetheless, as some frames are more informative than others, the model confidence might alternate between high and low values within the same action segment. Such behavior might result in ignoring regions with low confidence within the segments. To alleviate this problem, we apply the following loss \begin{align} \begin{split}\label{rankingloss} & \mathcal{L}_{conf} = \frac{1}{T'} \sum_{\substack{a_{t_i} \in A_{TS}}}{\left( \sum_{t=t_{i-1}}^{t_{i+1}}{ \delta_{a_{t_i},t } }\right) }, \end{split}\\ \begin{split}\label{trancatedleft} \delta_{a_{t_i}, t} &=\left\{ \begin{array}{ll} max(0,\ \log \tilde{y}_{t,a_{t_i}} - \ \log \tilde{y}_{t-1,a_{t_i}}) &if\ t \ge t_i \\ max(0,\ \log \tilde{y}_{t-1,a_{t_i}} - \ \log \tilde{y}_{t,a_{t_i}}) &if\ t < t_i \\ \end{array} \right. \end{split}, \end{align} where $\tilde{y}_{t,a_{t_i}}$ is the probability of action $a_{t_i}$ at time $t$, and $T' = 2(t_N-t_1)$ is the number of frames that contributed to the loss. For the first and last timestamps, we set $t_0 = t_1$ and $t_{N+1} = t_{N}$. This loss penalizes an increase in confidence as we deviate from the annotations as illustrated in Fig.~\ref{fig:confidence_loss}. Enforcing monotonicity on the model confidence has two effects as shown in Fig.~\ref{fig:effect_of_conf_loss}. First, it encourages the model to predict higher probabilities for low confident regions that are surrounded by regions with high confidence. Second, it suppresses outlier frames with high confidence that are far from the timestamps and not supported by high confident regions. The final loss function to train the segmentation model is the sum of these three losses \begin{equation}\label{totalloss} \mathcal{L}_{total} = \mathcal{L}_{cls} + \alpha \mathcal{L}_{T-MSE} + \beta \mathcal{L}_{conf}, \end{equation} where $\alpha$ and $\beta$ are hyper-parameters to balance the contribution of each loss. \begin{figure}[tb] \centering \includegraphics[trim={1.4cm 0cm 0cm 0cm},clip,width=.74\columnwidth]{confidence_loss.pdf} \caption{The confidence loss penalizes increases in the model confidence for label $a_{t_i}$ as we move away from the annotated timestamp $t_i$.} \label{fig:confidence_loss} \vspace{-3mm} \end{figure} \section{Experiments} \subsection{Datasets and Metrics} \textbf{Datasets.} We evaluate our approach on four datasets: 50Salads~\cite{stein2013combining}, Breakfast~\cite{kuehne2014language}, BEOID~\cite{damen2014you}, and Georgia Tech Egocentric Activities (GTEA)~\cite{fathi2011learning}. The \textbf{50Salads} dataset contains 50 videos with roughly 0.6M frames, where the frames are annotated with 17 action classes. The videos show actors preparing different kind of salads. We use five-fold cross validation for evaluation and report the average. The \textbf{Breakfast} dataset contains 1712 videos with roughly 3.6M frames, where the frames are annotated with 48 action classes. All actions are related to breakfast preparation activities. We use the standard four splits for evaluation and report the average. The \textbf{BEOID} dataset contains 58 videos, where the frames are annotated with 34 actions classes. For evaluation, we use the same training-testing split as in~\cite{ma2020sf}. The \textbf{GTEA} dataset contains 28 videos with roughly 32K frames, where the frames are annotated with 11 action classes. For evaluation, we report the average of four splits. To generate the timestamps annotations, we randomly select one frame from each action segment in the training videos. We further evaluate our approach using human and noisy annotations in Section~\ref{sec:comparison_with_sota}. Additional settings are evaluated in the supplementary material. \textbf{Metrics.} We use the standard metrics for fully supervised action segmentation and report frame-wise accuracy (Acc), segmental edit distance (Edit) and segmental F1 scores at overlapping thresholds $10\%,\ 25\%$ and $50\%$. \textbf{Baselines.} We implement two baselines: a Naive and a Uniform baseline. The \textbf{Naive} baseline computes the loss at the annotated timestamps only and does not generate frame-wise labels. Whereas the \textbf{Uniform} baseline generates the frame-wise labels by assuming that action labels change at the center frame between consecutive timestamps. \subsection{Implementation Details} \label{sec:implementation_details} We use a multi-stage temporal convolutional network~\cite{farha2019ms} as a segmentation model $\mathcal{M}$. Following~\cite{vats2020event}, we use two parallel stages for the first stage with kernel size $5$ and $3$ and pass the sum of the outputs to next stages. We train our model for 50 epochs with Adam optimizer. To minimize the impact of initialization, only the annotated timestamps are used for the classification loss in the first $30$ epochs, and the generated labels are used afterwards. The learning rate is set to $0.0005$ and the batch size is $8$. For the loss function, we set $\tau=4$, $\alpha=0.15$ as in~\cite{farha2019ms} and set $\beta=0.075$. As input for our model, we use the same I3D~\cite{carreira2017quo} features that were used in~\cite{farha2019ms}. \begin{figure*}[tb] \begin{center} \begin{tabular}{c} \includegraphics[width=.74\linewidth]{quality_salad.pdf} \\ (a) \\ \\ \includegraphics[width=.74\linewidth]{quality_breakfast.pdf} \\ (b) \\ \\ \includegraphics[width=.74\linewidth]{quality_gtea.pdf} \\ (c) \end{tabular} \end{center} \vspace{-4mm} \caption{Qualitative results on (a) 50Salads, (b) Breakfast, and (c) GTEA datasets. As the naive baseline only trains on the sparse annotations, it suffers from an over-segmentation problem. While the uniform baseline reduces this problem by uniformly assigning labels to the frames, the durations of the predicted segments are not accurate and the predictions tend towards a uniform segmentation of the videos. On the contrary, our approach generates better predictions by utilizing the model output to detect where the action labels change.} \label{fig:qualitative_res} \end{figure*} \subsection{Comparison with the Baselines} In this section, we compare the proposed approach for action segmentation from timestamp supervision with the naive and uniform baselines. The results on the three datasets are shown in Table~\ref{tab:baselines}. Our approach outperforms these baselines with a large margin in all the evaluation metrics. While the naive baseline achieves a good frame-wise accuracy, it suffers from a severe over-segmentation problem as indicated by the low F1 and Edit scores. This is because it only uses the sparse timestamps annotations for training, which leaves a lot of ambiguity for frames without annotations. Using the uniform baseline reduces the over-segmentation by uniformly assigning a label for each frame. However, this results in inferior frame-wise accuracy as the uniform assignment generates many wrong labels. On the contrary, our approach utilizes the model predictions to generate much better target labels, which is reflected in the performance as illustrated in Fig.~\ref{fig:qualitative_res}. We also compare the performance of our approach to the fully supervised setup in Table~\ref{tab:baselines}. Our approach achieves comparable performance to the fully supervised case. \begin{table}[tb]\setlength{\tabcolsep}{8pt} \centering \resizebox{.9\columnwidth}{!}{% \begin{tabular}{@{\hskip .2in}l@{\hskip .7in}ccc@{\hskip .2in}c@{\hskip .2in}c} \toprule & \multicolumn{3}{c}{F1@\{10, 25, 50\}} & Edit & Acc \\ \midrule \emph{\textbf{50Salads}} \\ \midrule Naive & 47.9 & 43.3 & 34.0 & 37.2 & 69.6 \\ Uniform & 62.9 & 58.2 & 42.3 & 60.4 & 63.4 \\ Ours &\textbf{73.9} & \textbf{70.9} & \textbf{60.1} & \textbf{66.8} & \textbf{75.6} \\ \hdashline Full Supervision & 70.8 & 67.7 & 58.6 & 63.8 & 77.8 \\ \midrule \emph{\textbf{Breakfast}} \\ \midrule Naive & 34.1 & 29.1 & 20.1 & 37.4 & 56.8 \\ Uniform & 66.2 & 56.3 & 36.4 & 68.1 & 51.0 \\ Ours & \textbf{70.5} & \textbf{63.6} & \textbf{47.4} & \textbf{69.9} & \textbf{64.1} \\ \hdashline Full Supervision & 69.9 & 64.2 & 51.5 & 69.4 & 68.0 \\ \midrule \emph{\textbf{GTEA}} \\ \midrule Naive & 59.7 & 55.3 & 39.6 & 51.1 & 56.5 \\ Uniform & \textbf{78.9} & 72.5 & 50.9 & \textbf{73.1} & 56.5\\ Ours & \textbf{78.9} & \textbf{73.0} & \textbf{55.4} & 72.3 & \textbf{66.4} \\ \hdashline Full Supervision & 85.1 & 82.7 & 69.6 & 79.6 & 76.1 \\ \bottomrule \end{tabular} } \caption{Comparison with the baselines on the three datasets.} \vspace{-4mm} \label{tab:baselines} \end{table} \subsection{Impact of the Loss Function} The loss function to train our model consists of three losses: a classification loss, a smoothing loss, and a confidence loss. Table~\ref{tab:losses} shows the impact of each loss on both the 50Salads and the Breakfast dataset. While either of the smoothing loss and the confidence loss gives an additional boost in performance, the best performance is achieved when both of the losses are combined with the classification loss with a frame-wise accuracy improvement of $2.8\%$ and $3.9\%$ on 50Salads and the Breakfast dataset respectively, and roughly $10\%$ on the F1 score at $50\%$ overlapping threshold. While the smoothing loss forces a smooth transition between consecutive frames, it does not take the annotations into account. On the contrary, the confidence loss forces the predicted probabilities to monotonically decrease as the distance to the timestamps increases. This encourages the model to have a high confidence for all frames within an action segment, and yet it suppresses outlier frames that are far from the annotations and not supported by regions with high confidence as illustrated in Fig.~\ref{fig:effect_of_conf_loss}. To balance the contribution of the different losses, we set the weight of the smoothing loss to $0.15$ as in~\cite{farha2019ms}, and the weight of the confidence loss $\beta = 0.075$. In Table~\ref{tab:beta}, we study the impact of $\beta$ on the performance on the 50Salads dataset. As shown in the table, good results are achieved for $\beta$ between $0.05$ and $0.1$. \begin{table}[tb]\setlength{\tabcolsep}{8pt} \centering \resizebox{.9\columnwidth}{!}{% \begin{tabular}{lccccc} \toprule & \multicolumn{3}{c}{F1@\{10, 25, 50\}} & Edit & Acc \\ \midrule \emph{\textbf{50Salads}} \\ \midrule $\mathcal{L}_{cls}$ & 65.7 & 62.6 & 50.7 & 57.7 & 72.8 \\ $\mathcal{L}_{cls} + \alpha \mathcal{L}_{T-MSE}$ & 70.1 & 66.8 & 55.3 & 62.6 & 74.6 \\ $\mathcal{L}_{cls} + \beta \mathcal{L}_{conf}$ & 73.2 & 70.6 & 60.1 & 65.2 & 75.3 \\ $\mathcal{L}_{cls} + \alpha \mathcal{L}_{T-MSE} + \beta \mathcal{L}_{conf}$ & \textbf{73.9} & \textbf{70.9} & \textbf{60.1} & \textbf{66.8} & \textbf{75.6} \\ \midrule \emph{\textbf{Breakfast}} \\ \midrule $\mathcal{L}_{cls}$ & 60.3 & 52.8 & 36.7 & 64.2 & 60.2 \\ $\mathcal{L}_{cls} + \alpha \mathcal{L}_{T-MSE}$ & 67.5 & 60.1 & 44.3 & 68.9 & 63.7 \\ $\mathcal{L}_{cls} + \beta \mathcal{L}_{conf}$ & 67.6 & 60.4 & 43.7 & 68.0 & 61.6 \\ $\mathcal{L}_{cls} + \alpha \mathcal{L}_{T-MSE} + \beta \mathcal{L}_{conf}$ & \textbf{70.5} & \textbf{63.6} & \textbf{47.4} & \textbf{69.9} & \textbf{64.1} \\ \bottomrule \end{tabular} } \caption{Contribution of the different loss functions on the 50Salads and Breakfast datasets.} \label{tab:losses} \end{table} \begin{table}[tb]\setlength{\tabcolsep}{10pt} \centering \resizebox{.85\columnwidth}{!}{% \begin{tabular}{@{\hskip .2in}l@{\hskip 0.5in}ccc@{\hskip .2in}c@{\hskip .2in}c} \toprule & \multicolumn{3}{c}{F1@\{10, 25, 50\}} & Edit & Acc \\ \midrule $\beta = 0$ & 70.1 & 66.8 & 55.3 & 62.6 & 74.6 \\ $\beta = 0.025$ & 70.9 & 68.8 & 57.4 & 63.4 & \textbf{76.2} \\ $\beta = 0.05$ & 73.1 & 70.2 & 58.7 & 65.4 & 75.6 \\ $\beta = 0.075$ & \textbf{73.9} & \textbf{70.9} & \textbf{60.1} & \textbf{66.8} & 75.6 \\ $\beta = 0.1$ & 73.2 & 70.6 & \textbf{60.1} & 66.1 & 74.6 \\ \bottomrule \end{tabular} } \caption{Impact of $\beta$ on the 50Salads dataset.} \vspace{-4mm} \label{tab:beta} \end{table} \subsection{Impact of the Energy Function for Action Change Detection} Our approach generates target labels by estimating where the action labels change using the forward-backward estimate as in (\ref{eqn:forward_backward}). To analyze the impact of this estimate, we train another model that directly uses the stamp-to-stamp estimate (Stamp-to-Stamp (Features)) as in (\ref{eqn:s2s_energy}). As shown in Table~\ref{tab:forward_backward}, our approach performs better. We also tried another variant of the stamp-to-stamp energy function that maximizes the average probabilities of the action segments (Stamp-to-Stamp (Prob.)) instead of minimizing the distances to cluster centers. However, the performance is worse than the proposed energy function. \begin{figure}[tb] \centering \begin{tabular}{c} \includegraphics[trim={0.8cm 0cm 0cm 0cm},clip,width=.7\columnwidth]{conf_loss_effect.pdf} \\ (a) \\ \includegraphics[trim={0.8cm 0cm 0cm 0cm},clip,width=.7\columnwidth]{conf_loss_effect_2.pdf} \\ (b) \end{tabular} \caption{Impact of the confidence loss. Forcing monotonicity encourages the model to have a high confidence for all frames within an action segment (a). It also suppresses outlier frames with high confidence (b).} \label{fig:effect_of_conf_loss} \vspace{-3mm} \end{figure} \begin{table}[tb]\setlength{\tabcolsep}{8pt} \centering \resizebox{.9\columnwidth}{!}{% \begin{tabular}{lccccc} \toprule & \multicolumn{3}{c}{F1@\{10, 25, 50\}} & Edit & Acc \\ \midrule \emph{\textbf{50Salads}} \\ \midrule Stamp-to-Stamp (Prob.) & 67.5 & 61.8 & 48.6 & 61.1 & 68.9 \\ Stamp-to-Stamp (Features) & 73.4 & 70.5 & 59.9 & 66.7 & 74.2 \\ Ours &\textbf{73.9} & \textbf{70.9} & \textbf{60.1} & \textbf{66.8} & \textbf{75.6} \\ \midrule \emph{\textbf{Breakfast}} \\ \midrule Stamp-to-Stamp (Prob.) & 65.7& 55.9 & 35.9 & 68.0 & 58.8 \\ Stamp-to-Stamp (Features) & 66.3 & 59.6 & 44.4 & 67.9 & 60.1 \\ Ours & \textbf{70.5} & \textbf{63.6} & \textbf{47.4} & \textbf{69.9} & \textbf{64.1} \\ \bottomrule \end{tabular} } \caption{Impact of the energy function for action change detection on the 50Salads and Breakfast datasets.} \label{tab:forward_backward} \end{table} \subsection{Impact of the Segmentation Model $\mathcal{M}$} In all experiments, we used a multi-stage temporal convolutional architecture based on~\cite{farha2019ms} and~\cite{vats2020event}. In this section we study the impact of the segmentation model on the performance. To this end, we apply the proposed training scheme on the original MS-TCN~\cite{farha2019ms} and the recently introduced MS-TCN++~\cite{li2020ms}. As shown in Table~\ref{tab:impact_of_seg_model}, our approach is agnostic to the segmentation model and performs well with all these models. \begin{table}[tb] \centering \resizebox{.9\columnwidth}{!}{% \begin{tabular}{clccccc} \toprule Dataset & Seg. Model $\mathcal{M}$ & \multicolumn{3}{c}{F1@\{10, 25, 50\}} & Edit & Acc \\ \midrule 50Salads & MS-TCN~\cite{farha2019ms} & 71.7 & 68.7 & 57.0 & 64.0 & 74.7 \\ & MS-TCN++~\cite{li2020ms} & 75.0 & 71.1 & 55.8 & 67.2 & 72.9 \\ & Ours & 73.9 & 70.9 & 60.1 & 66.8 & 75.6 \\ \midrule GTEA & MS-TCN~\cite{farha2019ms} & 79.8 & 73.3 & 47.7 & 76.3 & 59.3\\ & MS-TCN++~\cite{li2020ms} & 78.3 & 72.2 & 49.1 & 74.5 & 62.2 \\ & Ours & 78.9 & 73.0 & 55.4 & 72.3 & 66.4 \\ \bottomrule \end{tabular} } \caption{Impact of the segmentation model $\mathcal{M}$ on the 50Salads and GTEA datasets.} \vspace{-3mm} \label{tab:impact_of_seg_model} \end{table} \subsection{Comparison with the State-of-the-Art} \label{sec:comparison_with_sota} In this section, we compare our approach with recent state-of-the-art approaches for timestamp supervision. To the best of our knowledge, timestamp supervision has not been studied for the temporal action segmentation task. We, therefore, compare with similar methods in the context of action recognition~\cite{moltisanti2019action} and action localization~\cite{ma2020sf}. Since the approach of~\cite{moltisanti2019action} assumes the testing videos are trimmed and does not work for long untrimmed videos, we replaced their backbone network with our segmentation model for a fair comparison. To this end, we initialized the plateau functions around the timestamps annotations of the training videos and iteratively update their parameters based on the segmentation model output as in~\cite{moltisanti2019action}. Results for the 50Salads, Breakfast, and GTEA datasets are shown in Tables~\ref{tab:conparison50salads}-\ref{tab:conparisonGTEA}, respectively. Our approach outperforms~\cite{moltisanti2019action} on all datasets with a large margin of up to $13.5\%$ frame-wise accuracy and $11.8\%$ for the F1 score with $50\%$ overlapping threshold on the GTEA dataset. We also compare our approach for timestamp supervision with other levels of supervision for the temporal action segmentation task. As shown in Tables~\ref{tab:conparison50salads}-\ref{tab:conparisonGTEA}, timestamp supervision outperforms weaker levels of supervision in the form of transcripts or sets with a large margin. Our approach provides a good compromise between annotation effort and performance, and further reduces the gap to fully supervised approaches. \begin{table}[tb] \centering \resizebox{.9\columnwidth}{!}{% \begin{tabular}{clccccc} \toprule Supervision & Method & \multicolumn{3}{c}{F1@\{10, 25, 50\}} & Edit & Acc \\ \midrule Full & MS-TCN~\cite{farha2019ms} & 76.3 & 74.0 & 64.5 & 67.9 & 80.7 \\ & MS-TCN++~\cite{li2020ms} & 80.7 & 78.5 & 70.1 & 74.3 & 83.7 \\ & BCN~\cite{wang2020boundary} & 82.3 & 81.3 & 74.0 & 74.3 & 84.4 \\ & ASRF~\cite{ishikawa2020alleviating} & 84.9 & 83.5 & 77.3 & 79.3 & 84.5 \\ \midrule Timestamps & \footnotesize{Seg. Model $\mathcal{M}$ + plateau~\cite{moltisanti2019action}} & 71.2 & 68.2 & 56.1 & 62.6 & 73.9 \\ & Ours & \textbf{73.9} & \textbf{70.9} & \textbf{60.1} & \textbf{66.8} & \textbf{75.6} \\ \midrule Transcripts & CDFL~\cite{li2019weakly} & - & - & - & - & 54.7 \\ & NN-Viterbi~\cite{richard2018neuralnetwork} & - & - & - & - & 49.4 \\ & HMM-RNN~\cite{richard2017weakly} & - & - & - & - & 45.5 \\ \bottomrule \end{tabular} } \caption{Comparison with different levels of supervision on the 50Salads dataset.} \label{tab:conparison50salads} \vspace{-0.5mm} \end{table} \begin{table}[tb] \centering \resizebox{.9\columnwidth}{!}{% \begin{tabular}{clccccc} \toprule Supervision & Method & \multicolumn{3}{c}{F1@\{10, 25, 50\}} & Edit & Acc \\ \midrule Full & MS-TCN~\cite{farha2019ms} & 52.6 & 48.1 & 37.9 & 61.7 & 66.3 \\ & MS-TCN++~\cite{li2020ms} & 64.1 & 58.6 & 45.9 & 65.6 & 67.6 \\ & BCN~\cite{wang2020boundary} & 68.7 & 65.5 & 55.0 & 66.2 & 70.4 \\ & ASRF~\cite{ishikawa2020alleviating} & 74.3 & 68.9 & 56.1 & 72.4 & 67.6 \\ \midrule Timestamps & \footnotesize{Seg. Model $\mathcal{M}$ + plateau~\cite{moltisanti2019action}} & 65.5 & 59.1 & 43.2 & 65.9 & 63.5 \\ & Ours & \textbf{70.5} & \textbf{63.6} & \textbf{47.4} & \textbf{69.9} & \textbf{64.1} \\ \midrule Transcripts & CDFL~\cite{li2019weakly} & - & - & - & - & 50.2 \\ & MuCon~\cite{souri2019fast} & - & - & - & - & 47.1 \\ & D$^{3}$TW~\cite{chang2019d3tw} & - & - & - & - & 45.7 \\ & NN-Viterbi~\cite{richard2018neuralnetwork} & - & - & - & - & 43.0 \\ & TCFPN~\cite{ding2018weakly} & - & - & - & - & 38.4 \\ & HMM-RNN~\cite{richard2017weakly} & - & - & - & - & 33.3 \\ & ECTC~\cite{huang2016connectionist} & - & - & - & - & 27.7 \\ \midrule Sets & SCT~\cite{fayyaz2020set} & - & - & - & - & 30.4 \\ & SCV~\cite{li2020set} & - & - & - & - & 30.2 \\ & Action Sets~\cite{richard2018action} & - & - & - & - & 23.3 \\ \bottomrule \end{tabular} } \caption{Comparison with different levels of supervision on the Breakfast dataset.} \label{tab:conparisonbreakfast} \vspace{-0.5mm} \end{table} \begin{table}[tb] \centering \resizebox{.9\columnwidth}{!}{% \begin{tabular}{clccccc} \toprule Supervision & Method & \multicolumn{3}{c}{F1@\{10, 25, 50\}} & Edit & Acc \\ \midrule Full & MS-TCN~\cite{farha2019ms} & 85.8 & 83.4 & 69.8 & 79.0 & 76.3 \\ & MS-TCN++~\cite{li2020ms} & 88.8 & 85.7 & 76.0 & 83.5 & 80.1 \\ & BCN~\cite{wang2020boundary} & 88.5 & 87.1 & 77.3 & 84.4 & 79.8 \\ & ASRF~\cite{ishikawa2020alleviating} & 89.4 & 87.8 & 79.8 & 83.7 & 77.3 \\ \midrule Timestamps & \footnotesize{Seg. Model $\mathcal{M}$ + plateau~\cite{moltisanti2019action}} & 74.8 & 68.0 & 43.6 & \textbf{72.3} & 52.9 \\ & Ours & \textbf{78.9} & \textbf{73.0} & \textbf{55.4} & \textbf{72.3} & \textbf{66.4}\\ \bottomrule \end{tabular} } \caption{Comparison with different levels of supervision on the GTEA dataset.} \label{tab:conparisonGTEA} \vspace{-3mm} \end{table} Timestamp supervision has recently been studied for action localization in~\cite{ma2020sf}. In their approach, they use the model confidence to sample foreground action frames and background frames for training. To compare with~\cite{ma2020sf}, we use the same setup and the provided human annotations to train our model and report mean average precision at different overlapping thresholds. Table~\ref{tab:sfnetmap} shows the results on the GTEA and BEOID~\cite{damen2014you} datasets. Our approach outperforms Ma~\etal~\cite{ma2020sf} with a large margin of $5.4\%$ average mAP on GTEA and $4.3\%$ on the BEOID dataset. In contrast to~\cite{ma2020sf} where only the frames with high confidence are used for training, our approach detects action changes and generates a target label for each frame in the training videos. Finally, we compare our approach with the semi-supervised setup on the Breakfast dataset proposed in Kuehne~\etal~\cite{kuehne2020hybrid}. In this setup, the training videos are annotated with the transcript of actions and a fraction of the frames as well. Compared to the timestamp supervision, this setup provides annotations for much more frames. Since the timestamps are randomly sampled from the video, there are sometimes multiple timestamps for one action and not all actions are annotated as reported in the supplementary material. As shown in Table~\ref{tab:semi_sup}, our approach outperforms~\cite{kuehne2020hybrid} with a large margin. While the approach of~\cite{kuehne2020hybrid} relies on an expensive Viterbi decoding during inference, our approach directly predicts the frame-wise labels. \begin{table}[tb]\setlength{\tabcolsep}{8pt} \centering \resizebox{.77\columnwidth}{!}{% \begin{tabular}{@{\hskip .3in}l@{\hskip .5in}ccccc} \toprule mAP@IoU & 0.1 & 0.3 & 0.5 & 0.7 & Avg \\ \midrule \emph{\textbf{GTEA}} \\ \midrule SF-Net~\cite{ma2020sf} & 58.0 & 37.9 & 19.3 & 11.9& 31.0 \\ Ours & \textbf{60.2} & \textbf{44.7} & \textbf{28.8} & \textbf{12.2} & \textbf{36.4} \\ \midrule \emph{\textbf{BEOID}} \\ \midrule SF-Net~\cite{ma2020sf} & 62.9 & \textbf{40.6} & 16.7 & 3.5 & 30.1 \\ Ours & \textbf{71.5} & 40.3 & \textbf{20.3} & \textbf{5.5} & \textbf{34.4} \\ \bottomrule \end{tabular} } \caption{Comparison with SF-Net~\cite{ma2020sf} for action localization with timestamp supervision on the GTEA and BEOID datasets.} \label{tab:sfnetmap} \end{table} \begin{table}[tb]\setlength{\tabcolsep}{24pt} \centering \resizebox{.78\columnwidth}{!}{% \begin{tabular}{clc} \toprule Fraction & Method & Acc \\ \midrule 0.1 & HMM-RNN~\cite{kuehne2020hybrid} & 60.9 \\ & Ours & \textbf{68.4} \\ \midrule 0.01 & HMM-RNN~\cite{kuehne2020hybrid} & 58.8 \\ & Ours & \textbf{67.4} \\ \bottomrule \end{tabular} } \caption{Comparison with Kuehne~\etal~\cite{kuehne2020hybrid} on the Breakfast dataset with semi-supervised setup.} \label{tab:semi_sup} \vspace{-3mm} \end{table} \section{Conclusion} In this paper, we proposed an approach to train a temporal action segmentation model using only timestamps annotations. Our approach combines the model predictions with the timestamps annotations for estimating where the action labels change. We further introduced a confidence loss that enforces monotonicity on the model confidence. The loss encourages high confidence values for all frames within an action segment and suppresses outlier frames. Results on four datasets show that models trained with timestamp supervision achieve comparable performance to the fully supervised setup. The proposed approach is model agnostic and can be applied to any segmentation model. \small{\noindent\textbf{\\Acknowledgements:} The work has been funded by the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) – GA 1927/4-2 (FOR 2535 Anticipating Human Behavior) and the ERC Starting Grant ARCA (677650).} \clearpage \input{supplementary_material} \clearpage {\small \bibliographystyle{ieee_fullname} \section*{Supplementary Material} \def\Alph{section}{\Alph{section}} \renewcommand{\thetable}{\Alph{table}} \setcounter{section}{0} \setcounter{table}{0} \hyphenation{time-stamp} \hyphenation{time-stamps} We evaluate our model on additional settings for generating the timestamps annotations. We further analyze the impact of noise on the performance. \section{Frame Selection for the Timestamp Annotations} In the paper, we randomly select one frame from each action segment in the training videos. Table~\ref{tab:ts_annotations} shows results for two additional settings. While using the center frame of each segment achieves comparable results to a random frame, the performance drops when the start frame is used. Humans, however, would not annotate the start frame since it is more ambiguous (see Fig.~4 in~\cite{ma2020sf}). \begin{table}[ht]\setlength{\tabcolsep}{8pt} \centering \resizebox{.8\columnwidth}{!}{% \begin{tabular}{@{\hskip .1in}l@{\hskip .5in}ccc@{\hskip .2in}c@{\hskip .2in}c} \toprule Timestamps & \multicolumn{3}{c}{F1@\{10, 25, 50\}} & Edit & Acc \\ \midrule Start frame & 65.5 & 52.2 & 28.0 & 70.4 & 51.2 \\ Center frame & \textbf{70.8} & 63.5 & 45.4 & \textbf{71.3} & 61.3 \\ Random & 70.5 & \textbf{63.6} & \textbf{47.4} & 69.9 & \textbf{64.1} \\ \bottomrule \end{tabular} } \caption{Using start, center, or random frame as timestamp for each action on the Breakfast dataset.} \label{tab:ts_annotations} \end{table} \section{Human Annotations vs Generated Annotations} In Table~\ref{tab:gtea}, we directly compare the human annotations from~\cite{ma2020sf} with simulated annotations on the GTEA dataset. The results show that the performance with random sampling is very close to real annotations. \begin{table}[ht]\setlength{\tabcolsep}{8pt} \centering \resizebox{.8\columnwidth}{!}{% \begin{tabular}{@{\hskip .1in}l@{\hskip .3in}ccccc} \toprule mAP@IoU & 0.1 & 0.3 & 0.5 & 0.7 & Avg \\ \midrule Human annotations & \textbf{60.2} & 44.7 & \textbf{28.8} & \textbf{12.2} & \textbf{36.4} \\ Random sampling & 59.7 & \textbf{46.3} & 26.0 & 10.4 & 35.6 \\ \bottomrule \end{tabular} } \caption{Human vs.\ generated annotations on the GTEA dataset.} \label{tab:gtea} \end{table} \section{Impact of Noise} In Table~10 in the paper, the timestamps are randomly sampled from the videos. Thus, there are sometimes multiple timestamps for one action and not all actions are annotated. Table~\ref{tab:semi_sup} shows the percentage of action segments with 0, 1, or $>$1 timestamps (TS). As shown in the table, our approach is robust to annotation errors. \begin{table}[ht] \centering \resizebox{.9\columnwidth}{!}{% \begin{tabular}{c|ccc|c} \toprule Fraction & \% actions with 0 TS & \% with 1 TS & \% with $>$ 1 TS & Acc \\ \midrule 0.1 & 3.5 & 3.4 & 93.1 & 68.4 \\ 0.01 & 27.5 & 21.6 & 50.9 & 67.4 \\ 0.0032 & 49.0 & 25.2 & 25.8 & 61.7 \\ 0.0032 & 0 & 100 & 0 & 64.1 \\ \bottomrule \end{tabular} } \caption{Percentage of actions with 0, 1, or $>$1 timestamps (TS) using the protocol of Table~10. The last row is the protocol of Table~7. } \label{tab:semi_sup} \end{table}
{'timestamp': '2021-03-29T02:22:49', 'yymm': '2103', 'arxiv_id': '2103.06669', 'language': 'en', 'url': 'https://arxiv.org/abs/2103.06669'}
arxiv
\section{Introduction} \vspace{-0.05cm} System-Level Test (SLT) has emerged as an important additional test insertion in today’s semiconductor lifecycle \cite{Che:18}. It is run by the circuit manufacturer in the final stage of production or by the buyer of the circuit, e.g., an automotive Tier-1 supplier who will integrate the circuit into a product, as part of incoming quality control. SLT can also be used during the post-silicon characterization phase where a circuit's extra-functional properties are measured on a population of several hundreds or thousands ``first-silicon'' circuits. Conventional structural and functional test methods are based on established theoretical concepts, such as fault models, detection and detectability concepts, coverages. A plethora of algorithms have been invented (and tools implementing these algorithms developed) in the last decades. SLT lacks much of this fundamental understanding; in fact, even the very term ``system-level test'' is being used in rather different meanings. This paper aims at making first steps towards laying solid theoretical foundations for SLT. Specifically, it discusses the following questions: \begin{itemize} \item What precisely is SLT that is being used in semiconductor testing? How does it differ from the traditional structural and functional test approaches? \item What are possible reasons for \emph{SLT-unique fails}, i.e., failures observed during SLT in circuits that passed structural and functional tests during earlier test insertions? \item How to determine the root cause of a failure during SLT, in absence of established diagnostic methods? \item How can knowledge from the software engineering domain, e.g., on coverage definitions or on stress test generation, be \end{itemize} In the remainder of the paper, we describe our current knowledge with respect to these questions, touching on related scientific disciplines where necessary. Not all questions have a known answer, and we see it as our objective to capture and discuss the currently discussed explanations or hypotheses, even if they are controversial or contradictory. \section{System-Level Test} \label{sec:slt} \subsection{What is SLT?} The term ``system-level test'' (SLT) can stand for different types of testing. In the context of integrated circuits (ICs), the following three meanings are predominant: \begin{enumerate} \item Test of a whole system (e.g., a smartphone or an automotive electronic control unit), focusing on interactions between its components: ICs, sensors, mechanical parts, and the like. \item Incoming quality control of ICs by a system integrator, to sort out defective ICs and to uncover systematic quality problems of a supplier. The ICs under test are put on a board that imitates the full-system setup and applies to the IC a workload that mimics real-life operation. \item Outgoing quality control by the IC manufacturer to prevent defective ICs from delivery and to reinforce its own quality control. The procedure is similar to 2), except that the IC manufacturer has less knowledge about the full-system setup but more knowledge about the manufactured IC. \end{enumerate} \begin{figure} \includegraphics[width=0.99\columnwidth]{fig1-flow} \caption{SLT within the quality-assurance flow} \label{fig:flow} \end{figure} In this paper, we focus on scenario 3), even though most findings are directly applicable to scenario 2). We do not consider scenario 1), where a failing test can point to a defect in one of the system's ICs, to a defect in a different component, or to an erroneous integration. In the SLT scenarios considered here, the system around the IC is assumed to work, and the purpose of testing is to determine whether the IC is defective or not. Fig.~\ref{fig:flow} visualizes the role of SLT \emph{within the IC manufacturer's quality assurance}, i.e., before the circuit has been shipped to a customer. While there is no precise definition of ``system-level test'', it usually refers to applying to the device under test (usually, a complex system-on-chip IC) workloads that originate from its intended usage. A popular SLT example is booting an operating system and running several software applications known to stress the system; if the system does not behave as expected (e.g., it crashes), SLT has found a failure. This implies that there is currently no test specification and generation process for SLT: the workload comes from an application scenario. This may change in the future; for example, Chen \cite{Che:18} proposes to use automatically generated design-validation scenarios based on the \emph{Portable Test and Stimulus Standard} (PSS) flow. \subsection{SLT-induced Costs and Complexities} SLT's benefits are offset by its costs. As it is obvious from Fig.~\ref{fig:flow}, SLT is an additional test insertion that also requires special hardware. The device under test usually needs to be mounted on an evaluation board which includes memories, peripherals and interfaces necessary to run the intended workloads. It is often impossible to perform SLT on regular test equipment that does not include such features, but specialized SLT testers are available. Companies are currently investing in deploying SLT-oriented tester architectures that can be re-used (at least partly) over different products. In this scenario, the more diversified a company's products are, the more they profit from the re-usability of dedicated SLT testers \cite{ATS:5034}. Another SLT cost factor is its very long test application time in the range of several minutes, a multiple of prior test insertions \cite{Che:18,Sin:19,BRR+:20sh}. This has triggered interest in \emph{adaptive test} methods, where SLT is applied only for a subset of circuits determined during earlier test insertions \cite{LTGW:18sh}. For example, Singh \cite{Sin:19} (motivated by industrial data reported in \cite{HHM+:20sh}) proposes to assign the circuits to bins based on their timing variability observed during pre-SLT test insertions. Every bin corresponds to a certain expected test quality, quantified by the number of defective circuits that will go undetected if no SLT is applied (\emph{defective parts per million} or DPPM). The expected DPPM contribution for each bin is established by a predictive model created by machine-learning from previous experiences. SLT is skipped for circuits from ``non-critical'' bins associated with (predicted) DPPM contribution below the desired DPPM target. When considering application areas where Burn-In test is required (e.g., automotive), cost reduction can be achieved by combining Burn-In test and SLT. In this case, the tester infrastructure developed for Burn-In (characterized by high parallelism) can be adapted to account for SLT requirements as well \cite{ABC+:19sh}. \begin{table*} \caption{SLT compared with structural and functional test} \label{tab:slt} \centering \begin{tabular}{@{}|@{\hspace{0.2cm}}p{0.15\textwidth}@{\hspace{0.19cm}}|@{\hspace{0.2cm}}p{0.2\textwidth}@{\hspace{0.19cm}}|@{\hspace{0.2cm}}p{0.31\textwidth}@{\hspace{0.19cm}}|@{\hspace{0.2cm}}p{0.25\textwidth}@{\hspace{0.19cm}}|@{}} \hline \multicolumn{1}{@{}|@{\hspace{0.19cm}}l|@{\hspace{0.2cm}}}{\bf Aspect} & \multicolumn{1}{@{\hspace{0.2cm}}c|@{\hspace{0.2cm}}}{\bf Structural Test} & \multicolumn{1}{@{\hspace{0.2cm}}c|@{\hspace{0.2cm}}}{\bf Functional Test} & \multicolumn{1}{c|}{\bf System-Level Test} \\\hline Level of abstraction & Gate level, sometimes incorporating additional information from layout or RTL & Instruction set architecture & None explicitly considered \\\hline Main stimuli format & 0/1 values at circuit’s inputs / scan flops & Assembly programs & Application or operating system code \\\hline Test application & ATE; BIST & ATE; Software-based self-test (from cache) & Evaluation board; SLT tester \\\hline Test generation & Fault-oriented ATPG; manual & Manually created test programs; automated techniques & Reuse of verification stimuli; applications; operating system \\\hline Quality metrics & Fault coverage & Instruction coverage; fault coverage; coverage used in validation domain & Representative application (no explicit metric) \\\hline How assessed? & Fault simulation; sometimes electrical simulation (Spice) of selected patterns & Instruction set level simulation, sometimes fault simulation & No systematic approach available \\\hline What defects covered? & Gross and marginal defects represented by considered fault models and beyond & Defects not targeted by structural tests (e.g., small memories without BIST); complex defects missed by structural tests; variability; defects triggered by complex interactions within processor; a major advantage of functional test compared to structural test is the fact that it is performed at speed & Defects missed by structural and functional tests; asynchronous or analog interfaces; clock-gating logic; clock domain boundaries; unknowns (Xes); timing-related failures in uncore logic \\ \hline \end{tabular} \end{table*} Fine-grained adaptive testing based on quality prediction can also be used to select a subset of chips that must undergo SLT for high-volume production~\cite{Liu:ITC2019, Liu:TODAES2020}. This strategy includes two key steps. In the first step, parametric test results from an early test insertion are used to train a machine-learning model, which can predict the quality of each chip. A random-forest model is used for quality prediction; the parametric test results of the previous test insertion are used as independent variables, and binary pass/fail results of the current test insertion are used as dependent variables. In the second step, based on the predicted quality, chips are partitioned into two groups using k-means clustering. Test selection is performed for each group individually. SLT can be limited to chips that are predicted to be of low quality. It is shown in~\cite{Liu:ITC2019, Liu:TODAES2020} using data from three lots, including 71 wafers and 230,000 dies, that fine-grained adaptive testing reduces test cost by up to 7\% for a lot, and by as much as 90\% for low-quality chips. Moreover, experimental results also show a strong correlation between the predicted quality and marginality of the test outcomes. Therefore, the quality-prediction model can be further used to predict the occurrence of early-life failures. \subsection{SLT vs.~Conventional Testing} It helps the understanding of SLT to contrast its properties with conventional structural and functional test approaches. Table \ref{tab:slt} summarizes the discussion below and in the subsequent sections. The main difference between SLT and \emph{structural test} is that the latter is strongly based on the notion of a fault according to a \emph{fault model}. Although fault models defined on various levels of abstraction have been introduced in the past \cite{NGB:99,YH:06sh}, most popular models (including stuck-at, bridging and most delay fault models) work on gate level. The stimuli used during testing are usually test patterns either applied through scan infrastructure by automated test equipment (ATE) or generated on-chip by built-in self-test (BIST) or test-compression logic. These patterns are usually produced by automatic test pattern generation (ATPG) procedures that target specific faults. The resulting test set has a fault coverage (number of detected divided by the number of all modeled faults), and there are efficient fault-simulation tools that determine fault coverage. In contrast, SLT fault models are currently lacking, even though first ideas to define an ``SL-FM'' and to use it to guide ``SL-TG'' to generate PSS scenarios for use in SLT are discussed in \cite{Che:18}. Moreover, the application of conventional fault models, such as stuck-at faults, to SLT is practically infeasible because it would necessitate simulation of very long (billions of clock cycles) SLT sequences for every considered fault. Regarding the test quality, there is no serious discussion of skipping structural test altogether, replacing it with SLT. Structural tests, in addition to covering defects directly represented by the detected faults, usually also detect a large number of unmodeled defects (``fortuitious detection''), such as manifestations of crosstalk or power-supply noise \cite{WGB:04sh,Pol:10}. Therefore, the ``baseline DPPM level'' is provided by structural tests (it depends on the accuracy of the fault models and the throughness of ATPG). SLT is considered as an additional test insertion if this DPPM level is higher than required by a given application. The differentiation between \emph{functional test} and SLT is more subtle; in fact, many publications simply treat SLT as a sub-type of functional test \cite{Che:18}. However, we believe that there are serious differences between the ``traditional'' functional test \cite{MHB:00} and SLT. The former is based on running relatively small test programs, usually stored in a microprocessor's cache and written, at least partially, in assembly language. Such programs can be created manually, using evolutionary techniques \cite{SSR+:05sh} or even deterministic test sequence generation \cite{RCS+:16sh}. Functional test programs can be (and are) assessed with respect to detection of traditional gate-level fault models (stuck-at, delay faults, and the like) or special instruction-set level fault models \cite{TA:80}. As was discussed above, meaningful SLT sequences are far too long to be assessed using these fault models or generated by ATPG. A meaningful coverage metric or any other systematic approach to decide whether an SLT suite is ``good enough'' is currently lacking (see Section \ref{sec:cov} for some ideas to this end). In many cases, the functional test (which plays also a major role when considering in-field test) is developed targeting single modules in the IC (CPU, peripherals, memories, interconnections). Hence, it basically aims at checking the correct behavior of each single module in an isolated manner. At the same time, one target of SLT is to check whether the whole device works correctly, exploring for example the effects induced by the interactions among modules. Among the different phenomena triggered by SLT, temperature-related ones play a major role: cases have been reported, where a given defect in an interconnection was only triggered when the temperature gradient between two modules was exceeding a given threshold. Clearly, this kind of defects can hardly be detected by anything different than SLT. An interesting question is whether functional test and SLT detect the same classes of defects. Both aim at closing the coverage holes of structural tests, and yet one would expect that the expensive SLT would not be applied if the desired test quality were achievable by simpler functional tests alone. One reason for SLT's superiority might be its sheer huge number of test patterns being applied to the circuit during its billions of clock cycles, resulting in a higher chance of fortuitous detections. However, SLT may have systematic advantages, as it is defined on SoC level and incorporates functional interactions between the microprocessor and other SoC components, while functional test tends to focus on the microprocessor itself. For an ultimate answer to this question (and possibly, options to shift some of the detections from SLT to previous insertions), the nature of SLT-unique fails should be better understood. The next section discusses our current understanding of SLT-unique fails. \subsection{Debug and Diagnosis in SLT Context} \label{sec:diag} When doing SLT, determining the root cause of an observed failure is more difficult than for conventional testing, where efficient diagnosis methods \cite{VD:01,HW:09sh} are available. As will be discussed further below, the exact nature of failures observed during SLT is not always clear, and the manifestation of a failure (e.g., a crash) may happen thousands of cycles after its occurrence. Post-silicon validation features such as trace buffers \cite{IGTF:17} or ``quick error detection'' logic \cite{LHL+:14sh} can alleviate this problem. It was proposed in \cite{RHC:19sh} to use machine learning to establish a relationship between SLT failures and values of over one hundred check status registers within a server-grade processor SoC. The key idea in~\cite{RHC:19sh} is to use a support-vector machine (SVM) to classify SLT failures in the Intel Skylake SoC into one of 18 classes, where each class corresponds to a candidate faulty core or group of cores in the chip. The SVM model was trained using a small number (1,000) of manually created training vectors. A drawback of this approach is that the training data has to be generated manually. Such a manual approach obviously is not practical for high-volume production tests. While it is desirable to use actual fail data from SLT to train the model, a challenge in this context is that SLT fails are ``rare events'', and it would take a considerable amount of time to generate a sufficient amount of fail data to train the model. An attractive alternative in this context is to leverage transfer learning techniques and methods for root-cause localization methods using streaming data that have been developed for board-level fault diagnosis~\cite{Liu:ITC2019,Liu:VTS2019sh}. Machine learning-based fault-identification models exploit knowledge from test results and corresponding ground-truth data, without requiring a detailed understanding of the complex functionality of chips. This problem can be formulated as a \emph{supervised classification} problem, where a complete set of learning data consisting of pairs $f(x; y)$. Each instance $x$ is associated with a unique label $y$, and we refer to each instance-label pair $(x; y)$ as a \emph{sample}. In our application, since different chips may have different fault candidates, we train a binary classifier to diagnose each target fault. The learning algorithm constructs a classifier that outputs a class prediction for a given instance. In a typical SLT scenario, only a limited amount of test fallout data arrives in the early stages of manufacturing. In fact, fallout data and then associated ground truth about root-cause localization arrives in a streaming format characterized by a potentially large volumes of data instances. As a result, the diagnosis accuracy tends to be low in the early stages of manufacturing. Compared to a static test and diagnosis flow, processing data streams imposes two new requirements on diagnosis algorithms: (1) the ability to adapt to concept drift, and (2) the availability of a limited amount of memory. Online incremental learning algorithms have been proposed for handling streaming data, and to deal with concept drift, classifiers implement forgetting, adaptation and drift detection mechanisms. To overcome the challenge of limited memory, classifiers record only the key information extracted from the previous round of streaming data instead of all the past samples. Moreover, classifiers can learn the target concepts incrementally instead of training from scratch to save training time. By executing online learning algorithms for streaming data, the trained model predicts more accurately when the data distributions shift. This approach has been utilized for fault diagnosis in printed circuits boards~\cite{Liu:VTS2019sh}. We expect a similar solution to be useful for root-cause localization in SLT. \begin{figure} \includegraphics[width=0.98\columnwidth]{fig2-krish.jpg} \vspace{-0.2cm} \caption{Diagnostic quality over time} \label{fig:diagqual} \vspace{-0.3cm} \end{figure} The diagnosis accuracy improves when more instances of successful root-cause localization in SLT are available for training the diagnosis system. However, there exists a significant knowledge gap in the initial product ramp-up stage (see Fig.~\ref{fig:diagqual}). In reality, a successful product typically experiences multiple updates and there are often similar products during a period of time. In chip manufacturing, fallout data accumulates over multiple wafers and lots. A similar problem has been addressed for board diagnosis, whereby knowledge learned from a mature board is transferred to the diagnosis model of a new board~\cite{Liu:ITC2019}. A supervised model is trained to identify board-level functional fault using a large number of samples from the mature product (i.e., source domain) and a limited number of samples from the new product (i.e., target domain). \section{SLT-Unique Fails} \label{sec:fails} SLT's main \emph{raison d'\^etre} is its ability to detect failing ICs that are missed during the conventional test insertions. The existing literature suggests a number of sources of these failures, which can be attributed to three broad categories: \begin{enumerate} \item \textbf{Failure mechanisms that are not covered by standard fault models.} For example, traditional scan-based stuck-at and TDF timing tests are node oriented, and explicitly only target the interconnect between the standard cells (gates) in the design. More recently, it was recognized that these classical tests can miss a significant number of defects within complex standard cells, which has led to the development of Cell Aware Tests (CAT) targeting cell internal defects \cite{HHM+:20sh}. Scan tests generated using the CAT methodology can significantly reduce subsequent SLT fallout in some applications. However, marginal, or ``soft'', timing failures \cite{Sin:19} that manifest themselves only under certain operating conditions (voltage, temperature) \cite{Che:18,BRR+:20sh}, and power-supply instabilities in conjunction with complex power-management schemes \cite{BRR+:20sh}, remain challenging to detect using the available scan-based delay test methods. \item \textbf{Systematic ATPG coverage holes.} Complex SoC designs contain signal lines connecting several, even dozens, of different clock domains. Faults in the logic structures at the clock domain boundaries, asynchronous or analog interfaces or clock distribution networks often need careful manual expert intervention during test generation to ensure reliable detection. These may be conservatively classified as ``untestable'' by automated ATPG tools, even though the faults can manifest themselves during the device's operation. More mundane causes of incomplete test coverage are test time and tester memory limitations. At times some scan patterns that detect only a few faults are dropped to reduce memory requirements or test-application time; this ``long-tail'' problem is also alleviated by fortuitous detection by the very long SLT test sequences. \item \textbf{Faults exposed only during system-level interactions.} This includes complex software-controlled clock- and power-domain interactions or resource contention in a multi-core system that cannot be fully replicated on an ATE \cite{Che:18}. Other possible situations include complex hardware-implemented protocols or ``soft'' failures during high-speed memory accesses \cite{BRR+:20sh}. The key characteristics of these failures is that the electrical and timing interaction of the IC under test with other components in the target system are insufficiently defined, or too complex, to be accurately modelled on a tester. \end{enumerate} Since using SLTs as an additional final test screen during post manufacturing tests imposes significant added costs, considerable efforts have focused on minimizing test escapes from traditional structural scan-based testing so as to eliminate, or at least reduce, the need for SLTs. In some applications, SLT is critically needed only during the early yield ramp phase of production, when the yield of defect free parts is low, as test escapes are obviously more numerous when there are more defective parts being tested. Once the manufacturing process matures and yields improve, SLT is only performed in these applications on sample parts for quality assurance purposes---to ensure acceptable defect levels in the shipped ICs. An increasing number of high-volume applications, e.g. high-end cell phone processor SoCs, continue to require SLT on all manufactured parts throughout the product lifetime. This has motivated considerable research on understanding the test escapes from traditional scan tests that are uniquely detected by SLTs. The goal is to improve the coverage of these failures by the scan tests, and thereby reduce dependence on SLTs. In revisiting the three categories of test escapes listed above, it is obvious that (3), faults exposed only during system-level interactions, cannot by definition be targeted using traditional test methods. Plugging coverage holes (2) caused by the inability of ATPG tools to generate some tests, e.g., across timing domain boundaries, and for asynchronous and analog mixed signal circuit structures, is a well understood and a longstanding challenge. It is currently the focus of significant development effort at major EDA companies. However, until recently, considerable mystery has surrounded Category (1), failures that are not covered by fault-model-based scan tests but uniquely detected by SLT. The reason for this uncertainly is the poor diagnostic capability of SLTs. Unlike in scan tests where each applied test input pattern and corresponding circuit response is known, it is extremely difficult to root cause a failure observed by functional SLT down to a logic gate. Failure in functional operation may be observed thousands, even millions, of clock cycles after the underlying logic level malfunction occurs, making it impossible to trace and locate (see Section \ref{sec:diag}). It is virtually impossible to confirm the cause of most of the SLT failures that escape scan tests. This makes it difficult to target them with new fault models. The new Cell Aware Test generation methodology aimed at detecting shorts and opens within standard cells has been successful in reducing SLT fallout in some applications, but less so in others \cite{HHM+:20sh}. The distinction appears to be the susceptibility of the design to “soft” timing errors, which are not caused by the “hard” defects targeted by CAT. Particularly vulnerable to timing failures are power constrained applications such as cell phones that implement aggressive power management to ensure battery life while meeting ever increasing computational demands. This involves dynamic voltage-frequency scaling, with the circuit operated at slow clock frequencies and low energy saving voltages when computational loads are minimal. Unfortunately, the impact of manufacturing process variations on circuit timing is greatly amplified during very low voltage operation, causing some circuits to experience occasional timing errors. Ideally, such “defective” ICs containing extremely slow statistical outlier transistors from random process variations should be detected by the scan timing tests. However, the widely used transition delay fault (TDF) model explicitly only targets a single lumped delay in the circuit. It is unable to reliably detect accumulated delays along circuit paths resulting from a distribution of delays across the IC due to the effects of random process variations. What are required are effective scan path delay tests, which have so far not proven practical. Variation-aware tests \cite{SPI+:14sh} are, therefore, not part of the scan test set, resulting in the increasing dependence on SLTs in power constrained low voltage applications. \section{Assessing the Quality of SLT Programs} \label{sec:cov} As was already mentioned above, the standard quality metrics normally used during IC testing (fault coverages) are not practically applicable to SLT, just because the workloads that are being applied for minutes would be impossible to simulate. The only suggestion for an SLT-aware metric proposed so far is the number of used scenarios in the context of the PSS-based SLT flow \cite{Che:18}. In the following, we discuss coverage concepts used during software integration test and whether it can play a role during SLT. Overall, software integration test is---similarly to SLT---not as well investigated as unit tests on the lower levels. For the latter, coverage is often used to describe the completeness of the tests. The coverage most often encompasses control flow (such as statement coverage or branch coverage) but can also relate to the data flow (such as all definitions). This translates badly to integration tests as it then still relies on which statements in the integrated components are executed, just with a relation to the interface of the components \cite{spillner1995test}. An alternative approach \cite{HSW:19sh} sees the integrated components as black boxes. Motivated by the application in the automotive domain, in which many software components are developed by suppliers without revealing the source code, it aims at understanding if the components are well integrated only based on the information from the data flow between them. To achieve this, the observations on shared data between components are described and classified into \emph{preconditions} that represent the states of the components, \emph{stimulations} that capture manipulations of shared data, and \emph{verification} that represents observed data that can be used to check the behaviour based together with preconditions and stimulations. This gives rise to new coverage criteria% , for example, the coverage of all usages of shared data (``shared-data-use''), or the verification usage of a shared data (``verification-data-use'') in which a test must use a shared data to verify behaviour \cite{HSW:19sh}. Using this approach for automotive integration testing, test gaps were identified. It appears promising to use similar coverage criteria for SLT. Some high-level parameters are playing an important role in the detection of failures during the SLT insertion. To stress the component to facilitate the insurgence of an SLT defect is often not a pure duty of the SLT software, but it requires some extra conditions to be met. The characterization of an SLT program must also carefully consider the effects of different temperatures (both high and low) and temperature gradients. In most cases when temperature is a factor to consider, the requested temperature conditions are provided by climatic chambers. Anyway, a stressful (therefore valuable) SLT workload should also show self-heating capabilities to reach a specific junction temperature as indicated in mission profiles. Furthermore, it should also implement heat control mechanisms to avoid over stress and sometimes the thermal overrun. Testing at harsh power supply conditions is another very common industrial practice in SLT; power supply voltage for core and other power domains is increased or decreased even to make the test running out of the functional specifications of the product. This power supply variation is aimed at screening out latent faults that may easily show up in the early life of the IC. Obviously, this may turn into a dangerous practice if the SLT workload was not very carefully graded in term of punctual power demands. \section{SLT Program Generation} \label{sec:gen} While the current state of the art for SLT is to use existing software (thus requiring no explicit generation), testing for specific problems can call for SLT programs with specific characteristics. For instance, if we know that a particular part of the system is vulnerable to subtle failures, an SLT workload that stresses this part of the system will be useful. This is related to the ``power-virus'' generation considered (for much smaller circuits) in the past \cite{NKH+:07sh}. Thermal measurement on physical samples like in \cite{BRV+:17sh} is an important practice to also provide physical findings about the implemented SLT workload. Warming up the silicon surface of a device is often asking quite a long time (up to minutes) before the circuit shows the desired (usually high) temperatures. Such a thermal characterization is usually done by thermocamera-based experiments. This experimental observation can be supported by suitable firmware read-out of the chip the temperature recorded by the sensors embedded in it. The creation of a functional oriented program able to control the thermal behaviour should not address the entire circuit in one shot, but rather focus on different circuit zones at different times. Differently from scan testing, the focused functionalities during SLT should be triggered by a suite of workloads targeting relevant circuit portions. \section{Conclusion} \label{sec:concl} Looking back at conventional integrated circuit test several decades ago, we see a scientific success story, which made quality assurance feasible and kept its cost reasonable throughout the long period of exponential circuit complexity growth. A (largely) common understanding of terms and concepts throughout a large community, both industrial and academic, has led to sophisticated and yet practical solutions that could be adopted by most relevant players. We believe that SLT needs to reach a similar level of widely agreed-upon understanding to enable comparable progress and overcome its foreseeable limitations. To answer the questions posed in this paper, a new level of cross-sector collaboration between semiconductor manufacturers, system integrators, test equipment manufacturers, EDA companies and academia will be necessary. For instance, reliable information on SLT programs that are practically effective, and on SLT-unique fails identified by such programs, will be helpful in giving the necessary research, e.g., on improved generation of SLT programs and systematic assessment of their quality, a meaningful direction. \section*{Acknowledgment} This work was supported by Advantest as part of the Graduate School ``Intelligent Methods for Test and Reliability'' (GS-IMTR) at the University of Stuttgart. \bibliographystyle{IEEEtran}
{'timestamp': '2021-03-12T02:23:18', 'yymm': '2103', 'arxiv_id': '2103.06656', 'language': 'en', 'url': 'https://arxiv.org/abs/2103.06656'}
arxiv
\section{INTRODUCTION} \label{Introduction} Underlying all reinforcement learning (RL) algorithms is the simple mechanism of receiving a reward feedback upon an interaction with the environment. This allows the algorithms to acquire sophisticated skills. Deep reinforcement learning has thus been successfully applied to a variety of tasks such as robotics \cite{HaarnojaPZDAL18} as well as board and video games \cite{Silver,Vinyals,samvelyan2019starcraft}. In this work we focus on model-free algorithms which can be readily applied to various environments. In particular, online Actor-Critic methods for challenging settings with high-dimensional action and state spaces have recently gained a lot of attention \cite{mnih2016asynchronous,lillicrap2019continuous,haarnoja2018soft,fujimoto2018addressing}. The common perspective is that their success is owed to the use of deep neural networks which allow for high-capacity function approximations. The default policy network for the Actor is usually a Multi-Layer-Perceptron (MLP). The majority of the recent literature - with a few notable exceptions \cite{srouji2018structured,liu2019recurrent} - attempts to improve learning results by altering the algorithm e.g. by modifying the loss function and interaction of the Actor and Critic. In contrast our angle is to study other policy networks with the aim of improving the general reward performance while reducing the number of trainable weights and being more computationally resource efficient. We achieve this by introducing a single layer quadratic neuron in between input and output in addition to the deep MLP in a network called Q-MLP (Quadratic-MLP), see fig.\,\ref{QN}. \begin{figure}[ht] \vskip 0.2in \vspace{-0,2 cm} \begin{center} \centerline{\includegraphics[width=\columnwidth]{figures/QN_MLP.pdf}} \vspace{-0,35 cm} \caption{Quadratic neuron connecting input and output in a single layer additively to a deep neural network architecture in our study given by a MLP. } \label{QN} \end{center} \vskip -0.2in \end{figure} The non-linearity of a conventional MLP is induced by the activation functions. In contrast, the Q-MLP allows for a direct approximation using the quadratic dependencies of the input as a first order optimisation problem. Thus naturally using quadratic layers one gains expressive advantages \cite{FAN2020383}. We introduce the Q-MLP only for the Actor network while we do not alter the Critic network i.e.\,we use a conventional MLP for the latter. For our empirical tests we focus on the two following state-of-the-art model-free algorithms: SAC \cite{pmlr-v70-haarnoja17a} and TD3 \cite{fujimoto2018addressing}. Our source code as well as the raw data for our main results can be found online\footnote{\url{https://github.com/matthias-weissenbacher/Quadratic_MLPs_in_RL}}. Let us emphasize that we do not modify the hyperparamters of the TD3 and SAC algorithm to accommodate for the Q-MLP actor policy. Regardless, we find a benefit across almost all tasks. The top returned reward for the TD3 is in average increased by $8.9\%$ while being about $29.98\%$ more sample efficient. The found improvements for the SAC algorithm are more moderate: $2.7\%$ and $12.3\%$ for top returned reward and sample efficiency, respectively. These numbers can be improved when relaxing the condition of reducing the number of weights of the Q-MLP in comparison to the MLP. E.g.\,we show that in the case of the Ant-v3 environment the benefit doubles from $\sim 16 \%$ to $\sim 33 \%$ for the top reward and from $\sim 40\%$ to $\sim 60\%$ for the sample efficiency compared to the MLP when increasing the number of weights of the quadratic layer. Moreover, it is worth noting that the benefit over the conventional MLP is maintained when action or observation noise is added.\footnote{Experiments for a smaller number of environments.} For specific setups we even improve the noise robustness compared to the MLP. Noise robustness of deep neural nets is crucial for Sim2Real transfer, see e.g.\cite{zhao2020simtoreal} for a review. In particular, let us emphasise that our method does not require domain randomisation \cite{Fernndez2020DeepRL,Kaspar2020Sim2RealTF}. Let us comment on another angle under which one may view our proposal. Reduction techniques of fully-connected neural networks to sparser representations with similar output performance have been widely investigated \cite{LeCun90,NIPS1992_647,han2015learning,hinton2015distilling,frankle2018lottery}. Those are mostly found in supervised learning research. The lottery ticket hypothesis states that “dense, randomly-initialized, feed-forward networks contain subnetworks that … reach test accuracy comparable to the original network”\cite{frankle2018lottery}. The degrees of freedom of function approximation of the the Q-MLP are contained in a more parameter extensive MLP which naturally incorporates quadratic dependencies over the activation functions. Thus one may view the Q-MLP as a "sparser version" of the latter. One may thus consider our results as a step forward towards identifying a lottery ticket winner of neural networks in reinforcement learning. The success of the Q-MLP may be attributed to the fact that it allows to propagate quadratic dynamic dependencies directly from input to output. In other words, the Q-MLP Actor Policy can thus adapt easily to gain potential benefits in exploring these quadratic directions. This seems beneficial in particular in an online reinforcement setting where dynamic exploration is the source for new data. Although not discussed explicitly in this work it is expected that our approach may as well lead to benefits in an offline reinforcement learning. \section{RELATED WORK} \label{Related_work} To the best of our knowledge this work presents the first study of a quadratic layer in combination with a MLP as the policy network in the context of reinforcement learning. The standard policy network commonly used for the Actor in continuous control tasks is the Multi-Layer Perceptron (MLP). The non-linearity of deep neural networks as in the MLP is introduced by activation functions. Recently quadratic layers have been used in the context of categorical image classification in supervised learning \cite{fan2017new,CNNq2,fan2019universal,xu2020efficient}. We incorporate the quadratic neuron as a single unit between input and output additively to a MLP which is in contrast to \cite{xu2020efficient}. \footnote{Another distinguishing minor feature contrasting our work from \cite{xu2020efficient} is that we make us of activation functions in the final layer. } Moreover, their study is restricted to supervised learning setups. More relevant for us is the previously discussed architecture \cite{he2015deep,srouji2018structured} employed in the context of reinforcement learning. Their approach is conceptually analog to ours as their architecture is comprised of a linear module which directly connects the input state additively to the output state of a deep neural network i.e. the MLP, see fig.\,\ref{L-MLP}. The authors refer to this architecture as "structured control nets". In other words, the authors split the policy network into linear and nonlinear components where the latter is given by a MLP. This is in contrast to our approach where the quadratic neuron layer does not admit any linear components but is of quadratic order instead, see fig.\,\ref{QN}. Moreover, it is worth emphasizing that as the quadratic neuron uses a quadratic function approximation it carries more complexity. Lastly, we allow for activation functions i.e. $tanh$ to act upon the sum of the quadratic neuron and the MLP output. \begin{figure}[ht] \vspace{-0,7 cm} \vskip 0.2in \begin{center} \centerline{\includegraphics[width=\columnwidth]{figures/LN_MLP.pdf}} \vspace{-0,5cm} \caption{Linear neuron i.e. a fully connected (FC) layer connecting input and output in a single layer additively to a deep neural network architecture e.g. a MLP. } \label{L-MLP} \end{center} \vskip -0.2in \end{figure} Due to the similarity to \cite{srouji2018structured} we provide results on their architecture in the ablation study, see fig.\,\ref{L-MLP}. Moreover, we provide the ablation study for the case where a quadratic neuron and FC layer are present, see fig.\,\ref{LQ-MLP}. \begin{figure}[ht] \vspace{-0,7 cm} \vskip 0.2in \begin{center} \centerline{\includegraphics[width=\columnwidth]{figures/QN_MLP_LN.pdf}} \vspace{-0,3 cm} \caption{Linear and quadratic neuron connecting input and output each in a single layer additively to a deep neural network architecture e.g. a MLP. } \label{LQ-MLP} \end{center} \vskip -0.2in \end{figure} Lastly, let us mention the idea of recurrent strategies in RL dates back two decades \cite{LSTM_RL}. More recent advances build on the above strategy \cite{liu2019recurrent,LeCun90}. Our results give comparable benefits while being supported by a much simpler architecture.\footnote{As our focus is on simple Actor policy architectures we do not consider LSTMs in the main scope of this work. And thus do not perform an empirical quantitative comparison of the Q-MLP with an LSTM architecture.} \section{BACKGROUND} \label{Background} In this work we focus on two recent state-of-the-art model-free algorithms SAC \cite{pmlr-v70-haarnoja17a} and TD3 \cite{fujimoto2018addressing}. SAC is an algorithm for soft Q-learning \cite{Rawlik,pmlr-v70-haarnoja17a, Fox2016TamingTN} which estimate a “soft Q-function” directly. The latter implicitly induces a maximum entropy policy. On the other hand the TD3 algorithm is the direct successor of DDPG \cite{lillicrap2019continuous, pmlr-v32-silver14}. It owes it improvement over DDPG to the following three major changes: clipped double Q-Learning and delayed policy as well as target policy smoothing. Let us remark that as a future extension of our present work it would be interesting to incorporate Q-MLP into other types of algorithms for scalable learning for continuous control problems such as Trust-Region Policy Optimisation (TRPO)\cite{schulman2017trust} and its derivative class of Proximal Policy Optimisation algorithms (PPO) \cite{schulman2017proximal} as well as Maximum a Posteriori Policy Optimisation (MPO) \cite{abdolmaleki2018maximum,pmlr-v119-abdolmaleki20a}. However, such a study is beyond the scope of this work. \subsection{Preliminaries} Reinforcement learning algorithms train policies to maximize the cumulative reward received by an agent who interacts with an environment. The underlying setting is given by a Markov decision process $ (\mathcal{S}, \mathcal{A}, p, r, \gamma)$, with S being a set of states, $\mathcal{A}$ the action space and p the transition density function. Moreover, $\gamma$ is the discount factor and r the reward function. At any discrete time the agent chooses an action $a_t \in \mathcal{A}$ according to its underlying policy $\pi_\theta (a_t | s_t) $ based on the information of the current state $s_t \in \mathcal{A}$. The policy is parametrized by $\theta$. While the policy of the TD3 is deterministic i.e. it predicts a single action with probability one, the policy of the SAC algorithm is of stochastic nature. The parameters $\theta$ naturally are the weights in the neural network function approximation of the Actor as well as the Critic. The agent i.e. the Actor-Critic is trained to maximize the expected $\gamma$-discounted cumulative reward \begin{equation} \mathcal{J}_{\pi}(\theta) = {\bf E}_{\pi} \Big[ \sum_{t=0}^T \gamma^ t \, r_\pi(s_t,a_t) \Big] \;\; , \end{equation} with respect to the policy network parameters $\theta$. \section{Q-MLP — Quadratic-Multi-Layer-Perceptron} \label{Q-MLP} A quadratic neuron is a deep neural network layer that outputs a vector of quadratic monomials \cite{book_QN_mention} constructed from the input e.g. for the input $ {\bf{x}} =(x_1,x_2,x_3)$ the output would be $ y = \Theta_{11} x_1^ 2 + \Theta_{12} x_1 x_2, +\Theta_{13} x_1 x_3+ \Theta_{22} x_2^ 2+\Theta_{23} x_2 x_3+\Theta_{33} x_3^ 2$ where the $\Theta$'s are six trainable weights. The latter can be arranged in an upper triangular weights matrix $\hat \Theta$ which allows one to generally express the action of the quadratic neuron as \begin{equation}\label{QNdef} y^ f = \sum_{\stackrel{j=1}{ j \geq i}}^ N \sum_{i=1}^ N \hat\Theta^ f_{ij} x_i x_j= {\bf{x}}^T\, \cdot \, \hat \Theta^f \, \cdot {\bf{x}} \;. \end{equation} Where $f=1,\dots, n_f$ with $n_f$ the number of features of the quadratic neuron and $\bf x$ a N-dimensional input vector. The trainable degrees of freedom of a quadratic neuron are given by the matrix elements of $\hat\Theta^f$ i.e. its upper triangular components which are counted as \begin{equation}\label{QN_original} \tfrac{1}{2} N \cdot (N +1) \cdot n_f \;\;. \end{equation} One notes the $\mathcal{O}(N^ 2)$ scaling which makes an efficient direct implementation of eq.\,\eqref{QNdef} difficult for large hidden feature sizes. As proposed recently \cite{xu2020efficient} one may simply take the common "square" of a single linear i.e. fully connected layer to approximate the degrees of freedom of eq. \eqref{QNdef}. This reduces the scaling to $\mathcal{O}(N)$ as well utilizes the parallelisation benefits build into deep learning libraries \cite{NEURIPS2019_9015, tensorflow2015-whitepaper}. Thus we adopt the following implementation for the quadratic neuron in our work \begin{equation}\label{QNsimpledef} y_ f := \mathcal{Q}_f(\bf x) = \Big( \sum_{i=1}^ N \hat\Theta'_{f i} x_{i}\Big) *\Big( \sum_{j=1}^ N \hat\Theta''_{f j} x_j \Big)\;. \end{equation} where $\hat\Theta' $ and $ \hat\Theta''$ are weight matrices. Note that the index $f$ appears in both brackets in eq.\,\eqref{QNsimpledef} which denotes that the multiplication $*$ is element-wise. Moreover, let us emphasize that the quadratic neuron in our neural network serves as a direct connection between input and output, see figure \ref{QN}. Thus the implementation \eqref{QNsimpledef} is too restrictive as the input dimension is equal to the environments state vector and the feature dimensions equal to the one of the environments action state. Thus to allow for a higher number of trainable weights we choose the intermediate features size larger than the environments action state and introduce another linear layer as \begin{equation}\label{QNsimpledef2} y_ a := \sum_{f=1}^ {n_f :=\text{hidden features}} \hat\Theta_{af} \mathcal{Q}_f (\bf x) + b_a \;\; , \end{equation} where $\hat\Theta , {\bf b}$ are the weight matrix and bias vector, respectively, while $a=1,\dots, $ number of action dimension of the environment. Eq. \eqref{QNsimpledef2} simply represents another fully connected layer acting on \eqref{QNsimpledef}. The crucial distinction to a MLP is that no activation function is used which would introduce additional non-linearities. Concludingly, \eqref{QNsimpledef2} is of precisely quadratic order in the monomials of the input vector. Our guiding principle is to reduce the number of weights compared to the three layer actor policy MLP network from \cite{wei2021fork} i.e. two hidden layers with hidden unit dimension $256$ each. For the deep neural network part of our Q-MLP we choose the same three layer MLP architecture each with two hidden unit dimensions either $n_h = 64,128,192$ . For the features for the quadratic neuron we are guided by the relation \eqref{QN_original} to arrive at \begin{equation} \label{featureFormula} n_f = \text{integer-part}\big(\tfrac{\kappa^ 2}{2} \cdot N \cdot (N+1)\big) \;\;, \;\; \text{with} \;\; 0 < \kappa \leq 1 \;\; , \end{equation} where $N$ is the input dimensions i.e. the observation space dimension of the environment. The expression \eqref{featureFormula} provides a convenient guiding principle for choosing the hyper-parameter $n_f$ which served us well in achieving good empirical results without almost any hyper-parameter search. \section{EXPERIMENTS} \label{Experiments} This section contains the empirical tests of our Q-MLP actor policy compared to the MLP baseline in \ref{sec:mainResults} as well as an ablation study in subsection \ref{sec:ablation}. \subsection{Training Environments \& RL Algorithm } \label{sec:mainResults} We exclusively focus on training environments with continuous state and action spaces. The selection for our empirical study consists out of five MuJoCo environments \cite{Mujoco} namely: Ant-v3, Hooper-v3, HalfCheetah-v3, Humanoid-v3 and Walker2d-v3 and moreover the BipedalWalker-v3 from Box2D \cite{catto}, see fig. \ref{fig:trainenvs}. \begin{figure} \vspace{0.20 cm} \centering \tabcolsep = 0.5pt \begin{tabular}{ccc} \includegraphics[width=2.8cm]{figures/Ant-v3.jpeg}& \includegraphics[width=2.78cm]{figures/BipedalWalker-v3.png}& \includegraphics[width=2.782cm]{figures/HalfCheetah-v3.jpeg} \\ (a) Ant-v3 & (b) {\small BipedalWalker-v3}& (c) {\small HalfCheetah-v3} \\ \includegraphics[width=2.8cm]{figures/Hopper-v3.jpeg}& \includegraphics[width=2.8cm]{figures/Humanoid-v3.png}& \includegraphics[width=2.76cm]{figures/Walker2d-v3.jpeg}\\ (e) Hopper-v3 & (f) Humanoid-v3& (g) Walker2d-v3 \\ \end{tabular} \caption{Training environments (a) and (c)-(g) from MuJoCo and (b) from Box2D.} \vspace{-0.3cm} \label{fig:trainenvs} \end{figure} \begin{figure*}[hbt!] \begingroup \centering \renewcommand{\arraystretch}{0.2} \tabcolsep = -6.0pt \begin{tabular}{ccc} \multicolumn{3}{c}{\includegraphics[width=12.5cm]{figures/CaptionTD3SAC.pdf}} \vspace{-0.3cm} \\ \includegraphics[width=6.4cm]{figures/Train_Ant-v3.pdf}& \includegraphics[width=6.4cm]{figures/Train_BipedalWalker-v3.pdf}& \includegraphics[width=6.4cm]{figures/Train_HalfCheetah-v3.pdf} \\ (a) Ant-v3 & (b) BipedalWalker-v3& (c) HalfCheetah-v3 \\ \includegraphics[width=6.4cm]{figures/Train_Hopper-v3.pdf}& \includegraphics[width=6.4cm]{figures/Train_Humanoid-v3.pdf}& \includegraphics[width=6.4cm]{figures/Train_Walker2d-v3.pdf}\\ (e) Hopper-v3 & (f) Humanoid-v3& (g) Walker2d-v3 \\ \end{tabular} \caption{Learning curves of environment (a)-(g) for both the TD3 and SAC algorithm. Mean and standard deviation averaged over five environment seeds, respectively. For better interpretability we have smoothened the plots uniformly by averaging over eight subsequent data points.} \label{fig:mainresults} \endgroup \end{figure*} All experiments were conducted under the same conditions. The policies are evaluated every 5k time-steps averaged over ten episodes i.e. evaluation runs with different initial conditions. We train five different seed initialisation for the random seeds $0,1,2,3,4$, respectively. The solid curves in all figures shows the average cumulative rewards per episode, and the shaded region represents the standard deviations. The implementation of the TD3 and SAC algorithms as well as hyper parameter settings are taken from \cite{wei2021fork} \footnote{\url{https://github.com/honghaow/FORK}}. The latter is closely based on \cite{fujimoto2018addressing}\footnote{\url{https://github.com/sfujim/TD3}} in the case of the TD3 algorithm and \cite{pytorch_sac}\footnote{\url{https://github.com/ vitchyr/rlkit} and \newline \url{https://github.com/denisyarats/pytorch_sac}} for the SAC algorithm. Thus these algorithms provide our baseline results which may be easily compared to the cited works. \begin{figure*}[hbt!] \centering \vspace{0,2 cm} \begin{tabular}{SSSSSSS} \toprule {\bf Environment} & {\bf Q$-$MLP TD3} & {\bf TD3}& {\bf Improvement} & {\bf Q$-$MLP SAC} & {\bf SAC} & {\bf Improvement} \\ \midrule {Ant-v3} & {\it 3847.40} & 3317.29& {15.98\%} & {\bf 4027.65} &3423.88& {17.63\%}\\ {BipedalWalker-v3} & {\it 314.08 } & 308.48& {1.82\%} & {\bf 315.05} & { 314.46}& {0.19\%}\\ {HalfCheetah-v3} & {\it 10295.54} & 9247.73 & {11.33\%} & {\bf 11301.82} & {10884.99}& {3.83\%} \\ {Hopper-v3} & {\it 3437.87} & 3384.06& {1.59\%}& {\bf 3525.81} & 3470.89 & {1.58\%} \\ \midrule {Humanoid-v3} & {\it 5414.98} &5242.58 & {3.29\%} & 5494.45 &{\bf 5508.70}& {-0.26\%} \\ {Walker2d-v3} & {\it 4159.95} & 3485.84& {19.34\%} & 4651.67 & {\bf 4995.56}& {-6.88\%} \\ \bottomrule \end{tabular} \caption{The table shows the top average reward for each environment and algorithm. Bold font highlights the best return reward while italic symbolizes the winner of the comparison of with and without quadratic neurons. The Q-MLP systematically outperforms the MLP. We separate the horizontal line for the Humanoid as well as Walker2d environment to highlight that no improvement for the Q-MLP SAC algorithm is found.} \label{tab:bestRun} \end{figure*} \begin{figure*}[hbt!] \centering \begin{tabular}{SSSSSSS} \toprule {\bf Environment} & {\bf Q$-$MLP TD3} & {\bf TD3}& {\bf Improvement} & {\bf Q$-$MLP SAC} & {\bf SAC} & {\bf Improvement} \\ \midrule {Ant-v3} & {\bf 575k} & {970k}& {40.72\%} & {\it 845k} & {990k} & {14.64\%}\\ {BipedalWalker-v3} & {\bf 740k } & {1M} & {26.00\%} & {\it 895k} & { 970k}& {7.73\%}\\ {HalfCheetah-v3} & {\bf 630k} & {995k} & {36.68\%} & {\it 815k} & {975k}& {16.41\%} \\ {Hopper-v3} & {\it 720k} & {990k} & {27.27\%}& {\bf 515k} & {795k} & {35.22\%} \\ \midrule {Humanoid-v3} & {\bf 865k} &{975k} & {11.28\%} & {--}&{ --}& {$\sim$ 0\%} \\ {Walker2d-v3} & {\bf 565k} & {910k} & {37.91\%} & {--} & {--}& {$\sim$ 0\%} \\ \bottomrule \end{tabular} \caption{ The table shows a comparison of the Q-MLP to the conventional MLP in terms of sample efficiency. Bold font highlights the best sample efficiency while italic symbolizes the winner of the comparison of with and without quadratic neurons. For the Humanoid and Walker2d for the SAC algorithm we omit the comparison as visual inspection of figures \ref{fig:mainresults} (e) and (f) shows no quantitative difference. } \label{tab:sampleEfficient} \vspace{-0,4cm} \end{figure*} \subsection{Q-MLP Performance on SAC \& TD3 } \label{sec:mainResults} In this section we discuss our empirical results. The main results are given in fig.\,\ref{fig:mainresults} which shows the comparison of the MLP to the Q-MLP tested with the TD3 and SAC algorithm, respectively. For the Q-MLP actor policy network we choose the hyper-parameters as in table \ref{tab:HypPar1}. For the environments with small observation space dimension i.e. $\mathcal{O}(10)$ such as HalfCheetah-v3, BipedalWalker-v3, Hopper-v3 and Walker2d-v3 \eqref{featureFormula} can be applied simply with $\kappa = 1$. For environments with large observation space dimension $ \mathcal{O}(100)$ such as Ant-v3 and Humanoid-v3 to arrive at a less weight extensive network architecture one must choose $\kappa < 1$. Note that for $\kappa=1$ eq.\,\eqref{featureFormula} provides the same order of degrees of freedoms as a honest quadratic neuron \eqref{QN_original} where all the quadratic monomials are counted explicitly. For other hyper-parameters such as details of the MLP for the Critic network see the appendix. In summary we conclude from fig.\,\ref{fig:mainresults} that the Q-MLP results in performance gains across all environments and for both the TD3 and SAC algorithm. Let us emphasize that we do not modify the hyperparameters of the TD3 and SAC algorithm to accommodate for the Q-MLP actor policy. In table \ref{tab:bestRun} we show the highest cumulative reward obtained averaged over the five training seeds for all environments and algorithms, respectively. We find that even for the choices $\kappa < 1$ performance benefits are obtained, see figure \ref{fig:mainresults} and tables \ref{tab:bestRun},\ref{tab:sampleEfficient}. This suggest that for those environments not all quadratic monomials weights need to be chosen independently for the actor to achieve high dynamic skills. Moreover, in table \ref{tab:sampleEfficient} we provide a quantitative measure for sample efficiency of the algorithms. Namely, the time-steps it takes to achieve the best reward (table \ref{tab:bestRun}) of the weaker environment in comparison between the MLP and Q-MLP. Let us illustrate this in an example. For the TD3 algorithm for the Ant-v3 environment the better reward is obtained by the Q-MLP, see table \ref{tab:bestRun}. Thus we compute how many time steps it takes both the TD3 as well as the Q-MLP TD3 algorithm to achieve the "weaker" top reward, i.e. the one obtained from the MLP without quadratic neurons. The time-steps are again averaged over the five seeds by using the mean values provided by the solid lines in the figures \ref{fig:mainresults}, respectively. \newline {\bf Summary of main result:} In conclusion, we find a benefit across almost all tasks. The top returned reward for the TD3 is in average increased by $8.9\%$ while being about $29.98\%$ more sample efficient. The found improvements for the SAC algorithm are $2.7\%$ and $12.3\%$ for top returned reward and sample efficiency, respectively. This averages to {\bf a total improvement of the cumulative reward of $5.8\%$ while being $21.1\%$ more sample efficient}. \newline Let us stress that the above performance measures for the Q-MLP can be improved by hyperparameter tuning. We will present details in the section \ref{sec:ablation}. In particular, we will find that improvements can be found by increasing the number of weights of the Q-MLP in compared to the study in figure \ref{fig:mainresults} and tables \ref{tab:bestRun} and \ref{tab:sampleEfficient}. Moreover, there is a clear difference on the performance gain in between the SAC and the TD3 algorithm with the latter having a strongly increased benefit of employing the Q-MLP network. As we do not perform any hyper-parameter tuning of the intrinsic values of the SAC nor the TD3 algorithm we cannot conclude on the origin of the difference.\footnote{However, it is worth noting that our implementation of the Actor Policy networks uses a Xavier uniform weight initializer which is in contrast to the Kaiming uniform initializer used for the quadratic layer. It would be interesting to see in a future study if hyperparameter refinements such as the weights initializer for the Q-MLP SAC algorithm can lead to increased benefits across a wide range of tasks analog to the improvements found for the TD3 algorithm.} \begin{figure*}[hpt!] \begingroup \renewcommand{\arraystretch}{0.2} \centering \tabcolsep = - 6.0pt \begin{tabular}{ccc} \multicolumn{3}{c}{\includegraphics[width=12.5cm]{figures/CaptionTD3_HypSearch2.pdf}} \vspace{-0.3cm} \\ \includegraphics[width=6.4cm]{figures/HypSearch_Ant-v3.pdf}& \includegraphics[width=6.4cm]{figures/HypSearch_HalfCheetah-v3.pdf}& \includegraphics[width=6.4cm]{figures/HypSearch_Humanoid-v3.pdf}\\ \vspace{0.2cm} (a) Ant-v3 ; $n_h = 64$ & (b) HalfCheetah-v3 ; $\kappa = 1.0$ & (c) Humanoid-v3 ; $n_h = 192$ \\ \vspace{0.2cm} Q, Q', Q'': $\kappa=0.1,0.25,1.0$ & Q, Q', Q'': $n_h = 64,128,192$ & Q, Q', Q'': $\kappa=0.02,0.02^\ast,0.01^\ast$ \\ \end{tabular} \caption{Learning performance under hyperparameter changes of the Q-MLP i.e. its hidden state dimensions. The figure shows the learning curves for the TD3 algorithm of the Ant (a), HalfCheetah (b) and Humanoid (c) environment for different hyper-parameter settings denoted by Q,Q',Q''-MLP, respectively. In (a) we vary the $\kappa$-hyper parameter i.e. the hidden features $n_f$ of the quadratic neuron while keeping $n_h$ fixed. In (b) we keep $n_f$ fixed and vary $n_h$. Lastly, in (c) we mainly compare initializing the weights of the quadratic neuron with value zero -denoted by the asterisk - to the default Kaiming uniform initializer. The precise hyper-parameter choices are found below the images in table. As for the MLP network we choose our default $n_h=256$. The plot displays the mean and standard deviation averaged over five environment seeds, respectively. For better interpretability we have smoothened the plots uniformly by averaging over 12 subsequent data points. } \label{fig:hypersearch} \endgroup \end{figure*} {\bf Critical comment:} While we find that in general the performance benefit holds without much hyper-parameter tuning, for the Humanoid environment however the training results may vary. As the Humanoid is by far the most complex environment this caveat may be caused due to the rich state and action space. We traced the origin to the weight initializer which is Kaiming uniform by default \cite{he2015delving}. A solution to enhance the training stability is to set the weight initializer of the quadratic neuron eq. \eqref{QNsimpledef} to zero i.e. for the weight matrices $\bf \hat\Theta' = 0$ and $\bf \hat\Theta''= 0$ as well as the bias in \eqref{QNsimpledef2}. \newline {\bf Noise Robustness: } We consider the TD3 algorithm for the Ant-v3 and HalfCheetah-v3 as those environments show a clear benefit in fig. \ref{fig:mainresults} and the most complex environment the Humanoid-v3 \footnote{With hyperparameters for Ant : $n_h =64 ;\, \kappa = 0.25, 0.1$, HalfCheetah: $n_h = 192 ;\, \kappa = 1.0$ and Humanoid: $n_h = 192 ;\, \kappa = 0.02^{\ast}$.}. We find that the performance benefit of the Q-MLP is slightly improved further when adding action or observation noise at test time, see table \ref{tab:actionnoise} and \ref{tab:statenoise}. One concludes that for added action or observation noise the Q-MLP average benefit of $14.8\%$ is improved to $19.7\%$ and $16.3\%$, respectively. Lastly, it is worth noting that in particular for the Humanoid environment an increase in noise leads to a higher benefit of the Q-MLP. \begin{figure}[hbt!] \centering \begin{tabular}{cccccc} \toprule {\bf MLP vs. } & \multicolumn{5}{c}{\bf Action Noise Added} \\ { \bf Q-MLP} & {0.05} & {0.1} & {0.15} & {0.2} &{ 0.25} \\ \midrule {14.8\%} & {18.3\%} & { 25.0\%} & {24.1\%} & {20.2\%} & { 10.9\%} \\ \bottomrule \end{tabular} \caption{Q-MLP performance gain over MLP for added action noise averaged over several environments. We evaluate the model of highest no noise performance for each seed then take the average. The displayed noise levels multiply a random action variable. } \label{tab:actionnoise} \end{figure} \begin{figure}[hbt!] \centering \begin{tabular}{cccccc} \toprule {\bf MLP vs. } & \multicolumn{5}{c}{\bf Observation Noise Added} \\ { \bf Q-MLP}& {0.01} & {0.02} & {0.03} & {0.04} &{ 0.05} \\ \midrule {14.8\%} & {13.7\%} & { 16.3\%} & {18.7\%} & {17.6\%} & {15.0\%} \\ \bottomrule \end{tabular} \caption{Q-MLP performance gain over MLP for added observation noise averaged over several environments. We evaluate the model of highest no noise performance for each seed then take the average. The displayed noise levels multiply a random observation variable. } \label{tab:statenoise} \vspace{-0.2 cm} \end{figure} \newpage \subsection{Ablation Study} \label{sec:ablation} \begin{figure*}[hpt!] \begingroup \renewcommand{\arraystretch}{0.2} \centering \tabcolsep = -6.0pt \begin{tabular}{ccc} \multicolumn{3}{c}{\includegraphics[width=12.5cm]{figures/CaptionTD3_Ablation.pdf}} \vspace{-0.3cm} \\ \includegraphics[width=6.4cm]{figures/Ablation_Ant-v3.pdf}& \includegraphics[width=6.4cm]{figures/Ablation_HalfCheetah-v3.pdf} \includegraphics[width=6.4cm]{figures/Ablation_Hopper-v3.pdf} \\ (a) Ant-v3 & (b) HalfCheetah-v3& (c) Hopper-v3 \\ \end{tabular} \caption{Ablation study in regard to the network alteration containing a linear unit, see fig.'s \ref{L-MLP} and \ref{LQ-MLP}. The plot shows the learning curves mean and standard deviation derived from five environment seeds, respectively. For better interpretability we have smoothened the plots uniformly by averaging over 12 subsequent data points.} \label{fig:ablationresults} \endgroup \vspace{-0.3 cm} \end{figure*} In this section we perform an ablation study to compare the Q-MLP network to the alteration containing linear units see fig.'s\,\ref{L-MLP} and \ref{LQ-MLP}. As well as discuss quantitative features of changes in the performance of the Q-MLP in regard to changes of the hyper-parameters $n_h$ and $\kappa$ i.e.\,$n_f$. For simplicity we restrict this study to only the TD3 algorithm in this section and to a reduced number of environments. Let us start our study by discussing systematics of our approach in regard to changes of the hyper-parameters $n_f$ and $n_h$ as well as the weight initializers for the quadratic neuron layers, see figure \ref{fig:hypersearch}. \newline {\bf Fixed $n_h$ and varying $n_f \,\& \,\kappa$:} In figure \ref{fig:hypersearch} (a) we display the learning curves for the Ant-v3 environment for increasing $\kappa$ i.e. $n_f$ and find that there is a direct positive correlation to the reward returned as well as the sample efficiency. In particular, we find that the benefit over the conventional MLP doubles from $\sim 16 \%$ to $\sim 33 \%$ for the top reward and from $\sim 40\%$ to $\sim 60\%$ for the sample efficiency when increasing the number of weights of the quadratic layer compared to the one used in table \ref{tab:bestRun}. \newline {\bf Fixed $n_f \,\& \,\kappa$ and varying $n_h$ :} In figure \ref{fig:hypersearch} (b) we display the learning curves for the HalfCheetah-v3 environment for increasing $n_h$ and analogously find that there is a direct positive correlation to the reward returned as well as the sample efficiency. \newline {\bf Initializer ablation study:} In figure \ref{fig:hypersearch} (c) we display the learning curves for the Humanoid-v3 environment. The focus is on the stability achieved by initializing the quadratic neuron weights with zero. For details see our comments earlier in the text. From this study we see that initializing the weights with zero not only leads to improved training stability over different hyperparameter choices. Furthermore, it slightly improves the sample efficiency. Let us next turn our attention to the comparison of the Q-MLP network to the alteration containing linear units see figures \ref{L-MLP} and \ref{LQ-MLP}. For all experiments we choose $n_h=64$ and $\kappa = 1.0$. The results can be found in figure \ref{fig:ablationresults}. \newline {\bf Main conclusion on linear units:} Our results figure \ref{fig:ablationresults} suggest that the benefit of using the linear unit is negligible and more likely leads to worse performance. Across the tasks (a) and (b) from fig.\,\ref{fig:ablationresults} one concludes that using the linear unit alone leads to a drop in the returned reward. In the HalfCheetah environment fig.\,\ref{fig:ablationresults}(b) the network alteration with both a quadratic and linear neuron leads to a minor benefit over the Q-MLP alone. Whereas in the experiment fig.\,\ref{fig:ablationresults}(c) the latter leads to a visible performance increase. In conclusion, for both alterations the downsides exceed the benefit. Moreover, let us emphasise that our results here do not reproduce the performance gains found in the original study of linear units \cite{srouji2018structured}. It is our opinion that this is due to the fact that our TD3 and SAC algorithm produce significantly higher rewards as the ones in \cite{srouji2018structured}. This is a critical point which we have observed using less sophisticated reinforcement learning algorithms: benefits due to changes in the actor policy which occur when using a weak RL algorithm often fade away when employing a state of the art algorithm. In other words, it is a much bigger challenge to have architectural modifications of the actor policy improve the performance of an already strong learning setup - such as the one used in this work -. \vspace{0,3 cm} \section{CONCLUSIONS} \vspace{0,1 cm} In this work we propose Q-MLP, a modification of the conventional MLP actor policy network to be used in Actor-Critic algorithms. Our contribution is the additional direct quadratic neuron connection between observation state input and action state output. Our empirical results derived by employing two state-of-the-art model-free reinforcement learning algorithms across six environments show performance improvements in terms of returned reward and sample efficiency. All while maintaining a smaller number of weights compared to the baseline provided by a conventional MLP actor policy network. \vspace{0,3 cm} \section*{APPENDIX} \vspace{0,1 cm} The neural networks are trained using Pytorch $1.7.1+\text{cu}110$ and Python $3.8.7$. The actor policy MLP as well as the the MLP part of the Q-MLP have two hidden layers with ReLU activation and hidden dimension units given in table \ref{tab:HypPar1}, respectively. The final activation function of the Q-MLP is $tanh$. For the critic network for both the TD3 as well as the SAC algorithm we use a MLP with two hidden layers with $256$ units each and ReLU non-linearity. Moreover, the optimizer is Adam with learning rate $3 \cdot 10^{-4}$, discount factor $\gamma = 0.99$, replay buffer size $1M$, target update rate of $5\cdot 10^{-3}$ and a batch size of $100$ for both the TD3 as well as SAC. For the TD3 we us a target update delay of $2$, a policy noise of $0.2$ with a noise clip of $0.5$. \begin{figure*}[hbt!] \centering \vspace{0,2 cm} \begin{tabular}{ccccccccccccc} \toprule {} & \multicolumn{4}{c}{{\bf Q$-$MLP TD3}} & \multicolumn{2}{c}{{\bf TD3}} & \multicolumn{4}{c}{{\bf Q$-$MLP SAC}} & \multicolumn{2}{c}{{\bf SAC}} \\ \midrule {\bf Environment} & {\bf $n_h$} & {$\kappa$} & {\bf $n_f$}& {\bf weights} & {\bf $n_h$} & {\bf weights} &{\bf $n_h$} &{$\kappa$}& {\bf $n_f$}& {\bf weights} &{\bf $n_h$} & {\bf weights} \\ \midrule {Ant-v3} & 64 & 0.1 & 62 & {\bf 26.1k} & 256 & {96.5k} & 128& 0.1 & 62& {\it 47.7k} &256 & {98.6k} \\ {BipedalWalker-v3} & 192 & 1.0 & 300 & {\bf 58.2k} & 256 & {73.2k} & 192 &1.0 & 300& {\it 60.2k} &256 & {74.2k} \\ {HalfCheetah-v3} & 192 & 1.0 & 153 & {\bf 47.8k} & 256 & {71.9k} & 192 &1.0 & 153& {\it 49.9k} &256 & {73.5k} \\ {Hopper-v3} & 128 & 1.0 & 66 & {\bf 20.1k} & 256 & {69.6k} & 128& 1.0 & 66& {\it 20.6k} &256 & {70.4k} \\ \midrule {Humanoid-v3} & 192 & 0.02& {28$^\ast$} & {\bf 134.2k} & 256 & {166.7k} & 224 & 0.02 & {28$^\ast$}& {\it 164.5k} &256 & {171.0k} \\ {Walker2d-v3} & 64 & 1.0& 153 & {\bf 11.8k} & 256 & {71.9k} & {128} & 1.0& 153& {\it 27.4k} &256 & {73.5k} \\ \bottomrule \end{tabular} \caption{ Hyperparameter details of the actor policy networks. Hidden dimensions and total weight numbers of the Q-MLP and MLP neural networks used in the the main study see figures \ref{fig:mainresults} and tables \ref{tab:bestRun} and \ref{tab:sampleEfficient}. Note that the total number of weights is influenced by the observation and action space dimensions of the environment. Moreover, as the SAC algorithm admits a deterministic as well as stochastic policy each admitting the same number of weights displayed in the table, respectively. The asterisk symbolises that we have initialized the quadratic neuron with zero weights in contrast to the standard Kaiming uniform initializer \cite{he2015delving} used in pytorch \cite{NEURIPS2019_9015}.} \vspace{-0.6 cm} \label{tab:HypPar1} \end{figure*} \vspace{0,5 cm} \section*{ACKNOWLEDGMENT} \vspace{0,2 cm} We would like to thank Yoshiteru Nishimura for his technical assistance. The current work is, partly, supported by JSPS KAKENHI Grant Number JP18H03287 and JST CREST Grant Number JPMJCR1913. \vspace{0,5 cm} \nocite{*} \bibliographystyle{IEEEtran}
{'timestamp': '2021-03-12T02:20:32', 'yymm': '2103', 'arxiv_id': '2103.06617', 'language': 'en', 'url': 'https://arxiv.org/abs/2103.06617'}
arxiv
\section{Introduction} Convolutional neural networks, and deep learning in general, have received a lot of attention in the past few years \cite{krizhevsky2012imagenet,he2016deep,BMVC2016_87,guo2018review,georgiou2019survey} and have been applied in many research areas, such as image understanding \cite{guo2018review,georgiou2019survey}, natural language processing \cite{young2018recent,ruder2019transfer} and game solving \cite{mnih2015human}. The research in these models has been motivated by the success of deep learning in image classification with AlexNet \cite{krizhevsky2012imagenet} and later by much deeper models such as VGG \cite{DBLP:journals/corr/SimonyanZ14a}, ResNet \cite{he2016deep} and wide-ResNet \cite{BMVC2016_87}. In order to understand these models and enhance their performance, a lot of research has been carried out and in many directions \cite{guo2018review,georgiou2019survey}, including data preprocessing strategies \cite{cubuk2019autoaugment,lim2019fast}, activation normalization \cite{wang2018kalman,wu2018group}, weight regularization \cite{bansal2018can,huang2020controllable}, activation functions \cite{trottier2017parametric}, and overall network architectures \cite{he2016deep,BMVC2016_87,han2017deep}. In this work we focus on weight regularization methods and propose a new soft regularization loss function, the norm loss.\par Weight regularization has been a wide research topic. The main issues of deep learning training procedures are the exploding/vanishing gradients, as well as the scaling-based weight space symmetry and covariant-shift \cite{pmlr-v37-ioffe15,huang2017projection,bansal2018can}. In order to alleviate one or more of the aforementioned issues, researchers are developing methods that restrict the search space of possible weight vectors.\par One of the first approaches, and most popular, is the weight decay \cite{krizhevsky2012imagenet}, which adds a penalty to the Euclidean norm of the weight vector. In the past few years a number of approaches and theories have emerged, regarding weight regularization, such as weight normalization \cite{salimans2016weight,huang2017projection} and weight orthogonalization \cite{huang2018orthogonal,bansal2018can,huang2020controllable}. The most popular goal for regularization methods has been weight orthogonalization. The reason is that orthogonal weights have very nice properties in relation to deep network training \cite{bansal2018can,pmlr-v80-chen18i,huang2020controllable}. For example, orthogonal weights can obtain dynamical symmetry \cite{huang2020controllable} which accelerates convergence. Nonetheless, it is not always possible to have orthogonal weights, due to the fact that in many DNN architectures, the weight matrices are over-complete. Moreover, hard-orthogonalization can restrict the learning capacity of a network \cite{bansal2018can}. As an oversimplified, intuitive example of learning capacity restriction we show the schematic visualization of the weights of two $3\times3$, one-channel kernels in Figure \ref{fig:exKernels}. A combination of (a) with a ReLU activation function would result in upper edge detection, while the combination of (b) with a ReLU activation function would result in lower edge detection. The inner product of these filters is -1 and thus wouldn't be possible to have both kernels in a layer restricted to orthogonal weight matrices. Thus, we believe that in some cases weight orthogonalization can be too restrictive, hurting the final performance. In order to overcome this limitation some authors, like \cite{bansal2018can}, reduce the effect of regularization after some point during training, or drop it completely.\par \begin{figure}[t!] \centering \includegraphics[width=.6\linewidth]{exampleKernels.eps} \caption{ Schematic visualization of the weights of two example $3\times3$ one-channel kernels. White (dark) values indicate high (low) numbers. The weight matrix in example (b) is a 180\degree rotated version of (a).} \label{fig:exKernels} \end{figure} In this paper we focus on weight regularization by imposing a normalization constraint and propose a new soft-regularization method pushing the weight matrix into the Oblique manifold \cite{absil2006joint,huang2017projection}. To that end we propose a loss function, the norm loss. We evaluate our method with state-of-the-art networks on standard research benchmarks, i.e. CIFAR-10, CIFAR-100 \cite{krizhevsky2009learning} and ImageNet 2012 \cite{russakovsky2015imagenet} and show that networks trained with the norm loss achieve comparable to the state-of-the-art performance and in some cases superior to it, while having negligible computational overhead. To the best of our knowledge we are the first to propose this regularization loss function.\par The rest of this paper is organized as following. In Section \ref{sec:relatedWork} we discuss the related to our approach research, in Section \ref{sec:preliminaries} we discuss the theory on which our method is based and in Section \ref{sec:proposedMethod} we describe the proposed method. In Section \ref{sec:experiments} we discuss the experimental procedure and show our results and finally in Section \ref{sec:conclusion} we derive our conclusions.\par \section{Related Work} \label{sec:relatedWork} There are many methods that try and alleviate the scaling-based weight space symmetry and the exploding gradients problems. Most of them can be classified into one of two groups, namely hard-regularization and soft-regularization \cite{huang2020controllable}. A very well known approach is the inclusion of the weight decay loss to the total loss which imposes a penalty to the magnitude of the weight vectors \cite{krizhevsky2012imagenet}. It can be considered as a soft-regularization method, since it applies a small change to the weights or the gradients (according to the implementation) in every step. Although this method does address the exploding gradients issue, it does not address the scaling-based weight space symmetry problem. Most methods try to normalize the weights, i.e. force them to have unit norm, make them orthogonal, i.e $\mathbf{W}^T\mathbf{W} = I*\lambda, $ where $ \lambda$ is a small scaling factor, or both, i.e. $\mathbf{W}^T\mathbf{W} = I$. Another work proposed to use the norm of the CNN Jacobian as a training to regularize the models \cite{sokolic2017robust}, while \cite{yoshida2017spectral} proposed spectral norm regularization, which penalizes the high spectral norm of weight matrices.\par Hard-regularization methods specify hard limits for the weights. For example, \cite{salimans2016weight} divide the weight vector with its norm ($\mathbf{W}^* = \frac{\mathbf{W}}{\|\mathbf{W}\|}$), before applying them to the input, ensuring that the applied weights are normalized. This method is computationally expensive since the normalization happens on the fly. A later work \cite{huang2017projection} ensures that the weights are normalized by normalizing the weight vector every $T$ iterations, i.e. instead of normalizing on the fly they change the original weight vector. This method is more computationally efficient than the previous one and experiments show that it also produces higher performing networks. Moreover, it is the most similar to our approach as we are targeting the same goal but with a soft constraint. Instead of abruptly changing the weights to force unit norm, we add a term to the loss function (instead of the weight decay) to smoothly guide the weights towards unit norm.\par Other regularization methods try to force the weights to be orthogonal to each other, i.e $\mathbf{W}^T\mathbf{W}=I$ \cite{huang2018orthogonal,huang2020controllable}. Some works \cite{vorontsov2017orthogonality,bansal2018can,xie2017all,balestriero2018spline} apply soft regularization methods by utilizing the standard Frobenius norm and define a term in the training loss function which requires the Gram matrix of the weight matrix to be close to identity, i.e.: \begin{equation} L = \lambda\|\mathbf{W}^T\mathbf{W}-I\| \end{equation} Although this is an efficient method, when considering over-complete weight vectors it can only be a rough approximation \cite{bansal2018can}. In order to overcome this issue, \cite{bansal2018can} proposed and tested a number of different regularization terms, all focused around weight orthogonalization. Our method is similar to the aforementioned, in the sense that we apply a loose regularization term on the loss function. Our is a bit softer regularization since we only loosely constrain the norm of the weight vectors and do not force them to be orthogonal. Although orthogonal weights have many nice properties, they also restrict the learning capacity of the weights \cite{huang2020controllable}.\par One of the first works that implemented weight orthogonalization with hard regularization, did so for only fully connected layers \cite{harandi2016generalized}. They defined the generalized back propagation algorithm and compute gradients on the Stiefel manifold. Though this procedure requires the form of Riemannian gradient and a retraction mechanism, which are computationally intensive. In a later work \cite{ozay2016optimization} extended this approach to convolutional layers as well. \cite{huang2018orthogonal}, \cite{huang2020controllable} propose re-parameterization techniques in order to overcome the limitations of a retraction mechanism. \cite{huang2018orthogonal} uses eigen decomposition to calculate the transformation, whilst \cite{huang2020controllable} used the Newtonian iteration (ONI), which is shown to be more stable and more computationally efficient. The last method also allows for weights to be orthogonal but not normalized, i.e. $\mathbf{W}^T\mathbf{W} = I*\lambda$. The approach proposed in this paper provides a softer regularization than all aforementioned, with the exception of weight decay, whilst having negligible computational overhead.\par \section{Preliminaries} \label{sec:preliminaries} Given a set of corresponding sets $\{\mathbf{X}, \mathbf{Y}\}$, where every $x_i\in \mathbf{X}$ has a unique corresponding value, or ground-truth label, $y_i\in \mathbf{Y}$, a neural network $f$ should predict the value $y_i$ for the corresponding input $x_i$ with a set of model parameters $\mathbf{W}$. For a given set of model parameters, the neural network output, i.e. the predicted values $\tilde{y_i}=f(x_i,\mathbf{W})$, does not match the desired output $y_i$. If $\mathbf{E}$ is the discrepancy between the $\mathbf{Y}$ and the predicted values $\tilde{\mathbf{Y}}$, the aim of the network training process is to find a set of parameters $\mathbf{W}$ that minimize $E(\mathbf{Y}, \tilde{\mathbf{Y}})$. This is done with the help of a differentiable loss function $L(\mathbf{Y}, \tilde{\mathbf{Y}})$. The training process is carried out by changing by a small factor the set of parameters $\mathbf{W}$ in the direction that minimizes $L(\cdot)$. For an example $x_i, y_i$ or a set of examples $\{\mathbf{X}, \mathbf{Y}\}$ the direction is given by the gradients of $L$, and the weights $\mathbf{W}$ are updated as follows: \begin{equation} \label{eq:euclideanGradient} \mathbf{W}_{new} = \mathbf{W} - \eta\frac{\partial L}{\partial \mathbf{W}} \end{equation} where $\eta\ll 1$ denotes the learning rate. For clarity, we make the following remark: Since the Oblique manifold defines matrices with normalized rows, we construct the weight matrix as a row-matrix of the individual weight vectors of each filter, $\mathbf{W} \in \mathbb{R}^{n \times p}$ where $p$ is the dimensionality of each weight vector of a filter, while $n$ is the number of filters. This corresponds to the transpose of the weight matrix typically used in the orthogonality related literature \cite{bansal2018can}.\par As shown by \cite{huang2017projection}, the Hessian matrix can be ill-conditioned due to the scaling-based weight space symmetry. In an effort to avoid this issue they propose to optimize the network parameters using the Riemannian optimization \cite{absil2009optimization} over the Oblique manifold. The Oblique manifold $\mathcal{BO}(n, p)$ defines a subset of $\mathbb{R}^{n \times p}$, where for every $\mathbf{W} \in \mathcal{BO}(n, p)$: \begin{equation} \label{eq:oblique} ddiag(\mathbf{W}\mathbf{W}^T) = I \end{equation} where $ddiag(\cdot)$ is a function that sets all elements of an input array except the diagonal to zero. The above formulation restricts all rows of the matrix $\mathbf{W}$ to have a norm of one. Notice that imposing the requirement of equation \ref{eq:oblique} is less restricting than the usual orthogonalization requirement $\mathbf{W}\mathbf{W}^T = I$, since it only enforces a unit norm but does not enforce the weight vectors to be orthogonal to each other.\par Given a set of weights $\mathbf{w}$ of a single neuron, i.e., $\mathbf{w} \in \mathbb{R}^{1 \times p}$, where $\mathbf{w}\mathbf{w}^T = 1$, the Riemannian gradients are given by the following equation \cite{huang2017projection}: \begin{equation} \label{eq:riemannianDerivative} \widehat{\frac{\partial L}{\partial \mathbf{W}}} = \frac{\partial L}{\partial \mathbf{W}} - \left(\mathbf{W}^T\frac{\partial L}{\partial \mathbf{W}}\right)\mathbf{w} \end{equation} where the norm of the gradients is bound \cite{huang2017projection}: \begin{equation} \label{eq:dominantFactor} \left\|\frac{\partial L}{\partial \mathbf{W}}\right\| \leq \left\|\left(\mathbf{W}^T\frac{\partial L}{\partial \mathbf{W}}\right)\mathbf{w}\right\| \end{equation} From equation \ref{eq:dominantFactor} and experimental evidence they conclude that $\frac{\partial L}{\partial \mathbf{W}}$ is the dominant factor of the derivative in equation \ref{eq:riemannianDerivative} and thus propose to apply the Euclidean gradient (equation \ref{eq:euclideanGradient}) and then project the weights back to the Oblique manifold by normalizing them: \begin{equation} \label{eq:weightNormalization} \mathbf{w}^{new} = \frac{\mathbf{w}}{\|\mathbf{w}\|} \end{equation} \section{Proposed method} \label{sec:proposedMethod} Inspired by the insights of using the Riemannian gradients described in the previous section, we propose to use a similar normalization for neural network training. However, the hard change in the weights after normalization can cause disturbance in the training process since they abruptly shift the weights from the direction of the original gradients. This can be a problem with large learning rates or large projection period $T$, where $T$ is the number of training steps between each projection operation \cite{huang2017projection}. In order to overcome this issue we propose a soft regularization method that instead of abruptly changing the weights, slowly guides them towards the Oblique manifold, i.e., to have unit norm. We implement that by introducing a normalization loss, or norm loss (nl): \begin{equation} \label{eq:normLoss} L_{nl} = \sum_{c_o = 1}^{C_o}\left(1 - \sqrt{\sum_{c_i=1}^{C_i}\sum_{i=1}^{F_h}\sum_{j=1}^{F_w}w_{ijc_ic_o}^2} \right)^2 \end{equation} where $F_w, F_h, C_i, C_o$ are the filter (or weight vector) width, height, number of input and number of output channels respectively. The loss is penalizing the weight vector of each neuron if its Euclidean norm is different from one. The final loss function then becomes: \begin{equation} \label{eq:totalLoss} L_{total} = L_{target} + \lambda_{nl}\cdot L_{nl} \end{equation} where $\lambda_{nl}$ a small factor that determines how strong the regularization will be and $L_{target}$ is the loss function defined by the task to be solved, e.g., triplet loss function, cross entropy loss etc.\par \subsection{Connection to weight decay} \label{sec:conWeightDeacay} The weight decay is similar to our loss since it introduces a small penalty on the magnitude of the weights. The loss function for the weight decay is given by: \begin{equation} L_{wd} = \sum_{c_o = 1}^{C_o} \sum_{c_i=1}^{C_i} \sum_{i=1}^{F_h} \sum_{j=1}^{F_w} w_{ijc_ic_o}^2 \end{equation} There are two main differences. Firstly, weight decay penalizes the absolute magnitude of the weight vector while norm loss penalizes the deviation to having unit norm. This means that in the case the norm is smaller than one, our method will try to increase it, whilst the weight decay will continue pushing to decrease it. This makes a difference in situations where some components are rarely being utilized (e.g., due to nonlinearities such as the ReLU) in which case the main loss changing these components is the weight decay loss, resulting in very small weights that might never recover. The second difference is that it applies to all components of a layer uniformly, whilst the norm loss differentiates between the vectors of each output channel. This can be seen by the derivatives of each method. The derivatives for each component of the weight matrix are given by: \begin{equation} \label{eq:weightDecayDer} \frac{\partial L_{wd}}{\partial w_{ijc_ic_o}} = 2w_{ijc_ic_o} \end{equation} From Equation \ref{eq:normLoss} it is easy to derive the gradients of the norm loss (Derivation can be found in the appendix): \begin{equation} \label{eq:normLossDer} \frac{\partial L_{nl}}{\partial w_{ijc_ic_o}} = 2w_{ijc_ic_o}\left (1 - \frac{1}{\|w_{c_o}\|}\right) \end{equation} where $\|w_{c_o}\|$ is the norm of the weight vector of a single neuron, with index $c_o$. Comparing equations \ref{eq:weightDecayDer} and \ref{eq:normLossDer} we can see that effectively norm loss can be seen as an extension of the weight decay where the weight decay factor and its sign are regulated during training by the norm of the weight vector. This is explicitly visible from the overall update rule (combining equations \ref{eq:euclideanGradient}, \ref{eq:totalLoss}, \ref{eq:normLossDer}): \begin{equation} \label{eq:upadateRule} \mathbf{w}^{new} = \mathbf{w} -\eta\lambda_{nl}2\left (1 - \frac{1}{\|w_{c_o}\|}\right)\mathbf{w} - \eta\frac{\partial L_{target}}{\partial \mathbf{w}} \end{equation} \subsection{Computational cost} For a convolutional layer with $C_o$ filters of shape $F_h\times F_w\times C_i$, the computational cost of weight decay is two operations per weight, thus $2\cdot C_o\cdot F_h\cdot F_w\cdot C_i$. For the norm loss it is $3 \cdot C_o \cdot (F_h\cdot F_w \cdot C_i) + C_o + 2\cdot C_o\cdot F_h\cdot F_w\cdot C_i$. The overhead then is $3 \cdot C_o \cdot (F_h\cdot F_w \cdot C_i) + C_o$. The computational cost of a convolutional layer is $6 \cdot m \cdot C_o \cdot C_i \cdot F_h \cdot F_w \cdot I_h \cdot I_w$, where $m, I_h, I_w$ are the number of images in a mini batch, and the input (to the layer) image height and width respectively. The computational overhead of the norm loss is orders of magnitude smaller than the computational cost of a convolutional layer with weight decay, for usual network and image input sizes. \section{Experiments} \label{sec:experiments} We evaluate our method on three well known benchmarks, i.e., CIFAR-10, CIFAR-100 and ImageNet2012. CIFAR-10 consists of 50K training and 10K test $32\times 32$ natural images, divided into 10 classes. CIFAR-100 also consists of 50K training and 10K test natural images with the same resolution, but in this dataset they are divided into 100 classes. For both CIFAR-10 and CIFAR-100 we evaluate using classification error on the designated test sets. The ImageNet 2012 is a large scale image recognition dataset. The train set consists of 1.281 million natural images of arbitrary resolution and aspect ratio. The images are divided into 1000 classes. The validation set consists of 50K images, i.e. 50 images per class. We evaluate our method on the validation set top 1 and top 5 error rates, as is common practice in the field.\par We utilize two different state-of-the-art architectures, namely the ResNet \cite{he2016deep} and the wide ResNet (WRN) \cite{BMVC2016_87}, since they are usual test cases for weight regularization methods \cite{huang2017projection,huang2018orthogonal,huang2020controllable,bansal2018can}. Both ResNet and WRN have been defined for many different sizes with different learning capacity. Unfortunately, training such big networks is very computationally expensive and thus we choose only one architecture per model. For all our three benchmarks we utilize the cross-entropy loss function as our target loss function ($L_{target}$).\par We compare our method with state-of-the-art approaches, like weight decay (wd), weight normalization (WN)\cite{salimans2016weight}, projection based weight normalization (PBWN)\cite{huang2017projection}, orthogonalization with Newton iteration (ONI)\cite{huang2020controllable}, orthogonal linear module (OLM)\cite{huang2018orthogonal}.\par \subsection{Regularization factor} With our first experiment we evaluate the effect of the regularization factor $\lambda_{nl}$ on the training. As a benchmark we use the CIFAR-100 dataset. We train for four different values of $\lambda_{nl}$ and plot our results in Figure \ref{fig:reg_factor}. It is apparent that the effect of $\lambda_{nl}$ on the training is much smaller than that of $\lambda_{wd}$ in the case of weight decay. We believe that this results from the regularization of the $\lambda_{nl}$ factor discussed before (equation \ref{eq:upadateRule}).\par \begin{figure}[h] \centering \includegraphics[width=\linewidth]{reguralizationFactor.png} \caption{Test error of WRN-28-10 on CIFAR-100 with weight decay and norm loss for different regularization factors.} \label{fig:reg_factor} \end{figure} \begin{figure}[h] \centering \includegraphics[width=\linewidth]{crossEtropyDuringTraining.png} \caption{Evolution of cross entropy during training on CIFAR-100 for weight decay and norm loss. The regularization factor for both runs is 5e-4. The shaded lines are the true lines, whilst the non-shaded are smoothed version of the original (averaged over 19 steps) for more comprehensive visualization.} \label{fig:trainCrossEntropy_cifar100} \end{figure} Figure \ref{fig:trainCrossEntropy_cifar100} shows the evolution of the train cross entropy (per batch) during training, for the case of $\lambda=5\cdot 10^{-4}$. We can see that with the norm loss, the networks are being trained faster than with weight decay, even in the case where the weight decay training has marginally higher accuracy in the end of training (see Figure \ref{fig:reg_factor}).\par \subsection{Batch size} \begin{figure}[h] \centering \includegraphics[width=\linewidth]{batchSizeResults.png} \caption{Test error of WRN-28-10 on CIFAR-100 with weight decay and norm loss for different batch sizes.} \label{fig:batch_size} \end{figure} The next experiment is to test the training behavior for different batch sizes. We train networks with both weight decay and our method for batch sizes $\{8,16,32,64,128\}$ on CIFAR-100. The performance of the trained networks on the test set can be seen in Figure \ref{fig:batch_size}. We can see that the norm loss has more steady behavior than the weight decay. We can still see some dependence on the batch size, which is expected since our networks utilize batch normalization. Moreover, although for most batch sizes tested the networks trained with norm loss show better performance, only for batch size 128 the opposite is true. Finally, we can see that the highest overall performance for both methods is achieved by the networks trained with batch size 64.\par \subsection{CIFAR-10} On this dataset we train on the ResNet110 and WRN-28-10. As is common practice \cite{he2016deep,BMVC2016_87} we train the networks using SGD with Momentum of 0.9 and a batch size of 128. The initial learning rate is set to 0.1. We follow a learning schedule close to the one used in \cite{BMVC2016_87}. When training the WRN, we drop the learning rate by a factor of 5 at epochs 53, 107, 230 and we train for a total of 300 epochs. For the ResNet we train for 164 epochs and reduce the learning rate at epochs 82 and 123. We follow the standard preprocessing for training as in \cite{he2016deep,BMVC2016_87,bansal2018can}, i.e. padding each train example by four pixels and getting a random $32\times32$ crop. Both train and test sets are mean and std normalized \cite{BMVC2016_87}. We train five times and report the mean as well as the best run. For both networks, the regularization factor $\lambda_{nl}$ is set to 0.01 while the weight decay factor $\lambda_{wd}$ is set to $10^{-4}$ for the ResNet and $5\cdot 10^{-4}$ for the WRN, as in the original papers \cite{he2016deep,BMVC2016_87}. The results can be seen in Table \ref{tab:cifar10_results}.\par \begin{table}[h] \renewcommand{\arraystretch}{1.3} \caption{Performance of different methods on CIFAR-10 test set for the ResNet110 and WRN-28-10. In parentheses are the mean or median over some runs given by the authors of the respective papers. Outside parentheses the best accuracy (if shown by the authors). For methods denoted by *, the performance is given in the respective papers.} \label{tab:cifar10_results} \centering \begin{tabular}{lrr} \toprule model & reg. method & error \\ \midrule ResNet110 & wd & 6.32 (6.568)\\ ResNet110 \cite{he2016deep}* & wd & 6.43 (6.61) \\ ResNet110 \cite{salimans2016weight}* & WN & - (7.56) \\ ResNet110 \cite{huang2017projection}* & PBWN & - (6.27) \\ ResNet110 \cite{huang2020controllable}* & ONI & - (6.56) \\ ResNet110 (Ours) & nl & 5.9 (5.996) \\ \midrule WRN-28-10 & wd & 3.9 (3.966) \\ WRN-28-10 \cite{BMVC2016_87}* & wd & - (3.89) \\ WRN-28-10 \cite{huang2018orthogonal}* & OLM\ & - (3.73) \\ WRN-28-10 \cite{huang2018orthogonal}* & OLM-L1\ & - (3.82) \\ WRN-28-10 (Ours) & nl & 4.47 (4.662) \\ \bottomrule \end{tabular} \end{table} When training the ResNet110 we manage to outperform all other regularization methods we are aware of, that tested on the same network \cite{huang2020controllable,salimans2016weight,huang2017projection}. We also outperform the reported accuracy of the SRIP regularization method of \cite{bansal2018can}. Due to large difference with our and their baseline performance, we do not consider it a valid comparison and thus their result is omitted from Table \ref{tab:cifar10_results}.\par When training the WRN-28-10 we observe a big decrease in performance over our benchmark. Figures \ref{fig:trainCrossEntropy_cifar10}, \ref{fig:testAccuracy_cifar10} show the training process of the WRN-28-10 on the CIFAR-10 with weight decay and norm loss. We can see that even in this case, where the final performance of weight decay is better, the network that utilizes the norm loss is converging much faster and shows more stable behavior. More experimentation is needed to understand why in this specific scenario the final performance is worse than the baseline. For example, a schema like the one used in \cite{bansal2018can} could be used, where from a certain epoch on the regularization is minimized or even dropped completely.\par \begin{figure}[h] \centering \includegraphics[width=\linewidth]{crossEtropyDuringTrainingCIFAR10.png} \caption{Evolution of cross entropy during training on CIFAR-10 for weight decay and norm loss for the WRN-28-10. The shaded lines are the true lines, whilst the non-shaded are smoothed version of the original (averaged over 19 steps) for more comprehensive visualization.} \label{fig:trainCrossEntropy_cifar10} \end{figure} \begin{figure}[h] \centering \includegraphics[width=\linewidth]{testAccuracyCIFAR10.png} \caption{Evolution of test accuracy during training on CIFAR-10 for weight decay and norm loss for the WRN-28-10.} \label{fig:testAccuracy_cifar10} \end{figure} In order to evaluate the computational overhead of our method, we report that training the ResNet110 on CIFAR-10 with weight decay takes, on average, 4.56 hours while training the same network with norm loss takes, on average, 4.79 hours. All aforementioned experiments ran on an Intel(R) Xeon(R) CPU E5-2699 v4 @ 2.20GHz and an NVIDIA GTX 1080Ti graphics card.\par \subsection{CIFAR-100} As with CIFAR-10, for this section we use the same hyper parameters as in \cite{BMVC2016_87}, with a slightly different learning rate schedule. We train the WRN using a batch size of 64 instead of 128, because it results in better performance even for the baseline method. The regularization factor $\lambda_{nl}$ was set to $10^{-3}$ and the $\lambda_{wd}$ to $5\cdot 10^{-4}$. We train for a total of 448 epochs and reduce the learning rate by a factor of 5 in epochs 77, 153 and 307. We train the ResNet for 300 epochs and drop the learning rate at epochs 53, 107, 230. We train 5 times and report the accuracy of the mean and best run. The results are shown in Table \ref{tab:cifar100_results}. We also trained with the learning rate scheduler used for ResNet110 on CIFAR-10, i.e. 164 epochs and reduce the learning rate at epochs 82 and 123, but the aforementioned scheduler produced results for the baseline that match the literature and thus is reported on Table \ref{tab:cifar100_results}. For clarity we also report the results using the CIFAR-10 scheduler: Average error for the weight decay is $28.094$ with a best run of $27.56$ whilst for the norm loss the average error is $25.878$ with a best run of $25.2$. For all ResNet experiments, the regularization factor $\lambda_{nl}$ was set to $10^{-2}$ and the $\lambda_{wd}$ to $10^{-4}$.\par The norm loss manages to produce better performance than most methods for both ResNet110 and WRN-28-10. Although in the case of CIFAR-10 we managed to outperform the method developed in \cite{bansal2018can} (results were omitted from the tables due to large difference of their and our baseline performance), in the case of CIFAR-100 their methods outperform our own. For the same reason as before their results are omitted (25.42\% vs 27.49\% accuracy for the baseline ResNet110). It should be noted that they used a different optimizer for their experiments, the Adam optimizer \cite{DBLP:journals/corr/KingmaB14}. \begin{table}[h] \renewcommand{\arraystretch}{1.3} \caption{Performance of different methods on CIFAR-100 test set for the ResNet110 and WRN-28-10. In parentheses are the mean or median over some runs given by the authors of the respective papers. Outside parentheses the best accuracy (if shown by the authors). For methods denoted by *, the performance is given in the respective papers. } \label{tab:cifar100_results} \centering \begin{tabular}{lrr} \toprule model & reg. method & error \\ \midrule ResNet110 & wd & 27.9 (28.398) \\ ResNet110 \cite{salimans2016weight}* & WN & - (28.38) \\ ResNet110 \cite{huang2017projection}* & PBWN & - (27.03) \\ ResNet110 (Ours) & nl & 26.24 (26.526) \\ \midrule WRN-28-10 & wd & 18.85 (19.138) \\ WRN-28-10 \cite{BMVC2016_87}* & wd & - (18.85) \\ WRN-28-10 \cite{huang2018orthogonal}* & OLM & - (18.76) \\ WRN-28-10 \cite{huang2018orthogonal}* & OLM-L1 & - (18.61) \\ WRN-28-10 (Ours) & nl & 18.57 (18.648) \\ \bottomrule \end{tabular} \end{table} \subsection{ImageNet} For the ImageNet dataset, we utilize the ResNet50 architecture to evaluate our method. We use the same data augmentation and hyper parameters (for batch normalization, dropout rates, etc.) as the implementation of \cite{huang2017projection} on GitHub\footnote{https://github.com/huangleiBuaa/NormProjection}. We train using SGD with Nesterov momentum of 0.9. The learning rate is initialized at 0.1 and divided by 10 every 30 epochs. We train with a batch size of 128, whilst due to GPU memory limitations, the batch normalization parameters are trained on half, i.e. 64 examples. The regularization factor for both methods, i.e. $\lambda_{nl}, \lambda_{wd}$ is set to $10^{-4}$ The top-1 and top-5 error rates \footnote{Top-1 error is 100 - classification accuracy. Top-5 error counts a correct classification if the ground truth label is in the top-5 predictions of the network.} of the networks on the ImageNet 2012 validation set are shown in Table \ref{tab:imageNet_results}.\par The results are shown in Table \ref{tab:imageNet_results}. The first two rows show the performance of the baseline method as reported in literature\cite{huang2020controllable} and our attempt at reproducing it. As it can be seen, there is a large difference between the results as our error is much larger than the one reported in literature. The origin of this is currently not clear to us and therefore a direct comparison of performance numbers is not warranted. Nonetheless, we can observe that for our implementations the norm loss approach improves both TOP-1 and TOP-5 performances substantially over weight decay.\par \begin{table}[t!] \renewcommand{\arraystretch}{1.3} \caption{Top-1 and Top-5 error rates of different methods on ImageNet validation set for the ResNet50. For methods denoted by *, the performance is given in the respective papers.} \label{tab:imageNet_results} \centering \begin{tabular}{lrrr} \toprule model & reg. method & Top-1 error & Top-5 error\\ \midrule ResNet50 & wd & 25.29 & 7.86 \\ ResNet50 \cite{huang2020controllable}* & wd & 23.85 & - \\ ResNet50 \cite{huang2020controllable}* & ONI & 23.30 & - \\ ResNet50 (Ours) & nl & 24.34 & 7.44 \\ \bottomrule \end{tabular} \end{table} \section{Conclusion} \label{sec:conclusion} In this work we proposed a new soft-regularization method, that tries to guide the weight vector towards the Oblique manifold. It accomplishes that by utilizing the proposed norm-loss function as regularization during the neural network training.\par We evaluate our method on standard benchmarks, i.e. CIFAR-10, CIFAR-100 and ImageNet 2012 and compare the performance to the state-of-the-art regularization methods. Our method accelerates the convergence speed of networks and leads to a more robust, i.e.\ less sensitive training process with regard to the hyperparameters settings for the regularization factor and the batch size. While having a negligible computational overhead over weight decay during training, and no extra computational cost during inference, our method has comparable performance to the state-of-the-art and some cases even higher, while only for one setup our method is under performing, i.e. WRN-28-10 on CIFAR-10. \par \section*{Acknowledgment} This work is part of the research program DAMIOSO with project number 628.006.002, which is partly financed by the Netherlands Organization for Scientific Research (NWO) and partly by Honda Research Institute-Europe (GmbH). \bibliographystyle{IEEEtran}
{'timestamp': '2021-03-12T02:19:06', 'yymm': '2103', 'arxiv_id': '2103.06583', 'language': 'en', 'url': 'https://arxiv.org/abs/2103.06583'}
arxiv
\subsection*{Acknowledgement} The OxAI society is grateful for support from Google Academic Research Credits program. {\small\bibliographystyle{iclr2021_conference} \section{Introduction} Deep learning-based methods have enjoyed tremendous gains over the past years. While this has also been due to better architectures, a large part of this success is due to the ever-increasing size of datasets. However, there are two major problems with the current datasets that the research community is increasingly becoming aware of and that could limit the progress in this domain if not addressed. First, datasets are being revealed to be heavily biased. Works such as \citep{buolamwini_gebru2018,yang2020towards} find significant underrepresentation of women and those with darker skin in common datasets. Biases in datasets, in turn, manifest as bias within models. For example, an image labelling algorithm from Google was found to label an image of two black people "Gorilla" \citep{simonite2018google} and facial analysis models have been found to have significantly lower accuracy on darker female faces than on lighter male faces~\citep{buolamwini_gebru2018}. A second problem is the lack of consent for using these images to train AI models: As noted in~\citep{prabhu2020large} while these datasets are collected under the Creative Commons licence, this license does not yield or say anything about their use in training AI models. This can potentially violate the licenses (as reproduction requires the ascription of the creator) since trained models can be probed to reveal whole training samples, such as addresses and bank accounts in GPT-2~\citep{carlini2020extracting} or potentially even images~\citep{orekondy18gradient}. Therefore, there is a clear need for the removal of personally identifiable information within images. This would not only protect the individuals within the images (e.g. reduced risk of identify theft) but also ensure higher adherence to the General Data Protection Regulation (GDPR). One common variable in both problems is the usage of raw, unedited data which tends to be either privacy infringing or biased. However, since collecting an unbiased dataset with consenting individuals would be very costly and potentially even unfeasible~\citep{yang2020towards}, in this paper we investigate approaches to mitigating these problems by modifying the current training data. Specifically, our contributions are as follows: \begin{enumerate} \item We investigate privacy-preserving measures on object detection performance. \item We develop a novel method for balancing gender and race distribution in the training data while simultaneously removing personally-identifying information. \item We test the fine-tuned models with two measures of model bias. \end{enumerate} \section{Related work} \paragraph{Measuring Bias.} Experimentally, it has been shown that many models are biased: For example~\cite{buolamwini_gebru2018} show that face recognition tools perform worse for women of colour than white men, and in~\citep{simonite2018google, kayserbril2020googlevision} publicly available models have been shown to be biased towards minorities. Furthermore, \citet{steed2021biases} find that unsupervised models trained on ImageNet contain racial, gender, and intersectional biases. We use their test to probe bias in our models. To mitigate biases, \cite{zhang2016discrimination} develop a method to remove discriminatory effects of collected datasets prior to its statistical analysis. Even with a balanced dataset, a model can amplify implicit gender biases, as shown by \cite{wang2019balanced}, who propose to use a generative-adversarial approach to remove this information by painting over that part of the image. In this paper, we focus on how input data can be efficiently transformed to make datasets more balanced and potentially remove the association biases of stereotypes. \paragraph{Preserving Privacy.} Privacy is important within computer vision given the potential contradiction between using image recognition algorithms while at the same time limiting elements which expose identifiable and sensitive information. Preserving privacy in computer vision models has already been addressed to an extent using various methods, such as head inpainting~\citep{Sun2018inpainting}, reducing resolution quality~\citep{Ryoo2016lowres}, and many more~\citep{ren2018privacy, Wu2018preservingprivacy}. Notably, \citep{Orekondy2018privacy} showed how to apply targeted obfuscation to areas of private information as to protect privacy yet also preserve the utility of the image. However, so far little work has evaluated performances of preserving privacy on modern object detection algorithms. \paragraph{Face Swapping.} There has also been work in the area of transferring a face onto a target in a similar pose. \cite{Zhong2016} paste celebrity faces onto images to generate a synthetic dataset of novel (celebrity face, action) pair images. \paragraph{Mitigating bias.} In \citep{wang2019balanced}, the authors find that performance on multi-label prediction on COCO decreases only slightly when augmenting the model architecture with an adversarial loss to blur parts of the image that cause leakage of protected characteristics such as race and gender. \section{Methodology} \label{method} This paper explores how representations learnt for object detection change with various privacy-preserving augmentations of the training dataset. We augment the COCO dataset \citep{coco} by face-blurring and face-swapping using an adaptation of StarGAN~\citep{Choi2018stargan}. We use these, as well as the raw COCO dataset, to train Faster-RCNN~\citep{ren2016faster}. We measure the resulting model's object detection performance on both transformed and original versions. Finally, we attempt to measure the bias of the representations of all fine-tuned ResNet50 backbones via the Image Embedding Association Test (iEAT)~\citep{steed2021biases}. \paragraph{Face Detection and Blurring.} We augment the COCO dataset so that all faces are blurred and the face colours are scrambled. To blur the faces, we take an elliptical area inside each of the bounding boxes returned by the MTCNN face detector~\citep{mtcnn} and perform a Gaussian blur (see Appendix for details). The intensity of the region of pixels inside each ellipse was shifted by a randomly sampled integer between -80 and +80. This provided a large range of colours, randomising the skin colours of faces in the image, while not saturating the intensity values. \paragraph{GAN-based face swapping.} We develop a pipeline for swapping faces in images using StarGAN~\citep{Choi2018stargan}, detailed in Figure \ref{fig:data_gen}. To make a swap, we take a crop of a face detection using MTCNN~\citep{mtcnn} and sample a reference image from UTKFace~\citep{Song2018dataset} with a predefined distribution of gender and/or race\footnote{Definition from UTKFace as in the US census, classified as White, Black, Asian, Indian, and Others}. To align the two faces, we first identify facial landmarks with FAN~\citep{bulat2017far}, then generate a matrix transformation to map landmarks to fixed coordinates. Using StarGAN, we create an artificial face that has the style of the source face (facial expression) and the texture of the reference face (gender, skin and hair colour). Finally, we warp the generated face to align its landmarks with the face in the source image, remove the background using a pretrained instance segmentation model (Mask-RCNN~\citep{He2017maskcnn}), and paste the segmented face in the original image. The detailed procedure is in \ref{app:faceswap}. \begin{figure*}[t] \centering \includegraphics[width=\textwidth]{figures/bias-dset.pdf} \vspace{-1.5em} \caption{\textbf{Example Images.} Five versions of the same COCO image (ID=509864), each taken from one of our datasets. \textit{Default} is the original, \textit{Blurred} was created by blurring detected faces, and \textit{White Male}, \textit{Black \& Balanced Gender}, and \textit{Balanced Gender \& Race} are created using the GAN-based method, augmentations outlined in Section \ref{method}. \label{fig:datagen}} \end{figure*} \paragraph{Bias measure: iEAT test.} \label{iEAT} To measure the bias of image representations, we use the iEAT test \citep{steed2021biases}, which is adapted from the social psychology IAT test~\citep{greenwald1998measuring}. The test measures the differential association of some target concepts (e.g. ``woman'' vs ``man'') with a set of attributes (e.g. ``maths'' vs ``arts''), in all images (a total of 697). We first extract the representations of these visual stimuli using the ResNet backbone in Faster-RCNN models trained on the different datasets. Then, we calculate the cosine distance between the normalized representations of different visual stimuli, and record the $p$-value and effective size $d$ of the null hypothesis significance testing whether the model is biased. \paragraph{Privacy-Attribute Leakage: Linear classifier.} \label{leakage} We say a model ``leaks'' gender data if it learns different representations for ``man'' and ``woman'' when there has only been label ``person'' in the training set. To measure leakage, we train a linear binary classifier on top of the representations of frozen ResNet50 backbones from the Faster-RCNNs. We test leakage using two datasets, frame-wise PA-HMDB51~\citep{wang2019privacy} and a Kaggle gender classification dataset~\citep{Orsolini2019dataset}. We use this as a proxy for a model's performance on out-of-distribution datasets, and in particular its ability to pick up previously unseen attributes (e.g. the ``blurred'' model has not seen faces). \section{Results} \paragraph{Object Detection Performance} \input{tabs/obj_det} The original COCO 2017 dataset contains 118{,}287 training images. Removing all images with detected faces yields 86{,}721 training images, while removing all images labelled with the ``person'' class leaves a training set of only 54{,}172 images. These drops in the number of available training are also echoed in much lower performances in Tab.~\ref{tab:obj_det}(b-c). Compared to this, even our simple baseline, blurring of faces (row d), works much better and also does not suffer from a loss in performance when evaluating on blurred faces. Overall, all models trained on modified datasets perform as well as the default model when detecting objects in the COCO dataset. There is no significant drop in AP (<0.1) across any model and measure. Each model trained on an modified dataset performs better on that dataset than the default model. In particular, we find the model with balanced gender and race (row h) to perform well across the board. This can be attributed to the artifacts around modified faces that the models trained on the modified datasets pick up. However, models trained on any modified dataset perform no worse on the default dataset, where no face obfuscation has been performed, than the default model. We conclude that given a suitable face obfuscation method, we can train an object detector that does not degrade in performance on real data, despite never having seen a real face. \paragraph{iEAT Bias Measurements} The results from the iEAT association test show only minor differences between the default COCO model and our augmentations. The model \textit{Black Female} shows a 20\% decrease in bias against "Arab-Muslim" and \textit{Balanced Gender \& Race} shows a minor increase in bias against "Disability". Biases concerning "(modern) weapons" are statistically significant in \textit{Balanced Gender} and \textit{Balanced Gender \& Race} even though they are not in other models. All other differences are either (i) of negligible magnitude (e.g. "Weight"), (ii) are differences of effect size in statistically insignificant results (e.g. in sexuality) or (iii) are differences in the empirically untested intersectional categories (see \ref{app:ieat}). This, in combination with the highly significant biases of a randomly initialised RCNN, cast doubt on the validity of the iEAT test. \paragraph{Privacy-Attribute Leakage Results} The accuracy of gender classifiers trained on all models was similar. This suggests that there is no significant reduction in the possibility of decoding gender from the features, even in our backbone \textit{Blurred} which never saw a face during final training. It is likely that cues from a person's hair or body must also be altered to successfully obfuscate gender. While obfuscating gender is not a necessary condition for removing bias, we believe further work is required. Another next step involves pretraining only the weights of ResNet backbones with manipulated input data before finetuning on COCO object detection and repeating these experiments. \input{tabs/leakage} \section{Conclusion} Does a dataset need real human faces? Not for object detection. In this paper, we show that at least for finetuning on COCO, this is not the case. We find that even when faces are blurred or edited to be more balanced in terms of represented gender and race, the object detector learns just the same. We also investigate whether it is possible to de-bias the models using two measures proposed. However, here we report negative and inconsistent findings that at least partially point to potential shortcomings of these measures tested. \section{Appendix} \subsection{Discussion on GDPR} Under the General Data Protection Regulation (GDPR) biometric data is considered a special category of data (Art. 9.1) and facial images are classified as a type of 'biometric data' (Art 4.14). As such it would be reasonable to conclude that the storage of facial images would likely fall under the GDPR. However, as we have shown, this paper's method is able to remove certain personally identifiable information (PII), leading to what is known as a ‘de-identification’ process~\citep{Hintze2017identify}. By removing PII, whether the data falls under the GDPR and, for example the storage limitation principle (Art. 5.1.e), is brought into question. We believe that as our method reduces PII from images, it also reduces the regulatory requirements for those storing images. This is dependent on if an argument can be made whether the method anonymizes or pseudonymizes the images. If it anonymizes the images, then they would no longer fall under the GDPR (see Recital 26). However, if it pseudonymizes them then it would fall under the GDPR (Art. 4.3b). Regardless of the extent to which our method `de-identifies' subjects, we believe that by reducing PII this provides greater flexibility for researchers to work with computer vision models while adhering to ‘data minimisation’ and ‘storage limitations’ principles where applicable. Therefore, as our method retains information such as facial expression and (to some extent) photorealism it is more favorable than ablation or blurring. We believe that large available datasets could be processed using similar methods before public release to minimise privacy and bias concerns. However, given that under the law it often depends on the specific case in order to provide a legal argument, the fact remains that our method of protecting privacy and preserving performance seems to be of beneficial use. \subsection{Blurring details} We apply Gaussian blurring with kernel length $h/6$ (where $h$ is the height of the original bounding box) and a standard deviation of 20 pixels. \subsection{Face Swapping with StarGAN} \label{app:faceswap} Suppose we want to swap a face in image $I$. We crop out the original face $F$ which can be decomposed as $F = (A, E, L, B)$, where $A$ is appearance and texture, $E$ is the style and facial expressions, $L$ is position of landmarks, and $B$ is background behind the face. Given a predefined gender and/or race setting $p$ for the target dataset, we choose a reference face $R_p = (A_p', E', L', B')$. To align the two faces, we calculate two alignment matrices $\mathcal{M}$, $ \mathcal{M}'$ (calculated such that $\mathcal{M}L=L_0$ and $\mathcal{M}'L'=L_0$, where $L_0$ is a fixed face framework). We apply these to get two aligned face that we denote $F^{(a)}$ and $R^{(a)}$ by $F^{(a)}=\mathcal{M}F,\; R_p^{(a)}=\mathcal{M}'R_p$. Using StarGAN ($\mathcal{T}$), we merge the two faces to create $G^{(a)}_p=\mathcal{T}(F^{(a)}, R_p^{(a)}) = (A'^{(a)}_p, E^{(a)}, L_0, B'^{(a)})$, which retains the style of the original face $E^{(a)}$ but the appearance and background of the reference face $A'^{(a)}_p B'^{(a)}$. The synthesised face is then reverted back to the original position by using an inverted alignment matrix ($G_p = \mathcal{M}^{-1}G^{(a)}_p=(A_p', E, L, B')$). The background of the artificial face is removed by segmentation (denoted by $\mathcal{S}$) to create $S_p = \mathcal{S}G_p=(A_p', E, L, \emptyset )$. Finally, the face is pasted back to the original image, giving us $I_p$, an altered image with desired gender and skin colour. \paragraph{Hyper-parameters of StarGAN:} Most hyper-parameters are default values from the pretrained models: MTCNN, FAN, StarGAN, and Mask-RCNN. \\ We only change the margin parameter of StarGAN to $0.8$ and the threshold of MTCNN to $0.5$. \subsubsection{Gender Classification} \paragraph{Male/Female Kaggle dataset} We train the frozen ResNet50 backbones for 20 epochs, using Adam optimizer \citep{kingma2017adam} with learning rate $0.001$ and a batch size of 16, and use 3-fold cross validation. \paragraph{PA-HMDB51 dataset} PA-HMDB51 contains videos labelled by actions (such as "brush\_hair") and frame-by-frame labels of privacy attributes including skin colour and gender. We extract frames containing only one "male"/"female" gender label to create a dataset of images labelled by gender and use this to train a gender classifier. As with the Male/Female Kaggle dataset, we train the frozen ResNet50 backbones for 1 epoch, using Adam optimizer \citep{kingma2017adam} with learning rate 0.001 and a batch size of 16, and use 3-fold cross-validation. \subsection{Leakage results} \label{sec:leakage-app} \begin{table}[!h] \footnotesize \caption{Full leakage results.} \label{tab:leakage-app} \centering \begin{tabular}{l c @{\hspace{0.7ex}} c@{\hspace{0.7ex}} c@{\hspace{0.7ex}} } \toprule \textit{Model} & PA-HMDB51 & M/F \\ \midrule Original & 80.6 $\pm$ 1.0 & 85.4 $\pm$ 0.8 \\ Blurred & 80.3 $\pm$ 0.6 & 85.7 $\pm$ 1.5 \\ White M & 80.2 $\pm$ 0.7 & 85.7 $\pm$ 0.6 \\ Black F & 79.9 $\pm$ 0.6 & 85.8 $\pm$ 0.3 \\ Bal. G.\&R. & 80.7 $\pm$ 0.7 & 85.4 $\pm$ 0.7 \\ \bottomrule \end{tabular} \end{table} \subsection{iEAT Test Results} \label{app:ieat} The iEAT test measures bias along a number of variables, but we focus on the ones that we identify as \textit{social} biases, and only discuss statistically significant results. There is a decrease in the \textit{Gender-Science}, \textit{Arab-Muslim} and \textit{Weight} categories when comparing \textbf{Balanced-intersectional} to \textbf{Default}.Comparing \textbf{Black-female} to \textbf{Default}, we see a 10\% to 20\% decrease of effective size in \textit{Gender-Science}, \textit{Arab-Muslim} and \textit{Disability}. \textbf{White-male} increases the bias in all categories with significant results, \textit{Weight} and \textit{Disability}, compared to \textbf{Default}. Similarly, \textbf{Blurred} increases \textit{Gender-Science} and \textit{Weight} biases, while slightly decreasing along the \textit{Disability} and \textit{Arab-Muslim} categories.\\ For completeness, we include results for a randomly initialised RCNN, as well as an RCNN backbone pretrained on ImageNet. While the results of the randomly initialised one can not be interpreted, the ImageNet-pretrained one shows the smallest bias in the \textit{Weight} and \textit{Arab-Muslim} categories, and the highest in \textit{Disability}. Models trained on altered datasets show similar bias results, suggesting that data preprocessing has a small effect. Changing the layer from which we take representations extraction layer shows no difference in the results\\ An important thing to note is that as mentioned in the original iEAT paper~\citep{steed2021biases}, the IAT bias test on humans, where this test is adapted from, did not include the bias tests on intersectionality. Therefore, the results for intersectional bias have not been empirically compared and supported. The fact that even the randomly initialised model has significant biases in some categories means that the intersectional biases are likely false positives. \\ In addition, the tests use a small number of visual stimuli (normally less than 10 for each attribute and concept) and sample 3000-10000 partitions from the union of 2 attributes and 2 concepts, so statistical bias could result from the small selection of images. \input{tabs/ieat} \newpage \subsection{Example-Image Gallery} \begin{figure*}[h] \centering \includegraphics[width=\textwidth]{figures/appendix_gallery.pdf} \caption{A selection of example images used for training. They are labelled by their COCO IDs, such as "$32901$", as well as the dataset they belong to. Details about the creation of each dataset can be found in \ref{method}. \label{fig:augmented_data}} \end{figure*} \section{Appendix} \subsection{Discussion on GDPR} Under the General Data Protection Regulation (GDPR) biometric data is considered a special category of data (Art. 9.1) and facial images are classified as a type of 'biometric data' (Art 4.14). As such it would be reasonable to conclude that the storage of facial images would likely fall under the GDPR. However, as we have shown, this paper's method is able to remove certain personally identifiable information (PII), leading to what is known as a ‘de-identification’ process~\citep{Hintze2017identify}. By removing PII, whether the data falls under the GDPR and, for example the storage limitation principle (Art. 5.1.e), is brought into question. We believe that as our method reduces PII from images, it also reduces the regulatory requirements for those storing images. This is dependent on if an argument can be made whether the method anonymizes or pseudonymizes the images. If it anonymizes the images, then they would no longer fall under the GDPR (see Recital 26). However, if it pseudonymizes them then it would fall under the GDPR (Art. 4.3b). Regardless of the extent to which our method `de-identifies' subjects, we believe that by reducing PII this provides greater flexibility for researchers to work with computer vision models while adhering to ‘data minimisation’ and ‘storage limitations’ principles where applicable. Therefore, as our method retains information such as facial expression and (to some extent) photorealism it is more favorable than ablation or blurring. We believe that large available datasets could be processed using similar methods before public release to minimise privacy and bias concerns. However, given that under the law it often depends on the specific case in order to provide a legal argument, the fact remains that our method of protecting privacy and preserving performance seems to be of beneficial use. \subsection{Blurring details} We apply Gaussian blurring with kernel length $h/6$ (where $h$ is the height of the original bounding box) and a standard deviation of 20 pixels. \subsection{Face Swapping with StarGAN} \label{app:faceswap} Suppose we want to swap a face in image $I$. We crop out the original face $F$ which can be decomposed as $F = (A, E, L, B)$, where $A$ is appearance and texture, $E$ is the style and facial expressions, $L$ is position of landmarks, and $B$ is background behind the face. Given a predefined gender and/or race setting $p$ for the target dataset, we choose a reference face $R_p = (A_p', E', L', B')$. To align the two faces, we calculate two alignment matrices $\mathcal{M}$, $ \mathcal{M}'$ (calculated such that $\mathcal{M}L=L_0$ and $\mathcal{M}'L'=L_0$, where $L_0$ is a fixed face framework). We apply these to get two aligned face that we denote $F^{(a)}$ and $R^{(a)}$ by $F^{(a)}=\mathcal{M}F,\; R_p^{(a)}=\mathcal{M}'R_p$. Using StarGAN ($\mathcal{T}$), we merge the two faces to create $G^{(a)}_p=\mathcal{T}(F^{(a)}, R_p^{(a)}) = (A'^{(a)}_p, E^{(a)}, L_0, B'^{(a)})$, which retains the style of the original face $E^{(a)}$ but the appearance and background of the reference face $A'^{(a)}_p B'^{(a)}$. The synthesised face is then reverted back to the original position by using an inverted alignment matrix ($G_p = \mathcal{M}^{-1}G^{(a)}_p=(A_p', E, L, B')$). The background of the artificial face is removed by segmentation (denoted by $\mathcal{S}$) to create $S_p = \mathcal{S}G_p=(A_p', E, L, \emptyset )$. Finally, the face is pasted back to the original image, giving us $I_p$, an altered image with desired gender and skin colour. \paragraph{Hyper-parameters of StarGAN:} Most hyper-parameters are default values from the pretrained models: MTCNN, FAN, StarGAN, and Mask-RCNN. \\ We only change the margin parameter of StarGAN to $0.8$ and the threshold of MTCNN to $0.5$. \subsubsection{Gender Classification} \paragraph{Male/Female Kaggle dataset} We train the frozen ResNet50 backbones for 20 epochs, using Adam optimizer \citep{kingma2017adam} with learning rate $0.001$ and a batch size of 16, and use 3-fold cross validation. \paragraph{PA-HMDB51 dataset} PA-HMDB51 contains videos labelled by actions (such as "brush\_hair") and frame-by-frame labels of privacy attributes including skin colour and gender. We extract frames containing only one "male"/"female" gender label to create a dataset of images labelled by gender and use this to train a gender classifier. As with the Male/Female Kaggle dataset, we train the frozen ResNet50 backbones for 1 epoch, using Adam optimizer \citep{kingma2017adam} with learning rate 0.001 and a batch size of 16, and use 3-fold cross-validation. \subsection{Leakage results} \label{sec:leakage-app} \begin{table}[!h] \footnotesize \caption{Full leakage results.} \label{tab:leakage-app} \centering \begin{tabular}{l c @{\hspace{0.7ex}} c@{\hspace{0.7ex}} c@{\hspace{0.7ex}} } \toprule \textit{Model} & PA-HMDB51 & M/F \\ \midrule Original & 80.6 $\pm$ 1.0 & 85.4 $\pm$ 0.8 \\ Blurred & 80.3 $\pm$ 0.6 & 85.7 $\pm$ 1.5 \\ White M & 80.2 $\pm$ 0.7 & 85.7 $\pm$ 0.6 \\ Black F & 79.9 $\pm$ 0.6 & 85.8 $\pm$ 0.3 \\ Bal. G.\&R. & 80.7 $\pm$ 0.7 & 85.4 $\pm$ 0.7 \\ \bottomrule \end{tabular} \end{table} \subsection{iEAT Test Results} \label{app:ieat} The iEAT test measures bias along a number of variables, but we focus on the ones that we identify as \textit{social} biases, and only discuss statistically significant results. There is a decrease in the \textit{Gender-Science}, \textit{Arab-Muslim} and \textit{Weight} categories when comparing \textbf{Balanced-intersectional} to \textbf{Default}.Comparing \textbf{Black-female} to \textbf{Default}, we see a 10\% to 20\% decrease of effective size in \textit{Gender-Science}, \textit{Arab-Muslim} and \textit{Disability}. \textbf{White-male} increases the bias in all categories with significant results, \textit{Weight} and \textit{Disability}, compared to \textbf{Default}. Similarly, \textbf{Blurred} increases \textit{Gender-Science} and \textit{Weight} biases, while slightly decreasing along the \textit{Disability} and \textit{Arab-Muslim} categories.\\ For completeness, we include results for a randomly initialised RCNN, as well as an RCNN backbone pretrained on ImageNet. While the results of the randomly initialised one can not be interpreted, the ImageNet-pretrained one shows the smallest bias in the \textit{Weight} and \textit{Arab-Muslim} categories, and the highest in \textit{Disability}. Models trained on altered datasets show similar bias results, suggesting that data preprocessing has a small effect. Changing the layer from which we take representations extraction layer shows no difference in the results\\ An important thing to note is that as mentioned in the original iEAT paper~\citep{steed2021biases}, the IAT bias test on humans, where this test is adapted from, did not include the bias tests on intersectionality. Therefore, the results for intersectional bias have not been empirically compared and supported. The fact that even the randomly initialised model has significant biases in some categories means that the intersectional biases are likely false positives. \\ In addition, the tests use a small number of visual stimuli (normally less than 10 for each attribute and concept) and sample 3000-10000 partitions from the union of 2 attributes and 2 concepts, so statistical bias could result from the small selection of images. \input{tabs/ieat} \newpage \subsection{Example-Image Gallery} \begin{figure*}[h] \centering \includegraphics[width=\textwidth]{figures/appendix_gallery.pdf} \caption{A selection of example images used for training. They are labelled by their COCO IDs, such as "$32901$", as well as the dataset they belong to. Details about the creation of each dataset can be found in \ref{method}. \label{fig:augmented_data}} \end{figure*} \section{Introduction} Deep learning-based methods have enjoyed tremendous gains over the past years. While this has also been due to better architectures, a large part of this success is due to the ever-increasing size of datasets. However, there are two major problems with the current datasets that the research community is increasingly becoming aware of and that could limit the progress in this domain if not addressed. First, datasets are being revealed to be heavily biased. Works such as \citep{buolamwini_gebru2018,yang2020towards} find significant underrepresentation of women and those with darker skin in common datasets. Biases in datasets, in turn, manifest as bias within models. For example, an image labelling algorithm from Google was found to label an image of two black people "Gorilla" \citep{simonite2018google} and facial analysis models have been found to have significantly lower accuracy on darker female faces than on lighter male faces~\citep{buolamwini_gebru2018}. A second problem is the lack of consent for using these images to train AI models: As noted in~\citep{prabhu2020large} while these datasets are collected under the Creative Commons licence, this license does not yield or say anything about their use in training AI models. This can potentially violate the licenses (as reproduction requires the ascription of the creator) since trained models can be probed to reveal whole training samples, such as addresses and bank accounts in GPT-2~\citep{carlini2020extracting} or potentially even images~\citep{orekondy18gradient}. Therefore, there is a clear need for the removal of personally identifiable information within images. This would not only protect the individuals within the images (e.g. reduced risk of identify theft) but also ensure higher adherence to the General Data Protection Regulation (GDPR). One common variable in both problems is the usage of raw, unedited data which tends to be either privacy infringing or biased. However, since collecting an unbiased dataset with consenting individuals would be very costly and potentially even unfeasible~\citep{yang2020towards}, in this paper we investigate approaches to mitigating these problems by modifying the current training data. Specifically, our contributions are as follows: \begin{enumerate} \item We investigate privacy-preserving measures on object detection performance. \item We develop a novel method for balancing gender and race distribution in the training data while simultaneously removing personally-identifying information. \item We test the fine-tuned models with two measures of model bias. \end{enumerate} \section{Methodology} \label{method} This paper explores how representations learnt for object detection change with various privacy-preserving augmentations of the training dataset. We augment the COCO dataset \citep{coco} by face-blurring and face-swapping using an adaptation of StarGAN~\citep{Choi2018stargan}. We use these, as well as the raw COCO dataset, to train Faster-RCNN~\citep{ren2016faster}. We measure the resulting model's object detection performance on both transformed and original versions. Finally, we attempt to measure the bias of the representations of all fine-tuned ResNet50 backbones via the Image Embedding Association Test (iEAT)~\citep{steed2021biases}. \paragraph{Face Detection and Blurring.} We augment the COCO dataset so that all faces are blurred and the face colours are scrambled. To blur the faces, we take an elliptical area inside each of the bounding boxes returned by the MTCNN face detector~\citep{mtcnn} and perform a Gaussian blur (see Appendix for details). The intensity of the region of pixels inside each ellipse was shifted by a randomly sampled integer between -80 and +80. This provided a large range of colours, randomising the skin colours of faces in the image, while not saturating the intensity values. \paragraph{GAN-based face swapping.} We develop a pipeline for swapping faces in images using StarGAN~\citep{Choi2018stargan}, detailed in Figure \ref{fig:data_gen}. To make a swap, we take a crop of a face detection using MTCNN~\citep{mtcnn} and sample a reference image from UTKFace~\citep{Song2018dataset} with a predefined distribution of gender and/or race\footnote{Definition from UTKFace as in the US census, classified as White, Black, Asian, Indian, and Others}. To align the two faces, we first identify facial landmarks with FAN~\citep{bulat2017far}, then generate a matrix transformation to map landmarks to fixed coordinates. Using StarGAN, we create an artificial face that has the style of the source face (facial expression) and the texture of the reference face (gender, skin and hair colour). Finally, we warp the generated face to align its landmarks with the face in the source image, remove the background using a pretrained instance segmentation model (Mask-RCNN~\citep{He2017maskcnn}), and paste the segmented face in the original image. The detailed procedure is in \ref{app:faceswap}. \begin{figure*}[t] \centering \includegraphics[width=\textwidth]{figures/bias-dset.pdf} \vspace{-1.5em} \caption{\textbf{Example Images.} Five versions of the same COCO image (ID=509864), each taken from one of our datasets. \textit{Default} is the original, \textit{Blurred} was created by blurring detected faces, and \textit{White Male}, \textit{Black \& Balanced Gender}, and \textit{Balanced Gender \& Race} are created using the GAN-based method, augmentations outlined in Section \ref{method}. \label{fig:datagen}} \end{figure*} \paragraph{Bias measure: iEAT test.} \label{iEAT} To measure the bias of image representations, we use the iEAT test \citep{steed2021biases}, which is adapted from the social psychology IAT test~\citep{greenwald1998measuring}. The test measures the differential association of some target concepts (e.g. ``woman'' vs ``man'') with a set of attributes (e.g. ``maths'' vs ``arts''), in all images (a total of 697). We first extract the representations of these visual stimuli using the ResNet backbone in Faster-RCNN models trained on the different datasets. Then, we calculate the cosine distance between the normalized representations of different visual stimuli, and record the $p$-value and effective size $d$ of the null hypothesis significance testing whether the model is biased. \paragraph{Privacy-Attribute Leakage: Linear classifier.} \label{leakage} We say a model ``leaks'' gender data if it learns different representations for ``man'' and ``woman'' when there has only been label ``person'' in the training set. To measure leakage, we train a linear binary classifier on top of the representations of frozen ResNet50 backbones from the Faster-RCNNs. We test leakage using two datasets, frame-wise PA-HMDB51~\citep{wang2019privacy} and a Kaggle gender classification dataset~\citep{Orsolini2019dataset}. We use this as a proxy for a model's performance on out-of-distribution datasets, and in particular its ability to pick up previously unseen attributes (e.g. the ``blurred'' model has not seen faces). \subsection*{Acknowledgement} The OxAI society is grateful for support from Google Academic Research Credits program. {\small\bibliographystyle{iclr2021_conference} \section{Conclusion} Does a dataset need real human faces? Not for object detection. In this paper, we show that at least for finetuning on COCO, this is not the case. We find that even when faces are blurred or edited to be more balanced in terms of represented gender and race, the object detector learns just the same. We also investigate whether it is possible to de-bias the models using two measures proposed. However, here we report negative and inconsistent findings that at least partially point to potential shortcomings of these measures tested. \section{Related work} \paragraph{Measuring Bias.} Experimentally, it has been shown that many models are biased: For example~\cite{buolamwini_gebru2018} show that face recognition tools perform worse for women of colour than white men, and in~\citep{simonite2018google, kayserbril2020googlevision} publicly available models have been shown to be biased towards minorities. Furthermore, \citet{steed2021biases} find that unsupervised models trained on ImageNet contain racial, gender, and intersectional biases. We use their test to probe bias in our models. To mitigate biases, \cite{zhang2016discrimination} develop a method to remove discriminatory effects of collected datasets prior to its statistical analysis. Even with a balanced dataset, a model can amplify implicit gender biases, as shown by \cite{wang2019balanced}, who propose to use a generative-adversarial approach to remove this information by painting over that part of the image. In this paper, we focus on how input data can be efficiently transformed to make datasets more balanced and potentially remove the association biases of stereotypes. \paragraph{Preserving Privacy.} Privacy is important within computer vision given the potential contradiction between using image recognition algorithms while at the same time limiting elements which expose identifiable and sensitive information. Preserving privacy in computer vision models has already been addressed to an extent using various methods, such as head inpainting~\citep{Sun2018inpainting}, reducing resolution quality~\citep{Ryoo2016lowres}, and many more~\citep{ren2018privacy, Wu2018preservingprivacy}. Notably, \citep{Orekondy2018privacy} showed how to apply targeted obfuscation to areas of private information as to protect privacy yet also preserve the utility of the image. However, so far little work has evaluated performances of preserving privacy on modern object detection algorithms. \paragraph{Face Swapping.} There has also been work in the area of transferring a face onto a target in a similar pose. \cite{Zhong2016} paste celebrity faces onto images to generate a synthetic dataset of novel (celebrity face, action) pair images. \paragraph{Mitigating bias.} In \citep{wang2019balanced}, the authors find that performance on multi-label prediction on COCO decreases only slightly when augmenting the model architecture with an adversarial loss to blur parts of the image that cause leakage of protected characteristics such as race and gender. \section{Results} \paragraph{Object Detection Performance} \input{tabs/obj_det} The original COCO 2017 dataset contains 118{,}287 training images. Removing all images with detected faces yields 86{,}721 training images, while removing all images labelled with the ``person'' class leaves a training set of only 54{,}172 images. These drops in the number of available training are also echoed in much lower performances in Tab.~\ref{tab:obj_det}(b-c). Compared to this, even our simple baseline, blurring of faces (row d), works much better and also does not suffer from a loss in performance when evaluating on blurred faces. Overall, all models trained on modified datasets perform as well as the default model when detecting objects in the COCO dataset. There is no significant drop in AP (<0.1) across any model and measure. Each model trained on an modified dataset performs better on that dataset than the default model. In particular, we find the model with balanced gender and race (row h) to perform well across the board. This can be attributed to the artifacts around modified faces that the models trained on the modified datasets pick up. However, models trained on any modified dataset perform no worse on the default dataset, where no face obfuscation has been performed, than the default model. We conclude that given a suitable face obfuscation method, we can train an object detector that does not degrade in performance on real data, despite never having seen a real face. \paragraph{iEAT Bias Measurements} The results from the iEAT association test show only minor differences between the default COCO model and our augmentations. The model \textit{Black Female} shows a 20\% decrease in bias against "Arab-Muslim" and \textit{Balanced Gender \& Race} shows a minor increase in bias against "Disability". Biases concerning "(modern) weapons" are statistically significant in \textit{Balanced Gender} and \textit{Balanced Gender \& Race} even though they are not in other models. All other differences are either (i) of negligible magnitude (e.g. "Weight"), (ii) are differences of effect size in statistically insignificant results (e.g. in sexuality) or (iii) are differences in the empirically untested intersectional categories (see \ref{app:ieat}). This, in combination with the highly significant biases of a randomly initialised RCNN, cast doubt on the validity of the iEAT test. \paragraph{Privacy-Attribute Leakage Results} The accuracy of gender classifiers trained on all models was similar. This suggests that there is no significant reduction in the possibility of decoding gender from the features, even in our backbone \textit{Blurred} which never saw a face during final training. It is likely that cues from a person's hair or body must also be altered to successfully obfuscate gender. While obfuscating gender is not a necessary condition for removing bias, we believe further work is required. Another next step involves pretraining only the weights of ResNet backbones with manipulated input data before finetuning on COCO object detection and repeating these experiments. \input{tabs/leakage}
{'timestamp': '2021-03-12T02:19:12', 'yymm': '2103', 'arxiv_id': '2103.06587', 'language': 'en', 'url': 'https://arxiv.org/abs/2103.06587'}
arxiv
\section{Introduction} \noindent Hodgson \cite{Ho76,Ho83} as well as Khoussainov and Nerode \cite{KN95} \ifxfullconf and Blumensath and Gr\"adel \cite{BG00} \fi \ifxfullfull and Blumensath and Gr\"adel \cite{Bl99,BG00} \fi initiated the study of automatic structures. A structure $(A,\circ,\leq)$ of, say, an ordered semigroup is then automatic iff there is an isomorphic copy $(B,\circ,\leq)$ where $B$ is regular and $\circ,\leq,=$ are automatic in the following sense: A finite automaton reads all tuples of possible inputs and outputs with the same speed in a synchronised way and accepts these tuples which are valid tuples in the relations $\leq$ and $=$ or which are valid combinations $(x,y,z)$ with $x \circ y = z$ in the case of the semigroup operation (function) $\circ$. For this, one assumes that the inputs and outputs of relations and functions are aligned with each other, like decimal numbers in addition, and for this alignment -- which has to be the same for all operations -- one fills the gaps with a special character. So words are functions with some domain $\{-m,-m+1,\ldots,n-1,n\}$ and some fixed range $\Sigma$ and the finite automaton reads, when processing a pair $(x,y)$ of inputs, in each round the symbols $(x(k),y(k))$ where the special symbol $\# \notin \Sigma$ replaces $x(k)$ or $y(k)$ in the case that these are not defined. See Example~\ref{gridexample} below for an example of a finite automaton checking whether $x+y=z$ for numbers $x,y,z$; here a finite automaton computes a function by checking whether the output matches the inputs. Automatic functions are characterised as those computed by a position-faithful one-tape Turing machine in linear time \cite{CJSS12}. \ifxfullfull Position-faithful means that input and output start at the same position on the Turing tape and the Turing machine overwrites the input by the output. Furthermore, note that if a structure has several representatives per element then a finite automaton must recognise the equality. \fi The reader should note, that after Hodgson's pioneering work \cite{Ho76,Ho83}, Epstein, Cannon, Holt, Levy, Paterson and Thurston \cite{ECHLPT92} argued that in the above formalisation, automaticity is, at least from the viewpoint of finitely generated groups, too restrictive. They furthermore wanted that the representatives of the group elements are given as words over the generators, leading to more meaningful representatives than arbitrary strings. Their concept of automatic groups led, for finitely generated groups, to a larger class of groups, though, by definition, of course it does not include groups which require infinitely many generators; groups with infinitely many generators, to some extent, were covered in the notion of automaticity by Hodgson, Khoussainov and Nerode. Nies, Oliver and Thomas provide in several papers \ifxfullconf \cite{NT08,OT05} \fi \ifxfullfull \cite{Ni07,NT08,OT05} \fi results which contrast and compare these two notions of automaticity and give an overview on results for groups which are automatic in the sense of Hodgson, Khoussainov and Nerode. \ifxfullfull Kharlampovich, Khoussainov and Miasnikov \cite{KKM11} generalised the notion further to Cayley automatic groups. Here a finitely generated group $(A,\circ)$ is Cayley automatic iff the domain $A$ is a regular set, for every group element there is a unique representative in $A$ and, for every $a \in A$, the mapping $x \mapsto x \circ a$ is automatic. \fi \iffalse Finitely generated Cayley automatic groups have word problem decidable in quadratic time, carrying over the corresponding result from the two previous versions of automaticity. As opposed to the case of automatic groups (in the original sense of Hodgson), Miasnikov and \v Suni\'c \cite{MS12} showed that several natural problems like the conjugacy problem can be undecidable for some Cayley automatic groups. \fi Jain, Khoussainov, Stephan, Teng and Zou \cite{JKSTZ17} investigated the general approach where, in a structure for some relations and functions, it is only required that the versions of the functions or relations with all but one variable fixed to constants is automatic. Here the convention is to put the automatic domains, functions and relations before a semicolon and the semiautomatic relations after the semicolon. \ifxfullfull For example, a semiautomatic group $(A,\circ;=)$ would be a structure where the domain $A$ is regular, the group operation (with both inputs) is automatic and for each fixed element $a \in A$ the set $\{b \in A: b = a\}$ is regular --- note that group elements might have several representatives in semiautomatic groups. \fi The present work will focus more on structures like rings than groups, although the field of automatic and semiautomatic structures has a strong group theoretic component. The construction of these semiautomatic rings is similar to that of Nies and Semukhin \cite{NS09} for a presentation of ${\mathbb Z}^2$ where no $1$-dimensional subgroup is a regular subset. The interested reader finds information about automatic structures in the surveys of Khoussainov and Minnes \cite{KM10} and Rubin \cite{Ru08}. Related but different links between automata theory and geometry have been studied previously like, for example, the usage of weighted automata and transducers to generate fractals \cite{CK97}, $\omega$-automata to represent geometric objects in the reals \cite{BJW05,JSY07} and the field of reals not being $\omega$-automatic \ifxfullconf \cite{ZGKP13}. \fi \ifxfullfull \cite{ZGK12,ZGKP13}. \fi The last section of the present work applies the results and methods of the current work to $\omega$-automatic structures. \iffalse In the present work, for any group, $\varepsilon$ represents the neutral element. One of the basic results obtained is that the notion $(A,\circ;=)$ collapses to an automatic group (in the sense of Hodgson, Khoussainov and Nerode), as $$ a = b \Leftrightarrow \exists c \,[a \circ c = \varepsilon \mbox{ and } b \circ c = \varepsilon]. $$ For semiautomatic groups, the two interesting group structures are $(A,=;\circ)$ and $(A;\circ,=)$. In the first one, the equality is automatic, while in the second one, both the group operation and the equality are only semiautomatic. If a group is finitely generated, then the definition of being Cayley biautomatic is the same as having a presentation of the form $(A,=;\circ)$. Finitely generated semiautomatic groups share with the other types of automatic groups one important property: The word problem can be decided in quadratic time and the algorithm is the same as known for the Cayley automatic groups \cite{KKM11}. Thus finitely generated groups with an undecidable or very complex word problem are not semiautomatic. One of the problems left open in the present work is the following: Is every finitely generated semiautomatic group Cayley automatic? More generally, does every semiautomatic group admit a presentation where the multiplication with a fixed group element from one side only is semiautomatic and the equality is automatic? \fi The present work looks at semiautomatic rings which can be used to represent selected points in the real plane. Addition and subtraction and comparisons \pagebreak[3] as well as multiplication with constants have to be automatic; however, the full multiplication is not automatic. It depends on the structures which geometric objects and operations with such object can be represented. \begin{defn} \label{de:automatic} The {\em convolution} of two words $v,w$ is a mapping from the union of their domains to $(\Sigma \cup \{\#\}) \times (\Sigma \cup \{\#\})$ such that first one extends $v,w$ to $v',w'$, each having the domain $dom(v) \cup dom(w)$, by assigning $\#$ whenever $v$ or $w$ are undefined and then letting the convolution $u$ map every $h \in dom(v) \cup dom(w)$ to the new symbol $(v'(h),w'(h))$. Similarly one defines the convolutions of three, four or more words. A $h$-ary relation $R$ is {\em automatic} \ifxfullfull \cite{Bl99,BG00,Ho76,Ho83,KN95} \fi \ifxfullconf \cite{BG00,Ho76,Ho83,KN95} \fi iff the set of all the convolutions of tuples $(x_1,\ldots,x_h) \in R$ is regular; a $h$-ary function $f$ is automatic iff the set of all convolutions of $(x_1,\ldots,x_h,y)$ with $f(x_1,\ldots,x_h) = y$ is regular. A $h$-ary relation $P$ is {\em semiautomatic} \cite{JKSTZ17} iff for all indices $i \in \{1,\ldots,h\}$ and for all possible fixed values $x_j$ with $j \neq i$ the resulting set $\{x_i: (x_1,\ldots,x_h) \in P\}$ is regular. A $h$-ary function $g$ is semiautomatic iff for all indices $i \in \{1,\ldots,h\}$ and all possible values $x_j$ with $j \neq i$ the function $x_i \mapsto g(x_1,\ldots,x_h)$ is automatic. A structure $(A,f_1,\ldots,f_k,R_1,\ldots,R_\ell;g_1,\ldots,g_i, P_1,\ldots,P_j)$ is {\em semiautomatic} \cite{JKSTZ17} iff (i) $A$ is a regular set of words where each word maps a finite subset of $\mathbb Z$ to a fixed alphabet, (ii) each $f_h$ is automatic, (iii) each $R_h$ is automatic, (iv) each $g_h$ is semiautomatic and (v) each $P_h$ is semiautomatic. The semicolon separates the automatic components of the structure from those which are only semiautomatic. Structures without semiautomatic items are just called automatic. An {\em automatic family} \ifxfullfull \cite{JOPS10} \fi $\{L_d: d \in E\}$ is a collection of sets such that their index set $E$ and the set of all convolutions of $(d,x)$ with $x \in L_d$ and $d \in E$ are regular. \end{defn} \begin{defn} A {\em semiautomatic grid} or, in this paper, just grid, is a semiautomatic ring $(A,+,=,<;\cdot)$ where the multiplication is only semiautomatic and the addition and comparisons are automatic such that $A$ forms a dense subring of the reals, that is, whenever $p,r$ are real numbers with $p<r$ then there is an $q \in A$ with $p < q \wedge q < r$ and furthermore, all elements of $A$ represent real numbers. \end{defn} \noindent It makes sense to define density as a property of an ordered ring that is embeddable into the reals, since the embedding is unique. A necessary and sufficient criterion for the ring to be dense is that it has an element strictly between $0$ and~$1$. \ifxfullfull If there is $q$ with $0<q<1$ and $p,r$ are any ring members with $p<r$ then $p + q \cdot (r-p)$ is strictly between $p$ and $r$. Furthermore, ordered rings which are subrings of the real numbers do not have an endpoint, as adding $+1$ or $-1$ to any element allows finding elements strictly above and strictly below the element. \fi \begin{exmp} \label{gridexample} The ring $({\mathbb D}_b,+,=,<;\cdot)$ of the rational numbers in base $b$ with only finitely many nonzero digits is a grid. Here ${\mathbb D}_b = \{n/b^m: n,m \in {\mathbb Z}\}$. Addition and comparison follow the school algorithm as in the following example of Stephan \cite{St15}. In ${\mathbb D}_{10}$, given three numbers $x,y,z$, an automaton to check whether $x+y = z$ would process from the back to the front and the states would be ``correct and carry to next digit (c)'', ``correct and no carry to next digit (n)'' and ``incorrect (i)''. In the following three examples, $x$ stands on the top, $y$ in the second and $z$ in the last row. The states of the automaton are for starting from the end of the string to the beginning after having processed the digits after them but not those before them. The filling symbol $\#$ is identified with $0$. The decimal dot is not there physically, it just indicates the position between digit $a_0$ and digit $a_{-1}$. The domain of each string is an interval from a negative to a positive number plus an entry for the sign $-$ if needed. \begin{verbatim} Correct Addition Incorrect Addition Incomplete Addition # 2 3 5 8. 2 2 5 3 3 3 3. 3 3 # 9 9 1 2 3. 4 5 6 # 9 1 1 2. # # # # # 2 2. 2 2 2 # # 9 8 7. 6 5 4 1 1 4 7 0. 2 2 5 # 1 5 5. 5 5 2 0 0 1 1 1. 1 1 # n c n n c n n n n i i n n n n n n c c c c c c c c n \end{verbatim} The difference $x-y=z$ is checked by checking whether $x=y+z$ and then one can compare the outcome of additions of possibly negative numbers by going to $-$ when the signs of the numbers require this. Furthermore, $x<y$ iff $y-x$ is positive and $x=y$ if the two numbers are equal as strings. For checking whether $x \cdot i/j = y$ for given rational constant $i/j$, one just checks whether $i \cdot x = j \cdot y$ which, as $i,j$ are constants, can be done by $i$ times adding $x$ to itself and $j$ times adding $y$ to itself and then comparing the results. So $x \cdot 3/2 = y$ is equivalent to $x+x+x = y+y$ and the latter check is automatic. Also the set of all $x \in {\mathbb D}_{10}$ so that $x$ is a multiple of $3$ is regular, as it is first-order definable as $ \{x: \exists y \in {\mathbb D}_{10}\,[x = y+y+y]\} $ and $1.2$ would be in this set and $1.01$ not. This works for all multiples of fixed rational numbers in ${\mathbb D}_b$. \end{exmp} \section{Grids with Special Properties} \noindent Jain, Khoussainov, Stephan, Teng and Zou \cite{JKSTZ17} showed that for every natural number $c$ which is not a square there is a grid containing $\sqrt{c}$. Though these grids are dense subsets of the real numbers, they do not have the property that one can divide by any natural number, that is, for each $b \geq 2$ there is a ring element $x$ such that $x/b$ is not in the ring. The reason is that most of the rings considered by Jain, Khoussainov, Stephan, Teng and Zou are of the form ${\mathbb Z} \oplus \sqrt{c} \cdot {\mathbb Z}$. The following result will produce grids for which one can always divide by some number $b \geq 2$, if this number is composite, it might allow division by finitely many primes. Note that the number of primes cannot be infinite by a result of Tsankov \cite{Ts11}. \begin{thm} \label{th:main} Assume that $b \in \{2,3,4,\ldots\}$ and $c$ is some root of an integer and let $u>1$ be a real number chosen such that the following four polynomials $p_1,p_2,p_3,p_4$ in a variable $x$ and constants $\ell,\hat c$ exist, where all polynomials have only finitely many nonzero coefficients and all coefficients are integers: \begin{enumerate} \item $p_1(u) = \sum_{k \in \mathbb Z} b_k u^k = 1/b$; \item $p_2(u) = \sum_{k \in \mathbb Z} c_k u^k = c$; \item $p_3(u) = \sum_{k=0,-1,-2,\ldots,-h+1} d_k u^k = 0$ with $d_0=1$; \item $p_4(u) = \sum_{k \in \mathbb Z} e_k u^k = 0$ with $e_\ell > \sum_{k \neq \ell} |e_k|$ and $| e_k |$ being the absolute value of $e_k$. \end{enumerate} Furthermore, the choice of the above has to be such that $\hat c > 3|e_\ell|$ and one can run for every polynomial $p = \sum_{k=-m,\ldots,n} a_k x^k$ with every $a_k$ being an integer satisfying $|a_k| \leq 3 |e_\ell|$ the following algorithm $C$ satisfying the below termination condition: \begin{quote} Let $k = n+h$. \\ While $k > -m$ and $|a_{k'}| \leq \hat c$ for $k'=k,k-1,\ldots,k-h+1$ \\ Do Begin $p = p-a_k \cdot p_3(u) \cdot u^k$ and update the coefficients of the polynomial $p$ accordingly; Let $k=k-1$ End. \end{quote} The termination condition on $C$ is that whenever the algorithm terminates at some $k > -m$ with some $|a_{k'}| > \hat c$ then \begin{quote} $|\sum_{k'=k,k-1,\ldots,k-h+1} u^{k'} a_{k'}| > u^{k-h}/(1-u^{-1}) \cdot 3|e_{\ell}|$. \end{quote} If all these assumptions are satisfied then one can use the representation $$ S = \{\sum_{k=-m,\ldots,n} a_k u^k: m,n \in {\mathbb N}, \ a_k \in {\mathbb Z} \mbox{ and } |a_k| < |e_\ell|\} $$ to represent every member of ${\mathbb D}_b[c]$ and the ring $(S,+,<,=;\cdot)$ has automatic addition and comparisons and semiautomatic multiplication. Furthermore, as $1/b$ is in the ring, it is a dense subset of the reals, thus the ring forms a semiautomatic grid. \end{thm} \begin{proof} When not giving $-m,n$ explicitly in the sum, sums like $\sum_{k \in {\mathbb Z}} a_k u^k$ use the assumption that almost all $a_k$ are $0$. For ease of notation, let $S'$ be the set $$ S' = \{\sum_{k \in {\mathbb Z}} a_k x^k: \mbox{ almost all $a_k$ are $0$ and all } a_k \in {\mathbb Z}\} \vspace{-0.1cm} $$ so that $S \subseteq S'$. On members $p,q \in S'$, one defines that $p \leq q$ iff $p(u) \leq q(u)$ when the polynomial is evaluated at the real number $u$. Furthermore, $p = q$ iff $p \leq q$ and $q \leq p$. Addition and subtraction in $S'$ is defined using componentwise addition of coefficients. Now one shows that for every $p \in S'$ there is a $q \in S$ with $p = q$. For this one lets initially $h=0$ and $q_h = p$ and whenever there is a coefficient $a_k$ of $q_h$ with $|a_k| \geq |e_\ell|$ then one either lets $q_{h+1} = q_h - x^{k-\ell} \cdot p_4$ (in the case that $a_k > 0$) or lets $q_{h+1} = q_h + x^{k-\ell} \cdot p_4$ (in the case that $a_k < 0$). Now let $||q_h||$ be the sum of the absolute values of the coefficients; note that $$ ||q_{h+1}|| \leq ||q_h||-e_\ell+\sum_{k \neq \ell} |e_k| < ||q_h|| $$ and as there is no infinite strictly decreasing sequence of integers, there is a $h$ where $q_h$ is defined but $q_{h+1}$ not, as this update can no longer be made. Thus all coefficients of $q_h$ are between $-|e_\ell|$ and $+|e_\ell|$ and furthermore, as each polynomial $p_4(u) \cdot u^{k-\ell}$ added or subtracted has the value $0$, $q_h = p$. Now let $q = q_h$ and note that $q$ is a member of $S$ with the same value at $u$ as $p$, so $p(u) = q(u)$. Now let $p,q,r$ be members of $S$. In order to see what the sign of $p+q-r$ is, that is, whether $p(u)+q(u)<r(u)$, $p(u)+q(u)=r(u)$ or $p(u)+q(u)>r(u)$, one adds the coefficients pointwise and to check the expression $p+q-r$ at $u$, one then runs the algorithm $C$. If $C$ terminates with some $|a_{k'}| > \hat c$, then the sign of the current value of \ifxfullfull $$\sum_{k'=k,k-1,\ldots,k-h+1} u^{k'} a_{k'}$$ \fi \ifxfullconf $$\tilde a = \sum_{k'=k,k-1,\ldots,k-h+1} u^{k'} a_{k'}$$ \fi gives the sign of $p+q-r$, as the not yet processed tail-sum of $p+q-r$ is bounded by $u^{k-h}/(1-u^{-1}) \cdot 3|e_{\ell}|$. In the case that $C$ terminates with all $|a_{k'}| \leq \hat c$ and $k=-m$, then only the coefficients at $k'=k,k-1,\ldots,k-h+1$ are not zero and again the sign of \ifxfullfull $$\sum_{k'=k,k-1,\ldots,k-h+1} u^{k'} a_{k'}$$ \fi \ifxfullconf $\tilde a$ \fi is the sign of the original polynomial $p+q-r$. Note that the algorithm $C$ can be carried out by a finite automaton, as it only needs to memorise the current values of $(a_k,a_{k-1},$ $\ldots,a_{k-h+1})$ which are $(0,0,\ldots,0)$ at the start and which are updated in each step by reading $a_{k-h}$ for $k=n+h,n+h-1,\ldots,-m$; the update is just subtracting $a_{k'} = a_{k'}-a_k \cdot d_{k'-k}$ for $k'=k,k-1,\ldots,k-h+1$ and then updating $k=k-1$ which basically requires to read $a_{k-h}$ into the window and shift the window by one character; note that the first member, which goes out of the window, is $0$. Furthermore, during the whole runtime of the algorithm, all values in the window have at most the values $(1+\max\{|d_{k''}|: 0 \geq k'' \geq -h+1\}) \cdot \hat c$ and thus there are only finitely many choices for $(a_k,a_{k-1},\ldots,a_{k-h+1})$, and thus the determination of the sign of $\sum_{k'=k,k-1,\ldots,k-h+1} u^{k'} a_{k'}$ can be done by looking up a finite table. Early termination of the finite automaton can be handled by not changing the state on reading new symbols, once it has gone to a state with some $|a_{k'}| > \hat c$. Thus comparisons and addition are automatic; note that for automatic functions, the automaton checks whether the tuple $(inputs,output)$ is correct, it does not compute $output$ from $inputs$. For the multiplication with constants, note that multiplication with $u$ or $u^{-1}$ is just shifting the coefficients in the representation by one position; multiplication with $-1$ can be carried out componentwise on all coefficients; multiplication with integers is repeated addition with itself. This also then applies to polynomials put together from these ground operations, so $p \cdot (u^2-2+u^{-1})$ can be put together as the sum of $p \cdot u \cdot u$, $-p$, $-p$, $p \cdot u^{-1}$. All four terms of the sum can be computed by concatenated automatic functions, thus there is an automatic function which also computes the sum of these terms from a single input~$p$.~$\Box$ \end{proof} \begin{exmp} \label{2R2+1/2} There is a semiautomatic grid containing $\sqrt{2}$ and $1/2$. \end{exmp} \begin{proof} For $c = \sqrt{2}$ and $b=2$, one chooses \begin{enumerate} \item $u^{-1} = 1-c/2$ (note that $u = 1/(1-\sqrt{1/2}) = 2/(2-\sqrt{2})>1$), \item $p_1(u) = 2u^{-1}-u^{-2} = 1/2$, \item $p_2(u) = 2-2u^{-1} = c$, \item $p_3(u) = 1-4u^{-1}+2u^{-2} = 0$, \item $p_4(u) = -u+4-2u^{-1} = 0$ with $\ell = 0$ and $e_{\ell}=4$, \item $\hat c = 100$ (or any larger value). \end{enumerate} While all operations above come from straight-forward manipulations of the choice of $u^{-1}$, one has to show the termination condition of the algorithm. For this one uses that $u \geq 3.41$ and $1/(1-1/u) = \sum_{k \leq 0} u^k = \sqrt{2} \leq 1.4143$. Assume that the algorithm satisfies before doing the step for $k$ that all $|a_{k'}| \leq \hat c$ and does not satisfy this after updating $a_k,a_{k-1},a_{k-2}$ respectively to $0$, $a' = a_{k-1}+4a_k$ and $a'' = a_{k-2}-2a_k$; in the following, $a_k,a_{k-1},a_{k-2}$ refer to the values before the update. Without loss of generality assume that $a_k > 0$, the case $a_k < 0$ is symmetric, the case $a_k=0$ does not make the coefficients go beyond $\hat c$. If $a'' < -\hat c$ --- it can only go out of the range to the negative side --- then $2a_k \geq \hat c-3 (e_\ell-1)$ and $p(u)$ is at least $a_k \cdot (4-2/u) \cdot u^{k-1} - \hat c \cdot u^{k-1}/(1-1/u) \geq ((2-1/u) \cdot (\hat c -9) - 1.4143 \hat c) u^{k-1} \geq (1.7 \cdot (\hat c \cdot 0.9) - 1.4143 \hat c) u^{k-1} \geq 0.1 \cdot \hat c \cdot u^{k-1}> 0$. If $a'' \geq -\hat c$ and $a' > \hat c$ then $p(u) \geq (\hat c \cdot u - 1/(1-1/u) \hat c) \cdot u^{k-2} \geq \hat c \cdot u^{k-2} > 0$. So in both cases, one can conclude that $p(u)$ is positive. Similarly, when $a_k < 0$ and the bound $\hat c$ becomes violated in the updating process then \mbox{$p(u) < 0$.}~$\Box$ \end{proof} \begin{exmp} \label{2R3+1/2} There is a grid which contains $\sqrt{3}$ and $1/2$ or, more generally, any $c$ of the form $c = \sqrt{b^2-1}$ and $1/b$ for some fixed integer $b \geq 2$. \end{exmp} \begin{proof} One chooses \begin{enumerate} \item $u^{-1} = 1-c/b$ (note that $u = b/(b-c) > 1$), \item $p_1(u) = 2bu^{-1}-bu^{-2} = 1/b$, \item $p_2(u) = b-bu^{-1} = c$, \item $p_3(u) = 1-2b^2u^{-1}+b^2u^{-2} = 0$, \item $p_4(u) = -u+2b^2-b^2u^{-1} = 0$ with $\ell = 0$ and $e_{\ell}=2 b^2$, \item $\hat c = 1000 \cdot b^5$ (or any larger value). \end{enumerate} While all operations above come from straight-forward manipulations of the equations, the termination condition of the algorithm needs some additional work. Note that $u > b$, as $b-c < 1$. Indeed, by $u \geq 1$ and $p_3(u)=0$ and $b \geq 2$, one has $1-b^2u^{-1} \geq 0$ and $u \geq b^2$ and $\sum_{k \leq 0} u^k \leq 2$. For the algorithm, one now notes that if after an update at $k$ where, without loss of generality, $a_k > 0$, it happens that either (a) $a'' = a_{k-2}-b^2 a_k < -\hat c$ or (b) $a'' \geq -\hat c$ and $a' = a_{k-1}+2b^2 a_k > \hat c$ then the following holds: In the case (a), $a_k \geq 1000 b^3 - 6 b^2$ and the value of the sum is at least \begin{eqnarray*} (a_k \cdot (2b^2 u-b^2)-\hat c \cdot u - 12 b^4) \cdot u^{k-2} & > & \\ ((2000 b^5 u -6b^4) - 1000 b^5\cdot u - 12 b^4) \cdot u^{k-2} & > & \\ (1000 b^5 - 18 b^4) \cdot u^{k-1} & > & 0 \end{eqnarray*} where the tail sum $12 b^4$ estimates that all digits $a_{k'}$ with $k' \leq k-2$ are at least $-6b^2$ in the expression and the $a_{k-1}$ is at least $-\hat c$ by assumption. In case (b), one just uses that the first coefficient in the sum is greater than $\hat c$ while all other coefficients are of absolute value below $\hat c$, in particular as $\hat c \geq 6b^2$, so that, since $u \geq 2$, $$ \hat c \cdot u^{k-1} > \sum_{k' < k-1} \hat c u^{k'} \mbox{ and } \hat c \cdot u^{k-1} > 2 \cdot \hat c \cdot u^{k-2}. $$ Thus the algorithm terminates as required.~$\Box$ \end{proof} \section{Applications to Geometry} \noindent One can use the grid to represent the coordinates of geometric objects. For this, one uses in the field of automatic structures the concept of convolution which uses the overlay of constantly many words into one word. One introduces a new symbol, $\#$, which is there to pad words onto the same length. Now, for example, if in the grid of decimal numbers, one wants to describe a point of coordinates $(1.112,22.2895)$, this would be done with the convolution $(\#,2) (1,2) . (1,2) (1,8) (2,9) (\#,5)$ where these six characters are the overlay of two characters and the dot is virtual and only marking the position where the numbers have to be aligned, that means, the position between the symbols at location $0$ and location $-1$. Instead of combining two numbers, one can also combine five numbers or any other arity. An automatic family is a family of sets $L_e$ with the indices $e$ from some regular set $D$ such that the set $\{conv(e,x): x \in L_e\}$ is regular. Given a grid $G$, the set of all lines parallel to the $x$-axis in $G \times G$ is an automatic family: Now $D = G$ and $L_y = \{conv(x,y): x \in G\}$. The next example shows that one cannot have an automatic family of all lines. \begin{exmp} The set of all lines (with arbitrary slope) is not an automatic family, independent of the definition of the semiautomatic grid. Given a grid $G$ and assuming that $\{L_e: e \in D\}$ is the automatic family of all lines, one can first-order define the multiplication using this automatic family: \begin{quote} $x \cdot y = z$ if either at least one of $x,y$ and also $z$ are $0$ or $x=1$ and $y=z$ or $y=1$ and $x=z$ or all are nonzero and neither $x$ nor $y$ is $1$ and there exists an $e \in D$ such that $conv(0,0),conv(1,y),conv(x,z)$ are all three in $L_e$. \end{quote} As the grid $G$ has to be dense and is a ring with automatic addition and comparison and as $G \subset \mathbb R$, the ring $G$ is an integral domain and furthermore, $G$ has an automatic multiplication by the above first-order definition. Khoussainov, Nies, Rubin and Stephan \cite{KNRS04} showed that no integral domain is automatic, hence the collection of all lines cannot be an automatic family, independent of the choice of the grid. \end{exmp} \noindent Similarly one can consider the family of all triangles. \begin{thm} Independently of the choice of the semiautomatic grid $G$, the family of all triangles in the plane is not an automatic family. However, every triangle with corner points in $G \times G$ is a regular set. \end{thm} \begin{proof} For the first result, assume that $\{L_e: e \in D\}$ is a family of all triangles -- when viewed as closed subsets of $G \times G$ -- which are represented in the grid and that this family contains at least all triangles with corner points in $G \times G$. Now one can define for $x,y,z > 0$ the multiplication-relation $z = x \cdot y$ using this family as follows: \begin{quote} $z = x \cdot y$ $\Leftrightarrow$ some $e\in D$ satisfies the following conditions: \\ $\forall v,w \in G \mbox{ with } v \leq 0\,[(v,w) \in L_e \Leftrightarrow (v,w) = (0,0)]$, \\ $\forall w \in G\,[(1,w) \in L_e \Leftrightarrow 0 \leq w \wedge w \leq y]$, \\ $\forall w \in G\,[(x,w) \in L_e \Leftrightarrow 0 \leq w \wedge w \leq z]$. \end{quote} This definition can be extended to a definition for the multiplication on full $G$ with a straightforward case-distinction. Again this cannot happen as then the grid would form an infinite automatic integral domain which does not exist. However, given a triangle with corner points $(x,y),(x',y'),(x'',y'')$, note that one can find that linear functions from $G \times G$ into $G$ which are nonnegative iff the input point is on the right side of the line through $(x,y)$ and $(x',y')$. So one would require that the function $$f(v,w) = (w-y) \cdot (x'-x) - (v-x) \cdot (y'-y) $$ is either always nonpositive or always nonnegative, depending on which side of the line the triangle lies; by multiplying $f$ with $-1$, one can enforce nonnegativeness. Note here that $x'-x$ and $y'-y$ are constants and multiplying with constants is automatic, as the ring has a semiautomatic multiplication. Thus a point is in the triangle or on its border iff all three automatic functions associated with the three border-lines of the triangle do not have negative values. This allows to show that every triangle with corner points in $G \times G$ is regular.~$\Box$ \end{proof} \medskip \noindent Note that this also implies that polygons with all corner points being in $G \times G$ are regular subsets of the plane $G \times G$. \begin{prop} Moving a polygon by a distance $(v,w)$ can be done in any grid, as it only requires adding $(v,w)$ to the coordinates of each points. However, rotating by $30^\circ$ or $45^\circ$ is possible in some but not all grids. \end{prop} \begin{proof} Note that the formula for rotating around $30^\circ$, one needs to map each point $(x,y)$ by the mapping $(x,y) \mapsto (\cos(30^\circ) x - \sin(30^\circ)y, \sin(30^\circ) x + \cos(30^\circ) y)$ and similarly for $45^\circ$ and $60^\circ$. For $30^\circ$, as $\sin(30^\circ) = 1/2$ and $\cos(30^\circ) = \sqrt{3}/2$, one needs a grid which allows to divide by $2$ and multiply by $\sqrt{3}$, an example is given by the grid of Example~\ref{2R3+1/2}. For rotating by $60^\circ$, as it is twice doing a rotation by $30^\circ$, the same requirements on the grid need to be there. For rotating by $45^\circ$, the grid from Example~\ref{2R2+1/2} can be used. However, these operations cannot be done with grids which do not have the corresponding roots and also do not have the possibility to divide by $2$. In particular, the grids ${\mathbb D}_b$ do not allow to multiply by roots and those grids of the form ${\mathbb Z} \cup \sqrt{c} \cdot {\mathbb Z}$ in prior work \cite{JKSTZ17} do not allow to divide by $2$. Furthermore, the authors are not aware of any grid which has both, $\sqrt{2}$ and $\sqrt{3}$ and thus allow to rotate by both, $30^\circ$ and $45^\circ$.~$\Box$ \end{proof} \begin{rem} A grid allows to represent all equilateral triangles with side-length in $G$ iff $\sqrt{3}$ and $1/2$ are both in $G$. \ifxfullfull This is in particular true for grids which allow to rotate by $60^\circ$ and it is false for all grids of the type ${\mathbb D}_b$. For a proof, assume that in a plane $G \times G$, an equilateral triangle is represented with all three corner points in $G \times G$. So let $(x,y),(x',y')$ be two corner points in $G \times G$. Now the third corner point $(x'',y'')$ has either the coordinates $$((x+x')/2+(y-y') \cdot \sqrt{3}/2,(y+y')/2+(x'-x)\cdot \sqrt{3}/2)$$ or the coordinates $$((x+x')/2-(y-y') \cdot \sqrt{3}/2,(y+y')/2-(x'-x)\cdot \sqrt{3}/2)$$ and in either case, a scaling of either $x-x'$ or $y-y'$ by $\sqrt{3}/2$ has to be in $G$ and at least one of these is nonzero. This is impossible in the case of $G = {\mathbb D}_b$, as all members of $G$ are rational. However, it can always be done in the grid from Example~\ref{2R3+1/2} with $c = \sqrt{3}$ and $b=2$, as in that grid there are automatic functions which divide the input by $2$ and which multiply the input with $\sqrt{3}$, respectively. In this grid, for any base-line given by two distinct points in $G \times G$, one can find the third point in order to obtain the equilateral triangle with the three corner points. \fi \end{rem} \begin{rem} \label{rem:standardrep} Note that one represents a word $a_5 a_4 \ldots a_1 a_0.a_{-1} a_{-2}\ldots a_{-7}$ also by starting with $a_0$ and then putting alternatingly the digits of even and odd indices giving \ifxfullfull $$a_0 a_1 a_{-1} a_2 a_{-2} \ldots a_5 a_{-5} 0 a_{-6} 0 a_{-7}$$ \else $a_0 a_1 a_{-1} a_2 a_{-2} \ldots a_5 a_{-5} 0 a_{-6} 0 a_{-7}$ \fi and one can show that in this representation, the same semiautomaticity properties are valid as in the previously considered representation. However, one gets one additional relation: One can recognise whether two digits $a_{-m}$ and $a_n$ satisfy that $n=m+c$ for a given integer constant $c$. This is used in the following example. \end{rem} \begin{exmp} The family $\{E_d: d \in D\}$ of all axis-parallel rectangles is an automatic family in all grids. Furthermore, let $d \equiv d'$ denote that $E_d$ and $E_{d'}$ have the same area. In no grid, this relation $\equiv$ is automatic, as otherwise one could reconstruct the multiplication. For $p$ being a prime power, in the grid $({\mathbb D}_p,+,=,<;\cdot)$ from Example~\ref{gridexample}, the relation $\equiv$ is semiautomatic using the representation given in Remark~\ref{rem:standardrep}. To see this, for a given area $\ell \cdot p^k$, (i) one can disjunct over all factorisations $\ell_1 \cdot \ell_2$ of $\ell$ which are pairs of natural numbers not divisible by $p$, then (ii) check whether the length of the sides of a given rectangle are of the form $\ell_1 \cdot p^i$ and $\ell_2 \cdot p^j$ with $i+j = k$, where $i,j$ are the positions of the last nonzero digits in the $p$-adic representation of the lengths and (iii) check, by Remark~\ref{rem:standardrep}, whether $i+j$ are the given constant $k$. Note that representations using prime powers can be translated into representations based on the corresponding primes. However, for grids such as $({\mathbb D}_6,+,=,<;\cdot)$, where $b$ is a composite number other than a prime power, this method does not work. This is mainly because one needs to use base $6$ for the comparison $<$ and then a finite automaton cannot see whether the two sides are, for example, of lengths $2^k$ and $2^{-k}$ when recognising squares of area $1$. Knowing that this method does not work, however, does not say that no other method works. It is an open problem whether one can find a semiautomatic grid which allows to divide by $6$ and to represent axis-parallel rectangles in a way such that checking whether two rectangles have same area is semiautomatic. The same applies to the grids of Examples~\ref{2R2+1/2} and~\ref{2R3+1/2}. \end{exmp} \section{Cube Roots} \noindent Jain, Khoussainov, Stephan, Teng and Zou \cite{JKSTZ17} did not find any example of other roots than square roots to be represented in a semiautomatic ordered ring. The following example represents a cube root. \begin{exmp} \label{3R7} There is a grid which contains $\sqrt[3]{7}$. Furthermore, there is a grid which contains $\sqrt[3]{65}$ and $1/2$. For the first, as one does not want to represent a proper rational, $p_1$ is not needed. For this, one chooses \begin{enumerate} \item $u^{-1} = 2-\sqrt[3]{7}$, \item $p_2(u) = 2-u^{-1} = \sqrt[3]{7}$, \item $p_3(u) = 1-12u^{-1}+6u^{-2}-u^{-3} = 0$ and $p_4(u) = -p_3(u)$ with $\ell = -1$, \item Instead of a flat $\hat c$, one uses a bit different bound for the algorithm, namely $|a_k| \leq 16\hat c$, $|a_{k-1}| \leq 4 \hat c$ and $|a_{k-2}| \leq \hat c$ for $\hat c = 360$. \end{enumerate} The equations for $p_3,p_4$ follow from $p_3(u) = (p_2(u))^3-7$. Note that $11 < u < 12$ and $u^{-1}+u^{-2}+\ldots \leq 1/10$. Furthermore, the coefficients in the normal form are between $-12$ and $+12$ and, when three numbers are added coefficientwise, between $-36$ and $+36$. Let $p = \sum_k a_k \cdot u^k$ be such a sum of three numbers whose sign has to be determined; all the coefficients have absolute values up to $36$. The main thing is that the algorithm can detect the sign of the number whenever the first three coefficients overshoot for the first time. Note that they start with $(0,0,0)$ and so one runs the updates $a_{k-k'} = a_{k-k'}-a_k \cdot d_{-k'}$ simultaneously for $k'=1,2,3$ and then sets $a_k = 0$ and $k=k-1$ Here $d_{\cdot}$ are coefficients of $p_3$. Assume that the update would make the coefficients to overshoot for the first time and let $k,a_k,a_{k-1}, a_{k-2},a_{k-3}$ and $p = \sum_{k'} a_{k'}u^{k'}$ denote the values just before the update. Without loss of generality, assume that $a_k > 0$ and it will be shown that this implies that the polynomial $p$ would be positive. Note that before the update, for all $k'<k$, $|a_{k'}| \leq 4 \hat c$ and $|\sum_{k'<k} a_{k'} u^{k'}| \leq 0.4 \cdot \hat c \cdot u^k$. If $a_{k-3}$ grows above $\hat c$ at the update then $a_k \geq \hat c \cdot 9/10$ and $p > (0.9 \cdot \hat c - \sum_{k' \leq -1} a_{k+k'} \cdot u^{k'}) \cdot u^k \geq (0.9 - 0.4) \cdot \hat c \cdot u^k > 0$. If $a_{k-2}$ grows below $-4\hat c$ at the update but $a_{k-3}$ stays inside the bound then $a_k \geq \hat c \cdot 3 \cdot 1/6$ and $p > (0.5-0.4) \cdot \hat c \cdot u^k > 0$. If $a_{k-1}$ grows beyond $16 \hat c$ at the update but $a_{k-2}$ and $a_{k-3}$ stay inside their bounds then $a_k \geq \hat c \cdot 12 \cdot 1/12$ and $p > (1-0.4) \cdot \hat c \cdot u^k > 0$. \ifxfullconf Thus there is a semiautomatic grid containing $\sqrt[3]{7}$. One similarly proves the second item that there is a semiautomatic grid containing $\sqrt[3]{65}$ and $1/2$. \fi \ifxfullfull So the above test can detect the sign of $p$ by just looking at the sign of $a_k$ in the event that the next step overshoots; if, through the runtime, it never overshoots, then one can deduce the sign of $p$ from a table look-up of the final values of the coefficients in the tracked window. Thus there is a semiautomatic grid containing $\sqrt[3]{7}$. Furthermore, for the grid which contains $\sqrt[3]{65}$ and $1/2$, one chooses \begin{enumerate} \item $u^{-1} = (\sqrt[3]{65}-4)/2$, note that $96.49 \leq u \leq 96.50$, \item $p_1(u) = 4((u^{-1}+2)^3-8) = 48u^{-1}+24u^{-2}+4u^{-3} = 1/2$, \item $p_2(u) = 2u^{-1}+4 = \sqrt[3]{65}$, \item $p_3(u) = 1-96u^{-1}-48u^{-2}-8u^{-3} = 0$ and $p_4(u) = -p_3(u)$ with $\ell = -1$, \item Instead of a flat $\hat c$, one uses a bit different bound for the algorithm, namely $|a_k| \leq 19\hat c$, $|a_{k-1}| \leq 7 \hat c$ and $|a_{k-2}| \leq \hat c$ for $\hat c$ very large, for example $\hat c = 285000$. \end{enumerate} Note that $96.49 < u < 96.50$ and $u^{-1}+u^{-2}+\ldots \leq 1/95$. Furthermore, the coefficients in the normal form are between $-95$ and $+95$ (both inclusive) and, when three numbers are added coefficientwise, between $-285$ and $+285$ (both inclusive). Let $p = \sum_k a_k \cdot u^k$ be such a sum of three numbers whose sign has to be determined; all the coefficients have absolute values up to $285$. Again the algorithm can detect the sign of the number whenever the first three coefficients overshoot for the first time. Note that they start with $(0,0,0)$ and so one runs the updates $a_{k-k'} = a_{k-k'}-a_k \cdot d_{-k'}$ simultaneously for $k'=1,2,3$ and then sets $a_k = 0$ and $k=k-1$. Here $d_{\cdot}$ are coefficients of $p_3$. Assume that the update would make the coefficients to overshoot for the first time and let $k,a_k,a_{k-1}, a_{k-2},a_{k-3}$ and $p = \sum_{k'} a_{k'}u^{k'}$ denote the values just before the update. Without loss of generality, assume that $a_k > 0$ and it will be shown that this implies that the polynomial $p$ would be positive. Note that before the update, for all $k'<k$, $|a_{k'}| \leq 7 \hat c$ and $|\sum_{k'<k} a_{k'} u^{k'}| \leq 7/95 \cdot \hat c \cdot u^k \leq 0.074 \cdot \hat c \cdot u^k$. If $a_{k-3}$ grows above $\hat c$ at the update then $8a_k \geq \hat c \cdot 999/1000$ and $a_k \geq 0.1 \hat c$ and $p > (0.1 \cdot \hat c - \sum_{k' \leq -1} a_{k+k'} \cdot u^{k'}) \cdot u^k \geq (0.1 - 0.074) \cdot \hat c \cdot u^k > 0$. If $a_{k-2}$ grows above $7\hat c$ at the update then $48a_k \geq (7 \hat c - \hat c)$ and $a_k \geq \hat c/8 \geq 0.1 \hat c$ and $p > (0.1 - 0.074) \cdot \hat c \cdot u^k > 0$. If $a_{k-1}$ grows beyond $19 \hat c$ at the update then $96a_k \geq \hat c \cdot (19-7)$ and $a_k \geq \hat c/8 \geq 0.1 \hat c$ and $p > (0.1 - 0.074) \cdot \hat c \cdot u^k > 0$. So the test works well and similarly the test also gives that $p<0$ in the case that there is an overshooting with negative $a_k$. Thus there is a semiautomatic grid containing $\sqrt[3]{65}$ and $1/2$. The method could be used to generate other examples of grids with cube roots and fractions. \fi \end{exmp} \section{Representing All Reals} \label{se:omega} \noindent \ifxfullfull The authors assume for this section that the readers are familiar with the theory of $\omega$-automata. Here $\omega$-words are mappings $k \mapsto a_k$ from $\mathbb Z$ to the set of digits such that, for some $k$, all $a_h$ with $h>k$ are $0$. An $\omega$-automaton starts at an arbitrary $k$ such that all $a_h$ with $h \geq k$ are $0$ in a start state and then reads $a_k a_{k-1} a_{k-2} \ldots$ and updates, on each $a_h$ read, its state in the same way as a finite automaton. If the $\omega$-automaton goes infinitely often through an accepting state, then it accepts the $\omega$-word, else it rejects the $\omega$-word. In the case of determining the sign, there is a positive acceptance and a negative acceptance; rejecting means that the $\omega$-word represents $0$. Note that for an $\omega$-word to be accepted, the $\omega$-automaton needs just to have some accepting run and not all runs need to be accepting. \fi Now a comment on the $\omega$-automatic approach \cite{BJW05,CK97,JSY07}. The reals with addition and multiplication and infinite integral domains in general are not $\omega$-automatic \ifxfullfull \cite{ZGK12,ZGKP13}. \fi \ifxfullconf \cite{ZGKP13}. \fi It is also clear that $({\mathbb R},+;\cdot)$ is not $\omega$-semiautomatic, as one otherwise would need uncountably many different $\omega$-automata for recognising the uncountably many functions $x \mapsto r \cdot x$ for constants $r \in \mathbb R$. So the best what one can expect is that $({\mathbb R},+,<,=)$ is $\omega$-automatic and that there are countably many functions $f_r: x \mapsto r \cdot x$ which are $\omega$-automatic as well. These functions certainly include, independent of the ring representation, all $f_r$ with $r \in \mathbb Q$, as one only verifies the relation $x \cdot r = y$ and for $r = i/j$ this is equivalent with verifying $x \cdot i = y \cdot j$ with $i,j$ are integers and multiplication with integers can be realised by repeated self-addition. The following result shows that one can carry over ideas of Theorem~\ref{th:main} to $\omega$-automatic structures in order to get that multiplication with all constants from ${\mathbb Q}[\sqrt{b}]$ are $\omega$-automatic for all natural numbers $b \geq 2$. As there is no need to implement the division by $2$ explicitly, as that comes for free, one can use the previously known representations \cite[Theorem~26]{JKSTZ17}. \begin{thm} \label{th:omega} There is an $\omega$-automatic representation of the reals where addition, subtraction and comparisons are $\omega$-automatic and furthermore the multiplication with any constant from ${\mathbb Q}[\sqrt{b}]$ is also an $\omega$-automatic unary function. \end{thm} \ifxfullfull \begin{proof} One uses the representation of \cite[Theorem 26]{JKSTZ17}. For $b \geq 2$ which is not a square, one can use that there are natural numbers $d,e>3$ with $d^2 = be^2+1$. Now one chooses $u = d+e \sqrt{b}$ and as shown by Jain, Khoussainov, Stephan, Teng and Zou \cite[Theorem 26]{JKSTZ17}, $u+u^{-1} = 2d$. Given any $\omega$-word $\sum_{k \in \mathbb Z} a_k u^k$ where all sufficiently large $k$ satisfy $a_k = 0$, one can always choose the largest coefficient with $|a_k| > 2d$ and let $s$ be the sign of $a_k$ and update $a_{k+1} = a_{k+1}+s, a_k = a_k - 2ds, a_{k-1}=a_{k-1}+s$; either this algorithm terminates or runs forever. In the case that all coefficients are initially bounded by a constant $\hat c$, the algorithm produces in the limit an $\omega$-word of the same value $\sum_k a_k u^k$ such that all $k$ satisfy $|a_k| \leq 2d$: For the verification, one takes a value $\tilde u > 1$ such that $2d-\tilde u - 1/\tilde u > 0$. Starting with an $\omega$-word $p_0(u)$, let $p_n(u)$ be the $\omega$-word after the $n$-th iteration and let $q_n(\tilde u)$ be $\sum_{k \in \mathbb Z} |a_k| \tilde u^k$ where the coefficients are taken from $p_n(u) = \sum_{k \in \mathbb Z} a_k u^k$. Due to the absolute bounds on the coefficients and due to $a_k = 0$ for all sufficiently large $k$, both $p_n(u)$ and $q_n(\tilde u)$ converge absolutely. Note that the value $p_n(u) = \sum_k a_k u^k$ is for all $n$ the same, as every $u^{k+1} - 2du^k + u^{k-1}$ has the value $0$ and $p_{n+1}(u) = p_n(u) + s(u^{k+1} - 2du^k + u^{k-1})$ for some $k$ and $s$. Furthermore, $$ q_{n+1}(\tilde u) \leq q_n(\tilde u) - (2d-\tilde u-1/\tilde u) \cdot {\tilde u}^k $$ for the $k$ from the update of $p_n$. Furthermore, $q_n(\tilde u) \geq 0$ for all $n$. For that reason, the sequence of the $q_n(\tilde u)$ converges from above to some number. Thus, for each $k$ there can only be finitely many updates where some digit at or above $k$ changes. Thus the pointwise limit $p_{\infty}$ of all $p_n$ exists and this limit satisfies that all coefficients have at most the absolute value $2d$. Furthermore, all $p_n(u)$ have the same value. Furthermore, if one looks at the difference $\omega$-words $p_n-p_\infty$ then its coefficients converge at $\tilde u$ absolute and therefore converge also absolute when $u$ is taken, as $u^{-1} < \tilde u^{-1}$ and for almost all $n$, only nonzero negative-indexed coefficients occur. Thus the $p_n(u)$ converge to $p_\infty(u)$ and thus $p_\infty(u)$ has the same value as $p_n(u)$ while all its coefficients are between $-2d$ and $+2d$. Thus all real numbers can be represented in the given system. For verifying that addition and comparison are $\omega$-automatic, one shows that given $p = r_1+r_2-r_3$ computes by coefficientwise addition and subtraction of the three numbers $r_1,r_2,r_3$ given in the normal form, there is a deterministic B\"uchi automaton which recognises, on the $\omega$-word of all $a_k$, the sign of $p(u) = \sum_{k \in \mathbb Z} a_k u^k$ where all sufficiently large $k$ have $a_k = 0$. The digits are bounded by $6d$. The algorithm is like algorithm $C$ in Theorem~\ref{th:main}, when $k$ is the largest nonzero coefficient, the algorithm starts with the memory $(a_{k+2},a_{k+1}) = (0,0)$ and then in each round updates on reading $a_k$ the memory from $(a_{k+2},a_{k+1})$ to $(a_{k+1}+2da_{k+2},a_k-a_{k+2})$, where the first number has at most the absolute value $306d^2$ and the second number has at most the absolute value $106d$. These values can only overshoot when $a_{k+2}$ before the update has at least the absolute value $100d$. So assume, without loss of generality, that $a_{k+2} > 100d$, and that it is the first time where an overshooting will happen as a consequence of an upcoming update. As the overshooting has not yet happened, all $a_h$ with $h < k+2$ satisfy $|a_h| \leq 106d$. Note that $$100d > 106d \cdot \sum_{k < 0} u^k \geq 106d \cdot (1/d+1/d^2+\ldots),$$ as $d>3$ and $1/d+1/d^2+\ldots \leq 1/3$. Thus the algorithm can always indicate that the number is positive in the case that an overshooting happens at an update where the first component of the old memory pair is positive and the algorithm can indicate that the number is negative in the case that an overshooting happens at an update where the first component of the old memory pair is negative. Furthermore, as there are only finitely many possibilities for the two components in the memory, the algorithm works overall with finite memory and can be implemented as a B\"uchi automaton which goes into the right accepting state (for positive or negative) at that moment that the sign of $p$ is known and which then stays in this state forever. While this allows directly to implement addition, subtraction and comparisons, one has still to verify that multiplications with finite polynomials $q(u)$ work. For the latter, note that a shift by a costant amount of positions, say from $\sum_k a_k u^k$ to $\sum_k a_k u^{k+h}$ for some constant $h$, is an $\omega$-automatic function. Thus multiplication with fixed positive or negative powers of $u$ is $\omega$-automatic. Furthermore, repeated addition is $\omega$-automatic. For multiplication with rationals involving $u$ like $x \mapsto (3+u)/(8-u^3) \cdot x$ can be mapped back to multiplication with polynomials: In the theory of $\omega$-automatic functions, one does not compute the $y = (3+u)/(8-u^3) \cdot x$ directly but one compares whether $y$ is the result of that operation. For that reason, one can just compare whether $y \cdot (8-u^3) = x \cdot (3+u)$ and this can be implemeted via multiplication with fixed polynomials in~$u$.~$\Box$ \end{proof} \medskip \noindent This also works with the field of $\mathbb Q$ extended by $\sqrt[3]{7}$ or $\sqrt[3]{65}$ using the formulas and algorithms given in Example~\ref{3R7}. So one has the following corollary. \begin{cor} For any semiautomatic subring $(G,+,<,=;\cdot)$ of the reals constructed by methods in the present work, there is an $\omega$-automatic representation of the reals where addition, subtraction and comparisons are $\omega$-automatic and furthermore the multiplication with any constant from $G$ is also an $\omega$-automatic unary function. \end{cor} \section{Conclusion} \noindent Jain, Khoussainov, Stephan, Teng and Zou \cite{JKSTZ17} studied semiautomatic structures and in particular semiautomatic ordered rings where addition, subtraction, order and equality are in fact automatic. In particular they showed that for all nonsquare positive integers $c$ the ordered ring $({\mathbb Z}[\sqrt{c}],+,<,=;\cdot)$ is semiautomatic. The present work shows that for certain roots one can also add in the fraction $1/2$ so that the rings $({\mathbb D}_2[\sqrt{c}],+,<,=;\cdot)$ with $c=2,3$, respectively, are semiautomatic. The case $c=3$ has applications in geometry, as one can take the domain $G$ of the ring as a grid in order to represent geometric objects with corner points in $G \times G$. This grid $G$ in particular allows to represent equilateral triangles and also allows to rotate objects by $30^\circ$ in the representation. For the case $c=2$, one obtains a grid where one can rotate by $45^\circ$. It is unknown whether one can make a grid which allows to rotate by $15^\circ$, the challange would be that one has to get $\sqrt{2}$ and $\sqrt{3}$, $1/2$ all three into the grid in a way that addition, comparison, equality and multiplication with fixed elements from the grid are automatic. Further results are investigations into which collections of geometric objects form an automatic family; while the collection of all triangles with corner points in $G \times G$ is for no grid $G$ an automatic family, all triangles and polygones with corner points in $G \times G$ are always regular. Axis-parallel rectangles form an automatic family and for some grids, the relation saying that two axis-parallel rectangles have the same size is semiautomatic. Finally the paper provides two semiautomatic rings which contain $\sqrt[3]{7}$ and $\sqrt[3]{65}$, respectively, and these methods can generate further such examples. Some subsequent discussions transfer the results to $\omega$-automatic structures. For $\omega$-automatic structures, as for every real $r$ and every integer $b$ the number $r/b$ always exists, one does not need, as in the case of countable grids, to make sure that one can divide by $b$ explicitly; it comes for free whenever addition is $\omega$-auto\-matic, that is, if one has an $\omega$-automatic model of the reals with addition and order, then the multiplication with every fixed rational is automatic; so the main goal is to extend this also to multiplication with some irrationals and this can be done for all square-roots of positive integers by transferring results from prior work and also for $\sqrt[3]{7}$ and $\sqrt[3]{65}$ by applying methods in the present work. Note that enabling the multiplication of different irrationals might require different representations and therefore the current methods do not give a single $\omega$-automatic structure where the multiplication with each algebraic number is $\omega$-automatic. \fi
{'timestamp': '2021-03-12T02:25:55', 'yymm': '2103', 'arxiv_id': '2103.06714', 'language': 'en', 'url': 'https://arxiv.org/abs/2103.06714'}
arxiv
\section{Training Parameters} \label{sec:training_parameters} \begin{lstlisting} general settings: layers 6 rnn_size 300 word_vec_size 300 transformer_ff 1200 heads 6 warmup_init_lr 1e-8 warmup_end_lr 0.0007 min_lr 1e-9 encoder_type transformer decoder_type transformer position_encoding max_generator_batches 2 param_init_glorot label_smoothing 0.1 param_init 0 share_embeddings share_decoder_embeddings generator_layer_norm warmup_steps 4000 learning_rate 1 \end{lstlisting} \begin{lstlisting} vmf model: dropout 0.1 batch_size 8192 batch_type tokens normalization tokens accum_count 2 optim radam adam_beta2 0.9995 decay_method linear weight_decay 0.00001 max_grad_norm 5.0 lambda_vmf 0.2 generator_function continuous-linear loss nllvmf \end{lstlisting} \begin{lstlisting} softmax model: dropout 0.2 batch_size 1536 batch_type tokens accum_count 6 optim adam adam_beta2 0.999 decay_method noam max_grad_norm 25 \end{lstlisting} \newpage \section{Multilingual Basesystem Scores} \label{appendix:basesystem_scores} \begin{table}[htpb] \centering \begin{tabular}[]{|c|*{5}{r}|} \hline $\ell$ & \texttt{de} & \texttt{en} & \texttt{es} & \texttt{fr} & \texttt{it} \tabularnewline \hline \texttt{de} & & 30.6 & 21.4 & 23.0 & 18.5 \tabularnewline \texttt{en} & 25.9 & & 34.6 & 33.1 & 26.5 \tabularnewline \texttt{es} & 21.8 & 40.8 & & 29.8 & 25.1 \tabularnewline \texttt{fr} & 19.1 & 32.5 & 25.3 & & 22.8 \tabularnewline \texttt{it} & 18.9 & 30.2 & 25.7 & 26.7 & \tabularnewline \hline \end{tabular} \caption{Individual language pair test scores for the section \ref{evaluation:nmt_model} \emph{frozen softmax} basesystem. Lines represent the source language, while columns represent the target language.} \label{tab:frozen_softmax} \end{table} \section{Approach} We propose a three-step approach to the cross-lingual transfer learning task \begin{enumerate} \setlength{\itemsep}{0pt} \item train the cross-lingual word embeddings on monolingual data for each of the involved languages \item train the multilingual basesystem on parallel data for the set of base languages $\mathcal{L}_{\text{base}}$ \item add a new language $\lang_{\new} \notin \mathcal{L}_{\text{base}}$ to the system on monolingual data only \end{enumerate} Figure \ref{fig:clwe-architecture} describes the resulting NMT architecture.% \begin{figure}[tpb] \centering \includegraphics[width=0.96\linewidth]{figures/clwe-architecture} \caption{Our NMT architecture consists of a Transformer model with pre-trained cross-lingual word embeddings for embedding layers. The embedding vectors are obtained through alignment of monolingual \emph{fastText} embeddings for each language into a common embedding space.}% \label{fig:clwe-architecture} \end{figure} \subsection{Cross-Lingual Word Embeddings} \label{approach:cross_lingual_word_embeddings} In conventional training of a universal multilingual NMT system the $\lang_{\new}$ word vectors are randomly initialized. The model then learns in training to represent its words in a shared multilingual embedding space, by learning cross-lingual word correlations from the parallel data. In a monolingual data only setting we aim at achieving an equivalent result through cross-lingual word embeddings. These word embeddings are then integrated into our translation model by supplying in the form of pre-trained embeddings. For each language $\ell \in \mathcal{L}_{\text{base}} \cup \{\lang_{\new}\}$ we use pre-trained monolingual word embeddings learned with \emph{fastText} \citep{bojanowski-etal-2017-enriching}, which we then align into one common space through cross-lingual embedding alignment \citep{joulin-etal-2018-loss}. For a common alignment we choose to align into a \emph{single hub space} \citep[SHS][]{heyman-etal-2019-learning}, e.g.\ we pick one of our base languages as a \emph{pivot} and align each of the embedding spaces $E_{\ell}$ to $E_{\text{pivot}}$. \subsection{Adding a New Language} In this work we present three methods to add a new language to a multilingual basesystem. In the order of increasing level of supervision, they are as follows: \begin{enumerate} \setlength{\itemsep}{0pt} \item \emph{blind} decoding \item (denoising) autoencoding \item backtranslation \end{enumerate} The first experiment serves to answer the question of how well a pre-trained multilingual model can generalize to an unseen language, and can equally be applied on the source and on the target-side. The latter two experiments present two different methods for adaptation on $\lang_{\new}$ monolingual data, and focus on adding $\lang_{\new}$ on the target-side. \subsubsection{Blind Decoding}% \label{approach:blind_decoding} \begin{figure}[tpb] \centering \includegraphics[width=1.0\linewidth]{figures/blind-translation} \caption{In \emph{blind decoding} we simply decode from an unseen language $\lang_{\new}$ without prior exposure to $\lang_{\new}$ whatsoever. The cross-lingual word embeddings (CLWE) serve as lookup table for $\lang_{\new}$ words.}% \label{fig:blind_decoding} \end{figure} To provide an indication of how well the universal encoder generalizes to unseen languages we let our multilingual model decode from $\lang_{\new}$ sentences, without any sorts of prior exposure to $\lang_{\new}$. We call this method \emph{blind} decoding. As depicted in Figure~\ref{fig:blind_decoding} we therefore employ the cross-lingual embeddings to lookup the $\lang_{\new}$ word vectors and then simply decode from the resulting sequence. While we are also concerned about testing the NMT system ability to blindly decode \emph{to} a new language, we consider the target-side the less interesting side in this experiment, as the decoder couldn't possibly know the sentence level features, such as the $\lang_{\new}$ word order. We anticipated that the language production ability should be very limited, while the language comprehension ability should -- through the information supplied by the word embeddings -- only be constrained to a lesser extend. While the encoder may not know the syntax of an unseen language either, many syntactical concepts in language -- such as grammatical case, part-of-speech, grammatical genders, or tense -- are encoded at the word level\footnote{Take German for example, a noun would have different surface forms for different grammatical cases, which the fastText model should take into account and appropriately assign different word vectors.}. As such we hypothesize that the word vectors trained on the new language alone provide enough syntactic level information to perform the language comprehension task to a certain degree. \subsubsection{Learning Sentence-Level Features via Autoencoding}% \label{approach:autoencoding} As our first adaptation method towards $\lang_{\new}$ we propose two different ways of using our NMT model as an autoencoder, e.g. train to translate from $\lang_{\new}$ to $\lang_{\new}$. The primary objective in doing so is to train the decoder $\lang_{\new}$ language model while maintaining the cross-lingual signal received from the encoder. \paragraph{Denoising autoencoder}% \label{approach:denoising_autoencoder} For the first autoencoding approach we want to focus on teaching the model the target language syntax. To achieve this, we train the model to perform denoising autoencoding: the model gets noisy input sentences and is tasked with reconstructing the original, grammatically correct version of this sentence. One major aspect of language syntax which sets apart different languages from each other is the word order. By ``slightly'' shuffling the input sentence \citep{lample2017unsupervised}, e.g.\ displacing every word by up to $n$ positions from the original position, we can easily force the model to learn the correct word order. \paragraph{Plain autoencoder}% \label{approach:plain_autoencoder} As our second autoencoding\footnote{due to the differing nature of the task we consider auto\emph{decoding} might be a more appropriate name} method we try training raw $\lang_{\new}{\rightarrow}\lang_{\new}$ translation while freezing the encoder parameters. With this method we rely on the ability of our encoder to encode sentences from $\lang_{\new}$ in a suitable manner, as we directly take the encoder output for $\lang_{\new}$ sentences and learn to generate $\lang_{\new}$ sentences from it. In order for the model to not just learn to copy words from the input sentence to the output sentence, we rely on the encoder output to be language independent enough to not retain any word level information from the source sentence. This method thus tests the raw ability of our NMT system to learn the $\lang_{\new}$ language generation task conditioned on the encoder output $c$: $\mathbb{P}(Y_{\lang_{\new}} = y \mid H_{\text{enc}} = c)$. In worst case this method trains the language generation ability conditioned on white noise. \subsubsection{Backtranslation}% \label{approach:backtranslation} Lastly we would like to combine our model's ability to translate from $\lang_{\new}$ and its ability to adapt to $\lang_{\new}$. We therefore use the in unsupervised NMT commonly employed approach of training on \emph{backtranslated} data \citep{sennrich-etal-2016-improving}. Therefore one can use a joint NMT system translating between two languages in both directions to iteratively produce better translations, to then adapt the bootstrapped model on the improved synthetic generated data \citep{lample2017unsupervised}. In our approach to backtranslation -- exploiting the model's ability to perform blind decoding -- we choose a simplified approach: we perform one single round of backtranslation in which we use monolingual $\lang_{\new}$ data to \begin{enumerate*}[label=\arabic*)] \setlength{\itemsep}{0pt} \item blindly decode from $\lang_{\new}$ to each one of our base languages $\ell \in \mathcal{L}_{\text{base}}$ in order to generate synthetic parallel data, and then \item reversing the translation direction to train our model on this synthetic parallel data to translate from $\ell$ to $\lang_{\new}$. \end{enumerate*} \section{Multilingual Neural Machine Translation}% \label{sec:machine_translation} In training the multilingual NMT system we aim to estimate the probability $\mathbb{P}(Y_{\ell_{tgt}} = y \mid X_{\ell_{src}} = x)$ that the sentence $y$ in the target language $\ell_{tgt}$ is a suitable translation of the source sentence $x$ in the source language $\ell_{src}$. We describe the distribution of the sentences in different natural languages $\ell$ through random variables $X_{\ell}$, $Y_{\ell}$. A universal encoder maps the sentences from the different input distributions onto a single, shared latent distribution $H_{\text{enc}} = enc(X_{\ell})$. A decoder is then tasked to model the probability distribution from this latent variable: $\mathbb{P}(Y_{\ell_{tgt}} = y \mid H_{\text{enc}} = c)$. Identically to a regular bilingual NMT system, the multilingual translation system consists of a neural network, which, in a supervised setting, is trained to maximize the log-likelihood of a dataset of parallel sentences $\mathcal{D} = \{(x_1, y_1), \ldots{}, (x_n, y_n)\}$, where sentence pairs $(x_i, y_i)$ are translations of each other: \[ \min_{\vartheta \in \Theta}{ \left\{-\sum_{i=1}^{n}{ \log{ \mathbb{P}\left( X_{\ell_{tgt}^i} = y_i \mid X_{\ell_{src}^i} = x_i, \vartheta \right) } }\right\} } \]% Note that the only difference to bilingual translation is the nature of the input and output distribution. Thus, the only practical difference in the training a multilingual system is that instead of using a bilingual training corpus, $\mathcal{D}$ consists of a concatenation of several parallel corpora. It is a desirable quality for the universal encoder to learn a language independent latent representation. Such language independence may be expressed as a low variance $\mathbb{V}\{H_{\text{enc}}\}$ in the latent encoding space, as well as a high cross-lingual covariance $\mathbb{C}\{enc(X_{\ell}), enc(X_{\ell'})\}$. \section{Conclusion} In this work we have looked into adding a new language to a previously trained multilingual NMT system in an unsupervised fashion. We explored the possibility of reusing the existing latent sentence representation and adding a language by adapting the decoder on monolingual data only. As part of our approach we show the feasability of doing multilingual NMT with pre-trained cross-lingual word embeddings. By blindly decoding from Portuguese, e.g.\ translating without any prior exposure towards Portuguese aside from the cross-lingual word embeddings, using a basesystem containing multiple Romance languages we achieve scores of up to 36.4 BLEU for Portuguese-English, thereby demonstrating the universal encoder ability to generalize to an entirely unseen language. While this works significantly worse on a more distant language, this model -- which has never seen even a single sentence from any Slavic language -- is still able to achieve up to 13 BLEU for Russian-English. Furthermore, by applying blind decoding on the target-side we have been able to achieve up to 16.2 BLEU when decoding \emph{to} Portuguese. To this end we looked into the recently proposed continuous output representation approach. In an attempt to train the mapping from our sentence representation to a new target language we use our model as an autoencoder. By training to translate from Portuguese to Portuguese while freezing the encoder we have achieved up to 26 BLEU for English-Portuguese. Adding artificial noise to the input to let the model learn the correct word order gains us an additional 2 BLEU. Translating to Russian we achieve up to 8.7 BLEU for English-Russian. Lastly we have explored a more practical approach of learning the new language by training the system on backtranslated data. To this end we exploit our model's ability to produce high quality translations from an unseen source-side language to generate the synthetic data. The training on the synthetic data has yielded up to 34.6 BLEU, again on English-Portuguese, attaining near parity with a model trained on real bilingual data. Translating to Russian yields at most 13.9 BLEU for English-Russian. Considering the low English-Russian baseline score of 17.2 BLEU we suspect the overall low Russian scores to partly be an issue with the low quality word embedding alignment. \subsection{Future Work} In the future we would like to explore the question of how the composition and number of languages in the base system affects the ability to perform the transfer learning, and whether seeing a wide variety of different languages will help the translation system in generalizing to new languages -- especially more distant ones. In order to further improve the performance on source-side unseen languages we would like to explore various methods for the adaptation of the encoder. While the focus of this work lies mainly on adapting the decoder, an improvement on the source-side would especially benefit the backtranslation results for more distant languages. As an alternative to teaching the new language to the decoder via autoencoding, we would like to explore the possibility of using generative adversarial training on top of a translation system with a continuous output representation. \section{General Experimental Setup}% \label{sec:experimental_setup} \paragraph{Cross-lingual word embeddings} As the basis for all of our monolingual word embeddings we use the pre-trained \emph{fastText} models provided on the fastText website\footnote{\url{https://fasttext.cc/docs/en/crawl-vectors.html}}. These models provide 300-dimensional high-quality embeddings for full word units, accumulated on large web crawled monolingual text corpora. Using the pivot approach described in section \ref{approach:cross_lingual_word_embeddings} we align these embeddings into a common embedding space using direct supervised optimization on the RCSLS criterion \citep{joulin-etal-2018-loss} while using the bilingual dictionaries provided by the MUSE repository\footnote{\citep[\url{https://github.com/facebookresearch/MUSE}]{conneau2017word}}. In order to reduce the vocabulary size, we subsequently regenerate our vocabulary and the corresponding embedding vectors using only the words in our NMT training corpus. Alignment accuracies and vocabulary sizes are listed in Table \ref{tab:vocab_size}. \paragraph{Full word-units}% \label{par:full_word_units} \begin{table}[!tpb] \centering \begin{tabular}{c|rr} \hline lng & vocab size & CLWE acc \tabularnewline \hline en & 47,067 & 1.000 \tabularnewline de & 98,747 & 0.554 \tabularnewline es & 74,267 & 0.750 \tabularnewline fr & 60,416 & 0.732 \tabularnewline it & 74,962 & 0.696 \tabularnewline \hline total & 355,459 & \tabularnewline \hline pt & 67,237 & 0.734 \tabularnewline ru & 166,651 & 0.627 \tabularnewline \hline \end{tabular} \caption{The number of words in the vocabulary generated from the training corpus for each of the languages. \emph{total} represents the size of the shared vocabulary of the base model. The column \emph{CLWE acc} describes the nearest neighbour accuracies for the cross-lingual embedding alignments to $\ell_{\text{pivot}} = \mathit{en}$.} \label{tab:vocab_size} \end{table} While using a joint BPE lets us share information between vocabularies and significantly reduces the size of the multilingual vocabulary, for our approach we choose to work with full word units, since our preliminary experiments have shown them to outperform the BPE models when used in combination with cross-lingual embeddings. Furthermore, this gives us better compatibility with distant languages with separate alphabets and to avoids the problem of having to extend the learned BPE codes post-training when we add a new language to the model. To alleviate the OOV word problem we use \emph{fastText} as the basis for our monolingual word embeddings, which, by using subword level information, gives us the ability to map unseen words into the embedding space. For our multilingual vocabulary we merge our monolingual vocabularies and concatenate their embedding matrices, while dealing with duplicate words across different languages by encoding each word with a language specific prefix, e.g.\ we encode the English word \emph{bank} as \emph{\textbf{en@}bank}. This also allows us to easily match any token in the vocabulary to its corresponding language, which is not trivial in a model with BPE units that are shared across multiple languages. In inference we thus restrict the target vocabulary to the tokens matching the language we decode to, thereby forcing the model to only choose tokens from a single language in a situation where it would otherwise not do so, e.g.\ to decode to a yet entirely unseen language (see section \ref{sub:blind_decoding}). This filtering furthermore provides a speedup in inference, as well as an improvement by around +0.4 BLEU in our basesystem evaluation. \paragraph{Datasets}% \label{par:datasets} As our training, development and evaluation data sets we use multilingual transcriptions of TED talks \citep{cettoloEtAl:EAMT2012}. For our basesystems we include English, German, Spanish, French and Italian as the base languages. We train the basesystem on a total of 20 language pairs, and a parallel corpus size of $3,251,582$ sentences. For our transfer learning experiments we use monolingual TED data for Portuguese and Russian, and parallel test data for BLEU score evaluation. The monolingual data corpora contain $148,321$ sentences of Portuguese data and $187,843$ sentences of Russian data. For test and development data we use the IWSLT dev2010 and tst2010 data sets. All data is first tokenized and truecased with standard Moses tools. \paragraph{NMT model}% \label{evaluation:nmt_model}% For our NMT model we use a Transformer model \citep{vaswani2017} with relative position encodings \citep{shaw-etal-2018-self}. In accordance with our 300-dimensional fastText embeddings we use a model size of 300, and inner size of 1200, 6 attention heads and 6 layers. Our implementation is based on the repository provided by \citet{kumar2018}\footnote{\url{https://github.com/Sachin19/seq2seq-con}}, which in turn is based on \emph{OpenNMT-py} \citep{klein-etal-2017-opennmt}. We share the multilingual vocabulary, as well as the embedding parameters across the encoder and the decoder, and use tied output embeddings. Refer to Appendix \ref{sec:training_parameters} for the full set of training parameters. The evaluation scores for the multilingual basemodel, which we train on our available parallel data are listed in Table \ref{tab:basemodel_comparison}. The scores represent the average over all of the 20 language pairs. For the individual scores refer to Appendix B. The \emph{frozen softmax} model serves as the main model for our transfer learning experiments. It uses the cross-lingual embeddings in a pure lookup fashion, never updating the word vectors in NMT training. This freezing ensures that the word embeddings stay in the shared embedding space, and we can as such trivially add new words to our vocabulary and align new languages into the shared embedding space. The regular non-frozen softmax model serves for comparison with the frozen softmax model, as we do not know how well the pre-trained fastText embeddings fit the translation task. We initialize this model to the trained cross-lingual embeddings while in training adapting them to the training data. We can see that the frozen softmax model performs on par with its non-frozen counterpart, which suggests that the cross-lingual embeddings are very well suited for the translation task, despite them being trained on an unrelated task on purely monolingual data. \\ For the \emph{continuous output} model we employ the approach proposed by \citet{kumar2018}, which, instead of calculating a multinomial distribution over a closed vocabulary, optimizes the network output directly towards the semantic information encoded in our pre-trained word embeddings. This is ideal for our use case, since this is more suited towards extending the vocabulary. Furthermore it helps us deal with our large multilingual vocabulary, as computational complexity and memory complexity in a continuous output model are independent of its vocabulary size. While the model delivers inferior performance considering raw BLEU scores ony, training times amount to around one fifth of the training times for the softmax models. \\ Finally, in order to test the viability of our basesystem -- namely a full word-unit translation system with pre-trained word embeddings -- we also train a standard subword-unit translation system. This model uses BPE trained on the multilingual corpus, reducing the vocabulary size from the $355,459$ words in our full word-unit vocabulary to $36,150$ BPE units. \begin{table}[tpb] \centering \begin{tabular}[]{c|rr|rr} \toprule model & dev & $\Delta$ & test & $\Delta$ \tabularnewline \midrule BPE baseline & 26.10 & & 27.73 & \tabularnewline \hline softmax & 24.56 & -1.54 & 26.65 & -1.08 \tabularnewline frozen softmax & 24.96 & -1.14 & 26.60 & -1.13 \tabularnewline continuous & 22.27 & -3.83 & 24.11 & -3.62 \tabularnewline \bottomrule \end{tabular} \caption{Comparison of average BLEU scores for the different variants of the multilingual base system} \label{tab:basemodel_comparison} \end{table} \section{Adding a New Language}% \label{sec:language_addition} \begin{table*}[!htpb] \centering \begin{tabular}{c|rrrrr|rr||rr} \toprule source-side method & pt-de & pt-en & pt-es & pt-fr & pt-it & ru-de & ru-en & $\varnothing$\,pt & $\varnothing$\,ru \tabularnewline \midrule blind decoding & 20.6 & 36.4 & 30.7 & 29.3 & 24.4 & 11.1 & 12.8 & 28.3 & 11.9 \tabularnewline supervised & 22.2 & 39.7 & 33.0 & 31.9 & 26.6 & 15.2 & 20.9 & 30.7 & 18.1 \tabularnewline \toprule target-side method & de-pt & en-pt & es-pt & fr-pt & it-pt & de-ru & en-ru & $\varnothing$\,pt & $\varnothing$\,ru \tabularnewline \midrule blind decoding & 8.4 & 16.2 & 13.3 & 11.6 & 10.7 & 1.1 & 1.7 & 12.0 & 1.4 \tabularnewline autoencoder & 17.0 & 28.1 & 27.1 & 21.5 & 20.8 & 8.1 & 8.7 & 22.9 & 8.4 \tabularnewline backtranslation & 21.3 & 34.6 & 32.3 & 26.4 & 25.4 & 13.6 & 13.9 & 28.0 & 13.8 \tabularnewline supervised & 21.9 & 35.8 & 32.9 & 27.1 & 26.2 & 15.1 & 17.2 & 28.8 & 16.2 \tabularnewline \bottomrule \end{tabular} \caption{BLEU scores for decoding from (top) and to (bottom) Portuguese and Russian as the new language, with and without adaptation through various methods.} \label{tab:newlang_results} \end{table*} In the following we present our results for extending the multilingual basesystem by Portuguese and Russian. Unless stated otherwise, we evaluate our methods on the section \ref{evaluation:nmt_model} \emph{frozen softmax} model. For our adaptation methods we select the best performing model based on the development data BLEU scores. \subsection{Blind Decoding}% \label{sub:blind_decoding} As our first experiment we investigate decoding to $\lang_{\new}$ without any sort of additional training or adaptation. We therefore simply swap out the source or target-side embeddings and decode from or to $\lang_{\new}$. As seen in Table \ref{tab:newlang_results} we can achieve BLEU scores of up to 36.4 with Portuguese as the source language. While the average of 28.3 BLEU on the test set is significantly lower, it is still a considerably reasonable score, considering the model has never seen even a single Portuguese sentence. On a more distant source language such as Russian, we achieve much lower scores. Despite of the fact that the basesystem has never even seen a single sentence from any Slavic language the results are, however, still intelligible, achieving scores of up to 12.8 BLEU. When decoding with $\lang_{\new}$ on the target-side, to force the model to decode to $\lang_{\new}$ as opposed to any $\ell \in \mathcal{L}_{\text{base}}$ we need to filter out any target vocabulary words not associated with $\lang_{\new}$. Initially, using our frozen softmax model to decode to Portuguese results in an average BLEU score of 3.0 BLEU. For the continuous output model this amounts to 6.2 BLEU. We suspect the main cause for the inferior softmax performance to be the missing bias for the new language, which the continuous output system does not require. In fact, the models often get stuck in a decoding loop, which we combat by adding a postprocessing step remove the resulting duplicate words. For both models this doubles the BLEU score, achieving up to even 16.2 BLEU on English-Portuguese. \subsection{(Denoising) Autoencoder}% \label{sub:denoising_autoencoder} For our antoencoding methods we adapt on monolingual TED data using unchanged training parameters from the basesystem training. When training to denoise via word order shuffling, we found -- in accordance with \citet{lample2017unsupervised} -- that displacing every word by up to $n = 3$ positions yields the best results. We furthermore experiment with word dropout as additional noise, however, we did not observe any noticeable improvement over pure reordering noise. Table \ref{tab:adaptation_comparison} shows the results for afterwards decoding to Portuguese and to Russian. The denoising autoencoding results in slightly lower scores than the frozen encoder variant. While the resulting scores clearly demonstrate the model ability to adapt to the new language -- even without noisy input -- we find the Russian scores to be disappointingly low. Using both methods in conjunction with our postprocessing step (see section \ref{sub:blind_decoding}), we bring the translation to Russian up to a maximum of 8.7 BLEU and translation to Portuguese up to a maximum of 28.1 BLEU. Table \ref{tab:newlang_results} shows the resulting BLEU scores for the individual language pairs. The Portuguese and Russian softmax models both train for 1,000 iterations, completing after roughly 60 minutes on a \emph{GTX 1080 Ti} GPU. We believe the significant improvement for the frozen encoder approach when adding noise to be an indication that the encoder representation still retains certain language specific word-level information. In this case the noiseless model might find it easier to reconstruct the original sentence, thus learning less about the new language syntax in the process. While this is an undesirable quality, this is to be expected considering just the fact that the encoder output sequence is equal in length to the input sentence. \begin{table}[!pb] \centering \begin{tabular}{lrr} \toprule method & $\varnothing$\,pt & $\varnothing$\,ru \tabularnewline \midrule denoising autoencoder & 20.8 & 6.5 \tabularnewline frozen encoder & 21.1 & 6.6 \tabularnewline + denoise & 22.9 & 7.9 \tabularnewline ~~~+ postprocessing & 22.9 & 8.4 \tabularnewline \midrule backtranslation & 27.4 & 13.2 \tabularnewline + frozen encoder & 28.0 & 13.8 \tabularnewline supervised baseline & 28.8 & 16.2 \tabularnewline \bottomrule \end{tabular} \caption{A comparison of average test scores for different variations of the autoencoder methods (top), as well as the backtranslation method (bottom).} \label{tab:adaptation_comparison} \end{table} \subsection{Backtranslation}% \label{sub:backtranslation} Without any additional steps, our blind decoding approach has already enabled our basesystem to produce translations of up to 36.4 BLEU from Portuguese. In our final experiment we exploit this for backtranslation to benefit the more difficult direction. We train the Portuguese and the Russian model on backtranslated data for 6,000 and 10,000 iterations respectively, again with unchanged training parameters from basesystem training. Table \ref{tab:newlang_results} shows the translation scores after training on backtranslated data for each of the language pairs. Translation scores reach up to 34.6 BLEU, namely on English-Portuguese. From the comparison in Table \ref{tab:adaptation_comparison} we can also see that the Portuguese backtranslation scores are almost on par with our supervised model trained on bilingual data, falling short by just 0.8 BLEU. Again, freezing the encoder in training results in improved translation, albeit to a lesser extent than for the autoencoding approach. We note that training the Russian system on $en{\rightarrow}ru$ data only also improves the performance for $de{\rightarrow}ru$, in our experiments sometimes even outperforming the language pair it is trained on. We see this as an indication that this training mainly affects the decoder language model for Russian. This furthermore means that the decoder, when decoding to Russian, is able to use a similar amount of information from the encoder representation of the source sentence. This either means that the encoder representation of English and German are very similar in quality, being able to extract the same amount of meaning. Alternatively it means that the decoder does not learn to use the full amount of information encoded into the representation of the English source sentence, meaning the decoder is lacking in translation adequacy while leaning towards better fluency. \section{Introduction} Neural machine translation (NMT) systems consist of an encoder, which encodes an input sentence into a latent numerical sentence representation space, and a decoder, which generates the target sentence from this representation \citep{cho-etal-2014-learning,bahdanau14}. While under favourable circumstances neural networks bring significant improvements to translation performance, a major problem with them, however, is that they are extremely data hungry. While for the most common language pairs large amounts of parallel data might be available, for most language pairs parallel data is extremely scarce. As such one of the goals of multilingual NMT is to significantly reduce the amount of parallel data required for each given individual language pair. Universal multilingual NMT \citep{johnson-etal-2017-googles,ha2016} employs a universal encoder so that the source languages share one single set of parameters. Ideally this universal encoder would learn a language independent representation of the input sentences, e.g.\ learn to map semantically similar sentences onto similar neural sentence representations -- even across different languages. Ongoing research in the field of zero-shot translation provided evidence that multilingual NMT models exhibit this property up to a certain extent, and that enforcing the similarity between sentence representations across different languages in turn also improves the zero-shot capabilities \citep{pham-etal-2019-improving}. On the other hand, cross-lingual transfer learning research in NMT further showed that such multilingual systems can rapidly be extended to new languages on very little data \citep{neubig-hu-2018-rapid}. \citet{neubig-hu-2018-rapid} furthermore show that going as far as training a basesystem on 58 source languages immensely helps the universal encoder in subsequently generalizing to new source languages in a supervised setting. In this work we take this approach one step further and investigate the ability to translate to a new language with no parallel data for this language. While integrating cross-lingual word embeddings into the model we provide two contributions in the field of multilingual NMT: \begin{enumerate} \setlength{\itemsep}{0pt} \item To explore the generalization-ability of the universal encoder we translate from a yet entirely unseen language to a known language. \item Inspired by the recent advancements in unsupervised NMT we adapt the universal decoder to a new language through \begin{enumerate}[label=\emph{\alph*)}] \item using the NMT model as autoencoder \item backtranslation \end{enumerate} \end{enumerate} Using a German-English-Spanish-French-Italian multilingual basesystem we perform experiments in transfer learning to translate to and from Portuguese and Russian. First, by simply decoding from Portuguese and Russian while using the cross-lingual embeddings for word lookup we demonstrate the effectiveness of applying the universal encoder to an unseen language, achieving reasonable $36.4$ BLEU and $12.8$ BLEU scores for Portuguese-English and Russian-English respectively. We discovered that, when using the multilingual model as autoencoder, we can successfully adapt to the new language even without training to denoise -- simply by freezing the encoder in training. Finally, we devise a method to jump-start the iterative backtranslation process oftentimes employed in unsupervised NMT, by exploiting model transfer learning ability and generate data by translating from an unseen language. Our models trained on the synthetic parallel data attain translation performance close to what we achieve through supervised adaptation on real parallel data, falling short by an average of 0.8 BLEU for translation to Portuguese. As our final contribution we experiment on continuous output NMT, which, while underperforming the softmax models in terms of BLEU scores, attains vastly superior performance in terms of training times as well as memory complexity. \section{Related Work} \citet{qi-etal-2018-pre} looked into the effectiveness of using pre-trained embeddings for NMT, asking whether the alignment of the embedding vectors into a shared embedding space helps in NMT and coming to the conclusion that it is helpful in a multilingual setting. Similarly, \citet{sen-etal-2019-multilingual} carried out unsupervised multilingual NMT with the utilization of cross-lingual word embeddings. While their approach is similar to ours, their focus lies in improving unsupervised NMT, while we mainly look into multilingual transfer learning. \citet{neubig-hu-2018-rapid} concerned about the possibility of rapidly extending a multilingual NMT model by an unseen low-resource language. They compare between bilingual training, multilingual training alongside a similar source language and multilingual pre-training with as many languages as possible. They came to the conclusion that pre-training in a highly multilingual setting -- this in their case is a system with 58 source languages -- significantly improves the ability to learn the low-resourced language. Similar to our findings, they also achieved significant performance on a yet entirely unseen language. They, however, do not use cross-lingual embeddings, but rely on bilingual data to teach their model the cross-lingual word correlations. \citet{kim-etal-2019-effective} conducted unsupervised cross-lingual transfer learning in NMT, transferring the parameters learned on a high resource language pair and to a new source language. Similar to our work they therefore employed cross-lingual word embeddings, aligning the new language embeddings to the parent model source embeddings. Their work focuses on adaptation on the source-side, furthermore in a bilingual setting. \citet{escolano-etal-2019-bilingual} devised an approach to multilingual NMT with independent encoders and decoders that allows for zero-shot translation, as well as the addition of new languages. \citet{siddhant-etal-2020-leveraging} looked into leveraging monolingual data for multilingual NMT. Amongst other things they extended the model by a new language through masked denoising autoencoding. While they did not perform backtranslation they suggest that their scenario presents a promising avenue for jump-starting the backtranslation process, which our work demonstrates to indeed be the case. Our work is also closely related to unsupervised NMT \citep{lample2017unsupervised,lample-etal-2018-phrase,artetxe2017,artetxe-etal-2019-effective}. \citet{lample2017unsupervised} trained an unsupervised NMT system which translates between two languages $\ell_1$ and $\ell_2$, while employing universal encoder and decoder for the simultaneous translation in both directions. They iteratively trained the NMT model to generate $\ell_1$ and $\ell_2$ sentences through denoising autoencoding, while simultaneously training to maximize the similarity between the encoder sentence representation for $\ell_1$ and $\ell_2$ sentences. Through unsupervised means they thus induce a shared sentence representation, essentially bootstrapping a multilingual NMT system from monolingual data. We, on the other hand, consider a more realistic scenario where we have enough data from high resource language pairs to train a supervised multilingual NMT system, on which we then perform unsupervised transfer learning. \section{Acknowledgement} The projects on which this paper is based were funded by the Federal Ministry of Education and Research (BMBF) of Germany under the numbers 01IS18040A. The authors are responsible for the content of this publication.
{'timestamp': '2021-03-12T02:24:58', 'yymm': '2103', 'arxiv_id': '2103.06689', 'language': 'en', 'url': 'https://arxiv.org/abs/2103.06689'}
arxiv
\section{INTRODUCTION} Human is still required in the control loop of the automated driving system. According to the European Road Transport Research Advisory Council, highly and fully autonomous vehicles (SAE level 4 and 5) are not likely to occur by 2030, and conditionally autonomous vehicles (SAE level 3) were occurred since 2018 and will be developed entirely by 2024 \cite{dokic2015european}. Driver-vehicle interaction plays a very significant role in level 3 vehicles as the driving task is both assigned to driver and vehicle. In this context, human drivers are retained in the control loop to monitor the system and prepare for takeover requests initiated by the system, such as Level 2 or Level 3 automation system \cite{sae2014taxonomy}. They can also help the system deal with ethical troubles and legislation requirements\cite{bonnefon2016,nhtsa}. When an automated driving system failure occurs according to various causes including sensor failures or emergency traffic scenarios cannot be handled, drivers will be required to take over the control of the vehicle \cite{korber2018}. As a result, how to ensure a smooth and safe control transition from the system to the human driver at different types of system failures is the key to safety assurance of level 3 vehicles. Takeover requests raised lots of attention in recent years, including effects on drivers’ situation awareness \cite{vlakveld2018}, drivers’ responsive times \cite{gold} and effects of warnings \cite{lylykangas2016}. Existing studies have been conducted to evaluate and improve the transition of control from the automation system to the human driver \cite{zeeb2016}. A fair amount of studies is conducted about improving the human-machine interface to enhance attention allocation before control transition and reduce reaction time \cite{van2017priming}. However, the precise evaluation of a good transition should be higher safety performance throughout the process, instead of shorter reaction time \cite{favaro2017}. Furthermore, acceptance and trust of the transition mechanism should also be a crucial issue. An untrusted and not user-friendly system may lead to improper control transitions, e.g. early hand over before requested \cite{umeno2018}. Instead of a complete transition of control, shared control strategies combine inputs of both the human driver and the automation driving system \cite{bhardwaj2020}. One type of the shared control strategy directly blends the human input and autonomy command through an arbitrator. Drivers can feel the involvement of autonomy through observing the vehicle state after the mixed command takes effect \cite{anderson2011design}. Most studies applied the shared control strategy to improve human-vehicle interaction of Advanced Driving Assistant Systems (ADAS) \cite{nguyen2017}. Various shared control strategies, such as fictive nonlinear models, fuzzy logic models, and haptic adaptive models based on Model Predictive Control (MPC) controllers were developed \cite{nguyen2018}. These strategies are proven to improve the driving performances in terms of lane-keeping and risk avoidance through both driving simulator studies and field tests. Apart from control models to optimize shared control's driving performance, an expert driving model or reference driving model is also applied to develop the shared control strategy \cite{sekimoto}. Such methods, often called expert shared control, develop expert driving models from naturalistic driving data to obtain both control efficiency and high safety performance. Compared with other control strategies, the expert shared control strategy can have better performance for high-risk vehicle interactions. Although most studies are conducted at the population level without considering individual differences, the shared control strategy is found to be able to improve driving performance with less visual workload and response time to driving from secondary tasks \cite{griffiths2005}. Moreover, previous studies have proved that the shared control model imposes positive effects on many aspects, including driving safety improvement and user comfort \cite{sentouh2019}. Therefore, the objectives of this paper are: 1) develop a takeover strategy incorporating shared control, 2) evaluate the proposed shared control takeover strategy at driver’s individual level. The driving data of an actual expert driver who can accomplish the driving task with smooth vehicle motion and high safety performance was obtained. The expert shared control strategy was then developed and embedded in a "human-in-the-loop" driving simulator by combining the expert driver model with the human driver's control. A simulator experiment was then conducted on 32 participants to evaluate safety performance during the takeover process. Individual driver's mental workload, reaction time and safety performance are then evaluated. \section{EXPERT SHARED CONTROL TAKEOVER} This study obtains a more realistic driving experience of Level 3 vehicles and an expert shared control strategy through replacing the autonomous driving model into an expert driving model. An experienced driver with more than ten years of driving experience was required to drive in compliance with traffic regulations, follow the lead vehicle at a steady and safe distance. The experienced driver was needed to drive several times, and the drive that well blended the safety of autonomous driving and the comfort of manual driving was selected. Gas pedal force, brake pedal force, and steering wheel angle were recorded at 20Hz. The expert driver model determines the steering wheel angle and pedal force to track the desired path recorded by the experienced driver. Euclidean distance between the real-time and recorded data in time and space get the minimal value, the behavior data at that recorded time point was chosen as the expert input at that moment, as shown in Fig.~\ref{fig_sharedcontrol}. Through incorporating shared control in a semi-autonomous vehicle, a shared control takeover strategy can be developed. When the subject vehicle is in automated driving, the vehicle runs totally depending on the expert model. When the vehicle requires the driver to take over the control and the automation is off, the control authority is completely shifted to the driver. When the automation did not completely quit, the vehicle is controlled by the driver and automation with the respective weights (shared ratio). The shared ratio was set as 0.5, indicating the control authority is fixedly divided by driver and automation to avoid the interactive effect. The blended or independent inputs are then transferred to the simulation software through a specific Application Programming Interface (API). \begin{figure}[t] \flushleft \includegraphics[width=3.2in]{img/shared.jpg} \caption{Share control strategy.} \label{fig_sharedcontrol} \end{figure} \section{SIMULATOR EXPERIMENT} \subsection{Participants} A total of 32 participants were recruited, 22 males and 10 females. Their ages ranged from 22 to 34 years old with an average age of 25.4. The driving experience of the participants ranges from 1-11 years, with an average experience of 3.4 years. Each participant held a valid driving license. After the experiment, a cash reimbursement of 150CNY (USD\$22.00) was offered to each participant. \subsection{Apparatus and Systems} The road driving scenarios were developed using SCANeR™ studio software and projected onto three screens (23.8-inch, 34-inch curved, 23.8-inch from left to right) located 0.5m in front of the participant. The field of view was approximately 270 degrees (as shown in Fig.~\ref{fig_simulator}). The steering wheel, accelerator, and brake pedals used in this experiment were Logitech G29 Racing Wheel and Pedals. The 34-inch curved display (R=150cm) in the middle presented the central front view. In addition, two additional displays (27-inch) were used as the instrument board and central dashboard display. A 10-inch central dashboard display was employed to indicate different system status: Automation On, Shared Driving On, Automation Off, and Manual Driving On, Automation Off, and Shared Driving On. The activation of different statuses was indicated by different colors and accompanied by beeps or corresponding verbal guidance. As shown in Fig.~\ref{fig_tor}(a) and~\ref{fig_tor}(b), blue indicates the activation of autonomous driving while amber indicates shared driving. When the system was switched into the two status, a pleasant tune occurred with the texts to hint at drivers. As shown in Fig.~\ref{fig_tor}(c) and~\ref{fig_tor}(d), the TOR interface was accompanied by beeps and verbal guidance. ‘Autonomous driving ends. Please resume full control of the vehicle’ indicated the complete exit of autonomous driving status and alerted the driver to take full control as soon as possible. ‘Shared driving is activated. Please resume control of the vehicle’s alerted the driver to take control and cooperative with the vehicle in time for safe driving. \begin{figure}[t] \flushleft \includegraphics[width=3.2in]{img/simulator.jpg} \caption{Driving simulator.} \label{fig_simulator} \end{figure} \begin{figure}[t] \flushleft \includegraphics[width=3.2in]{img/torrequest.jpg} \caption{Autonomous driving system and takeover request.} \label{fig_tor} \end{figure} \subsection{Experimental Design} The designed driving environment was an urban road with two lanes of traffic in each direction in the misty daytime (Fig.~\ref{fig_environment}). Surrounding vehicles were programmed to drive at 30-50 km/h. The lead vehicle employed an automated driving algorithm, which enabled sign and emergency observing. Participants were instructed to follow a lead vehicle at a safe distance. At the beginning of each drive, autonomous driving was performed, and the driver should monitor the surrounding environment for safety. During the driving process, the autonomous driving system would fail and exit at specific positions. Then a safety-critical event occurred not far ahead. Drivers needed to take control in time to avoid a potential forward collision. Each participant had five drives. As is shown in Fig.~\ref{fig_route}, the driving routes were shown in lines with an arrow. At the beginning of each drive, the automation was on. TOR occurred at the red points, and the system state was switched to manual/shared driving. When drivers took over the vehicle to avoided the collision, the system would reenter the autonomous driving again after a steadily car-following status is observed. The positions of blue points were not fixed but based on the judgment of the vehicle operating status. Each drive included two TOR events. The differences between the two driving routes in Fig.~\ref{fig_route}(a) and Fig.~\ref{fig_route}(b) were the TOR events' positions. Driving routes in five drives were chosen at a random order to prevent drivers from forecasting emergency. \begin{figure}[t] \flushleft \includegraphics[width=2.8in]{img/environment.jpg} \caption{Driving environment.} \label{fig_environment} \end{figure} \begin{figure}[t] \flushleft \includegraphics[width=2.8in]{img/route.jpg} \caption{Designed driving routes.} \label{fig_route} \end{figure} Two kinds of disengagement events were designed in the experiment. The first type is a sudden disengagement due to non-traffic related reasons (e.g. sensor failure). The failure triggered TOR immediately. To assess driver’s collision avoidance ability after takeover, a sudden brake of the lead vehicle at –9.8 m/$s^2$ would be occurred 1s after TOR. The second TOR was due to traffic-related reasons, as TOR and the sudden brake happened simultaneously because the situation exceeded the system capacity. In this study, the first type of disengagement is called “ordinary scenario”, and the second type is called “urgent scenario”. \begin{figure}[t] \flushleft \includegraphics[width=3.2in]{img/tordescriptions.jpg} \caption{Descriptions of takeover requests.} \label{fig_description} \end{figure} Thirty-two participants were divided into two groups, equally and randomly. T-tests of age, gender, and driving experience have been conducted. There were no significant differences between the two groups. The participants were informed to drive as normal in daily life and comply with traffic rules as in real-driving situations. Before the experiment, each driver had about a 5-minute trial session to get familiar with the driving simulator operations and the autonomous driving state. During each drive of the formal experiment, each participant drove five times with two TORs. Different scenarios were presented in a counterbalanced order for two groups to reduce experiment order effects such as fatigue or learning (Fig.~\ref{fig_process}). Each drive lasted about 4 min. After each drive, participants filled in a NASA Task Load Index (TLX) questionnaire to rate their subjective workload during the driving process (Hart and Staveland, 1988). \begin{figure}[t] \flushleft \includegraphics[width=3.2in]{img/process.jpg} \caption{Experiment process.} \label{fig_process} \end{figure} \subsection{Measurements} In this study, the experiment was designed as a 2 (urgent/ordinary scenarios)×2 (takeover strategies) within-subjects repeated measures. Dependent variables included both objective (i.e., reaction time) and subjective measures (i.e., subjective ratings of workload). Detailed definitions were as follows: 1) Reaction time (RT): time is taken to press the brake pedal after TOR was prompted, as shown in Fig.~\ref{fig_breakreaction}. 2) Safety indicators: Three safety indicators are computed according to the relative vehicle movements of the subject and lead vehicles. Minimal time to Collision (minTTC) is computed as the minimal value of time to a potential collision between two vehicles after TOR, as shown in Fig.~\ref{fig_ttc}. Time Exposed TTC (TET) were derived from TTC to evaluate the dynamic potential risk. It is computed as the duration of TTC smaller than a certain TTC threshold, as shown in Fig.~\ref{fig_ttc}. Time Exposed TTC (TET) were derived from TTC to evaluate the dynamic potential risk. It is computed as the duration of TTC smaller than a certain TTC threshold, as shown in Figure 8b. Similarly, Time Integrated TTC (TIT) was derived from TTC to evaluate the integration of TTC smaller than a certain threshold. 3) Subjective ratings of workload: NASA-TLX requires participants to rate the demands in mind, physics, time, frustration, effort, and performance. The overall workload index is computed by averaging the scores of six dimensions in this study. \begin{figure}[t] \flushleft \includegraphics[width=3.2in]{img/brakereaction.jpg} \caption{Computation of brake reaction time.} \label{fig_breakreaction} \end{figure} \begin{figure}[t] \flushleft \includegraphics[width=3.2in]{img/ttc.jpg} \caption{Computation of minimal TTC.} \label{fig_ttc} \end{figure} \section{RESULTS AND DISCUSSIONS} \subsection{Safety performance of shared control takeovers} Fig.~\ref{fig_ordinary} and Fig.~\ref{fig_urgent} summarized distributions of safety indicators under ordinary and urgent scenarios, respectively. According to Figures 10a and 11a, the minTTC of shared control takeover was larger than manual driving under both kinds of scenarios. The decrease was significant under 5\% significance level (p=0.024 under ordinary scenarios and p=0.044 under urgent scenarios). The results indicated that the proposed shared control take over strategy effectively improves safety performance by preventing severe conflict. Significant TET and TIT reduction between shared control and manual takeover were not observed at 5\% level. However, the share control takeover's effectiveness under urgent scenarios is found to be largely affected by individual differences. TET and TIT's interquartile ranges were larger in shared driving than that in manual driving compared with ordinary scenarios. To further evaluate the individual differences, individual drivers' vehicle movements and safety performances were extracted and analyzed. \subsection{Individual differences on takeover reactions} Fig.~\ref{fig_individual} shows the brake reaction time of each participant mainly affected by individual differences. Four vertical axles represent reaction times under four driving scenarios. In general, brake reaction time is longer in shared control takeover compared to manual takeover. This can be explained as drivers may delay their braking response with a shared driving system's assistance. Therefore, further evaluation of individual differences is analyzed by comparing each driver's behavior with and without shared control takeover. Firstly, Fig.~\ref{fig_classifybyttc} shows drivers classified by minTTC differences between shared control takeover and manual takeover. Red lines represent drivers with smaller minTTC (worse safety performance) in shared control takeover, while blue lines represent drivers with larger minTTC (better safety performance) in shared control takeover. \begin{figure}[t] \flushleft \includegraphics[width=3.2in]{img/ordinary.jpg} \caption{Safety performance of shared and manual takeover in ordinary scenario.} \label{fig_ordinary} \end{figure} \begin{figure}[t] \flushleft \includegraphics[width=3.2in]{img/urgent.jpg} \caption{Safety performance of shared and manual takeover in urgent scenario.} \label{fig_urgent} \end{figure} From Fig.13a, it can be found that the shared control takeover can reduce individual differences under ordinary scenarios. A relatively safe and appropriate minimal TTC can be achieved when driver needed to take over half control of the vehicle. However, the shared control takeover didn't work for everyone when it comes to urgent situations. It is noteworthy that several drivers were involved in crashes when the shared control takeover was introduced, as shown in Fig.13b. \begin{figure}[t] \flushleft \includegraphics[width=3.2in]{img/individual.jpg} \caption{Individual brake reaction time under tested scenarios.} \label{fig_individual} \end{figure} \begin{figure}[t] \flushleft \includegraphics[width=3.2in]{img/classbyttc.jpg} \caption{Drivers classified by different impacts on minTTC.} \label{fig_classifybyttc} \end{figure} To further analyze drivers’ individual differences under urgent takeover scenarios. Drivers are divided into several groups by comparing the differences between manual takeover and shared control takeover, as summarized in Tab.~\ref{tab:table1}. For each driver, minTTC difference was calculated by subtracting minimal TTC under manual takeover from that under shared control takeover. The positive values indicate that the safety performance under shared control takeover is better than that under manual takeover, and vice versa. Drivers were then divided into three groups taking -0.2 and 0.2 seconds of minTTC difference as critical thresholds\ cite. The first group is performed better with manual takeover, the 2nd group performed similar under two takeover strategies, and the 3rd group performed better after shared control strategy. T-tests were conducted significant differences are marked as asterisks (*, between 1$^st$ and 2$^nd$ groups) and pounds (\#, between 2$^nd$ and 3$^rd$ groups) at 5\% significant level. As shown in Tab.1, under urgent takeover scenarios, significantly differences are observed from reaction times and self-reported workloads. The driver with worse performance after shared control takeover reports significantly higher mental workload. Moreover, although the driver reacted quicker than in manual takeover, the deceleration was not efficient and thus result in a worse safety performance. On the other hand, drivers with higher performance after shared control takeover reports significantly lower mental workload and smaller reaction time. Last but not least, all the females were in this group, indicating the shared control takeover was more suitable for female drivers. \begin{table}[] \caption{Group differences under urgent takeover scenarios} \label{tab:table1} \begin{tabular}{@{}lcccl@{}} \toprule \multirow{2}{*}{} & \multicolumn{3}{c}{Minimal TTC difference} & \\ \cmidrule(l){2-5} & \textless{}-0.2s & -0.2$\sim$0.2s & \textgreater{}0.2s & \\ \cmidrule(r){1-1} No.of drivers & 1 & 5 & 26 & \\ Reaction time difference*\# & -0.8 & 0.25 (0.86) & 0.07 (0.50) & \\ Workload difference*\# & 18.67 & 6.13 (9.61) & 0.19 (13.18) & \\ Age & 22 & 27.50 (4.36) & 25.42 (2.77) & \\ Driving Experience & 3 & 6.25 (3.40) & 4.23 (2.39) & \\ Gender\# & M & 5M & 16M 10F & \\ \bottomrule \end{tabular} \end{table} illustrates the existence of individual differences. The reaction time under urgent situations were scattered, ranging from 0 to 3.3 seconds. It is hard to observe a common trend that can summarize the effect of shared control takeover. \begin{figure}[t] \flushleft \includegraphics[width=3.2in]{img/square.PNG} \caption{Drivers classified by different impacts on minTTC.} \label{fig_square} \end{figure} Furthermore, the consistency between ordinary and urgent scenarios in the aspects of minimal TTC difference, reaction time and workload. As shown in Fig.~\ref{fig_square},the squares were painted from shallow to dark blue depending on the increase of driver numbers in corresponding group. It can be found that the minimal TTC difference and workload difference showed a common tendency in the two scenarios. Most drivers can increase their minimal TTC more than 0.2 seconds under the shared control takeover. Also, driver workload was more affected by the takeover strategy instead of the scenario urgency. Figures 14d-f demonstrated the relationship between minimal TTC difference, reaction time and workload under urgent scenario. It is found that the decrease of driver workload was along with the increase of minimal TTC. The minimal TTC was extended among most drivers under urgent scenarios, but their reaction time was scattered. Also, there was no obvious association between workload and reaction time. \section{CONCLUSIONS} In this paper, an expert shared control takeover strategy of semi-autonomous vehicle is proposed and evaluated at individual level. The strategy aimed to reduce driver’s mental workload and improving the safety performance through a smooth control transition between automation driving system to the human driver. A “human-in-the-loop” driving simulator study is conducted through embedding the shared control takeover strategy based on co-simulation of SCANeR and Matlab Simulink. Experimental results of 32 drivers showed shared control takeover strategy can improve safety performance at group level. This is consistent with many previous studies of shared control driving and shared control takeover. Further evaluation on individual difference have found that the shared control strategy can achieve a unified better safety performance at non-traffic related disengagements. For more urgent disengagements, shared control strategy enlarges individual differences. The results also showed that worse safety performance is related with higher mental workloads caused by shared control strategy rather than disengagement types. This study confirmed the effectiveness of the proposed expert shared control strategy on improving safety performance. Controlling driver's mental overload through instructions and training are also necessary in further studies. \addtolength{\textheight}{-12cm} \bibliographystyle{IEEEtran}
{'timestamp': '2021-03-12T02:25:15', 'yymm': '2103', 'arxiv_id': '2103.06700', 'language': 'en', 'url': 'https://arxiv.org/abs/2103.06700'}
arxiv
\section{\textbf{Introduction}} \label{Section: Introduction} The wide penetration and overwhelming acceptance of internet in Nigeria and across the globe has facilitated learning, business and other activities that are internet enabled. The introduction of internet technology has impacted positively on everyday activities in the various sectors of human endeavours. However, this technological advancement has equally resulted to increased cyber threats, vulnerabilities and risks. In Nigeria, for instance, internet has made it possible the perpetration of different forms of cyber-crime on daily basis ranging from fraudulent electronic mails, pornography, identity theft, hacking, cyber harassment, spamming, Automated Teller Machine spoofing, piracy and phishing~\cite{omodunbi2016cybercrimes}. \\ According to~\cite{adesina2017cybercrime}, in the year 2016, the personal information of millions of people were stolen through cyber-crime, which comprises of 40 million people in United States of America (USA), 54 million in Turkey, 20 million in Korea, 16 million in Germany and over 20 million in China.\\ Moreover, these risks associated with this ugly phenomenon are likely to be more in developing countries such as Nigeria. In Nigeria, cyber-attacks are committed by people of different age ranges, both old and young are involved in this act though majority are young ones~\cite{hassan2012cybercrime}. The cyber space is the main channel through which financial fraud is being perpetrated in the Nigerian banking industry~\cite{ibrahimimpact}. This therefore calls for concerted effort to curb the menace of cyber-crime activities on individuals, organisations and governments. \\ One of the ways through which cyber-crime can be mitigated is by improving the cyber-hygiene culture of the internet users. Cyber-hygiene here refers to those cyber-security attitudes and behaviours which internet users are expected to adopt to ensure the safety and integrity of their data and also their devices in the case of cyber-attacks by the internet fraudsters~\cite{vishwanath2020cyber}. \\ This research through a pilot study seeks to find out if there is relationship between demographic factors (age and level of education) and cyber-hygiene among students and employees of University of Nigeria, Nsukka. An ethical approval was obtained from the university for the purpose of this research. This paper presents the result of the survey for determining the relationship between age and level of education of students and staff, and cyber-hygiene. The wide adoption of internet in tertiary institutions, coupled with quest for migration to online learning as a result o f the outbreak of Coronavirus-2019 (COVID-19) necessitated this research.\\ The remaining parts of this paper are organised as follows: Section~\ref{Section: Review} presents the literature review, followed by methodology as Section~\ref{Section: Method}. Section~\ref{Section: Discussion} presents the Result and Discussion of the research analysis. The Conclusion forms the final section of the the paper. \\ \section\textbf{{Review of Related Literature}} \label{Section: Review} While there have been several studies involving various users and aspects of cyber-hygiene, there is currently is no substantial survey, which explores cyber-hygiene by considering individual differences and the users’ level of knowledge especially amongst students and employees in the universities in Nigeria. The main reasons for this research are to find out the effect of age and educational level on cyber-hygiene and also to ascertain the level of cyber-hygiene knowledge and behaviour among students and employees of University of Nigeria, Nsukka.\\ Previously many researchers have made findings on cyber-hygiene cultures of internet users. Talib~\textit{et al.}~\cite{talib2010analysis} found that 97\% of users did have antivirus software at home. Authors in~\cite{talib2010analysis} also reported that 72\% of people who are not trained on the topic did use firewall protection. There are also discrepancies in the data that describes the use of Spam protection. \\ The study conducted in~\cite{neigel2020holistic} focused on understanding the human factors and individual differences that influence cyber-hygiene. The results demonstrated in the work indicate that cyber-hygiene education need not target a particular sex or age group in terms of content or delivery method, which contradicts previous findings from~\cite{whitty2015individual}. The research carried out by authors in~\cite{whitty2015individual} highlighted the importance of understanding the types of people who are more likely to engage in the risky behavior of sharing passwords. They found a number of variables that can be used to predict users that engage in the risky practice of sharing passwords, which are age, perseverance, and self-monitoring.\\ Research conducted in~\cite{barrerainfluence} seeks to examine relationships, if any, between cyber-security awareness level and the background of participants pursuing careers in the area of Information Systems (IS) and/or Information Technology (IT) at the bachelor’s level in three different geographic locations; Germany, United Kingdom, and the United States of America, focusing specifically on four demographic variables: gender, age, education Level Completed and Current Employment Status. They arrived at a conclusion that Awareness is frequently associated to operational situations, where specific reasons require individuals to have an identifiable awareness level for a specific context. Therefore, individuals and business organisations benefit from higher levels of security awareness, which ultimately reflects higher literacy levels and learning. Lastly, business continuity depends on how individuals respond to various situations, exercise caution in their decisions, and ultimately, how aware they are about current and future security risks in their doings.\\ A study to create awareness of security threat and avoidance was carried out in \cite{arachchilage2014security}. The study was carried out on anti-phishing education to guard against identity theft and related issues. It examined whether the knowledge of cyber-hygiene concepts has effect on users’ ability to avoid phishing attack. An online questionnaire were distributed and collected from 161 computer users from Brunel University and the University of Bedfordshire and their responses were used for analysis. The finding revealed that the knowledge of concepts enables internet users to avoid phishing attacks. It was concluded that educating users on the knowledge of concepts has significant positive effects on enabling users to avert phishing threats and attacks.\\ \section{Methodology} \label{Section: Method} \subsection{\textbf{Research Goal}} The primary goal of this research is to determine the significance effect of certain demographic factors/variables such as age and level of education on cyber-hygiene culture among students and employees of University of Nigeria, Nsukka. The reasons for choosing the university are for convenience, cost reduction and availability of participants to researchers. In respect to this research, an ethical approval was sought from the university authority and it was given. Because of prolonged Academic Staff Union of Universities in Nigeria and lockdown necessitated by COVID-19 pandemic, the response rate was very low. Based on this reason, the researchers decided to take a pilot study from the received responses to test the respondent’s understanding of the research questionnaire. An updated version of the survey will be conducted as soon as the university reopens.\\ \subsection{\textbf{Instrument and Method of Data Collection}} Questionnaire was the basic instrument used to gather required data from the chosen institution. A well-structured questionnaire was designed with Google form for the survey and distributed via online approach using the institution’s online mailing system and group WhatsApps to the chosen participants. Responses from the respondents were collated in a datasheet and were subjected for analysis.\\ \subsection{\textbf{Sampling Technique}} Convenience sampling, a common non-probability sampling was applied in selecting the sample used for the survey. This sampling method is fast, cost-effective and it makes sample easily available.\\ \subsection{\textbf{Sample Size}} A total of 145 responses were received and used for this pilot study. The respondents cut across different age ranges and educational levels to accommodate all relevant demographics.\\ \subsection{\textbf{Research Model}} Here in our study, the analysis of the effect of some selected demographic factors on cyber-hygiene among students and employees of University of Nigeria, Nsukka was carried out. The demographic factors represent the independent variables, which include age and educational level whereas cyber-hygiene represents the dependent variable in this study. The percentage of internet usage for educational purposes increases with the student’s age, which shows the increasing e-learning prospect with the level of education as observed in \cite{tirumala2016survey}. Some common aspects of cyber-hygiene culture were chosen for this study namely, storage and virus attack hygiene, social network hygiene, authentication hygiene and social engineering hygiene. The first three which include virus attack hygiene, social network hygiene and authentication hygiene were adopted from~\cite{vishwanath2020cyber} with little modification in nomenclature. Social engineering hygiene was introduced by the research team as users’ cyber-hygiene dimension required to overcome the cyber-security threat considered in~\cite{fatokun2019impact}. Questions in section B and section C of the questionnaire were spread across these four aspects of cyber-hygiene. The association of the independent variables and the dependent variable is shown in Figure~\ref{fig:my_label} below.\\ \begin{figure} [h] \centering \includegraphics[width=8cm,height=4cm]{model2.jpg} \caption{\textbf{Research Model}} \label{fig:my_label} \end{figure} \subsection{\textbf{Research Questions}} In order to ascertain if there is any significance relationship between demographic factors and cyber-hygiene culture, the following research questions were raised: \begin{enumerate} \item Does age of internet users have any significant relationship with cyber-hygiene culture? \item Does level of education of internet users have any significant relationship with cyber-hygiene culture? \end{enumerate} \subsection{\textbf{Research Hypotheses}} Two null hypotheses were formulated as follows by the researchers to answer the above research questions: \begin{itemize} \item H1: Age of internet user does not have any significant effect on cyber-hygiene \item H2: Level of education of internet user does not have any significant effect on cyber-hygiene \end{itemize} \subsection{\textbf{Data Analysis}} Our research questionnaire in this study consist of three sections, section A which was used to gather information on demographic factors, type of activities they perform with internet and the type of devices used for these activities. Questions on section B were asked to determine participants’ knowledge on threat and concept. This section has total of 12 questions, which comprises of multiple choice questions and five points Likert scale statements. Options for the five points Likert scale statements ranging from \textbf{Strongly Agree}, \textbf{Agree}, \textbf{Don’t Know}, \textbf{Disagree} and \textbf{Strongly Disagree}. In each of the statement, either Strongly Agree and Agree or Disagree and Strongly Disagree are considered as the correct option. Section C seeks to verify the level of cyber-hygiene culture exhibited by participants or their cyber-hygiene behaviour. On section C, respondents were asked to report the degree to which they engage on certain cyber-hygiene behaviour on a four points Likert scale with option ranging from Every time, Often, Rarely, and Never. In this case, either Every time and Often or Never is considered as the correct option. Questions in section B and C concentrates within the four chosen aspects of cyber-hygiene (\textbf{storage and virus, social network, authentication and social engineering}) used for this study. The respondents were asked to go through the definition of some technical terms such as cyber-hygiene, virus, authentication, social network and social engineering used in the study for clarification, easy understanding and better response. \\ According to~\cite{akman2010gender}, the test of statistical hypotheses is one of the main areas of statistical inference. Version 20 of the Statistical Packages for Social Sciences (SPSS) software was used for the analysis. Chi-square test, an analytical tool embedded in Statistical Packages for Social Sciences (SPSS) software was used to test the significance of these demographic variables. Also, multiple regression technique was subsequently used to determine the direction of the main impacts of the independent variables on the dependent one. Out of these tests, the following inferences made on this paper were drawn.\\ \section{\textbf{Result and Discussion}} \label{Section: Discussion} This research survey sought to find out from the participants the type of devices they use for internet, the activities they use internet for, their knowledge of cyber-hygiene concepts and threats, and their cyber-hygiene behaviour. Our findings are shown as tables and discussed in the following sections below:\\ \subsection{\textbf{Devices Used for the Internet}} As shown in Table~\ref{tab: table1}, it was found that majority of the respondents, 135(93.1\%) indicated mobile phone as the most commonly used device, followed by laptop 103(71\%). The least used is other devices 2(1.4\%), followed by desktop 17(11.7\%) and finally, Tablet with 21(14.5\%). This varies from the result in~\cite{cain2018exploratory}, where the number of laptop users are more than the number of smart phone users. This may not be far from the low cost of mobile phones and its proliferation across the country compared to laptops.\\ \begin {table}[h!] \begin {center} \caption{\textbf{Devices used for internet}} \label{tab: table1} \begin{tabular}{l|c|r} \textbf{Variable} & \textbf{Frequency} & \textbf{Percentage}\\ \hline Laptop & 103 & 71\\ Desktop & 17 & 11.7\\ Mobile phone & 135 & 93.1\\ Tablet & 21 & 14.5\\ Other devices & 2 & 1.4\\ \end{tabular} \end {center} \end {table} \subsection{\textbf{Uses of Internet}} Table~\ref{tab: table2} shows various purposes for which the participants use internet for. It can be drawn from the table that apart from playing games with only 23.4\% (34, n=145), other purposes in which the participants use the internet for attracts high percentage of users ranging from 50.3 to 94.5. The highest is internet browsing with 94.5\% (137, n=145), followed by learning with 86.9\% (126, n=145). This findings show high level of adoption and usage of internet among students and employees of higher institutions, which calls for survey of their cyber-hygiene knowledge and behaviour.\\ \begin {table}[h!] \begin {center} \caption{\textbf{Uses of internet}} \label{tab: table2} \begin{tabular}{l|c|r} \textbf{Variable} & \textbf{Frequency} & \textbf{Percentage}\\ \hline Browsing & 137 & 94.5\\ Email & 117 & 80.7\\ Downloading music/video & 96 & 66.2\\ Social Networking & 118 & 81.4\\ Playing games & 34 & 23.4\\ Learning & 126 & 86.9\\ Business & 73 & 50.3\\ Banking & 91 & 62.8\\ \end{tabular} \end {center} \end {table} \subsection\textbf{{Demographics of Respondents}} From the demographic information presented in Table~\ref{tab: table3}, the age of the respondents were coded into five groups, respondents between 15-24years, 25-34year, 35-44years, 45-54years and above 54years. The distributions of respondents within these groups are as follows: 15-24years 40.7\% (59, n=145), 25-34year 25.5\% (37, n=145), 35-44years 20.0\% (29, n=145), 45-54years 11.0\% (16, n=145) and above 54years 2.8\% (4, n=145). As regards their educational level of the respondents, 0.7\% (1) has diploma, 44.1\% (64) are undergraduates, 21.4\% (31) are graduates, 20.0\% (29) are Masters degree holders and 13.8\% (20) have Doctorate degree.\\ \begin {table}[h!] \begin {center} \caption{\textbf{Socio-demographics of the respondents}} \label{tab: table3} \begin{tabular}{l|c|r} \textbf{Variable} & \textbf{Frequency} & \textbf{Percentage}\\ \hline \multirow {2} {*} Age\\ 15-24yrs & 59 & 40.7\\ 25-34yrs & 37 & 25.5\\ 34-44yrs & 29 & 20.0\\ 45-54yrs & 16 & 11.0\\ Above 54yrs & 4 & 2.8\\ \hline Educational Level\\ Diploma & 1 & 0.7\\ Undergraduate & 64 & 44.1\\ Graduate & 31 & 21.4\\ Masters & 29 & 20.0\\ Doctorate & 20 & 13.8\\ \end{tabular} \end {center} \end {table} \subsection{\textbf{Age and Cyber hygiene}} In order to find out the effect of the age of the participants on cyber-hygiene, chi-square tests were carried out to check the relationship between age and cyber-hygiene knowledge and also between age and cyber-hygiene behaviour. From the result of the chi-square test to determine the relationship between age and cyber-hygiene as shown in Table~\ref{tab: table4}, the p-value of (0.455), which is greater than 0.05 indicates no statistical significance. This means that there is no relationship between age and cyber-hygiene knowledge. On the same hand, Table~\ref{tab: table5} presents a p-value of 0.551 for age and cyber-hygiene behaviour, meaning that age of the participants has no relationship with the cyber-hygiene behaviour. The result here conforms to what was obtained in-\cite{cain2018exploratory}.\\ \begin {table}[h!] \begin {center} \caption{\textbf{Chi-Square Test for Age and Cyber hygiene knowledge}} \label{tab: table4} \begin{tabular}{l|c|c|r} \textbf{Quantity} & \textbf{Value} & \textbf{df} & \textbf{ Asym. Sig (2-sided)}\\ \hline Pearson Chi-Square & 3.691 & 4 & 0.455\\ Likelihood Ratio & 3.175 & 4 & 0.270\\ Linear-by-Linear Association & 0.896 & 1 & 0.344\\ N of Valid Cases & 145 \\ \end{tabular} \end {center} \end {table} \begin {table}[h!] \begin {center} \caption{\textbf{Chi-Square Test for Age and Cyber hygiene behaviour}} \label{tab: table5} \begin{tabular}{l|c|c|r} \textbf{Quantity} & \textbf{Value} & \textbf{df} & \textbf{ Asym. Sig (2-sided)}\\ \hline Pearson Chi-Square & 3.043 & 4 & 0.551\\ Likelihood Ratio & 3.093 & 4 & 0.542\\ Linear-by-Linear Association & 0.301 & 1 & 0.583\\ N of Valid Cases & 145 \\ \end{tabular} \end {center} \end {table} \subsection{\textbf{Level of Education and Cyber hygiene}} Chi-square tests were also conducted in two categories to determine the relationship between level of education as an independent variable and the dependent variable, cyber-hygiene. In the first category, the p-value of the chi-square test for level of education and cyber-hygiene knowledge as shown in Table \ref{tab: table6} is 0.628. The interpretation is that the level of education of the respondent does not have relationship with cyber-hygiene knowledge. Secondly, the chi-square test for level of education and cyber-hygiene behaviour has p-value of 0.285 as shown in Table \ref{tab: table7}. This also means that there is no relationship between the level of education of the respondents and cyber-hygiene behaviour.\\ \begin {table}[h!] \begin {center} \caption{\textbf{Chi-Square Test for Level of Education and Cyber-hygiene knowledge}} \label{tab: table6} \begin{tabular}{l|c|c|r} \textbf{Quantity} & \textbf{Value} & \textbf{df} & \textbf{ Asym. Sig (2-sided)}\\ \hline Pearson Chi-Square & 2.596 & 4 & 0.628\\ Likelihood Ratio & 2.985 & 4 & 0.560\\ Linear-by-Linear Association & 0.655 & 1 & 0.418\\ N of Valid Cases & 145 \\ \end{tabular} \end {center} \end {table} \begin {table}[h!] \begin {center} \caption{\textbf{Chi-Square Test for Level of Education and Cyber-hygiene behaviour}} \label{tab: table7} \begin{tabular}{l|c|c|r} \textbf{Quantity} & \textbf{Value} & \textbf{df} & \textbf{ Asym. Sig (2-sided)}\\ \hline Pearson Chi-Square & 5.012 & 4 & 0.285\\ Likelihood Ratio & 5.488& 4 & 0.241\\ Linear-by-Linear Association & 0.135 & 1 & 0.714\\ N of Valid Cases & 145 \\ \end{tabular} \end {center} \end {table} \subsection{\textbf{Percentage Representation of Good Knowledge and Good Behaviour}} Tables \ref{tab: table8} and \ref{tab: table9} show the descriptive statistics of good knowledge scores and good behaviour score respectively. This was done to find out if the data is normally distributed, that is, if the median is the same as the mean. There are other tests used for normality but are not included here. Both tables show that data are normally distributed. That is it failed the tests. So, the median was used as the cut off point for the categorisation of the respondents into those with poor and good knowledge, and poor and good behaviour. Those who had a score of 10 and above had good knowledge, while those with lower than 10 score were grouped as having poor knowledge. The median for cyber-hygiene behaviour score is 6, therefore, those who had a score of 6 and above had good behaviour, while those with lower than 6 score were grouped as having poor behaviour. As shown in Table \ref{tab: table10}, the number of the respondents with good knowledge is 78, representing 53.79\%, while 75 have good behaviour, that is 71.72\%. This result shows that a reasonable number of the respondents, almost half, do neither have good cyber-hygiene knowledge nor good cyber-hygiene behaviour. \\ \begin {table}[h!] \begin {center} \caption{\textbf{Descriptive for cyber-hygiene knowledge score}} \label{tab: table8} \begin{tabular}{l|c|r} \textbf{Total cyber-hygiene knowledge score } & \textbf{ Statistic } & \textbf{Std. Error} \\ \hline Mean & 9.39 & 0.123\\ 95\% confidence upper range & 9.15\\ Interval of mean lower range & 9.64\\ 5\% Trimmed Mean & 9.49\\ Median & 10.00\\ Variance & 2.20\\ Std. Deviation & 1.48\\ Minimum & 4.00\\ Maximum & 12.00\\ Range & 8.00\\ Interquartile Range & 2.00\\ Skewness & -0 .87 & 0.201\\ Kurtosis & 0.81 & 0.400\\ \end{tabular} \end {center} \end {table} \begin {table}[h!] \begin {center} \caption{\textbf{Descriptive for Cyber-hygiene behaviour score}} \label{tab: table9} \begin{tabular}{l|c|r} \textbf{ Total Cyber-hygiene behaviour score } & \textbf{ Statistic } & \textbf{Std. Error} \\ \hline Mean & 5.84 & 0.248\\ 95\% confidence upper range & 5.35\\ Interval of mean lower range & 6.33\\ 5\% Trimmed Mean & 5.78\\ Median & 6.00\\ Variance & 8.93\\ Std. Deviation & 2.99\\ Minimum & 0.00\\ Maximum & 13.00\\ Range & 13.00\\ Interquartile Range & 5.00\\ Skewness & 0 .27 & 0.201\\ Kurtosis & -0.78 & 0.400\\ \end{tabular} \end {center} \end {table} \begin {table}[h!] \begin {center} \caption{\textbf{Percentage Representation of Good Knowledge and Good Behaviour }} \label{tab: table10} \begin{tabular}{l|c|c|r} \textbf{Descriptive variable} & \textbf{Total Sample} & \textbf{Good Knowledge} & \textbf{Good Behaviour}\\ $\hspace{1cm}$ & $N=145(100)\%$ & $N=75(51.72)\%$ & $N=78(53.79)\%$\\ \hline \multirow {2} {*} \underline{Age}\\ 15-24yrs & 59(40.7) & 31(39.7) & 27(36.0)\\ 25-34yrs & 37(25.5) & 19(24.4) & 21(28.0)\\ 34-44yrs & 29(20.0) & 15(19.2) &17(22.7)\\ 45-54yrs & 16(11.0) & 9(11.5) & 9(12.0)\\ Above 54yrs & 4(2.8) & 4(5.1) & 1(1.3)\\ \hline Educational Level\\ Diploma & 1(0.7) & 0(0.0) & 0(0.0) \\ Undergraduate & 64(44.1) & 32(44.1) & 30(40.0)\\ Graduate & 31(21.4) & 19(24.4) & 21(28.0)\\ Masters & 29(20.0) & 15(19.2) & 14(18.7)\\ Doctorate & 20(13.8) & 12(15.4) & 10(13.3)\\ \end{tabular} \end {center} \end {table} \section{\textbf{Conclusion and Recommendation}} \label{Section: Conclusion} The primary target of our study was to determine the effect of age and educational level on the cyber-hygiene knowledge of employees and students of University of Nigeria, Nsukka, through an online pilot study. Thus, the detailed findings of the research were presented in the result and discussion section of our paper. From the results we have, it was found that the two variables: age and level of education do not have significant effect on the cyber-hygiene knowledge and behaviour of students and employees of University of Nigeria, Nsukka. It was also discovered that a reasonable proportion of the participants of this survey have poor cyber-hygiene knowledge and behaviour, which suggests the need for proper awareness and training. \\ The result of our findings as regards the effect of age on cyber-hygiene correlates with the result in obtained in \cite{cain2018exploratory}, which also found that age has no statistical significance with cyber-hygiene. Based on the findings from this research, it can be recommended that well focused training on cyber-hygiene best practices should be organised for both students and employees of the tertiary institutions. Also, the internet security units of tertiary institutions should put in place adequate security infrastructures to safeguard the institution’s information and devices against cyber-attacks.\\ \section{\textbf{Future Work}} \label{Section: Future Work} In future study, the effect of other factors such as gender, level of exposure, area of discipline that might impact on the cyber-hygiene will be investigated. One major limitation of this study was poor responses occasioned by closed down of institutions because of Coronavirus disease 2019 (COVID-19) pandemic. \\ \bibliographystyle{IEEEtran}
{'timestamp': '2021-03-12T02:20:36', 'yymm': '2103', 'arxiv_id': '2103.06621', 'language': 'en', 'url': 'https://arxiv.org/abs/2103.06621'}
arxiv
\section{The problem} The Dunnett test based on the common variance estimator and its degree of freedom of an one-way layout, i.e. the assumption of variance homogeneity holds. In practical data, heteroscedasticity occur sometimes which is considered as a disturbing influence factor. To avoid a violation of the FWER, modifications are recommended where the sandwich variance estimator is used \cite{Herberich2010}, or the degree of freedom is reduced accordingly \cite{Hasler2008}. In addition, there is a possible bias if, for example, the increased variance in a group of no interest which may biases the inference of another group of interest. Here we consider heterogeneity not primarily as a confounding factor, but a kind of early detection criteria before location effects become visible. This phenomenon can be seen, for example, in genetics, global warming, or income differences in the case of external stress, such as a pandemic. Here it is not about the detection of pure location effects on the one hand or pure scale effects on the other hand, but always about the detection of combined location and scale effects. \\ The basic approach is a max(maxT) test, simultaneously modeling both location effects and scale effects for simultaneous comparisons to the control. For this purpose, an asymptotic multiple marginal models method (mmm) \cite{Pipper2012} is used. A scale-sensitive modified 2nd endpoint is defined by the Levene transformation $abs(y_{ij}-median(y_i))$ \cite{Neuhauser2000}. A further approach is resampling test using the Lepage test idea \cite{Hothorn2006, Hothorn2008b}. As an alternative, the most likely transformation method is used \cite{Hothorn2018, Hothorn2020a}, which accounts for location and scale differences in the context of more general distributional differences, again for a Dunnett-type test \cite{Hothorn2019}. For comparison (although considerably limited), Dunnett-type tests for location (and homogeneous variance), for location effects with sandwich estimators, and for scale (Levene residuals) are included. \section{Location-Scale Dunnett-type tests} First, max(maxT) test using the asymptotic mmm method to achieve the variance-covariance matrix of several model fits where $\xi=k*\eta$ models with a factor $A$ are included: $k$ for comparing of $k$ treatments versus control and $\eta=2$ for the untransformed endpoint $Y$ and the Levene-transformed endpoint $Yt$ (raw data available in the object $dat$) (MMM). The R-code shows this simple approach clearly: \footnotesize \begin{verbatim} library(multcomp) mod1<-lm(Y~A, data=dat) mod2<-lm(tY~A, data=dat) summary(glht(mmm(location = mod1, scale= mod2), mlf(mcp(A ="Dunnett")))) \end{verbatim} \normalsize Second, the most likely transformation approach (MLT) is more complex. A transformation using Bernstein polynomials is needed (where the order 5 is appropriate for such data). A conditional transformation model (ctm) is used for an additive factor shift and the transformation to normal distribution, followed by the most likely transformation (mlt). Finally, the parameter estimates are used in the generalize hypotheses testing function(glht) with the Dunnett-type correlation matrix. \footnotesize \begin{verbatim} library(mlt) yvar <- numeric_var("Number", support =quantile(dat$Y, prob = c(.01, .99))) # MLT support bstorder<-5 # order of Bernstein polynomial (an appropriate choice) yb <- Bernstein_basis(yvar, ui = "increasing",order =bstorder) # Bernstein polynomial ma <- ctm(yb, shifting = ~ A, todistr = "Normal", data = dat) # condit transformation model m_mlt<-mlt(ma, data = dat) # most likely transformation K <- diag(length(coef(m_mlt))) # contrast matrix rownames(K) <- names(coef(m_mlt)); matr<-bstorder+1 K <- K[-(1:matr),] # contrast matrix when using order 5 Bernstein summary(glht(m_mlt, linfct = K)) # MLT-Dunnett-type test \end{verbatim} \normalsize Third, the Lepage test approach (LEPA) can be modeled by the transformation function $legape_trafo$ in the library(coin) where the object DUN contains the Dunnett-type contrast matrix: \cite{Hothorn2006, Hothorn2008} \footnotesize \begin{verbatim} library("coin") lepage_trafo <- function(y) cbind("Location" = rank_trafo(y), "Scale" = ansari_trafo(y)) pvalue(independence_test(Y ~ A, data = dat, xtrafo =DUN, teststat = "maximum", distribution = approximate(nresample = 10000), ytrafo = function(data) trafo(data, numeric_trafo = lepage_trafo)), method = "single-step") \end{verbatim} \normalsize \section{Simulation results} Both FWER (under global $H_0$) and the any-pairs power (under $H_1$) for the three basic location-scale Dunnett-type tests: MMM, MLT, LEPA are reported in Table \ref{tab:sim} for a balanced design and an unbalanced design ($n_i=16,8,8,8$). Additional the estimates for the location models within mmm (MMMl), the standard Dunnett Test, the Dunnett-test modified with sandwich estimator (sDUN), the scale test (SCA) and the location models with Lepage tests (LEPAl) are considered. \textit{($H_{10}$ is for location effects only, $H_{01}$ is for scale effects only, $H_{11}$ is for location and scale effects, $H_{11}^d$ is for location and scale effects where the heterogeneity occurs in a non-interesting treatment group).} Variance heterogeneity was formulated by just increasing a treatment variance (MQR ... unadjusted) or keeping the MQR constant (MQR ... adjusted).\\ Per definition, FWER is controlled by all tests (MLT asymptotically only), however for any pattern of heteroscedasticity, the standard Dunnett test (DUN) behaves inflationary, where the sandwich modification still controls FWER. Per definition, MMM detects pure location effects, or pure scale effects or location and scale effects. MMM's power loss versus sDUN in the case of pure location effects, or versus SCA in the case of pure scale effects exists per definition, but is acceptable small. In most configurations, MMM outperforms both MLT and LEPA. \begin{table}[ht] \centering \caption{Simulations under $H_{00}$ and $H_1$ for location-scale Dunnett-type tests} \label{tab:sim} \scalebox{0.6}{ \begin{tabular}{r|r|rrr|rrr||rrrrrrrr} \hline MQR & Hypo. & $\mu_2$ & $\mu_3$ & $\mu_4$ & $s_2$ & $s_3$ & $s_4$ & MMM & MMMl & DUN & sDUN & SCA & MLT & LEPA & LEPAl \\ \hline Unadj & $H_{00}$ & 1.0 & 1.0 & 1.0 & 0.8 & 0.8 & 0.8 & 0.05 & 0.03 & 0.06 & 0.05 & 0.03 & 0.06 & 0.06 & 0.03 \\ \hline \hline &$H_{01}$ & 1.0 & 1.0 & 1.0 & 0.8 & 0.8 & 1.8 & 0.39 & 0.04 & 0.06 & 0.05 & 0.46 & 0.04 & 0.23 & 0.02 \\ &$H_{01}$ & 1.0 & 1.0 & 1.0 & 0.8 & 0.8 & 2.4 & 0.66 & 0.06 & 0.10 & 0.05 & 0.73 & 0.07 & 0.40 & 0.04 \\ &$H_{01}^d$ & 1.0 & 1.0 & 1.0 & 1.8 & 0.8 & 0.8 & 0.40 & 0.03 & 0.05 & 0.05 & 0.46 & 0.04 & 0.23 & 0.03 \\ \hline &$H_{10}$ & 1.0 & 1.0 & 2.5 & 0.8 & 0.8 & 0.8 & 0.93 & 0.93 & 0.96 & 0.94 & 0.04 & 0.96 & 0.84 & 0.82 \\ \hline &$H_{11}$ & 1.0 & 1.0 & 2.5 & 0.8 & 0.8 & 1.8 & 0.74 & 0.58 & 0.66 & 0.47 & 0.47 & 0.54 & 0.48 & 0.32 \\ &$H_{11}$ & 1.0 & 1.0 & 2.5 & 0.8 & 0.8 & 2.4 & 0.82 & 0.43 & 0.52 & 0.31 & 0.72 & 0.37 & 0.54 & 0.23 \\ &$H_{11}^d$ & 1.0 & 1.0 & 2.5 & 1.8 & 0.8 & 0.8 & 0.80 & 0.66 & 0.79 & 0.94 & 0.44 & 0.85 & 0.79 & 0.72 \\ &$H_{11}^d$ & 1.0 & 1.0 & 2.5 & 2.4 & 0.8 & 0.8 & 0.81 & 0.41 & 0.54 & 0.93 & 0.72 & 0.73 & 0.83 & 0.67 \\ \hline \hline Adj & $H_{01}$ & 1.0 & 1.0 & 1.0 & 0.5 & 0.5 & 1.9 & 0.82 & 0.06 & 0.09 & 0.07 & 0.88 & 0.06 & 0.52 & 0.03 \\ &$H_{01}^d$ & 1.0 & 1.0 & 1.0 & 1.9 & 0.5 & 0.5 & 0.83 & 0.06 & 0.09 & 0.05 & 0.88 & 0.06 & 0.50 & 0.04 \\ &$H_{01}^d$ & 1.0 & 1.0 & 1.0 & 1.8 & 0.6 & 0.6 & 0.66 & 0.05 & 0.07 & 0.06 & 0.75 & 0.05 & 0.39 & 0.02 \\ &$H_{01}$ & 1.0 & 1.0 & 1.0 & 0.6 & 0.6 & 1.8 & 0.67 & 0.06 & 0.10 & 0.05 & 0.75 & 0.07 & 0.41 & 0.04 \\ \hline &$H_{11}$ & 1.0 & 1.0 & 2.5 & 0.5 & 0.5 & 1.9 & 0.96 & 0.65 & 0.72 & 0.49 & 0.89 & 0.53 & 0.73 & 0.35 \\ & $H_{11}^d$& 1.0 & 1.0 & 2.5 & 1.9 & 0.5 & 0.5 & 0.98 & 0.76 & 0.86 & 1.00 & 0.88 & 0.98 & 0.99 & 0.96 \\ & $H_{11}^d$& 1.0 & 1.0 & 2.5 & 1.8 & 0.6 & 0.6 & 0.96 & 0.75 & 0.86 & 1.00 & 0.76 & 0.95 & 0.96 & 0.90 \\ & $H_{11}$& 1.0 & 1.0 & 2.5 & 0.6 & 0.6 & 1.8 & 0.89 & 0.64 & 0.73 & 0.49 & 0.74 & 0.55 & 0.62 & 0.35 \\ \hline Adj $n_0=16$ & $H_{10}$ & 1.0 & 1.0 & 2.5 & 0.8 & 0.8 & 0.8 & 0.94 & 0.94 & 0.96 & 0.95 & 0.04 & 0.96 & 0.72 & 0.69 \\ & $H_{11}$& 1.0 & 1.0 & 2.5 & 0.8 & 0.8 & 1.8 & 0.81 & 0.64 & 0.71 & 0.43 & 0.47 & 0.58 & 0.46 & 0.30 \\ &$H_{11}$ & 1.0 & 1.0 & 2.5 & 1.8 & 0.8 & 0.8 & 0.88 & 0.74 & 0.84 & 0.95 & 0.46 & 0.90 & 0.74 & 0.61 \\ \hline \end{tabular} } \end{table} \section{Evaluation of two examples using CRAN packages} \subsection{Possible location and scale effects} First an example was selected where both location and scale effects may occur. In a reverse genetic rescue experiment using Arabidopsis for the seed filling phenotype of acr4-2, the number of seeds per siliques in 10 transgenic lines were compared to wild type (wt), see the boxplots \cite{Okuda2020}. The related R-code is in Appendix I. The transgenic line f reveals the strongest decrease vs. wild type where both a locations effect and a scale effect was observed, see Table \ref{tab:gen}. \begin{figure}[ht] \centering \includegraphics[width=0.3468\textwidth]{Genf4.pdf} \caption{Number of seeds in a reverse genetic rescue experiment} \label{fig:F4} \end{figure} \begin{table}[ht] \centering\scriptsize \caption{Adjusted p-values of 4 approaches- reverse genetic rescue experiment} \label{tab:gen} \begin{tabular}{r|l|rr|rr} \hline No & Comparison & Location only & Scale only & LocationScale & MLT \\ \hline 1 & location: a - wt & 0.65 &-& 0.92 & 0.45\\ 2 & location: acr - wt & 0.0001 &-& 0.0001 & 0.0001 \\ 3 & location: b - wt & 0.55 &-& 0.85 & 0.59\\ 4 & location: c - wt & 0.99 &-& 0.99 & 0.99\\ 5 & location: com - wt & 0.99 &-& 0.99 &0.99\\ 6 & location: d - wt & 0.0001 &-& 0.0001 & 0.0013\\ 7 & location: e - wt & 0.99 &-& 0.99 &0.99\\ 8 & location: f - wt & 0.0001 &-& 0.0001 & 0.0001\\ 9 & location: g - wt & 0.0001 &-& 0.0001 & 0.0002\\ 10 & location: h - wt & 0.60 &-& 0.89 &0.56\\ \hline 11 & scale: a - wt & - &0.99 &0.99 &-\\ 12 & scale: acr - wt & - &0.99 & 0.99 &-\\ 13 & scale: b - wt & - &0.66 & 0.92 &-\\ 14 & scale: c - wt & - &0.99 & 0.99 &-\\ 15 & scale: com - wt & - &0.99 & 0.99 &-\\ 16 & scale: d - wt & - &0.03 & 0.07 &-\\ 17 & scale: e - wt & - &0.99 & 0.99 &-\\ 18 & scale: f - wt & - &0.0001 & 0.0001 &-\\ 19 & scale: g - wt & - & 0.65& 0.92 &-\\ 20 & scale: h - wt & - &0.83 & 0.98 &-\\ \hline \end{tabular} \end{table} \subsection{Considering disturbing variance heterogeneity} A second example was selected where a disturbing variance effect in a non-interesting dose group may occur. As example data, the cholesterol values in a chronic toxicity study was used \cite{Hothorn2016} where in the box-plots an increased variance in the low dose group occurred (global variance heterogeneity due to the Levene test in library(EnvStats). This low dose group is not of interest because only decreasing cholesterol values are of interest in this toxicological bioassay. The question arises which impact this low dose group has on the effect of the higher doses vs. control? The magnitude of global variance heterogeneity is not too large ($p_{Levene}=0.07$). In this example data, teh MLT approach detects an effect for the 250 mg dose group already. \begin{figure}[ht] \centering \includegraphics[width=0.34\textwidth]{Chol.pdf} \caption{Cholesterol example data} \label{fig:Chol} \end{figure} \begin{table}[ht] \centering\footnotesize \caption{Adjusted p-values of 4 approaches- cholesterol experiment} \begin{tabular}{rl|ll|l|l} \hline No & Comparison & Location/Scale only & LocationScale& MLT & LocSandwich \\ \hline 1 & location: 62.5 - 0 & 0.0001 & 0.0001&0.0006 &0.004\\ 2 & location: 125 - 0 & 0.99 & 0.99 &0.99& 0.99 \\ 3 & location: 250 - 0 & 0.08 & 0.12 &0.026& 0.058\\ 4 & location: 500 - 0 & 0.007 & 0.01 &0.0014& 0.0065\\ 5 & location: 1000 - 0 & 0.0001 & 0.0001 &0.0001& 0.0001\\ \hline 6 & scale: 62.5 - 0 & 0.10 & 0.15 & &\\ 7 & scale: 125 - 0 & 0.99 & 0.99 & &\\ 8 & scale: 250 - 0 & 0.99 & 0.99 & &\\ 9 & scale: 500 - 0 & 0.99 & 0.99 & &\\ 10 & scale: 1000 - 0 & 0.99 & 0.99 & & \\ \hline \end{tabular} \end{table} \section{Conclusion} If both location effects and scale effects might be of interest when comparing treatments to a control, a max(maxT) test using multiple marginal approach (mmm) is well suited. Here, the elementary decisions for both the individual treatment contrasts for both location and scale effects are available as adjusted p-values or simultaneous confidence intervals. The CRAN package multcomp makes the calculation relatively simple. \scriptsize \bibliographystyle{plain}
{'timestamp': '2021-03-12T02:19:07', 'yymm': '2103', 'arxiv_id': '2103.06585', 'language': 'en', 'url': 'https://arxiv.org/abs/2103.06585'}
arxiv
\section{Introduction} In mathematics, computer science and statistical physics, there exist many constraint satisfaction problems (CSPs) whose worst-case computation is of exponential complexity. Studies show that solution space structures affect the performance of algorithms and the hardness of problems, and the computing complexity attains the maximum at the satisfiability threshold, where the probability of a random instance being satisfiable changes from 1 to 0 sharply. These hard problems provide challenging benchmarks for evaluation of algorithms. To evaluate the performance of incomplete algorithms around the hard region, it is natural to generate hard but satisfiable benchmarks, which can be done by planting solutions to random CSPs \cite{bar02,Dimitris05,jia2007,krza2009,xu2007}. In graph theory, planted cliques problems \cite{alon98,feige00,feige10,dekel14,deshpande15}, planed partitions \cite{amin09} and planted colourings \cite{bapst17} have been studied as well. Generating hard satisfiable instances has important applications, e.g. one-way function in cryptography. Indeed, \cite{ju1998} applied the ``planting" strategy to random graph problems, and proved that large hidden cliques are as hard to find as large cliques in usual random graphs, thus hidden cliques can be applied to create cryptographically secure primitives. Sometimes planting a solution may change the properties of the ensemble, thus making it difficult to understand when and why they can provide hard instances. For instance, random $k$-SAT instances generated by planting an assignment tend to be easy, where the hidden assignment attracts assignments close to it, thus can be solved efficiently. However, ``2-hidden" (where two complementary assignments are hidden) \cite{Dimitris05} and ``$q$-hidden" \cite{jia2007} 3-SAT formulas are as hard as usual random 3-SAT formulas. In this paper we will study the model RB, in which the properties of the usual random instances and random instances with one hidden solution are identical in that, the expected number of solutions and the hardness at the threshold remain the same \cite{xu2000}.
{'timestamp': '2021-03-16T01:33:01', 'yymm': '2103', 'arxiv_id': '2103.06649', 'language': 'en', 'url': 'https://arxiv.org/abs/2103.06649'}
arxiv
\section{Introduction} One key challenge in developing autonomous mobile robots is the SLAM (Simultaneous Localization And Mapping) problem \cite{Thrun2008}. Graph-based solutions are often based on a static environment, which is unrealistic: objects move, seasons influence the appearance of the surroundings and -- depending on the lighting -- images of the same scene differ. For long-term autonomy in dynamic environments two main requirements must be met. First, the computational complexity of graph optimization, the back-end, must be limited. Second, the process has to be robust against changes in the environment. The processing of sensor data, the front-end, must be developed in such a way that, despite changes, already visited places are recognized again. Answering the question \textit{Have I been here before?} belongs to the most important tasks during SLAM, since in presence of a loop closure, the odometry drift can be corrected retrospectively and the map quality can be improved. \inkscapescale{nodes_detector}{Loops with discrete nodes (blue points) are searched for in a variable radius of the current position (orange arrow). The search space depends on the position uncertainty. Due to the use of different memories not all nodes in the radius are used as loop candidates.}{htbp}{.85} Loop detection approaches can be classified according to the sensor technology used. Due to the high information density in an image and the multitude of effective techniques, visual methods are widely used. Where such methods are stable for static environments, the illumination change can already lead to failure within a few hours. Actively illuminated sensors such as LiDAR (Light Detection And Ranging) scanners are robust in such situations, as generated point clouds are illumination-invariant. This work deals with the combination of the two approaches to realize robust mapping and localization. The basis for this is the widespread library RTAB-Map (Real-Time Appearance-Based Mapping) \cite{Labbe.2018b}. Although the method can be used with a LiDAR, the data is only marginally utilized due to the simplified method of loop search within a constant radius using 2D Iterative Closest Point (ICP), making an extension suitable. Fig.~\ref{fig:nodes_detector} illustrates our approach. Loops are searched based on scan descriptors, and within a variable radius $r$ depending on the largest eigenvalue $\lambda_{\textrm{max}}$ of the position covariance matrix to take the odometry drift into account. If a loop exists, the respective scans are registered and the graph is optimized with the calculated transformation $\mm{T}$. The paper is structured as follows. Sec.~\ref{relatedwork} presents related work. Based on this, Sec.~\ref{cmrlidarloop} describes our contributions: \begin{itemize} \item further development of a loop detection method to enable the necessary scan registration, \item introduction of several loop verification steps to reject false positives, \item elaboration of a robust, open-source ROS package\footnote{\url{https://github.com/MarvinStuede/cmr\_lidarloop}} to close loops with LiDAR data during graph-based SLAM. \end{itemize} This is followed by various validations in Sec.~\ref{expval} and conclusions in Sec.~\ref{conclusions}. \section{Related Work}\label{relatedwork} Approaches to mapping changing environments are manifold. Examples are filtering moving objects and assuming a static environment \cite{Hua.2016}, modeling the dynamics in the frequency domain \cite{Krajnik.} and integrating new data to adapt the map \cite{Krajnik.2016}. The continuous adaptation to changes is also possible by removing old nodes at loop closure \cite{Lazaro.01.10.201805.10.2018} or by representing the environment in several time frames simultaneously \cite{Biber.June8112005}. RTAB-Map \cite{Labbe.2018b} is suitable for large-scale and long-term online SLAM in changing environments due to its memory management \cite{Labbe.2018}: The bounded Working Memory (WM) ensures a bounded demand on computing which is realized by transferring nodes to a database. A buffer of constant size ensures that recently created nodes are not considered for loop detection, since the odometry drift cannot be significantly corrected. Whereas most state-of-the-art methods are either visual or LiDAR-based, RTAB-Map supports both. This key advantage enables the use of many sensor configurations, comparison of results and easy integration into different systems. The availability in the ROS framework, multi-session operation and a high accuracy \cite{Labbe.2018b} further promote its deployment. RTAB-Map's LiDAR-based \textit{proximity detection} module was developed for challenging situations, such as a significant illumination change, in which the visual loop detection is not promising. However, the used 2D ICP algorithm is a simplified method for loop detection. The high amount of data within the three-dimensional point cloud is not used and a fast loop search with several hundred potential pairs is not possible. Beyond that, this module only searches within a constant radius for loops which is problematic, since the error of the estimated position increases due to odometry drift. The search space should thus be permanently adjusted. Further, a local search is useless at the beginning of multi-session operation, because the position in the old map is unknown. Instead, a global search must be performed here so that a link can be established between the two sessions, and the robot can locate itself in the old map. The potential of scans to close loops is thus not exploited, making an extension necessary. To detect loops with LiDAR data, there are a variety of methods which are based on histograms to reduce the scan dimension. Representing a scanning area as a piecewise continuous function using Normal Distribution Transform (NDT) and detecting loops by matching feature histograms realizes a high accuracy \cite{Magnusson.2009}. The time to create such histograms is an important property which is a disadvantage of NDT. Instead, by using simpler histrogram types such as the range or height of each point, a fast histogram generation \cite{Rohling.2015} is possible with results comparable to NDT. The azimuthal and radial division of the scan into bins and use of the maximum height of the points in each bin also allows a fast computation of a global descriptor called Scan Context \cite{gkim-2018-iros}. However, besides height and range, there is further information in the raw scan, which can be obtained with low computational effort. In \cite{Granstrom.}, each point cloud is described with 41 rotationally invariant geometric features, so that a trained classifier decides whether a loop exists. The extensive scan description with small, rapidly computed features and fast prediction make this approach suitable for efficient loop search. However, the method does neither consider the scan registration nor the important loop verification to reject false positives. We thus extend the method of Granström and Schön \cite{Granstrom.} with these essential elements and integrate it into RTAB-Map, so that a robust loop search with laser scans is realized. \section{SLAM with Learned LiDAR Loop Detector}\label{cmrlidarloop} The developed LiDAR extension is presented in Fig.~\ref{fig:cmr_lidarloop} and described in this section. \subsection{Loop Classification}\label{lidarclass} Loop detection is a binary problem: either the robot has already visited the current location in the past or not. To solve this problem based on LiDAR data, a classifier is trained. A point cloud $\m{P}{}{}{}{\mathit{i}}=\{\m{p}{}{}{\mathit{k}}{\mathit{i}}\}^{N}_{\mathit{k}=1}$ from node $i$ in the graph contains $N$ points $\m{p}{}{}{\mathit{k}}{\mathit{i}}\in\mathbb{R}^3$ representing the environment. The rotation invariant classifier presented in \cite{Granstrom.} is used in our work and is briefly introduced in the following. Depending on the LiDAR, the number of points differs. For example, the scanner of the mobile robot Sobi used for evaluation (see Sec.~\ref{expval}) generates $N$$\approx\,$45,000 points per cloud, requiring a dimensionality reduction for comparison. For this, each cloud is described by global features \cite{Granstrom.} \e{\m{f}{}{}{}{\mathit{i}}=(\m{f}{}{}{I}{\mathit{i}},\m{f}{}{}{II}{\mathit{i}})^\textrm{T}.}{feature_vector} Features $\m{f}{}{}{I}{\mathit{i}}$ of type I map the point cloud to a real number, e.g. simple geometric quantities such as the mean range or the range's standard deviation. More complex geometric quantities, such as the center and radius of a sphere fitted to the point cloud, are also calculated. A total of 32 features of type I are computed. In addition, there are nine features $\m{f}{}{}{II}{\mathit{i}}$ of type II. These are range histograms with nine different container sizes $b_{1},\ldots,b_{9}$. For each histogram, starting at the sensor origin, the scan is divided into annular container of constant width and the points lying in each container are counted. Each feature is a vector whose dimension depends on the container size. Before feature computation, every scan is processed in a way that all points with range $r_k$ greater than a maximum range $r_\textrm{max}$ are moved in the direction of the sensor origin so that $r_k \leq r_\textrm{max}$ applies for all points. This limitation allows range histograms of one container size to have the same dimension in any case. A total of 41 features are calculated consisting of 843 real numbers during SLAM with Sobi (see Sec.~\ref{expval}). Thus, the dimension of any scan is significantly reduced. \begin{figure*}[h] \centering \resizebox{1\linewidth}{!}{\input{Abbildungen/cmr_lidarloop.pdf_tex}} \caption{LiDAR extension of RTAB-Map. Loops are permanently searched for using the scan descriptors. In case of a detected loop, the registration of the scans takes place in a parallel thread. After the point clouds have been pre-processed, first a rough registration and then a refinement takes place.} \label{fig:cmr_lidarloop} \end{figure*} If during mapping and localization the features are calculated and stored for each node, the descriptor $\m{f}{}{}{}{c}$ of the current position can be efficiently compared to descriptors of map nodes $\m{f}{}{}{}{\mathit{i}}$ with respect to a possible loop closure. An AdaBoost Classifier \cite{Pedregosa.2011} \cite{Hastie.2009} predicts if a loop is present and the entity $\sk{p}{}{\mathit{i}}{}{c}$ indicates the probability that the corresponding scans are from the same location. The input of the classifier is generated from the respective feature vectors by comparing them appropriately \cite{Granstrom.}. Type I features are compared via the absolute difference and histogram comparison for features of type II is done using Pearson's correlation coefficient. AdaBoost classification \cite{Freund.1997} belongs to the class of boosting algorithms and uses $T$ weak learners, which together form a strong classifier. In each learning round, the data is reweighted depending on the current prediction error. Incorrectly classified and thus difficult cases are prioritized higher, so that the number of training rounds $T$ significantly influences the accuracy. For $T\geq50$ weak classifiers, the error was observed to stop decreasing for the used LiDAR descriptors \cite{Granstrom.}. Accordingly, in the present work $T=50$ rounds are performed for learning. \subsection{Scan Registration}\label{lidarreg} In case of a detection, a further step is necessary to close a loop: the scan registration. This aims at determining the homogeneous transformation $\mm{T}$ between the current point cloud $\m{P}{}{}{}{c}$ and the point cloud $\m{P}{}{}{}{*}$, with which a loop was detected. The transformation is then used to add a link between the two nodes in the map in order to take the loop into account. The entire registration process is illustrated in Fig.~\ref{fig:cmr_lidarloop} and is implemented with the point cloud library \cite{Rusu.09.05.201113.05.2011}. Registering raw point clouds is computationally expensive and the scans also contain regions that prevent successful registration. Examples are points on the ground or regions generated by reflection of the laser beam on glass fronts. To encounter this, the following filters are executed consecutively: \begin{itemize} \item voxel grid filter with voxel side length $l$, \item height filter to remove points with height lower than $z_\textrm{lim}$, \item intensity filter to remove points with intensity lower than $i_\textrm{lim}$ and therefore points which laser beams were reflected, \item range filter to remove points with range larger than $r_\textrm{lim}$ and therefore to remove scan regions which are far away and do not describe the environment in sufficient detail, \item random downsampling filter to randomly remove points until the point cloud consists of $n_\textrm{p,max}$ points. \end{itemize} The pre-processed scans $\m{\tilde{P}}{}{}{}{c}$, $\m{\tilde{P}}{}{}{}{*}$ used for registration can have a large translational and rotational offset. Using a local method like ICP \cite{Besl.1992} would not be expedient due to a convergence into a local optimum. Consequently, a rough registration to compute an initial alignment takes place first according to \cite{Holz.2015}. Thereby, Fast Point Feature Histograms (FPFH) \cite{Rusu.2009} are used as robust multidimensional features that describe local geometry around a point and only persistent features are used \cite{Rusu.2008}. The latter increases robustness, since only unique regions are taken into account. With these keypoints, the correspondences can then be estimated by performing a nearest neighbor search in the feature space. Because of a partial overlap, not every keypoint has a match and a large number of incorrect correspondences would be possible. These outliers negatively influence the registration and must be rejected. By means of outlier rejection based on RANdom SAmple Consensus (RANSAC) \cite{Fischler.1981} a transformation is computed over a multiplicity of iterations with different subsets of correspondences. Only those correspondences are classified as correct whose Euclidean distance, after application of the respective transformation, is smaller than a defined threshold. The outliers that are present during the transformation with the most inliers are rejected. With the filtered correspondences the initial alignment can be completed using Singular Value Decomposition (SVD) \cite{Horn.1987}. The transformation $\m{T}{}{}{\,\textrm{IA}}{}$ of this global method is the initial guess for subsequent refinement, so that the output of the ICP registration $\mm{T}$ is used to correct the odometry drift. Since adding a wrong transformation has drastic consequences for the SLAM procedure, some verification criteria must be met. First, both processed scans must consist of at least $n_\textrm{p,min}$ points so that enough data is included. Second, a transformation is only accepted if at least $n_\textrm{inliers}$ correspondences after outlier rejection are present which ensures that enough matching areas are found. Third, the transformation has a translational offset of at most $t_\textrm{max}$. This condition increases the robustness since a larger translational offset leads to a smaller scan overlap, and thus the registration can become less accurate. \subsection{Extending the RTAB-Map Framework}\label{impl} The presented loop detection and scan registration are integrated as an extension into RTAB-Map which is illustrated in Fig.~\ref{fig:cmr_lidarloop}. For each scan, the corresponding descriptor is calculated and sent to RTAB-Map. Saving the scans with associated features enables compatibility with multi-session operation. The extension is continuously supplied with current map data which contains required information of the graph such as the position $\m{x}{}{}{}{c}$ of the current node. Further, the extension receives the positions $\mm{X}=\{\m{x}{}{}{}{\mathit{i}}|\forall i\}$ of all map nodes and associated descriptors $\mm{F}=\{\m{f}{}{}{}{\mathit{i}}|\forall i\}$, which is the basis for the actual task to detect loops. When receiving new map data, a loop search is done with the trained detector. Similar to \textit{proximity detection}, the current node is compared with other WM nodes within a certain radius only. For example, if the robot is located in a corridor and the entire WM is checked, a loop detection with a node in a similar corridor at a completely different location in the building would be possible due to similar scans. Adding such a loop would be fatal for the SLAM process, so the local restriction is useful for increasing robustness. In determining the search space, the present work differs from RTAB-Map's approach. For large loops, a large odometry drift is present and therefore, a large uncertainty in the estimated position. The search carried out in \textit{proximity detection} in a constant radius is problematic here because the estimated position is highly inaccurate and loops are searched for in the wrong map area. Accordingly, we follow a different philosophy: the use of a variable search space depending on the position inaccuracy. The search radius \e{r(\lambda_{\textrm{max}})=r_\textrm{min}+\beta g_{\textrm{max}}(\lambda_{\textrm{max}})}{r_search} consists of two parts. In the constant radius $r_\textrm{min}$, loops are searched for if the current position can be assumed to be without errors. This is the case at the start of the process as well as at loop closures, where the inaccuracy is corrected. In all other cases, the estimated position is subject to error, whereby we assume the odometry error to be steadily increasing. This property is taken into account by the second component of (\ref{eq:r_search}). Thereby, $g_{\textrm{max}}(\lambda_{\textrm{max}})=2\sqrt{5.991\lambda_{\textrm{max}}}$ is the length of the longest major axis of the $95$\% confidence ellipse of the two-dimensional position. This quantity can be obtained from the largest eigenvalue $\lambda_{\textrm{max}}$ of the covariance matrix, for which the odometry data is processed by the extension. The parameter $\beta$ serves as a scaling factor. Fig.~\ref{fig:R_search} visualizes the variable search space. The approach enables to include nodes close to the exact position in the loop search despite a large position inaccuracy. \inkscapescale{R_search}{Despite the difference between the actual (green arrow) and estimated position (orange arrow), the search space (orange circle) contains the desired circular area with the radius $r_\textrm{min}$ around the actual position. The schematic course shows the increase of the radius with increasing time $t$ due to odometry error. If a loop closure occurs, the uncertainty is reset.}{bp}{1} As already mentioned, adding a wrong loop is fatal for the integrity of the map. Hence, further precautions are taken to reduce the number of false positives. Only when $\sk{p}{}{\mathit{i}}{}{c}>\sk{p}{}{}{}{min}$ applies to the predicted loop probability $\sk{p}{}{\mathit{i}}{}{c}$, the pair is treated as a potential loop pair. Further information on the adjustment of the threshold $\sk{p}{}{}{}{min}$, i.e. the fine tuning of precision and recall, is presented in Sec.~\ref{det_perf}. If the search was successful, a final verification is performed with the node of highest loop probability $\sk{p}{}{*}{}{c}$ at the location $i^*$. The current node is compared with the surrounding nodes of the potential loop candidate. If at least one loop with the current node is detected in the immediate neighborhood consisting of $2n_\textrm{v}$ verification nodes, this candidate is accepted. In each case $n_\textrm{v}$ nodes with $i<i^*$ and $n_\textrm{v}$ nodes with $i>i^*$ are considered. For the strictest variant ($n_\textrm{v}=1$) there must be either another loop with the node created before or after the loop candidate. Otherwise, the loop is rejected and the search starts again when new map data is received. If the verification is successful, the scan registration takes place in a parallel thread and the link between the involved nodes is added with the accepted transformation $\mm{T}$. After further verification in RTAB-Map, the loop can be closed by graph optimization. Two final adjustments remain to be made: First, loops must be searched robustly even in multi-session operation, which is impossible with the previous approach of a local search if the position is unknown. Especially at the beginning of a new session the relative position in the old map is in general not given -- the initial state problem. A position-independent search must be carried out here, so that nodes of the entire WM are examined. As alternative local restriction during multi-session, the size $n_\textrm{ms}$ is introduced which is the number of consecutive loop candidates that must lie within a radius $r_\textrm{ms}$. Only one loop is accepted if several loop pairs are from the same place. This type of loop search is done in multi-session mode for the first $n_\textrm{start}$ accepted loops, after which it has to be checked if the localization in the old map was successful. The criterion for this is the ratio $\alpha=\frac{n_\textrm{local}}{n_\textrm{WM}},$ where $n_\textrm{local}$ is the number of nodes in the local map and $n_\textrm{WM}$ is the number of all WM nodes. If this ratio is smaller than a defined threshold $\alpha_\textrm{min}$, there are few nodes in the local map, so the relative positions of many WM nodes to the robot are unknown. In this case, the entire WM should continue to be searched for loops, since localization is not yet satisfactory. Otherwise, the relative position of many WM nodes with regard to the robot is known and the local search in the variable radius can be started. To meet online requirements, the second adjustment is to limit the number of nodes used in the search. For this, $n_\textrm{n,max}$ nodes are randomly selected from the possible candidates. Due to the fast detector, hundreds of nodes can be used. \section{Experimental Validation}\label{expval} The evaluation is divided into three parts: First, a loop detector is trained and tested in an independent environment (see Sec.~\ref{det_perf}). Second, multi-session experiments were performed with this detector under challenging conditions (see Sec.~\ref{val_slam}). The mobile service robot Sobi \cite{Ehlers.2020} is used for both validations, which is a ROS-based information and guidance system equipped with a differential drive base (Neobotix MP-500), two RGBD cameras (Intel Realsense D435, front and back) and a 3D LiDAR (Velodyne VLP-16). An extended Kalman filter \cite{Moore.2016} is used to fuse the wheel odometry with the IMU data (XSens MTi-30). Third, the general applicability of our approach is shown with the widely used KITTI\cite{Geiger.2012b} dataset in Sec.~\ref{kitti_sec}. \subsection{Detector Performance}\label{det_perf} To train the detector, indoor and outdoor data consisting of descriptors with corresponding coordinates was collected on an university campus. There are large distances between objects in outdoor areas of the campus, so $r_\textrm{max}=40\textrm{m}$ is chosen. With the container sizes $b_{1},\ldots,b_{9}$ suggested in \cite{Granstrom.}, each feature vector consists of 843 entries. There is no ground truth position, so the optimized poses were obtained from RTAB-Map to generate the most accurate positions of the 1248 nodes with a path length of 697m. Comparing each node with itself and with all others gives 779,376 pairs. As the distance at which the detector should treat a pair as positive, we choose 3m. With this distinction, the set is divided into 11,458 positive and 767,918 negative pairs. Training with this set would not be expedient, as the number of pairs for the classes is clearly unbalanced. As in \cite{Granstrom.}, a random subset of negative pairs is used, where we select 11,458 pairs to obtain the same amount of data for both classes. However, it is noticeable that the performance varies considerably depending on the subset, since half of the data is randomly taken from a large set. Thus, an optimization was carried out, whereby 50 detectors were trained with different subsets. For comparison, common criteria consisting of detection rate $D$ and false alarm rate $FA$ are used: \e{D=\frac{\textrm{\# Positive data pairs classified as positive}}{\textrm{\# Positive data pairs}},}{D} \e{FA=\frac{\textrm{\# Negative data pairs classified as positive}}{\textrm{\# Negative data pairs}}.}{FA} An ideal detector would detect every loop ($D=100\%$) and would also not detect any loop incorrectly ($FA=0\%$). Since our extension still verifies every possible loop pair, $FA<1\%$ is set as target. The decisive parameter for this is the introduced threshold $p_\textrm{min}$, which is fine tuned with a training-independent test dataset consisting of 181 nodes. The path of length 72m is a loop in an indoor hall, which is illustrated in Fig.~\ref{fig:detector_performance}a). For each of the 50 detectors, $p_\textrm{min}$ was incrementally increased so that the requirement $FA<1\%$ is met. This process can be visualized with the ROC (Robot Operating Curve) of the best performing detector in Fig.~\ref{fig:detector_performance}b). Increasing the threshold results in a more restrictive detector, which is less erroneous but also detects fewer loops. The best classifier ($D=47.3\%,\,FA=0.8\%,\,p_\textrm{min}=52.4\%$) detects approximately half of all loops with only few false positives in the unknown environment. \begin{figure*}[t] \centerline{\includegraphics[width=\linewidth]{Abbildungen/detector_performance.pdf}} \caption{Detector performance for training-independent test environment a). ROC b) shows performances of best detector at different thresholds $p_\textrm{min}$. Detectors can be compared using their detection rates at the desired boundary of $FA<1\%$ (blue star). Corresponding classification matrix c) compared to distance matrix d) visualizes performance of this detector at $p_\textrm{min}=52.4\%$ with $D=47.3\%$ and $FA=0.8\%$. Orange areas represent loops and grey areas no loops. } \label{fig:detector_performance} \end{figure*} The test results can be illustrated in the form of two matrices. The classification matrix Fig.~\ref{fig:detector_performance}c), in which each node pair is examined by the detector for a loop, is compared with the distance matrix Fig.~\ref{fig:detector_performance}d). The latter represents the underlying ground truth, since all pairs with a distance less than 3m are treated as loop and the rest as negative pairs. The orange area on the diagonal represents the successive nodes that are close enough together. The off-diagonal orange area is the loop that is driven, since the robot returned to an old position at a later point in time and the nodes concerned are a short distance apart. For the trained detector, these matrices are roughly similar and all detected loops are located in areas where the pairs are not far away from each other. However, pairs with a distance minimally greater than the selected 3m are classified as positive as well. This does not pose a problem, as these loop closures are also desirable. \subsection{SLAM under Challenging Conditions}\label{val_slam} The presented method is furthermore validated in an experiment under challenging conditions. Since the introduced extension shall support the loop detection, we compare RTAB-Map extended with our work against the default operation. The extension is termed LL (LiDAR Loop). First, all required sensor data was recorded while driving. The evaluation was performed afterwards on a 2.60GHz Intel Core i7-4720HQ CPU with 8 GB of RAM running Linux, so that both methods had the same data available. Predicting with the detector takes on average 2ms and RTAB-Map's time threshold was set to 0.75s. Depending on the cloud sizes, registration of a loop pair takes 2s--10s. Due to the use of parallel threads, the longer time of registration is unproblematic. The parameters of our extension must be adjusted depending on the environment and robot and were chosen as follows: \begin{itemize} \item $r_\textrm{min}=t_\textrm{max}=3\textrm{m}\,$$\rightarrow\,$loop distance during training, \item $n_\textrm{p,max}=10,000$, $n_\textrm{p,min}=7,000$, $n_\textrm{inliers}=1,000$, \mbox{$i_\textrm{lim}=5$,} $z_\textrm{lim}=0.3\textrm{m}$, $r_\textrm{lim}=30\textrm{m}$, $l=0.03\textrm{m}\,$$\rightarrow\,$fast and robust scan registration, \item $n_\textrm{n,max}=200\,$$\rightarrow\,$many nodes during loop search and computation time less than RTAB-Map's time threshold, \item $\beta=0.25\,$$\rightarrow\,$reduces the increase of the search radius, \item $n_\textrm{v}=1\,$$\rightarrow\,$strict verification, \item $\alpha_\textrm{min}=0.5, n_\textrm{ms}=2, r_\textrm{ms}=5\textrm{m}, n_\textrm{start}=3\,$$\rightarrow\,$global loop search until localization is satisfactory. \end{itemize} According to odometry, the path for the outdoor map has a length of 423m and consists of 769 nodes. When mapping with RTAB-Map, there were 6 visual loop closures, compared to 15 loops closed with the extended method. The potential of the extension is already apparent in single session operation, as significantly more loops were detected. However, there are no major differences in terms of map quality. The main reason is the precise odometry used, which means that with such a path, a few loops are sufficient for an acceptable map quality. Due to similar maps, Fig.~\ref{fig:outdoor_experiments} presents only the map generated by RTAB-Map+LL with the corresponding nodes in orange. The added value becomes evident when taking the usual task of a mobile robot into account: \textit{map the environment and extend the map on another day}. The central requirement for such a multi-session operation is a successful localization in the old map. For this, the paths shown in Fig.~\ref{fig:outdoor_experiments} in light and dark blue were driven on another day at a different time. It was checked individually whether a localization succeeded or failed in the map generated with the respective method. Due to the dynamic environment, RTAB-Map did not detect any loops and, therefore, a localization for all of the five paths failed, preventing to extend the map. In contrast, with RTAB-Map+LL, a localization in the map of the old session was possible in four out of five paths, and the mapping could be continued. Loops were detected in the third path, but localization failed due to a wrong transformation matrix. The participating scans are from a location on the campus which has few descriptive elements except for a multitude of repetitive pillars. Due to the repetitiveness, pillars of one scan were registered with different pillars of the other scan, so that a translational error led to a mapping failure. To illustrate the environmental dynamics, Fig.~\ref{fig:outdoor_experiments} shows pictures of loop pairs successfully added in RTAB-Map+LL operation. A change in sunlight, switched on lights, a person in the picture and a different field of view are the reasons why the visual loop search of RTAB-Map failed. Only by observing the three-dimensional surrounding structure, a localization is still possible. Even if the robot travels to an already visited location with a different orientation and therefore the image comparison returns no match, loop detection succeeds due to the 360° view and the rotation invariant features used. \begin{figure}[tbp] \centerline{\includegraphics[width=\linewidth]{Abbildungen/outdoor_experiments.pdf}} \caption{Outdoor map with associated nodes (orange circles), five paths (light and dark blue) that were driven on another day and images of three exemplary loop pairs detected by RTAB-Map+LL.} \label{fig:outdoor_experiments} \end{figure} Similar experiments were conducted in two challenging indoor environments: an entrance hall with many glass fronts and an office environment with corridors. According to odometry, the mapping paths have a length of 196m and 299m respectively. Analogous to the outdoor experiment, three paths were driven at a different time in each environment. RTAB-Map operation realizes successful localization in two out of six paths, whereby in the respective areas, a change in sunlight has a small influence due to a large amount of artificial light. Using RTAB-Map+LL, a successful localization is present in all six cases. Combining the results of the indoor and outdoor validation, RTAB-Map realizes a successful localization in two out of eleven cases. In contrast to that, with the LiDAR extension it was possible to localize in ten out of eleven paths. \subsection{KITTI Dataset}\label{kitti_sec} Finally, our extension was evaluated with the widely used KITTI\cite{Geiger.2012b} odometry benchmark. We continued to use the detector trained in Sec.~\ref{det_perf}, so that the training data recorded in indoor and outdoor environments on our campus differs significantly from the test data acquired in road traffic. The sequences containing loops are mapped with our proposed extension using the RTAB-Map parameters for KITTI \cite{Labbe.2018b}. Odometry is calculated with the front stereo camera image sequences Frame-To-Map (F2M) wise. The following parameters of our package have been adjusted for the car and road traffic: $r_\textrm{min}=7.5\textrm{m}$, $r_\textrm{max}=50\textrm{m}$, $n_\textrm{v}=3$, $z_\textrm{lim}=1\textrm{m}$, \mbox{$l=0.2\textrm{m}$}, $t_\textrm{max}=10\textrm{m}$. Since the intensities of the point clouds were not given, we set $i_\textrm{lim}=0$. Our extended version of RTAB-Map is compared to the LiDAR-based approach LOAM \cite{zhang2017} which is currently ranked \#2 on KITTI's odometry leaderboard. Table \ref{tab:kitti} shows the results of the two methods using the average translational error as the performance metric. The number of visual and the number of additional LiDAR-based loop closures in RTAB-Map+LL operation are also included. The results show that the performance of our extension is comparable to LOAM. In four out of seven sequences, the error is lower with our method than with LOAM. For sequence 09, RTAB-Map+LL performs significantly worse. This can be explained by the small number of loop closures. Moreover, the potential of the LiDAR extension can be seen in sequence 08. Since the camera is oriented in the opposite direction when traversing back, preventing the detection of visual loops. By using LiDAR data, 30 loops can still be closed in this case. \begin{table}[t] \caption{Results for the KITTI odometry dataset. Average translational error in \%.} \input{kitti_loam.tex} \label{tab:kitti} \end{table} This experiment demonstrates the general applicability of our method. Despite large deviation between training and test environment, loops are still detected successfully. To improve loop detection in road traffic, training could be carried out directly with part of the KITTI data. In this case, the loop distance of 3m defined during training could also be increased, since detection is desired at greater distances on the road. \section{Conclusions}\label{conclusions} We presented a module to close loops based on laser scans to extend graph-based SLAM methods. By global description of a point cloud with rotation invariant features and a trained classifier, the question \textit{Have I been here before?} can be answered under challenging conditions, which is essential for the long-term autonomy of mobile robots. Experiments show that the classifier detects $47.3\%$ of loops with a small number of false positives which can be filtered out by verification. In dynamic environments, localization with RTAB-Map succeeded only in two out of eleven cases. A connection between all different sessions could be established using our extension. Except for a registration error, in ten out of eleven experiments, the localization succeeded. The potential of our module was also demonstrated by a validation on the KITTI dataset. Despite all the positive results, new tasks arise: Since registration can fail with many repeating elements, the acceptance of a calculated transformation should be further restricted, e.g. by considering the percentage of overlapping regions. Further, we will integrate the extension into a map management approach \cite{Ehlers.2020}. With different SLAM configurations, it would be possible to use a different classifier and registration parameters for a short range than for a long range environment. The main potential for improvement lies in the use of absolute positions using WiFi and GPS data. When starting multi-session operation instead of a loop search in the entire map, loops could be searched for directly in the local environment. \bibliographystyle{IEEEtran}
{'timestamp': '2021-05-13T02:17:42', 'yymm': '2103', 'arxiv_id': '2103.06713', 'language': 'en', 'url': 'https://arxiv.org/abs/2103.06713'}
arxiv
\section{Introduction} Graph matching aims to find an optimal one-to-one node correspondence between graph-structured data, which has been widely used in many tasks~\cite{berg2005shape,brendel2011learning,conte2004thirty,gasse2019exact,jiang2010linear,szeliski2010computer}. By integrating the similarity between nodes and edges in a combinatorial fashion, graph matching is often mathematically formulated as a quadratic assignment problem (QAP)~\cite{loiola2007survey}. QAP is known to be NP-hard~\cite{hartmanis1982computers}, and various approximation techniques~\cite{leordeanu2005spectral,leordeanu2009integer,liu2014graph,schellewald2001evaluation} have been proposed to make it computationally tractable. \begin{figure}[t!] \centering \subfigure[DGM {\em without} quadratic constraint]{ \includegraphics[height=0.25\linewidth, width=0.7\linewidth]{car_noQC.pdf} \includegraphics[height=0.25\linewidth]{car_noQC_mtx.pdf} }\\ \vspace{-3mm} \subfigure[DGM {\em with} quadratic constraint (our method)]{ \includegraphics[height=0.25\linewidth, width=0.7\linewidth]{car_QC.pdf} \includegraphics[height=0.25\linewidth]{car_QC_mtx.pdf} } \caption{Deep graph matching with/without quadratic constraint. Matching results are in left and the predicted (black) {\em v.s.} the ground truth (red) correspondence matrices are in right.} \vspace{-3mm} \label{fig:QC} \end{figure} \begin{figure*}[t] \centering \includegraphics[width=0.87\linewidth]{pipeline.pdf} \caption{Overview of our proposed architecture for deep graph matching under quadratic constraint. Node attributes consisting geometric prior and deep features are refined to build the initial node affinity matrix, which is followed by a Sinkhorn layer and then further optimized under quadratic constraint (QC). Loss between the prediction and the ground truth (GT) is calculated by the proposed false matching loss (FM-Loss).} \vspace{-3mm} \label{fig:overview} \end{figure*} Until recently, deep graph matching (DGM) methods give birth to many more flexible formulations~\cite{fey2020deep,rolinek2020deep,wang2019learning,yu2020learning} besides traditional QAP. DGM aims to learn the meaningful node affinity by using deep features extracted from convolutional neural network. To this end, many existing DGM methods~\cite{rolinek2020deep,wang2019learning,yu2020learning} primarily focus on the feature modeling and refinement for more accurate affinity construction. The feature refinement step is expected to capture the implicit structure information~\cite{wang2019learning} encoded in learnable parameters. However, nodes with similar deep features are hard to distinguish from each other in deep graph matching, while their structure contexts may be very different. Moreover, the implicit structure information is not specific enough, which is insufficient to clearly represent the structural discrepancy over graphs ({\em e.g.}, Fig.~\ref{fig:QC}(a)). In traditional graph matching, it is common to incorporate pairwise structures into the formulation to enhance matching accuracy~\cite{leordeanu2005spectral}, which inspired us to consider quadratic structural constraint in deep graph matching to maximize the adjacency consensus and achieve global consistency. More precisely, we use the pairwise term of Koopmans-Beckmann’s QAP~\cite{loiola2007survey} as our quadratic constraint to minimize the adjacency discrepancy of graphs to be matched ({\em e.g.}, Fig.~\ref{fig:QC}(b)). To this end, we present a modified Frank-Wolfe algorithm~\cite{lacoste2015global}, which is a differentiable optimization scheme {\em w.r.t.} learnable parameters in our model and the relaxed Koopmans-Beckmann’s QAP. Another important issue of deep graph matching is class imbalance. Concretely, the result of a graph matching task is usually represented as a permutation matrix, where only a small portion of the entries take the value of one representing the pairs to be matched while the rest are zero-valued, leading to the imbalance between matched and unmatched entries. In case of such class imbalance, it will be problematic to establish the loss function between predicted matching matrices and ground truth matrices by using the conventional cross-entropy-type loss functions (see Section~\ref{subsec:fmloss} for details). To our best knowledge, there is no loss function specifically designed for deep graph matching to take care of the class imbalance issue so far. To this end, we design a novel loss function for deep graph matching, called False Matching Loss, which will be experimentally shown to be better for dealing with class imbalance and overfitting in compared with previous works. Our main contributions are highlighted as follows: \begin{itemize} \item[-] We explicitly introduce quadratic constraint with our constructed geometric structure into deep graph matching, which can further revise wrong matches by minimizing structure discrepancy over graphs. \item[-] We present a differentiable optimization scheme in training to approach the objective such that it is compatible with the unconstrained deep learning optimizer. \item[-] We propose a novel loss function focusing on false matchings, {\em i.e.} false negatives and false positives, to better lead the parameter update against class imbalance and overfitting. \end{itemize} \section{Preliminaries and Related Work} For better understanding, this section will revisit some preliminaries and related works on both traditional combinatorial graph matching and deep graph matching. \subsection{Combinatorial graph matching} Graph matching aims to build the node-to-node correspondence between the given two graphs $\mathcal{G}_A = \{V_A, E_A\}$ with $|V_A|=n$ and $\mathcal{G}_B = \{V_B, E_B\}$ with $|V_B|=m$, where $V$ we denote as the set of nodes and $E$ as the set of edges. By denoting $\mathbf{X}$ as the correspondence matrix indicating the matching between two graphs $\mathcal{G}_A$ and $\mathcal{G}_B$, {\em i.e.}, $X_{ij}=1$ means the $i$-th node in $V_A$ matches to the $j$-th node in $V_B$, $X_{ij}=0$ otherwise, one well-known form of graph matching with combinatorial nature can be written as: \begin{align} \label{eq:KBQAP} \min_{\mathbf{X}}\quad ||\mathbf{A}-\mathbf{XBX}^T||^2_F-{\rm tr}(\mathbf{X}^T_u\mathbf{X})\\ \mathbf{X}\in\{0,1\}^{n\times m}, \mathbf{X1}_{n}=\mathbf{1}_{m}, \mathbf{X}^T\mathbf{1}_{n}\leq\mathbf{1}_{n} \nonumber \end{align} where $\mathbf{A}\in \mathbb{R}^{n\times n}$, $\mathbf{B}\in \mathbb{R}^{m\times m}$ are adjacency matrices encoding the pairwise information of edges in graphs $\mathcal{G}_A$ and $\mathcal{G}_B$, respectively. $\mathbf{X}_u\in\mathbb{R}^{n\times m}$ measures the node similarities between two graphs. $||\cdot||_F$ is the Frobenius norm. Generally, Eq.~\eqref{eq:KBQAP} can be cast as a quadratic assignment problem called Koopmans-Beckmann's QAP~\cite{loiola2007survey}. One can find more details in \cite{yan2016short}. In the previous works \cite{gold1996graduated,wfd2020frgm,zhou2015factorized} following this combinatorial graph matching formulation, the node similarity $\mathbf{X}_u$ and adjacency matrices $\mathbf{A},\mathbf{B}$ are usually calculated with some specifically designed handcrafted features like SIFT \cite{lowe2004distinctive}, Shape Context \cite{belongie2002shape}, {\em etc}. And then they will solve the objective functions ({\em e.g.}, Eq.~\eqref{eq:KBQAP}) with different discrete or continuous constrained-optimization algorithms \cite{cho2014finding,wfd2020frgm,egozi2012probabilistic,yan2015discrete}. Until recently, the deep learning based graph matching framework has been developed consisting of learned features and unconstrained optimizer, which will be detailed in next section. \subsection{Deep graph matching} $\textbf{Feature extraction.}$ Recently, many works~\cite{fey2020deep,wang2019learning,wang2020combinatorial,yu2020learning,rolinek2020deep} on deep graph matching have been proposed to take advantages of the descriptive capability of high-dimensional deep features as node or edge attributes, which can collect visual information of background images. As a basic setting of these works, the output of CNN layers ${\rm relu4\_2}$ and ${\rm relu5\_1}$ are commonly used, denoted as $\mathbf{U}\in\mathbb{R}^{n\times d}$ and $\mathbf{F}\in\mathbb{R}^{n\times d}$, \begin{align} \label{eq:ftU} \textbf{U} &={\rm align}({\rm CNN_{relu4\_2}}(I), V) \\ \label{eq:ftF} \textbf{F} &={\rm align}({\rm CNN_{relu5\_1}}(I), V) \end{align} where $I$ denotes the input image and $V$ denotes the annotated keypoints. CNN here is a widely used architecture VGG16~\cite{simonyan2014very} initially pretrained on the ImageNet~\cite{russakovsky2015imagenet}. "align" in Eq.~\eqref{eq:ftU} and Eq.~\eqref{eq:ftF} is bi-linear interpolation to approximately assign the output features of a convolution layer to the annotated keypoints on the input image pairs. $\textbf{Feature modeling and refinement.}$ Since the extracted raw features are independent with the graph structure, various refinement strategies on the raw features are adopted in deep graph matching trying to implicitly utilize the information of graph structure. As a typical example of non-Euclidean data, a graph with its node and edge attributes can be processed by graph convolutional network (GCN)~\cite{kipf2016semi} under the message passing scheme to update its attributes. Each node attribute is updated by aggregating its adjacency node attributes so that GCN is expected to implicitly capture the structure contexts of each node to some extent. There are also some works~\cite{rolinek2020deep,yu2020learning} using unary node features to model pairwise edge features for matching. $\textbf{Differentiable optimization.}$ Deep graph matching asks for the model fully-differentiable so that many combinatorial solvers and methods ({\em e.g.}, Hungarian algorithm~\cite{kuhn1955hungarian} and IPFP~\cite{leordeanu2009integer}) are not recommended. Thus, various relaxation approaches become popular, which refer to the recent progress~\cite{rolinek2020deep,wang2019learning,wang2020learning}. Under these settings, deep graph matching can be reformulated as maximizing the node affinity based on the extracted features. $\textbf{Loss function for deep graph matching.}$ Though many works about deep graph matching have been proposed, there are few thorough discussions about loss functions. The prototype of cross entropy loss has been widely used in deep graph matching, {\em e.g.} permutation loss~\cite{wang2019learning} and its improved version~\cite{yu2020learning}. Instead of directly calculating the linear assignment cost, GMN~\cite{zanfir2018deep} uses ``displacement loss" measuring pixel-wise offset on the image but is shown to have a weaker supervision than cross entropy loss~\cite{wang2019learning}. However, none of the existing works consider the class imbalance that naturally exists in deep graph matching. Besides, overfitting and gradient explosion are always conspicuous on models trained with cross-entropy-type loss functions. For the above reasons, we propose a novel loss function specifically designed for deep graph matching, which not only considers numerical issue but also shows promising performance against overfitting and class imbalance. \section{DGM under Quadratic Constraint} We briefly demonstrate our method overview here. As shown in Fig.~\ref{fig:overview}, given the input two images with detected or annotated keypoints as graph nodes, we firstly adopt the CNN features and the coordinates of keypoints to calculate both the initial node attributes and the pairwise structural context as weighted adjacency matrices. By this end, we establish graphs with structural attributes, based on which we explicitly use the weighted adjacency matrices to construct the quadratic constraint, and design a differentiable constrained-optimization algorithm to achieve compatibility with the deep learning optimizer. Since the quadratic constrained-optimization is non-convex and needs a proper initialization, we update the node attributes with weighted adjacency matrices through a GCN module and a differentiable Sinkhorn layer~\cite{adams2011ranking,sinkhorn1967concerning} respectively, to obtain a node affinity matrix between two graphs as the initialization. Finally, the solved optimum will be compared with the ground truth by the proposed false matching loss, which addresses the issue of class imbalance to achieve better performance. \subsection{Geometric structure for DGM} {\bf{Unary geometric prior} } Since our work doesn't focus on deep feature extraction, we follow the previous deep graph matching works to use CNN features described in Eq.~\eqref{eq:ftU} and Eq.~\eqref{eq:ftF}. Moreover, features from different layers of CNN are expected to incorporate both the local and global semantic information of images, we concatenate $\mathbf{U}$ and $\mathbf{F}$ together as $\mathbf{P}_r={\rm cat}(\mathbf{U};\mathbf{F})$ to be the initial node attributes of two graphs. Since the extracted raw features associated to nodes only have visual information of local patches, to make raw node attributes more discriminative, we add the the normalized 2D Cartesian coordinate $[\hat{\mathbf{x}},\hat{\mathbf{y}}]$ of each node as $\mathbf{P}={\rm cat}(\mathbf{P}_r;[\hat{\mathbf{x}},\hat{\mathbf{y}}])$, which provides a unary geometric prior that can better describe the locations of nodes as a complement to the CNN features. {\bf{Pairwise structural context} } In deep graph matching, the graph construction is usually based on node coordinates and never consider the visual meaningful features of the background image. For this reason, we introduce deep feature weighted adjacency matrices $\mathbf{A}_D$ and $\mathbf{B}_D$ of the two graphs to learn more proper relations among graph nodes, which are defined as \begin{equation} \label{eq:adj} \mathbf{A}_D=f(\mathbf{P_A})\odot\mathbf{A}, \quad \mathbf{B}_D=f(\mathbf{P_B})\odot\mathbf{B} \end{equation} where $\mathbf{A}\in\mathbb{R}^{n\times n},\mathbf{B}\in\mathbb{R}^{m\times m}$ are the binary adjacency matrices built on coordinates of nodes in two graphs, $\mathbf{P}_A\in\mathbb{R}^{n\times (d+2)},\mathbf{P}_B\in\mathbb{R}^{m\times (d+2)}$ are the above-mentioned node attributes of two graphs, $\odot$ denotes element-wise product. $f(\mathbf{P})$ can be various commutative function and here we use a linear kernel $f_{i,j}=\mathbf{p}^T_i\mathbf{p}_j$ for simplicity, where $\mathbf{p}_i$ is the $i$-th row of $\mathbf{P}$. As illustrated in Fig.~\ref{fig:cosine}, the geometric meaning of the function $f$ is related to the cosine of the angle between two normalized node attributes, which can be detailed as cos$\theta_{ij}=\frac{\left<\mathbf{p}_i,\mathbf{p}_j\right>}{|\mathbf{p}_i||\mathbf{p}_j|}=\frac{1}{\sqrt{3}}\frac{1}{\sqrt{3}}\left<\mathbf{p}_i,\mathbf{p}_j\right>=\frac{1}{3}\mathbf{p}^T_i\mathbf{p}_j$. By this definition, each element of $\mathbf{A}_D$ and $\mathbf{B}_D$ represents the feature distance between the corresponding nodes while preserving the topology constraints provided by $\mathbf{A}$ and $\mathbf{B}$. \begin{figure}[t] \centering \includegraphics[width=0.9\linewidth]{cosine.pdf} \caption{Illustration of the geometric relationship between two nodes and their edge connection in attribute space. Normalized attributes of nodes are represented as coloured squares.} \label{fig:cosine} \vspace{-3mm} \end{figure} {\textbf{Attributes fusion with GCN} } There are many convolutional architectures~\cite{fey2018splinecnn,zhou2018graph} for processing irregular data. As a typical example of non-Euclidean data, a graph with its node and edge attributes can be processed by GCN under the message passing scheme to update its attributes. Each node attribute is updated by aggregating its adjacency node attributes so that GCN is expected to capture the structure contexts of each node in an implicit way. With the above interpretation, we adopt GCN that incorporates both update from neighbors and self-update, which can be written as: \begin{equation} \label{eq:GCN} \textbf{P}^{l+1}=\sigma(\textbf{A}_D\textbf{P}^l\textbf{W}^l_r+\textbf{P}^l\textbf{W}^l_s) \end{equation} where $\mathbf{W}^l_r,\mathbf{W}^l_s\in\mathbb{R}^{(d+2)\times(d+2)}$ denote learnable parameters of GCN at $l$-th layer. $\sigma$ is the activation function. The updated attributes $\mathbf{P}^{l+1}$ is then used to update $\mathbf{A}_D$ and $\mathbf{B}_D$ by Eq.~\eqref{eq:adj}. {\bf{Node affinity} } Since we have the refined attributes of two graphs, the node affinity $\mathbf{K}^l_p\in\mathbb{R}^{n_A\times n_B}$ at $l$-th iteration can be built by a learnable metric: \begin{equation} \label{eq:affinity} \mathbf{K}^l_p={\rm exp}\{{\mathbf{P}^l_A\textbf{W}^l_{{\rm aff}}{\mathbf{P}^l_B}^T}\} \end{equation} where $\mathbf{W}^l_{{\rm aff}}$ is a matrix containing learnable parameters. We then adopt Sinkhorn layer taking $\mathbf{K}^l_p$ to the set of doubly-stochastic matrices $\mathcal{D}$, which is the convex hull of the set of permutation matrices $\mathcal{P}$. \subsection{Quadratic constraint for DGM} To explicitly utilize the information of graph structures, we formulate the objective as to minimize the pairwise structure discrepancy between the graphs to be matched. As Eq.~\eqref{eq:KBQAP}, Koopmans-Beckmann’s QAP explicitly involves the second-order geometric context in its pairwise term and the optimal solution will minimize the two terms simultaneously. The learnable metric $\mathbf{K}^l_p$ we obtained from Eq.~\eqref{eq:affinity} is considered as the initial point of $\mathbf{X}$, {\em i.e.}, $\mathbf{X}_0=\mathbf{K}^l_p$. We rewrite Eq.~\eqref{eq:KBQAP} as: \begin{equation} \label{eq:obj} \min_{\mathbf{X}}g(\mathbf{X})=\min_{\mathbf{X}} ||\mathbf{A}_D-\mathbf{X}\mathbf{B}_D\mathbf{X}^T||^2_F-{\rm tr}({\mathbf{X}_u}^T\mathbf{X}) \end{equation} \begin{algorithm}[t!] \label{alg1} \caption{DGM under Quadratic Constraint} \KwIn{Nodes of graph pairs $V_s$; two input images $I_s$, where $s$=A, B; the ground truth $\mathbf{X}^*$; initial parameters $\mathbf{W}=\{\mathbf{W}^l_r,\mathbf{W}^l_s,\mathbf{W}^l_{aff}\}$} \KwOut{prediction $\mathbf{X}_P\in\mathcal{P}$} //feature extraction and alignment\\ $\mathbf{U}_s ~\gets \text{align}(\text{CNN}_{{\text{relu4}}\_2}(I_s), V_s)$;\\ $\mathbf{F}_s ~\gets \text{align}(\text{CNN}_{{\text{relu5}}\_1}(I_s), V_s)$;\\ //node attributes\\ $\mathbf{P}_s$ $\gets$ ${\rm cat}(\mathbf{U}_s;\mathbf{F}_s;[\hat{\mathbf{x}}_s,\hat{\mathbf{y}}_s])$;\\ $\textbf{Training stage}:$\\ \For{{\rm epoch $k\leq n$}}{ $\mathbf{P}^{l}_s$ $\gets$ ${\rm GCN}((\mathbf{A}_D)_s,\mathbf{P}^{l-1}_s)$;\\ ($\mathbf{A}^{l}_D)_s$ $\gets$ $f(\mathbf{P}^l_s)\odot \mathbf{A}_s$;\\ $\mathbf{K}^l_p$ $\gets$ ${\rm exp}\{\mathbf{P}^l_A\mathbf{W}^l_{{\rm aff}}{\mathbf{P}^l_B}^T\}$;\\ $\mathbf{X}$ $\gets$ $\mathbf{K}^l_p$;\\ \For{{\rm iter = 1:$m_1$}}{ \For{{\rm k = 1:$m_2$}}{$\noindent$ $\mathbf{y}$ $\gets$ $\arg\min\limits_{\mathbf{y}}\nabla g(\mathbf{X})^T\mathbf{y}$;\\ //$f_{\mathcal{D}}$ is Sinkhorn normalization\\ $\mathbf{s}$ $\gets$ $f_{\mathcal{D}}(\mathbf{y})$;\\ $\overline{\mathbf{X}}$ $\gets$ $\mathbf{X} - \epsilon_k(\mathbf{X} - \mathbf{s})$; } $\mathbf{X}$ $\gets$ $f_{\mathcal{D}}(\overline{\mathbf{X}})$; } $\mathbf{W}$ $\gets$ $L_{fm}$($\mathbf{X}$, $\mathbf{X}^{\rm GT}$), $\mathbf{W}$; } $\textbf{Inference stage}:$\\ $\mathbf{X}_P$ $\gets$ $\mathbf{X}$;\\ \For{{\rm iter = 1:m}}{ \Repeat {{\rm $\mathbf{X}_P$ converges}}{$\noindent$ $\mathbf{y}$ $\gets$ $\arg\min\limits_{\mathbf{y}}\nabla g(\mathbf{X}_P)^T\mathbf{y}$;\\ //$f_{\mathcal{P}}$ is Hungarian algorithm\\ $\mathbf{s}$ $\gets$ $f_{\mathcal{P}}(\mathbf{y})$;\\ $\overline{\mathbf{X}}_{P}$ $\gets$ $\mathbf{X}_P - \epsilon_k(\mathbf{X}_P - \mathbf{s})$;} $\mathbf{X}_{P}$ $\gets$ $f_{\mathcal{P}}(\overline{\mathbf{X}}_{P})$;} \end{algorithm} We specify unary affinity matrix $\mathbf{X}_u$ as the obtained node affinity matrix $\mathbf{K}^l_p$ in both the training stage and the inference stage. Due to the paradox between the combinatorial nature of QAP formulation and the differentiable requirement of deep learning framework, we consider a relaxed version of Eq.~\eqref{eq:obj}: $\mathbf{X}\in[0,1]^{n_A\times n_B}, \mathbf{X1}_{n_B}=1, \mathbf{X}^T\mathbf{1}_{n_A}\leq\mathbf{1}_{n_A}$. The value of $\mathbf{X}$ is continuous and satisfies normalization constraints at the same time. By minimizing the objective function, the solution will close to the ground truth in the direction of minimizing the adjacency inconsistency. \subsection{Quadratic constrained-optimization} We adopt a differentiable Frank-Wolfe algorithm~\cite{lacoste2015global} for $g(\mathbf{X})$ to obtain an approximate solution: \begin{align} \label{eq:yk} \mathbf y_k &= \arg \min_{\mathbf y} \nabla g(\mathbf{X}_k)^T \mathbf y \\ \label{eq:s} \mathbf s &= f_{proj}(\mathbf y_k) \\ \label{eq:xhat} \bar{\mathbf X}_{k+1} &= \mathbf{X}_k - \epsilon_k(\mathbf{X}_k - \mathbf s) \\ \label{eq:x} \mathbf{X}_{k+1} &= f_{proj}(\bar{\mathbf{X}}_{k+1}) \end{align} where $\epsilon_k$ is a parameter representing the step size. Usually, we set $\epsilon_k=\frac {2} {k+2}$~\cite{jaggi2013revisiting} in implementation. In training stage, $f_{proj}$ in Eq.~\eqref{eq:s} and Eq.~\eqref{eq:x} is the Sinkhorn layer to project the positive variable into the set of doubly stochastic matrices $\mathcal{D}$, while $f_{proj}$ is the Hungarian algorithm in the inference stage for obtaining a discrete solution. We write down the gradient of $g(\mathbf{X})$ as: \begin{equation} \label{eq:gradient} \nabla g\left(\mathbf{X}\right)=-2[\mathbf{U}^T\mathbf{XB}^l_D+\mathbf{U}{\mathbf{XB}^l_D}^T]-\mathbf{X}_u \end{equation} where $\mathbf{U}=\mathbf{A}^l_D-\mathbf{XB}^l_D\mathbf{X}^T$. In training stage, the variable $\mathbf{X}$ is associated with the learnable parameters $\mathbf{W}=\{\mathbf{W}^l_r,\mathbf{W}^l_s,\mathbf{W}^l_{aff}\}$ and every iteration of Frank-Wolfe algorithm is actually going with the parameters fixed before backpropagation~\cite{ionescu2015training}. From Eq.~\eqref{eq:xhat} and Eq.~\eqref{eq:x}, $\mathbf{X}_{k+1}$ is differentiable with respect to $\mathbf{X}_{k}$ so $\mathbf{X}_{k+1}$ is differentiable with respect to $\mathbf{X}_0=\mathbf{K}^l_{p}$ by the recursive relations: \begin{align} \label{eq:iter} \mathbf{X}_{k+1}=f_r(\mathbf{X}_k)=f_r\circ f_r(\mathbf{X}_{k-1})=...=f_r^k(\mathbf{X}_0) \end{align} where $f_r(\mathbf{X})\triangleq f_{proj}(\mathbf{X}-\epsilon_k(\mathbf{X}-\mathbf{s}))$ is a differentiable function {\em w.r.t.} $\mathbf{X}$ in training stage. Since the goal of the optimization is to utilize the information of the pairwise term in Eq.~\eqref{eq:obj}, only few iterations roughly approaching to a local minimum in training stage can fulfill our purpose. Though there is no guarantee of global minimum, it is actually not necessary because the pairwise term will be noisy with outliers and the global minimum may not be the desired matching. Besides, few iterations in training stage encourage the model to learn a relatively short path to approximate the object so that it is easier to convergence within fewer iterations in inference stage. \iffalse Though deep graph matching framework can extract CNN features for matching rather than handcrafted attributes as in traditional QAP formulation, there are two main reasons why CNN features along are not enough for graph matching. Firstly because the spatial resolution of feature map on high level convolution layer is not the same as input image and the features from CNN layers will only be interpolated to the graph nodes as approximation. Secondly because the nodes with similar local patches have the similar CNN features while their structure context may be very different. Although some works~\cite{fey2020deep,rolinek2020deep,yu2020learning} explicitly consider the learned or handcrafted pairwise features as a complement to the unary node features, the problems about CNN features mentioned above can not be avoid. Besides, the refinement step of using GCN is also a compromise because it is essentially a smooth operation over neighbor features of each node and can incorporate the information of graph structure only to a limit extent. Thus far, none of the above parts explicitly involve the structure constraint to maximize the adjacency consensus or minimize the adjacency inconsistency. \fi \subsection{False-matching loss} \label{subsec:fmloss} $\textbf{Class imbalance.}$ The elements of correspondence matrix can be divided into two classes with clear different meaning, one of which represents matched pairs and the other represents unmatched pairs. Given two graphs with equal number of nodes $n$, there are $n$ elements of correspondence matrix are 1 while the rest $n^2-n$ are 0. Under the constraint of one-to-one matching, the unmatched pairs clearly take the majority. Though the values of the soft correspondence matrix are all between 0 and 1, the two classes should be separately treated in the calculation of loss during training. The cross-entropy-type loss functions such as permutation loss~\cite{wang2019learning} and its improved version~\cite{yu2020learning} achieve the state-of-the-art performance. This type of loss functions directly measures the linear assignment cost between the ground truth $\mathbf{X}^*\in\{0,1\}^{n\times n}$ and the prediction $\mathbf{X}\in[0,1]^{n\times n}$ like \begin{align} \label{eq:ce} L_{ce}=-\sum_{i, j}\mathbf{X}^*_{ij} \log \mathbf{X}_{ij}+(1-\mathbf{X}^*_{ij}) \log (1-\mathbf{X}_{ij}) \end{align} with $i\in\mathcal{G}_A$, $j\in\mathcal{G}_B$. Cross entropy loss does not consider the class imbalance in deep graph matching because the vast majority of $\mathbf{1-X}$ are preserved by multiplying $\mathbf{1-X^*}$ while at most $n$ elements of $\mathbf{X}$ are kept by multiplying $\mathbf{X^*}$. Similarly, cross entropy loss with Hungarian attention~\cite{yu2020learning} can not solve this issue either and the so called Hungarian attention in loss function brings discontinuity in learning. \begin{figure}[t!] \begin{center} \includegraphics[width=1\linewidth]{fmloss.pdf} \end{center} \caption{An illustration of the work flow about our proposed false matching loss. We take both the false positive and false negative of the predicted doubly stochastic matrix into consideration. $\alpha$ and $\beta$ are two parameters to weight the two terms.} \label{fig:inner} \vspace{-3mm} \end{figure} $\textbf{Numerical stability.}$ Since the optimization of deep learning is unconstraint, the local minimum with bad properties can not be avoid. Once a bad case or a bad local minimum occurs, {\em e.g.} at least one element of the prediction $\mathbf{X}$ approaches to 0 while the corresponding element of the ground truth $\mathbf{X}^*$ is 1, the cross-entropy-type loss will be invalid. Though permutation loss with Hungarian attention mechanism is more focus on a specific portion of the prediction $\mathbf{X}$, it only works without severe bad cases either. Even with gradient clipping, overfitting is still a problem to be addressed. \begin{figure}[t] \centering \subfigure[cross entropy loss $L_{ce}$]{ \begin{minipage}[t]{0.5\linewidth} \centering \includegraphics[width=1.7in]{cross_entropy.pdf} \end{minipage}% }% \subfigure[false matching loss $L_{fm}$]{ \begin{minipage}[t]{0.5\linewidth} \centering \includegraphics[width=1.7in]{false_matching.pdf} \end{minipage}% }% \centering \caption{Comparison between cross entropy loss and false matching loss on a toy example, where $\mathbf{X}\in\mathbb{R}^{1\times 3}$ and $\mathbf{X}^*=(0,0,1)$. We mark the three extreme points of $\mathbf{X}$: $\mathbf{A}=(0,0,1)$, $\mathbf{B}=(0,1,0)$ and $\mathbf{C}=(1,0,0)$. A cooler color means a smaller value. The comparison shows that false matching loss has a higher value than cross entropy loss when it close to the ground truth. Besides, false matching loss has a high but limited value when $\mathbf{X}$ close to the extreme points, which are the bad cases for cross entropy loss and make the loss function output infinite values. The curve of cross entropy loss on points between $\mathbf{B}$ and $\mathbf{C}$ are below the red line connected to $\mathbf{B}$ and $\mathbf{C}$, while the curve of false matching loss coincides with the red line.} \label{fig:innercross} \vspace{-2mm} \end{figure} Facing the problems above, we propose a new loss function called false matching loss: \begin{align} \label{eq:fm} L_{fm} =\underbrace{e^{\alpha\sum_{i,j}\left[\mathbf{X}\odot(\mathbf{1}-\mathbf{X}^*)\right]_{ij}}}_{L_+} + \underbrace{e^{\beta\sum_{i,j}\left[\mathbf{X}^*\odot(\mathbf{1}-\mathbf{X})\right]_{ij}}}_{L_-} \end{align} where $i\in\mathcal{G}_A$, $j\in\mathcal{G}_B $. $L_+$ and $L_-$ of our false matching loss penalize false positive matches and false negative matches, which are the main indexes describing the false matchings in statistics. To address the issue of class imbalance, we draw on the experience of focal loss~\cite{lin2017focal} and take two hyperparameters $\alpha$ and $\beta$ for weighting. As illustrated in Fig.~\ref{fig:innercross}, false matching loss is more smooth and always has a relatively large value than cross entropy loss even when the prediction $\mathbf{X}$ is close to the ground truth. While on extreme points that are away from the ground truth, false matching loss will have more proper outputs (high but limited). Besides, the values of cross entropy loss on points between $\mathbf{B}$ and $\mathbf{C}$ are lower than that on $\mathbf{B}$ and $\mathbf{C}$, which is not proper because points between $\mathbf{B}$ and $\mathbf{C}$ are still far away from the ground truth. Our method is summarized in Algorithm~\ref{alg1}. \section{Experiments and Analysis} In this section, we evaluate our method on two challenging datasets. We compare the proposed method with several state-of-the-art deep graph matching methods: GLMNet~\cite{jiang2019glmnet}, PCA~\cite{wang2019learning}, NGM~\cite{wang2019neural}, ${\rm CIE_1}$~\cite{yu2020learning}, GMN~\cite{zanfir2018deep}, LCSGM~\cite{wang2020learning} and BB-GM~\cite{rolinek2020deep}. To compare the proposed false matching loss with the previous work: permutation loss with Hungarian attention~\cite{yu2020learning}, we follow~\cite{yu2020learning} to implement the loss function for the source code is not publicly available. Given graphs with $n$ nodes, the matching accuracy is computed as \begin{align} {\rm accuracy}=\frac{1}{n}\sum_{i,j}[\mathbf{X}^*\odot {\rm Hungarian}(\mathbf{X})]_{ij} \end{align} Stochastic gradient descent (SGD)~\cite{bottou2010large} is employed as the optimizer with an initial learning rate $10^{-3}$. In our false matching loss, we set $\alpha=2$ and $\beta=0.1$. In our optimization step, we set the number of iterations $m_1=3$ and $m_2=5$ for the consideration of both computational efficiency and convergence. Since the feature refinement step is not limited to Eq.~\eqref{eq:GCN}, we additionally deploy another novel architecture SplineCNN~\cite{fey2018splinecnn} to replace Eq.~\eqref{eq:GCN} as a comparision with~\cite{rolinek2020deep}. Thus, two versions of our method are provided: qc-DG${\rm M}_1$ and qc-DG${\rm M}_2$. In qc-DG${\rm M}_1$, the node attributes are refined by a two-layer GCN as Eq.~\eqref{eq:GCN} with ReLU~\cite{nair2010rectified} activation function. While in qc-DG${\rm M}_2$, the refinement step is done by a two-layer SplineCNN~\cite{fey2018splinecnn} with max aggregation. In our implementation, all the input graphs are constructed by Delaunay triangulation. Specifically for GMN~\cite{zanfir2018deep}, two input graphs are constructed by fully-connected topology and Delaunay triangulation respectively. While ${\rm GMN_D}$ is another version of GMN that two input graphs are both constructed by Delaunay triangulation. \subsection{Results on Pascal VOC Keypoints} Pascal VOC dataset~\cite{everingham2010pascal} with Berkeley annotations of keypoints~\cite{bourdev2009poselets} has 20 classes of instance images with annotated keypoints. There are 7,020 annotated images for training and 1,682 for testing. Before training, each instance is cropped around its bounding box and is re-scaled to $256\times 256$ as the input for VGG16. We follow the previous works to filter the truncated, occluded and difficult images. The training process will be performed on all 20 classes. Because of the large variation of pose, scale, and appearance, Pascal VOC Keypoints is considerably a challenging dataset. \begin{table*}[t!] \begin{center} \resizebox{\textwidth}{!}{ \begin{tabular}{c | cccccccccccccccccccc | c} \toprule \noalign{\smallskip} Method & aero & bike & bird & boat & bottle & bus & car & cat & chair & cow & table & dog & horse & mbike & person & plant & sheep & sofa & train & tv & Mean\\ \noalign{\smallskip} \midrule \noalign{\smallskip} GMN~\cite{zanfir2018deep} & 35.5 & 50.0 & 52.2 & 45.2 & 75.5 & 69.1 & 59.0 & 61.1 & 34.4 & 51.9 & 66.4 & 53.4 & 53.9 & 50.7 & 31.1 & 75.8 & 59.2 & 47.9 & 86.1 & 89.6 & 57.4 \\ ${\rm GMN_D}$~\cite{zanfir2018deep} & 40.8 & 57.1 & 56.2 & 48.2 & 75.5 & 71.6 & 64.1 & 63.3 & 36.3 & 54.3 & 50.2 & 57.6 & 60.3 & 55.4 & 35.5 & 85.2 & 62.7 & 51.8 & 86.5 & 87.4 & 60.0\\ qc-GMN & 37.3 & 52.2 & 54.3 & 47.2 & 76.4 & 70.4 & 61.2 & 61.7 & 34.5 & 53.1 & 69.1 & 55.4 & 56.0 & 52.4 & 31.6 & 77.3 & 59.7 & 49.1 & 87.4 & 89.7 & 58.8 \\ PCA~\cite{wang2019learning} & 40.9 & 55.0 & 65.8 & 47.9 & 76.9 & 77.9 & 63.5 & 67.4 & 33.7 & 66.5 & 63.6 & 61.3 & 58.9 & 62.8 & 44.9 & 77.5 & 67.4 & 57.5 & 86.7 & 90.9 & 63.8 \\ qc-PCA & 42.5 & 58.5 & 66.1 & 51.3 & 79.6 & 78.2 & 65.8 & 68.7 & 35.1 & 66.8 & 65.6 & 62.5 & 62.1 & 63.1 & 45.1 & 80.7 & 67.7 & 59.1 & 87.0 & 91.1 & 64.8\\ PCA-H~\cite{wang2019learning} & 50.8 & 61.7 & 62.6 & 56.4 & 80.0 & 75.6 & 72.4 & 74.0 & 38.5 & 64.3 & 49.9 & 63.8 & 65.2 & 63.5 & 46.0 & 78.5 & 68.0 & 41.5 & 82.2 & 90.8 & 64.3 \\ PCA-F & 50.0 & 66.7 & 61.8 & 55.1 & 81.5 & 75.5 & 70.1 & 70.4 & 39.7 & 64.8 & 60.3 & 65.5 & 67.6 & 64.2 & 45.6 & 84.4 & 68.6 & 56.5 & 88.7 & 91.1 & 66.3 \\ NGM~\cite{wang2019neural} & 50.8 & 64.5 & 59.5 & 57.6 & 79.4 & 76.9 & 74.4 & 69.9 & 41.5 & 62.3 & 68.5 & 62.2 & 62.4 & 64.7 & 47.8 & 78.7 & 66.0 & 63.3 & 81.4 & 89.6 & 66.1 \\ GLMNet~\cite{jiang2019glmnet} & $\bf{52.0}$ & 67.3 & 63.2 & 57.4 & 80.3 & 74.6 & 70.0 & 72.6 & 38.9 & 66.3 & $\bf{77.3}$ & 65.7 & 67.9 & 64.2 & 44.8 & 86.3 & 69.0 & 61.9 & 79.3 & 91.3 & 67.5 \\ LCSGM~\cite{wang2020learning} & 46.9 & 58.0 & 63.6 & $\bf{69.9}$ & $\bf{87.8}$ & 79.8 & 71.8 & 60.3 & $\bf{44.8}$ & 64.3 & 79.4 & 57.5 & 64.4 & 57.6 & $\bf{52.4}$ & $\bf{96.1}$ & 62.9 & 65.8 & $\bf{94.4}$ & 92.0 & 68.5\\ ${\rm CIE_1}$-H~\cite{yu2020learning} & 51.2 & $\bf{69.2}$ & $\bf{70.1}$ & 55.0 & 82.8 & 72.8 & 69.0 & $\bf{74.2}$ & 39.6 & 68.8 & 71.8 & $\bf{70.0}$ & $\bf{71.8}$ & 66.8 & 44.8 & 85.2 & $\bf{69.9}$ & 65.4 & 85.2 & $\bf{92.4}$ & 68.9\\ \noalign{\smallskip} \midrule \noalign{\smallskip} qc-DG${\rm M}_1$(ours) & 48.4 & 61.6 & 65.3 & 61.3 & 82.4 & 79.6 & 74.3 & 72.0 & 41.8 & $\bf{68.8}$ & 65.0 & 66.1 & 70.9 & 69.6 & 48.2 & 92.1 & 69.0 & 66.7 & 90.4 & 91.8 & 69.3 \\ qc-DG${\rm M}_2$(ours) & 49.6 & 64.6 & 67.1 & 62.4 & 82.1 & $\bf{79.9}$ & $\bf{74.8}$ & 73.5 & 43.0 & 68.4 & 66.5 & 67.2 & 71.4 & $\bf{70.1}$ & 48.6 & 92.4 & 69.2 & $\bf{70.9}$ & 90.9 & 92.0 & $\bf{70.3}$ \\ \noalign{\smallskip} \bottomrule \end{tabular}} \end{center} \vspace{-3mm} \caption{Accuracy (\%) of 20 classes and average accuracy on Pascal VOC. Bold numbers represent the best performing of the methods to be compared. Method with ``-H" and ``-F" denotes it with permutation loss with Hungarian attention and false matching loss, respectively. Suffix ``-QC" denotes the method with the proposed quadratic constraint.} \label{table:accuracyP} \end{table*} \begin{table*}[t!] \centering \resizebox{\textwidth}{!}{ \begin{tabular}{c | cccccccccccccccccccc | c} \toprule \noalign{\smallskip} Method & aero & bike & bird & boat & bottle & bus & car & cat & chair & cow & table & dog & horse & mbike & person & plant & sheep & sofa & train & tv & Mean\\ \noalign{\smallskip} \midrule \noalign{\smallskip} BB-GM-Max~\cite{rolinek2020deep} & 35.5 & 68.6 & 46.7 & 36.1 & 85.4 & 58.1 & 25.6 & 51.7 & 27.3 & 51.0 & 46.0 & 46.7 & 48.9 & 58.9 & 29.6 & 93.6 & 42.6 & 35.3 & 70.7 & 79.5 & 51.9\\ BB-GM~\cite{rolinek2020deep} & 42.7 & 70.9 & 57.5 & 46.6 & 85.8 & 64.1 & 51.0 & 63.8 & 42.4 & 63.7 & 47.9 & 61.5 & 63.4 & 69.0 & 46.1 & 94.2 & 57.4 & 39.0 & 78.0 & 82.7 & 61.4\\ \noalign{\smallskip} \midrule \noalign{\smallskip} qc-DGM$_1$ (ours) & 30.1 & 59.1 & 48.6 & 40.0 & 79.7 & 51.6 & 32.4 & 55.4 & 26.1 & 52.1 & 47.0 & 50.1 & 56.8 & 59.9 & 27.6 & 90.4 & 50.9 & 33.1 & 71.3 & 78.8 & 52.0\\ qc-DGM$_2$ (ours) & 30.9 & 59.8 & 48.8 & 40.5 & 79.6 & 51.7 & 32.5 & 55.8 & 27.5 & 52.1 & 48.0 & 50.7 & 57.3 & 60.3 & 28.1 & 90.8 & 51.0 & 35.5 & 71.5 & 79.9 & 52.6\\ \noalign{\smallskip} \bottomrule \end{tabular} } \vspace{-1mm} \caption{F1 score (\%) of matching and mean over 20 classes on Pascal VOC.} \label{table:accuracyP1} \vspace{-2mm} \end{table*} Experimental results on 20 classes are given in Table~\ref{table:accuracyP}. Since the peer work~\cite{rolinek2020deep} suggests to compare F1 score (the harmonic mean of precision and recall) on the dataset without intersection filtering, we provide F1 score of our method to compare with BB-GM~\cite{rolinek2020deep} and its ablation BB-GM-Max as shown in Table~\ref{table:accuracyP1}. To show the robustness of the deep graph matching models against outliers, we add outliers to the original set of keypoints. The 2D Cartesian coordinates of the outliers are generated by Gaussian distribution $\mathcal{N}(0, 10)$. The outliers exist only in inference stage to challenge the model trained on the clean data (without outliers). This robustness test is more challenging than that on synthetic graphs because all the inliers and outliers have their extracted CNN features and thus, more close to the real-world scenes. Experimental results are shown in Fig.~\ref{fig:comparison}. With our quadratic constraint, the improvement of overall accuracy is witnessed on the clean data and the robustness of deep graph matching models have been significantly improved against outliers. By comparing PCA and qc-PCA or GMN and qc-GMN in Table~\ref{table:accuracyP}, the effectiveness of our quadratic constraint is shown to be general and the matching accuracy is improved over all 20 classes by considering our quadratic constraint. \begin{table}[t!] \vspace{-1mm} \scriptsize \centering \begin{tabular}{c|ccccc|c} \noalign{\smallskip} \toprule {Method} & {face} & {mbike} & {car} & {duck} & {wbottle} & {Mean} \\ \midrule \noalign{\smallskip} HARG-SSVM~\cite{cho2013learning} & 91.2 & 44.4 & 58.4 & 55.2 & 66.6 & 63.2\\ GMN~\cite{zanfir2018deep} & 98.1 & 65.0 & 72.9 & 74.3 & 70.5 & 76.2 \\ ${\rm GMN_D}$ & $\textbf{100.0}$ & 82.4 & 84.4 & 84.0 & 91.2 & 88.4 \\ qc-GMN & $\textbf{100.0}$ & 65.7 & 75.3 & 81.1 & 90.5 & 82.5\\ PCA~\cite{wang2019learning} & $\textbf{100.0}$ & 76.7 & 84.0 & 93.5 & 96.9 & 90.2 \\ qc-PCA & $\textbf{100.0}$ & 83.3 & 87.3 & 93.8 & 97.1 & 92.3 \\ PCA-H~\cite{wang2019learning} & $\textbf{100.0}$ & 76.9 & 88.9 & 89.7 & 92.9 & 89.7 \\ PCA-F~\cite{wang2019learning} & $\textbf{100.0}$ & 78.4 & 86.8 & 93.2 & 97.2 & 91.1 \\ NGM~\cite{wang2019neural} & 99.2 & 82.1 & 84.1 & 77.4 & 93.5 & 87.2 \\ GLMNet~\cite{jiang2019glmnet} & $\textbf{100.0}$ & 89.7 & 93.6 & 85.4 & 93.4 & 92.4 \\ LCSGM~\cite{wang2020learning} & $\textbf{100.0}$ & $\textbf{99.4}$ & 91.2 & 86.2 & 97.9 & 94.9\\ ${\rm CIE_1}$-H~\cite{yu2020learning} & $\textbf{100.0}$ & 90.0 & 82.2 & 81.2 & 97.6 & 90.2 \\ BB-GM~\cite{rolinek2020deep} & $\textbf{100.0}$ & $\textbf{99.2}$ & 96.9 & 89.0 & 98.8 & 96.8\\ \midrule qc-DG${\rm M}_1$(ours) &$\textbf{100.0}$ & 95.0 & 93.8 & $\textbf{93.8}$ & 97.6 & 96.0 \\ qc-DG${\rm M}_2$(ours) & $\textbf{100.0}$ & 98.8 & $\textbf{98.0}$ & 92.8 & $\textbf{99.0}$ & $\textbf{97.7}$\\ \bottomrule \end{tabular} \vspace{.2em} \caption{Accuracy (\%) of 5 classes and the average on Willow Object Class.} \label{table:willow} \vspace{-3mm} \end{table} \begin{figure}[t!] \vspace{-7mm} \centering \includegraphics[height=0.13\linewidth, width=0.8\linewidth]{legend.pdf}\\ \vspace{-1mm} \subfigure[]{ \includegraphics[height=0.4\linewidth,width=0.47\linewidth]{comparisonp.pdf}} \subfigure[]{ \includegraphics[height=0.4\linewidth,width=0.47\linewidth]{comparisonw.pdf} } \caption{Robustness analysis against outliers on Pascal VOC (a) and Willow Object Class (b). Method with ``+'' means {\em with} quadratic constraint while ``-'' means {\em without} quadratic constraint.} \label{fig:comparison} \vspace{-3mm} \end{figure} \begin{figure*}[t!] \centering \includegraphics[height=0.14\linewidth,width=0.33\linewidth]{airplane.pdf} \includegraphics[height=0.14\linewidth,width=0.33\linewidth]{duck1_instance.pdf} \includegraphics[height=0.14\linewidth, width=0.33\linewidth]{motor1_instance.pdf}\\ \includegraphics[height=0.14\linewidth,width=0.33\linewidth]{train.pdf} \includegraphics[height=0.143\linewidth,width=0.33\linewidth]{face1_instance.pdf} \includegraphics[height=0.14\linewidth,width=0.33\linewidth]{bottle.pdf} \caption{Matching examples on Pascal VOC and Willow Object Class. Nodes with the same color indicate the correspondence of a graph pair. All the visualized graphs are constructed by Delaunay triangulation in yellow.} \vspace{-3mm} \label{fig:example} \end{figure*} \subsection{Results on Willow Object Class} Willow Object Class dataset~\cite{cho2013learning} contains 5 classes with 256 images in total. Three classes (face, duck and wine bottle) of the dataset are from Caltech-256 and the rest two classes (car and motorbike) are from Pascal VOC 2007. We resize all the image pairs to 256$\times$256 for VGG16 backbone and crop the images around the bounding box of the objects. The variations of the pose, scale, background and illumination of the images on Willow Object Class are small, and thus, graph matching tasks on this dataset are much more easier. As shown in Table~\ref{table:willow}, the proposed method achieves the state-of-the-art performance. Comparing the methods with and without quadratic constraint (PCA and qc-PCA or GMN and qc-GMN), the performance improvements on Willow dataset are more prominent than those on Pascal VOC, which because the structure variations of graph pairs on the easier dataset are relatively small and quadratic constraint contributes to matching more soundly. Since BB-GM adopts SplineCNN to refine the features, we provide qc-DG${\rm M}_2$ for fair comparison, which has a higher overall accuracy. \subsection{Further study} Table~\ref{table:ablation} shows the usefulness of the proposed components. CNN feature vector of each node has d=1024 dimensions, which are supposed to be better than the two-dimensional coordinates but the geometric prior encoded in coordinates provides a more precise description of graph nodes. By simply combining the unary geometric prior with the extracted CNN features, the matching accuracy is improved, which supports our point of view, {\em i.e.}, CNN features are indeed useful but not discriminative enough to depict pixel-wise graph nodes. $\textbf{Quadratic constraint.}$ There are various forms of quadratic constraint that are not limited to ours. Global affinity matrix $\mathbf{K}$ is constrainted by graph incidence matrices in the factorized form of Lawler's QAP~\cite{lawler1963quadratic,zhou2015factorized}, which can be considered as another form of quadratic constraint adopted in GMN. As shown in Table~\ref{table:accuracyP} and Table~\ref{table:willow}, GMN performs significantly worse than ${\rm GMN_D}$ on both two datasets by replacing similar graph topology with the completely different one, while the extracted deep features of both settings remain the same. This implies the main limitation of quadratic constraint, {\em i.e.}, only graphs with similar topology contribute to matching. Besides, the fact shows the independent relationship between the graph structure and raw deep features for the change of graph topology can not be reflected by raw deep features (before being refined). \begin{figure}[t!] \vspace{-1mm} \centering \includegraphics[height=0.13\linewidth, width=0.45\linewidth]{legend_acc.pdf} \includegraphics[height=0.13\linewidth, width=0.47\linewidth]{legend_loss.pdf}\\ \includegraphics[height=0.4\linewidth, width=0.47\linewidth]{comparison_acc.pdf} \includegraphics[height=0.4\linewidth, width=0.47\linewidth]{comparison_loss.pdf} \caption{Accuracy/loss vs. training epoch on Pascal VOC. As the training goes, the loss functions try to drag the output to binary and the local minimum with bad properties makes the cross-entropy-type loss explosion. Since the accuracy will be very close to 0 after gradient explosion, we truncate the descending curves and keep them unchanged for better visualization.} \label{fig:allcomp} \end{figure} $\textbf{False-matching loss vs. cross entropy loss.}$ The two main loss functions to be compared with ours are permutation loss~\cite{wang2019learning} and permutation loss with Hungarian attention~\cite{yu2020learning}. We report accuracy/loss with training epoch in Fig.~\ref{fig:allcomp}. In experiments, the model with cross-entropy-type loss functions (Loss-P and Loss-H) always encounter the bad cases leading to gradient explosion in training stage, while our false matching loss (Loss-F) can avoid this issue. Besides, false matching loss is shown to do better against overfitting than the compared two loss functions. \begin{table}[t!] \scriptsize \centering \begin{tabular}{ccccc} \toprule \multicolumn{1}{c}{\begin{tabular}[c]{@{}c@{}}raw \\attributes\end{tabular}} & \multicolumn{1}{c}{\begin{tabular}[c]{@{}c@{}}unary \\geomteric prior\end{tabular}} & \multicolumn{1}{c}{\begin{tabular}[c]{@{}c@{}}pairwise \\structure context\end{tabular}} & \multicolumn{1}{c}{\begin{tabular}[c]{@{}c@{}}QC \\ optimization\end{tabular}} & accuracy \\ \midrule $\surd$ & $\surd$ & $\surd$ & $\surd$ & 69.3\\ $\surd$ & $\surd$ & $\surd$ & & 68.5\\ $\surd$ & $\surd$ & & & 68.3\\ $\surd$ & & & &67.8\\ \bottomrule \end{tabular} \vspace{1mm} \caption{Ablation study of qc-DG${\rm M}_1$ on Pascal VOC. The component been adopted is marked by a tick. ``QC optimization" is quadratic constrained-optimization.} \label{table:ablation} \vspace{-3mm} \end{table} \section{Conclusion} In this work, we explicitly introduce quadratic constraint of graph structure into deep graph matching. To this end, unary geometric prior and pairwise structural context are considered for objective construction and a differentiable optimization scheme is provided to approach the problem. Moreover, we focus on class imbalance that naturally exists in deep graph matching to propose our false matching loss. Experimental results show the competitive performance of our method. In future work, we plan to seek a more general form of quadratic constraint to the learning-based optimization for better matching. {\small \bibliographystyle{ieee_fullname}
{'timestamp': '2021-03-16T01:15:57', 'yymm': '2103', 'arxiv_id': '2103.06643', 'language': 'en', 'url': 'https://arxiv.org/abs/2103.06643'}
arxiv
\section{Sequential token swapping on trees is NP-complete} \label{sec:NP-hard-unweighted} Recall that the token swapping problem is a decision problem: given a tree with initial and target positions of the tokens, and given a number $K$, can the tokens be moved from their initial to their target positions with at most $K$ swaps. Membership in NP is easy to show: any problem instance can always be solved with a quadratic number of swaps by repeatedly choosing a leaf and swapping its target token to it. Thus, a certificate can simply be the list of swaps to execute. % \ifabstract Here we give an overview of the construction for the unweighted case; however, most of the proof is left to the Appendix. \fi \subsection{Overview} We reduce from Star STS and follow the same reduction plan as for the weighted case, building a tree with an ordering gadget and $m$ slot gadgets, each with a nook for an item token. However, there are several challenges. First of all, the swaps with item tokens are no longer free, so we need to take the number of them into account. Secondly, we cannot know the number of item token swaps precisely since it will depend on the number of swaps (between $0$ and $n$) required by the original Star STS instance. Our plan is to make this ``slack'' $n$ very small compared to the total number of swaps needed for the constructed token swapping instance. To do this, we will make the total number of swaps very big by replacing each of the non-item tokens $x_j$ and $y_j$ by a long path of non-item tokens called a ``segment.'' This raises further difficulties, because nothing forces the tokens in one segment to stay together, which means that they can sneak around and occupy nooks, freeing item tokens to swap amongst themselves in unanticipated ways. To remedy this we add further ``padding segments'' to the construction. The construction details are given in Section~\ref{sec:construction}. Proving that our unweighted construction is correct is much more involved than in the weighted case. There are two parts to the proof: \begin{description} \item[Part 1:] \customlabel{1}{part:1} {\bf YES instance of Star STS $\to$ YES instance of token swapping.} In Section~\ref{sec:ForwardDirection} we show that if there is a solution to an instance of Star STS then the constructed token swapping instance can be solved with at most $K$ swaps (where $K$ will be specified in the construction). This solution uses exactly $H = K-n$ swaps to get the non-item tokens to their target positions, and uses between $0$ and $n$ additional swaps to get the item tokens to their target positions. It is important to note that $H$ counts swaps of both item and non-item tokens and is more than just the cost of moving each non-item token along its shortest path. \item[Part 2:] \customlabel{2}{part:2} {\bf YES instance of token swapping $\to$ YES instance of Star STS.} In Section~\ref{sec:BackwardDirection} we show that if the constructed token swapping instance can be solved with at most $K$ swaps then the original Star STS instance has a solution. We show that $H$ swaps are needed to get the non-item tokens to their destinations. We then show that with only $n$ remaining swaps, the motion of item tokens is so constrained that they must behave ``as intended'' and therefore correspond to swaps in the original Star STS instance. \end{description} \subsection{Construction of token swapping instance} \label{sec:construction} Suppose we have an instance of Star STS where the star has center 0 and leaves $1, \ldots, m$ and each vertex has a token of its same label. We have a permutation $\pi$ of the tokens with $\pi(0) = 0$ (recall that this version is still hard by Lemma~\ref{lemma:StarSTS}), and a sequence $s_1, \ldots, s_{n}$ with $s_j \in \{1, \ldots, m\}$ that specifies the allowed swaps. As in the weighted case in Section~\ref{sec:NP-hard-weighted}, we will refer to the tokens of the Star STS instance as \defn{items} and the leaves as \defn{slots}. We assume without loss of generality that every slot appears in the sequence (otherwise remove that slot from the problem) and that no slot appears twice in a row in the sequence. Construct a tree as in the weighted case except that each individual $x_j$ and $y_j$ is replaced by a sequence of $k$ vertices (and tokens) with $k=(mn)^c$ for a large constant $c$, to be set later. Each such sequence of length $k$ is called a \defn{big segment}. Refer to Figure~\ref{fig:plan-segments} where the tree is drawn with the root in the middle, the ordering gadget to the left and the slot gadgets to the right. We will refer to left and right as in the figure. The target ordering of tokens within a big segment behaves as though the segment just slides along the shortest path to its target, i.e., the left to right order of tokens in a segment is the same in the initial and the final configurations. % \begin{figure}[htbp] \centering \includegraphics[width=\textwidth]{Figures/plan-segments-horizontal-2.pdf} \caption{(a) An instance of Star STS with $m=4$ slots and a sequence of length $n=5$. (b) The corresponding instance of token swapping with the initial token positions. The root has item token $0$ (coloured red). The ordering gadget lies to the left of the root. There are 4 slot gadgets to the right of the root. A long oval indicates a big segment of length $k$, and a short oval indicates a padding segment of length $k' = k/n^8$. Each nook vertex (coloured red) is attached to the $k^{\rm th}$ vertex from the root along the slot gadget path. Item tokens are coloured red; non-slot tokens are in the segment ovals coloured gray; and slot tokens are in the segment ovals coloured white. (c) The target token positions. In the first round of the ``intended'' solution, big segments $y_1$ and $x_1$ first change places. As $y_1$ moves left, item token $0$ moves to nook parent 1 where it may swap with item token 1. As $x_1$ moves right, the item token moves back to the root. Then segment $y_1$ moves to the far left of the ordering gadget and $x_1$ moves to the far right of the first slot gadget. Next, padding segments $p_{3,1}$ and $q_{3,1}$ change places across the root and move to their target locations; then $p_{2,1}$ and $q_{2,1}$; then $p_{4,1}$ and $q_{4,1}$; and finally $p_{1,1}$ and $q_{1,1}$. Note the ordering $q_{3,1},q_{2,1},q_{4,1},q_{1,1}$ of padding segments that lie to the right of $y_1$ in the final configuration---$q_{1,1}$ is last because $s_1=1$ and $q_{3,1}$ is first because $s_2=3$. } \label{fig:plan-segments} \end{figure} The nook vertex in each slot gadget is attached to the vertex at distance $k$ from the root in the slot gadget, and this vertex is called the \defn{nook parent}. The edge between the nook vertex and the nook parent is called the \defn{nook edge}. Refer to Figure~\ref{fig:plan-segments}. In the ``intended'' solution, the big segments leave the slot gadgets and enter the ordering gadget in the order $y_1, \ldots, y_n$. Although we will not give details, it turns out that the construction so far allows ``cheating'' via interference between slot gadgets. To prevent this, we add a total of % $2nm$ \defn{padding segments} each of length $k' = k/n^8$. The intuition is that in the ``intended'' solution, after $y_j$ enters the ordering gadget, one padding segment from each slot gadget will enter the ordering gadget, and then $y_{j+1}$ will do so. We now give the details of the padding segments in the initial/final configurations of the slot/ordering gadgets. In the initial configuration there are $nm$ padding segments $q_{i,j}, i= 1, \ldots, m, j=1, \ldots, n$ in the slot gadgets, and $nm$ padding segments $p_{i,j}, i= 1, \ldots, m, j=1, \ldots, n$ in the ordering gadget. In the final configuration, the $q_{i,j}$'s are in the ordering gadget and the $p_{i,j}$'s are in the slot gadgets. In the initial configuration, slot gadget $i$, $i=1, \ldots, m$ contains $n$ padding segments $q_{i,j}, j=1, \ldots, n$. They appear in order from left to right, with big segments mixed among them. Specifically, if $y_{j'}$ is a big segment in slot gadget $i$ then $y_{j'}$ appears just before $q_{i,j'}$. In the final configuration of the ordering gadget there are $m$ padding segments after each of the $n$ big segments. The padding segments after $y_j$ are $q_{i,j}, i=1, \ldots, m$. They appear in a particular left to right order: $q_{s_j,j}$ is last, $q_{s_{j+1},j}$ is first, and the others appear in order of index $i$. Within one padding segment, the left to right ordering of tokens is the same in the initial and final configurations. The initial configuration of the ordering gadget is obtained from the final configuration by: reversing (from left to right) the pattern of big segments and padding segments; changing $y$'s to $x$'s, and changing $q$'s to $p$'s. Similarly, the final configuration of slot gadget $i$ is obtained from the initial configuration of slot gadget $i$ in the same way. Let $A$ be the set of non-item tokens, and for any token $t$, let $d_t$ be the distance between $t$'s initial and target positions. To complete the reduction, we will set $H$ to be $\frac{1}{2}\sum_{t \in A} (d_t + 1)$ and set the bound $K$ to be $H + n$. The decision question is whether this token swapping instance can be solved with at most $K$ swaps. The reduction takes polynomial time. \ifabstract The remainder of the proof can be found in Appendix~\ref{App:Sequential}.\fi \later{ \ifabstract \section{Proof of NP-completeness of Sequential Token Swapping.}\label{App:Sequential} \fi In future sections we use the following definitions and notation. \begin{definition} \label{defn:move} \label{defn:partner} \label{defn:basic} \ \begin{itemize} \item $T$ is the set of tokens. $T = A \cup I$. $I$ is the set of $m+1$ \defn{item tokens} whose initial and target positions are the nook vertices and the root. Item token 0 has initial and target position at the root. $A$ is the set of \defn{non-item tokens} and consists of $nk + nmk'$ \defn{slot tokens} whose initial positions are in the slot gadget, and equally many \defn{non-slot tokens} whose initial positions are in the ordering gadget. % \item For a token $t \in A$, $d_t$ is the distance between its initial and target positions. \item $H = \frac{1}{2}\sum_{t \in A} (d_t + 1)$. $K = H+n$. \item Big segments $x_j$ and $y_j$ are \defn{partners}. Padding segments $p_{i,j}$ and $q_{i,j}$ are \defn{partners}. \item Every swap consists of two \defn{moves}, where a \defn{move} means one token moving across one edge. A \defn{left} move goes left in Figure~\ref{fig:plan-segments}, i.e., towards the root in a slot gadget or away from the root in the ordering gadget. A \defn{right} move does the opposite. \end{itemize} \end{definition} \subsection{Part \ref{part:1}: YES instance of Star STS \texorpdfstring{$\to$}{-->} YES instance of token swapping} \label{sec:ForwardDirection} In this section we prove that if we start with a YES instance of Star STS then the constructed token swapping instance has a solution with at most $K=n+H$ swaps. We first show how a solution to the Star STS instance gives an ``intended'' solution to the constructed token swapping instance. We follow the same idea as in the proof for the weighted case (Theorem~\ref{thm:weighted-NP-hard}). \medskip\noindent {\bf The ``intended'' solution.} For $j=1, \ldots, n$, implement $s_j$ as follows: \begin{itemize} \item Move the item token $t$ currently at the root % along the path of slot gadget $s_j$ to the nook parent. Item token $t$ now has the opportunity to swap with the item token in the adjacent nook. Perform this swap if and only if swap $s_j$ was performed in the solution to the Star STS instance. Let $t'$ be the resulting token at the nook parent. Move big segment $y_j$ to its target position in the ordering gadget. Move big segment $x_j$ to its target position in the slot gadget $s_j$. This moves token $t'$ to the root. \item Next, for each slot gadget $i$, move the padding segment nearest the root out the slot gadget to its target position in the ordering gadget and move its partner padding segment out of the ordering gadget to its target position in slot gadget $i$. These pairs of segment moves must be done in the order in which the padding segments $q_{i,j}$ appear in the final configuration (left to right). Note that item token $t'$ returns to the root after each of the $m$ pairs of segment moves. \end{itemize} It is straightforward to show that this solution is correct, i.e., that at the beginning of round $j$, big segment $y_j$ is next to the root at the left end of slot gadget $s_j$ and big segment $x_j$ is next to the root at the right end of the ordering gadget, and similarly, that after the movements of these big segments, the successive pairs of padding segments are in position next to the root when we are ready to move them. At the heart of the intended solution is a subsequence of moves that are used to correctly re-position the non-item tokens while leaving the item tokens fixed. We formalize this ``scaffold solution'' for use in future sections. \medskip\noindent {\bf The ``scaffold'' solution.} This is the same as the intended solution except that no swaps are performed between item tokens. Thus, item tokens $1, 2, \ldots, m$ remain in their initial nook vertices, and item token $0$ returns to the root after each round (each loop on $j$). \medskip\noindent {\bf Properties of the intended/scaffold solution.} \begin{description} \item{(P1)} Every non-item token travels on the path from its initial position to its target position and makes $d_t$ moves. \item{(P2)} There is no swap between two slot tokens nor between two non-slot tokens. \item{(P3)} The pairs of non-item tokens that swap with each other can be characterized with respect to the initial configuration as follows. Let $t$ be a slot token that lies in big/padding segment $g$, and suppose that the partner of $g$ is the big/padding segment $g'$. Let $\pi_1$ be the ordered list of segments between the root and $g$ (not including $g$). Let $\pi'_1$ be the partners of the segments of $\pi_1$. Let $\pi_2$ be the ordered list of segments from $g'$ (including $g'$) to the right end of the ordering gadget. Then the non-slot tokens that $t$ swaps with are the tokens that lie in the segments $\pi'_1, \pi_2$. See Figure~\ref{fig:intended-swaps}. In particular, note that the number of tokens from $\pi'_1$ is less than the distance from $t$ to the root. \item{(P4)} In the scaffold solution, token $0$ swaps with every non-item token. \item{(P5)} The order in which the slot tokens reach the root is precisely the left-to-right order of their final positions in the ordering gadget. Similarly, the order in which the non-slot tokens reach the root is precisely the right-to-left order of their initial positions in the ordering gadget. \item{(P6)} The final positions of the slot tokens in the ordering gadget are such that between any big segment and any other segment from the same slot gadget, there is a segment from each of the other slot gadgets. Combining this with (P5) implies the following property. Consider a time interval during which at least one token from a big segment from a slot gadget $i$ and at least one token from any other segment from slot gadget $i$ reach the root. During this time interval, every token in at least one segment from each of the other slot gadgets reaches the root. \end{description} \begin{figure}[htbp] \centering \includegraphics[width=.4\textwidth]{Figures/intended-swaps-horizontal-2.pdf} \caption{In the intended/scaffold solution, slot token $t$ from segment $g$ swaps with the non-slot tokens with initial positions in $\pi'_1, \pi_2$. Here $\pi'_1$ (coloured red) consists of the segments that are the partners of segments in $\pi_1$. } \label{fig:intended-swaps} \end{figure} \medskip\noindent {\bf Bounding the number of token swaps for a YES instance of Star STS.} \begin{lemma} \label{lem:forward} Given a YES instance of Star STS, the total number of swaps in the corresponding token swapping instance is at most $K$. \end{lemma} \begin{proof} Recall that $H = \frac{1}{2}\sum_{t \in A} (d_t + 1)$ and $K = H + n$. We show that the number of swaps used by the intended solution is at most $K$. First consider the scaffold solution. The number of moves made by a non-item token $t$ in the scaffold solution is $d_t$ by (P1). In addition, item token 0 swaps once with each non-item token by (P4), for a total of $|A|$ moves by item tokens. There are no other moves. Thus the total number of moves in the scaffold solution is $\sum_{t \in A} (d_t +1)$, and the number of swaps is half that, i.e., $H$. The intended solution has additional swaps between pairs of item tokens---these are the swaps that occur on the nook edges. They correspond exactly to the swaps $s_j$ that are chosen for the Star STS solution, thus, % at most $n$. In sum the total number of swaps is at most $H + n = K$. \end{proof} \subsection{Part \ref{part:2}: YES instance of token swapping \texorpdfstring{$\to$}{-->} YES instance of Star STS} \label{sec:BackwardDirection} In the previous section we showed that if we have a YES instance of Star STS then the corresponding token swapping instance can be solved in at most $K$ swaps. The goal of this section is to prove the reverse claim: % \begin{lemma} \label{lem:backward} Consider an instance of Star STS whose corresponding token swapping instance has a solution using at most $K$ swaps. Then the Star STS instance is a YES instance. \end{lemma} Note that Lemmas~\ref{lem:forward} and \ref{lem:backward} combined show correctness of our reduction, which finishes the NP-completeness proof. Throughout the section we assume that in the solution to the token swapping instance no pair of tokens swaps more than once, which we justify as follows: \begin{claim} \label{lem:unique} If a pair of tokens swaps more than once in a token swapping solution, then there is a shorter solution. \end{claim} \begin{proof} Suppose tokens $x$ and $y$ swap more than once in a sequence of swaps. Eliminate the last two swaps of $x$ and $y$ and exchange the names $x$ and $y$ in the subsequence between the two removed swaps. The resulting shorter sequence yields the same final token configuration. \end{proof} Our argument will be based on the number of moves rather than the number of swaps. Recall from Definition~\ref{defn:move} that every swap consists of two moves. By assumption we have a solution that uses at most $K$ swaps, which is at most $2K$ moves and $2K = 2H + 2n = 2(\frac{1}{2}\sum_{t \in A} (d_t + 1)) + 2n = \sum_{t \in A} d_t + |A| + 2n$. Clearly, we need at least $d_t$ moves to get each non-item token $t \in A$ to its target location. In the first part of the argument (in Subsection~\ref{sec:Back moves for any instance}) we identify $|A|$ additional moves (of item or non-item tokens) that are dedicated to the task of getting non-item tokens to their target locations. This leaves at most $2n$ moves unaccounted for. In the second part of the argument (in Subsection~\ref{sec:Back moves for NO instance}), we show that with so few remaining moves, the movement of item tokens is very constrained and corresponds to a solution to the original Star STS instance. Before starting the rather technical subsections, we give more detail on these two high level aspects: how we classify and account for moves; and how we convert the constrained movement of item tokens into a solution to the original Star STS instance. % \paragraph*{Accounting for moves.} Rather than arguing about all the moves, we will argue about special moves called ``contrary moves.'' For slot and non-slot tokens, the ``contrary moves'' go contrary to the direction the token should go, i.e., for a slot token---which should go left---a contrary move is a right move, and vice versa for non-slot tokens. We formalize this and extend the definition to item tokens as follows. \begin{definition} \label{defn:contrary-move} \label{defn:main-path} A \defn{contrary} move of a slot token is a right move. See Figure~\ref{fig:moves}. A \defn{contrary} move of a non-slot token is a left move. A \defn{contrary} move of an item token is right move (this is somewhat arbitrary). Let $c_t$ be the number of contrary moves made by token $t$. The \defn{main path} of a slot token $t$ is the path in the tree between the rightmost vertex of $t$'s slot gadget and the leftmost vertex of the ordering gadget. \end{definition} The concept of a main path will be used later in the proof. Observe that every slot token $t$ must make $d_t$ left moves along its main path. \begin{figure}[htb] \centering \includegraphics[width=.55\textwidth]{Figures/moves-contrary-horizontal.pdf} \caption{Classifying the moves as a slot token moves from its initial position $u$ to its target position $v$. \defn{Contrary} (right) moves are coloured red. Left moves are coloured black, with the solid portions occurring on the \defn{main path} (coloured purple). } \label{fig:moves} \end{figure} \begin{claim} \label{claim:contrary-moves} The total number of moves in the solution is $\sum_{t \in A} d_t + 2 \sum_{t \in T} c_t$. \end{claim} \begin{proof} Note that the first sum is over non-item tokens and the second sum is over all tokens. Every slot token $t$ must make $d_t$ left moves, one on each edge of the path from its initial to final position. The other moves made by token $t$ come in pairs, where each pair consists of a left move and a right (contrary) move on some edge $e$. Thus the total number of moves made by a slot token $t$ is $d_t + 2c_t$. For a non-slot token $t$ the same argument (with directions reversed) shows that the total number of moves is $d_t + 2c_t$. For item tokens, observe that the set of nodes of the tree that contain item tokens is the same in the initial and the target configurations. This implies that, if an item token makes a contrary (right) move on an edge $e$, then some (possibly other) item token must move left on $e$. Thus the total number of moves made by item tokens is $2\sum_{t \in I} c_t$. Putting these together, the total number of moves in the solution is $\sum_{t \in A} d_t + 2 \sum_{t \in T} c_t$. \end{proof} We obtain a bound on the number of contrary moves: \begin{lemma} \label{lemma:contrary-move-bound} A token swapping solution with at most $K$ swaps has at most $ |A|/2 + n$ contrary moves. \end{lemma} \begin{proof} An upper bound of $K$ swaps is an upper bound of $\sum_{t \in A} d_t + |A| + 2n$ moves. By Claim~\ref{claim:contrary-moves}, the number of moves is $\sum_{t \in A} d_t + 2 \sum_{t \in T} c_t$. Thus $\sum_{t \in T} c_t \le |A|/2 + n$. \end{proof} In Subsection~\ref{sec:Back moves for any instance} we will identify in the solution a set $\cal M$ of $|A|/2$ contrary moves that are associated with getting slot tokens to their target locations, one contrary move per slot token. This leaves at most $n$ contrary moves outside of $\cal M$. In Subsection~\ref{sec:interface} we make a careful catalogue of which contrary moves are included in $\cal M$, thus providing an interface to the final Subsection~\ref{sec:Back moves for NO instance}. In that final subsection we argue that if the big segments and padding segments are long enough (i.e., for sufficiently large $k$), and given the bound of at most $n$ contrary moves outside $\cal M$, the movement of the tokens is constrained to be ``close'' to the intended solution. We do this by proving various properties. For example, to give the flavour of these arguments, we prove that to get two item tokens into the ordering gadget at the same time takes more than $n$ contrary moves outside $\cal M$. A major challenge in proving all these properties is showing that the $>n$ contrary moves we count are indeed disjoint from $\cal M$. Finally, the properties allow us to convert the movement of item tokens into a solution to the original Star STS instance as we describe next. \paragraph*{Converting a token swapping solution to a star STS solution.} Recall that at any point in time during the intended solution, there is an item token in each nook plus one ``free'' item token (initially the one at the root) that moves around. The free item token moves to a nook parent and may swap with the item token $t'$ in the nook, in which case $t'$ becomes the new free item token. We cannot hope for such structure in our solution since many item tokens can be outside the nooks. However, we can still identify one ``free'' item token and one item token per slot gadget. \begin{definition} At any point in time during the swap sequence the \defn{free} item token is the item token that most recently was at the root. \end{definition} In the initial and target configurations, item token $0$ is the free item token. We will prove that apart from the free item token, there is always exactly one item token in each slot gadget. How can the free item token change? An item token from a slot gadget, say slot gadget $i$, must reach the root to become the new free item token. Because of the property just stated (that, apart from the free item token, there is always exactly one item token in each slot gadget), at this point in time, the old free item token must be in slot gadget $i$ (it may have entered the slot gadget at the most recent swap or at some previous time). \begin{definition} The \defn{exchange} sequence $\chi$ is constructed from the changes in the free item token as follows: initialize $\chi$ to the empty string; when the item token that was just in slot gadget $i$ becomes the free item token, append $i$ to $\chi$. \end{definition} At the end of Subsection~\ref{sec:Back moves for NO instance} we will prove the following statement. \begin{lemma} \label{lem:free-item-token} If $k$, the length of a big segment, is sufficiently large, then the free item token and the exchange sequence $\chi$ satisfy the following properties. \begin{enumerate} \item At any point in time, apart from the free item token, there is exactly one item token in each slot gadget. \item $\chi$ is a subsequence of the sequence of swaps given as input to the Star STS instance. \end{enumerate} \end{lemma} With this lemma in hand, we can prove the main result of this section: \begin{proof}[Proof of Lemma~\ref{lem:backward}] We get a direct correspondence between the token swapping solution and a solution to the Star STS instance: the free item token corresponds to the item at the root in the Star STS instance; the token in slot gadget $i$ corresponds to the token at slot $i$ in the Star STS instance; and an exchange $i$ in $\chi$ corresponds to a swap between the token at the root and the token at slot $i$. By Lemma~\ref{lem:free-item-token}, the exchange sequence $\chi$ corresponds to a subsequence of the allowed swap sequence. Thus the solution to the token swapping instance provides a solution to the Star STS instance. \end{proof} \subsubsection{Contrary moves to get non-item tokens to their destinations} \label{sec:Back moves for any instance} In this section we will show that a solution to the constructed token swapping instance must contain $|A|/2$ contrary moves dedicated to the task of getting the non-item tokens to their target destinations. We do this by building a set $\mathcal M$ that contains one distinct contrary move per slot token. Since there are $|A|/2$ slot tokens, $\mathcal M$ will have $|A|/2$ contrary moves. For intuition about why contrary moves are necessary, observe that in the intended/scaffold solution every slot token swaps with an item token as it travels leftward from its initial position to its final position, and this swap is a right (contrary) move for the item token. Of course, a general solution need not have this property. However, note that in the initial configuration item token 0 lies in the path between the initial and final positions of any slot token $t$. The informal idea is that if item token 0 swaps off this path, then some other ``intruder'' token $r$ takes its place, and we will show that $r$ must make a contrary move. We now make this intuition formal. Recall from Definition~\ref{defn:main-path} that for a slot token $t$ with initial position in slot gadget $i$ its main path is the path in the tree between the rightmost vertex of $t$'s slot gadget and the leftmost vertex of the ordering gadget. \begin{definition} An \defn{imposter} for a slot token $t$ is a token $r$ such that: (1) $t$ makes a left move on its main path while swapping with $r$; and (2) $r$ is either an item token or a token that $t$ does not swap with in the scaffold solution. \end{definition} \begin{claim} \label{claim:imposter} Every slot token $t$ has at least one imposter. \end{claim} \begin{proof} Token $t$ must make at least $d_t$ left moves along its main path. (Recall that $d_t$ is the distance from $t$'s initial position to its target position.) The number of non-item tokens that $t$ swaps with in the scaffold solution is exactly one less than $d_t$. Furthermore, by Lemma~\ref{lem:unique} $t$ does not swap with the same token more than once. Thus one of $t$'s left moves on its main path must be a swap with an imposter. \end{proof} \paragraph*{Choosing contrary moves.} Consider a solution to the token swapping instance. (In fact, we will only use the property that the sequence of swaps gets every non-item token to its destination.) We will give a procedure that iterates through the slot tokens $t$, and chooses one of $t$'s imposters, $r$, together with a unique contrary move of $r$. The contrary move of $r$ will not always occur when $r$ swaps with $t$. Our procedure will add the chosen contrary move to a set $\mathcal{M}$ (initially empty). Since there are $|A|/2$ slot tokens and we choose a unique contrary move for each one, the final size of $\mathcal{M}$ will be $|A|/2$. For each slot token $t$ consider the left moves of $t$ along its main path. Check the following cases in order. \noindent {\bf Case 1.} If $t$ swaps with an item token, choose one such item token $r$. Then $r$ is an imposter for $t$. Since $t$ moves left, $r$ moves right which is a contrary move for $r$. Add this contrary move of $r$ to $\mathcal{M}$. \noindent {\bf Case 2.} If $t$ swaps with another slot token, choose one such slot token $r$. Then $r$ is an imposter for $t$ since no two slot tokens swap in the scaffold solution by (P2). Since $t$ moves left, $r$ moves right which is a contrary move for $r$. Add this contrary move of $r$ to $\mathcal{M}$. We may now suppose that $t$ only swaps with non-slot tokens as it makes left moves on its main path. By Claim~\ref{claim:imposter}, $t$ swaps with at least one imposter. We next check \emph{where} this happens. Suppose that $t$'s initial position is in slot gadget $i$. \noindent {\bf Case 3.} If $t$ swaps with an imposter in slot gadget $i$, choose one such imposter $r$. Suppose the swap happens on edge $e$. Then $r$ moves right. In the scaffold solution $t$ swaps with every non-slot token whose target destination is in slot $i$. Thus $r$'s target destination is outside slot gadget $i$ and $r$ must move left on $e$ at some later time. As the contrary move, choose the earliest left move of $r$ on edge $e$ after the $r$-$t$ swap, and add this contrary move to $\mathcal{M}$. We may now suppose that $t$ swaps with imposters only in the ordering gadget, and all these imposters are non-slot tokens. \noindent {\bf Case 4.} If $t$ swaps with an imposter $r$ that was at the root at some time before the $r$-$t$ swap, choose one such $r$. Suppose the $r$-$t$ swap occurs on edge $e$. Then $r$ moves right on $e$, and must have moved left on $e$ between the time it was at the root and the time it swapped with $t$. As the contrary move, choose the most recent left move of $r$ on edge $e$ before the $r$-$t$ swap, and add this contrary move to $\mathcal{M}$. We are left with the set of tokens $t$ that only have imposters of the following special form. \begin{definition} A non-slot token $r$ is a \defn{non-leaving imposter} for slot token $t$ if: $t$ makes a left move in the ordering gadget while swapping with $r$; (2) $r$ does not swap with $t$ in the scaffold solution; and (3) $r$ has remained inside the ordering gadget up until the $r$-$t$ swap. \end{definition} Let $S$ be the set of slot tokens $t$ such that every imposter for $t$ is a non-leaving imposter. Note that by Claim~\ref{claim:imposter}, every $t \in S$ has a non-leaving imposter. In order to complete the procedure to build $\cal M$, we must choose a non-leaving imposter and a contrary move for each token in $S$. In later sections we will need to limit the number of non-slot tokens that are chosen as non-leaving imposters so we will choose the non-leaving imposters for tokens in $S$ according to Lemma~\ref{lem:FewImposters} below. This has no effect on the rest of the current argument, so for now, just assume that we have some assignment of non-leaving imposters to the tokens in $S$. Let $S(r) \subseteq S$ be the tokens of $S$ that are assigned to imposter $r$. Let $S_i(r) \subseteq S(r)$ be the tokens of $S(r)$ whose initial positions are in slot gadget $i$. Note that the sets $S_i(r)$ partition $S$. Let $D_i$ be the non-slot tokens whose final positions are in slot gadget $i$. \begin{lemma} \label{lemma:enough-contrary-moves} Token $r$ makes at least $|S_i(r)|$ contrary moves while swapping with tokens of $D_i$. \end{lemma} With this lemma in hand, we can complete the construction of $\mathcal M$. \noindent {\bf Case 5.} Token $t$ lies in $S$, which we have partitioned into the sets $S_i(r)$. For each $i$ and $r$ such that $S_i(r)$ is non-empty, choose $|S_i(r)|$ contrary moves of $r$ where $r$ swaps with tokens of $D_i$ and add them to $\mathcal M$. Note that this adds a total of $|S|$ contrary moves to $\mathcal M$ because the contrary moves of $r$ for different $i$'s are disjoint since the sets $D_i$ are disjoint. \begin{proof}[Proof of Lemma~\ref{lemma:enough-contrary-moves}] Consider the initial configuration of tokens. Let $t_1, \ldots, t_f$ be the tokens of $S_i(r)$ ordered by their (initial) positions in slot gadget $i$ with $t_1$ closest to the root. Then $|S_i(r)| = f$ so we need to show that $r$ makes $f$ contrary moves while swapping with tokens of $D_i$. Let $g$ be the big/padding segment containing $t_1$, and let $g'$ be the partner of $g$. Let $h_1$ and $h_f$ be the distances from the root to $t_1$ and $t_f$, respectively. Since $r$ is an imposter for $t_1$, there was no swap between $r$ and $t_1$ in the scaffold solution. But in the scaffold solution, by property (P3), $t_1$ swaps with every token to the left of (and including) $g'$. Therefore $r$ must lie to the right of $g'$. Also, by property (P3), fewer than $h_1$ tokens of $D_i$ lie to the right of $g'$. Thus, fewer than $h_1$ tokens of $D_i$ lie to the right of $r$. Let $Z$ be the set of non-slot tokens that swap with $t_f$ during left moves of $t_f$ on its main path in slot gadget $i$. By Lemma~\ref{lem:unique}, $t_f$ does not swap with the same token twice, so $|Z| \ge h_f$. No token of $Z$ is an imposter for $t_f$ because $t_f$ only has non-leaving imposters. Thus $Z$ consists of non-slot tokens whose destinations are in slot gadget $i$, i.e., $Z \subseteq D_i$. Also note that $r \notin Z$ since $r$ stays in the ordering gadget until it swaps with $t_f$. Let $Z'$ be the tokens of $Z$ that lie to the left of $r$ in the initial configuration. Since there are less than $h_1$ tokens of $D_i$ to the right of $r$, we have $|Z'| > h_f - h_1 \ge f-1$. Thus $|Z'| \ge f$. Finally, we claim that all the tokens of $Z'$ swap with $r$, and do so during contrary (left) moves of $r$. This is because $r$ remains inside the ordering gadget until it swaps with $t_f$, but all the tokens of $Z'$ must exit the ordering gadget so they can swap with $t_f$ on its journey to the root. Thus $r$ makes at least $f$ contrary moves while swapping with tokens of $D_i$, as required. \end{proof} \paragraph*{Uniqueness of contrary moves.} We claim that the set $\mathcal M$ constructed above contains $|A|/2$ distinct contrary moves. First note that we added a contrary move to $\mathcal M$ for each slot token, and there are $|A|/2$ slot tokens. It remains to show that we never added the same contrary move to $\mathcal M$ multiple times. Consider a contrary move in $\mathcal{M}$ of a token $r$. We can uniquely identify when it was added to $\mathcal{M}$ as follows. \begin{itemize} \item If $r$ is an item token then the move was added to $\mathcal{M}$ in Case 1, and the associated slot token $t$ is the one that $r$ swaps with during this contrary move. \item If $r$ is a slot token then the move was added to $\mathcal{M}$ in Case 2, and $t$ is the token that $r$ swaps with. \item If $r$ is a non-slot token and its contrary (left) move is on an edge $e$ in a slot gadget, then the move was added to $\mathcal{M}$ in Case 3, and in $r$'s most recent right move on edge $e$ it swapped with token $t$. \item If $r$ is a non-slot token and its contrary (left) move is on an edge $e$ in the ordering gadget and $r$ visited the root before this contrary move, then the move was added to $\mathcal{M}$ in Case 4, and in $r$'s most recent right move on edge $e$ it swapped with token $t$. \item Finally, if $r$ is a non-slot token and its contrary (left) move is on an edge in the ordering gadget and $r$ did not visit the root before this contrary move, then the move was added to $\mathcal M$ in Case 5. As already noted, Case 5 added $|S|$ distinct contrary moves to $\mathcal M$ to pay for the tokens $t \in S$. \end{itemize} Thus, we have shown what we set out to show at the beginning of this section: a solution to our token swapping instance must have $|A|/2$ contrary moves dedicated to the task of getting the non-item tokens to their target destinations. However, to argue that the contrary moves that we will count in future sections are disjoint from those counted in this section, we need to be more precise about how imposters are chosen. \paragraph*{How to choose non-leaving imposters.} We will prove the following lemma, which limits the number of non-leaving imposters. % \begin{lemma}\label{lem:FewImposters} We can choose non-leaving imposters so that the total number of unique non-leaving imposters is less than or equal to % $n(m+1)$. \end{lemma} \begin{proof} Recall that $S$ is the set of slot tokens $t$ such that every imposter for $t$ is a non-leaving imposter. Tokens of $S$ are exactly the tokens for which we must choose a non-leaving imposter. We show how to choose non-leaving imposters so that if two tokens in $S$ were initially in the same segment (the same $y_j$ or $q_{i,j}$) then they are assigned the same imposter. This proves that the number of unique non-leaving imposters is less than or equal to the number of segments initially in the slot gadgets. There are $n$ big segments and $nm$ padding segments in the slot gadgets, so the bound is $n(m+1)$, as required. Let $G$ be the set of slot tokens from one segment. Observe that every token in $G$ swaps with the same set of tokens in the scaffold solution. Let $G'$ be $G \cap S$. Then every $g \in G'$ has a non-leaving imposter and does not have any other kind of imposter. We must show that all tokens in $G'$ can share the same non-leaving imposter. Consider the last time each token in $G'$ enters the ordering gadget, and let $t$ be the last token to do so. \begin{claim} $t$ swaps with an imposter after it enters the ordering gadget for the last time. \end{claim} \begin{proof} Let $d_t = h + h'$ where $h$ is the distance from $t$'s initial position to the root and $h'$ is the distance from the root to $t$'s target position. Then $t$ must make at least $h$ left moves before it reaches the root for the first time, and must make at least $h'$ left moves after it reaches the root for the last time. These moves all occur on $t$'s main path. As noted in the proof of Claim~\ref{claim:imposter}, the number of non-item tokens that $t$ swaps with in the scaffold solution is $d_t -1$. Since $t$ has already used up at least $h$ of them on its way to the root (where it met no imposters along the way), there are at most $h' -1$ of them left. Therefore $t$ must swap with an imposter during a left move after $t$ enters the ordering gadget for the last time. \end{proof} Let $r$ be an imposter that $t$ swaps with after it enters the ordering gadget for the last time. Note that $r$ must be a non-leaving imposter, since $t$ did not have any other kind of imposter. We claim that $r$ is also a non-leaving imposter for every token in $G'$. Since the tokens in $G'$ only have non-leaving imposters, it suffices to show that $r$ is an imposter for every token $g \in G'$. To do this, we prove that: (1) $g$ swaps with $r$ while $g$ makes a left move on an edge of the ordering gadget (note that the ordering gadget is part of every slot token's main path); and (2) $g$ does not swap with $r$ in the scaffold solution. By definition of $t$, when $t$ enters the ordering gadget for the last time, every other token in $G'$ is in the ordering gadget and will not leave again. After $t$ enters the ordering gadget it swaps with $r$, and after that, $r$ reaches the root for the first time. Thus, before $r$ reaches the root, it must swap with every token $g$ in $G'$ with $r$ moving right and $g$ moving left. This proves~(1). Since all tokens in $G$ swap with the same set of tokens in the scaffold solution, the fact that $r$ does not swap with $t$ in the scaffold solution means that $r$ does not swap with any token in $G'$ in the scaffold solution. This proves (2). \end{proof} \subsubsection{Interface between Sections~\ref{sec:Back moves for any instance} and~\ref{sec:Back moves for NO instance}: Characterization of contrary moves}\label{sec:interface} In this section we will characterize the contrary moves that we counted in Section~\ref{sec:Back moves for any instance}, so that we can argue that the contrary moves % we will count in forthcoming Section~\ref{sec:Back moves for NO instance} are disjoint from those already counted. We say that the \defn{initial gadget} of a non-item token $t$ is the gadget (either the ordering gadget or one of the slot gadgets) containing $t$'s initial position. Similarly, the \defn{final/destination gadget} of $t$ is the gadget containing $t$'s final position. Recall that $\mathcal{M}$ is the set of contrary moves counted in Section~\ref{sec:Back moves for any instance}. The following observation follows directly from the construction of $\mathcal{M}$. These correspond to {\bf Cases 1-5} in Section~\ref{sec:Back moves for any instance}. \begin{observation}\label{obs:purple} $\mathcal{M}$ can be written as $\mathcal{M}=M_1\cup M_2 \cup M_3 \cup M_4 \cup M_5$, where each $M_i$ is a set of contrary moves that are \emph{not} into or out of the nook, with the following properties: \begin{enumerate} \item $M_1$ is a set of contrary (right) moves of item tokens. \item $M_2$ is a set of contrary (right) moves of slot tokens with the following properties: \begin{itemize} \item Each contrary move in $M_2$ occurs in a slot gadget $i$ where the \emph{other} token in the swap is a slot token $t$ whose initial position is in slot gadget $i$. \item $M_2$ contains at most one such contrary move for each slot token $t$. \end{itemize} \label{purp2} \item $M_3$ is a set of contrary (left) moves of non-slot tokens with the following properties: \begin{itemize} \item Each contrary move in $M_3$ of a token $s$ occurs on an edge $e$ in a slot gadget $i$ that is not $s$'s destination gadget. \item In $s$'s most recent right move on edge $e$, $s$ swapped with a slot token $t$ whose initial gadget is slot gadget $i$. \item $M_3$ contains at most one such contrary move for each slot token $t$. \end{itemize} \label{purp3} \item $M_4$ is a set of contrary (left) moves of non-slot tokens with the following properties: \begin{itemize} \item Each contrary move in $M_4$ occurs in the ordering gadget. \item For each contrary move in $M_4$, the token $s$ that performs the contrary move was at the root at some point previously. \end{itemize} % \item $M_5$ is a set of contrary (left) moves of a set of at most $n(m+1)$ non-slot tokens, that occur in the ordering gadget. The bound of $n(m+1)$ follows from Lemma~\ref{lem:FewImposters}. \end{enumerate} \end{observation} The following result follows directly from Observation~\ref{obs:purple} and is an explicit description of various contrary moves that are \emph{not} in $\mathcal{M}$. We list these moves here for easy reference from Section~\ref{sec:Back moves for NO instance}. \begin{corollary}\label{obs:interface}$ $ \begin{enumerate} \item Any contrary (left) move of a non-slot token that is in its destination slot gadget is not in $\mathcal{M}$.\label{int1} \item Any contrary (right) move of a slot token $s$ swapping with a token $t$ that occurs in slot gadget $i$, such that $i$ is $s$'s initial gadget and $i$ is \emph{not} $t$'s initial gadget, is not in $\mathcal{M}$.\label{int6} \item Any contrary move of a non-item token into or out of the nook is not in $\mathcal{M}$.\label{int4} \item Any contrary move of a non-item token that is in a slot gadget that is not its final gadget, such that the other token in the swap is an item token, is not in $\mathcal{M}$.\label{int5} \item If a slot token $t$ has $\lambda$ many swaps in either $t$'s initial slot gadget or the ordering gadget, in which the other token in each of these swaps is a slot token doing a contrary (right) move, then at least $\lambda-1$ of these contrary moves are not in $\mathcal{M}$.\label{int2} \item If a non-slot token $t$ has $\lambda$ many swaps in the ordering gadget, in which the other token in each of these swaps is doing a contrary (left) move and is a non-slot token that has not yet reached the root, then at least $\lambda-n(m+1)$ of these contrary moves are not in $\mathcal{M}$.\label{int3} \end{enumerate} \end{corollary} \subsubsection{Moves to get item tokens to their destinations} \label{sec:Back moves for NO instance} Recall that we assume that the token swapping instance that was constructed from an instance of Star STS has a solution with at most $K$ swaps. By Lemma~\ref{lemma:contrary-move-bound}, the solution has at most $|A|/2 + n$ contrary moves. Previously, we found a set $\mathcal M$ of $|A|/2$ contrary moves in the solution that are required to get the non-item tokens to their destinations. This leaves at most $n$ contrary moves to complete the job of getting the item tokens to their destinations. In this section we will show that if the big/padding segments are very long, then the movement of tokens is constrained enough that we can prove the structural properties of Lemma~\ref{lem:free-item-token}. Recall from the construction that the length of a big segment is $k=(mn)^c$ for a large constant $c$. Set $c=25$. We will assume $n,m > 5$. % The following observation will be useful. \begin{observation}\label{obs:contrary} The total number of contrary moves in the token swapping solution is less than $k^{1+1/c} =kmn$, and the number of contrary moves not in $\mathcal{M}$ is less than $k^{1/c} = mn$. \end{observation} \begin{proof} By Lemma~\ref{lemma:contrary-move-bound} the number of contrary moves is at most $|A|/2 + n$. Plugging in $|A| = 2nk + 2nmk'$ and $k' = k/n^8$ this is $\le nk + nmk/n^8 + n < kmn = k^{1 + 1/c}$. The number of contrary moves not in $\mathcal M$ is at most $n$ and $n < mn = k^{1/c}$. In both cases, we used $n,m > 1$. \end{proof} This section has four subsections: \begin{enumerate} \item In Section~\ref{sec:Segment Ordering}, we show that tokens are constrained in the sense that the segments reach the root in roughly the same order as in the scaffold solution. \item In Section~\ref{sec:Ordering Lemma}, we show that the tokens are constrained in the sense that each individual token cannot get too far out-of-order with its surrounding tokens. \item In Section~\ref{sec:Item Tokens Stuck}, we use the above results to prove the key lemma that every slot gadget contains an item token ``near'' its nook at all times. \item In Section~\ref{sec:Item and Segment Swap} we combine the above results to complete the proof of Lemma~\ref{lem:free-item-token}. \end{enumerate} \paragraph{Correspondence with the scaffold solution}\label{sec:Segment Ordering}% In this section we will show that the movement of tokens in our solution is similar to that of the scaffold solution. The main lemma of this section is Lemma~\ref{lem:segbyseg}, which says that tokens reach the root in roughly the same order as in the scaffold solution. We start with a simple lemma that shows that not many tokens can enter and exit one gadget (as made precise below). We use ``gadget'' here to mean a slot gadget or the ordering gadget. Note that a token leaves the gadget it is in if and only if it reaches the root. We will find it convenient to use both expressions when we talk about the movement of tokens. Note that a token can leave any gadget, i.e., reach the root, many times throughout the sequence of swaps. \begin{lemma} \label{lem:swapNotOutsideOfGadget} Let $S$ be a set of tokens, all of which are either slot or non-slot tokens. Let $g$ be a gadget. Suppose that either of the following situations occur: \begin{enumerate} \item At some time $\tau$, all tokens of $S$ are in gadget $g$, but each token of $S$ was outside $g$ at some time before $\tau$ and at some time after $\tau$. \item At two time points $\tau_1$ and $\tau_2$, all tokens of $S$ are in gadget $g$, but each token of $S$ % reached the root at some time between $\tau_1$ and $\tau_2$. \end{enumerate} Then the tokens of $S$ make at least $\frac{1}{2}|S|^2$ contrary moves, and consequently, $|S| \le k^{1/2 + 1/c}$. \end{lemma} \begin{proof} Depending on whether % the tokens of $S$ are slot or non-slot tokens, either moving the tokens out of, or % into, the gadget $g$ will count as contrary moves. In either case the tokens of $S$ make at least $1+2+ \cdots + |S| > \frac{1}{2} |S|^2$ contrary moves. If $|S| > k^{1/2 + 1/c}$, then the number of contrary moves is $> \frac{1}{2}k^{1 + 2/c} > k^{1 + 1/c}$, which contradicts Observation~\ref{obs:contrary}. \end{proof} Recall that for any token $t$, its \defn{initial gadget} is the gadget that contains $t$'s initial position, and its \defn{final gadget} is the gadget that contains $t$'s final position. The next lemma says that if a large number of tokens have reached the root, then most of them have entered their final gadgets for the last time. \begin{lemma}\label{lem:indest} Let $S$ be a set of at least $\ell=k^{1/2+2/c}$ tokens that are either all slot tokens or all non-slot tokens. If, at some point in time, every token in $S$ has reached the root then every token in $S$ except for at most $\ell$ of them has entered its final gadget for the last time. \end{lemma} \begin{proof} We consider the situation at % the point in time stipulated in the lemma. Let $R$ be the tokens of $S$ that have entered their final gadgets for the last time. Our goal is to show that $|S \setminus R| \le \ell$. Observe that $S \setminus R$ is a disjoint union of two sets: $S'$, the tokens of $S$ that are not in their final gadgets, and $S''$, the tokens of $S$ that are in their final gadgets, but will subsequently leave (and then re-enter) those gadgets. Thus our goal is to show that $|S'| + |S''| \le \ell$. We will use Lemma~\ref{lem:swapNotOutsideOfGadget} to bound their sizes. Consider $S'$. By the pigeonhole principle, at least one of the $m+1$ gadgets, say gadget $g$, contains a set $X$ of at least $|S'|/(m+1)$ tokens from $S'$. Since $g$ is not the final gadget for any token in $X$, they will all eventually leave gadget $g$. By assumption, every token $t \in X$ has reached the root before the current time point, so $t$ has been outside $g$ at a previous time. Thus by Lemma~\ref{lem:swapNotOutsideOfGadget}(1) we have $|S'|/(m+1) \le k^{1/2 + 1/c}$. Next consider $S''$. Again by the pigeonhole principle, at least one of the $m+1$ gadgets, say gadget $g$, contains at least $|S''|/(m+1)$ tokens from $S''$. These tokens are currently in $g$, will each leave $g$ at some later time (by definition of $S''$), and will all eventually be back in $g$ (since $g$ is their final gadget). Thus by Lemma~\ref{lem:swapNotOutsideOfGadget}(2), we have $|S''|/(m+1) \le k^{1/2 + 1/c}$. Now $|S'| + |S''| \le 2(m+1)k^{1/2 + 1/c} \le k^{1/2 + 2/c}$ for $m,n > 2$ giving the required bound. \end{proof} Next, we prove a related lemma which says that, for any slot gadget $g$, if many tokens with initial positions in $g$ have reached the root then almost as many tokens with final gadget $g$ have entered $g$ for the last time. This lemma is not needed until Section~\ref{sec:Item Tokens Stuck}, but we place it here because its proof heavily depends on Lemma~\ref{lem:indest}. \begin{lemma}\label{lem:exchange} Let $S$ be a set of at least $k^{1/2+3/c}$ tokens that all have slot gadget $g$ as their initial gadget. Let $\tau_1$ be a point in time where no token in $S$ has reached the root, and let $\tau_2$ be a later point in time after every token in $S$ has reached the root. Then, between $\tau_1$ and $\tau_2$, at least $|S|-k^{1/2+3/c}$ many tokens (not in $S$) whose final gadget is $g$ enter gadget $g$ for the last time. \end{lemma} \begin{proof} Let $S'$ be the set of tokens that were not in slot gadget $g$ at time $\tau_1$, but are in slot gadget $g$ at time $\tau_2$. We will show that $(i)$ $S'$ is big enough for the statement to hold and $(ii)$ few tokens of $S'$ subsequently leave gadget $g$. For Statement $(i)$, we first apply Lemma~\ref{lem:indest} to $S$. Set $S$ has size at least $\ell =k^{1/2+2/c}$ and at time $\tau_2$ all the tokens of $S$ have reached the root, so, by the lemma, all except at most $\ell$ of them have entered their final gadgets (which are different from $g$) for the last time. Since all tokens of $S$ were in gadget $g$ at time $\tau_1$ and at least $|S| - \ell$ of them are not in gadget $g$ at time $\tau_2$, therefore $|S'| \ge |S| - \ell$ (since the missing tokens must have been replaced). For Statement ($ii$), we apply Lemma~\ref{lem:swapNotOutsideOfGadget}(1) to $S'$. All the tokens of $S'$ are in gadget $g$ at time $\tau_2$, all of them were outside gadget $g$ at a previous time, and therefore, the number that can leave gadget $g$ after time $\tau_2$ is at most $k^{1/2 + 1/c}$ which is less than $\ell$. Putting these together, the number of tokens that have entered gadget $g$ and will remain there until the end is at least $|S| - 2\ell$. Since $2\ell < k^{1/2 + 3/c}$, this gives the bound we want. \end{proof} Recall that in the scaffold solution, the segments reach the root in a particular order, as specified by property (P5) of the scaffold solution. Now we show that, although not all tokens in our solution obey this particular order, many tokens do. In particular, the \defn{core} of each segment, defined below, behaves like the scaffold solution. \begin{definition} \label{def:core} Let $S$ be a segment. Order the tokens of $S$ by the first time they reach the root. The \defn{core}, $C(S)$, is the set of all tokens in $S$ except for the first and last $k^{1/2+3/c}$ in this ordering. \end{definition} \begin{lemma}\label{lem:segbyseg} Let $S_1$ and $S_2$ each be a segment (either a big segment or a padding segment) of slot tokens such that tokens of $S_1$ reach the root before tokens of $S_2$ in the scaffold solution. Then, in our token swapping solution, all tokens of $C(S_1)$ reach the root before any token of $C(S_2)$ does so. \end{lemma} \begin{proof} Note that because $S_1$ and $S_2$ consist of slot tokens, their final gadget is the ordering gadget. Also, by property (P5) of the scaffold solution, the final positions of the tokens in $S_1$ are to the left of tokens of $S_2$ in the ordering gadget. Consider the order in which the tokens of $S_1 \cup S_2$ reach the root for the first time. We must show that (all tokens of) $C(S_1)$ come before (all tokens of) $C(S_2)$ in this ordering. Assume for the sake of contradiction that a token $t_2$ of $C(S_2)$ comes before a token $t_1$ of $C(S_1)$ in the ordering. Let $L_1 \subseteq S_1$ be the last $k^{1/2+3/c}$ tokens of $S_1$ in the ordering (i.e., the tokens of $S_1$ after $C(S_1)$) and let $F_2$ be the first $k^{1/2+3/c}$ tokens of $S_2$ in the ordering (i.e., the tokens of $S_2$ before $C(S_2)$). Then $F_2$ comes before $t_2$, which in turn comes before $t_1$ (which also comes before $L_1$). Let $\tau$ be the time point just after all tokens of $F_2$ have reached the root. At time $\tau$, none of the tokens of $L_1$ have reached the root, so none of them are in the ordering gadget. Apply Lemma~\ref{lem:indest} to $F_2$ and the time point $\tau$. The lemma gives us a set $F'_2 \subseteq F_2$ of tokens that have entered the ordering gadget for the last time at time $\tau$, where $|F'_2| \ge k^{1/2+3/c} - k^{1/2-2/c}$. However, as already noted, the final positions of the tokens in $S_1$ are to the left of tokens of $S_2$. In particular, the final positions of the tokens in $L_1$ are to the left of the tokens of $F'_2$. Thus, $L_1$ (which is outside the ordering gadget at time $\tau$) and $F'_2$ must pairwise swap in the ordering gadget. During these swaps, the tokens in $F'_2$ are performing contrary (right) moves. This amounts to a total of $|F'_2||L_1|\geq (k^{1/2+3/c}-k^{1/2-2/c})(k^{1/2+3/c})>k^{1+1/c}$ contrary moves, a contradiction to Observation~\ref{obs:contrary}. \end{proof} From the definition of core (and construction of gadgets) we get the following bounds on the size of each core: \begin{lemma}\label{lem:noncore} If $S$ is a segment, then $|C(S)|>k^{1-9/c}$. Also, for any slot gadget $i$, the total number of tokens initially in slot gadget $i$ that are \emph{not} in the core of any segment is less than $k^{1/2+5/c}$. \end{lemma} \begin{proof} Each segment is of size at least $k/n^8$, and exactly $2k^{1/2+3/c}$ tokens in each segment are not in the core. Thus, $|C(S)|\geq k/n^8-2k^{1/2+3/c}>k^{1-9/c}$ since $c>22$. The second statement follows from the fact that any slot gadget contains at most $2n$ segments ($n$ padding segments and at most $n$ big segments), and for each segment, exactly $2k^{1/2+3/c}$ tokens are not in the core. Thus, there are at most $2n \cdot k^{1/2+3/c}<k^{1/2+5/c}$ many tokens initially in slot gadget $i$ that are not in the core of any segment. \end{proof} \paragraph{Individual tokens stay roughly in order}\label{sec:Ordering Lemma}$ $\\ \ The main lemma of this section (Lemma~\ref{lem:OutOfOrder}) shows that no individual token that is currently in a slot gadget can get too far out of order with respect to its surrounding tokens (see below for a precise definition of `out of order'). More precisely, we show that in any solution to the token swapping instance that has at most $K$ swaps, no intermediate token configuration can contain a set of $\ell=k^{1/2+2/c}$ tokens that are all out of order with a token $t$ in a slot gadget, as otherwise there would be too many contrary moves. We use the fact (proved in Lemma~\ref{tooManyContraryMoves}) that by Observation~\ref{obs:contrary}, the token swapping sequence can neither use $\frac{\ell}{2^4(m+1)}$ % contrary moves that are disjoint from moves accounted in $\mathcal{M}$ (c.f.~Corollary~\ref{obs:interface}), nor it can use $\frac{\ell^2}{2^53^2(m+1)^2}$ % contrary moves in total (irrespective of whether they are disjoint from $\mathcal{M}$ or not) -- as in both cases these would be more contrary moves than the token swapping instance can afford. % Recall that for a slot token with initial position in slot gadget $i$ or a non-slot token with target position in slot gadget $i$, its \defn{main path} is the path consisting of the slot gadget $i$ (not including the nook edge) and the ordering gadget, connected via the root. \begin{definition} Let $t$ and $s$ be two slot tokens that share the same initial gadget or two non-slot tokens that share the same final gadget. Observe that $t$ and $s$ have the same main path $p$. We say that $t$ is \defn{out of order} with $s$ if $t$ and $s$ are both on their main path $p$, but $s$ is on the opposite side of $t$ than it was initially. Note that this relation is symmetric, that is, if $t$ is out of order with $s$, then also $s$ is out of order with $t$. Moreover, we say that $t$ is \defn{out of order} with a set $S$ of tokens if $t$ is out of order with every element $s \in S$. \end{definition} In what follows, we first show that transforming certain token configurations into others uses too many contrary moves. To this end, we start by proving two auxiliary lemmas % and by identifying Transformations 1--4. These will subsequently be used in the proof of the main Lemma~\ref{lem:OutOfOrder} of this section. Consider the four transformations in Figure~\ref{fig:transformations}. Each transformation shows a pair of configurations and assumes that a token swapping sequence transforms the first configuration into the second one. The type of token $t$ (slot or non-slot), as well as its position relative to a set $S$ of $\lambda$ tokens of the same type are marked in each configuration. \begin{figure}[tbh] \centering \includegraphics[width=\textwidth]{Figures/transformations.pdf} \caption{Four transformations. The empty circle denotes the root of the tree. In each configuration, the solid and dashed ovals mark the possible location of the set $S$ of $\lambda$ tokens. Token $t$ can be anywhere inside the marked gadget or at the root as long as it respects its position relative to the set~$S$. The marked gadget is assumed to be $t$'s initial or target gadget, depending on the context. The tokens from $S$ have the same initial and target gadget as $t$. % } \label{fig:transformations} \end{figure} \begin{lemma} \label{lem:transformations} If $t$ exchanges its order with each of the $\lambda$ tokens of the set $S$ inside the same gadget as the one in which $t$ starts and ends a transformation, then realizing any of the four transformations from Figure~\ref{fig:transformations} takes either at least $ \lambda^2/(2\cdot3^2)$ contrary moves or at least $\lambda/3-n(m+1)$ contrary moves that are disjoint from contrary moves accounted in $\mathcal{M}$. \end{lemma} \begin{proof} All four transformations are argued by contradiction. Typically, the token $t$ will be able to exchange with tokens of $S$ in the marked gadget $i$ in up to 3 different ways, and so there will always be a subset $S'$ of at least $\lambda/3$ tokens from $S$ that swapped with $t$ in the same way. {\bf Transformation 1.} There are three possibilities: either the tokens of $S'$ swap directly with the token $t$ in the slot gadget $i$ (Case a), or each of the $S'$ tokens at some point enters the nook and the token $t$ passes it by moving in slot gadget $i$ % (Case b), or the token $t$ enters the nook and the $S'$ tokens pass it by moving in the slot gadget % (Case c). In Case a, $t$ is a slot token in its initial slot gadget and each $s\in S'$ makes a contrary (right) move when swapping with $t$. By Corollary~\ref{obs:interface}(\ref{int2}), these are % at least $\lambda/3$ contrary moves that were not accounted in $\mathcal{M}$. In Case b, moving each slot token $s\in S'$ into the nook is a contrary (right) move. By Corollary~\ref{obs:interface}(\ref{int4}), these are at least $\lambda/3$ % contrary moves that were not accounted in $\mathcal{M}$. For Case c, note that all $\geq \lambda/3$ % tokens of $S'$ are to the left of $t$ just before $t$ enters the nook for the first time, and all these tokens are to the right of $t$ after $t$ leaves the nook for the last time. Hence the block of at least $ \lambda/3$ % slot tokens of $S'$ moved by at least $ \lambda/3$ % vertices to the right, which takes at least $\frac{1}{2}\cdot (\frac{\lambda}{3})^2$ % contrary (right) moves. {\bf Transformation 2.} The same three possibilities as for Transformation 1 need to be discussed. In Case a, when each non-slot token $s\in S'$ swaps directly with $t$, it makes a contrary (left) move in its destination gadget. These are at least $ \lambda/3$ % contrary moves that by Corollary~\ref{obs:interface}(\ref{int1}) were not accounted in $\mathcal{M}$. In Case b, every time a non-slot token $s \in S'$ moves out of the nook, it makes a contrary (left) move. These are at least $ \lambda/3$ % contrary moves that by Corollary~\ref{obs:interface}(\ref{int4}) were not accounted in $\mathcal{M}$. In Case c, the at least $\lambda/3$ % non-slot tokens of $S'$ shift by at least $ \lambda/3$ % vertices to the left, which takes at least $ \frac{1}{2}\cdot(\frac{\lambda}{3})^2$ % contrary (left) moves. {\bf Transformation 3.} The only possibility here is that each token $s \in S$ directly swaps with the slot token $t$ in the ordering gadget, meaning that the slot token $s$ makes a contrary (right) move. These are $\lambda$ % contrary moves that by Corollary~\ref{obs:interface}(\ref{int2}) were not accounted in $\mathcal{M}$. {\bf Transformation 4.} The non-slot token $t$ must again swap directly with each $s \in S$ in the ordering gadget but we distinguish two cases depending on whether the tokens of $S'$ have never left the ordering gadget before swapping with $t$ (Case a) or whether they did (Case b). Note that `never left the ordering gadget' refers to the entire token swapping sequence, possibly even before Transformation 4 started. In Case a, each non-leaving non-slot token $s$ of $S'$ makes a contrary (left) move when swapping with $t$. These are at least $ \lambda/3$ contrary moves, out of which by Corollary~\ref{obs:interface}(\ref{int3}) at most $n(m+1)$ have been accounted in $\mathcal{M}$. Hence, there are at least $\lambda/3 - n(m+1)$ contrary moves disjoint from $\mathcal{M}$. In Case b, each $s \in S'$ had visited the root before it swapped with $t$ and eventually all $\geq \lambda/3$ % tokens of $S'$ lie to the left of $t$ in the ordering gadget. Hence the tokens in $S'$ must have altogether made at least $1+2+\dots+\lambda/3 \geq \frac{1}{2}\cdot(\frac{\lambda}{3})^2$ % contrary (left) moves (some of them possibly before the transformation started). \end{proof} The following lemma lists bounds that imply too many contrary moves in the token swapping instance. \begin{lemma} \label{tooManyContraryMoves}$ $ \begin{enumerate} \item The total number of contrary moves in the token swapping solution is less than $\frac{\ell^2}{2^53^2(m+1)^2}$.\label{tooManyItem1} \item If $\lambda\geq\frac{\ell}{4(m+1)}$, then realizing any of the four transformations from Figure~\ref{fig:transformations} as described in Lemma~\ref{lem:transformations} requires too many contrary moves (i.e., either too many contrary moves in total, or too many contrary moves that are disjoint from contrary moves accounted in~$\mathcal{M}$).\label{tooManyItem2} \end{enumerate} \end{lemma} \begin{proof}$ $ \begin{enumerate} \item Recall that $\ell = k^{1/2+2/c}$, we assume that $m,n>5$ and from the construction of the token swapping instance, $k=(mn)^c$. Hence, $\frac{\ell^2}{2^53^2(m+1)^2} = k^{1+1/c}\cdot \frac{m^3n^3}{2^53^2(m+1)^2}$ which exceeds $k^{1+1/c}$ contrary moves given in Observation~\ref{obs:contrary} whenever $m,n\geq 5$. \item By Lemma~\ref{lem:transformations}, the four transformations in Figure~\ref{fig:transformations} result in either at least $ \lambda^2/(2\cdot3^2)$ contrary moves or at least $\lambda/3-n(m+1)$ contrary moves that are disjoint from contrary moves accounted in $\mathcal{M}$. We show that either case exceeds the number of available contrary moves. % By assumption on $\lambda$, we have $\lambda^2/(2\cdot3^2) \geq \frac{\ell^2}{2^53^2(m+1)^2}$ which by the first statement of the current lemma are too many contrary moves. For the second case, we show that $\lambda/3-n(m+1) \geq \lambda/4 \geq k^{1/c}$. By Observation~\ref{obs:contrary}, this will imply that there are too many contrary moves disjoint from $\mathcal{M}$. To prove the first inequality, it suffices to show that $\lambda/12 \geq n(m+1)$. Recall that $\ell=k^{1/2+2/c}$, by construction of the token swapping instance $k=(mn)^c$ and we have set $c=25$. By assumption, $\lambda \geq \frac{\ell}{4(m+1)}$ which implies $\lambda \geq \frac{(mn)^{c/2}(mn)^2}{4(m+1)}$. % We obtain that $\lambda/12 \geq \frac{(mn)^{c/2}(mn)^2}{48(m+1)} \geq n(m+1)$ holds whenever $m,n \geq 2$. % Finally, $\lambda/4 \geq \frac{\ell}{16(m+1)}= k^{1/c} \cdot \frac{(mn)^{1+c/2}}{16(m+1)}$ % and this exceeds $k^{1/c}$ whenever $m,n\geq2$. \end{enumerate} \end{proof} We can now prove the main lemma: \begin{lemma} \label{lem:OutOfOrder} At all times, for every non-item token $t$ that is currently in a slot gadget or at the root, there does not exist a set $S$ of $\ell=k^{1/2+2/c}$ tokens that are out of order with $t$. \end{lemma} \begin{proof} Suppose for a contradiction that $t$ is out of order with a set $S$ of $\ell$ tokens of the same type (i.e., all slot or all non-slot tokens). Observe that with respect to the main path of $t$ at least $\ell / 2$ of these tokens are on the same side (either left or right) of $t$. Call this subset $S'$, $|S'| \geq \ell / 2$. We will consider four cases: the token $t$ is either a slot or a non-slot token and the set $S'$ is either to the right or to the left of $t$, see Figure~\ref{fig:four_cases.pdf}. \begin{figure}[tbh] \centering \includegraphics[scale=0.8]{Figures/four_cases.pdf} \caption{Four cases considered in proof of Lemma~\ref{lem:OutOfOrder}. The empty circle denotes the root of the tree. The bottom-most slot gadget indicates the initial or the target slot gadget (depending on the context) of token $t$ and of all tokens from $S$.} \label{fig:four_cases.pdf} \end{figure} {\bf Case 1.} If $t$ is a slot token that is to the left of the set $S'$ of slot tokens in the current out-of-order configuration, then the initial configuration of the token swapping instance must have had $t$ in the same slot gadget on the right side of $S'$. Transforming the initial configuration into the current out-of-order configuration is exactly Transformation 1. If $\ell/4$ or more % tokens from $S'$ exchange with $t$ inside the slot gadget, then by Lemma~\ref{tooManyContraryMoves}(\ref{tooManyItem2}) % there are too many contrary moves. Otherwise there is a subset $S''$ of at least $|S'|/2\geq\ell/4$ tokens from $S'$ that exchange with $t$ outside of the slot gadget. Then, in order for $t$ to get out of this slot gadget, all $S''$ tokens must first get out of the gadget and then re-enter it again. Hence, Lemma~\ref{lem:swapNotOutsideOfGadget} applies and there are at least $\frac{1}{2}\cdot(\frac{\ell}{4})^2=\ell^2/2^5$ % contrary moves, which is by Lemma~\ref{tooManyContraryMoves}(\ref{tooManyItem1}) too many. {\bf Case 2.} If $t$ is a non-slot token that is to the left of the set $S'$ of non-slot tokens in the current out-of-order configuration, then the final configuration of the token swapping instance must have $t$ in the same slot gadget on the right side of $S$. Transforming the current out-of-order configuration into the final configuration is exactly Transformation 2. By a similar argument as in Case 1, the Lemmas~\ref{tooManyContraryMoves}(\ref{tooManyItem2})% , \ref{lem:swapNotOutsideOfGadget} and \ref{tooManyContraryMoves}(\ref{tooManyItem1}) show that $t$ cannot exchange order with the tokens from $S'$ inside nor outside of the slot gadget. {\bf Case 3.} Assume that $t$ is a slot token and the set $S'$ of slot tokens is to the left of it, each such token either in the same slot gadget $i$ or in the ordering gadget. Consider the first time after the current out-of-order configuration that token $t$ reaches the root: this intermediate configuration has at least % $\frac{\ell}{2(m+1)}$ tokens of $S'$, call this set $S''$, either in slot gadget $i$ (Subcase~a), or in a slot gadget $j\neq i$ (Subcase~b), or in the ordering gadget (Subcase~c). In Subcase a, % all $\geq\frac{\ell}{2(m+1)}$ % tokens of $S''$ must exchange their order with token $t$ inside the slot gadget $i$ between the current out-of-order configuration and the intermediate configuration. This is exactly Transformation 1 and by Lemma~\ref{tooManyContraryMoves}(\ref{tooManyItem2}) it causes too many contrary moves. In Subcase b, moving the $S''$ slot tokens from their current position into slot gadget $j$ (for the intermediate configuration) takes at least $\frac{1}{2}\cdot(\frac{\ell}{2(m+1)})^2$ % contrary (right) moves, which are again by Lemma~\ref{tooManyContraryMoves}(\ref{tooManyItem1}) more contrary moves than we can afford. Finally, note that given the current out-of-order configuration, the target configuration of the token swapping instance must have $t$ to the left of $S'$ tokens in the ordering gadget. Thus, in Subcase c, transforming the intermediate configuration into the target configuration is exactly Transformation 3. If at least half of the $S''$ tokens, i.e.,~ $\frac{\ell}{4(m+1)}$ tokens, exchange with $t$ inside the ordering gadget, then by Lemma~\ref{tooManyContraryMoves}(\ref{tooManyItem2}) there are too many contrary moves. Otherwise at least $|S''|/2\geq\frac{\ell}{4(m+1)}$ tokens of $S''$ exchange with $t$ outside of the ordering gadget. For that, they must all first leave and then re-enter the ordering gadget. By Lemma~\ref{lem:swapNotOutsideOfGadget}, this results in at least $\frac{1}{2} \cdot (\frac{\ell}{4(m+1)})^2$ contrary moves which by Lemma~\ref{tooManyContraryMoves}(\ref{tooManyItem1}) are too many. {\bf Case 4.} Assume that $t$ is a non-slot token and the set $S'$ of non-slot tokens is to the left of it, each such token either in the same slot gadget $i$ or in the ordering gadget. Consider the last time before the current out-of-order configuration that token $t$ was at the root: this intermediate configuration has at least $\frac{\ell}{2(m+1)}$ % tokens of $S'$, call this set $S''$, either in slot gadget~$i$ (Subcase~a), or in a slot gadget $j\neq i$ (Subcase~b), or in the ordering gadget (Subcase~c). In Subcase a, % all $\geq\frac{\ell}{2(m+1)}$ % tokens of $S''$ must exchange their order with token $t$ inside the slot gadget $i$ between the intermediate and the current out-of-order configuration. This is exactly Transformation 2 and by Lemma~\ref{tooManyContraryMoves}(\ref{tooManyItem2}) it causes too many contrary moves. In Subcase b, moving the $S''$ non-slot tokens out of slot gadget $j$ (in the intermediate configuration) to their current position takes at least $\frac{1}{2}\cdot(\frac{\ell}{2(m+1)})^2$ % contrary (left) moves, which are again by Lemma~\ref{tooManyContraryMoves}(\ref{tooManyItem1}) more contrary moves than we can afford. Finally, note that given the current out-of-order configuration, the initial configuration of the token swapping instance must have $t$ to the left of $S'$ tokens in the ordering gadget. Thus, in Subcase c, transforming the initial configuration into the intermediate configuration is exactly Transformation 4. If at least half of the $S''$ tokens, i.e.,~ $\frac{\ell}{4(m+1)}$ tokens, exchange with $t$ inside the ordering gadget, then by Lemma~\ref{tooManyContraryMoves}(\ref{tooManyItem2}) there are too many contrary moves. Otherwise at least $|S''|/2\geq\frac{\ell}{4(m+1)}$ tokens of $S''$ exchange with $t$ outside of the ordering gadget. By Lemma~\ref{lem:swapNotOutsideOfGadget}, this results in at least $\frac{1}{2} \cdot (\frac{\ell}{4(m+1)})^2$ contrary moves which by Lemma~\ref{tooManyContraryMoves}(\ref{tooManyItem1}) are too many. \end{proof} \paragraph{Every slot gadget contains an item token at all times}\label{sec:Item Tokens Stuck}$ $\\ The goal of this section is to prove the following lemma. \begin{lemma}\label{lem:LeafLeaving} At all times there is at least one item token in each slot gadget at distance at least $k(1-\frac{1}{4n})$ from the root. \end{lemma} \begin{proof} Our approach will be to suppose for contradiction that there is a slot gadget that does not satisfy the lemma statement, which in particular means that the token at the nook of that slot gadget is a non-item token. We will argue that having a non-item token in the nook with no item token nearby creates too many contrary moves. To be precise, suppose that there is a time $\tau$ when some slot gadget, say slot gadget $i$, does not have an item token at distance at least $k(1-\frac{1}{4n})$ from the root. Let $\tau_1$ be the last time before $\tau$ in which we had an item token occupying the nook, and let $q$ be that item token. Similarly, we define $\tau_2$ as the first time after $\tau$ when there is an item token occupying the nook, and let $q'$ be the item token. Note that both $\tau_1$ and $\tau_2$ must exist since the initial and target configurations are candidates for each of them, respectively. % Let $v$ be the unique vertex of slot gadget $i$ whose distance to the root is $k(1-\frac{1}{4n})$. Equivalently, $v$ is the vertex $\frac{k}{4n}$ vertices to the left of the nook parent of slot gadget $i$. At time $\tau_1$, $q$ was at the nook of slot gadget $i$, and before time $\tau$, $q$ reached vertex $v$. That is, between times $\tau_1$ and $\tau$, token $q$ traverses all of the $\frac{k}{4n}$ edges from the nook parent to $v$. Let $R$ be the set of tokens that $q$ swaps with on $q$'s last traversal of each of these edges before time $\tau$. By Claim~\ref{lem:unique}, these tokens are distinct, so $|R|=\frac{k}{4n}$. We now give an overview of the proof. We first show that after their swaps with $q$, many of the tokens in $R$ proceed to pass by the nook parent in the rightward direction (Claim~\ref{claim:rightnook}). Then, we identify a non-item token $t$ that is in the nook while many of the tokens in $R$ pass by the nook parent (Claim~\ref{claim:tnook}). Then, we show that while $t$ is in the nook, many tokens also pass by the nook parent in the leftward direction, to ``replace'' the tokens in $R$ that are passing in the rightward direction (Claim~\ref{claim:Tbig}). Next, we show that $t$ cannot have slot gadget $i$ as its initial nor final gadget (Claim~\ref{claim:fromelsewhere}). This is because if $t$ has slot gadget $i$ as its initial or final gadget then $t$ will get out of order with the tokens that are passing by the nook in the leftward or rightward direction, respectively. This contradicts Lemma~\ref{lem:OutOfOrder} (which says that a token cannot be out of order with too many tokens). The remaining case is when $t$ does not have $i$ as either its initial or final gadget. In this case we find a similar type of contradiction: we find a large number of tokens that have the same initial and final gadget as $t$ that move out of their initial gadget and into their final gadget while $t$ stays in slot gadget $i$ (Claim~\ref{claim:slotfromt}). We are able to find these tokens because the segments (actually just their cores) reach the root in order according to the scaffold solution by Lemma~\ref{lem:segbyseg}, and the scaffold solution includes segments from \emph{every} slot gadget at high frequency due to the padding segments. The consequence of this is that $t$ becomes out of order with the tokens from its initial gadget that have entered their final gadget while $t$ is in slot gadget $i$, which again contradicts Lemma~\ref{lem:OutOfOrder}. We now formalize this intuition. Towards showing that many tokens in $R$ pass by the nook parent, we first show that many tokens in $R$ are non-slot tokens whose final gadget is $i$. \begin{claim}\label{claim:sizer2} $R$ contains at least $\frac{k}{4n}-k^{1/c}-k^{1/2+2/c}$ many non-slot tokens whose final gadget is $i$. \end{claim} \begin{proof} When token $r\in R$ swaps with $q$, $r$ moves to the right. Thus, if $r$ is a slot token, then $r$ does a contrary move. By Corollary~\ref{obs:interface}(\ref{int5}), this contrary move is not in $\mathcal{M}$. Thus, at most $k^{1/c}$ tokens in $R$ are slot tokens. Also, by Lemma~\ref{lem:indest}, at most $k^{1/2+2/c}$ of the tokens in $R$ are non-slot tokens whose final gadget is not~$i$. Since $|R|=\frac{k}{4n}$ we have that the number of tokens in $R$ that are non-slot tokens whose final gadget is $i$ is at least $\frac{k}{4n}-k^{1/c}-k^{1/2+2/c}$ as claimed. % \end{proof} Let $R_2$ be the subset of tokens in $R$ that are non-slot tokens whose final gadget is~$i$. % Now consider the movement of the tokens in $R_2$ between times $\tau_1$ and $\tau_2$. We claim that many tokens in $R_2$ move to the right of the nook parent. \begin{claim}\label{claim:rightnook} At least $k^{1-2/c}$ tokens in $R_2$ move to the right of the nook parent at some point between times $\tau_1$ and $\tau_2$. \end{claim} \begin{proof} First, we claim that fewer than $k^{1/2+1/c}$ tokens in $R_2$ can ever reach vertex $v$ (the vertex at distance $\frac{k}{4n}$ to the left of the nook parent) after swapping with $q$. This is because each token in $R_2$ swaps with $q$ along a unique edge of distance at most $\frac{k}{4n}$ from the nook. Thus, moving $k^{1/2+1/c}$ of these tokens to a distance \emph{at least} $\frac{k}{4n}$ from the nook requires at least $\frac{(k^{1/2+1/c})^2}{2}>k^{1+1/c}$ left moves, which are all contrary moves since every token in $R_2$ is a non-slot token. Other than the $k^{1/2+1/c}$ tokens mentioned above, any token that does not satisfy the claim must remain between $v$ and the nook parent from when it swaps with $q$ until time $\tau_2$. We will show that there are at most $k^{1/c}$ many such tokens. Recall that at time $\tau$ no item token is in slot gadget $i$ at distance at least $k(1-\frac{1}{4n})$ from the root. In particular, at time $\tau$, $q'$ (the item token defined by time $\tau_2$) is either in slot gadget $i$ between the root and $v$ or not in slot gadget $i$. At time $\tau_2$, $q'$ is at the nook. Thus, between times $\tau$ and $\tau_2$, $q'$ swaps with every token in $R'$ with $q'$ moving to the right and the tokens in $R'$ moving to the left. Since every token in $R_2$ (and thus $R'$) is a non-slot token, these left moves are contrary moves. Furthermore, these contrary moves are not in $\mathcal{M}$ by Corollary~\ref{obs:interface}(\ref{int5}). Thus, $|R'|< k^{1/c}$. Putting everything together, the number of tokens that move to the right of the nook parent at some point between times $\tau_1$ and $\tau_2$ is at least $|R|-k^{1/2+1/c}-k^{1/c}\geq\frac{k}{4n}-2k^{1/c}-k^{1/2+2/c}-k^{1/2+1/c}>k^{1-2/c}$ since $c>6$. \end{proof} Now, we are ready to define the token $t$ mentioned in the overview. Let $e$ be the edge between the nook parent and the vertex to its right. \begin{claim}\label{claim:tnook} There exists an interval $\mathcal{I}$ of time contained between $\tau_1$ and $\tau_2$ such that: $(1)$ a single non-item token $t$ is in the nook of slot gadget $i$ for the entirety of $\mathcal{I}$, and $(2)$ at least $k^{1-3/c}$ tokens of $R_2$ traverse edge $e$ in the rightward direction during $\mathcal{I}$. \end{claim} \begin{proof} First observe that, by Corollary~\ref{obs:interface}(\ref{int4}), each move of a non-item token into and out of the nook creates a contrary move that is not in $\mathcal{M}$. Thus, the total number of different non-item tokens that ever go into the nook of any gadget (and in particular slot gadget $i$) is at most $k^{1/c}$. Let $R_3 \subseteq R_2$ be the tokens of $R_2$ that move to the right of the nook parent at some point between times $\tau_1$ and $\tau_2$. By Claim~\ref{claim:rightnook}, we know that $|R_3|\geq k^{1-2/c}$. For each token of $R_3$, consider the last time that it traverses edge $e$ to the right between times $\tau_1$ and $\tau_2$ and look at which token is in the nook during that traversal. By the pigeonhole principle and the above bounds, there must exist a non-item token $t$ that is in the nook of gadget~$i$ contiguously for an interval $\mathcal{I}$ of time during which at least $|R_3|/k^{1/c}\geq k^{1-3/c}$ tokens of $R_3$ traverse edge $e$ in the rightward direction. \end{proof} Let $\mathcal{I}$ be the interval of time from Claim~\ref{claim:tnook} and let $R_4\subseteq R_2$ be the set of at least $k^{1-3/c}$ tokens from Claim~\ref{claim:tnook}. Also, let $\mathcal{S}$ be the set of swaps during interval $\mathcal{I}$ during which tokens in $R_4$ traverse edge $e$ in the rightward direction, taking the last such traversal for each token in $R_4$. % Let $L$ be the set of tokens that $R_4$ swaps with during the swaps $\mathcal{S}$. Next, we will show that many distinct tokens traverse the edge $e$ to the left during $\mathcal{I}$. We already know that there are many such traversals (performed by tokens in $L$), however we need to guarantee that many such traversals are performed by \emph{distinct} tokens. In particular, it is possible for $L$ to be composed of a single token that is going back and forth across~$e$. Furthermore, we require that these distinct tokens were initially in slot gadget $i$. These required properties are captured in the following claim. \begin{claim}\label{claim:Tbig} At least $k^{1-4/c}$ distinct tokens whose initial slot gadget is $i$ traverse $e$ in the left direction during interval $\mathcal{I}$. \end{claim} \begin{proof} First suppose $|L|\geq |R_4|/4$. We already know that every token in $L$ traverses $e$ in the left direction while $t$ is in the nook, so it suffices to show that at least half of the tokens in $L$ were initially in slot gadget $i$ (since $|L|/2\geq |R_4|/8\geq k^{1-3/c}/8>k^{1-4/c}$). Suppose more than half of the tokens in $L$ are \emph{not} initially in slot gadget $i$. If at least $|L|/4$ of these tokens have slot gadget $i$ as their final gadget, then their leftward traversal of $e$ is a contrary move, which is not in $\mathcal{M}$ by Corollary~\ref{obs:interface}(\ref{int1}). Thus, at least $|L|/4$ of these tokens do not have gadget~$i$ as their initial or final gadget. In this case, these tokens must move both into slot gadget $i$ all the way to $e$, and out of slot gadget $i$. One of these two directions is composed of contrary moves, so since $e$ is at distance $k$ from the root, we have $k$ contrary moves for each of the $|L|/4$ tokens, which is a contradiction. On the other hand, suppose $|L|< |R_4|/4$. This is the tricky case because for example $L$ could be just a single token that is moving back and forth across $e$, but we still need to show that many \emph{distinct} tokens traverse $e$ in the left direction. Because $|L|< |R_4|/4$, some tokens in $L$ participate in multiple swaps in $\mathcal{S}$. Let $\mathcal{S}'\subseteq\mathcal{S}$ be the set of swaps such that the participating token in $L$ has already previously performed a swap in $\mathcal{S}$ and will again perform another swap in $\mathcal{S}$. That is, for every token in $L$, at most two of its swaps in $\mathcal{S}$ are \emph{not} in $\mathcal{S'}$. Thus, $|\mathcal{S'}|\geq|\mathcal{S}|-2|L|=|R_4|-2|L|>|R_4|/2$. Defining $\mathcal{S'}$ is useful because we are guaranteed the following property: during each swap in $\mathcal{S'}$, the participating token in $L$ is moving leftward, however at some later point this same token must traverse $e$ in the \emph{rightward} direction in order to be set up to again traverse $e$ leftward during its next swap in $\mathcal{S}$. For every swap in $\mathcal{S'}$, consider the next time this token in $L$ traverses $e$ in the rightward direction and denote this set of swaps by $\mathcal{S''}$. By definition, $|\mathcal{S''}|=|\mathcal{S'}|$. Now we will condition on whether the tokens in $L$ that participate in swaps in $\mathcal{S'}$ are slot tokens or non-slot tokens. {\bf Case 1.} Suppose that for at least half of the swaps in $\mathcal{S'}$, the participating token in $L$ is a slot token. Then, for at least half of the swaps in $\mathcal{S''}$, the participating token in $L$ is performing a contrary move. At least $|\mathcal{S''}|/2-k^{1/c}$ of these contrary moves are in $\mathcal{M}$, because if $k^{1/c}$ of them are not in $\mathcal{M}$ then we have a contradiction. Then according to the characterization of $\mathcal{M}$ in Observation~\ref{obs:purple} (specifically item~\ref{purp2}), for each these contrary moves in $\mathcal{M}$, the token $s$ swapped with is a \emph{distinct} slot token that was initially in slot gadget $i$. The number of such tokens $s$ is at least $|\mathcal{S''}|/2-k^{1/c}=|\mathcal{S'}|/2-k^{1/c}>|R_4|/4-k^{1/c}\geq k^{1-3/c}/4-k^{1/c}>k^{1-4/c}$ since $c>4$. This completes Case 1. {\bf Case 2.} Suppose that for at least half of the swaps in $\mathcal{S'}$, the participating token in $L$ is a non-slot token. In this case, for at least half of the swaps in $\mathcal{S''}$, the participating token in $L$ is performing a contrary move. At least $|\mathcal{S'}|/2-k^{1/c}$ of these contrary moves are in $\mathcal{M}$, because if $k^{1/c}$ of them are not in $\mathcal{M}$ then we have a contradiction. Then according to the characterization of $\mathcal{M}$ in Observation~\ref{obs:purple} (specifically item~\ref{purp3}), for each of these contrary moves of tokens in $L$ in $\mathcal{M}$, the previous time this token in $L$ moved rightward along $e$ it swapped with a \emph{distinct} slot token $s$ that was initially in slot gadget $i$. Importantly, the previous time this token in $L$ moved rightward along $e$ was during $\mathcal{I}$ by the definition of $\mathcal{S'}$. The number of such tokens $s$ is at least $|\mathcal{S'}|/2-k^{1/c}>|R_4|/4-k^{1/c}\geq k^{1-3/c}/4-k^{1/c}>k^{1-4/c}$ since $c>4$. This completes the proof. \end{proof} Now we will consider where token $t$ originated. First, we will show that slot gadget $i$ is \emph{not} the initial or final gadget for token $t$. \begin{claim}\label{claim:fromelsewhere} Slot gadget $i$ is \emph{not} the initial or final gadget for token $t$. \end{claim} \begin{proof} A key fact in this proof is that we know that while $t$ is in the nook, many tokens pass by the nook both rightward (in particular $R_4$) and leftward (in particular the tokens from Claim~\ref{claim:Tbig}). The idea of this proof is to show that if $t$ has slot gadget $i$ as its initial or final gadget then these tokens passing by the nook become out of order with $t$, which is impossible by Lemma~\ref{lem:OutOfOrder}. First, suppose for contradiction that slot gadget $i$ is the final gadget for token $t$. Let $R_5$ be the subset of $R_4$ that are on their main path both immediately before and immediately after interval $\mathcal{I}$. By Lemma~\ref{lem:indest}, $|R_5|\geq |R_4|-2k^{1/2+2/c}$. Since every token in $R_2\supseteq R_5$ also has final gadget~$i$, the notion of \defn{out of order} from Lemma~\ref{lem:OutOfOrder} can apply to any pair of tokens in $R_5\cup \{t\}$. By Lemma~\ref{lem:OutOfOrder}, when $t$ is at the nook parent both immediately before and immediately after interval $\mathcal{I}$, $t$ cannot be out of order with any subset of $R_5$ of size at least $k^{1/2+2/c}$. Thus, compared to immediately before interval $\mathcal{I}$, right after interval $\mathcal{I}$ $t$ is on the opposite side of less than $2k^{1/2+2/c}$ tokens in $R_5$. Thus, at least $|R_5|-2k^{1/2+2/c}$ of the tokens in $R_5$ are on the same side (left or right) of $t$ immediately before and immediately after interval $\mathcal{I}$. Note that by definition all tokens in $R_5$ traverse the edge $e$ during interval $\mathcal{I}$. Thus, either moving these $|R_5|-2k^{1/2+2/c}$ tokens from their positions immediately before $\mathcal{I}$ to $e$, or moving them from $e$ to their positions immediately after $\mathcal{I}$, are contrary moves. This amounts to a total number of contrary moves of at least $(|R_5|-2k^{1/2+2/c})^2\geq (|R_4|-4k^{1/2+2/c})^2\geq (k^{1-3/c}-4k^{1/2+2/c})^2>k^{2-7/c}>k^{1+1/c}$, since $c>10$. Now suppose for contradiction that token $t$ was initially in slot gadget $i$. This case is similar to the previous case, except in this case $R_5$ and $t$ do not have the same initial gadget so the notion of ``out of order'' does not apply to them; instead, $t$ has the same initial gadget as the tokens from Claim~\ref{claim:Tbig} so the notion of ``out of order'' applies to them instead. Claim~\ref{claim:Tbig} implies that there is a set $L'$ of at least $k^{1-4/c}$ tokens initially in slot gadget $i$ that traverse $e$ in the left direction during interval $\mathcal{I}$. Let $L''$ be the subset of $L'$ that are on their main path both immediately before and immediately after interval $\mathcal{I}$. By Lemma~\ref{lem:indest}, $|L''|\geq |L'|-2k^{1/2+2/c}$. By Lemma~\ref{lem:OutOfOrder}, when $t$ is at the nook parent both immediately before and immediately after interval $\mathcal{I}$, $t$ cannot be out of order with any subset of $L''$ of size at least $k^{1/2+2/c}$. Thus, compared to immediately before interval $\mathcal{I}$, right after interval $\mathcal{I}$ $t$ is on the opposite side of at most $2k^{1/2+2/c}$ tokens in $L''$. Thus, at least $|L''|-2k^{1/2+2/c}$ of the tokens in $L''$ are on the same side (left or right) of $t$ immediately before and immediately after interval $\mathcal{I}$. Thus, either moving these $|L''|-2k^{1/2+2/c}$ tokens from their positions immediately before $\mathcal{I}$ to $e$, or moving them from $e$ to their positions immediately after $\mathcal{I}$, are contrary moves. This amounts to a total number of contrary moves at least $(|L''|-2k^{1/2+2/c})^2\geq (|L'|-4k^{1/2+2/c})^2\geq (k^{1-4/c}-4k^{1/2+1/c})^2>k^{2-9/c}>k^{1+1/c}$, since $c>10$. \end{proof} Now that we know that slot gadget $i$ is not the initial or final gadget for $t$, we analyze what happens in $t$'s initial and final gadgets while $t$ is in slot gadget $i$. We will eventually argue when $t$ reaches the root after being in slot gadget $i$, $t$ has become out of order with a large set of tokens, which we have shown in Lemma~\ref{lem:OutOfOrder} is impossible. The first step towards proving this is to show that while $t$ is in slot gadget $i$, many tokens that were initially in slot gadget~$i$ reach the root for the first time. We need to precisely define the time interval ``while $t$ is in slot slot gadget $i$'': Let $\mathcal{I}'$ be the time interval starting from the last time $t$ enters slot gadget $i$ before interval $\mathcal{I}$ and ending at the first time $t$ exits slot gadget $i$ after interval $\mathcal{I}$. Both events exist since $i$ is not the initial or final gadget for $t$ by Claim~\ref{claim:fromelsewhere}. \begin{claim}\label{claim:up} During interval $\mathcal{I}'$, at least $k+k^{1-6/c}$ tokens that were initially in slot gadget $i$ reach the root for the first time. \end{claim} \begin{proof} At the beginning and end of interval $\mathcal{I}'$, $t$ is at the root, and during interval $\mathcal{I}$, $t$ is in the nook of slot gadget $i$. Thus, during interval $\mathcal{I}'$, $t$ moves from the root to the nook of slot gadget $i$ and then back to the root. Let $\mathcal{S}$ be the set of swaps that $t$ performs while traveling from the root to the nook parent of slot gadget $i$, taking the last such swap that $t$ performs for each edge between the root and the nook parent; thus, $|\mathcal{S}|=k$. Let $S_1$ be the set of tokens that swap with $t$ during swaps in $\mathcal{S}$. By Claim~\ref{lem:unique}, $|S_1|=k$. By Claim~\ref{claim:Tbig}, at least $k^{1-4/c}$ tokens that were initially in slot gadget $i$ traverse $e$ in the left direction during interval $\mathcal{I}$. Call these tokens $S_2$. We will show three properties of $|S_1\cup S_2|$, which together complete the proof. Roughly, the three properties are the following: (1) many of the tokens in $|S_1\cup S_2|$ were initially in slot gadget $i$, (2) $|S_1\cup S_2|$ is large, and (3) many of the tokens in $|S_1\cup S_2|$ reach the root for the first time during interval $\mathcal{I}'$. First we will show item (1). All of the tokens in $S_2$ were initially in slot gadget $i$ by definition, so our goal is to get a lower bound on the number of tokens in $S_1$ that were initially in slot gadget $i$. Less than $k^{1/2+1/c}$ of the tokens in $S_1$ do not have slot gadget $i$ as their initial or final gadget, because otherwise it requires $k^{2(1/2+1/c)}/2$ contrary moves to get these tokens into slot gadget $i$ to the position of the swap in $\mathcal{S}$, or to get them back out of slot gadget $i$ (since each token in $S_1$ swaps with $t$ along a distinct edge). Further, note that if a token $s\in S_1$ has its final position in slot gadget $i$, then during its swap with $t$, $s$ is performing a contrary (left) move, which is not in $\mathcal{M}$ by Corollary~\ref{obs:interface}(\ref{int1}). Thus, less than $k^{1/c}$ of the tokens in $S_1$ have final position in gadget~$i$. Therefore, we have shown that at least $k-k^{1/2+1/c}-k^{1/c}$ tokens in $S_1$ were initially in slot gadget $i$. Call these tokens $S'_1$. From now on we will focus on $|S'_1\cup S_2|$. Next we will show item (2). Our goal is to get a lower bound on $|S'_1\cup S_2|$. To do this we will get an upper bound on $|S'_1\cap S_2|$. By definition, each token in $S'_1\cap S_2$ swaps with $t$ along a distinct edge between the root and the nook parent of slot gadget $i$, and then subsequently traverses the edge $e$. Each token in $S'_1$ (and thus $S'_1\cap S_2$) is initially in slot gadget $i$, so moving rightward from the location where it swapped with $t$ to edge $e$ are contrary moves. This incurs at least $(|S'_1\cap S_2|)^2/2$ contrary moves. Thus, $|S'_1\cap S_2|<k^{1/2+1/c}$ since otherwise the number of contrary moves would be more than $k^{1+1/c}$. Therefore, $|S'_1\cup S_2|=|S'_1|+|S_2|-|S'_1\cup S_2|>(k-k^{1/2+1/c}-k^{1/c})+k^{1-4/c}-k^{1/2+1/c}>k+k^{1-5/c}$ since $c>10$. Lastly, we will show item (3). We claim that after the tokens in $|S'_1\cup S_2|$ have traversed $e$, at no point in the future are more than $k^{1/2+1/c}$ of these tokens to the right of the nook parent. This is because right moves are contrary moves for these tokens (since they were initially gadget is $i$) so having $k^{1/2+1/c}$ of these tokens to the right of the nook parent simultaneously would incur $k^{2(1/2+1/c)}/2 > k^{1+1/c}$ contrary moves. In particular, when $t$ reaches the nook parent for the last time during interval $\mathcal{I}'$, no more than $k^{1/2+1/c}$ tokens in $S'_1\cup S_2$ are to the right of $t$. For each token $s\in S'_1\cup S_2$ that is \emph{not} to the right of $t$ at this point in time, note that $s$ either reaches the root before $t$ or swaps with $t$ (since at the end of $\mathcal{I}'$, $t$ is at the root). Less than $k^{1/c}$ such tokens $s$ swap with $t$ since in this case, $s$ performs a contrary (right) move that is not in $\mathcal{M}$ by Corollary~\ref{obs:interface}(\ref{int6}). Thus, at least $|S'_1\cup S_2|-k^{1/2+1/c}-k^{1/c}$ tokens in $S'_1\cup S_2$ reach the root during interval $\mathcal{I}'$. It remains to show that enough tokens in $S'_1\cup S_2$ reach the root \emph{for the first time} during interval $\mathcal{I}'$. We know that at most $k^{1/c}$ of the tokens in $S'_1\cup S_2$ reached the root for the first time before the beginning of interval $\mathcal{I}'$ because all of these tokens subsequently traverse $e$, which requires $k$ contrary moves per token. Thus, we have shown that at least $k+k^{1-5/c}-k^{1/2+1/c}-2k^{1/c}$ tokens in $S'_1\cup S_2$ reach the root for the first time during interval $\mathcal{I}'$. This quantity of tokens is more than $k+k^{1-6/c}$ since $c>12$. \end{proof} Recall that we will eventually argue when $t$ reaches the root at the end of interval $\mathcal{I}'$, $t$ has become out of order with a large set of tokens. To define this large set of tokens, it will be useful to return to the idea of the \defn{core} $C(S)$ of a segment $S$ from Definition~\ref{def:core}. Next, we will show that during interval $\mathcal{I}'$, for \emph{each} slot gadget $j\not=i$, there is a segment whose initial position was in that slot, such that every token in the core of that segment reaches the root for the first time. \begin{claim}\label{claim:oneofeach} For each slot gadget $j\not=i$, there is a segment $S_j$ whose initial position was in slot gadget $j$ such that during interval $\mathcal{I}'$ every token in $C(S_j)$ reaches the root for the first time. \end{claim} \begin{proof} It will help to count the number of tokens of various types initially in slot gadget $i$. By Lemma~\ref{lem:noncore} the total number of tokens with initial position in slot gadget $i$ that are not in the core of any segment is at most $k^{1/2+5/c}$. Also, the total number of tokens with initial position in slot gadget $i$ in a padding segment is $n(\frac{k}{n^8})>k^{1-7/c}$ since there are $n$ padding segments in each slot gadget and each one is of length $\frac{k}{n^8}$. Each remaining token initially in slot gadget $i$ is in the core of a big segment. Each big segment is of size $k$. By Claim~\ref{claim:up}, there is a set $S$ of at least $k+k^{1-6/c}$ tokens that were initially in slot gadget $i$ that reach the root for the first time during interval $\mathcal{I}'$. Because $|S|>k^{1/2+5/c}+k^{1-7/c}+k$ (which is true since $c>24$), the calculations from the previous paragraph imply that $S$ must contain at least one token from the core of a big segment and at least one token from the core of another segment. Lemma~\ref{lem:segbyseg} says that the tokens in the cores of segments reach the root for the first time in the same order as in the scaffold solution. Property (P6) of the scaffold solution says that during a time interval in which at least one token from a big segment and at least one token from any other segment from the same slot gadget reach the root, at least one segment from each of the other slot gadgets reaches the root. Combining these two facts, we have that in our token swapping solution, during a time interval in which at least one token from the core of a big segment initially in slot gadget $i$ and at least one token from the core of any other segment initially in slot gadget $i$ reach the root for the first time, the core of at least one segment initially in each of the other slot gadgets reaches the root for the first time. $\mathcal{I}'$ is such a time interval, since every token in $S$ reaches the root for the first time during $\mathcal{I}'$ and we have shown that $S$ contains at least one token from the core of a big segment and at least one token from the core of another segment (both initially in slot gadget $i$). This completes the proof. \end{proof} The final claim towards arguing that when $t$ reaches the root at the end of interval $\mathcal{I}'$, $t$ has become out of order with a large set of tokens, is the following. \begin{claim}\label{claim:slotfromt} During interval $\mathcal{I}'$, at least $k^{1-10/c}$ tokens that all have the same initial and final gadget as $t$ exit their initial gadget for the first time and enter their final gadget for the last time. \end{claim} \begin{proof} First, suppose $t$'s initial gadget is a slot gadget. Then, by Claim~\ref{claim:oneofeach}, every token in the core of a segment $S$ with the same initial gadget as $t$ reaches the root for the first time during $\mathcal{I}'$. Then, by Lemma~\ref{lem:indest}, at least $|C(S)|-k^{1/2+2/c}$ tokens from $C(S)$ enter the ordering gadget for the last time during $\mathcal{I}'$. This completes the case where $t$'s initial gadget is a slot gadget since by Lemma~\ref{lem:noncore}, $|C(S)|-k^{1/2+2/c}>k^{1-9/c}-k^{1/2+2/c}>k^{1-10/c}$ since $c>22$. Now, suppose $t$'s initial gadget is the ordering gadget. Then, by Claim~\ref{claim:oneofeach}, every token in the core of a segment $S$ whose initial gadget is $t$'s \emph{final} gadget reaches the root for the first time during $\mathcal{I}'$. By Lemma~\ref{lem:exchange}, during interval $\mathcal{I}'$, a set $S'$ of at least $|C(S)|-k^{1/2+3/c}$ tokens with the same final gadget as $t$ enter this gadget for the last time. That is, at the beginning of interval $\mathcal{I}'$, no token in $S'$ had yet entered their final gadget for the last time. Then, by the contrapositive of Lemma~\ref{lem:indest}, at the beginning of interval $\mathcal{I}'$, at least $|C(S)|-k^{1/2+3/c}-k^{1/2+2/c}$ of the tokens in $S'$ had not yet exited the ordering gadget for the first time, and thus first exited the ordering gadget during interval $\mathcal{I}'$. This completes the proof since by Lemma~\ref{lem:noncore}, $|C(S)|-k^{1/2+3/c}-k^{1/2+2/c}>k^{1-9/c}-k^{1/2+3/c}-k^{1/2+2/c}>k^{1-10/c}$ since $c>24$. \end{proof} Now we are ready to complete the proof of Lemma~\ref{lem:LeafLeaving} by deriving the contradiction that $t$ has become out of order with a large set of tokens. When interval $\mathcal{I}'$ both begins and ends, $t$ is at the root. By Claim~\ref{claim:slotfromt}, during interval $\mathcal{I}'$, a set $S$ of at least $k^{1-10/c}$ tokens that all have the same initial and final gadget as $t$ exit their initial gadget for the first time and enter their final gadget for the last time. This immediately implies that at the beginning of interval $\mathcal{I}'$, every token in $S$ is in its initial gadget (which is the same as $t$'s initial gadget), and at the end of interval $\mathcal{I}'$, every token in $S$ is in its final gadget (which is the same as $t$'s final gadget). Thus, for every token $s\in S$, $t$ is out of order with $s$ either at the beginning or the end of interval $\mathcal{I}'$. Thus, either at the beginning or the end of interval $\mathcal{I}'$, $t$ is out of order with at least $|S|/2\geq k^{1-10/c}/2$ tokens. Since $c>24$, this contradicts Lemma~\ref{lem:OutOfOrder}, which says that $t$ can only be out of order with at most $k^{1/2+2/c}$ tokens at any given point in time. \end{proof} \paragraph{Proof of Lemma~\ref{lem:free-item-token}}\label{sec:Item and Segment Swap}$ $\\ We begin with Lemma~\ref{lem:free-item-token}(1): \emph{At any point in time, apart from the free item token, there is exactly one item token in each slot gadget.} \begin{proof}[Proof of Lemma~\ref{lem:free-item-token}(1)] By Lemma~\ref{lem:LeafLeaving}, at all times, each slot gadget contains at least one item token. It remains to show that if the free item token is in a slot gadget $i$, then there is another item token in slot gadget $i$. Consider the token $t$ that was in slot gadget $i$ the last time the free item token $f$ was at the root. We claim that $t$ is still in slot gadget $i$. This is because if $t$ has left slot gadget $i$ then $t$ has passed through the root, which would mean that $t$ is the free item token instead of $f$ (since we were considering the \emph{last} time $f$ was at the root). \end{proof} Because any token must pass through the root when moving from one slot gadget to another, Lemma~\ref{lem:free-item-token}(1) immediately implies the following corollary: \begin{corollary} When the free item token changes from an item token $f$ to another item token $f'$, $f$ is in the slot gadget that $f'$ was just in. \end{corollary} Now we move to Lemma~\ref{lem:free-item-token}(2): \emph{The exchange sequence $\chi$ is a subsequence of the sequence of swaps given as input to the Star STS instance.} Towards proving this, we show in the following claim that there is a direct correspondence between the free item token changing and segments leaving a slot gadget. \begin{claim}\label{lem:ItemSwap} Suppose the free item token changes from item token $f$ to item token $f'$, and let $i$ be the slot gadget containing $f$ when this happens. Then, while $f$ was the free item token, at least $k(1-\frac{1}{3n})$ slot tokens that were initially in slot gadget $i$ reached the root for the first time. \end{claim} \begin{proof} This proof has a similar idea to the proof of Claim~\ref{claim:up} (but is less involved). Let $v$ be the vertex in slot gadget $i$ of distance exactly $k(1-\frac{1}{4n})$ from the root (this is the same definition of $v$ as in the previous section). By Lemma~\ref{lem:LeafLeaving}, when $f'$ becomes the free item token, $f$ is at $v$ or to the right of $v$. Previously, when $f$ became the free item token, $f$ was at the root. Thus, while $f$ was the free item token, $f$ moved from the root to $v$. Let $\mathcal{S}$ be the set of swaps that $f$ performed while traveling from the root to $v$, taking the last such swap that $f$ performs for each edge between the root and $v$; thus, $|\mathcal{S}|=k(1-\frac{1}{4n})$. Let $S'$ be the set of tokens that swap with $f$ during swaps in $\mathcal{S}$. By Claim~\ref{lem:unique}, $|S'|=k(1-\frac{1}{4n})$. First, we will show that many of the tokens in $S'$ were initially in slot gadget $i$. Less than $k^{1/2+1/c}$ of the tokens in $S'$ do not have slot gadget $i$ as their initial or final gadget, because otherwise it requires $k^{2(1/2+1/c)}/2$ contrary moves to get these tokens into slot gadget $i$ to the position of the swap in $\mathcal{S}$, or to get them back out of slot gadget $i$ (since each token in $S'$ swaps with $f$ along a distinct edge). Further, note that if a token $s\in S'$ has its final position in slot gadget $i$, then during its swap with $f$, $s$ is performing a contrary (left) move, which is not in $\mathcal{M}$ by Corollary~\ref{obs:interface}(\ref{int5}). Thus, less than $k^{1/c}$ of the tokens in $S'$ have final position in slot gadget $i$. Therefore, we have shown that a set $S''\subseteq S'$ of at least $k(1-\frac{1}{4n})-k^{1/2+1/c}-k^{1/c}$ tokens were initially in slot gadget $i$. Now, we will show that many of the tokens in $S'$ reached the root for the first time while $f$ was the free item token. By Lemma~\ref{lem:LeafLeaving}, once $f$ became the free item token and until $f$ reached $v$, $f'$ was in slot gadget $i$ at $v$ or to the right of $v$. Thus, right after $f$ swaps with each token $s\in S'$, $s$ is to the left of $f'$. We claim that after $f$ reaches $v$, there are never more than $k^{1/2+1/c}$ tokens in $S''$ simultaneously to the right of $v$. This is because right moves are contrary moves for these tokens (since they were initially in slot gadget $i$) so having $k^{1/2+1/c}$ of these tokens to the right of $v$ would incur $k^{2(1/2+1/c)}/2>k^{1+1/c}$ contrary moves. In particular, when $f'$ reaches $v$ for the last time before becoming the free item token, no more than $k^{1/2+1/c}$ tokens in $S''$ are to the right of $f$. For each token $s\in S''$ that is \emph{not} to the right of $f$ at this point in time, note that $s$ either reaches the root before $f'$ or swaps with $f'$. Less than $k^{1/c}$ such tokens $s$ swap with $f'$ since in this case, $s$ performs a contrary (right) move that is not in $\mathcal{M}$ by Corollary~\ref{obs:interface}(\ref{int5}). Thus, we have shown that at least $|S''|-k^{1/2+1/c}-k^{1/c}$ tokens in $S''$ have reached the root while $f$ is the free item token. It remains to show that enough of these tokens reach the root \emph{for the first time} while $f$ is the free item token. We know that at most $k^{1/2+1/c}$ of the tokens in $S''$ reached the root for the first time before $f$ became the free item token because getting all of these tokens to their positions to swap with $f$ would require more than $k^{2(1/2+1/c)}/2>k^{1+1/c}$ contrary moves. Thus, we have shown that at least $|S''|-2k^{1/2+1/c}-k^{1/c}$ tokens in $S''$ reach the root for the first time while $f$ is the free item token. This quantity of tokens is at least $k(1-\frac{1}{4n})-3k^{1/2+1/c}-2k^{1/c}>k(1-\frac{1}{3n})$. \end{proof} Now we are ready to prove Lemma~\ref{lem:free-item-token}(2). \begin{proof}[Proof of Lemma~\ref{lem:free-item-token}(2)] Let $s_1,\dots,s_n$ be the input sequence for the Star STS instance. We begin by recalling the correspondence between $s_1,\dots,s_n$ and our token swapping solution. Recall from the construction that there is a direct correspondence between $s_1,\dots,s_n$ and the big segments $y_1,\dots,y_n$ in the sense that if $s_j=g$ then $y_j$ is initially in slot gadget $g$. Further recall that in the scaffold solution, the big segments reach the root in the order $y_1,\dots,y_n$. By Lemma~\ref{lem:segbyseg}, in our token swapping solution the vertices in the \defn{core} of the big segments reach the root for the first time in the same order as in the scaffold solution. That is, in the order $C(y_1),\dots,C(y_n)$. We will refer to this property as the \defn{core property}: {\bf The core property:} For all $i,j$ with $i<j$, every token in $C(y_i)$ reaches the root for the first time before any token in $C(y_j)$ does so. We will maintain a counter $\Lambda$ that intuitively keeps track of where we are up to in the sequence $s_1,\dots,s_n$. We will iterate through the exchange sequence $\chi=\chi[1],\chi[2],\dots$ from beginning to end, and for each element $\chi[i]$, we will increase $\Lambda$ by at least 1 to a new value $i$ such that $s_j=\chi[i]$. It is straightforward to see that if we can successfully maintain such a counter, then $\chi$ is a subsequence of $s_1,\dots,s_n$. Now we will define the rule for updating $\Lambda$. For each $\chi[i]$, let $p_i$ be the corresponding point in time when the token that was just in slot gadget $\chi[i]$ becomes the free item token (and let $p_0$ be the time initially). At each $p_i$, we will update $\Lambda$; let $\Lambda(i)$ be the value that we set $\Lambda$ to at $p_i$. {\bf Rule for updating $\Lambda$:} $\Lambda(0)=0$ and for all $i\geq 1$, set $\Lambda(i)$ to be the smallest $j>\Lambda(i-1)$ such that before $p_i$ at least one token from $C(y_j)$ reaches the root for the first time, where $y_{j}$ is initially in slot gadget $\chi[i]$. Note that the requirement that $y_j$ is initially in slot gadget $\chi[i]$ is equivalent to the above requirement that $s_j=\chi[i]$ (due to the correspondence between $y_j$ and $s_j$ described above). Thus, given this rule for updating $\Lambda$, proving the following claim completes the proof of Lemma~\ref{lem:free-item-token}(2). \begin{claim} For all $i\geq 1$, there exists $j>\Lambda(i-1)$ such that before $p_i$, at least one token from the core of some big segment $y_{j}$ that was initially in slot gadget $\chi[i]$ reaches the root for the first time. \end{claim} \begin{proof} Fix $i\geq 1$. Suppose inductively that $\Lambda(i')$ exists for all $i'<i$. By the definition of how we update $\Lambda$, before $p_{i-1}$, at least one token from $C(y_{\Lambda(i-1)})$ has reached the root for the first time, and $y_{\Lambda(i-1)}$ is initially in slot gadget $\chi[i-1]$. By the core property, this means that before $p_{i-1}$, every token in the core of every big segment $y_{j'}$ with $j'<\Lambda(i-1)$ has reached the root for the first time. Now, we consider what happens between $p_{i-1}$ and $p_i$. By Claim~\ref{lem:ItemSwap}, between $p_{i-1}$ and $p_i$, a set $S$ of at least $k(1-\frac{1}{3n})$ tokens that were initially in slot gadget $\chi[i]$ reach the root for the first time. We analyze the composition of the tokens in $S$. Since $S$ contains only tokens that reached the root for the first time after $p_{i-1}$, $S$ contains no tokens in the core of any big segment $y_{j'}$ with $j'<\Lambda(i-1)$. By Lemma~\ref{lem:noncore}, less than $k^{1/2+5/c}$ tokens in $S$ are not in the core of any segment. Also, at most $\frac{k}{n^7}$ tokens in $S$ are in a padding segment since there are $n$ padding segments in each slot gadget and each one is of length $\frac{k}{n^8}$. The remainder of the tokens in $S$ are in the core of a big segment $y_{j'}$ with $j'\geq \Lambda(i-1)$. Thus, letting $\beta=k^{1/2+5/c}+\frac{k}{n^7}$, we have that $S$ contains at least $|S|-\beta$ tokens that are in cores of big segments $y_{j'}$ with $j'\geq \Lambda(i-1)$. This does not suffice, however, because we are trying to identify a token in $S$ in the core of a big segment $y_{j'}$ with $j'> \Lambda(i-1)$, where the inequality is strict. If $i=1$, then $\Lambda(i-1)=0$ so it is trivially true that any big segment $y_{j'}$ has $j'>\Lambda(i-1)$. If $i>1$, then we need to bound the number of tokens in $S$ that are in $C(y_{\Lambda(i-1)})$. If $\chi[i]\not=\chi[i-1]$, then $S$ contains no tokens in $y_{\Lambda(i-1)}$ since $y_{\Lambda(i-1)}$ was initially in slot gadget $\chi[i-1]$ while every token in $S$ was initially in slot gadget $\chi[i]$. Thus, we are concerned with the case where $\chi[i]=\chi[i-1]$. Let $\ell\geq 1$ be the largest integer such that $\chi[i]=\chi[i-1]=\dots =\chi[i-\ell]$. Then by Claim~\ref{lem:ItemSwap}, between $p_{i-\ell-1}$ and $p_{i}$, a set $S'$ of at least $(\ell+1) k(1-\frac{1}{3n})$ tokens that were initially in slot gadget $\chi[i]$ reach the root for the first time. To complete the proof, we will show that at least one token in $S'$ is in the core of a big segment $y_{j'}$ with $j'> \Lambda(i-1)$. We can analyze the composition of $S'$ in the same way as we analyzed the composition of $S$ previously. $S'$ contains no tokens in the core of any big segment $y_{j'}$ with $j'<\Lambda(i-\ell-1)$. Also $S'$ contains at least $|S'|-\beta$ tokens that are in the core of a big segment $y_{j'}$ with $j'\geq \Lambda(i-\ell-1)$. Since $\chi[i-\ell]\not=\chi[i-\ell-1]$, $S'$ contains no tokens in $y_{\Lambda(i-\ell-1)}$. Thus, the number of tokens in $S'$ that are in the core of a big segment $y_{j'}$ with $j'> \Lambda(i-\ell-1)$ is at least \begin{align}\label{eqn} |S'|-\beta&\geq (\ell+1) k(1-\frac{1}{3n})-\beta\notag\\ &= \ell k+k-\frac{\ell k}{3n}-\frac{k}{3n}-\beta\notag\\ &\geq \ell k +k -\frac{k}{3}-\frac{k}{3n} -\beta \text{\hspace{5mm} since $\ell\leq n$}\notag\\ &=\ell k +\frac{2k}{3}-\frac{k}{3n} -k^{1/2+5/c}-\frac{k}{n^7}\notag\\ &\geq \ell k+1. \end{align} By the core property, the tokens in $S'$ that are in the core of big segments come from big segments whose initial positions are \emph{consecutive} within slot gadget $\chi[i]$. Let $y^*$ be the big segment with the smallest index larger than $\Lambda(i-\ell-1)$ out of the big segments that were initially in slot gadget $\chi[i]$. Since $S'$ contains no tokens in the core of any big segment $y_{j'}$ with $j'<\Lambda(i-\ell-1)$, $y^*$ is the lowest indexed big segment for which $S'$ could contain tokens from its core. If $S'$ contains any token in $C(y^*)$, then Equation~(\ref{eqn}) implies that $S'$ contains the entire core of the next $\ell-1$ consecutive big segments initially in slot gadget $\chi[i]$, as well as at least one token from the core of the next big segment $y^{**}$ from slot gadget $\chi[i]$ directly after (to the right of in the initial configuration) these $\ell-1$ consecutive big segments. Since $y^*$ is the lowest indexed big segment for which $S'$ could contain tokens from its core, if $S'$ does not contain a token in $C(y^*)$, then $S'$ still contains at least one token from the core of some big segment with index at least that of $y^{**}$. Together, the core property and the fact that the rule for updating $\Lambda$ chooses the \emph{smallest} such $j$ imply that $y_{\Lambda(i-\ell)},\dots,y_{\Lambda(i-1)}$ are big segments whose initial positions are consecutive within slot gadget $\chi[i]$. Furthermore, $\Lambda(i-\ell)$ is set to be the minimum value larger than $\Lambda(i-\ell-1)$ such that $y_{\Lambda(i-\ell)}$ is initially in slot gadget $\chi[i]$. That is, $y_{\Lambda(i-\ell)}=y^*$. Then, because $y_{\Lambda(i-\ell)},\dots,y_{\Lambda(i-1)}$ are consecutive big segments initially in slot gadget $\chi[i]$, we have that $y^{**}=y_{j'}$ for $j'>\Lambda(i-1)$. We have shown that $S'$ contains at least one token from the core of some big segment with index at least that of $y^{**}$. Thus, $S'$ contains at least one token from the core of some big segment $y_{j'}$ with $j'>\Lambda(i-1)$, which completes the proof. \end{proof} Therefore we have proved Lemma~\ref{lem:free-item-token}(2). \end{proof} } \section{Weighted sequential token swapping on trees is NP-hard} \label{sec:NP-hard-weighted} In this section, we prove that weighted token swapping on a tree is NP-hard, even when the token weights are in $\{0,1\}$. Our purpose is to introduce the general idea that is used in our main NP-completeness proof for the unweighted case given in Section~\ref{sec:NP-hard-unweighted}. We first precisely define the decision problem \defn{weighted sequential token swapping on trees} \cite{tree-token-swapping}, abbreviated in this section to \defn{weighted token swapping}. The input is: a tree on $n$ vertices with distinct initial positions (vertices) and distinct target positions for the $n$ tokens; non-negative integer weights on the tokens; and a maximum cost~$K$. The cost of a swap is the sum of the weights of the two tokens involved. The decision problem asks whether there is a sequence of swaps that moves all the tokens to their target positions and such that the sum of the costs of the swaps is at most~$K$. It is not clear whether the weighted token swapping problem lies in NP; however, it is in NP if $K$ is given in unary.\footnote{Consider % a minimum length swap sequence of weight at most $K$. The number of swaps involving a nonzero weight token is at most % $K$. Because the sequence has minimum length, it can be shown that no two zero-weight tokens swap more than once, see~Lemma~\ref{lem:unique}. Thus the sequence has length at most $K + n^2$ and provides a polynomial sized certificate, showing that the problem is in NP. } We prove that weighted token swapping is NP-hard when $K$ is given in unary. The reduction is from Star STS. In order to distinguish tokens and vertices in the original star from those in the tree that we construct, we will call the tokens of the Star STS instance \defn{items} and we will call the leaves \defn{slots}. Then the instance of Star STS consists of: a star with center 0 and slots $1, \ldots, m$, each of which initially has an item of its same label; a permutation $\pi$ of the items; and a sequence $s_1, \ldots, s_{n}$ of slots that specify the allowed swaps. Figure~\ref{fig:plan}(a) shows an example input for $m=4$ slots and $5$ items and a sequence of length $n=7$. \begin{theorem} \label{thm:weighted-NP-hard} Weighted token swapping on trees in NP-hard. \end{theorem} \begin{proof} Suppose we are given an instance of Star STS as described above. We may assume without loss of generality that every slot appears in the sequence (otherwise remove that slot from the problem) and that no slot appears twice in a row in the sequence. \begin{figure}[bt] \centering \includegraphics[width=.95\textwidth]{Figures/plan-horizontal.pdf} \caption{ (a) An instance of Star STS with $m=4$ slots and a sequence of length $n=7$; notation $a[b]$ indicates that token $a$ is initially at this vertex and token $b$ should move to this vertex. This instance has no solution because item 4 should move to slot 3, which is possible only if slot 3 appears after slot 4 in the sequence. (b) The corresponding instance of weighted token swapping with the ordering gadget on the left and $m=4$ slot gadgets attached to the root, each with a nook vertex shown in red. After swapping item token $0$ at the root with token $y_1$ in the first (bottom) slot gadget there is an opportunity to swap tokens $0$ and $1$ for free along the nook edge of the first slot gadget, before moving $y_1$ to its target position at the end of the ordering gadget and moving $x_1$ to its target position at the end of the first slot gadget. } \label{fig:plan} \end{figure} Construct a tree with a root, an \defn{ordering gadget} which is a path of length $n$ attached to the root, and $m$ \defn{slot gadgets} attached to the root. Slot gadgets are defined below. See Figure~\ref{fig:plan}(b) where the ordering gadget of length $n=7$ appears on the left and there are $m=4$ slot gadgets attached to the root. We picture the tree with the root in the middle, and use directions left/right as in the figure. Let $n_i$ be the number of occurrences of slot $i$ in the input sequence. Observe that $\sum_{i=1}^m n_i = n$. \defn{Slot gadget} $i$ consists of a path of $n_i$ vertices, plus an extra leaf attached to the leftmost vertex of the path. This extra leaf is called the \defn{nook} of the slot gadget. The $m$ nooks and the root are in one-to-one correspondence with the slots and the center of the original star (respectively), and we place \defn{item tokens} at these vertices whose names, initial positions, and final positions correspond exactly to those of the items of the input star. These item tokens are given a weight of 0. There are $2n$ additional \defn{non-item tokens} $x_1, \ldots, x_{n}$ and $y_1, \ldots, y_{n}$. These all have weight 1. The $x_j$'s are initially placed along the ordering gadget path, in order, with $x_1$ at the right and $x_{n}$ at the left. The ordering path is also the target position of the $y_j$'s in reverse order with $y_1$ at the left and $y_{n}$ at the right. Suppose slot $i$ appears in the sequence as $s_{j_1}, s_{j_2}, \ldots, s_{j_{n_i}}$ with indices in order $j_1 < j_2 < \cdots < j_{n_i}$. Then tokens $y_{j_1}, y_{j_2}, \ldots, y_{j_{n_i}}$ are initially placed along the path of slot gadget $i$, in order with smallest index at the left. The path of slot gadget $i$ is also the target position of the tokens $x_{j_1}, x_{j_2}, \ldots, x_{j_{n_i}}$ in reverse order with smallest index at the right. Consider, for each non-item token $x_j$ or $y_j$, the distance from its initial location to its target location. This is a lower bound on the cost of moving that token. We set the max cost $K$ to the sum of these lower bounds. This guarantees that every $x_j$ or $y_j$ only travels along its shortest path. Observe that this reduction takes polynomial time. We now prove that a YES instance of Star STS maps to a YES instance of token swapping and vice versa. \medskip\noindent {\bf YES instance of Star STS.} Suppose the Star STS instance has a solution. The ``intended'' solution to the token swapping instance implements each $s_j$ for $j=1, \ldots, n$ as follows. Suppose $s_j = i$. By induction on $j$, we claim that token $y_j$ will be in the leftmost vertex of slot gadget $i$ when it is time to implement $s_j$. Swap token $y_j$ with the item token $t$ currently at the root. Then item token $t$ has the opportunity to swap for free with the item token in nook $i$. We perform this free swap if and only if swap $s_j$ was performed in the solution to Star STS. Next, swap tokens $y_j$ and $x_j$---we claim by induction that $x_j$ will be in the rightmost vertex of the ordering gadget. Finally, move token $y_j$ to its target position in the ordering gadget, and move $x_j$ to its target position in slot gadget $i$. It is straightforward to verify the induction assumptions. Every $x_j$ and $y_j$ moves along its shortest path so the cost of the solution is equal to the specified bound $K$. \smallskip\noindent {\bf YES instance of weighted token swapping.} Suppose the weighted token swapping instance has a solution with at most $K$ swaps. Because $K$ is the sum of the distances of the non-item tokens from their target positions, each $x_j$ and $y_j$ can only move along the shortest path to its target position. Token $x_j$ must move into the root before $x_{j+1}$, otherwise they would need to swap before that, which means moving $x_j$ the wrong way along the ordering gadget path. Similarly, $y_j$ must move into the root before $y_{j+1}$, otherwise they need to swap after that, which means moving $y_{j+1}$ the wrong way. Furthermore, $x_j$ must move into the root before $y_{j+1}$ otherwise the ordering gadget would contain $x_j, \ldots, x_{n}$, and $y_1, \ldots, y_j$, a total of $n+1$ tokens, which is more tokens than there are vertices in the ordering gadget. We also claim that $y_j$ must move into the root before $x_{j+1}$. First note that the nooks can only contain item tokens, since no $x_j$ or $y_j$ can move into a nook. This accounts for every item token except for one ``free'' item token. Now suppose $x_{j+1}$ moves into the root before $y_j$. Then the ordering gadget contains $x_{j+2}, \ldots, x_{n}$, and $y_1, \ldots, y_{j-1}$, a total of $n-2$ tokens. Even if the free item token is in the ordering gadget, this is not enough tokens to fill the ordering gadget. Thus the $x_j$'s and $y_j$'s must use the root in order, first $x_1$ and $y_1$ in some order, then $x_2$ and $y_2$ in some order, etc. Finally, we examine the swaps of item tokens. A swap between two item tokens can only occur when the free item token is at the parent of a nook. Suppose this happens in slot gadget~$i$. Then some token $y_j$ must have left the slot gadget, and the corresponding token $x_j$ has not yet entered the slot gadget, which means that neither of the tokens $y_{j+1}$ or $x_{j+1}$ has moved into the root. This implies that any swap of item tokens is associated with a unique $s_j = i$, and such swaps must occur in order of $j$, $1 \le j \le n$. Thus the swaps of item tokens can be mimicked by swaps in the original Star STS sequence, and the Star STS instance has a solution. \end{proof} \section{Star Subsequence Token Swapping Reachability (Star STS) is NP-complete} \label{appendixA} Our starting point is the NP-complete problem called ``permutation generation'' in Garey and Johnson~\cite[MS6]{Garey-Johnson}, and called WPPSG (Word Problem for Products of Symmetric Groups) in~\cite{garey1980complexity}: \begin{quote} \textbf{WPPSG.} Given sets $X_1, X_2, \ldots, X_n$, where $X_i \subseteq \{1, 2, \ldots , m\}$, and a permutation $\pi$ of $\{1, \ldots, m\}$, can $\pi$ be written as $\pi = \pi_1 \cdot \pi_2 \cdots \pi_n$ where $\pi_i$ is a permutation of $X_i$ for $1 \le i \le n$? \end{quote} As noted in~\cite[Corollary, p.~224]{garey1980complexity} WPPSG remains NP-complete when each subset $X_i$ has size 2, i.e.,~the input is a sequence of swaps (transpositions) and the given permutation must be expressed as a subsequence of the given sequence of swaps. This special case is called WPPSG2 in~\cite{garey1980complexity}, and called ``Swap or not Reachability'' in~\cite{THEGAME_JCDCGGG}. By considering the transpositions as edges of a (complete) graph, the problem can be expressed as the following token swapping reachability problem. \begin{quote} \textbf{Subsequence Token Swapping Reachability (STS):} Given a graph on $m$ vertices where vertex $i$ initially has a token $i$, and given a target permutation $\pi$ of the tokens and a sequence of swaps $s_1, s_2, \ldots, s_{n}$, where $s_j$ is an edge of the graph, is there a subsequence of the swaps that realizes $\pi$? \end{quote} We prove that STS remains NP-complete when the underlying graph is a star. \begin{lemma} \label{lemma:StarSTS} Star STS is NP-complete, even in the special case where the target permutation places token 0 back on the center. \end{lemma} \begin{proof}[Proof of Lemma~\ref{lemma:StarSTS}] We give a polynomial time reduction from STS to Star STS. Suppose the input to STS consists of the target permutation $\pi \in S_m$ and the swaps $s_i = (a_i, b_i)$, $1 \le i \le n$, where $a_i, b_i \in \{1, \ldots, m\}$. Construct an instance of Star STS as follows. Make a leaf of the star for each of the $m$ vertices of the input graph. Also, for each swap $s_i$ in the input sequence, make two leaves $s^{\rm in}_i$ and $s^{\rm out}_i$. Each leaf has a token of its same label, and the center vertex of the star has token $0$. Define the target permutation such that token $0$ remains on the center vertex, tokens $1, \ldots, m$ permute according to the input permutation $\pi$, and tokens $s^{\rm in}_i$ and $s^{\rm out}_i$ must switch positions for $1 \le i \le n$. To construct the swap sequence, replace each $s_i= (a_i, b_i)$ by the 6-element sequence $s^{\rm in}_i, a_i, \allowbreak b_i, \allowbreak a_i, \allowbreak s^{\rm out}_i, s^{\rm in}_i$ (recall that an element $x$ indicates a swap on edge $(0,x)$). Observe that this construction can be carried out in polynomial time. If the original instance of STS has a solution, then we get a solution for the constructed instance of Star STS as follows. If $s_i$ is chosen in the original, then choose the corresponding 6-element sequence, and otherwise, choose only $s^{\rm in}_i$, $s^{\rm out}_i$, $s^{\rm in}_i$. In the other direction, suppose the instance of Star STS has a solution. For each $i$, we must use the subsequence $s^{\rm in}_i$, $s^{\rm out}_i$, and $s^{\rm in}_i$ because no other swaps operate on vertices $s^{\rm in}_i$ and $s^{\rm out}_i$, and all three of these swaps are needed to re-position the tokens correctly, i.e.~there is no other way to switch the positions of tokens $s^{\rm in}_i$ and $s^{\rm out}_i$. Note that the first swap places token $s^{\rm in}_i$ at the center vertex of the star. Now consider the swaps $a_i, b_i, a_i$. If we use all three, then this corresponds to using $s_i$, and if we use none of them, then this corresponds to not using $s_i$. We claim that these are the only possibilities because, if we choose $a_i,a_i$ it does nothing, and if we choose any other proper non-empty subsequece of $a_i, b_i, a_i$ then token $s^{\rm in}_i$, would not be at the center vertex when we perform $s^{\rm out}_i$, and $s^{\rm in}_i$, and thus would not reach its target vertex. \end{proof} \section{Open Problems} Many interesting related problems remain open. For sequential token swapping on trees, where is the divide between NP-complete and polynomial-time? Our reduction's tree is a subdivided star (as for parallel token swapping) with the addition of one extra leaf (the nook) per path. By contrast, there is a polynomial-time algorithm for the case of a broom (a star with only one edge subdivided) \cite{vaughan1999broom,kawahara2019time,tree-token-swapping}. What about a star with two subdivided edges? Another direction (for both sequential/parallel variations) is to explore low-diameter trees, or more generally, low-diameter graphs. Our reductions use long paths. Is there a polynomial-time algorithm (ideally fixed-parameter tractable) for low-diameter trees or graphs? What if we attach such a graph to a long path? For parallel token swapping, even the case of a single long path is open. Kawahara et al.~\cite{kawahara2019time} gave an additive approximation algorithm that uses at most one extra round. Is there an optimal algorithm, or is parallel token swapping NP-hard on paths? There are also open problems in approximation algorithms. In parallel token swapping, we know that there is no PTAS~\cite{kawahara2019time}. Is there an $O(1)$-approximation for trees or general graphs? For sequential token swapping, there is a 4-approximation algorithm~\cite{miltzow2016approximation}. Is 4 a lower bound on the approximation factor of this algorithm? Is $4$-approximation the best possible for general graphs? Although this paper focused on the best reconfiguration sequence, much research is devoted to understanding the worst-case behavior for a given graph; is it NP-hard to determine the diameter of the Cayley graph, i.e., the maximum number of reconfiguration steps that can be required for any pair of token configurations? This problem is open for both sequential token swapping (implicit in ~\cite{chitturi2019sorting}) and parallel token swapping \cite{alon1994routing}. \section{Introduction} Imagine $n$ distinctly labeled tokens placed without collisions on the $n$ vertices of a graph~$G$. For example, these $n$ tokens might represent (densely packed) movable \defn{agents} --- robots, people, packages, shipping containers, data packets, etc.\ --- while the $n$ vertices represent possible agent locations. Now suppose we want to move the tokens/agents around, for example, to bring certain shipping containers to the loading side of a cargo ship. In particular, we can suppose every token has a given start vertex and destination vertex, and the goal is to move every token to its desired destination. Because every vertex has a token (agents are densely packed), a natural reconfiguration operation is to \defn{swap} two adjacent tokens/agents, that is, to exchange the tokens on the two endpoints of a given edge in~$G$. In this paper, we study token reconfiguration by swaps from a given start configuration to a given destination configuration with two natural objective functions: \begin{enumerate} \item \textbf{(Sequential) Token Swapping} (a.k.a.\ ``sorting with a transposition graph'' \cite{akers1989group}): Minimize the number of swaps, i.e., the total work required to reconfigure. \item \textbf{Parallel Token Swapping} (a.k.a.\ ``routing permutations via matchings'' \cite{alon1994routing}): Minimize the number of rounds of simultaneous swaps (where the edges defining the swaps form a matching, so avoid conflicting shared endpoints), i.e., the total execution time or makespan required to reconfigure. \end{enumerate} These reconfiguration problems can be cast in terms of the symmetric group. Each possible reconfiguration step --- swapping along one edge in the sequential problem, or swapping along every edge of a matching in the parallel problem --- is a particular permutation on the $n$ tokens (element of the symmetric group~$S_n$). Assuming the graph is connected, these permutations generate~$S_n$, defining a \defn{Cayley graph} $C$ \cite{cayley-graph} where each node $\pi$ in $C$ corresponds to a permutation $\pi$ of the tokens (a collision-free placement of the tokens) and an undirected edge connects two nodes $\pi_1,\pi_2$ in $C$ if there is a reconfiguration step (swapping an edge or matching in~$G$) that transforms between the two corresponding permutations $\pi_1,\pi_2$. Minimizing the number of reconfiguration steps between two configurations of the tokens (sequential/parallel token swapping) is equivalent to finding the shortest path in the Cayley graph between two given nodes corresponding to two given permutations in~$S_n$. In fact, sequential token swapping was first studied by Cayley in 1849 \cite{cayley} who (before inventing the Cayley graph) solved the problem on a clique, i.e., without any constraint on which tokens can be swapped. What is the complexity of token swapping? In general, it is PSPACE-complete to find a shortest path between two given nodes in a Cayley graph defined by given generators \cite{jerrum1985complexity}. But when the generators include transpositions (single-swap permutations) as in both sequential and parallel token swapping, $O(n^2)$ swaps always suffice \cite{yamanaka2015swapping}, so the token-swapping problems are in NP. Both sequential token swapping \cite{AmirP15} and parallel token swapping \cite{banerjee2017new,kawahara2019time} are known to be NP-complete on a general graph. In this paper, we strengthen these NP-completeness results to hold even when the graph is restricted to be a tree. Sequential token swapping on a tree was first studied over thirty years ago by Akers and Krishnamurthy \cite{akers1989group}, in the context of interconnection networks. Specifically, they proposed connecting processors together in a network defined by a Cayley graph, in particular a Cayley graph of transpositions corresponding to edges of a tree (what they call a \defn{transposition tree}), so the shortest-path problem naturally arises when routing network messages. They gave an algorithm for finding short (but not necessarily shortest) paths in the resulting Cayley graphs, and characterized the diameter of the Cayley graph (and thus found optimal paths \emph{in the worst case} over possible start/destination pairs of vertices) when the tree is a star. Follow-up work along this line attains tighter upper bounds on the diameter of the Cayley graph in this situation when the graph is a tree \cite{vaughan1991bounds,ganesan2012efficient,kraft2015diameters,chitturi2018sorting} and develops exponential algorithms to compute the exact diameter of the Cayley graph of a transposition tree \cite{chitturi2019sorting}, though the complexity of the latter problem remains open. Here we show NP-hardness of the slightly more general problem of computing the shortest-path distance between two given nodes in the Cayley graph of a transposition tree (sequential token swapping on a tree), a problem implicit in \cite{akers1989group} and explicitly posed as an open problem in \cite{yamanaka2015swapping}. A well-known special case is when the graph is not just a tree but also a path. In this case, sequential token swapping is equivalent to sorting an array by the fewest possible swaps of adjacent elements. Bubble sort is known to be optimal for this problem, with a number of swaps equal to the number of inversions \cite{knuth1998art3} in the relative permutation $\pi_2 \circ \pi_1^{-1}$ that takes the start permutation $\pi_1$ to the destination permutation~$\pi_2$. Parallel token swapping was also introduced in the context of network routing: in 1994, Alon, Chung, and Graham \cite{alon1994routing} called the problem ``routing permutations via matchings''. They focused on worst-case bounds for a given graph (the diameter of the Cayley graph); in particular, they proved that any $n$-vertex tree (and thus any $n$-vertex connected graph) admits a $< 3n$-round solution, a bound later improved to $\frac{3}{2} n + O(\log n)$ \cite{zhang1999optimal}. Like sequential token swapping, computing the exact diameter of the Cayley graph of a given tree remains open, but we show NP-hardness of the slightly more general problem of computing the shortest-path distance between two given nodes in such a Cayley graph (parallel token swapping on a tree). \subsection{Our Results} \begin{enumerate} \item Sequential token swapping is NP-complete on trees. \item Weighted sequential token swapping is NP-complete on trees (intuition for Result 1). \item Parallel token swapping is NP-complete on trees, even on subdivided stars. \item Known techniques for approximating sequential token swapping on trees preclude approximation factors less than 2. \end{enumerate} {\bf Result 1} is our most difficult and technical result. The main intuition % is given by {\bf Result~2} in Section~\ref{sec:NP-hard-weighted}---NP-completeness of \defn{weighted} sequential token swapping, where each token has a nonnegative integer \defn{weight} and the cost of a swap is the sum of the weights of the two tokens being swapped. This reduction uses weights of just $0$ and~$1$, making some tokens ``free'' to move. Our main technical challenge for {\bf Result 1} (in Section~\ref{sec:NP-hard-unweighted}) is simulating the effect of weight-$1$ tokens with long paths of vertices and tokens, effectively showing that these tokens must move together, and making the cost of moving this group dominate the movement of simulated weight-$0$ tokens. The main difficulty in the new setting is that free swaps (i.e., swaps involving $0$-weight tokens) cannot be ignored anymore. We need a careful accounting to show that, although solutions can slightly deviate from each other, they all have the same pattern (i.e., at all times, we can tie a long path of vertices to tokens of weight $1$ in the first reduction, and so on). To give a sense of the complexity, our weighted hardness proof fits in just a couple of pages, while our unweighted proof spans around thirty pages. Our next main result is {\bf Result 3}, NP-completeness of parallel token swapping on trees, and even stronger, on \defn{subdivided stars} which have only one vertex of degree $>2$. At a high level, our reduction in Section~\ref{sec:parallel} is similar to the previous one, % using the one high-degree vertex as a bottleneck to limit the available parallelism. The details differ significantly, requiring the development of new techniques for constraining parallel token swapping behavior. In particular, we develop ``enforcement'' tokens that need to swap through the high-degree vertex at specific times in order to force congestion at certain times. This proof's difficulty is in between the unweighted and weighted sequential hardness proofs. All three of our NP-hardness reductions are from a common NP-complete problem, in essence the problem called \defn{permutation generation} in Garey and Johnson~\cite[MS6]{Garey-Johnson}. But we recast this problem in terms of a token-swapping \defn{reachability} problem where the swaps must be chosen as a subsequence of a given sequence and the underlying graph is just a star: \begin{quote} \textbf{Star Subsequence Token-Swapping Reachability (Star STS):} Given a star graph with center vertex $0$ and leaves $1, 2, \ldots, m$, where vertex $i$ initially has a token $i$; given a target permutation $\pi$ of the tokens; and given a sequence of swaps $s_1, s_2, \ldots, s_n$, where $s_j \in \{1, \ldots, m\}$ indicates a swap on edge $(0, s_j)$, is there a subsequence of the given swaps that realizes~$\pi$? \end{quote} Appendix~\ref{appendixA} gives the straightforward reduction from permutation generation to Star STS. At a high level, our three NP-hardness proofs all rely on representing the tokens from the Star STS instance using specific ``item tokens'' in the token-swapping instance and by associating locations in the token swapping graph with vertices of the Star STS star. Then the bulk of the construction in each of the three reductions is meant to constrain where these item tokens can go in the graph over the course of the token-swapping solution. By sufficiently constraining the movement of the item tokens, we can make sure that they have some opportunities to swap among themselves, but that these opportunities to swap correspond to the given sequence of swaps from the Star STS instance. Our final result, {\bf Result 4}, is about approximability of sequential token swapping. There are three known 2-approximation algorithms for sequential token swapping in trees: Akers and Krishnamurthy's ``happy swap'' algorithm \cite{akers1989group} (from the original paper introducing sequential token swapping in trees), Vaughan's algorithm \cite{vaughan1991bounds}, and Yamanaka et al.'s cycle algorithm \cite{yamanaka2015swapping} (from the paper that introduced the ``token swapping'' terminology). The first and last algorithms share a natural property: every token $t$ always remains within distance $1$ of the shortest path from $t$'s start vertex to $t$'s destination vertex. We show in Section~\ref{sec:inapprox} that this natural property is a fundamental barrier to improved approximation: any $< 2$-approximation algorithm must in general bring a token \emph{arbitrarily far} --- an $\Omega(n^{1-\epsilon})$ distance away --- from its shortest path. This result cleanly generalizes previous arguments that Akers and Krishnamurthy's and Yamanaka et al.'s algorithms have an approximation factor of exactly~$2$ \cite{tree-token-swapping}. We also obtain the first proof that Vaughan's algorithm \cite{vaughan1991bounds} is no better than a $2$-approximation; the best previous lower bound for its approximation factor was $\frac{4}{3}$ \cite{tree-token-swapping}. \vspace{-2ex} \subsection{Related Work} Sequential token swapping has been studied before by many researchers in many disparate fields, from discrete mathematics \cite{cayley,portier-vaughan1990star,vaughan1991bounds,pak1999reduced,vaughan1999broom,kraft2015diameters} and theoretical computer science \cite{jerrum1985complexity,knuth1998art3,ganesan2012efficient,yamanaka2015swapping,yasui2015swapping,AmirP15,miltzow2016approximation,bonnet2017complexity,kawahara2019time,yamanaka2018colored,chitturi2018sorting,chitturi2019sorting,tree-token-swapping} to more applied fields including network engineering as mentioned earlier \cite{akers1989group}, robot motion planning \cite{MotionPlanning_SoCG2018,surynek2019multi}, and game theory \cite{gourves2017object}. On general graphs, the problem is known to be NP-complete \cite{AmirP15}, furthermore APX-hard \cite{miltzow2016approximation}, and even W[1]-hard with respect to number of swaps \cite{bonnet2017complexity}. In particular, the best approximation factor we can hope for is a constant $>1$. Miltzow et al.~\cite{miltzow2016approximation} gave a $4$-approximation for general graphs (generalizing the original 2-approximation for trees \cite{akers1989group}), which remains the best known for general graphs. The main other approximation algorithms are the $2$-approximations on trees mentioned above \cite{akers1989group,vaughan1991bounds,yamanaka2015swapping}. Polynomial-time exact algorithms are known for cliques \cite{cayley}, paths \cite{knuth1998art3}, cycles \cite{jerrum1985complexity}, stars \cite{portier-vaughan1990star,pak1999reduced}, brooms \cite{vaughan1999broom,kawahara2019time,tree-token-swapping}, complete bipartite graphs \cite{yamanaka2015swapping}, and complete split graphs \cite{yasui2015swapping}. See also the surveys by Kim \cite{kim2016sorting} and Biniaz et al.~\cite{tree-token-swapping}. One of the strongest positive results for sequential token swapping is the case of a \defn{broom} (a path attached to a star). There are three different solutions to this problem \cite{vaughan1999broom,kawahara2019time,tree-token-swapping}, and all three involve very difficult proofs of correctness. This difficulty speaks to the challenge of arguing about token swapping, specifically, showing that the optimal reconfiguration has a particular form. These challenges arise in our proofs as well. Notably, our parallel reduction uses subdivided stars (the generalization of brooms to allow each ``bristle'' to be an arbitrary-length path) and our sequential reduction uses graphs that are close to subdivided stars (generalized so that each bristle path has one additional leaf attached), making our NP-hardness results strikingly close to the polynomial case of brooms. In the \defn{colored} generalization of token swapping \cite{yamanaka2018colored}, some subsets of tokens have identical labels (colors), so each of these subsets (color classes) can be permuted arbitrarily. This setting arises naturally in applications where agents (tokens) do not densely fill locations (vertices): one color class can represent ``empty'' vertices. Colored sequential token swapping is NP-hard even with just three color classes, but polynomial-time with two color classes \cite{yamanaka2018colored}. Miltzow et al.'s $4$-approximation algorithm for sequential token swapping \cite{miltzow2016approximation} generalizes to this setting. Exact solutions for paths and stars generalize to colored sequential token swapping, even with weights on tokens \cite{tree-token-swapping}. NP-hardness for weighted colored sequential token swapping on trees was proved recently \cite{tree-token-swapping}; we remove both the ``colored'' and ``weighted'' qualifiers on this result. Parallel token swapping is known to be NP-complete in bipartite maximum-degree-$3$ graphs, NP-complete even when restricted to just three rounds, but polynomial-time when restricted to one or two rounds, but NP-complete again for colored tokens restricted to two rounds \cite{banerjee2017new,kawahara2019time}. Two approximation results are known: an additive approximation for paths which uses only one extra round \cite{kawahara2019time}, and a multiplicative $O(1)$-approximation for the $n \times n$ grid graph \cite{MotionPlanning_SoCG2018}.% \footnote{The results of \cite{MotionPlanning_SoCG2018} are phrased in terms of motion planning for robots, and in terms of a model where an arbitrary disjoint collection of cycles can rotate one step in a round. However, the techniques quickly reduce to the model of swapping disjoint pairs of robots, so they apply to parallel motion planning as well. They show that there is always a solution within a constant factor of the obvious lower bound on the number of rounds: the maximum distance between any token's start and destination.} For other special graph classes, there are tighter worst-case bounds on the diameter of the Cayley graph \cite{alon1994routing,li2010routing,banerjee2017new}. Other models for moving tokens in graphs have been introduced. In ``sliding tokens'' \cite{NCL_TCS}, some vertices do not have tokens, vertices with tokens must always form an independent set, tokens are all identical (one color class), and the goal is to decide whether reconfiguration is even possible (a variation of independent set reconfiguration \cite{NPReconfiguration_TCS}). This problem is PSPACE-complete even for planar graphs \cite{NCL_TCS}, but polynomial on trees \cite{TokenReconfigurationTrees_TCS2015}. The associated Cayley graphs are called ``token graphs'', whose properties such as $k$-connectivity are well-studied; see \cite{fabila2020token}. In ``movement problems'' \cite{Movement_TAlg,Movement_APPROX2011,MovementFPT_TALG}, the problem is further relaxed to allow multiple tokens on the same vertex, and the goal is for the vertices with tokens to induce a subgraph with a particular property such as connectivity. In ``sequentially swapping'' \cite{SequentialTokenSwapping_JGAA2019}, the entire reconfiguration sequence consists of moving one token (conceptually, a blank space) along a nonsimple path in the graph, swapping each token encountered with the previous position in the path, and the goal is to minimize the length of the path. This model is a natural graph generalization of the Fifteen Puzzle (which is itself NP-hard on an $n \times n$ grid \cite{ratner1990n2,FifteenPuzzle_TCS}). This problem can be solved exactly on trees, complete graphs, and cycles; and with two color classes, it is APX-hard \cite{SequentialTokenSwapping_JGAA2019}. There is recent work exploring a version of token swapping where some specified pairs of tokens may not swap~\cite{defant2020friends}. Many of these problems have applications in AI, robotics, motion planning, and quantum circuit compilation. See \cite{surynek2019multi} for a recent survey on the practical side. There are also game-theoretic models for token swapping, where vertices are selfish players each of which has a strict total order on their preference among the tokens (called objects). A swap between adjacent vertices is possible only when it benefits both vertices (each player obtaining a higher object in their total order). In this setting, deciding whether a given configuration can be reached is NP-complete but polynomial on trees; deciding whether a given token can reach a specified vertex is NP-complete even for a tree but polynomial on paths and stars; and finding an equilibrium (Pareto-efficient) configuration is NP-complete but polynomial on paths and stars and open on trees \cite{gourves2017object}. \section*{Acknowledgments} This research was initiated at the 34th Bellairs Winter Workshop on Computational Geometry, co-organized by Erik Demaine and Godfried Toussaint, held on March 22--29, 2019 in Holetown, Barbados. We thank the other participants of that workshop for providing a stimulating research environment. Research supported in part by NSERC. Zuzana Mas\'arov\'a supported by Wittgenstein Prize, Austrian Science Fund (FWF), grant no.~Z 342-N31 Virginia Vassilevska Williams supported by an NSF CAREER Award, NSF Grants CCF-1528078, CCF-1514339 and CCF-1909429, a BSF Grant BSF:2012338, a Google Research Fellowship and a Sloan Research Fellowship. Nicole Wein supported by NSF Grant CCF-1514339. \input{intro.tex} \input{NP-hard_weighted.tex} \input{NP-hard_unweighted.tex} \input{no_better_algs.tex} \input{parallel.tex} \input{conclusion.tex} \section{Known techniques preclude approximation factors less than 2} \label{sec:inapprox} Previous results about sequential token swapping on trees include three different polynomial time 2-approximation algorithms and some lower bounds on approximation factors. The three algorithms all have the property that if a token at a leaf is at its destination (i.e., it is a ``happy leaf token'') then the algorithm will not move it. Biniaz et al.~\cite{tree-token-swapping} proved that any algorithm with this property has a (worst case) approximation factor at least $\frac{4}{3}$. They also proved via ad-hoc arguments that the approximation factor is exactly 2 for two of the known 2-approximation algorithms (the ``Happy Swap Algorithm'' and the ``Cycle Algorithm''). For the third 2-approximation algorithm, Vaughan's algorithm, they could not prove a lower bound better than $\frac{4}{3}$. This section contains two results: we prove that Vaughan's algorithm has approximation factor exactly 2. We also extend the approximation lower bounds of Biniaz et al.~by proving that the approximation factor is at least 2 for a larger family of algorithms. % We formalize this family as follows. For token $t$ let $P_t$ be the path from $t$'s initial position to its final position. A sequence of token swaps is \defn{$\ell$-straying} if at all intermediate points along the sequence, every token $t$ is within distance $\ell$ of the last vertex of $P_t$ that it has reached up to this point. A token swapping algorithm is \defn{$\ell$-straying} if it produces $\ell$-straying sequences. Both approximation lower bounds will be proved for the same family of trees that was used by Biniaz et al.~\cite{tree-token-swapping}. For any $k$ and any odd $b$ we define a tree $T_{k,b}$ together with initial and final positions of tokens. $T_{k,b}$ has $b$ paths of length $k$ attached to a central vertex, $c$, and a set $L$ of $k$ leaves also attached to $c$. See Figure~\ref{fig:branch-example}. The tokens at $c$ and $L$ are \defn{happy}---they are at their final positions. The tokens in branch $i, 0 \le i \le b-1$ have their final positions in branch $i+1$, addition modulo $b$, with the initial and final positions equally far from the center $c$. \begin{figure}[htb] \centering \includegraphics[width=.3\textwidth]{Figures/T43.pdf} \caption{Tree $T_{k,b}$ with $b=3$ branches each of length $k=4$, and with $k=4$ leaves attached to the center node. The dashed arrows go from a token's initial to final positions.} \label{fig:branch-example} \end{figure} Biniaz et al.~\cite{tree-token-swapping} proved that the optimum number of swaps for $T_{k,b}$ is at most $(b+1) ({k+1 \choose 2} +2k)$. The solution repeatedly exchanges the tokens in branch $i, 0 \le i \le b - 1 $, modulo $b$, with the tokens at $L$. The first exchange moves the tokens initially at $L$ into branch 0, and the $(b+1)^{\rm st}$ exchange moves those tokens back to $L$. We prove that for $T_{k,b}$ the approximation factor is not better than 2 for $\ell$-straying algorithms (Subsection~\ref{sec:ell-straying}) and for Vaughan's algorithm (Subsection~\ref{sec:Vaughan}) \ifabstract in the Appendix \fi. \later{ \ifabstract \section{Proofs that known techniques preclude $<2$-approximations} \fi \subsection{\texorpdfstring{$\ell$}{l}-straying algorithms do not achieve better than 2-approximation} \label{sec:ell-straying} Before proving the main result, we compare $\ell$-straying algorithms to previous algorithms/properties. It is easy to show that the Happy Swap Algorithm and the Cycle Algorithm are 1-straying (see ~\cite{tree-token-swapping} for descriptions of these algorithms). Thus our lower bound of 2 on the approximation factor replaces the ad hoc arguments of Biniaz et al.~\cite{tree-token-swapping}. We next compare the property of being $\ell$-straying to the property of fixing happy leaves. A swap sequence is \defn{minimal} if it never swaps the same two tokens more than once. It is easy to test this property and eliminate duplicate swaps. \begin{claim} A minimal 1-straying sequence does not move happy leaf tokens. \end{claim} \begin{proof} Suppose there is a happy leaf vertex $v$ with a token $t$ that is at its destination. Let $u$ be the vertex adjacent to $v$. The path $P_t$ from $t$'s initial to final vertex consists only of vertex $v$ so in a 1-straying swap sequence, token $t$ can only be at vertex $v$ or $u$. Suppose that at some point in the sequence there is a swap that moves $t$ to $u$ and moves a token, say $s$, from $u$ to $v$. The next time token $t$ moves, it must move back to $v$, and since $v$ is a leaf, token $s$ is stuck at $v$ until then. % Thus tokens $t$ and $s$ must re-swap on edge $uv$ at some later point in the sequence. Removing the two swaps of tokens $t$ and $s$ yields a shorter equivalent 1-straying sequence. \end{proof} We now prove the main result of this section. \begin{theorem} % $\ell$-straying algorithms do not achieve approximation factor less than 2. More precisely, for every small $\epsilon, \gamma > 0$, there exists an $n$ and an instance of token swapping on an $n$-node tree so that any $\ell$-straying algorithm for $\ell\leq n^{1-\gamma}$ cannot achieve an approximation factor better than $2-\epsilon$. \end{theorem} \begin{proof} We will prove a lower bound on the number of swaps used by any $\ell$-straying algorithm on $T_{k,b}$. Then we will choose values of $b$ and $k$ to get the ratio of the algorithm versus the optimum arbitrarily close to 2. We count two kinds of swaps performed by an $\ell$-straying algorithm: type-A swaps between tokens with initial positions in the same branch; and type-B swaps between tokens with initial positions in different branches. \begin{lemma} \label{lemma:typeA} The number of type-A swaps is at least $\frac{1}{2} b (k-b\ell)^2$. \end{lemma} \begin{proof} We count the number of type-A swaps for one branch $B$. Fix a token $t$ whose initial position is branch $B$ and at distance $i$ from the center, $1 \le i \le k$. Let $S(t)$ be the set of tokens whose initial position is in branch $B$ and closer to the center than $t$'s initial position. Then $|S(t)| = i-1$. Intuitively, we can think of $S(t)$ as a set of tokens that $t$ must swap with if we restrict to $t$'s initial and final branches. Let $H$ be the set of vertices within distance $\ell$ of the center. Observe that $|H| = b\ell + k + 1$. Let $H(t)$ be the tokens at vertices of $H$ at the point in time right before $t$ moves from the center vertex into its final branch for the first time. Intuitively, the only tokens of $S(t)$ that can ``hide'' and avoid swapping with $t$ are in $H(t)$. \begin{claim} \label{claim:same-branch-swaps} Token $t$ swaps with every token in $S(t) \setminus H(t)$. \end{claim} Before proving the claim we work out the bounds. The token initially at the center and the tokens at the $k$ leaves attached to the center were happy initially so they must stay within distance $\ell$ of their initial positions, and thus within distance $\ell$ of the center, which means that these tokens lie in $H(t)$. Also $t$ lies in $H(t)$. Thus $|S(t) \cap H(t)| \le b\ell -1$, and $|S(t) \setminus H(t)| \ge (i-1) - (b\ell-1) = i - b \ell$. Then the number of swaps per branch is at least $$\sum_{i=b\ell}^{k} (i-b\ell) = \sum_{i=0}^{k-b\ell} i = \frac{1}{2}(k-b\ell +1)(k-b\ell).$$ Summing over all $b$ branches gives a total of at least $\frac{1}{2} b (k-b\ell )^2$ type-A swaps. \begin{proof}[Proof of Claim~\ref{claim:same-branch-swaps}] Fix a token $t' \in S(t) \setminus H(t)$. Note that $t'$ always lies in its initial or final branch or at a vertex of $H$. At the point in time right before $t$ moves from the center vertex into its final branch for the first time, $t'$ is outside $H$, so it must be more than distance $\ell$ from the center and either: (1) in its initial branch; or (2) in its final branch. In case (1) $t'$ has never reached the center by the definition of $\ell$-straying. But $t$ has reached the center, and was initially further from the center than $t'$, so $t$ and $t'$ must have swapped in the past. In case (2) $t'$ will never leave its final branch in the future by the definition of $\ell$-straying. Meanwhile, $t$ is currently closer to the center than $t'$ and will end farther from the center than $t'$ and on the same branch. This means that $t$ and $t'$ must swap in the future. \end{proof} This completes the proof of Lemma~\ref{lemma:typeA}. \end{proof} \begin{lemma} \label{lemma:typeB} The number of type-B swaps is at least $\frac{1}{2}b(k-2\ell)^2$. \end{lemma} \begin{proof} Fix a branch $B$, and consider its \defn{tail} $T$ which consists of its last (furthest from the center) $k-2\ell$ vertices. Let $I(B)$ [$F(B)$] be the set of tokens whose initial [final, respectively] position is in the branch, and let $I(T)$ [$F(T)$] be the set of tokens whose initial [final] position is in the tail. If a token $t$ outside $I(B)$ enters the tail at some point in time, then, by the definition of $\ell$-straying, $t$'s final position cannot be outside $B$, nor among the first $\ell$ vertices of $B$. This implies that, from this time on, $t$ must stay in $B$. Thus at all points in time, the tokens in the tail are a subset of $I(B) \cup F(B)$. Every one of the $k - 2\ell$ tokens in $F(T)$ must enter the tail at some point in time. (Note that other tokens of $F(B)$ may enter the tail and then leave the tail.) Let $t_1, t_2, \ldots, t_{k-2\ell}$ be a list of the first $k-2\ell$ tokens of $F(B)$ that enter the tail, ordered by their first entry time. When $t_i$ is about to enter the tail, there are at most $i-1$ tokens of $F(B)$ in the tail, so there are at least $k-2\ell-(i-1)$ tokens of $I(B)$ in the tail. Furthermore, $t_i$ must swap with all of them, since they leave $B$ and $t_i$ stays inside $B$ from this point on. Thus the total number of swaps between a token of $F(B)$ and a token of $I(B)$ is at least $$\sum_{i=1}^{k-2\ell} (k-2\ell-(i-1)) = \sum_{j=1}^{k-2\ell} j = \frac{1}{2}(k-2\ell+1)(k-2\ell).$$ The total over all $b$ branches is then at least $\frac{1}{2} b (k - 2\ell)^2$. \end{proof} To complete the proof of the theorem we calculate the approximation factor for $T_{k,b}$. Let ALG be the number of swaps performed by an $\ell$-straying algorithm, and let OPT be the optimum number of swaps. By the above two lemmas, ${\rm ALG} \ge \frac{1}{2}b (k-b\ell)^2 + \frac{1}{2}b(k-2\ell)^2 \ge b(k-b\ell)^2$ for $b \ge 2$. Biniaz et al.~\cite{tree-token-swapping} proved that ${\rm OPT} \le (b+1) ({k+1 \choose 2} +2k)$. Choose $b = k^\delta$ for any small $\delta$, $0 < \delta < \frac{1}{2}$. Then ${\rm OPT} \le \frac{1}{2} k^{2+\delta} + O(k^{2})$ and ${\rm ALG} \ge k^{2+\delta} - O(k^{1 + 2 \delta}\ell)$. This gives ${\rm ALG}/{\rm OPT} \ge 2 - O(\frac{1}{k^\delta})$. To prove the stronger claim in the theorem, let $\epsilon,\gamma>0$ be given. Pick $k$ large enough so that $\epsilon$ is bigger than $24/k^\delta$. Let $b=k^\delta$ as before. However, now pick $\delta$ in terms of $\gamma$, so that $k^{1-2\delta}=(kb)^{1-\gamma}=k^{1+\delta-\gamma-\delta\gamma}$, and hence $\delta=\gamma/(1.9-\gamma)$ suffices. \end{proof} The fact that the lower bound on the approximation factor holds even if $\ell$ grows almost linearly in the size of the tree is interesting because it means that any approximation algorithm that performs better than the current best-known algorithms must be drastically different. \subsection{Vaughan's algorithm does not achieve better than 2-approximation} \label{sec:Vaughan} The previous section shows that any $\ell$-straying algorithm for token swapping on a tree cannot achieve an approximation factor better than 2. Of the three known approximation algorithms, two of them---the Happy Swap Algorithm and the Cycle Algorithm---are 1-straying. (This follows easily from the descriptions of those algorithms in ~\cite{tree-token-swapping}.) The third algorithm, Vaughan's algorithm, does not have this property, since tokens can stray far from their shortest paths. In this section we prove that Vaughan's algorithm cannot achieve an approximation factor better than 2. \subsubsection{Description of Vaughan's algorithm} Most token swapping algorithms find the sequence of swaps in order from first to last, i.e., based on the initial and final token configurations, the algorithm decides on the first swap to be made. This swap changes the initial token configuration, and the algorithm is applied recursively to the new initial configuration and the unchanged final configuration. Vaughan's algorithm is different. It exploits the symmetry that the reverse of a token swapping sequence changes the final configuration to the initial one. In particular, her algorithm may add a swap to either the start or the end of the sequence. If a swap is added at the start of the sequence, the initial configuration changes. If a swap is added at the end of the sequence, the final configuration changes. In either case, the algorithm is applied recursively. We describe and analyze her algorithm by thinking of each token as a pair of tokens, $t,t_f$, where $t$ is our usual token and $t_f$ is a ``destination token'' that is placed initially on $t$'s destination node. The goal is to get $t$ and $t_f$ to the same node of the tree. At any point in time any tree node has one token and one destination token. Swapping adjacent tokens $s$ and $t$ is the usual operation. Swapping adjacent destination tokens $s_f$ and $t_f$ means that the \emph{last} swap in the sequence will be of tokens $s$ and $t$. \paragraph*{Notation:} If a token and its destination are at the same node we say that the token and the destination token are \defn{happy}. We say that an unhappy token \defn{wants} to move along its incident edge towards its destination token. Symmetrically, we say that a destination token \defn{wants} to move along its incident edge towards its corresponding token. Vaughan's algorithm uses the following three operations. See also Figure~\ref{fig:Vaughan-swaps}. \begin{description} \item[Happy swap.] If $s$ and $t$ are two adjacent tokens that want to move towards each other, then output the swap $(s,t)$ and recursively solve the problem that results from swapping $s$ and $t$. \item[Happy destination swap.] If $t_f$ and $s_f$ are two adjacent destination tokens that want to move towards each other, then recursively solve the problem that results from swapping $t_f$ and $s_f$, and then output the swap $(s,t)$. \item[Symmetric shove.] Suppose $u$ and $v$ are adjacent nodes, where $u$ has token $t$ and destination token $r_f$, and $v$ has token $s$ and destination $s_f$ (so $s$ and $s_f$ are happy). Suppose that $t$ and $r_f$ both want to move towards $v$. Then output the swap $(s,t)$, recursively solve the problem that results from swapping $s,t$ and swapping $r_f,s_f$, then output the swap $(r,s)$. \end{description} \begin{figure}[h] \centering \includegraphics[width=.7\textwidth]{Figures/Vaughan-swaps.pdf} \caption{The three operations of Vaughan's algorithm. An arrow beside a [destination] token indicates the direction it wants to move.} \label{fig:Vaughan-swaps} \end{figure} Vaughan's algorithm applies these operations in order. If there is a happy swap or a happy destination swap that can be performed, do so. Otherwise perform a symmetric shove---she proves that one exists in this situation. Then repeat. Vaughan's algorithm has several important properties: \begin{description} \item{(P1)} Once a token is happy it stays happy. \item{(P2)} Unhappy tokens and destination tokens only move in the direction they want to move (while happy tokens can move arbitrarily). \item{(P3)} If $\sigma$ is a sequence of swaps returned by the algorithm then the reverse of $\sigma$ is a possible output of the algorithm for the instance where tokens and their destinations are flipped, i.e., each pair $t, t_f$ is replaced by $t_f, t$. \end{description} Property (P1) is true because the only operation that involves a happy token is a symmetric shove and the happy token $s$ remains happy. Property (P2) is true because every operation that moves an unhappy [destination] token moves it in the direction it wants to go. Property (P3) was observed by Vaughan. It is true because in the reversed problem happy swaps and happy destination swaps exchange roles, and a symmetric shove remains a symmetric shove. \begin{remark} We note that Vaughan's algorithm is not $\ell$-straying even if $\ell$ is $(n-1)/2$, and even if the tree is just a path. Say $n=2k+1$ is odd. The tokens in consecutive order on the path are $k+2,k+3,\ldots,2k+1,k+1,1,2,\ldots,k$, and the target of token $i$ is position $i$ of the path. Token $k+1$ is happy. A valid application of Vaughan's algorithm repeats the following for each $i$ from $k$ down to $1$: perform a symmetric shove of token $k+1+i$ with token $k+1$, and then use only happy swaps to move token $k+1+i$ to position $k+1+i$. This causes token $k+1$ to end up in position $1$, which is at distance $(n-1)/2$ from its desired destination and path. \end{remark} \subsubsection{Vaughan's algorithm on \texorpdfstring{$T_{k,b}$}{T\_\{k,b\}}} \begin{theorem} \label{thm:Vaughan-bound} The approximation factor of Vaughan's algorithm is not less than 2. \end{theorem} \begin{proof} We will show that on the tree $T_{k,b}$ the number of swaps, ALG, performed by Vaughan's algorithm is at least $bk(k-3)$ swaps. Recall that the optimum number of swaps, OPT, is at most $(b+1)({{k+1} \choose 2} +2k) $. For $k=b$, we get ${\rm OPT} \le \frac{1}{2} k^3 + \Theta(k^2)$, and ${\rm ALG} \ge k^3 - \Theta(k^2)$. Then ${\rm ALG} / {\rm OPT} \ge 2 - \Theta(\frac{1}{k})$, which proves the theorem. It remains to show that Vaughan's algorithm performs at least $bk(k-3)$ swaps on $T_{k,b}$. We will consider the dynamically changing quantity $D=\sum_t d(t,t_f)$, that is, the sum over all tokens $t$ of the distance from the current position of $t$ to the current position of the destination token $t_f$. Note that a happy swap and a happy destination swap both decrease $D$ by 2. A symmetric shove also decreases $D$ by 2, however it performs two swaps so a symmetric shove decreases $D$ by an average of 1 per swap. Since happy swaps and happy destination swaps are ``cheaper'' in this sense than symmetric shoves, to prove a lower bound on the number of swaps, we will prove an \emph{upper bound} on the number of happy swaps and happy destination swaps. Specifically, we will prove that the total number of happy swaps is at most $bk$. \begin{lemma} \label{lemma:happy-swap-bound} The total number of happy swaps is at most $bk$. \end{lemma} We first show that this lemma gives the bound we want. By Property (P3) the lemma also implies that the total number of happy destination swaps is at most $bk$. Now consider the quantity $D$ defined above. Initially, $D=b\sum_{i=1}^k 2i=bk(k+1)$ and at the end, $D=0$. Since each happy swap and each happy destination swap decreases $D$ by 2, these two operations can each decrease $D$ by a total of at most $4bk$. Thus, symmetric shoves account for decreasing $D$ by at least $bk(k+1)-4bk=bk(k-3)$. Since each swap in a symmetric shove decreases D by an average of 1, the total number of swaps is at least $bk(k-3)$, as required. It remains to prove Lemma~\ref{lemma:happy-swap-bound}. We begin with two claims about the relative ordering of tokens and their destination tokens during the course of Vaughan's algorithm on the tree of branches. \noindent \textbf{Notation:} For any token $t$, let $Q_t$ be the path consisting of the branch initially containing $t$ followed by the center node followed by the branch initially containing $t_f$. \begin{claim} \label{claim:ordering} If $t$ is unhappy, then $t$ and $t_f$ are on path $Q_t$, and appear in the order $t,t_f$. \end{claim} \begin{proof} By Property (P2), since $t$ is unhappy, so far $t$ and $t_f$ have only moved in the direction they want to go, which is along $Q_t$. Thus, $t$, and $t_f$ are both on $Q_t$. Note that $t$ initially appears before $t_f$ on $Q_t$. We will show that $t$ and $t_f$ have not switched order. Since $t$ and $t_f$ have never left $Q_t$, the only way for them to have switched order is for them to have swapped or for them to have arrived at the same node. It is not possible for $t$ and $t_f$ to swap because every swap either involves two tokens or two destinations. If they arrive at the same node then $t$ becomes happy and, by Property (P1), stays happy, contradicting our assumption that $t$ is unhappy. \end{proof} \begin{claim} \label{claim:pair-ordering} Suppose tokens $t$ and $s$ have the same initial branch, with $t$ further from the center. If $t$ and $s$ are unhappy, then their order along the path $Q_t=Q_s$ is $t, s, s_f, t_f$. \end{claim} \begin{proof} Initially, the tokens appear in the order $t,s,s_f,t_f$ along the path. By Claim~\ref{claim:ordering}, $s$ and $s_f$ maintain that order while $s$ is unhappy. Thus, the only way the ordering could change is if $t$ and $s$ change order, or $s_f$ and $t_f$ change order. Consider $t$ and $s$. They cannot lie at the same node, so the only way they can change order is by swapping, but this involves $s$ moving away from $s_f$. Similarly, if $s_f$ and $t_f$ change order then $s_f$ moves away from $s$. Thus the four tokens remain in their initial order. \end{proof} In order to prove Lemma~\ref{lemma:happy-swap-bound} (that there are at most $bk$ happy swaps), we will prove that during every happy swap, one of the tokens involved becomes happy. Since there are $bk$ unhappy tokens in the initial configuration, the result follows. Thus it remains to prove: \begin{lemma} \label{lemma:every-swap-happy} Suppose there is a happy swap of tokens $t$ and $s$, with $s$ closer to (or at) the center. Then the swap causes $s$ to become happy. \end{lemma} \begin{proof} Suppose $t$ and $s$ are at nodes $u$ and $v$, respectively and that $u$ is part of branch $B$. Node $v$ is either part of branch $B$ or the center node. Suppose the destination token at $u$ is $r_f$. Note that $r \ne t$ since $t$ is not happy. We aim to prove that $r=s$ which implies that $s$ and $s_f$ are at the same node after the swap. If $r_f$ wants to move away from the center, then $r$ must lie in branch $B$, further from the center. Then tokens $r$ and $t$ both had their initial positions in $B$. Along the path $Q_r=Q_t$ we find $r$, then $t,r_f$ at the same node, then $t_f$, a contradiction to Claim~\ref{claim:pair-ordering}. Thus $r_f$ wants to move towards the center. Suppose $r \ne s$. Because $s$ and $r$ both have their destinations in this branch, they had a common initial branch. Along the path $Q_r=Q_s$, the ordering is $r,s,r_f,s_f$, a contradiction to Claim~\ref{claim:pair-ordering}. Therefore $r=s$. \end{proof} This completes the proof of Theorem~\ref{thm:Vaughan-bound}. \end{proof} } \section{Sequential token swapping on trees is NP-complete} \label{sec:NP-hard-unweighted} Recall that the token swapping problem is a decision problem: given a tree with initial and target positions of the tokens, and given a number $K$, can the tokens be moved from their initial to their target positions with at most $K$ swaps. Membership in NP is easy to show: any problem instance can always be solved with a quadratic number of swaps by repeatedly choosing a leaf and swapping its target token to it. Thus, a certificate can simply be the list of swaps to execute. % \ifabstract Here we give an overview of the construction for the unweighted case; however, most of the proof is left to the Appendix. \fi \subsection{Overview} We reduce from Star STS and follow the same reduction plan as for the weighted case, building a tree with an ordering gadget and $m$ slot gadgets, each with a nook for an item token. However, there are several challenges. First of all, the swaps with item tokens are no longer free, so we need to take the number of them into account. Secondly, we cannot know the number of item token swaps precisely since it will depend on the number of swaps (between $0$ and $n$) required by the original Star STS instance. Our plan is to make this ``slack'' $n$ very small compared to the total number of swaps needed for the constructed token swapping instance. To do this, we will make the total number of swaps very big by replacing each of the non-item tokens $x_j$ and $y_j$ by a long path of non-item tokens called a ``segment.'' This raises further difficulties, because nothing forces the tokens in one segment to stay together, which means that they can sneak around and occupy nooks, freeing item tokens to swap amongst themselves in unanticipated ways. To remedy this we add further ``padding segments'' to the construction. The construction details are given in Section~\ref{sec:construction}. Proving that our unweighted construction is correct is much more involved than in the weighted case. There are two parts to the proof: \begin{description} \item[Part 1:] \customlabel{1}{part:1} {\bf YES instance of Star STS $\to$ YES instance of token swapping.} In Section~\ref{sec:ForwardDirection} we show that if there is a solution to an instance of Star STS then the constructed token swapping instance can be solved with at most $K$ swaps (where $K$ will be specified in the construction). This solution uses exactly $H = K-n$ swaps to get the non-item tokens to their target positions, and uses between $0$ and $n$ additional swaps to get the item tokens to their target positions. It is important to note that $H$ counts swaps of both item and non-item tokens and is more than just the cost of moving each non-item token along its shortest path. \item[Part 2:] \customlabel{2}{part:2} {\bf YES instance of token swapping $\to$ YES instance of Star STS.} In Section~\ref{sec:BackwardDirection} we show that if the constructed token swapping instance can be solved with at most $K$ swaps then the original Star STS instance has a solution. We show that $H$ swaps are needed to get the non-item tokens to their destinations. We then show that with only $n$ remaining swaps, the motion of item tokens is so constrained that they must behave ``as intended'' and therefore correspond to swaps in the original Star STS instance. \end{description} \subsection{Construction of token swapping instance} \label{sec:construction} Suppose we have an instance of Star STS where the star has center 0 and leaves $1, \ldots, m$ and each vertex has a token of its same label. We have a permutation $\pi$ of the tokens with $\pi(0) = 0$ (recall that this version is still hard by Lemma~\ref{lemma:StarSTS}), and a sequence $s_1, \ldots, s_{n}$ with $s_j \in \{1, \ldots, m\}$ that specifies the allowed swaps. As in the weighted case in Section~\ref{sec:NP-hard-weighted}, we will refer to the tokens of the Star STS instance as \defn{items} and the leaves as \defn{slots}. We assume without loss of generality that every slot appears in the sequence (otherwise remove that slot from the problem) and that no slot appears twice in a row in the sequence. Construct a tree as in the weighted case except that each individual $x_j$ and $y_j$ is replaced by a sequence of $k$ vertices (and tokens) with $k=(mn)^c$ for a large constant $c$, to be set later. Each such sequence of length $k$ is called a \defn{big segment}. Refer to Figure~\ref{fig:plan-segments} where the tree is drawn with the root in the middle, the ordering gadget to the left and the slot gadgets to the right. We will refer to left and right as in the figure. The target ordering of tokens within a big segment behaves as though the segment just slides along the shortest path to its target, i.e., the left to right order of tokens in a segment is the same in the initial and the final configurations. % \begin{figure}[htbp] \centering \includegraphics[width=\textwidth]{Figures/plan-segments-horizontal-2.pdf} \caption{(a) An instance of Star STS with $m=4$ slots and a sequence of length $n=5$. (b) The corresponding instance of token swapping with the initial token positions. The root has item token $0$ (coloured red). The ordering gadget lies to the left of the root. There are 4 slot gadgets to the right of the root. A long oval indicates a big segment of length $k$, and a short oval indicates a padding segment of length $k' = k/n^8$. Each nook vertex (coloured red) is attached to the $k^{\rm th}$ vertex from the root along the slot gadget path. Item tokens are coloured red; non-slot tokens are in the segment ovals coloured gray; and slot tokens are in the segment ovals coloured white. (c) The target token positions. In the first round of the ``intended'' solution, big segments $y_1$ and $x_1$ first change places. As $y_1$ moves left, item token $0$ moves to nook parent 1 where it may swap with item token 1. As $x_1$ moves right, the item token moves back to the root. Then segment $y_1$ moves to the far left of the ordering gadget and $x_1$ moves to the far right of the first slot gadget. Next, padding segments $p_{3,1}$ and $q_{3,1}$ change places across the root and move to their target locations; then $p_{2,1}$ and $q_{2,1}$; then $p_{4,1}$ and $q_{4,1}$; and finally $p_{1,1}$ and $q_{1,1}$. Note the ordering $q_{3,1},q_{2,1},q_{4,1},q_{1,1}$ of padding segments that lie to the right of $y_1$ in the final configuration---$q_{1,1}$ is last because $s_1=1$ and $q_{3,1}$ is first because $s_2=3$. } \label{fig:plan-segments} \end{figure} The nook vertex in each slot gadget is attached to the vertex at distance $k$ from the root in the slot gadget, and this vertex is called the \defn{nook parent}. The edge between the nook vertex and the nook parent is called the \defn{nook edge}. Refer to Figure~\ref{fig:plan-segments}. In the ``intended'' solution, the big segments leave the slot gadgets and enter the ordering gadget in the order $y_1, \ldots, y_n$. Although we will not give details, it turns out that the construction so far allows ``cheating'' via interference between slot gadgets. To prevent this, we add a total of % $2nm$ \defn{padding segments} each of length $k' = k/n^8$. The intuition is that in the ``intended'' solution, after $y_j$ enters the ordering gadget, one padding segment from each slot gadget will enter the ordering gadget, and then $y_{j+1}$ will do so. We now give the details of the padding segments in the initial/final configurations of the slot/ordering gadgets. In the initial configuration there are $nm$ padding segments $q_{i,j}, i= 1, \ldots, m, j=1, \ldots, n$ in the slot gadgets, and $nm$ padding segments $p_{i,j}, i= 1, \ldots, m, j=1, \ldots, n$ in the ordering gadget. In the final configuration, the $q_{i,j}$'s are in the ordering gadget and the $p_{i,j}$'s are in the slot gadgets. In the initial configuration, slot gadget $i$, $i=1, \ldots, m$ contains $n$ padding segments $q_{i,j}, j=1, \ldots, n$. They appear in order from left to right, with big segments mixed among them. Specifically, if $y_{j'}$ is a big segment in slot gadget $i$ then $y_{j'}$ appears just before $q_{i,j'}$. In the final configuration of the ordering gadget there are $m$ padding segments after each of the $n$ big segments. The padding segments after $y_j$ are $q_{i,j}, i=1, \ldots, m$. They appear in a particular left to right order: $q_{s_j,j}$ is last, $q_{s_{j+1},j}$ is first, and the others appear in order of index $i$. Within one padding segment, the left to right ordering of tokens is the same in the initial and final configurations. The initial configuration of the ordering gadget is obtained from the final configuration by: reversing (from left to right) the pattern of big segments and padding segments; changing $y$'s to $x$'s, and changing $q$'s to $p$'s. Similarly, the final configuration of slot gadget $i$ is obtained from the initial configuration of slot gadget $i$ in the same way. Let $A$ be the set of non-item tokens, and for any token $t$, let $d_t$ be the distance between $t$'s initial and target positions. To complete the reduction, we will set $H$ to be $\frac{1}{2}\sum_{t \in A} (d_t + 1)$ and set the bound $K$ to be $H + n$. The decision question is whether this token swapping instance can be solved with at most $K$ swaps. The reduction takes polynomial time. \ifabstract The remainder of the proof can be found in Appendix~\ref{App:Sequential}.\fi \later{ \ifabstract \section{Proof of NP-completeness of Sequential Token Swapping.}\label{App:Sequential} \fi In future sections we use the following definitions and notation. \begin{definition} \label{defn:move} \label{defn:partner} \label{defn:basic} \ \begin{itemize} \item $T$ is the set of tokens. $T = A \cup I$. $I$ is the set of $m+1$ \defn{item tokens} whose initial and target positions are the nook vertices and the root. Item token 0 has initial and target position at the root. $A$ is the set of \defn{non-item tokens} and consists of $nk + nmk'$ \defn{slot tokens} whose initial positions are in the slot gadget, and equally many \defn{non-slot tokens} whose initial positions are in the ordering gadget. % \item For a token $t \in A$, $d_t$ is the distance between its initial and target positions. \item $H = \frac{1}{2}\sum_{t \in A} (d_t + 1)$. $K = H+n$. \item Big segments $x_j$ and $y_j$ are \defn{partners}. Padding segments $p_{i,j}$ and $q_{i,j}$ are \defn{partners}. \item Every swap consists of two \defn{moves}, where a \defn{move} means one token moving across one edge. A \defn{left} move goes left in Figure~\ref{fig:plan-segments}, i.e., towards the root in a slot gadget or away from the root in the ordering gadget. A \defn{right} move does the opposite. \end{itemize} \end{definition} \subsection{Part \ref{part:1}: YES instance of Star STS \texorpdfstring{$\to$}{-->} YES instance of token swapping} \label{sec:ForwardDirection} In this section we prove that if we start with a YES instance of Star STS then the constructed token swapping instance has a solution with at most $K=n+H$ swaps. We first show how a solution to the Star STS instance gives an ``intended'' solution to the constructed token swapping instance. We follow the same idea as in the proof for the weighted case (Theorem~\ref{thm:weighted-NP-hard}). \medskip\noindent {\bf The ``intended'' solution.} For $j=1, \ldots, n$, implement $s_j$ as follows: \begin{itemize} \item Move the item token $t$ currently at the root % along the path of slot gadget $s_j$ to the nook parent. Item token $t$ now has the opportunity to swap with the item token in the adjacent nook. Perform this swap if and only if swap $s_j$ was performed in the solution to the Star STS instance. Let $t'$ be the resulting token at the nook parent. Move big segment $y_j$ to its target position in the ordering gadget. Move big segment $x_j$ to its target position in the slot gadget $s_j$. This moves token $t'$ to the root. \item Next, for each slot gadget $i$, move the padding segment nearest the root out the slot gadget to its target position in the ordering gadget and move its partner padding segment out of the ordering gadget to its target position in slot gadget $i$. These pairs of segment moves must be done in the order in which the padding segments $q_{i,j}$ appear in the final configuration (left to right). Note that item token $t'$ returns to the root after each of the $m$ pairs of segment moves. \end{itemize} It is straightforward to show that this solution is correct, i.e., that at the beginning of round $j$, big segment $y_j$ is next to the root at the left end of slot gadget $s_j$ and big segment $x_j$ is next to the root at the right end of the ordering gadget, and similarly, that after the movements of these big segments, the successive pairs of padding segments are in position next to the root when we are ready to move them. At the heart of the intended solution is a subsequence of moves that are used to correctly re-position the non-item tokens while leaving the item tokens fixed. We formalize this ``scaffold solution'' for use in future sections. \medskip\noindent {\bf The ``scaffold'' solution.} This is the same as the intended solution except that no swaps are performed between item tokens. Thus, item tokens $1, 2, \ldots, m$ remain in their initial nook vertices, and item token $0$ returns to the root after each round (each loop on $j$). \medskip\noindent {\bf Properties of the intended/scaffold solution.} \begin{description} \item{(P1)} Every non-item token travels on the path from its initial position to its target position and makes $d_t$ moves. \item{(P2)} There is no swap between two slot tokens nor between two non-slot tokens. \item{(P3)} The pairs of non-item tokens that swap with each other can be characterized with respect to the initial configuration as follows. Let $t$ be a slot token that lies in big/padding segment $g$, and suppose that the partner of $g$ is the big/padding segment $g'$. Let $\pi_1$ be the ordered list of segments between the root and $g$ (not including $g$). Let $\pi'_1$ be the partners of the segments of $\pi_1$. Let $\pi_2$ be the ordered list of segments from $g'$ (including $g'$) to the right end of the ordering gadget. Then the non-slot tokens that $t$ swaps with are the tokens that lie in the segments $\pi'_1, \pi_2$. See Figure~\ref{fig:intended-swaps}. In particular, note that the number of tokens from $\pi'_1$ is less than the distance from $t$ to the root. \item{(P4)} In the scaffold solution, token $0$ swaps with every non-item token. \item{(P5)} The order in which the slot tokens reach the root is precisely the left-to-right order of their final positions in the ordering gadget. Similarly, the order in which the non-slot tokens reach the root is precisely the right-to-left order of their initial positions in the ordering gadget. \item{(P6)} The final positions of the slot tokens in the ordering gadget are such that between any big segment and any other segment from the same slot gadget, there is a segment from each of the other slot gadgets. Combining this with (P5) implies the following property. Consider a time interval during which at least one token from a big segment from a slot gadget $i$ and at least one token from any other segment from slot gadget $i$ reach the root. During this time interval, every token in at least one segment from each of the other slot gadgets reaches the root. \end{description} \begin{figure}[htbp] \centering \includegraphics[width=.4\textwidth]{Figures/intended-swaps-horizontal-2.pdf} \caption{In the intended/scaffold solution, slot token $t$ from segment $g$ swaps with the non-slot tokens with initial positions in $\pi'_1, \pi_2$. Here $\pi'_1$ (coloured red) consists of the segments that are the partners of segments in $\pi_1$. } \label{fig:intended-swaps} \end{figure} \medskip\noindent {\bf Bounding the number of token swaps for a YES instance of Star STS.} \begin{lemma} \label{lem:forward} Given a YES instance of Star STS, the total number of swaps in the corresponding token swapping instance is at most $K$. \end{lemma} \begin{proof} Recall that $H = \frac{1}{2}\sum_{t \in A} (d_t + 1)$ and $K = H + n$. We show that the number of swaps used by the intended solution is at most $K$. First consider the scaffold solution. The number of moves made by a non-item token $t$ in the scaffold solution is $d_t$ by (P1). In addition, item token 0 swaps once with each non-item token by (P4), for a total of $|A|$ moves by item tokens. There are no other moves. Thus the total number of moves in the scaffold solution is $\sum_{t \in A} (d_t +1)$, and the number of swaps is half that, i.e., $H$. The intended solution has additional swaps between pairs of item tokens---these are the swaps that occur on the nook edges. They correspond exactly to the swaps $s_j$ that are chosen for the Star STS solution, thus, % at most $n$. In sum the total number of swaps is at most $H + n = K$. \end{proof} \subsection{Part \ref{part:2}: YES instance of token swapping \texorpdfstring{$\to$}{-->} YES instance of Star STS} \label{sec:BackwardDirection} In the previous section we showed that if we have a YES instance of Star STS then the corresponding token swapping instance can be solved in at most $K$ swaps. The goal of this section is to prove the reverse claim: % \begin{lemma} \label{lem:backward} Consider an instance of Star STS whose corresponding token swapping instance has a solution using at most $K$ swaps. Then the Star STS instance is a YES instance. \end{lemma} Note that Lemmas~\ref{lem:forward} and \ref{lem:backward} combined show correctness of our reduction, which finishes the NP-completeness proof. Throughout the section we assume that in the solution to the token swapping instance no pair of tokens swaps more than once, which we justify as follows: \begin{claim} \label{lem:unique} If a pair of tokens swaps more than once in a token swapping solution, then there is a shorter solution. \end{claim} \begin{proof} Suppose tokens $x$ and $y$ swap more than once in a sequence of swaps. Eliminate the last two swaps of $x$ and $y$ and exchange the names $x$ and $y$ in the subsequence between the two removed swaps. The resulting shorter sequence yields the same final token configuration. \end{proof} Our argument will be based on the number of moves rather than the number of swaps. Recall from Definition~\ref{defn:move} that every swap consists of two moves. By assumption we have a solution that uses at most $K$ swaps, which is at most $2K$ moves and $2K = 2H + 2n = 2(\frac{1}{2}\sum_{t \in A} (d_t + 1)) + 2n = \sum_{t \in A} d_t + |A| + 2n$. Clearly, we need at least $d_t$ moves to get each non-item token $t \in A$ to its target location. In the first part of the argument (in Subsection~\ref{sec:Back moves for any instance}) we identify $|A|$ additional moves (of item or non-item tokens) that are dedicated to the task of getting non-item tokens to their target locations. This leaves at most $2n$ moves unaccounted for. In the second part of the argument (in Subsection~\ref{sec:Back moves for NO instance}), we show that with so few remaining moves, the movement of item tokens is very constrained and corresponds to a solution to the original Star STS instance. Before starting the rather technical subsections, we give more detail on these two high level aspects: how we classify and account for moves; and how we convert the constrained movement of item tokens into a solution to the original Star STS instance. % \paragraph*{Accounting for moves.} Rather than arguing about all the moves, we will argue about special moves called ``contrary moves.'' For slot and non-slot tokens, the ``contrary moves'' go contrary to the direction the token should go, i.e., for a slot token---which should go left---a contrary move is a right move, and vice versa for non-slot tokens. We formalize this and extend the definition to item tokens as follows. \begin{definition} \label{defn:contrary-move} \label{defn:main-path} A \defn{contrary} move of a slot token is a right move. See Figure~\ref{fig:moves}. A \defn{contrary} move of a non-slot token is a left move. A \defn{contrary} move of an item token is right move (this is somewhat arbitrary). Let $c_t$ be the number of contrary moves made by token $t$. The \defn{main path} of a slot token $t$ is the path in the tree between the rightmost vertex of $t$'s slot gadget and the leftmost vertex of the ordering gadget. \end{definition} The concept of a main path will be used later in the proof. Observe that every slot token $t$ must make $d_t$ left moves along its main path. \begin{figure}[htb] \centering \includegraphics[width=.55\textwidth]{Figures/moves-contrary-horizontal.pdf} \caption{Classifying the moves as a slot token moves from its initial position $u$ to its target position $v$. \defn{Contrary} (right) moves are coloured red. Left moves are coloured black, with the solid portions occurring on the \defn{main path} (coloured purple). } \label{fig:moves} \end{figure} \begin{claim} \label{claim:contrary-moves} The total number of moves in the solution is $\sum_{t \in A} d_t + 2 \sum_{t \in T} c_t$. \end{claim} \begin{proof} Note that the first sum is over non-item tokens and the second sum is over all tokens. Every slot token $t$ must make $d_t$ left moves, one on each edge of the path from its initial to final position. The other moves made by token $t$ come in pairs, where each pair consists of a left move and a right (contrary) move on some edge $e$. Thus the total number of moves made by a slot token $t$ is $d_t + 2c_t$. For a non-slot token $t$ the same argument (with directions reversed) shows that the total number of moves is $d_t + 2c_t$. For item tokens, observe that the set of nodes of the tree that contain item tokens is the same in the initial and the target configurations. This implies that, if an item token makes a contrary (right) move on an edge $e$, then some (possibly other) item token must move left on $e$. Thus the total number of moves made by item tokens is $2\sum_{t \in I} c_t$. Putting these together, the total number of moves in the solution is $\sum_{t \in A} d_t + 2 \sum_{t \in T} c_t$. \end{proof} We obtain a bound on the number of contrary moves: \begin{lemma} \label{lemma:contrary-move-bound} A token swapping solution with at most $K$ swaps has at most $ |A|/2 + n$ contrary moves. \end{lemma} \begin{proof} An upper bound of $K$ swaps is an upper bound of $\sum_{t \in A} d_t + |A| + 2n$ moves. By Claim~\ref{claim:contrary-moves}, the number of moves is $\sum_{t \in A} d_t + 2 \sum_{t \in T} c_t$. Thus $\sum_{t \in T} c_t \le |A|/2 + n$. \end{proof} In Subsection~\ref{sec:Back moves for any instance} we will identify in the solution a set $\cal M$ of $|A|/2$ contrary moves that are associated with getting slot tokens to their target locations, one contrary move per slot token. This leaves at most $n$ contrary moves outside of $\cal M$. In Subsection~\ref{sec:interface} we make a careful catalogue of which contrary moves are included in $\cal M$, thus providing an interface to the final Subsection~\ref{sec:Back moves for NO instance}. In that final subsection we argue that if the big segments and padding segments are long enough (i.e., for sufficiently large $k$), and given the bound of at most $n$ contrary moves outside $\cal M$, the movement of the tokens is constrained to be ``close'' to the intended solution. We do this by proving various properties. For example, to give the flavour of these arguments, we prove that to get two item tokens into the ordering gadget at the same time takes more than $n$ contrary moves outside $\cal M$. A major challenge in proving all these properties is showing that the $>n$ contrary moves we count are indeed disjoint from $\cal M$. Finally, the properties allow us to convert the movement of item tokens into a solution to the original Star STS instance as we describe next. \paragraph*{Converting a token swapping solution to a star STS solution.} Recall that at any point in time during the intended solution, there is an item token in each nook plus one ``free'' item token (initially the one at the root) that moves around. The free item token moves to a nook parent and may swap with the item token $t'$ in the nook, in which case $t'$ becomes the new free item token. We cannot hope for such structure in our solution since many item tokens can be outside the nooks. However, we can still identify one ``free'' item token and one item token per slot gadget. \begin{definition} At any point in time during the swap sequence the \defn{free} item token is the item token that most recently was at the root. \end{definition} In the initial and target configurations, item token $0$ is the free item token. We will prove that apart from the free item token, there is always exactly one item token in each slot gadget. How can the free item token change? An item token from a slot gadget, say slot gadget $i$, must reach the root to become the new free item token. Because of the property just stated (that, apart from the free item token, there is always exactly one item token in each slot gadget), at this point in time, the old free item token must be in slot gadget $i$ (it may have entered the slot gadget at the most recent swap or at some previous time). \begin{definition} The \defn{exchange} sequence $\chi$ is constructed from the changes in the free item token as follows: initialize $\chi$ to the empty string; when the item token that was just in slot gadget $i$ becomes the free item token, append $i$ to $\chi$. \end{definition} At the end of Subsection~\ref{sec:Back moves for NO instance} we will prove the following statement. \begin{lemma} \label{lem:free-item-token} If $k$, the length of a big segment, is sufficiently large, then the free item token and the exchange sequence $\chi$ satisfy the following properties. \begin{enumerate} \item At any point in time, apart from the free item token, there is exactly one item token in each slot gadget. \item $\chi$ is a subsequence of the sequence of swaps given as input to the Star STS instance. \end{enumerate} \end{lemma} With this lemma in hand, we can prove the main result of this section: \begin{proof}[Proof of Lemma~\ref{lem:backward}] We get a direct correspondence between the token swapping solution and a solution to the Star STS instance: the free item token corresponds to the item at the root in the Star STS instance; the token in slot gadget $i$ corresponds to the token at slot $i$ in the Star STS instance; and an exchange $i$ in $\chi$ corresponds to a swap between the token at the root and the token at slot $i$. By Lemma~\ref{lem:free-item-token}, the exchange sequence $\chi$ corresponds to a subsequence of the allowed swap sequence. Thus the solution to the token swapping instance provides a solution to the Star STS instance. \end{proof} \subsubsection{Contrary moves to get non-item tokens to their destinations} \label{sec:Back moves for any instance} In this section we will show that a solution to the constructed token swapping instance must contain $|A|/2$ contrary moves dedicated to the task of getting the non-item tokens to their target destinations. We do this by building a set $\mathcal M$ that contains one distinct contrary move per slot token. Since there are $|A|/2$ slot tokens, $\mathcal M$ will have $|A|/2$ contrary moves. For intuition about why contrary moves are necessary, observe that in the intended/scaffold solution every slot token swaps with an item token as it travels leftward from its initial position to its final position, and this swap is a right (contrary) move for the item token. Of course, a general solution need not have this property. However, note that in the initial configuration item token 0 lies in the path between the initial and final positions of any slot token $t$. The informal idea is that if item token 0 swaps off this path, then some other ``intruder'' token $r$ takes its place, and we will show that $r$ must make a contrary move. We now make this intuition formal. Recall from Definition~\ref{defn:main-path} that for a slot token $t$ with initial position in slot gadget $i$ its main path is the path in the tree between the rightmost vertex of $t$'s slot gadget and the leftmost vertex of the ordering gadget. \begin{definition} An \defn{imposter} for a slot token $t$ is a token $r$ such that: (1) $t$ makes a left move on its main path while swapping with $r$; and (2) $r$ is either an item token or a token that $t$ does not swap with in the scaffold solution. \end{definition} \begin{claim} \label{claim:imposter} Every slot token $t$ has at least one imposter. \end{claim} \begin{proof} Token $t$ must make at least $d_t$ left moves along its main path. (Recall that $d_t$ is the distance from $t$'s initial position to its target position.) The number of non-item tokens that $t$ swaps with in the scaffold solution is exactly one less than $d_t$. Furthermore, by Lemma~\ref{lem:unique} $t$ does not swap with the same token more than once. Thus one of $t$'s left moves on its main path must be a swap with an imposter. \end{proof} \paragraph*{Choosing contrary moves.} Consider a solution to the token swapping instance. (In fact, we will only use the property that the sequence of swaps gets every non-item token to its destination.) We will give a procedure that iterates through the slot tokens $t$, and chooses one of $t$'s imposters, $r$, together with a unique contrary move of $r$. The contrary move of $r$ will not always occur when $r$ swaps with $t$. Our procedure will add the chosen contrary move to a set $\mathcal{M}$ (initially empty). Since there are $|A|/2$ slot tokens and we choose a unique contrary move for each one, the final size of $\mathcal{M}$ will be $|A|/2$. For each slot token $t$ consider the left moves of $t$ along its main path. Check the following cases in order. \noindent {\bf Case 1.} If $t$ swaps with an item token, choose one such item token $r$. Then $r$ is an imposter for $t$. Since $t$ moves left, $r$ moves right which is a contrary move for $r$. Add this contrary move of $r$ to $\mathcal{M}$. \noindent {\bf Case 2.} If $t$ swaps with another slot token, choose one such slot token $r$. Then $r$ is an imposter for $t$ since no two slot tokens swap in the scaffold solution by (P2). Since $t$ moves left, $r$ moves right which is a contrary move for $r$. Add this contrary move of $r$ to $\mathcal{M}$. We may now suppose that $t$ only swaps with non-slot tokens as it makes left moves on its main path. By Claim~\ref{claim:imposter}, $t$ swaps with at least one imposter. We next check \emph{where} this happens. Suppose that $t$'s initial position is in slot gadget $i$. \noindent {\bf Case 3.} If $t$ swaps with an imposter in slot gadget $i$, choose one such imposter $r$. Suppose the swap happens on edge $e$. Then $r$ moves right. In the scaffold solution $t$ swaps with every non-slot token whose target destination is in slot $i$. Thus $r$'s target destination is outside slot gadget $i$ and $r$ must move left on $e$ at some later time. As the contrary move, choose the earliest left move of $r$ on edge $e$ after the $r$-$t$ swap, and add this contrary move to $\mathcal{M}$. We may now suppose that $t$ swaps with imposters only in the ordering gadget, and all these imposters are non-slot tokens. \noindent {\bf Case 4.} If $t$ swaps with an imposter $r$ that was at the root at some time before the $r$-$t$ swap, choose one such $r$. Suppose the $r$-$t$ swap occurs on edge $e$. Then $r$ moves right on $e$, and must have moved left on $e$ between the time it was at the root and the time it swapped with $t$. As the contrary move, choose the most recent left move of $r$ on edge $e$ before the $r$-$t$ swap, and add this contrary move to $\mathcal{M}$. We are left with the set of tokens $t$ that only have imposters of the following special form. \begin{definition} A non-slot token $r$ is a \defn{non-leaving imposter} for slot token $t$ if: $t$ makes a left move in the ordering gadget while swapping with $r$; (2) $r$ does not swap with $t$ in the scaffold solution; and (3) $r$ has remained inside the ordering gadget up until the $r$-$t$ swap. \end{definition} Let $S$ be the set of slot tokens $t$ such that every imposter for $t$ is a non-leaving imposter. Note that by Claim~\ref{claim:imposter}, every $t \in S$ has a non-leaving imposter. In order to complete the procedure to build $\cal M$, we must choose a non-leaving imposter and a contrary move for each token in $S$. In later sections we will need to limit the number of non-slot tokens that are chosen as non-leaving imposters so we will choose the non-leaving imposters for tokens in $S$ according to Lemma~\ref{lem:FewImposters} below. This has no effect on the rest of the current argument, so for now, just assume that we have some assignment of non-leaving imposters to the tokens in $S$. Let $S(r) \subseteq S$ be the tokens of $S$ that are assigned to imposter $r$. Let $S_i(r) \subseteq S(r)$ be the tokens of $S(r)$ whose initial positions are in slot gadget $i$. Note that the sets $S_i(r)$ partition $S$. Let $D_i$ be the non-slot tokens whose final positions are in slot gadget $i$. \begin{lemma} \label{lemma:enough-contrary-moves} Token $r$ makes at least $|S_i(r)|$ contrary moves while swapping with tokens of $D_i$. \end{lemma} With this lemma in hand, we can complete the construction of $\mathcal M$. \noindent {\bf Case 5.} Token $t$ lies in $S$, which we have partitioned into the sets $S_i(r)$. For each $i$ and $r$ such that $S_i(r)$ is non-empty, choose $|S_i(r)|$ contrary moves of $r$ where $r$ swaps with tokens of $D_i$ and add them to $\mathcal M$. Note that this adds a total of $|S|$ contrary moves to $\mathcal M$ because the contrary moves of $r$ for different $i$'s are disjoint since the sets $D_i$ are disjoint. \begin{proof}[Proof of Lemma~\ref{lemma:enough-contrary-moves}] Consider the initial configuration of tokens. Let $t_1, \ldots, t_f$ be the tokens of $S_i(r)$ ordered by their (initial) positions in slot gadget $i$ with $t_1$ closest to the root. Then $|S_i(r)| = f$ so we need to show that $r$ makes $f$ contrary moves while swapping with tokens of $D_i$. Let $g$ be the big/padding segment containing $t_1$, and let $g'$ be the partner of $g$. Let $h_1$ and $h_f$ be the distances from the root to $t_1$ and $t_f$, respectively. Since $r$ is an imposter for $t_1$, there was no swap between $r$ and $t_1$ in the scaffold solution. But in the scaffold solution, by property (P3), $t_1$ swaps with every token to the left of (and including) $g'$. Therefore $r$ must lie to the right of $g'$. Also, by property (P3), fewer than $h_1$ tokens of $D_i$ lie to the right of $g'$. Thus, fewer than $h_1$ tokens of $D_i$ lie to the right of $r$. Let $Z$ be the set of non-slot tokens that swap with $t_f$ during left moves of $t_f$ on its main path in slot gadget $i$. By Lemma~\ref{lem:unique}, $t_f$ does not swap with the same token twice, so $|Z| \ge h_f$. No token of $Z$ is an imposter for $t_f$ because $t_f$ only has non-leaving imposters. Thus $Z$ consists of non-slot tokens whose destinations are in slot gadget $i$, i.e., $Z \subseteq D_i$. Also note that $r \notin Z$ since $r$ stays in the ordering gadget until it swaps with $t_f$. Let $Z'$ be the tokens of $Z$ that lie to the left of $r$ in the initial configuration. Since there are less than $h_1$ tokens of $D_i$ to the right of $r$, we have $|Z'| > h_f - h_1 \ge f-1$. Thus $|Z'| \ge f$. Finally, we claim that all the tokens of $Z'$ swap with $r$, and do so during contrary (left) moves of $r$. This is because $r$ remains inside the ordering gadget until it swaps with $t_f$, but all the tokens of $Z'$ must exit the ordering gadget so they can swap with $t_f$ on its journey to the root. Thus $r$ makes at least $f$ contrary moves while swapping with tokens of $D_i$, as required. \end{proof} \paragraph*{Uniqueness of contrary moves.} We claim that the set $\mathcal M$ constructed above contains $|A|/2$ distinct contrary moves. First note that we added a contrary move to $\mathcal M$ for each slot token, and there are $|A|/2$ slot tokens. It remains to show that we never added the same contrary move to $\mathcal M$ multiple times. Consider a contrary move in $\mathcal{M}$ of a token $r$. We can uniquely identify when it was added to $\mathcal{M}$ as follows. \begin{itemize} \item If $r$ is an item token then the move was added to $\mathcal{M}$ in Case 1, and the associated slot token $t$ is the one that $r$ swaps with during this contrary move. \item If $r$ is a slot token then the move was added to $\mathcal{M}$ in Case 2, and $t$ is the token that $r$ swaps with. \item If $r$ is a non-slot token and its contrary (left) move is on an edge $e$ in a slot gadget, then the move was added to $\mathcal{M}$ in Case 3, and in $r$'s most recent right move on edge $e$ it swapped with token $t$. \item If $r$ is a non-slot token and its contrary (left) move is on an edge $e$ in the ordering gadget and $r$ visited the root before this contrary move, then the move was added to $\mathcal{M}$ in Case 4, and in $r$'s most recent right move on edge $e$ it swapped with token $t$. \item Finally, if $r$ is a non-slot token and its contrary (left) move is on an edge in the ordering gadget and $r$ did not visit the root before this contrary move, then the move was added to $\mathcal M$ in Case 5. As already noted, Case 5 added $|S|$ distinct contrary moves to $\mathcal M$ to pay for the tokens $t \in S$. \end{itemize} Thus, we have shown what we set out to show at the beginning of this section: a solution to our token swapping instance must have $|A|/2$ contrary moves dedicated to the task of getting the non-item tokens to their target destinations. However, to argue that the contrary moves that we will count in future sections are disjoint from those counted in this section, we need to be more precise about how imposters are chosen. \paragraph*{How to choose non-leaving imposters.} We will prove the following lemma, which limits the number of non-leaving imposters. % \begin{lemma}\label{lem:FewImposters} We can choose non-leaving imposters so that the total number of unique non-leaving imposters is less than or equal to % $n(m+1)$. \end{lemma} \begin{proof} Recall that $S$ is the set of slot tokens $t$ such that every imposter for $t$ is a non-leaving imposter. Tokens of $S$ are exactly the tokens for which we must choose a non-leaving imposter. We show how to choose non-leaving imposters so that if two tokens in $S$ were initially in the same segment (the same $y_j$ or $q_{i,j}$) then they are assigned the same imposter. This proves that the number of unique non-leaving imposters is less than or equal to the number of segments initially in the slot gadgets. There are $n$ big segments and $nm$ padding segments in the slot gadgets, so the bound is $n(m+1)$, as required. Let $G$ be the set of slot tokens from one segment. Observe that every token in $G$ swaps with the same set of tokens in the scaffold solution. Let $G'$ be $G \cap S$. Then every $g \in G'$ has a non-leaving imposter and does not have any other kind of imposter. We must show that all tokens in $G'$ can share the same non-leaving imposter. Consider the last time each token in $G'$ enters the ordering gadget, and let $t$ be the last token to do so. \begin{claim} $t$ swaps with an imposter after it enters the ordering gadget for the last time. \end{claim} \begin{proof} Let $d_t = h + h'$ where $h$ is the distance from $t$'s initial position to the root and $h'$ is the distance from the root to $t$'s target position. Then $t$ must make at least $h$ left moves before it reaches the root for the first time, and must make at least $h'$ left moves after it reaches the root for the last time. These moves all occur on $t$'s main path. As noted in the proof of Claim~\ref{claim:imposter}, the number of non-item tokens that $t$ swaps with in the scaffold solution is $d_t -1$. Since $t$ has already used up at least $h$ of them on its way to the root (where it met no imposters along the way), there are at most $h' -1$ of them left. Therefore $t$ must swap with an imposter during a left move after $t$ enters the ordering gadget for the last time. \end{proof} Let $r$ be an imposter that $t$ swaps with after it enters the ordering gadget for the last time. Note that $r$ must be a non-leaving imposter, since $t$ did not have any other kind of imposter. We claim that $r$ is also a non-leaving imposter for every token in $G'$. Since the tokens in $G'$ only have non-leaving imposters, it suffices to show that $r$ is an imposter for every token $g \in G'$. To do this, we prove that: (1) $g$ swaps with $r$ while $g$ makes a left move on an edge of the ordering gadget (note that the ordering gadget is part of every slot token's main path); and (2) $g$ does not swap with $r$ in the scaffold solution. By definition of $t$, when $t$ enters the ordering gadget for the last time, every other token in $G'$ is in the ordering gadget and will not leave again. After $t$ enters the ordering gadget it swaps with $r$, and after that, $r$ reaches the root for the first time. Thus, before $r$ reaches the root, it must swap with every token $g$ in $G'$ with $r$ moving right and $g$ moving left. This proves~(1). Since all tokens in $G$ swap with the same set of tokens in the scaffold solution, the fact that $r$ does not swap with $t$ in the scaffold solution means that $r$ does not swap with any token in $G'$ in the scaffold solution. This proves (2). \end{proof} \subsubsection{Interface between Sections~\ref{sec:Back moves for any instance} and~\ref{sec:Back moves for NO instance}: Characterization of contrary moves}\label{sec:interface} In this section we will characterize the contrary moves that we counted in Section~\ref{sec:Back moves for any instance}, so that we can argue that the contrary moves % we will count in forthcoming Section~\ref{sec:Back moves for NO instance} are disjoint from those already counted. We say that the \defn{initial gadget} of a non-item token $t$ is the gadget (either the ordering gadget or one of the slot gadgets) containing $t$'s initial position. Similarly, the \defn{final/destination gadget} of $t$ is the gadget containing $t$'s final position. Recall that $\mathcal{M}$ is the set of contrary moves counted in Section~\ref{sec:Back moves for any instance}. The following observation follows directly from the construction of $\mathcal{M}$. These correspond to {\bf Cases 1-5} in Section~\ref{sec:Back moves for any instance}. \begin{observation}\label{obs:purple} $\mathcal{M}$ can be written as $\mathcal{M}=M_1\cup M_2 \cup M_3 \cup M_4 \cup M_5$, where each $M_i$ is a set of contrary moves that are \emph{not} into or out of the nook, with the following properties: \begin{enumerate} \item $M_1$ is a set of contrary (right) moves of item tokens. \item $M_2$ is a set of contrary (right) moves of slot tokens with the following properties: \begin{itemize} \item Each contrary move in $M_2$ occurs in a slot gadget $i$ where the \emph{other} token in the swap is a slot token $t$ whose initial position is in slot gadget $i$. \item $M_2$ contains at most one such contrary move for each slot token $t$. \end{itemize} \label{purp2} \item $M_3$ is a set of contrary (left) moves of non-slot tokens with the following properties: \begin{itemize} \item Each contrary move in $M_3$ of a token $s$ occurs on an edge $e$ in a slot gadget $i$ that is not $s$'s destination gadget. \item In $s$'s most recent right move on edge $e$, $s$ swapped with a slot token $t$ whose initial gadget is slot gadget $i$. \item $M_3$ contains at most one such contrary move for each slot token $t$. \end{itemize} \label{purp3} \item $M_4$ is a set of contrary (left) moves of non-slot tokens with the following properties: \begin{itemize} \item Each contrary move in $M_4$ occurs in the ordering gadget. \item For each contrary move in $M_4$, the token $s$ that performs the contrary move was at the root at some point previously. \end{itemize} % \item $M_5$ is a set of contrary (left) moves of a set of at most $n(m+1)$ non-slot tokens, that occur in the ordering gadget. The bound of $n(m+1)$ follows from Lemma~\ref{lem:FewImposters}. \end{enumerate} \end{observation} The following result follows directly from Observation~\ref{obs:purple} and is an explicit description of various contrary moves that are \emph{not} in $\mathcal{M}$. We list these moves here for easy reference from Section~\ref{sec:Back moves for NO instance}. \begin{corollary}\label{obs:interface}$ $ \begin{enumerate} \item Any contrary (left) move of a non-slot token that is in its destination slot gadget is not in $\mathcal{M}$.\label{int1} \item Any contrary (right) move of a slot token $s$ swapping with a token $t$ that occurs in slot gadget $i$, such that $i$ is $s$'s initial gadget and $i$ is \emph{not} $t$'s initial gadget, is not in $\mathcal{M}$.\label{int6} \item Any contrary move of a non-item token into or out of the nook is not in $\mathcal{M}$.\label{int4} \item Any contrary move of a non-item token that is in a slot gadget that is not its final gadget, such that the other token in the swap is an item token, is not in $\mathcal{M}$.\label{int5} \item If a slot token $t$ has $\lambda$ many swaps in either $t$'s initial slot gadget or the ordering gadget, in which the other token in each of these swaps is a slot token doing a contrary (right) move, then at least $\lambda-1$ of these contrary moves are not in $\mathcal{M}$.\label{int2} \item If a non-slot token $t$ has $\lambda$ many swaps in the ordering gadget, in which the other token in each of these swaps is doing a contrary (left) move and is a non-slot token that has not yet reached the root, then at least $\lambda-n(m+1)$ of these contrary moves are not in $\mathcal{M}$.\label{int3} \end{enumerate} \end{corollary} \subsubsection{Moves to get item tokens to their destinations} \label{sec:Back moves for NO instance} Recall that we assume that the token swapping instance that was constructed from an instance of Star STS has a solution with at most $K$ swaps. By Lemma~\ref{lemma:contrary-move-bound}, the solution has at most $|A|/2 + n$ contrary moves. Previously, we found a set $\mathcal M$ of $|A|/2$ contrary moves in the solution that are required to get the non-item tokens to their destinations. This leaves at most $n$ contrary moves to complete the job of getting the item tokens to their destinations. In this section we will show that if the big/padding segments are very long, then the movement of tokens is constrained enough that we can prove the structural properties of Lemma~\ref{lem:free-item-token}. Recall from the construction that the length of a big segment is $k=(mn)^c$ for a large constant $c$. Set $c=25$. We will assume $n,m > 5$. % The following observation will be useful. \begin{observation}\label{obs:contrary} The total number of contrary moves in the token swapping solution is less than $k^{1+1/c} =kmn$, and the number of contrary moves not in $\mathcal{M}$ is less than $k^{1/c} = mn$. \end{observation} \begin{proof} By Lemma~\ref{lemma:contrary-move-bound} the number of contrary moves is at most $|A|/2 + n$. Plugging in $|A| = 2nk + 2nmk'$ and $k' = k/n^8$ this is $\le nk + nmk/n^8 + n < kmn = k^{1 + 1/c}$. The number of contrary moves not in $\mathcal M$ is at most $n$ and $n < mn = k^{1/c}$. In both cases, we used $n,m > 1$. \end{proof} This section has four subsections: \begin{enumerate} \item In Section~\ref{sec:Segment Ordering}, we show that tokens are constrained in the sense that the segments reach the root in roughly the same order as in the scaffold solution. \item In Section~\ref{sec:Ordering Lemma}, we show that the tokens are constrained in the sense that each individual token cannot get too far out-of-order with its surrounding tokens. \item In Section~\ref{sec:Item Tokens Stuck}, we use the above results to prove the key lemma that every slot gadget contains an item token ``near'' its nook at all times. \item In Section~\ref{sec:Item and Segment Swap} we combine the above results to complete the proof of Lemma~\ref{lem:free-item-token}. \end{enumerate} \paragraph{Correspondence with the scaffold solution}\label{sec:Segment Ordering}% In this section we will show that the movement of tokens in our solution is similar to that of the scaffold solution. The main lemma of this section is Lemma~\ref{lem:segbyseg}, which says that tokens reach the root in roughly the same order as in the scaffold solution. We start with a simple lemma that shows that not many tokens can enter and exit one gadget (as made precise below). We use ``gadget'' here to mean a slot gadget or the ordering gadget. Note that a token leaves the gadget it is in if and only if it reaches the root. We will find it convenient to use both expressions when we talk about the movement of tokens. Note that a token can leave any gadget, i.e., reach the root, many times throughout the sequence of swaps. \begin{lemma} \label{lem:swapNotOutsideOfGadget} Let $S$ be a set of tokens, all of which are either slot or non-slot tokens. Let $g$ be a gadget. Suppose that either of the following situations occur: \begin{enumerate} \item At some time $\tau$, all tokens of $S$ are in gadget $g$, but each token of $S$ was outside $g$ at some time before $\tau$ and at some time after $\tau$. \item At two time points $\tau_1$ and $\tau_2$, all tokens of $S$ are in gadget $g$, but each token of $S$ % reached the root at some time between $\tau_1$ and $\tau_2$. \end{enumerate} Then the tokens of $S$ make at least $\frac{1}{2}|S|^2$ contrary moves, and consequently, $|S| \le k^{1/2 + 1/c}$. \end{lemma} \begin{proof} Depending on whether % the tokens of $S$ are slot or non-slot tokens, either moving the tokens out of, or % into, the gadget $g$ will count as contrary moves. In either case the tokens of $S$ make at least $1+2+ \cdots + |S| > \frac{1}{2} |S|^2$ contrary moves. If $|S| > k^{1/2 + 1/c}$, then the number of contrary moves is $> \frac{1}{2}k^{1 + 2/c} > k^{1 + 1/c}$, which contradicts Observation~\ref{obs:contrary}. \end{proof} Recall that for any token $t$, its \defn{initial gadget} is the gadget that contains $t$'s initial position, and its \defn{final gadget} is the gadget that contains $t$'s final position. The next lemma says that if a large number of tokens have reached the root, then most of them have entered their final gadgets for the last time. \begin{lemma}\label{lem:indest} Let $S$ be a set of at least $\ell=k^{1/2+2/c}$ tokens that are either all slot tokens or all non-slot tokens. If, at some point in time, every token in $S$ has reached the root then every token in $S$ except for at most $\ell$ of them has entered its final gadget for the last time. \end{lemma} \begin{proof} We consider the situation at % the point in time stipulated in the lemma. Let $R$ be the tokens of $S$ that have entered their final gadgets for the last time. Our goal is to show that $|S \setminus R| \le \ell$. Observe that $S \setminus R$ is a disjoint union of two sets: $S'$, the tokens of $S$ that are not in their final gadgets, and $S''$, the tokens of $S$ that are in their final gadgets, but will subsequently leave (and then re-enter) those gadgets. Thus our goal is to show that $|S'| + |S''| \le \ell$. We will use Lemma~\ref{lem:swapNotOutsideOfGadget} to bound their sizes. Consider $S'$. By the pigeonhole principle, at least one of the $m+1$ gadgets, say gadget $g$, contains a set $X$ of at least $|S'|/(m+1)$ tokens from $S'$. Since $g$ is not the final gadget for any token in $X$, they will all eventually leave gadget $g$. By assumption, every token $t \in X$ has reached the root before the current time point, so $t$ has been outside $g$ at a previous time. Thus by Lemma~\ref{lem:swapNotOutsideOfGadget}(1) we have $|S'|/(m+1) \le k^{1/2 + 1/c}$. Next consider $S''$. Again by the pigeonhole principle, at least one of the $m+1$ gadgets, say gadget $g$, contains at least $|S''|/(m+1)$ tokens from $S''$. These tokens are currently in $g$, will each leave $g$ at some later time (by definition of $S''$), and will all eventually be back in $g$ (since $g$ is their final gadget). Thus by Lemma~\ref{lem:swapNotOutsideOfGadget}(2), we have $|S''|/(m+1) \le k^{1/2 + 1/c}$. Now $|S'| + |S''| \le 2(m+1)k^{1/2 + 1/c} \le k^{1/2 + 2/c}$ for $m,n > 2$ giving the required bound. \end{proof} Next, we prove a related lemma which says that, for any slot gadget $g$, if many tokens with initial positions in $g$ have reached the root then almost as many tokens with final gadget $g$ have entered $g$ for the last time. This lemma is not needed until Section~\ref{sec:Item Tokens Stuck}, but we place it here because its proof heavily depends on Lemma~\ref{lem:indest}. \begin{lemma}\label{lem:exchange} Let $S$ be a set of at least $k^{1/2+3/c}$ tokens that all have slot gadget $g$ as their initial gadget. Let $\tau_1$ be a point in time where no token in $S$ has reached the root, and let $\tau_2$ be a later point in time after every token in $S$ has reached the root. Then, between $\tau_1$ and $\tau_2$, at least $|S|-k^{1/2+3/c}$ many tokens (not in $S$) whose final gadget is $g$ enter gadget $g$ for the last time. \end{lemma} \begin{proof} Let $S'$ be the set of tokens that were not in slot gadget $g$ at time $\tau_1$, but are in slot gadget $g$ at time $\tau_2$. We will show that $(i)$ $S'$ is big enough for the statement to hold and $(ii)$ few tokens of $S'$ subsequently leave gadget $g$. For Statement $(i)$, we first apply Lemma~\ref{lem:indest} to $S$. Set $S$ has size at least $\ell =k^{1/2+2/c}$ and at time $\tau_2$ all the tokens of $S$ have reached the root, so, by the lemma, all except at most $\ell$ of them have entered their final gadgets (which are different from $g$) for the last time. Since all tokens of $S$ were in gadget $g$ at time $\tau_1$ and at least $|S| - \ell$ of them are not in gadget $g$ at time $\tau_2$, therefore $|S'| \ge |S| - \ell$ (since the missing tokens must have been replaced). For Statement ($ii$), we apply Lemma~\ref{lem:swapNotOutsideOfGadget}(1) to $S'$. All the tokens of $S'$ are in gadget $g$ at time $\tau_2$, all of them were outside gadget $g$ at a previous time, and therefore, the number that can leave gadget $g$ after time $\tau_2$ is at most $k^{1/2 + 1/c}$ which is less than $\ell$. Putting these together, the number of tokens that have entered gadget $g$ and will remain there until the end is at least $|S| - 2\ell$. Since $2\ell < k^{1/2 + 3/c}$, this gives the bound we want. \end{proof} Recall that in the scaffold solution, the segments reach the root in a particular order, as specified by property (P5) of the scaffold solution. Now we show that, although not all tokens in our solution obey this particular order, many tokens do. In particular, the \defn{core} of each segment, defined below, behaves like the scaffold solution. \begin{definition} \label{def:core} Let $S$ be a segment. Order the tokens of $S$ by the first time they reach the root. The \defn{core}, $C(S)$, is the set of all tokens in $S$ except for the first and last $k^{1/2+3/c}$ in this ordering. \end{definition} \begin{lemma}\label{lem:segbyseg} Let $S_1$ and $S_2$ each be a segment (either a big segment or a padding segment) of slot tokens such that tokens of $S_1$ reach the root before tokens of $S_2$ in the scaffold solution. Then, in our token swapping solution, all tokens of $C(S_1)$ reach the root before any token of $C(S_2)$ does so. \end{lemma} \begin{proof} Note that because $S_1$ and $S_2$ consist of slot tokens, their final gadget is the ordering gadget. Also, by property (P5) of the scaffold solution, the final positions of the tokens in $S_1$ are to the left of tokens of $S_2$ in the ordering gadget. Consider the order in which the tokens of $S_1 \cup S_2$ reach the root for the first time. We must show that (all tokens of) $C(S_1)$ come before (all tokens of) $C(S_2)$ in this ordering. Assume for the sake of contradiction that a token $t_2$ of $C(S_2)$ comes before a token $t_1$ of $C(S_1)$ in the ordering. Let $L_1 \subseteq S_1$ be the last $k^{1/2+3/c}$ tokens of $S_1$ in the ordering (i.e., the tokens of $S_1$ after $C(S_1)$) and let $F_2$ be the first $k^{1/2+3/c}$ tokens of $S_2$ in the ordering (i.e., the tokens of $S_2$ before $C(S_2)$). Then $F_2$ comes before $t_2$, which in turn comes before $t_1$ (which also comes before $L_1$). Let $\tau$ be the time point just after all tokens of $F_2$ have reached the root. At time $\tau$, none of the tokens of $L_1$ have reached the root, so none of them are in the ordering gadget. Apply Lemma~\ref{lem:indest} to $F_2$ and the time point $\tau$. The lemma gives us a set $F'_2 \subseteq F_2$ of tokens that have entered the ordering gadget for the last time at time $\tau$, where $|F'_2| \ge k^{1/2+3/c} - k^{1/2-2/c}$. However, as already noted, the final positions of the tokens in $S_1$ are to the left of tokens of $S_2$. In particular, the final positions of the tokens in $L_1$ are to the left of the tokens of $F'_2$. Thus, $L_1$ (which is outside the ordering gadget at time $\tau$) and $F'_2$ must pairwise swap in the ordering gadget. During these swaps, the tokens in $F'_2$ are performing contrary (right) moves. This amounts to a total of $|F'_2||L_1|\geq (k^{1/2+3/c}-k^{1/2-2/c})(k^{1/2+3/c})>k^{1+1/c}$ contrary moves, a contradiction to Observation~\ref{obs:contrary}. \end{proof} From the definition of core (and construction of gadgets) we get the following bounds on the size of each core: \begin{lemma}\label{lem:noncore} If $S$ is a segment, then $|C(S)|>k^{1-9/c}$. Also, for any slot gadget $i$, the total number of tokens initially in slot gadget $i$ that are \emph{not} in the core of any segment is less than $k^{1/2+5/c}$. \end{lemma} \begin{proof} Each segment is of size at least $k/n^8$, and exactly $2k^{1/2+3/c}$ tokens in each segment are not in the core. Thus, $|C(S)|\geq k/n^8-2k^{1/2+3/c}>k^{1-9/c}$ since $c>22$. The second statement follows from the fact that any slot gadget contains at most $2n$ segments ($n$ padding segments and at most $n$ big segments), and for each segment, exactly $2k^{1/2+3/c}$ tokens are not in the core. Thus, there are at most $2n \cdot k^{1/2+3/c}<k^{1/2+5/c}$ many tokens initially in slot gadget $i$ that are not in the core of any segment. \end{proof} \paragraph{Individual tokens stay roughly in order}\label{sec:Ordering Lemma}$ $\\ \ The main lemma of this section (Lemma~\ref{lem:OutOfOrder}) shows that no individual token that is currently in a slot gadget can get too far out of order with respect to its surrounding tokens (see below for a precise definition of `out of order'). More precisely, we show that in any solution to the token swapping instance that has at most $K$ swaps, no intermediate token configuration can contain a set of $\ell=k^{1/2+2/c}$ tokens that are all out of order with a token $t$ in a slot gadget, as otherwise there would be too many contrary moves. We use the fact (proved in Lemma~\ref{tooManyContraryMoves}) that by Observation~\ref{obs:contrary}, the token swapping sequence can neither use $\frac{\ell}{2^4(m+1)}$ % contrary moves that are disjoint from moves accounted in $\mathcal{M}$ (c.f.~Corollary~\ref{obs:interface}), nor it can use $\frac{\ell^2}{2^53^2(m+1)^2}$ % contrary moves in total (irrespective of whether they are disjoint from $\mathcal{M}$ or not) -- as in both cases these would be more contrary moves than the token swapping instance can afford. % Recall that for a slot token with initial position in slot gadget $i$ or a non-slot token with target position in slot gadget $i$, its \defn{main path} is the path consisting of the slot gadget $i$ (not including the nook edge) and the ordering gadget, connected via the root. \begin{definition} Let $t$ and $s$ be two slot tokens that share the same initial gadget or two non-slot tokens that share the same final gadget. Observe that $t$ and $s$ have the same main path $p$. We say that $t$ is \defn{out of order} with $s$ if $t$ and $s$ are both on their main path $p$, but $s$ is on the opposite side of $t$ than it was initially. Note that this relation is symmetric, that is, if $t$ is out of order with $s$, then also $s$ is out of order with $t$. Moreover, we say that $t$ is \defn{out of order} with a set $S$ of tokens if $t$ is out of order with every element $s \in S$. \end{definition} In what follows, we first show that transforming certain token configurations into others uses too many contrary moves. To this end, we start by proving two auxiliary lemmas % and by identifying Transformations 1--4. These will subsequently be used in the proof of the main Lemma~\ref{lem:OutOfOrder} of this section. Consider the four transformations in Figure~\ref{fig:transformations}. Each transformation shows a pair of configurations and assumes that a token swapping sequence transforms the first configuration into the second one. The type of token $t$ (slot or non-slot), as well as its position relative to a set $S$ of $\lambda$ tokens of the same type are marked in each configuration. \begin{figure}[tbh] \centering \includegraphics[width=\textwidth]{Figures/transformations.pdf} \caption{Four transformations. The empty circle denotes the root of the tree. In each configuration, the solid and dashed ovals mark the possible location of the set $S$ of $\lambda$ tokens. Token $t$ can be anywhere inside the marked gadget or at the root as long as it respects its position relative to the set~$S$. The marked gadget is assumed to be $t$'s initial or target gadget, depending on the context. The tokens from $S$ have the same initial and target gadget as $t$. % } \label{fig:transformations} \end{figure} \begin{lemma} \label{lem:transformations} If $t$ exchanges its order with each of the $\lambda$ tokens of the set $S$ inside the same gadget as the one in which $t$ starts and ends a transformation, then realizing any of the four transformations from Figure~\ref{fig:transformations} takes either at least $ \lambda^2/(2\cdot3^2)$ contrary moves or at least $\lambda/3-n(m+1)$ contrary moves that are disjoint from contrary moves accounted in $\mathcal{M}$. \end{lemma} \begin{proof} All four transformations are argued by contradiction. Typically, the token $t$ will be able to exchange with tokens of $S$ in the marked gadget $i$ in up to 3 different ways, and so there will always be a subset $S'$ of at least $\lambda/3$ tokens from $S$ that swapped with $t$ in the same way. {\bf Transformation 1.} There are three possibilities: either the tokens of $S'$ swap directly with the token $t$ in the slot gadget $i$ (Case a), or each of the $S'$ tokens at some point enters the nook and the token $t$ passes it by moving in slot gadget $i$ % (Case b), or the token $t$ enters the nook and the $S'$ tokens pass it by moving in the slot gadget % (Case c). In Case a, $t$ is a slot token in its initial slot gadget and each $s\in S'$ makes a contrary (right) move when swapping with $t$. By Corollary~\ref{obs:interface}(\ref{int2}), these are % at least $\lambda/3$ contrary moves that were not accounted in $\mathcal{M}$. In Case b, moving each slot token $s\in S'$ into the nook is a contrary (right) move. By Corollary~\ref{obs:interface}(\ref{int4}), these are at least $\lambda/3$ % contrary moves that were not accounted in $\mathcal{M}$. For Case c, note that all $\geq \lambda/3$ % tokens of $S'$ are to the left of $t$ just before $t$ enters the nook for the first time, and all these tokens are to the right of $t$ after $t$ leaves the nook for the last time. Hence the block of at least $ \lambda/3$ % slot tokens of $S'$ moved by at least $ \lambda/3$ % vertices to the right, which takes at least $\frac{1}{2}\cdot (\frac{\lambda}{3})^2$ % contrary (right) moves. {\bf Transformation 2.} The same three possibilities as for Transformation 1 need to be discussed. In Case a, when each non-slot token $s\in S'$ swaps directly with $t$, it makes a contrary (left) move in its destination gadget. These are at least $ \lambda/3$ % contrary moves that by Corollary~\ref{obs:interface}(\ref{int1}) were not accounted in $\mathcal{M}$. In Case b, every time a non-slot token $s \in S'$ moves out of the nook, it makes a contrary (left) move. These are at least $ \lambda/3$ % contrary moves that by Corollary~\ref{obs:interface}(\ref{int4}) were not accounted in $\mathcal{M}$. In Case c, the at least $\lambda/3$ % non-slot tokens of $S'$ shift by at least $ \lambda/3$ % vertices to the left, which takes at least $ \frac{1}{2}\cdot(\frac{\lambda}{3})^2$ % contrary (left) moves. {\bf Transformation 3.} The only possibility here is that each token $s \in S$ directly swaps with the slot token $t$ in the ordering gadget, meaning that the slot token $s$ makes a contrary (right) move. These are $\lambda$ % contrary moves that by Corollary~\ref{obs:interface}(\ref{int2}) were not accounted in $\mathcal{M}$. {\bf Transformation 4.} The non-slot token $t$ must again swap directly with each $s \in S$ in the ordering gadget but we distinguish two cases depending on whether the tokens of $S'$ have never left the ordering gadget before swapping with $t$ (Case a) or whether they did (Case b). Note that `never left the ordering gadget' refers to the entire token swapping sequence, possibly even before Transformation 4 started. In Case a, each non-leaving non-slot token $s$ of $S'$ makes a contrary (left) move when swapping with $t$. These are at least $ \lambda/3$ contrary moves, out of which by Corollary~\ref{obs:interface}(\ref{int3}) at most $n(m+1)$ have been accounted in $\mathcal{M}$. Hence, there are at least $\lambda/3 - n(m+1)$ contrary moves disjoint from $\mathcal{M}$. In Case b, each $s \in S'$ had visited the root before it swapped with $t$ and eventually all $\geq \lambda/3$ % tokens of $S'$ lie to the left of $t$ in the ordering gadget. Hence the tokens in $S'$ must have altogether made at least $1+2+\dots+\lambda/3 \geq \frac{1}{2}\cdot(\frac{\lambda}{3})^2$ % contrary (left) moves (some of them possibly before the transformation started). \end{proof} The following lemma lists bounds that imply too many contrary moves in the token swapping instance. \begin{lemma} \label{tooManyContraryMoves}$ $ \begin{enumerate} \item The total number of contrary moves in the token swapping solution is less than $\frac{\ell^2}{2^53^2(m+1)^2}$.\label{tooManyItem1} \item If $\lambda\geq\frac{\ell}{4(m+1)}$, then realizing any of the four transformations from Figure~\ref{fig:transformations} as described in Lemma~\ref{lem:transformations} requires too many contrary moves (i.e., either too many contrary moves in total, or too many contrary moves that are disjoint from contrary moves accounted in~$\mathcal{M}$).\label{tooManyItem2} \end{enumerate} \end{lemma} \begin{proof}$ $ \begin{enumerate} \item Recall that $\ell = k^{1/2+2/c}$, we assume that $m,n>5$ and from the construction of the token swapping instance, $k=(mn)^c$. Hence, $\frac{\ell^2}{2^53^2(m+1)^2} = k^{1+1/c}\cdot \frac{m^3n^3}{2^53^2(m+1)^2}$ which exceeds $k^{1+1/c}$ contrary moves given in Observation~\ref{obs:contrary} whenever $m,n\geq 5$. \item By Lemma~\ref{lem:transformations}, the four transformations in Figure~\ref{fig:transformations} result in either at least $ \lambda^2/(2\cdot3^2)$ contrary moves or at least $\lambda/3-n(m+1)$ contrary moves that are disjoint from contrary moves accounted in $\mathcal{M}$. We show that either case exceeds the number of available contrary moves. % By assumption on $\lambda$, we have $\lambda^2/(2\cdot3^2) \geq \frac{\ell^2}{2^53^2(m+1)^2}$ which by the first statement of the current lemma are too many contrary moves. For the second case, we show that $\lambda/3-n(m+1) \geq \lambda/4 \geq k^{1/c}$. By Observation~\ref{obs:contrary}, this will imply that there are too many contrary moves disjoint from $\mathcal{M}$. To prove the first inequality, it suffices to show that $\lambda/12 \geq n(m+1)$. Recall that $\ell=k^{1/2+2/c}$, by construction of the token swapping instance $k=(mn)^c$ and we have set $c=25$. By assumption, $\lambda \geq \frac{\ell}{4(m+1)}$ which implies $\lambda \geq \frac{(mn)^{c/2}(mn)^2}{4(m+1)}$. % We obtain that $\lambda/12 \geq \frac{(mn)^{c/2}(mn)^2}{48(m+1)} \geq n(m+1)$ holds whenever $m,n \geq 2$. % Finally, $\lambda/4 \geq \frac{\ell}{16(m+1)}= k^{1/c} \cdot \frac{(mn)^{1+c/2}}{16(m+1)}$ % and this exceeds $k^{1/c}$ whenever $m,n\geq2$. \end{enumerate} \end{proof} We can now prove the main lemma: \begin{lemma} \label{lem:OutOfOrder} At all times, for every non-item token $t$ that is currently in a slot gadget or at the root, there does not exist a set $S$ of $\ell=k^{1/2+2/c}$ tokens that are out of order with $t$. \end{lemma} \begin{proof} Suppose for a contradiction that $t$ is out of order with a set $S$ of $\ell$ tokens of the same type (i.e., all slot or all non-slot tokens). Observe that with respect to the main path of $t$ at least $\ell / 2$ of these tokens are on the same side (either left or right) of $t$. Call this subset $S'$, $|S'| \geq \ell / 2$. We will consider four cases: the token $t$ is either a slot or a non-slot token and the set $S'$ is either to the right or to the left of $t$, see Figure~\ref{fig:four_cases.pdf}. \begin{figure}[tbh] \centering \includegraphics[scale=0.8]{Figures/four_cases.pdf} \caption{Four cases considered in proof of Lemma~\ref{lem:OutOfOrder}. The empty circle denotes the root of the tree. The bottom-most slot gadget indicates the initial or the target slot gadget (depending on the context) of token $t$ and of all tokens from $S$.} \label{fig:four_cases.pdf} \end{figure} {\bf Case 1.} If $t$ is a slot token that is to the left of the set $S'$ of slot tokens in the current out-of-order configuration, then the initial configuration of the token swapping instance must have had $t$ in the same slot gadget on the right side of $S'$. Transforming the initial configuration into the current out-of-order configuration is exactly Transformation 1. If $\ell/4$ or more % tokens from $S'$ exchange with $t$ inside the slot gadget, then by Lemma~\ref{tooManyContraryMoves}(\ref{tooManyItem2}) % there are too many contrary moves. Otherwise there is a subset $S''$ of at least $|S'|/2\geq\ell/4$ tokens from $S'$ that exchange with $t$ outside of the slot gadget. Then, in order for $t$ to get out of this slot gadget, all $S''$ tokens must first get out of the gadget and then re-enter it again. Hence, Lemma~\ref{lem:swapNotOutsideOfGadget} applies and there are at least $\frac{1}{2}\cdot(\frac{\ell}{4})^2=\ell^2/2^5$ % contrary moves, which is by Lemma~\ref{tooManyContraryMoves}(\ref{tooManyItem1}) too many. {\bf Case 2.} If $t$ is a non-slot token that is to the left of the set $S'$ of non-slot tokens in the current out-of-order configuration, then the final configuration of the token swapping instance must have $t$ in the same slot gadget on the right side of $S$. Transforming the current out-of-order configuration into the final configuration is exactly Transformation 2. By a similar argument as in Case 1, the Lemmas~\ref{tooManyContraryMoves}(\ref{tooManyItem2})% , \ref{lem:swapNotOutsideOfGadget} and \ref{tooManyContraryMoves}(\ref{tooManyItem1}) show that $t$ cannot exchange order with the tokens from $S'$ inside nor outside of the slot gadget. {\bf Case 3.} Assume that $t$ is a slot token and the set $S'$ of slot tokens is to the left of it, each such token either in the same slot gadget $i$ or in the ordering gadget. Consider the first time after the current out-of-order configuration that token $t$ reaches the root: this intermediate configuration has at least % $\frac{\ell}{2(m+1)}$ tokens of $S'$, call this set $S''$, either in slot gadget $i$ (Subcase~a), or in a slot gadget $j\neq i$ (Subcase~b), or in the ordering gadget (Subcase~c). In Subcase a, % all $\geq\frac{\ell}{2(m+1)}$ % tokens of $S''$ must exchange their order with token $t$ inside the slot gadget $i$ between the current out-of-order configuration and the intermediate configuration. This is exactly Transformation 1 and by Lemma~\ref{tooManyContraryMoves}(\ref{tooManyItem2}) it causes too many contrary moves. In Subcase b, moving the $S''$ slot tokens from their current position into slot gadget $j$ (for the intermediate configuration) takes at least $\frac{1}{2}\cdot(\frac{\ell}{2(m+1)})^2$ % contrary (right) moves, which are again by Lemma~\ref{tooManyContraryMoves}(\ref{tooManyItem1}) more contrary moves than we can afford. Finally, note that given the current out-of-order configuration, the target configuration of the token swapping instance must have $t$ to the left of $S'$ tokens in the ordering gadget. Thus, in Subcase c, transforming the intermediate configuration into the target configuration is exactly Transformation 3. If at least half of the $S''$ tokens, i.e.,~ $\frac{\ell}{4(m+1)}$ tokens, exchange with $t$ inside the ordering gadget, then by Lemma~\ref{tooManyContraryMoves}(\ref{tooManyItem2}) there are too many contrary moves. Otherwise at least $|S''|/2\geq\frac{\ell}{4(m+1)}$ tokens of $S''$ exchange with $t$ outside of the ordering gadget. For that, they must all first leave and then re-enter the ordering gadget. By Lemma~\ref{lem:swapNotOutsideOfGadget}, this results in at least $\frac{1}{2} \cdot (\frac{\ell}{4(m+1)})^2$ contrary moves which by Lemma~\ref{tooManyContraryMoves}(\ref{tooManyItem1}) are too many. {\bf Case 4.} Assume that $t$ is a non-slot token and the set $S'$ of non-slot tokens is to the left of it, each such token either in the same slot gadget $i$ or in the ordering gadget. Consider the last time before the current out-of-order configuration that token $t$ was at the root: this intermediate configuration has at least $\frac{\ell}{2(m+1)}$ % tokens of $S'$, call this set $S''$, either in slot gadget~$i$ (Subcase~a), or in a slot gadget $j\neq i$ (Subcase~b), or in the ordering gadget (Subcase~c). In Subcase a, % all $\geq\frac{\ell}{2(m+1)}$ % tokens of $S''$ must exchange their order with token $t$ inside the slot gadget $i$ between the intermediate and the current out-of-order configuration. This is exactly Transformation 2 and by Lemma~\ref{tooManyContraryMoves}(\ref{tooManyItem2}) it causes too many contrary moves. In Subcase b, moving the $S''$ non-slot tokens out of slot gadget $j$ (in the intermediate configuration) to their current position takes at least $\frac{1}{2}\cdot(\frac{\ell}{2(m+1)})^2$ % contrary (left) moves, which are again by Lemma~\ref{tooManyContraryMoves}(\ref{tooManyItem1}) more contrary moves than we can afford. Finally, note that given the current out-of-order configuration, the initial configuration of the token swapping instance must have $t$ to the left of $S'$ tokens in the ordering gadget. Thus, in Subcase c, transforming the initial configuration into the intermediate configuration is exactly Transformation 4. If at least half of the $S''$ tokens, i.e.,~ $\frac{\ell}{4(m+1)}$ tokens, exchange with $t$ inside the ordering gadget, then by Lemma~\ref{tooManyContraryMoves}(\ref{tooManyItem2}) there are too many contrary moves. Otherwise at least $|S''|/2\geq\frac{\ell}{4(m+1)}$ tokens of $S''$ exchange with $t$ outside of the ordering gadget. By Lemma~\ref{lem:swapNotOutsideOfGadget}, this results in at least $\frac{1}{2} \cdot (\frac{\ell}{4(m+1)})^2$ contrary moves which by Lemma~\ref{tooManyContraryMoves}(\ref{tooManyItem1}) are too many. \end{proof} \paragraph{Every slot gadget contains an item token at all times}\label{sec:Item Tokens Stuck}$ $\\ The goal of this section is to prove the following lemma. \begin{lemma}\label{lem:LeafLeaving} At all times there is at least one item token in each slot gadget at distance at least $k(1-\frac{1}{4n})$ from the root. \end{lemma} \begin{proof} Our approach will be to suppose for contradiction that there is a slot gadget that does not satisfy the lemma statement, which in particular means that the token at the nook of that slot gadget is a non-item token. We will argue that having a non-item token in the nook with no item token nearby creates too many contrary moves. To be precise, suppose that there is a time $\tau$ when some slot gadget, say slot gadget $i$, does not have an item token at distance at least $k(1-\frac{1}{4n})$ from the root. Let $\tau_1$ be the last time before $\tau$ in which we had an item token occupying the nook, and let $q$ be that item token. Similarly, we define $\tau_2$ as the first time after $\tau$ when there is an item token occupying the nook, and let $q'$ be the item token. Note that both $\tau_1$ and $\tau_2$ must exist since the initial and target configurations are candidates for each of them, respectively. % Let $v$ be the unique vertex of slot gadget $i$ whose distance to the root is $k(1-\frac{1}{4n})$. Equivalently, $v$ is the vertex $\frac{k}{4n}$ vertices to the left of the nook parent of slot gadget $i$. At time $\tau_1$, $q$ was at the nook of slot gadget $i$, and before time $\tau$, $q$ reached vertex $v$. That is, between times $\tau_1$ and $\tau$, token $q$ traverses all of the $\frac{k}{4n}$ edges from the nook parent to $v$. Let $R$ be the set of tokens that $q$ swaps with on $q$'s last traversal of each of these edges before time $\tau$. By Claim~\ref{lem:unique}, these tokens are distinct, so $|R|=\frac{k}{4n}$. We now give an overview of the proof. We first show that after their swaps with $q$, many of the tokens in $R$ proceed to pass by the nook parent in the rightward direction (Claim~\ref{claim:rightnook}). Then, we identify a non-item token $t$ that is in the nook while many of the tokens in $R$ pass by the nook parent (Claim~\ref{claim:tnook}). Then, we show that while $t$ is in the nook, many tokens also pass by the nook parent in the leftward direction, to ``replace'' the tokens in $R$ that are passing in the rightward direction (Claim~\ref{claim:Tbig}). Next, we show that $t$ cannot have slot gadget $i$ as its initial nor final gadget (Claim~\ref{claim:fromelsewhere}). This is because if $t$ has slot gadget $i$ as its initial or final gadget then $t$ will get out of order with the tokens that are passing by the nook in the leftward or rightward direction, respectively. This contradicts Lemma~\ref{lem:OutOfOrder} (which says that a token cannot be out of order with too many tokens). The remaining case is when $t$ does not have $i$ as either its initial or final gadget. In this case we find a similar type of contradiction: we find a large number of tokens that have the same initial and final gadget as $t$ that move out of their initial gadget and into their final gadget while $t$ stays in slot gadget $i$ (Claim~\ref{claim:slotfromt}). We are able to find these tokens because the segments (actually just their cores) reach the root in order according to the scaffold solution by Lemma~\ref{lem:segbyseg}, and the scaffold solution includes segments from \emph{every} slot gadget at high frequency due to the padding segments. The consequence of this is that $t$ becomes out of order with the tokens from its initial gadget that have entered their final gadget while $t$ is in slot gadget $i$, which again contradicts Lemma~\ref{lem:OutOfOrder}. We now formalize this intuition. Towards showing that many tokens in $R$ pass by the nook parent, we first show that many tokens in $R$ are non-slot tokens whose final gadget is $i$. \begin{claim}\label{claim:sizer2} $R$ contains at least $\frac{k}{4n}-k^{1/c}-k^{1/2+2/c}$ many non-slot tokens whose final gadget is $i$. \end{claim} \begin{proof} When token $r\in R$ swaps with $q$, $r$ moves to the right. Thus, if $r$ is a slot token, then $r$ does a contrary move. By Corollary~\ref{obs:interface}(\ref{int5}), this contrary move is not in $\mathcal{M}$. Thus, at most $k^{1/c}$ tokens in $R$ are slot tokens. Also, by Lemma~\ref{lem:indest}, at most $k^{1/2+2/c}$ of the tokens in $R$ are non-slot tokens whose final gadget is not~$i$. Since $|R|=\frac{k}{4n}$ we have that the number of tokens in $R$ that are non-slot tokens whose final gadget is $i$ is at least $\frac{k}{4n}-k^{1/c}-k^{1/2+2/c}$ as claimed. % \end{proof} Let $R_2$ be the subset of tokens in $R$ that are non-slot tokens whose final gadget is~$i$. % Now consider the movement of the tokens in $R_2$ between times $\tau_1$ and $\tau_2$. We claim that many tokens in $R_2$ move to the right of the nook parent. \begin{claim}\label{claim:rightnook} At least $k^{1-2/c}$ tokens in $R_2$ move to the right of the nook parent at some point between times $\tau_1$ and $\tau_2$. \end{claim} \begin{proof} First, we claim that fewer than $k^{1/2+1/c}$ tokens in $R_2$ can ever reach vertex $v$ (the vertex at distance $\frac{k}{4n}$ to the left of the nook parent) after swapping with $q$. This is because each token in $R_2$ swaps with $q$ along a unique edge of distance at most $\frac{k}{4n}$ from the nook. Thus, moving $k^{1/2+1/c}$ of these tokens to a distance \emph{at least} $\frac{k}{4n}$ from the nook requires at least $\frac{(k^{1/2+1/c})^2}{2}>k^{1+1/c}$ left moves, which are all contrary moves since every token in $R_2$ is a non-slot token. Other than the $k^{1/2+1/c}$ tokens mentioned above, any token that does not satisfy the claim must remain between $v$ and the nook parent from when it swaps with $q$ until time $\tau_2$. We will show that there are at most $k^{1/c}$ many such tokens. Recall that at time $\tau$ no item token is in slot gadget $i$ at distance at least $k(1-\frac{1}{4n})$ from the root. In particular, at time $\tau$, $q'$ (the item token defined by time $\tau_2$) is either in slot gadget $i$ between the root and $v$ or not in slot gadget $i$. At time $\tau_2$, $q'$ is at the nook. Thus, between times $\tau$ and $\tau_2$, $q'$ swaps with every token in $R'$ with $q'$ moving to the right and the tokens in $R'$ moving to the left. Since every token in $R_2$ (and thus $R'$) is a non-slot token, these left moves are contrary moves. Furthermore, these contrary moves are not in $\mathcal{M}$ by Corollary~\ref{obs:interface}(\ref{int5}). Thus, $|R'|< k^{1/c}$. Putting everything together, the number of tokens that move to the right of the nook parent at some point between times $\tau_1$ and $\tau_2$ is at least $|R|-k^{1/2+1/c}-k^{1/c}\geq\frac{k}{4n}-2k^{1/c}-k^{1/2+2/c}-k^{1/2+1/c}>k^{1-2/c}$ since $c>6$. \end{proof} Now, we are ready to define the token $t$ mentioned in the overview. Let $e$ be the edge between the nook parent and the vertex to its right. \begin{claim}\label{claim:tnook} There exists an interval $\mathcal{I}$ of time contained between $\tau_1$ and $\tau_2$ such that: $(1)$ a single non-item token $t$ is in the nook of slot gadget $i$ for the entirety of $\mathcal{I}$, and $(2)$ at least $k^{1-3/c}$ tokens of $R_2$ traverse edge $e$ in the rightward direction during $\mathcal{I}$. \end{claim} \begin{proof} First observe that, by Corollary~\ref{obs:interface}(\ref{int4}), each move of a non-item token into and out of the nook creates a contrary move that is not in $\mathcal{M}$. Thus, the total number of different non-item tokens that ever go into the nook of any gadget (and in particular slot gadget $i$) is at most $k^{1/c}$. Let $R_3 \subseteq R_2$ be the tokens of $R_2$ that move to the right of the nook parent at some point between times $\tau_1$ and $\tau_2$. By Claim~\ref{claim:rightnook}, we know that $|R_3|\geq k^{1-2/c}$. For each token of $R_3$, consider the last time that it traverses edge $e$ to the right between times $\tau_1$ and $\tau_2$ and look at which token is in the nook during that traversal. By the pigeonhole principle and the above bounds, there must exist a non-item token $t$ that is in the nook of gadget~$i$ contiguously for an interval $\mathcal{I}$ of time during which at least $|R_3|/k^{1/c}\geq k^{1-3/c}$ tokens of $R_3$ traverse edge $e$ in the rightward direction. \end{proof} Let $\mathcal{I}$ be the interval of time from Claim~\ref{claim:tnook} and let $R_4\subseteq R_2$ be the set of at least $k^{1-3/c}$ tokens from Claim~\ref{claim:tnook}. Also, let $\mathcal{S}$ be the set of swaps during interval $\mathcal{I}$ during which tokens in $R_4$ traverse edge $e$ in the rightward direction, taking the last such traversal for each token in $R_4$. % Let $L$ be the set of tokens that $R_4$ swaps with during the swaps $\mathcal{S}$. Next, we will show that many distinct tokens traverse the edge $e$ to the left during $\mathcal{I}$. We already know that there are many such traversals (performed by tokens in $L$), however we need to guarantee that many such traversals are performed by \emph{distinct} tokens. In particular, it is possible for $L$ to be composed of a single token that is going back and forth across~$e$. Furthermore, we require that these distinct tokens were initially in slot gadget $i$. These required properties are captured in the following claim. \begin{claim}\label{claim:Tbig} At least $k^{1-4/c}$ distinct tokens whose initial slot gadget is $i$ traverse $e$ in the left direction during interval $\mathcal{I}$. \end{claim} \begin{proof} First suppose $|L|\geq |R_4|/4$. We already know that every token in $L$ traverses $e$ in the left direction while $t$ is in the nook, so it suffices to show that at least half of the tokens in $L$ were initially in slot gadget $i$ (since $|L|/2\geq |R_4|/8\geq k^{1-3/c}/8>k^{1-4/c}$). Suppose more than half of the tokens in $L$ are \emph{not} initially in slot gadget $i$. If at least $|L|/4$ of these tokens have slot gadget $i$ as their final gadget, then their leftward traversal of $e$ is a contrary move, which is not in $\mathcal{M}$ by Corollary~\ref{obs:interface}(\ref{int1}). Thus, at least $|L|/4$ of these tokens do not have gadget~$i$ as their initial or final gadget. In this case, these tokens must move both into slot gadget $i$ all the way to $e$, and out of slot gadget $i$. One of these two directions is composed of contrary moves, so since $e$ is at distance $k$ from the root, we have $k$ contrary moves for each of the $|L|/4$ tokens, which is a contradiction. On the other hand, suppose $|L|< |R_4|/4$. This is the tricky case because for example $L$ could be just a single token that is moving back and forth across $e$, but we still need to show that many \emph{distinct} tokens traverse $e$ in the left direction. Because $|L|< |R_4|/4$, some tokens in $L$ participate in multiple swaps in $\mathcal{S}$. Let $\mathcal{S}'\subseteq\mathcal{S}$ be the set of swaps such that the participating token in $L$ has already previously performed a swap in $\mathcal{S}$ and will again perform another swap in $\mathcal{S}$. That is, for every token in $L$, at most two of its swaps in $\mathcal{S}$ are \emph{not} in $\mathcal{S'}$. Thus, $|\mathcal{S'}|\geq|\mathcal{S}|-2|L|=|R_4|-2|L|>|R_4|/2$. Defining $\mathcal{S'}$ is useful because we are guaranteed the following property: during each swap in $\mathcal{S'}$, the participating token in $L$ is moving leftward, however at some later point this same token must traverse $e$ in the \emph{rightward} direction in order to be set up to again traverse $e$ leftward during its next swap in $\mathcal{S}$. For every swap in $\mathcal{S'}$, consider the next time this token in $L$ traverses $e$ in the rightward direction and denote this set of swaps by $\mathcal{S''}$. By definition, $|\mathcal{S''}|=|\mathcal{S'}|$. Now we will condition on whether the tokens in $L$ that participate in swaps in $\mathcal{S'}$ are slot tokens or non-slot tokens. {\bf Case 1.} Suppose that for at least half of the swaps in $\mathcal{S'}$, the participating token in $L$ is a slot token. Then, for at least half of the swaps in $\mathcal{S''}$, the participating token in $L$ is performing a contrary move. At least $|\mathcal{S''}|/2-k^{1/c}$ of these contrary moves are in $\mathcal{M}$, because if $k^{1/c}$ of them are not in $\mathcal{M}$ then we have a contradiction. Then according to the characterization of $\mathcal{M}$ in Observation~\ref{obs:purple} (specifically item~\ref{purp2}), for each these contrary moves in $\mathcal{M}$, the token $s$ swapped with is a \emph{distinct} slot token that was initially in slot gadget $i$. The number of such tokens $s$ is at least $|\mathcal{S''}|/2-k^{1/c}=|\mathcal{S'}|/2-k^{1/c}>|R_4|/4-k^{1/c}\geq k^{1-3/c}/4-k^{1/c}>k^{1-4/c}$ since $c>4$. This completes Case 1. {\bf Case 2.} Suppose that for at least half of the swaps in $\mathcal{S'}$, the participating token in $L$ is a non-slot token. In this case, for at least half of the swaps in $\mathcal{S''}$, the participating token in $L$ is performing a contrary move. At least $|\mathcal{S'}|/2-k^{1/c}$ of these contrary moves are in $\mathcal{M}$, because if $k^{1/c}$ of them are not in $\mathcal{M}$ then we have a contradiction. Then according to the characterization of $\mathcal{M}$ in Observation~\ref{obs:purple} (specifically item~\ref{purp3}), for each of these contrary moves of tokens in $L$ in $\mathcal{M}$, the previous time this token in $L$ moved rightward along $e$ it swapped with a \emph{distinct} slot token $s$ that was initially in slot gadget $i$. Importantly, the previous time this token in $L$ moved rightward along $e$ was during $\mathcal{I}$ by the definition of $\mathcal{S'}$. The number of such tokens $s$ is at least $|\mathcal{S'}|/2-k^{1/c}>|R_4|/4-k^{1/c}\geq k^{1-3/c}/4-k^{1/c}>k^{1-4/c}$ since $c>4$. This completes the proof. \end{proof} Now we will consider where token $t$ originated. First, we will show that slot gadget $i$ is \emph{not} the initial or final gadget for token $t$. \begin{claim}\label{claim:fromelsewhere} Slot gadget $i$ is \emph{not} the initial or final gadget for token $t$. \end{claim} \begin{proof} A key fact in this proof is that we know that while $t$ is in the nook, many tokens pass by the nook both rightward (in particular $R_4$) and leftward (in particular the tokens from Claim~\ref{claim:Tbig}). The idea of this proof is to show that if $t$ has slot gadget $i$ as its initial or final gadget then these tokens passing by the nook become out of order with $t$, which is impossible by Lemma~\ref{lem:OutOfOrder}. First, suppose for contradiction that slot gadget $i$ is the final gadget for token $t$. Let $R_5$ be the subset of $R_4$ that are on their main path both immediately before and immediately after interval $\mathcal{I}$. By Lemma~\ref{lem:indest}, $|R_5|\geq |R_4|-2k^{1/2+2/c}$. Since every token in $R_2\supseteq R_5$ also has final gadget~$i$, the notion of \defn{out of order} from Lemma~\ref{lem:OutOfOrder} can apply to any pair of tokens in $R_5\cup \{t\}$. By Lemma~\ref{lem:OutOfOrder}, when $t$ is at the nook parent both immediately before and immediately after interval $\mathcal{I}$, $t$ cannot be out of order with any subset of $R_5$ of size at least $k^{1/2+2/c}$. Thus, compared to immediately before interval $\mathcal{I}$, right after interval $\mathcal{I}$ $t$ is on the opposite side of less than $2k^{1/2+2/c}$ tokens in $R_5$. Thus, at least $|R_5|-2k^{1/2+2/c}$ of the tokens in $R_5$ are on the same side (left or right) of $t$ immediately before and immediately after interval $\mathcal{I}$. Note that by definition all tokens in $R_5$ traverse the edge $e$ during interval $\mathcal{I}$. Thus, either moving these $|R_5|-2k^{1/2+2/c}$ tokens from their positions immediately before $\mathcal{I}$ to $e$, or moving them from $e$ to their positions immediately after $\mathcal{I}$, are contrary moves. This amounts to a total number of contrary moves of at least $(|R_5|-2k^{1/2+2/c})^2\geq (|R_4|-4k^{1/2+2/c})^2\geq (k^{1-3/c}-4k^{1/2+2/c})^2>k^{2-7/c}>k^{1+1/c}$, since $c>10$. Now suppose for contradiction that token $t$ was initially in slot gadget $i$. This case is similar to the previous case, except in this case $R_5$ and $t$ do not have the same initial gadget so the notion of ``out of order'' does not apply to them; instead, $t$ has the same initial gadget as the tokens from Claim~\ref{claim:Tbig} so the notion of ``out of order'' applies to them instead. Claim~\ref{claim:Tbig} implies that there is a set $L'$ of at least $k^{1-4/c}$ tokens initially in slot gadget $i$ that traverse $e$ in the left direction during interval $\mathcal{I}$. Let $L''$ be the subset of $L'$ that are on their main path both immediately before and immediately after interval $\mathcal{I}$. By Lemma~\ref{lem:indest}, $|L''|\geq |L'|-2k^{1/2+2/c}$. By Lemma~\ref{lem:OutOfOrder}, when $t$ is at the nook parent both immediately before and immediately after interval $\mathcal{I}$, $t$ cannot be out of order with any subset of $L''$ of size at least $k^{1/2+2/c}$. Thus, compared to immediately before interval $\mathcal{I}$, right after interval $\mathcal{I}$ $t$ is on the opposite side of at most $2k^{1/2+2/c}$ tokens in $L''$. Thus, at least $|L''|-2k^{1/2+2/c}$ of the tokens in $L''$ are on the same side (left or right) of $t$ immediately before and immediately after interval $\mathcal{I}$. Thus, either moving these $|L''|-2k^{1/2+2/c}$ tokens from their positions immediately before $\mathcal{I}$ to $e$, or moving them from $e$ to their positions immediately after $\mathcal{I}$, are contrary moves. This amounts to a total number of contrary moves at least $(|L''|-2k^{1/2+2/c})^2\geq (|L'|-4k^{1/2+2/c})^2\geq (k^{1-4/c}-4k^{1/2+1/c})^2>k^{2-9/c}>k^{1+1/c}$, since $c>10$. \end{proof} Now that we know that slot gadget $i$ is not the initial or final gadget for $t$, we analyze what happens in $t$'s initial and final gadgets while $t$ is in slot gadget $i$. We will eventually argue when $t$ reaches the root after being in slot gadget $i$, $t$ has become out of order with a large set of tokens, which we have shown in Lemma~\ref{lem:OutOfOrder} is impossible. The first step towards proving this is to show that while $t$ is in slot gadget $i$, many tokens that were initially in slot gadget~$i$ reach the root for the first time. We need to precisely define the time interval ``while $t$ is in slot slot gadget $i$'': Let $\mathcal{I}'$ be the time interval starting from the last time $t$ enters slot gadget $i$ before interval $\mathcal{I}$ and ending at the first time $t$ exits slot gadget $i$ after interval $\mathcal{I}$. Both events exist since $i$ is not the initial or final gadget for $t$ by Claim~\ref{claim:fromelsewhere}. \begin{claim}\label{claim:up} During interval $\mathcal{I}'$, at least $k+k^{1-6/c}$ tokens that were initially in slot gadget $i$ reach the root for the first time. \end{claim} \begin{proof} At the beginning and end of interval $\mathcal{I}'$, $t$ is at the root, and during interval $\mathcal{I}$, $t$ is in the nook of slot gadget $i$. Thus, during interval $\mathcal{I}'$, $t$ moves from the root to the nook of slot gadget $i$ and then back to the root. Let $\mathcal{S}$ be the set of swaps that $t$ performs while traveling from the root to the nook parent of slot gadget $i$, taking the last such swap that $t$ performs for each edge between the root and the nook parent; thus, $|\mathcal{S}|=k$. Let $S_1$ be the set of tokens that swap with $t$ during swaps in $\mathcal{S}$. By Claim~\ref{lem:unique}, $|S_1|=k$. By Claim~\ref{claim:Tbig}, at least $k^{1-4/c}$ tokens that were initially in slot gadget $i$ traverse $e$ in the left direction during interval $\mathcal{I}$. Call these tokens $S_2$. We will show three properties of $|S_1\cup S_2|$, which together complete the proof. Roughly, the three properties are the following: (1) many of the tokens in $|S_1\cup S_2|$ were initially in slot gadget $i$, (2) $|S_1\cup S_2|$ is large, and (3) many of the tokens in $|S_1\cup S_2|$ reach the root for the first time during interval $\mathcal{I}'$. First we will show item (1). All of the tokens in $S_2$ were initially in slot gadget $i$ by definition, so our goal is to get a lower bound on the number of tokens in $S_1$ that were initially in slot gadget $i$. Less than $k^{1/2+1/c}$ of the tokens in $S_1$ do not have slot gadget $i$ as their initial or final gadget, because otherwise it requires $k^{2(1/2+1/c)}/2$ contrary moves to get these tokens into slot gadget $i$ to the position of the swap in $\mathcal{S}$, or to get them back out of slot gadget $i$ (since each token in $S_1$ swaps with $t$ along a distinct edge). Further, note that if a token $s\in S_1$ has its final position in slot gadget $i$, then during its swap with $t$, $s$ is performing a contrary (left) move, which is not in $\mathcal{M}$ by Corollary~\ref{obs:interface}(\ref{int1}). Thus, less than $k^{1/c}$ of the tokens in $S_1$ have final position in gadget~$i$. Therefore, we have shown that at least $k-k^{1/2+1/c}-k^{1/c}$ tokens in $S_1$ were initially in slot gadget $i$. Call these tokens $S'_1$. From now on we will focus on $|S'_1\cup S_2|$. Next we will show item (2). Our goal is to get a lower bound on $|S'_1\cup S_2|$. To do this we will get an upper bound on $|S'_1\cap S_2|$. By definition, each token in $S'_1\cap S_2$ swaps with $t$ along a distinct edge between the root and the nook parent of slot gadget $i$, and then subsequently traverses the edge $e$. Each token in $S'_1$ (and thus $S'_1\cap S_2$) is initially in slot gadget $i$, so moving rightward from the location where it swapped with $t$ to edge $e$ are contrary moves. This incurs at least $(|S'_1\cap S_2|)^2/2$ contrary moves. Thus, $|S'_1\cap S_2|<k^{1/2+1/c}$ since otherwise the number of contrary moves would be more than $k^{1+1/c}$. Therefore, $|S'_1\cup S_2|=|S'_1|+|S_2|-|S'_1\cup S_2|>(k-k^{1/2+1/c}-k^{1/c})+k^{1-4/c}-k^{1/2+1/c}>k+k^{1-5/c}$ since $c>10$. Lastly, we will show item (3). We claim that after the tokens in $|S'_1\cup S_2|$ have traversed $e$, at no point in the future are more than $k^{1/2+1/c}$ of these tokens to the right of the nook parent. This is because right moves are contrary moves for these tokens (since they were initially gadget is $i$) so having $k^{1/2+1/c}$ of these tokens to the right of the nook parent simultaneously would incur $k^{2(1/2+1/c)}/2 > k^{1+1/c}$ contrary moves. In particular, when $t$ reaches the nook parent for the last time during interval $\mathcal{I}'$, no more than $k^{1/2+1/c}$ tokens in $S'_1\cup S_2$ are to the right of $t$. For each token $s\in S'_1\cup S_2$ that is \emph{not} to the right of $t$ at this point in time, note that $s$ either reaches the root before $t$ or swaps with $t$ (since at the end of $\mathcal{I}'$, $t$ is at the root). Less than $k^{1/c}$ such tokens $s$ swap with $t$ since in this case, $s$ performs a contrary (right) move that is not in $\mathcal{M}$ by Corollary~\ref{obs:interface}(\ref{int6}). Thus, at least $|S'_1\cup S_2|-k^{1/2+1/c}-k^{1/c}$ tokens in $S'_1\cup S_2$ reach the root during interval $\mathcal{I}'$. It remains to show that enough tokens in $S'_1\cup S_2$ reach the root \emph{for the first time} during interval $\mathcal{I}'$. We know that at most $k^{1/c}$ of the tokens in $S'_1\cup S_2$ reached the root for the first time before the beginning of interval $\mathcal{I}'$ because all of these tokens subsequently traverse $e$, which requires $k$ contrary moves per token. Thus, we have shown that at least $k+k^{1-5/c}-k^{1/2+1/c}-2k^{1/c}$ tokens in $S'_1\cup S_2$ reach the root for the first time during interval $\mathcal{I}'$. This quantity of tokens is more than $k+k^{1-6/c}$ since $c>12$. \end{proof} Recall that we will eventually argue when $t$ reaches the root at the end of interval $\mathcal{I}'$, $t$ has become out of order with a large set of tokens. To define this large set of tokens, it will be useful to return to the idea of the \defn{core} $C(S)$ of a segment $S$ from Definition~\ref{def:core}. Next, we will show that during interval $\mathcal{I}'$, for \emph{each} slot gadget $j\not=i$, there is a segment whose initial position was in that slot, such that every token in the core of that segment reaches the root for the first time. \begin{claim}\label{claim:oneofeach} For each slot gadget $j\not=i$, there is a segment $S_j$ whose initial position was in slot gadget $j$ such that during interval $\mathcal{I}'$ every token in $C(S_j)$ reaches the root for the first time. \end{claim} \begin{proof} It will help to count the number of tokens of various types initially in slot gadget $i$. By Lemma~\ref{lem:noncore} the total number of tokens with initial position in slot gadget $i$ that are not in the core of any segment is at most $k^{1/2+5/c}$. Also, the total number of tokens with initial position in slot gadget $i$ in a padding segment is $n(\frac{k}{n^8})>k^{1-7/c}$ since there are $n$ padding segments in each slot gadget and each one is of length $\frac{k}{n^8}$. Each remaining token initially in slot gadget $i$ is in the core of a big segment. Each big segment is of size $k$. By Claim~\ref{claim:up}, there is a set $S$ of at least $k+k^{1-6/c}$ tokens that were initially in slot gadget $i$ that reach the root for the first time during interval $\mathcal{I}'$. Because $|S|>k^{1/2+5/c}+k^{1-7/c}+k$ (which is true since $c>24$), the calculations from the previous paragraph imply that $S$ must contain at least one token from the core of a big segment and at least one token from the core of another segment. Lemma~\ref{lem:segbyseg} says that the tokens in the cores of segments reach the root for the first time in the same order as in the scaffold solution. Property (P6) of the scaffold solution says that during a time interval in which at least one token from a big segment and at least one token from any other segment from the same slot gadget reach the root, at least one segment from each of the other slot gadgets reaches the root. Combining these two facts, we have that in our token swapping solution, during a time interval in which at least one token from the core of a big segment initially in slot gadget $i$ and at least one token from the core of any other segment initially in slot gadget $i$ reach the root for the first time, the core of at least one segment initially in each of the other slot gadgets reaches the root for the first time. $\mathcal{I}'$ is such a time interval, since every token in $S$ reaches the root for the first time during $\mathcal{I}'$ and we have shown that $S$ contains at least one token from the core of a big segment and at least one token from the core of another segment (both initially in slot gadget $i$). This completes the proof. \end{proof} The final claim towards arguing that when $t$ reaches the root at the end of interval $\mathcal{I}'$, $t$ has become out of order with a large set of tokens, is the following. \begin{claim}\label{claim:slotfromt} During interval $\mathcal{I}'$, at least $k^{1-10/c}$ tokens that all have the same initial and final gadget as $t$ exit their initial gadget for the first time and enter their final gadget for the last time. \end{claim} \begin{proof} First, suppose $t$'s initial gadget is a slot gadget. Then, by Claim~\ref{claim:oneofeach}, every token in the core of a segment $S$ with the same initial gadget as $t$ reaches the root for the first time during $\mathcal{I}'$. Then, by Lemma~\ref{lem:indest}, at least $|C(S)|-k^{1/2+2/c}$ tokens from $C(S)$ enter the ordering gadget for the last time during $\mathcal{I}'$. This completes the case where $t$'s initial gadget is a slot gadget since by Lemma~\ref{lem:noncore}, $|C(S)|-k^{1/2+2/c}>k^{1-9/c}-k^{1/2+2/c}>k^{1-10/c}$ since $c>22$. Now, suppose $t$'s initial gadget is the ordering gadget. Then, by Claim~\ref{claim:oneofeach}, every token in the core of a segment $S$ whose initial gadget is $t$'s \emph{final} gadget reaches the root for the first time during $\mathcal{I}'$. By Lemma~\ref{lem:exchange}, during interval $\mathcal{I}'$, a set $S'$ of at least $|C(S)|-k^{1/2+3/c}$ tokens with the same final gadget as $t$ enter this gadget for the last time. That is, at the beginning of interval $\mathcal{I}'$, no token in $S'$ had yet entered their final gadget for the last time. Then, by the contrapositive of Lemma~\ref{lem:indest}, at the beginning of interval $\mathcal{I}'$, at least $|C(S)|-k^{1/2+3/c}-k^{1/2+2/c}$ of the tokens in $S'$ had not yet exited the ordering gadget for the first time, and thus first exited the ordering gadget during interval $\mathcal{I}'$. This completes the proof since by Lemma~\ref{lem:noncore}, $|C(S)|-k^{1/2+3/c}-k^{1/2+2/c}>k^{1-9/c}-k^{1/2+3/c}-k^{1/2+2/c}>k^{1-10/c}$ since $c>24$. \end{proof} Now we are ready to complete the proof of Lemma~\ref{lem:LeafLeaving} by deriving the contradiction that $t$ has become out of order with a large set of tokens. When interval $\mathcal{I}'$ both begins and ends, $t$ is at the root. By Claim~\ref{claim:slotfromt}, during interval $\mathcal{I}'$, a set $S$ of at least $k^{1-10/c}$ tokens that all have the same initial and final gadget as $t$ exit their initial gadget for the first time and enter their final gadget for the last time. This immediately implies that at the beginning of interval $\mathcal{I}'$, every token in $S$ is in its initial gadget (which is the same as $t$'s initial gadget), and at the end of interval $\mathcal{I}'$, every token in $S$ is in its final gadget (which is the same as $t$'s final gadget). Thus, for every token $s\in S$, $t$ is out of order with $s$ either at the beginning or the end of interval $\mathcal{I}'$. Thus, either at the beginning or the end of interval $\mathcal{I}'$, $t$ is out of order with at least $|S|/2\geq k^{1-10/c}/2$ tokens. Since $c>24$, this contradicts Lemma~\ref{lem:OutOfOrder}, which says that $t$ can only be out of order with at most $k^{1/2+2/c}$ tokens at any given point in time. \end{proof} \paragraph{Proof of Lemma~\ref{lem:free-item-token}}\label{sec:Item and Segment Swap}$ $\\ We begin with Lemma~\ref{lem:free-item-token}(1): \emph{At any point in time, apart from the free item token, there is exactly one item token in each slot gadget.} \begin{proof}[Proof of Lemma~\ref{lem:free-item-token}(1)] By Lemma~\ref{lem:LeafLeaving}, at all times, each slot gadget contains at least one item token. It remains to show that if the free item token is in a slot gadget $i$, then there is another item token in slot gadget $i$. Consider the token $t$ that was in slot gadget $i$ the last time the free item token $f$ was at the root. We claim that $t$ is still in slot gadget $i$. This is because if $t$ has left slot gadget $i$ then $t$ has passed through the root, which would mean that $t$ is the free item token instead of $f$ (since we were considering the \emph{last} time $f$ was at the root). \end{proof} Because any token must pass through the root when moving from one slot gadget to another, Lemma~\ref{lem:free-item-token}(1) immediately implies the following corollary: \begin{corollary} When the free item token changes from an item token $f$ to another item token $f'$, $f$ is in the slot gadget that $f'$ was just in. \end{corollary} Now we move to Lemma~\ref{lem:free-item-token}(2): \emph{The exchange sequence $\chi$ is a subsequence of the sequence of swaps given as input to the Star STS instance.} Towards proving this, we show in the following claim that there is a direct correspondence between the free item token changing and segments leaving a slot gadget. \begin{claim}\label{lem:ItemSwap} Suppose the free item token changes from item token $f$ to item token $f'$, and let $i$ be the slot gadget containing $f$ when this happens. Then, while $f$ was the free item token, at least $k(1-\frac{1}{3n})$ slot tokens that were initially in slot gadget $i$ reached the root for the first time. \end{claim} \begin{proof} This proof has a similar idea to the proof of Claim~\ref{claim:up} (but is less involved). Let $v$ be the vertex in slot gadget $i$ of distance exactly $k(1-\frac{1}{4n})$ from the root (this is the same definition of $v$ as in the previous section). By Lemma~\ref{lem:LeafLeaving}, when $f'$ becomes the free item token, $f$ is at $v$ or to the right of $v$. Previously, when $f$ became the free item token, $f$ was at the root. Thus, while $f$ was the free item token, $f$ moved from the root to $v$. Let $\mathcal{S}$ be the set of swaps that $f$ performed while traveling from the root to $v$, taking the last such swap that $f$ performs for each edge between the root and $v$; thus, $|\mathcal{S}|=k(1-\frac{1}{4n})$. Let $S'$ be the set of tokens that swap with $f$ during swaps in $\mathcal{S}$. By Claim~\ref{lem:unique}, $|S'|=k(1-\frac{1}{4n})$. First, we will show that many of the tokens in $S'$ were initially in slot gadget $i$. Less than $k^{1/2+1/c}$ of the tokens in $S'$ do not have slot gadget $i$ as their initial or final gadget, because otherwise it requires $k^{2(1/2+1/c)}/2$ contrary moves to get these tokens into slot gadget $i$ to the position of the swap in $\mathcal{S}$, or to get them back out of slot gadget $i$ (since each token in $S'$ swaps with $f$ along a distinct edge). Further, note that if a token $s\in S'$ has its final position in slot gadget $i$, then during its swap with $f$, $s$ is performing a contrary (left) move, which is not in $\mathcal{M}$ by Corollary~\ref{obs:interface}(\ref{int5}). Thus, less than $k^{1/c}$ of the tokens in $S'$ have final position in slot gadget $i$. Therefore, we have shown that a set $S''\subseteq S'$ of at least $k(1-\frac{1}{4n})-k^{1/2+1/c}-k^{1/c}$ tokens were initially in slot gadget $i$. Now, we will show that many of the tokens in $S'$ reached the root for the first time while $f$ was the free item token. By Lemma~\ref{lem:LeafLeaving}, once $f$ became the free item token and until $f$ reached $v$, $f'$ was in slot gadget $i$ at $v$ or to the right of $v$. Thus, right after $f$ swaps with each token $s\in S'$, $s$ is to the left of $f'$. We claim that after $f$ reaches $v$, there are never more than $k^{1/2+1/c}$ tokens in $S''$ simultaneously to the right of $v$. This is because right moves are contrary moves for these tokens (since they were initially in slot gadget $i$) so having $k^{1/2+1/c}$ of these tokens to the right of $v$ would incur $k^{2(1/2+1/c)}/2>k^{1+1/c}$ contrary moves. In particular, when $f'$ reaches $v$ for the last time before becoming the free item token, no more than $k^{1/2+1/c}$ tokens in $S''$ are to the right of $f$. For each token $s\in S''$ that is \emph{not} to the right of $f$ at this point in time, note that $s$ either reaches the root before $f'$ or swaps with $f'$. Less than $k^{1/c}$ such tokens $s$ swap with $f'$ since in this case, $s$ performs a contrary (right) move that is not in $\mathcal{M}$ by Corollary~\ref{obs:interface}(\ref{int5}). Thus, we have shown that at least $|S''|-k^{1/2+1/c}-k^{1/c}$ tokens in $S''$ have reached the root while $f$ is the free item token. It remains to show that enough of these tokens reach the root \emph{for the first time} while $f$ is the free item token. We know that at most $k^{1/2+1/c}$ of the tokens in $S''$ reached the root for the first time before $f$ became the free item token because getting all of these tokens to their positions to swap with $f$ would require more than $k^{2(1/2+1/c)}/2>k^{1+1/c}$ contrary moves. Thus, we have shown that at least $|S''|-2k^{1/2+1/c}-k^{1/c}$ tokens in $S''$ reach the root for the first time while $f$ is the free item token. This quantity of tokens is at least $k(1-\frac{1}{4n})-3k^{1/2+1/c}-2k^{1/c}>k(1-\frac{1}{3n})$. \end{proof} Now we are ready to prove Lemma~\ref{lem:free-item-token}(2). \begin{proof}[Proof of Lemma~\ref{lem:free-item-token}(2)] Let $s_1,\dots,s_n$ be the input sequence for the Star STS instance. We begin by recalling the correspondence between $s_1,\dots,s_n$ and our token swapping solution. Recall from the construction that there is a direct correspondence between $s_1,\dots,s_n$ and the big segments $y_1,\dots,y_n$ in the sense that if $s_j=g$ then $y_j$ is initially in slot gadget $g$. Further recall that in the scaffold solution, the big segments reach the root in the order $y_1,\dots,y_n$. By Lemma~\ref{lem:segbyseg}, in our token swapping solution the vertices in the \defn{core} of the big segments reach the root for the first time in the same order as in the scaffold solution. That is, in the order $C(y_1),\dots,C(y_n)$. We will refer to this property as the \defn{core property}: {\bf The core property:} For all $i,j$ with $i<j$, every token in $C(y_i)$ reaches the root for the first time before any token in $C(y_j)$ does so. We will maintain a counter $\Lambda$ that intuitively keeps track of where we are up to in the sequence $s_1,\dots,s_n$. We will iterate through the exchange sequence $\chi=\chi[1],\chi[2],\dots$ from beginning to end, and for each element $\chi[i]$, we will increase $\Lambda$ by at least 1 to a new value $i$ such that $s_j=\chi[i]$. It is straightforward to see that if we can successfully maintain such a counter, then $\chi$ is a subsequence of $s_1,\dots,s_n$. Now we will define the rule for updating $\Lambda$. For each $\chi[i]$, let $p_i$ be the corresponding point in time when the token that was just in slot gadget $\chi[i]$ becomes the free item token (and let $p_0$ be the time initially). At each $p_i$, we will update $\Lambda$; let $\Lambda(i)$ be the value that we set $\Lambda$ to at $p_i$. {\bf Rule for updating $\Lambda$:} $\Lambda(0)=0$ and for all $i\geq 1$, set $\Lambda(i)$ to be the smallest $j>\Lambda(i-1)$ such that before $p_i$ at least one token from $C(y_j)$ reaches the root for the first time, where $y_{j}$ is initially in slot gadget $\chi[i]$. Note that the requirement that $y_j$ is initially in slot gadget $\chi[i]$ is equivalent to the above requirement that $s_j=\chi[i]$ (due to the correspondence between $y_j$ and $s_j$ described above). Thus, given this rule for updating $\Lambda$, proving the following claim completes the proof of Lemma~\ref{lem:free-item-token}(2). \begin{claim} For all $i\geq 1$, there exists $j>\Lambda(i-1)$ such that before $p_i$, at least one token from the core of some big segment $y_{j}$ that was initially in slot gadget $\chi[i]$ reaches the root for the first time. \end{claim} \begin{proof} Fix $i\geq 1$. Suppose inductively that $\Lambda(i')$ exists for all $i'<i$. By the definition of how we update $\Lambda$, before $p_{i-1}$, at least one token from $C(y_{\Lambda(i-1)})$ has reached the root for the first time, and $y_{\Lambda(i-1)}$ is initially in slot gadget $\chi[i-1]$. By the core property, this means that before $p_{i-1}$, every token in the core of every big segment $y_{j'}$ with $j'<\Lambda(i-1)$ has reached the root for the first time. Now, we consider what happens between $p_{i-1}$ and $p_i$. By Claim~\ref{lem:ItemSwap}, between $p_{i-1}$ and $p_i$, a set $S$ of at least $k(1-\frac{1}{3n})$ tokens that were initially in slot gadget $\chi[i]$ reach the root for the first time. We analyze the composition of the tokens in $S$. Since $S$ contains only tokens that reached the root for the first time after $p_{i-1}$, $S$ contains no tokens in the core of any big segment $y_{j'}$ with $j'<\Lambda(i-1)$. By Lemma~\ref{lem:noncore}, less than $k^{1/2+5/c}$ tokens in $S$ are not in the core of any segment. Also, at most $\frac{k}{n^7}$ tokens in $S$ are in a padding segment since there are $n$ padding segments in each slot gadget and each one is of length $\frac{k}{n^8}$. The remainder of the tokens in $S$ are in the core of a big segment $y_{j'}$ with $j'\geq \Lambda(i-1)$. Thus, letting $\beta=k^{1/2+5/c}+\frac{k}{n^7}$, we have that $S$ contains at least $|S|-\beta$ tokens that are in cores of big segments $y_{j'}$ with $j'\geq \Lambda(i-1)$. This does not suffice, however, because we are trying to identify a token in $S$ in the core of a big segment $y_{j'}$ with $j'> \Lambda(i-1)$, where the inequality is strict. If $i=1$, then $\Lambda(i-1)=0$ so it is trivially true that any big segment $y_{j'}$ has $j'>\Lambda(i-1)$. If $i>1$, then we need to bound the number of tokens in $S$ that are in $C(y_{\Lambda(i-1)})$. If $\chi[i]\not=\chi[i-1]$, then $S$ contains no tokens in $y_{\Lambda(i-1)}$ since $y_{\Lambda(i-1)}$ was initially in slot gadget $\chi[i-1]$ while every token in $S$ was initially in slot gadget $\chi[i]$. Thus, we are concerned with the case where $\chi[i]=\chi[i-1]$. Let $\ell\geq 1$ be the largest integer such that $\chi[i]=\chi[i-1]=\dots =\chi[i-\ell]$. Then by Claim~\ref{lem:ItemSwap}, between $p_{i-\ell-1}$ and $p_{i}$, a set $S'$ of at least $(\ell+1) k(1-\frac{1}{3n})$ tokens that were initially in slot gadget $\chi[i]$ reach the root for the first time. To complete the proof, we will show that at least one token in $S'$ is in the core of a big segment $y_{j'}$ with $j'> \Lambda(i-1)$. We can analyze the composition of $S'$ in the same way as we analyzed the composition of $S$ previously. $S'$ contains no tokens in the core of any big segment $y_{j'}$ with $j'<\Lambda(i-\ell-1)$. Also $S'$ contains at least $|S'|-\beta$ tokens that are in the core of a big segment $y_{j'}$ with $j'\geq \Lambda(i-\ell-1)$. Since $\chi[i-\ell]\not=\chi[i-\ell-1]$, $S'$ contains no tokens in $y_{\Lambda(i-\ell-1)}$. Thus, the number of tokens in $S'$ that are in the core of a big segment $y_{j'}$ with $j'> \Lambda(i-\ell-1)$ is at least \begin{align}\label{eqn} |S'|-\beta&\geq (\ell+1) k(1-\frac{1}{3n})-\beta\notag\\ &= \ell k+k-\frac{\ell k}{3n}-\frac{k}{3n}-\beta\notag\\ &\geq \ell k +k -\frac{k}{3}-\frac{k}{3n} -\beta \text{\hspace{5mm} since $\ell\leq n$}\notag\\ &=\ell k +\frac{2k}{3}-\frac{k}{3n} -k^{1/2+5/c}-\frac{k}{n^7}\notag\\ &\geq \ell k+1. \end{align} By the core property, the tokens in $S'$ that are in the core of big segments come from big segments whose initial positions are \emph{consecutive} within slot gadget $\chi[i]$. Let $y^*$ be the big segment with the smallest index larger than $\Lambda(i-\ell-1)$ out of the big segments that were initially in slot gadget $\chi[i]$. Since $S'$ contains no tokens in the core of any big segment $y_{j'}$ with $j'<\Lambda(i-\ell-1)$, $y^*$ is the lowest indexed big segment for which $S'$ could contain tokens from its core. If $S'$ contains any token in $C(y^*)$, then Equation~(\ref{eqn}) implies that $S'$ contains the entire core of the next $\ell-1$ consecutive big segments initially in slot gadget $\chi[i]$, as well as at least one token from the core of the next big segment $y^{**}$ from slot gadget $\chi[i]$ directly after (to the right of in the initial configuration) these $\ell-1$ consecutive big segments. Since $y^*$ is the lowest indexed big segment for which $S'$ could contain tokens from its core, if $S'$ does not contain a token in $C(y^*)$, then $S'$ still contains at least one token from the core of some big segment with index at least that of $y^{**}$. Together, the core property and the fact that the rule for updating $\Lambda$ chooses the \emph{smallest} such $j$ imply that $y_{\Lambda(i-\ell)},\dots,y_{\Lambda(i-1)}$ are big segments whose initial positions are consecutive within slot gadget $\chi[i]$. Furthermore, $\Lambda(i-\ell)$ is set to be the minimum value larger than $\Lambda(i-\ell-1)$ such that $y_{\Lambda(i-\ell)}$ is initially in slot gadget $\chi[i]$. That is, $y_{\Lambda(i-\ell)}=y^*$. Then, because $y_{\Lambda(i-\ell)},\dots,y_{\Lambda(i-1)}$ are consecutive big segments initially in slot gadget $\chi[i]$, we have that $y^{**}=y_{j'}$ for $j'>\Lambda(i-1)$. We have shown that $S'$ contains at least one token from the core of some big segment with index at least that of $y^{**}$. Thus, $S'$ contains at least one token from the core of some big segment $y_{j'}$ with $j'>\Lambda(i-1)$, which completes the proof. \end{proof} Therefore we have proved Lemma~\ref{lem:free-item-token}(2). \end{proof} } \section{Weighted sequential token swapping on trees is NP-hard} \label{sec:NP-hard-weighted} In this section, we prove that weighted token swapping on a tree is NP-hard, even when the token weights are in $\{0,1\}$. Our purpose is to introduce the general idea that is used in our main NP-completeness proof for the unweighted case given in Section~\ref{sec:NP-hard-unweighted}. We first precisely define the decision problem \defn{weighted sequential token swapping on trees} \cite{tree-token-swapping}, abbreviated in this section to \defn{weighted token swapping}. The input is: a tree on $n$ vertices with distinct initial positions (vertices) and distinct target positions for the $n$ tokens; non-negative integer weights on the tokens; and a maximum cost~$K$. The cost of a swap is the sum of the weights of the two tokens involved. The decision problem asks whether there is a sequence of swaps that moves all the tokens to their target positions and such that the sum of the costs of the swaps is at most~$K$. It is not clear whether the weighted token swapping problem lies in NP; however, it is in NP if $K$ is given in unary.\footnote{Consider % a minimum length swap sequence of weight at most $K$. The number of swaps involving a nonzero weight token is at most % $K$. Because the sequence has minimum length, it can be shown that no two zero-weight tokens swap more than once, see~Lemma~\ref{lem:unique}. Thus the sequence has length at most $K + n^2$ and provides a polynomial sized certificate, showing that the problem is in NP. } We prove that weighted token swapping is NP-hard when $K$ is given in unary. The reduction is from Star STS. In order to distinguish tokens and vertices in the original star from those in the tree that we construct, we will call the tokens of the Star STS instance \defn{items} and we will call the leaves \defn{slots}. Then the instance of Star STS consists of: a star with center 0 and slots $1, \ldots, m$, each of which initially has an item of its same label; a permutation $\pi$ of the items; and a sequence $s_1, \ldots, s_{n}$ of slots that specify the allowed swaps. Figure~\ref{fig:plan}(a) shows an example input for $m=4$ slots and $5$ items and a sequence of length $n=7$. \begin{theorem} \label{thm:weighted-NP-hard} Weighted token swapping on trees in NP-hard. \end{theorem} \begin{proof} Suppose we are given an instance of Star STS as described above. We may assume without loss of generality that every slot appears in the sequence (otherwise remove that slot from the problem) and that no slot appears twice in a row in the sequence. \begin{figure}[bt] \centering \includegraphics[width=.95\textwidth]{Figures/plan-horizontal.pdf} \caption{ (a) An instance of Star STS with $m=4$ slots and a sequence of length $n=7$; notation $a[b]$ indicates that token $a$ is initially at this vertex and token $b$ should move to this vertex. This instance has no solution because item 4 should move to slot 3, which is possible only if slot 3 appears after slot 4 in the sequence. (b) The corresponding instance of weighted token swapping with the ordering gadget on the left and $m=4$ slot gadgets attached to the root, each with a nook vertex shown in red. After swapping item token $0$ at the root with token $y_1$ in the first (bottom) slot gadget there is an opportunity to swap tokens $0$ and $1$ for free along the nook edge of the first slot gadget, before moving $y_1$ to its target position at the end of the ordering gadget and moving $x_1$ to its target position at the end of the first slot gadget. } \label{fig:plan} \end{figure} Construct a tree with a root, an \defn{ordering gadget} which is a path of length $n$ attached to the root, and $m$ \defn{slot gadgets} attached to the root. Slot gadgets are defined below. See Figure~\ref{fig:plan}(b) where the ordering gadget of length $n=7$ appears on the left and there are $m=4$ slot gadgets attached to the root. We picture the tree with the root in the middle, and use directions left/right as in the figure. Let $n_i$ be the number of occurrences of slot $i$ in the input sequence. Observe that $\sum_{i=1}^m n_i = n$. \defn{Slot gadget} $i$ consists of a path of $n_i$ vertices, plus an extra leaf attached to the leftmost vertex of the path. This extra leaf is called the \defn{nook} of the slot gadget. The $m$ nooks and the root are in one-to-one correspondence with the slots and the center of the original star (respectively), and we place \defn{item tokens} at these vertices whose names, initial positions, and final positions correspond exactly to those of the items of the input star. These item tokens are given a weight of 0. There are $2n$ additional \defn{non-item tokens} $x_1, \ldots, x_{n}$ and $y_1, \ldots, y_{n}$. These all have weight 1. The $x_j$'s are initially placed along the ordering gadget path, in order, with $x_1$ at the right and $x_{n}$ at the left. The ordering path is also the target position of the $y_j$'s in reverse order with $y_1$ at the left and $y_{n}$ at the right. Suppose slot $i$ appears in the sequence as $s_{j_1}, s_{j_2}, \ldots, s_{j_{n_i}}$ with indices in order $j_1 < j_2 < \cdots < j_{n_i}$. Then tokens $y_{j_1}, y_{j_2}, \ldots, y_{j_{n_i}}$ are initially placed along the path of slot gadget $i$, in order with smallest index at the left. The path of slot gadget $i$ is also the target position of the tokens $x_{j_1}, x_{j_2}, \ldots, x_{j_{n_i}}$ in reverse order with smallest index at the right. Consider, for each non-item token $x_j$ or $y_j$, the distance from its initial location to its target location. This is a lower bound on the cost of moving that token. We set the max cost $K$ to the sum of these lower bounds. This guarantees that every $x_j$ or $y_j$ only travels along its shortest path. Observe that this reduction takes polynomial time. We now prove that a YES instance of Star STS maps to a YES instance of token swapping and vice versa. \medskip\noindent {\bf YES instance of Star STS.} Suppose the Star STS instance has a solution. The ``intended'' solution to the token swapping instance implements each $s_j$ for $j=1, \ldots, n$ as follows. Suppose $s_j = i$. By induction on $j$, we claim that token $y_j$ will be in the leftmost vertex of slot gadget $i$ when it is time to implement $s_j$. Swap token $y_j$ with the item token $t$ currently at the root. Then item token $t$ has the opportunity to swap for free with the item token in nook $i$. We perform this free swap if and only if swap $s_j$ was performed in the solution to Star STS. Next, swap tokens $y_j$ and $x_j$---we claim by induction that $x_j$ will be in the rightmost vertex of the ordering gadget. Finally, move token $y_j$ to its target position in the ordering gadget, and move $x_j$ to its target position in slot gadget $i$. It is straightforward to verify the induction assumptions. Every $x_j$ and $y_j$ moves along its shortest path so the cost of the solution is equal to the specified bound $K$. \smallskip\noindent {\bf YES instance of weighted token swapping.} Suppose the weighted token swapping instance has a solution with at most $K$ swaps. Because $K$ is the sum of the distances of the non-item tokens from their target positions, each $x_j$ and $y_j$ can only move along the shortest path to its target position. Token $x_j$ must move into the root before $x_{j+1}$, otherwise they would need to swap before that, which means moving $x_j$ the wrong way along the ordering gadget path. Similarly, $y_j$ must move into the root before $y_{j+1}$, otherwise they need to swap after that, which means moving $y_{j+1}$ the wrong way. Furthermore, $x_j$ must move into the root before $y_{j+1}$ otherwise the ordering gadget would contain $x_j, \ldots, x_{n}$, and $y_1, \ldots, y_j$, a total of $n+1$ tokens, which is more tokens than there are vertices in the ordering gadget. We also claim that $y_j$ must move into the root before $x_{j+1}$. First note that the nooks can only contain item tokens, since no $x_j$ or $y_j$ can move into a nook. This accounts for every item token except for one ``free'' item token. Now suppose $x_{j+1}$ moves into the root before $y_j$. Then the ordering gadget contains $x_{j+2}, \ldots, x_{n}$, and $y_1, \ldots, y_{j-1}$, a total of $n-2$ tokens. Even if the free item token is in the ordering gadget, this is not enough tokens to fill the ordering gadget. Thus the $x_j$'s and $y_j$'s must use the root in order, first $x_1$ and $y_1$ in some order, then $x_2$ and $y_2$ in some order, etc. Finally, we examine the swaps of item tokens. A swap between two item tokens can only occur when the free item token is at the parent of a nook. Suppose this happens in slot gadget~$i$. Then some token $y_j$ must have left the slot gadget, and the corresponding token $x_j$ has not yet entered the slot gadget, which means that neither of the tokens $y_{j+1}$ or $x_{j+1}$ has moved into the root. This implies that any swap of item tokens is associated with a unique $s_j = i$, and such swaps must occur in order of $j$, $1 \le j \le n$. Thus the swaps of item tokens can be mimicked by swaps in the original Star STS sequence, and the Star STS instance has a solution. \end{proof} \section{Parallel token swapping on trees is NP-complete} \label{sec:parallel} The parallel token swapping problem is like sequential token swapping, except that swaps that do not involve the same token can occur simultaneously ``in parallel''. In particular, time is measured in rounds where in each round a matching of adjacent tokens is selected and all of those swaps then occur simultaneously during that round. Instead of asking how many swaps are required to bring the tokens to their target destinations, we now ask how many rounds are needed. Precisely, in the \defn{parallel token swapping} problem, the input consists of a graph $G$, an integer $K$, and a permutation $\pi$ on the vertices of $G$. Place a unique token on every vertex of $G$. During a \defn{round}, we choose a matching in $G$ and then for every edge in the matching, \defn{swap} the tokens at the endpoints. In the \defn{parallel token swapping} problem, the goal is to determine whether it is possible to rearrange the tokens via a sequence of $K$ rounds such that for every vertex $v$ in $G$, the token starting in $v$ ends in $\pi(v)$. In this section, we will prove that the parallel token swapping problem remains hard even when the input graph is restricted to be a particular type of tree: a subdivided star. A \defn{subdivided star} is a graph consisting of any number of paths all joined at a single endpoint which we will call the \defn{root}. See Figure~\ref{figure:star_example} for an example. We will prove this by reducing from Star STS. As in previous sections, since we are reducing from a token swapping problem to another token swapping problem, we will introduce a difference in terminology: as before, we will call the tokens from the Star STS instance \defn{items}, and we will call the leaves of the graph in the Star STS instance \defn{slots}. \begin{figure}[!htb] \centering \includegraphics[scale=.4]{Figures/star_example} \caption{An example of a subdivided star} \label{figure:star_example} \end{figure} In Section~\ref{sec:parallel-intuition}, we will lay out the intuition behind the reduction. Then in Section~\ref{sec:parallel-reduction}, we will formally describe the reduction. Next, in Section~\ref{sec:parallel-forward} we will show how to solve the parallel token swapping instance produced by the reduction when the input Star STS instance was possible to solve. Finally, in Section~\ref{sec:parallel-backward} we will show the reverse direction: that any solution to a parallel token swapping instance produced by the reduction can be used to construct a solution to the input Star STS instance. Together, these last two sections combine to prove that the reduction is answer-preserving, allowing us to conclude: \begin{theorem} \label{thm:parallel-NP-hard} Parallel token swapping on trees in NP-hard. \end{theorem} \subsection{Proof idea} \label{sec:parallel-intuition} The most basic concept of this reduction is the same as the prior reduction for Token Swapping on trees. We represent each item in the Star STS instance with a token in the parallel token swapping instance (an item token) and associate some of the branches of the subdivided star (slot branches) with the slots of the Star STS graph. If an item is located at the root of the star, then the corresponding item token will be located at the root of the subdivided star. If an item token is located in a slot, then the corresponding item token will be located somewhere in the corresponding slot branch. In order to make that basic idea work, we need to be able to control which tokens can pass through the root and at which time. We want to restrict the possible transitions of an item token through the root rather than allow arbitrary traversal of the root. Using the root as a bottleneck for tokens swapping into their target branch will be a keystone idea in the proof. For this purpose, we introduce a second set of tokens, which we call \defn{enforcement tokens}. The enforcement tokens will enforce the behavior of the swaps near the root by creating ``congestion'' at the root. This will be achieved by placing the enforcement tokens a distance $K$ away from their targets, forcing the enforcement tokens to take the shortest path to their destination and thus needing to swap into the root at specific times. Each enforcement token will start at some distance $d$ from the root and end at distance $K-d$ from the root in a different branch. The token's destination is a distance of $K$ from its starting location, so therefore the enforcement token will have to move one step towards its target location every round in order to reach its destination by the $K$ round deadline. In particular, during round $d$ the token will swap into the root from its starting branch and during round $d+1$ the token will swap out of the root into its destination branch. Since the root vertex can only be involved in one swap on any given round, these swaps are going to be the only swaps involving the root during rounds $d$ and $d+1$. We want the root to have a swap involving an enforcement token at every round, so we can create one enforcement token, call it $e_1$, with $d=1$, another ($e_3$) with $d=3$, another ($e_5$) with $d=5$, and so on up to a final enforcement token, $e_{K-1}$, with $d=K-1$. This will make it so that there is a forced swap involving the root vertex during every single round (rounds $1$ and $2$ due to $e_1$, rounds $3$ and $4$ due to $e_3$, etc...). So let's say we set this up exactly like that. When can an item token (or any other non-enforcement token) pass through the root? There is a swap involving an enforcement token and the root during every round, so a token can pass through the root only if it is swapping with an enforcement token. An enforcement token enters the root every odd numbered round and exits every even numbered round. Therefore a token could be able to enter the root on some round $2t$ while enforcement token $e_{2t-1}$ is exiting the root and then exit the root on round $2t+1$ while enforcement token $e_{2t+1}$ is entering the root. If this occurs, however, the token must start in the branch that is the destination branch of token $e_{2t-1}$ and end in the branch that is the source branch of token $e_{2t+1}$. Therefore, not only have we restricted the possible traversals through the root, we also have a way to fine tune exactly which branches we allow swaps between and when by setting the source and destination branches of the enforcement tokens. Unfortunately, setting things up this way also gives us an additional constraint: for each branch, it cannot be the case that an enforcement token leaves that branch after another enforcement token enters the branch. The problem is that the two tokens, each on its own inexorable path towards its destination will end up colliding inside the branch. Two enforcement tokens can never swap with each other due to a parity argument (all enforcement tokens always have the same parity of distance from the root, as they all swap into the root on even numbered rounds), so there is no way for the two tokens to pass each other. In other words, if the constraint is violated then a solution to the parallel token swapping instance will be impossible. The constraint that all enforcement tokens leave a branch before any other enforcement tokens enter is equivalent to the constraint that all non-enforcement tokens that are going to enter a branch do so before any non-enforcement tokens leave the branch. This seems like a problem. How can we use a branch to represent a slot if the branch has the constraint that item tokens never enter after other item tokens have exited? After all, in Star STS, slots are used and re-used repeatedly. The solution to this problem is the second key idea of the reduction. Unlike in the sequential token swapping case, we will allow the correspondence between slots and branches to change over time. At any given time a particular branch will represent a slot, but which branch represents that slot can change. This makes it so that we don't have to keep returning tokens into the same branches again after tokens have already left the branch; instead, we just move those tokens into new branches and re-label the correspondence between branches and slots. So how do we actually position the start and end branches of the enforcement tokens so that the desired swaps between item tokens are possible? We will use 8 rounds for every swap. If we are trying to swap some slot $s$, here's the effect of these 8 rounds on the non-enforcement tokens: \begin{enumerate} \item the item token at the root moves into a branch $w$ dedicated to this swap \item the item token in the branch $b_s$ currently associated with slot $s$ moves into the root \item the item token now at the root moves into branch $w$; there are now two item tokens in branch $w$ \item some non-enforcement token moves into the root \item the token at the root moves into another branch (these two swaps provide an extra rounds in which the optional swap of the item tokens can occur) \item an item token from $w$ moves into the root \item the item token at the root moves into a new branch $b_s'$, which as the name suggests will become the new branch associated with slot $s$ \item the remaining item token in $w$ moves into the root \end{enumerate} Of course, to achieve these effects we set the start and destination branches of the enforcement tokens, rather than setting the start and destination branches of the item tokens as described in the list, since the latter is not something we can directly control. Notice that during rounds 4 and 5 in the above list, there are two item tokens in branch $w$: the item token that was at the root and the one which was in branch $b_s$ (corresponding with the item in slot $s$). During these rounds, the two tokens can (optionally) swap. Then the rest of the rounds move these two item tokens into their two new locations: branch $b_s'$ and the root. In other words, depending on which token ends up where, there may have been a swap. Since we can simulate a swap, we can just use the target locations of the item tokens to encode the target permutation of the items. The only remaining question is what to do about all the other tokens we haven't introduced. For this we bring back the concept of the scaffold solution. We know that certain swaps, the swaps of the enforcement tokens, are forced. Therefore, we can consider what happens if we do only those swaps; that is the scaffold solution. Now consider what happens if we place a token on every vertex, and then go through the scaffold solution. The enforcement tokens will all reach their destinations. The item tokens might end up shuffled among themselves (relative to where they should end up), but as a group of tokens, the item tokens will end up occupying exactly the group's target locations. Then for all non-item non-enforcement tokens, we can just set the target destination to be whatever the destination ends up under the scaffold solution. \subsection{Reduction} \label{sec:parallel-reduction} Suppose we have a Star STS instance consisting of: a star with center 0 and slots $1, \ldots, m$, each of which initially has an item of its same label; a permutation $\pi$ of the items; and a sequence $s_1, \ldots, s_n$ of slots that specify the allowed swaps. We will construct a parallel token swapping instance consisting of: the round limit $K$, a subdivided star, and a permutation $\pi$ of the vertices indicating for every vertex $v$ the target location $\pi(v)$ for the token that starts at $v$. For the parallel token swapping construction we will generally use a superscript to refer to the index of the branch and a subscript to refer to a distance from the root. For example, we might discuss the $i^{th}$ branch $b^i$ or the vertex $b^i_j$ which is in branch $i$ and a distance of $j$ away from the root. \subsubsection{Time limit \texorpdfstring{$K$}{K} and the subdivided star} As described in the proof idea section, each swap in the Star STS instance will be represented by $8$ rounds in the Parallel Token Swapping instance. Therefore, we set $K = 8n$. For the subdivided star, we will use the root $r$, together with a total of $n+(m+n)+2$ branches, each of length $K$. For each branch $b$, we will refer to the vertices of the branch starting from the end closest to the root as $b_1, b_2, \ldots, b_K$. These are also shown in Figure~\ref{fig:ParallelTokenOverview}. \begin{itemize} \item $n$ of these branches are \defn{swap branches} $w^t$ for $t=1,\ldots,n$. Each swap branch will be used for one of the swaps to temporarily hold the two swapping item tokens together (so that they can optionally swap). \item $m+n$ of the branches are \defn{slot branches} $s^i$ with $i = 1, 2, \ldots, m+n$. Obviously there are more slot branches than slots, but this is because not every slot branch will represent a specific slot at any given time. Rather, at any given time, $m$ of the branches will be \defn{active}, and those will be the branches which currently represent a slot. Since a swap needs a new branch to occur, we need an additional $n$ branches some of which will only temporarily represent a specific slot. More details on how the mapping will change over time are given in the next section. \item The final two branches are \defn{garbage branches} $g$ and $g'$. Tokens will move between these branches as a way of wasting time. \end{itemize} \begin{figure} \centering \includegraphics[scale=.5]{Figures/ParallelTokenOverview.pdf} \caption{The overall structure of the Parallel Token Swapping instance. Each branch is labeled with its name on the right, and each vertex initially containing an item token is labeled with the name of that token.} \label{fig:ParallelTokenOverview} \end{figure} All that's left is to define the permutation $\pi$. We will do this a piece at a time by considering the three types of tokens described in the proof idea section: item tokens, enforcement tokens, and the remaining, non-item non-enforcement, tokens, which we will refer to as \defn{filler tokens}. \subsubsection{Item tokens} Before considering the item tokens, we first turn our attention to the active branches. We define a function $a$ that tells us which branches are active at any time. In particular, if $1 \le i \le m$ and $0 \le t \le n$ then $a(i, t)$ is defined such that $s^{a(i,t)}$ is the slot branch which represents slot $i$ at time $t$. We say that, at time $t$, $\{s^{a(i, t)} \mid 1\le i \le m\}$ are the active slot branches and the other slot branches are inactive. At time $t=0$, slot branches $1$ through $m$ will represent slots $1$ through $m$, and so $a(i, 0) = i$. Then for every $t > 0$, we define $a(\cdot, t)$ recursively. In particular, during swap $t$, the slot branch that used to represent slot $s_t$ becomes inactive and instead slot branch $m+t$ becomes active in order to represent that slot. In other words, $a(i, t) = a(i, t-1)$ for $i \ne s_t$ and $a(s_t, t) = m+t$. With that done, we can define the initial and final positions of the item tokens. There are $m+1$ item tokens, which we refer to as $0, 1, \ldots, m$, named after their corresponding items. Item $0$ starts at the root of the star, so we will initially place item token $0$ at the root $r$. Each other item $i$ starts in slot $i$, so we will initially place the corresponding item token $i$ in the active branch (at time $t=0$) representing slot $i$ next to the root. In other words, we place item token $i$ at vertex $s^{a(i, 0)}_1=s^i_1$. For the final positions, consider the item which, according to $\pi$, should end up at the root of the star. We give this item token a final destination of $r$. For every other item $i$, the item is supposed to end up in slot $\pi(i)$. Therefore, we give the corresponding item token $i$ a final destination which is in the active branch (at time $t=n$) representing slot $\pi(i)$ next to the root. In other words, we give item token $i$ a final destination of $s^{a(\pi(i), n)}_1$. Notice that since the initial branches assigned to each item token are disjoint (with the exception of one item token starting at the root, which is not assigned an initial branch at all), each item token is given a unique start location. Similarly, the final locations of the item token ends are in disjoint branches (with the exception of one item token at the root), so each item token is given a unique end location. \subsubsection{Enforcement Tokens} Now we will describe the \defn{enforcement tokens}. There will be $\frac{K}{2}$ enforcement tokens $e_1, e_3, \ldots, e_{K-1}$. Enforcement token $e_d$ will start in some branch $x^d$ at distance $d$ from the root and end in some other branch $y^d$ at distance $K-d$ from the root. In other words, the token will start at vertex $x^d_d$ and end at vertex $y^d_{K-d}$. All that's left to make these positions precise is to identify the start and end branches $x^d$ and $y^d$ for $d = 1, 3, \ldots, K-1$. Here is how these branches are assigned: For each $t$ with $1 \le t \le n$, we assign branches as follows \begin{itemize} \item $x^{8t-7} = w^t$ \item $y^{8t-7} = s^{a(s_t, t-1)}$ \item $x^{8t-5} = w^t$ \item $y^{8t-5} = g$ \item $x^{8t-3} = g'$ \item $y^{8t-3} = w^t$ \item $x^{8t-1} = s^{a(s_t, t)}=s^{m+t}$ \item $y^{8t-1} = w^t$ \end{itemize} Note that these 8 branches in this order are exactly the 8 branches from the proof idea section list of token movements through the root corresponding with a swap. It is simple to argue using the distance from the root that each enforcement token has a unique start location and a unique end location. Furthermore, we also wish to claim that no enforcement token shares a start location or an end location with an item token. Since item tokens start and end at distance $0$ or $1$ from the root, $e_1$ is the only enforcement token that could possibly share a start location with an item token and $e_{K-1}$ is the only enforcement token that could possibly share an end location with an item token. However, $e_1$ starts in branch $w^1$ and $e_{K-1}$ ends in branch $w^n$, neither of which are slot branches. No item token starts or ends in a non-slot branch, so we can conclude that the item and enforcement token start locations are all unique, as are their end locations. \subsubsection{Filler Tokens} \label{sec:Filler Tokens} For every vertex that does not initially contain an enforcement token or an item token, we place a filler token initially at that vertex. In order to identify the target destination for these tokens, we make use of the scaffold solution. Define the \defn{scaffold solution} to be a set of swaps for times $1 \le t \le K$. At every time $t$, we will include one swap for each enforcement token: the swap that brings that token one step towards its destination. \footnote{Note, scaffold solution only defines a subset of swaps which must occur based on the enforcement token. It is not based on an `intended solution' like the scaffold solution for the single swap reduction. Thus, although both set up a structure of moves which must be followed, they have somewhat different intuition and technical differences which should not be confused with each other. } We will later prove the following lemma: \begin{lemma} \label{lemma:parallel-scaffold-legal} The scaffold solution does not include any pair of simultaneous swaps that share a vertex. \end{lemma} Using this lemma and the fact that no two item or enforcement tokens share a start position, we can unambiguously execute the scaffold solution starting with the initial position of all the tokens. (Note that if we tried to execute a timeline of swaps including simultaneous swaps sharing a vertex, we would have an ambiguity; where would the token at that vertex go?). Define the target destination of each filler token to be the destination of that token when we execute the scaffold solution. We showed previously that every vertex is the start position of at most one item or enforcement token. Since we started a filler token in every vertex not starting with an item or enforcement token, we now have that every token has a unique starting position and that every vertex is the starting location of some token. What about ending locations? We saw previously that every item and enforcement token has a unique end location. In order to consider the end locations of the filler tokens we have to examine the behavior of the tokens under the scaffold solution. First of all, every enforcement token is clearly moved to its target location by the scaffold solution. This is because the moves included in the scaffold solution are exactly the ones that are necessary in order to move the enforcement tokens to their target destinations. For the item tokens, we use the following lemma: \begin{lemma} \label{lemma:parallel-scaffold-item} The scaffold solution brings each item token to a final location that is the target location of some item token (though not necessarily the token's own target destination). \end{lemma} Then we can ask the question of where the scaffold solution brings the filler tokens. The enforcement tokens each end up in their own target locations. The $m+1$ item tokens each end up in a target location of an item token, and since there are only $m+1$ such locations (and the scaffold solution certainly doesn't bring two item tokens into the same location), we can conclude that the $m+1$ item tokens end up in the $m+1$ item token target locations. Therefore the end locations of the filler tokens under the scaffold solution are exactly those vertices that are not target locations of item or enforcement tokens. Since the target location of a filler token is defined to be its end location under the scaffold solution, we can conclude that every token is assigned a unique target location. \subsubsection{Permutation \texorpdfstring{$\pi$}{σ}} Since we have defined the start and end positions of the three types of tokens, we can define the permutation $\pi$. For every vertex $v$, let $\pi(v)$ be the end location of the token that starts at $v$. Since every vertex has exactly one token starting there, this is well defined. Since no two tokens share an end location, this is a permutation. \subsubsection{Proof of Lemmas~\ref{lemma:parallel-scaffold-legal} and \ref{lemma:parallel-scaffold-item}} In Section~\ref{sec:Filler Tokens}, we left out the proofs of two lemmas. Provided that those two lemmas hold, the reduction is clearly well defined and furthermore can be computed in polynomial time. Thus, all that's left in order to conclude NP-hardness of parallel token swapping is to prove the lemmas, which we do here, and prove the answer-preserving property of the reduction, which we do in the following sections. \begin{proof}[Proof of Lemma~\ref{lemma:parallel-scaffold-legal}] \emph{The scaffold solution does not include any pair of simultaneous swaps that share a vertex.} Every swap in the scaffold solution includes an enforcement token. All enforcement tokens always share the same parity of distance from $r$. Therefore, the only two ways for the scaffold solution to include a pair of simultaneous swaps that share a vertex is (1) two enforcement tokens both swap into the same vertex, or (2) two enforcement tokens at the same vertex both swap out of that vertex. In either case, there must be two enforcement tokens in the same place in order for the scaffold solution to have a pair of simultaneous swaps sharing a vertex. Clearly no pair of enforcement tokens is ever at $r$ at the same time (since each $e_d$ is at $r$ immediately after round $d$). Therefore, in order to be in the same place at the same time, the enforcement tokens would have to meet inside some branch. But then, some enforcement token would have to enter a branch before a different enforcement token exits that branch. Note that this is the condition that the proof idea section explicitly said we would need to avoid. Checking that no branch has an enforcement token enter before another one leaves is tedious but not difficult. We now consider, in turn, each type of branch: the swap branch, the garbage branch, and the slot branch. For each \textbf{swap branch} $w^t$ only four enforcement tokens ever enter or leave. The two that leave are $e_{8t-7}$, which exits during round $8t-7$, and $e_{8t-5}$, which exits during round $8t-5$. The two that enter are $e-{8t-3}$, which enters during round $8t-2$, and $e_{8t-1}$, which enters during round $8t$. Clearly, enforcement tokens never enter before another enforcement token leaves. The \textbf{garbage branch} $g$ only ever has enforcement tokens enter it, while the other garbage branch $g'$ only ever has enforcement tokens exit it. Each \textbf{slot branch} $s^i$ has at most one enforcement token enter it. This is because the only enforcement tokens to enter a slot branch are the ones of the form $e_{8t-7}$, which enter branch $y^{8t-7} = s^{a(s_t,t-1)}$ during round $8t-6$. For every $t$, $a(s_t,t-1)$ is a unique value (since by the definition of $a$, once $a(s_t,t-1)$ is replaced by $a(s_t,t)=m+t$, the value $a(s_t,t-1)$ can never occur again as an output of $a$). Therefore each such enforcement token enters exactly one such slot branch. Similarly, each slot branch $s^i$ has at most one enforcement token exit it. This is because the only enforcement tokens to exit a slot branch are the ones of the form $e_{8t-1}$, which exit branch $x^{8t-1} = s^{a(s_t,t)}=s^{m+t}$ during round $8t-1$. In order for an enforcement token to enter a slot branch before a different enforcement token exits the branch, it would have to be the case that $i = a(s_t,t-1)$ and $i = m+t'$ with $8t-6 < 8t'-1$. This is equivalent to $t \le t'$. But notice that the maximum value of $a(\cdot, \tau)$ is always $m+\tau$. Therefore $i = a(s_t,t-1) \le m + t - 1 \le m+t' - 1 = i - 1$. Clearly it cannot be that $i \le i-1$, and so we conclude that an enforcement token enters a slot branch $s^i$ only after other enforcement tokens have exited the branch. This concludes the casework, proving that two enforcement tokens never collide in the scaffold solution and therefore that the scaffold solution never includes two simultaneous swaps sharing a vertex. \end{proof} \begin{proof}[Proof of Lemma~\ref{lemma:parallel-scaffold-item}] \emph{The scaffold solution brings each item token to a final location that is the target location of some item token (though not necessarily the token's own target destination).} In order to prove this, we will prove by induction that for $0 \le t \le n$, after round $8t$, the item tokens are located at $r$ and at vertices $s^{a(i, t)}_1$ for $1 \le i \le m$. By definition this is true for $t = 0$: After round $0$ (that is, right at the beginning), the item tokens were defined to be at locations $r$ and $s^{a(i,0)}_1$ for $1 \le i \le m$, exactly where we wanted to show they would be. Next suppose that for some $1\le t \le n$, it was the case that after round $8(t-1)$, the item tokens are located at $r$ and at vertices $s^{a(i, t-1)}_1$ for $1 \le i \le m$. Let's see what happens in the scaffold solution over the course of rounds $8t-7$ through $8t$. This is depicted in Figure~\ref{fig:ParallelSwap}. The item tokens are all located within distance $1$ of $r$, and so the only enforcement tokens that can move the item tokens are the ones that get close to $r$ during these 8 rounds. In particular, it is easy to verify that the only relevant enforcement tokens are $e_{8t-7}$, $e_{8t-5}$, $e_{8t-3}$, and $e_{8t-1}$. Token $e_{8t-7}$ moves from $w^t_1$ to $s^{a(s_t, t-1)}_7$ over these 8 rounds. $e_{8t-5}$ moves from $w^t_3$ to $g_5$. $e_{8t-3}$ moves from $g'_5$ to $w^t_3$. $e_{8t-1}$ moves from $s^{a(s_t, t)}_7$ to $w^t_1$. \begin{figure} \centering \includegraphics[width=.8\linewidth]{Figures/parallelTokenFigures.pdf} \caption{Position of item and enforcement tokens during rounds $8t-7$ to $8t$. Branches as well as vertices containing enforcement and item tokens are labeled.} \label{fig:ParallelSwap} \end{figure} Here's the effect of these enforcement tokens on the item tokens. On round $8t-7$, token $e_{8t-7}$ moves the item token at $r$, call it $A$, into $w^t_1$. Next, on round $8t-6$, token $e_{8t-5}$ moves that same item token, $A$, into $w^t_2$, while simultaneously $e_{8t-7}$ moves the item token at $s^{a(s_t, t-1)}_1$, call it $B$, into $r$. On round $8t-5$, token $e_{8t-5}$ moves $B$ into $w^t_1$. During rounds $8t-4$ and $8t-3$, no item tokens move. On round $8t-2$, token $e_{8t-3}$ moves into $w^t_1$ from $r$, and as a result $B$ moves back into $r$. Next, on round $8t-1$, token $e_{8t-3}$ moves $A$ into $w^t_1$, while simultaneously token $e_{8t-1}$ moves $B$ from $r$ into $s^{a(s_t,t)}_1$. Finally, on round $8t$, token $e_{8t-1}$ moves $A$ into $r$. All other movements of non-enforcement tokens due to the scaffold solution are not movements of item tokens. The result on item tokens is that $A$, which started at $r$, is moved back into $r$, while $B$, which started at $s^{a(s_t, t-1)}_1$, is moved into $s^{a(s_t, t)}_1$. Note that $s^{a(i, t-1)}_1 = s^{a(i,t)}_1$ whenever $i \ne s_t$. Therefore, all the other item tokens, which started at $s^{a(i, t-1)}_1$ with $i \ne s_t$, end up at $s^{a(i,t)}_1$. And as we saw, the item token ($A$) that was previously at $r$ stays at $r$ and the item token ($B$) that was previously at $s^{a(i, t-1)}_1$ with $i = s_t$ ends up at $s^{a(i, t)}_1$. Thus, as desired, after round $8t$, the item tokens are located at $r$ and at vertices $s^{a(i, t)}_1$ for $1 \le i \le m$. By induction, this same statement holds for every $t$ with $0 \le t \le n$. In particular, applying it to $t = n$, we see that the item tokens are located at $r$ and the vertices $s^{a(i, n)}_1$ for $1 \le i \le m$ after $8n$ rounds of the scaffold solution (i.e. at the end of it). But those are exactly the target locations of item tokens, which is what we wanted to prove. \end{proof} \subsection{Star STS solution \texorpdfstring{$\to$}{-->} parallel token swapping solution} \label{sec:parallel-forward} Suppose we have a solution to a Star STS instance. Then consider the parallel token swapping instance produced by the reduction from the previous section. Let $S$ be the scaffold solution. We will build a different solution $S'$ by adding some swaps to $S$. Consider the solution to the Star STS instance. For $1\le t \le n$, if swap $t$ is used in the Star STS solution, then add a swap of vertices $w^t_1$ and $w^t_2$ during round $8t-4$ to $S'$. First of all, it is easy to verify that no enforcement token swaps into or out of either $w^t_1$ or $w^t_2$ during round $8t-4$. Therefore, $S'$ is a valid schedule of swaps for the parallel token swapping instance. In fact, we will show that $S'$ solves the instance. The main idea of this proof is that $S'$ maintains the following invariant: \begin{lemma} \label{lemma:parallel-forward-lemma-1} If $0 \le t \le n$ then after round $8t$ of $S$, one of the item tokens is located at $r$ and the other $m$ item tokens are in the active slot branches $s^{a(\cdot, t)}$, each in the vertex of that branch which is adjacent to the root. In particular, consider the state of the Star STS instance after the first $t$ swaps are each either used or not according to the solution. The item token located at $r$ will correspond to the item at the root, while the item token in active slot branch $s^{a(i, t)}$ will correspond to the item in slot $i$. \end{lemma} In the process of proving this, we will also show the following: \begin{lemma} \label{lemma:parallel-forward-lemma-2} During round $8t-4$ of $S'$, the two tokens in vertices $w^t_1$ and $w^t_2$ will always be item tokens. \end{lemma} We can use these two lemmas to prove that $S'$ brings every token to its target destination (within $K$ rounds), and therefore that $S'$ is a solution to the parallel token swapping instance. Consider first any token that is not an item token. We know that the scaffold solution $S$ brings every such token to its target location. But $S'$ is just $S$ with some swaps added. In particular, by Lemma~\ref{lemma:parallel-forward-lemma-2}, we know that every swap that was added is between two item tokens. Therefore, the result of $S'$ will be the same as the result of $S$, but with the item tokens permuted in some way. In particular, just as $S$ brings the non-item tokens to their target locations, $S'$ does the same. Now consider the item tokens. Let $i$ be an item token. There are two cases. Either the final position of the corresponding item $i$ is $\pi(i) = 0$ or the final position of item $i$ is some slot $\pi(i)$. In the first case, item $i$ ends up at the root ($\pi(i) = 0$). Therefore, in the Star STS solution, item $i$ is at the root after the entire solution. Phrased a little more verbosely, we have that after the first $t=n$ swaps are each either used or not according to the Star STS solution, item $i$ is at the root. But then by Lemma~\ref{lemma:parallel-forward-lemma-1} applied to $t = n$, we know that the item token at $r$ after $8t = 8n = K$ rounds of $S'$ (the entirety of $S'$) is exactly the item token $i$. But when we were defining the target location of an item token, we gave the item token $i$ for which $\pi(i)=0$ the vertex $r$ as its target location. Therefore in this case the item token is brought to its target location by $S'$. In the second case, the final position of item $i$ is some slot $\pi(i)$. Then in the Star STS solution, item $i$ is in slot $\pi(i)$ after the entire solution, or equivalently after the first $t=n$ swaps are each either used or not according to the Star STS solution. Then by Lemma~\ref{lemma:parallel-forward-lemma-1} applied to $t = n$, we know that the item token at $s^{a(\pi(i),t)} = s^{a(\pi(i),n)}$ after $8t = 8n = K$ rounds of $S'$ (the entirety of $S'$) is exactly the item token $i$. If we look back at the target location that was assigned to an item token $i$ with $\pi(i) \ne 0$, the target location was $s^{a(\pi(i), n)}$. Thus, in this case also we see that the item token is brought to its target location by $S'$. Since $S'$ consists of $K$ legal rounds of swaps which bring every token to its target location, we can conclude that as desired, $S'$ solves the parallel token swapping instance. \subsubsection{Proof of Lemma~\ref{lemma:parallel-forward-lemma-1} and~Lemma~\ref{lemma:parallel-forward-lemma-2}} \begin{proof}[Proof of Lemma~\ref{lemma:parallel-forward-lemma-1}] \emph{ If $0 \le t \le n$ then after round $8t$ of $S$, one of the item tokens is located at $r$ and the other $m$ item tokens are in the active slot branches $s^{a(\cdot, t)}$, each in the vertex of that branch which is adjacent to the root. In particular, consider the state of the Star STS instance after the first $t$ swaps are each either used or not according to the solution. The item token located at $r$ will correspond to the item at the root, while the item token in active slot branch $s^{a(i, t)}$ will correspond to the item in slot $i$. } This Lemma can be proved by an inductive argument almost identical to the proof of Lemma~\ref{lemma:parallel-scaffold-item}. The only difference is that instead of tracking the positions of the item tokens as a group, we track the position of each item token individually. Also, due to the swap that may have been added, the two item tokens that were called $A$ and $B$ in the proof may end up swapped (this is because the swap that might have been added to $S$ to get $S'$ depending on the Star STS solution, is a swap of two vertices which contain $A$ and $B$ at the time). Figure~\ref{fig:ParallelSwap} remains an accurate depiction, except that $A$ and $B$ will be swapped after round $8t-4$. In this new induction, if the Star STS solution does not involve a swap, then the analysis is exactly the same as in the previous proof: $A$ starts at $r$ and ends at $r$, $B$ starts at $s^{a(s_t, t-1)}_1$, and ends at $s^{a(s_t, t)}_1$, and every other item token starts at $s^{a(i, t-1)}_1$ and ends at $s^{a(i, t)}_1$ (which happens to be the same vertex). Under the correspondence with the Star STS instance, this corresponds with none of the items moving. If, on the other hand, the Star STS solution involves a swap, then as previously mentioned, the end result is that item tokens $A$ and $B$ are swapped. $A$ and $B$ are the tokens which were previously at $r$ and $s^{a(s_t, t-1)}_1$, which means that they corresponded to the items previously at the root and in slot $s_t$. Then the result of these 8 rounds is that the two item tokens are swapped relative to their positions in the previous case, which exactly corresponds to the fact that during step $t$ of the Star STS solution, the item in slot $s_t$ and the item at the root swap. \end{proof} \begin{proof}[Proof of Lemma~\ref{lemma:parallel-forward-lemma-2}] \emph{ During round $8t-4$ of $S'$, the two tokens in vertices $w^t_1$ and $w^t_2$ will always be item tokens.} This follows directly from the previous proof, where we saw that the two tokens in these positions at that time are the item tokens referred to as $A$ and $B$. \end{proof} \subsection{Parallel Token Swapping solution \texorpdfstring{$\to$}{-->} Star STS solution} \label{sec:parallel-backward} Suppose we started with a Star STS instance and used the reduction to construct the corresponding parallel token swapping instance, and that this instance had a solution $S'$. We will show that $S'$ can be used to construct a solution to the Star STS instance, which together with the results of the previous section shows that the reduction is answer-preserving. The key idea will be to consider the location of each item token after rounds $0,8,16,\ldots, 8n=K$ of $S'$. In particular, we will care only about whether the token is at the root or otherwise which branch the token is in, not where in a branch the item token can be found. We know that each enforcement token must move a distance of $K$ from its start location to its target destination. Therefore, the token must be swapped towards its destination during every round of $S'$. Thus every swap from the scaffold solution $S$ must be present in $S'$. We wish to know how the branches of the item tokens change over time. But a token switches branches only by passing through $r$. Therefore, we can consider which swaps of $S'$ involve $r$. In fact, the enforcement tokens were specifically chosen so that $S$ would include a swap involving $r$ on every round. Therefore, the only swaps involving $r$ in $S'$ are the swaps involving $r$ from $S$. What are those swaps? Well if $d$ is odd, then on round $d$, enforcement token $e_d$ swaps into $r$ from vertex $x^d_1$, and on round $d+1$, enforcement token $e_d$ swaps out of $r$ and into vertex $y^d_1$. Phrased differently, if $d$ is odd, then on round $d$, a non-enforcement token moves from $r$ into branch $x^d$, and on round $d+1$, a non-enforcement token moves from branch $y^d$ into $r$. Then let us consider the 8 such movements starting after round $8t-8$ and ending after round $8t$: \begin{itemize} \item On round $8t-7$, the token at $r$ moves into branch $x^{8t-7}=w^t$ \item On round $8t-6$, some non-enforcement token in branch $y^{8t-7}=s^{a(s_t, t-1)}$ moves into $r$ \item On round $8t-5$, the token at $r$ moves into branch $x^{8t-5}=w^t$ \item On round $8t-4$, some non-enforcement token in branch $y^{8t-5}=g$ moves into $r$ \item On round $8t-3$, the token at $r$ moves into branch $x^{8t-3}=g'$ \item On round $8t-2$, some non-enforcement token in branch $y^{8t-3}=w^t$ moves into $r$ \item On round $8t-1$, the token at $r$ moves into branch $x^{8t-1}=s^{a(s_t, t)}$ \item On round $8t$, some non-enforcement token in branch $y^{8t-1}=w^t$ moves into $r$ \end{itemize} As before, these correspond to swaps depicted in Figure~\ref{fig:ParallelSwap}. Some of these bullet points can be combined together. Overall, the effect of these 8 rounds (starting after round $8t-8$ and ending after round $8t$) on the branches of non-enforcement tokens is the following: \begin{enumerate} \item the token at $r$ moves into branch $w^t$ \item some non-enforcement token in branch $s^{a(s_t, t-1)}$ moves into branch $w^t$ \item some non-enforcement token in branch $g$ moves into branch $g'$ \item some non-enforcement token in branch $w^t$ moves into branch $s^{a(s_t, t)}$ \item some non-enforcement token in branch $w^t$ moves into $r$ \end{enumerate} In fact, we will show that most of these movements are movements of not just non-enforcement tokens, but more specifically item tokens. \begin{lemma} \label{lemma:parallel-backward-lemma} Every movement of non-enforcement tokens between branches in $S'$ (as described by the above list) is either a movement from branch $g$ into branch $g'$ or a movement of an item token. \end{lemma} Assuming that can be proven, we can then show that the movement of item tokens between branches in $S'$ corresponds to the movement of items between slots in the Star STS instance. In particular, after round $8t$ for $0 \le t \le n$, there will be one item token at $r$, and one item token in slot branch $s^{a(i, t)}$ for each $i \in \{1, \ldots, m\}$. Furthermore, the change between round $8(t-1)$ and round $8t$ will always correspond to either using or not using the swap $s_t$. Certainly, for $t=0$, this holds: there is one item token, $0$, at $r$, and each item token $i$ for $i\in \{1, \ldots, m\}$ is in slot branch $s^{a(i, 0)} = s^i$. In the Star STS instance, item $0$ is at the root, while each other item $i$ is in slot $i$. Next, suppose by the inductive hypothesis that for some $1 \le t \le n$, the above statement holds with $t-1$: after round $8(t-1)$ of $S'$, there was one item token at $r$, and one item token in slot branch $s^{a(i, t)}$ for each $i \in \{1, \ldots, m\}$. Let's see what movements of item tokens happen between rounds $8(t-1)$ and $8t$. According to the list above, (1) the item token at $r$ moves into branch $w^t$, (2) the item token in branch $s^{a(s_t, t-1)}$ moves into branch $w^t$, (3) some non-enforcement token in branch $g$ moves into branch $g'$, (4) an item token in branch $w^t$ moves into branch $s^{a(s_t, t)}$, and (5) the final item token in branch $w^t$ moves into $r$. Note that since there are no item tokens in $g$, the token moving in (3) must be a filler token. Thus, the overall movement of item tokens is this: first the item tokens at $r$ and in branch $s^{a(s_t, t-1)}$ are moved into $w^t$, then one of those tokens moves into branch $s^{a(s_t, t)}$, and the other moves to $r$. Every other item token, in branch $s^{a(i, t-1)}$ with $i \ne s_t$, stays in that branch. But by the definition of $a$, $a(i, t) = a(i, t-1)$ precisely when $i \ne s_t$. So the item token from branch $s^{a(i, t-1)}$ with $i \ne s_t$ ended up in branch $s^{a(i, t)}$, while the two item tokens at $r$ and in branch $s^{a(s_t, t-1)}$ ended up at $r$ and in branch $s^{a(s_t, t)}$, in some order. Then the inductive hypothesis holds: after round $8t$ of $S'$, there is one item token at $r$, and one item token in slot branch $s^{a(i, t)}$ for each $i \in \{1, \ldots, m\}$. Furthermore, as we wanted to prove, the change between round $8(t-1)$ and round $8t$ always corresponds to either using or not using the swap $s_t$, depending on the arrangement of the two item tokens that moved from vertex $r$ and branch $s^{a(s_t, t-1)}$ to vertex $r$ and branch $s^{a(s_t, t)}$. Thus, we can simply read off the movement of the items in a solution to the Star STS instance from the movement of the item tokens in $S'$. Now all that remains is to prove the needed lemma. \begin{proof}[Proof of Lemma~\ref{lemma:parallel-backward-lemma}] \emph{ Every movement of non-enforcement tokens between branches in $S'$ (as described by the above list) is either a movement from branch $g$ into branch $g'$ or a movement of an item token.} The list is reproduced below: \begin{enumerate} \item the token at $r$ moves into branch $w^t$ \item some non-enforcement token in branch $s^{a(s_t, t-1)}$ moves into branch $w^t$ \item some non-enforcement token in branch $g$ moves into branch $g'$ \item some non-enforcement token in branch $w^t$ moves into branch $s^{a(s_t, t)}$ \item some non-enforcement token in branch $w^t$ moves into $r$ \end{enumerate} For the moment, assume the following three statements which will be argued at the end of the proof: \begin{enumerate} \item For every slot branch $s^i$, there is exactly one way that an item token can get into the branch; either the slot token starts there or there is one movement according to the list which can move a non-enforcement token into the branch. \item Similarly, for every slot branch $s^i$, either there is an item token that has that branch as a target location, or there is exactly one movement according to the list which can move a non-enforcement token out of the branch, but not both. \item Finally, every swap branch $w^t$ has two movements on the list that can move a non-enforcement token into $w^t$, followed by two movements that can move a non-enforcement token out of $w^t$. \end{enumerate} We can combine these facts into a proof by induction. Consider all of the movements from the list other than those from $g$ to $g'$ in order according to $S'$. We will prove that all of these movements are movements of an item token. Suppose this is true up to a certain movement, call it $M$ in the list. Case 1: $M$ moves a non-enforcement token from a slot branch $s^i$ into some other branch. By applying fact 2 to $s^i$, we know that $M$ is the only time that a non-enforcement token can leave branch $s^i$ and also that no item token has a target location in $s^i$. We can also apply fact 1 from the list above to $s^i$, yielding two cases. Case 1a: $s^i$ started with an item token in it. Since no item token has a target location in $s^i$ and $M$ is the only opportunity for the item token to leave $s^i$, the token must take that opportunity in order to be able to reach its target location. Thus, $M$ must have been used to move an item token. Case 1b: there is one movement $M'$ somewhere in the list which can move a non-enforcement token into $s^i$. $M'$ must have occurred before $M$. This is because $M'$ corresponds to an enforcement token leaving $s^i$, $M$ corresponds to an enforcement token entering $s^i$, and as we saw in Lemma~\ref{lemma:parallel-scaffold-legal}, an enforcement token never enters a branch before another enforcement token leaves that same branch. Since $M'$ occurred before $M$, the inductive hypothesis applies: $M'$ must have moved an item token. But then there is an item token currently in $s^i$. As in case 1a, $M$ is the only opportunity for that item token to leave $s^i$, and so the token must take that opportunity in order to be able to reach its target location. Thus, $M$ must have been used to move an item token. Case 2: $M$ moves a non-enforcement token from a swap branch $w^t$ into another branch. Applying fact 3 from above, we see that $M$ must be one of the two movements $M_{out}^1$ or $M_{out}^2$ out of $w^t$ and must be preceded by exactly two movements $M_{in}^1$ and $M_{in}^2$ into $w^t$. The inductive hypothesis applies to both $M_{in}^1$ and $M_{in}^2$ since they precede $M$. Therefore, each of them moved an item token into $w^t$. As a result, after $M_{in}^1$ and $M_{in}^2$, there were two item tokens in $w^t$, neither of which has a target location in $w^t$. Since there are only two opportunities for an item token to leave $w^t$ ($M_{out}^1$ and $M_{out}^2$), it must be the case that the two item tokens make use of those two opportunities to leave the swap branch, since otherwise they would be unable to reach their target locations. Thus, both $M_{out}^1$ and $M_{out}^2$ must move an item token, and so $M$, which is one of the two, must have been used to move an item token. Since in all cases we conclude that $M$ moved an item token, the proof by induction goes through; every movement on the list other than those from $g$ to $g'$ must move an item token. All that's left is to confirm the three facts listed at the top of this proof. Proof of Fact 1: The only movements on the list that are directed into a slot branch $s^i$ are the movements from $w^t$ to $s^{a(s_t, t)}$ for $1\le t \le n$. There are two cases. If $i \in \{a(j, 0) \mid 1 \le j \le m\}=\{1, \ldots, m\}$, then $1 \le i \le m$. On the other hand $a(s_t, t) = m+t > m$, and so in this case the branch $s^{a(s_t, t)}$ will never equal $s^i$. We also see that in this case $s^i$ is exactly one of the slot branches that initially contains an item token. On the other hand, if $i \not\in \{a(j, 0) \mid 1 \le j \le m\}$ then $i > m$, and so $a(s_{i-m}, {i-m}) = m + (i-m) = i$. Thus, exactly one of the movements from $w^t$ to $s^{a(s_t, t)}$ (in particular the one with $t = i-m$) will move a non-enforcement token into $s^i$. Notice, however, that in this case $s^i$ does not start with an item token. Thus we have shown exactly fact 1: for every slot branch $s^i$, there is exactly one way that an item token can get into the branch; either the slot token starts there or there is one movement according to the list which can move a non-enforcement token into the branch. Proof of Fact 2: The only movements on the list that are directed out of a slot branch $s^i$ are the ones from $s^{a(s_t, t-1)}$ to $w^t$. Recall the recursive definition of $a$: $a(\cdot, 0)$ takes on the values $1$ through $m$, $a(\cdot, 1)$ replaces one of those values, $a(s_1,0)$ with $a(s_1, 1) = m+1$, then $a(\cdot, 2)$ replaces one of the remaining values, $a(s_2, 1)$, with $a(s_2, 2) = m+2$, etc... If $i \in \{a(j, n) \mid 1 \le j \le m\}$, then the value $i$ was never replaced out of the range of $a(\cdot, t)$ all the way until $t = n$. Therefore, in this case we see that $a(s_t, t-1)$ was not equal to $i$ for any $t$, and so none of the movements from $s^{a(s_t, t-1)}$ to $w^t$ are directed out of $s^i$. Note, however, that since $i \in \{a(j, n) \mid 1 \le j \le m\}$, we have that $s^i = s^{a(j, n)}$ for some $j$, and therefore that $s^i$ contains the target destination of some item token. On the other hand, if $i \not\in \{a(j, n) \mid 1 \le j \le m\}$, then the value $i$ was replaced out of the range of $a(\cdot, t)$ at some $t$. Therefore, in this case we see that $a(s_t, t-1)$ was equal to $i$ for exactly one $t$, and so exactly one of the movements from $s^{a(s_t, t-1)}$ to $w^t$ must have been directed out of $s^i$. In other words, we have demonstrated fact 2: for every slot branch $s^i$, either there is an item token that has that branch as a target location, or there is exactly one movement according to the list which can move a non-enforcement token out of the branch, but not both. Proof of Fact 3: Consider any swap branch $w^t$, the only occurrences of that branch are for the instance of the list of movements which corresponds with this specific value of $t$. In this instance of the list, there are four movements involving $w^t$. There are two movements on the list that can move a non-enforcement token into $w^t$, followed by two movements that can move a non-enforcement token out of $w^t$. \end{proof} \section{Star Subsequence Token Swapping Reachability (Star STS) is NP-complete} \label{appendixA} Our starting point is the NP-complete problem called ``permutation generation'' in Garey and Johnson~\cite[MS6]{Garey-Johnson}, and called WPPSG (Word Problem for Products of Symmetric Groups) in~\cite{garey1980complexity}: \begin{quote} \textbf{WPPSG.} Given sets $X_1, X_2, \ldots, X_n$, where $X_i \subseteq \{1, 2, \ldots , m\}$, and a permutation $\pi$ of $\{1, \ldots, m\}$, can $\pi$ be written as $\pi = \pi_1 \cdot \pi_2 \cdots \pi_n$ where $\pi_i$ is a permutation of $X_i$ for $1 \le i \le n$? \end{quote} As noted in~\cite[Corollary, p.~224]{garey1980complexity} WPPSG remains NP-complete when each subset $X_i$ has size 2, i.e.,~the input is a sequence of swaps (transpositions) and the given permutation must be expressed as a subsequence of the given sequence of swaps. This special case is called WPPSG2 in~\cite{garey1980complexity}, and called ``Swap or not Reachability'' in~\cite{THEGAME_JCDCGGG}. By considering the transpositions as edges of a (complete) graph, the problem can be expressed as the following token swapping reachability problem. \begin{quote} \textbf{Subsequence Token Swapping Reachability (STS):} Given a graph on $m$ vertices where vertex $i$ initially has a token $i$, and given a target permutation $\pi$ of the tokens and a sequence of swaps $s_1, s_2, \ldots, s_{n}$, where $s_j$ is an edge of the graph, is there a subsequence of the swaps that realizes $\pi$? \end{quote} We prove that STS remains NP-complete when the underlying graph is a star. \begin{lemma} \label{lemma:StarSTS} Star STS is NP-complete, even in the special case where the target permutation places token 0 back on the center. \end{lemma} \begin{proof}[Proof of Lemma~\ref{lemma:StarSTS}] We give a polynomial time reduction from STS to Star STS. Suppose the input to STS consists of the target permutation $\pi \in S_m$ and the swaps $s_i = (a_i, b_i)$, $1 \le i \le n$, where $a_i, b_i \in \{1, \ldots, m\}$. Construct an instance of Star STS as follows. Make a leaf of the star for each of the $m$ vertices of the input graph. Also, for each swap $s_i$ in the input sequence, make two leaves $s^{\rm in}_i$ and $s^{\rm out}_i$. Each leaf has a token of its same label, and the center vertex of the star has token $0$. Define the target permutation such that token $0$ remains on the center vertex, tokens $1, \ldots, m$ permute according to the input permutation $\pi$, and tokens $s^{\rm in}_i$ and $s^{\rm out}_i$ must switch positions for $1 \le i \le n$. To construct the swap sequence, replace each $s_i= (a_i, b_i)$ by the 6-element sequence $s^{\rm in}_i, a_i, \allowbreak b_i, \allowbreak a_i, \allowbreak s^{\rm out}_i, s^{\rm in}_i$ (recall that an element $x$ indicates a swap on edge $(0,x)$). Observe that this construction can be carried out in polynomial time. If the original instance of STS has a solution, then we get a solution for the constructed instance of Star STS as follows. If $s_i$ is chosen in the original, then choose the corresponding 6-element sequence, and otherwise, choose only $s^{\rm in}_i$, $s^{\rm out}_i$, $s^{\rm in}_i$. In the other direction, suppose the instance of Star STS has a solution. For each $i$, we must use the subsequence $s^{\rm in}_i$, $s^{\rm out}_i$, and $s^{\rm in}_i$ because no other swaps operate on vertices $s^{\rm in}_i$ and $s^{\rm out}_i$, and all three of these swaps are needed to re-position the tokens correctly, i.e.~there is no other way to switch the positions of tokens $s^{\rm in}_i$ and $s^{\rm out}_i$. Note that the first swap places token $s^{\rm in}_i$ at the center vertex of the star. Now consider the swaps $a_i, b_i, a_i$. If we use all three, then this corresponds to using $s_i$, and if we use none of them, then this corresponds to not using $s_i$. We claim that these are the only possibilities because, if we choose $a_i,a_i$ it does nothing, and if we choose any other proper non-empty subsequece of $a_i, b_i, a_i$ then token $s^{\rm in}_i$, would not be at the center vertex when we perform $s^{\rm out}_i$, and $s^{\rm in}_i$, and thus would not reach its target vertex. \end{proof} \section{Open Problems} Many interesting related problems remain open. For sequential token swapping on trees, where is the divide between NP-complete and polynomial-time? Our reduction's tree is a subdivided star (as for parallel token swapping) with the addition of one extra leaf (the nook) per path. By contrast, there is a polynomial-time algorithm for the case of a broom (a star with only one edge subdivided) \cite{vaughan1999broom,kawahara2019time,tree-token-swapping}. What about a star with two subdivided edges? Another direction (for both sequential/parallel variations) is to explore low-diameter trees, or more generally, low-diameter graphs. Our reductions use long paths. Is there a polynomial-time algorithm (ideally fixed-parameter tractable) for low-diameter trees or graphs? What if we attach such a graph to a long path? For parallel token swapping, even the case of a single long path is open. Kawahara et al.~\cite{kawahara2019time} gave an additive approximation algorithm that uses at most one extra round. Is there an optimal algorithm, or is parallel token swapping NP-hard on paths? There are also open problems in approximation algorithms. In parallel token swapping, we know that there is no PTAS~\cite{kawahara2019time}. Is there an $O(1)$-approximation for trees or general graphs? For sequential token swapping, there is a 4-approximation algorithm~\cite{miltzow2016approximation}. Is 4 a lower bound on the approximation factor of this algorithm? Is $4$-approximation the best possible for general graphs? Although this paper focused on the best reconfiguration sequence, much research is devoted to understanding the worst-case behavior for a given graph; is it NP-hard to determine the diameter of the Cayley graph, i.e., the maximum number of reconfiguration steps that can be required for any pair of token configurations? This problem is open for both sequential token swapping (implicit in ~\cite{chitturi2019sorting}) and parallel token swapping \cite{alon1994routing}. \section{Introduction} Imagine $n$ distinctly labeled tokens placed without collisions on the $n$ vertices of a graph~$G$. For example, these $n$ tokens might represent (densely packed) movable \defn{agents} --- robots, people, packages, shipping containers, data packets, etc.\ --- while the $n$ vertices represent possible agent locations. Now suppose we want to move the tokens/agents around, for example, to bring certain shipping containers to the loading side of a cargo ship. In particular, we can suppose every token has a given start vertex and destination vertex, and the goal is to move every token to its desired destination. Because every vertex has a token (agents are densely packed), a natural reconfiguration operation is to \defn{swap} two adjacent tokens/agents, that is, to exchange the tokens on the two endpoints of a given edge in~$G$. In this paper, we study token reconfiguration by swaps from a given start configuration to a given destination configuration with two natural objective functions: \begin{enumerate} \item \textbf{(Sequential) Token Swapping} (a.k.a.\ ``sorting with a transposition graph'' \cite{akers1989group}): Minimize the number of swaps, i.e., the total work required to reconfigure. \item \textbf{Parallel Token Swapping} (a.k.a.\ ``routing permutations via matchings'' \cite{alon1994routing}): Minimize the number of rounds of simultaneous swaps (where the edges defining the swaps form a matching, so avoid conflicting shared endpoints), i.e., the total execution time or makespan required to reconfigure. \end{enumerate} These reconfiguration problems can be cast in terms of the symmetric group. Each possible reconfiguration step --- swapping along one edge in the sequential problem, or swapping along every edge of a matching in the parallel problem --- is a particular permutation on the $n$ tokens (element of the symmetric group~$S_n$). Assuming the graph is connected, these permutations generate~$S_n$, defining a \defn{Cayley graph} $C$ \cite{cayley-graph} where each node $\pi$ in $C$ corresponds to a permutation $\pi$ of the tokens (a collision-free placement of the tokens) and an undirected edge connects two nodes $\pi_1,\pi_2$ in $C$ if there is a reconfiguration step (swapping an edge or matching in~$G$) that transforms between the two corresponding permutations $\pi_1,\pi_2$. Minimizing the number of reconfiguration steps between two configurations of the tokens (sequential/parallel token swapping) is equivalent to finding the shortest path in the Cayley graph between two given nodes corresponding to two given permutations in~$S_n$. In fact, sequential token swapping was first studied by Cayley in 1849 \cite{cayley} who (before inventing the Cayley graph) solved the problem on a clique, i.e., without any constraint on which tokens can be swapped. What is the complexity of token swapping? In general, it is PSPACE-complete to find a shortest path between two given nodes in a Cayley graph defined by given generators \cite{jerrum1985complexity}. But when the generators include transpositions (single-swap permutations) as in both sequential and parallel token swapping, $O(n^2)$ swaps always suffice \cite{yamanaka2015swapping}, so the token-swapping problems are in NP. Both sequential token swapping \cite{AmirP15} and parallel token swapping \cite{banerjee2017new,kawahara2019time} are known to be NP-complete on a general graph. In this paper, we strengthen these NP-completeness results to hold even when the graph is restricted to be a tree. Sequential token swapping on a tree was first studied over thirty years ago by Akers and Krishnamurthy \cite{akers1989group}, in the context of interconnection networks. Specifically, they proposed connecting processors together in a network defined by a Cayley graph, in particular a Cayley graph of transpositions corresponding to edges of a tree (what they call a \defn{transposition tree}), so the shortest-path problem naturally arises when routing network messages. They gave an algorithm for finding short (but not necessarily shortest) paths in the resulting Cayley graphs, and characterized the diameter of the Cayley graph (and thus found optimal paths \emph{in the worst case} over possible start/destination pairs of vertices) when the tree is a star. Follow-up work along this line attains tighter upper bounds on the diameter of the Cayley graph in this situation when the graph is a tree \cite{vaughan1991bounds,ganesan2012efficient,kraft2015diameters,chitturi2018sorting} and develops exponential algorithms to compute the exact diameter of the Cayley graph of a transposition tree \cite{chitturi2019sorting}, though the complexity of the latter problem remains open. Here we show NP-hardness of the slightly more general problem of computing the shortest-path distance between two given nodes in the Cayley graph of a transposition tree (sequential token swapping on a tree), a problem implicit in \cite{akers1989group} and explicitly posed as an open problem in \cite{yamanaka2015swapping}. A well-known special case is when the graph is not just a tree but also a path. In this case, sequential token swapping is equivalent to sorting an array by the fewest possible swaps of adjacent elements. Bubble sort is known to be optimal for this problem, with a number of swaps equal to the number of inversions \cite{knuth1998art3} in the relative permutation $\pi_2 \circ \pi_1^{-1}$ that takes the start permutation $\pi_1$ to the destination permutation~$\pi_2$. Parallel token swapping was also introduced in the context of network routing: in 1994, Alon, Chung, and Graham \cite{alon1994routing} called the problem ``routing permutations via matchings''. They focused on worst-case bounds for a given graph (the diameter of the Cayley graph); in particular, they proved that any $n$-vertex tree (and thus any $n$-vertex connected graph) admits a $< 3n$-round solution, a bound later improved to $\frac{3}{2} n + O(\log n)$ \cite{zhang1999optimal}. Like sequential token swapping, computing the exact diameter of the Cayley graph of a given tree remains open, but we show NP-hardness of the slightly more general problem of computing the shortest-path distance between two given nodes in such a Cayley graph (parallel token swapping on a tree). \subsection{Our Results} \begin{enumerate} \item Sequential token swapping is NP-complete on trees. \item Weighted sequential token swapping is NP-complete on trees (intuition for Result 1). \item Parallel token swapping is NP-complete on trees, even on subdivided stars. \item Known techniques for approximating sequential token swapping on trees preclude approximation factors less than 2. \end{enumerate} {\bf Result 1} is our most difficult and technical result. The main intuition % is given by {\bf Result~2} in Section~\ref{sec:NP-hard-weighted}---NP-completeness of \defn{weighted} sequential token swapping, where each token has a nonnegative integer \defn{weight} and the cost of a swap is the sum of the weights of the two tokens being swapped. This reduction uses weights of just $0$ and~$1$, making some tokens ``free'' to move. Our main technical challenge for {\bf Result 1} (in Section~\ref{sec:NP-hard-unweighted}) is simulating the effect of weight-$1$ tokens with long paths of vertices and tokens, effectively showing that these tokens must move together, and making the cost of moving this group dominate the movement of simulated weight-$0$ tokens. The main difficulty in the new setting is that free swaps (i.e., swaps involving $0$-weight tokens) cannot be ignored anymore. We need a careful accounting to show that, although solutions can slightly deviate from each other, they all have the same pattern (i.e., at all times, we can tie a long path of vertices to tokens of weight $1$ in the first reduction, and so on). To give a sense of the complexity, our weighted hardness proof fits in just a couple of pages, while our unweighted proof spans around thirty pages. Our next main result is {\bf Result 3}, NP-completeness of parallel token swapping on trees, and even stronger, on \defn{subdivided stars} which have only one vertex of degree $>2$. At a high level, our reduction in Section~\ref{sec:parallel} is similar to the previous one, % using the one high-degree vertex as a bottleneck to limit the available parallelism. The details differ significantly, requiring the development of new techniques for constraining parallel token swapping behavior. In particular, we develop ``enforcement'' tokens that need to swap through the high-degree vertex at specific times in order to force congestion at certain times. This proof's difficulty is in between the unweighted and weighted sequential hardness proofs. All three of our NP-hardness reductions are from a common NP-complete problem, in essence the problem called \defn{permutation generation} in Garey and Johnson~\cite[MS6]{Garey-Johnson}. But we recast this problem in terms of a token-swapping \defn{reachability} problem where the swaps must be chosen as a subsequence of a given sequence and the underlying graph is just a star: \begin{quote} \textbf{Star Subsequence Token-Swapping Reachability (Star STS):} Given a star graph with center vertex $0$ and leaves $1, 2, \ldots, m$, where vertex $i$ initially has a token $i$; given a target permutation $\pi$ of the tokens; and given a sequence of swaps $s_1, s_2, \ldots, s_n$, where $s_j \in \{1, \ldots, m\}$ indicates a swap on edge $(0, s_j)$, is there a subsequence of the given swaps that realizes~$\pi$? \end{quote} Appendix~\ref{appendixA} gives the straightforward reduction from permutation generation to Star STS. At a high level, our three NP-hardness proofs all rely on representing the tokens from the Star STS instance using specific ``item tokens'' in the token-swapping instance and by associating locations in the token swapping graph with vertices of the Star STS star. Then the bulk of the construction in each of the three reductions is meant to constrain where these item tokens can go in the graph over the course of the token-swapping solution. By sufficiently constraining the movement of the item tokens, we can make sure that they have some opportunities to swap among themselves, but that these opportunities to swap correspond to the given sequence of swaps from the Star STS instance. Our final result, {\bf Result 4}, is about approximability of sequential token swapping. There are three known 2-approximation algorithms for sequential token swapping in trees: Akers and Krishnamurthy's ``happy swap'' algorithm \cite{akers1989group} (from the original paper introducing sequential token swapping in trees), Vaughan's algorithm \cite{vaughan1991bounds}, and Yamanaka et al.'s cycle algorithm \cite{yamanaka2015swapping} (from the paper that introduced the ``token swapping'' terminology). The first and last algorithms share a natural property: every token $t$ always remains within distance $1$ of the shortest path from $t$'s start vertex to $t$'s destination vertex. We show in Section~\ref{sec:inapprox} that this natural property is a fundamental barrier to improved approximation: any $< 2$-approximation algorithm must in general bring a token \emph{arbitrarily far} --- an $\Omega(n^{1-\epsilon})$ distance away --- from its shortest path. This result cleanly generalizes previous arguments that Akers and Krishnamurthy's and Yamanaka et al.'s algorithms have an approximation factor of exactly~$2$ \cite{tree-token-swapping}. We also obtain the first proof that Vaughan's algorithm \cite{vaughan1991bounds} is no better than a $2$-approximation; the best previous lower bound for its approximation factor was $\frac{4}{3}$ \cite{tree-token-swapping}. \vspace{-2ex} \subsection{Related Work} Sequential token swapping has been studied before by many researchers in many disparate fields, from discrete mathematics \cite{cayley,portier-vaughan1990star,vaughan1991bounds,pak1999reduced,vaughan1999broom,kraft2015diameters} and theoretical computer science \cite{jerrum1985complexity,knuth1998art3,ganesan2012efficient,yamanaka2015swapping,yasui2015swapping,AmirP15,miltzow2016approximation,bonnet2017complexity,kawahara2019time,yamanaka2018colored,chitturi2018sorting,chitturi2019sorting,tree-token-swapping} to more applied fields including network engineering as mentioned earlier \cite{akers1989group}, robot motion planning \cite{MotionPlanning_SoCG2018,surynek2019multi}, and game theory \cite{gourves2017object}. On general graphs, the problem is known to be NP-complete \cite{AmirP15}, furthermore APX-hard \cite{miltzow2016approximation}, and even W[1]-hard with respect to number of swaps \cite{bonnet2017complexity}. In particular, the best approximation factor we can hope for is a constant $>1$. Miltzow et al.~\cite{miltzow2016approximation} gave a $4$-approximation for general graphs (generalizing the original 2-approximation for trees \cite{akers1989group}), which remains the best known for general graphs. The main other approximation algorithms are the $2$-approximations on trees mentioned above \cite{akers1989group,vaughan1991bounds,yamanaka2015swapping}. Polynomial-time exact algorithms are known for cliques \cite{cayley}, paths \cite{knuth1998art3}, cycles \cite{jerrum1985complexity}, stars \cite{portier-vaughan1990star,pak1999reduced}, brooms \cite{vaughan1999broom,kawahara2019time,tree-token-swapping}, complete bipartite graphs \cite{yamanaka2015swapping}, and complete split graphs \cite{yasui2015swapping}. See also the surveys by Kim \cite{kim2016sorting} and Biniaz et al.~\cite{tree-token-swapping}. One of the strongest positive results for sequential token swapping is the case of a \defn{broom} (a path attached to a star). There are three different solutions to this problem \cite{vaughan1999broom,kawahara2019time,tree-token-swapping}, and all three involve very difficult proofs of correctness. This difficulty speaks to the challenge of arguing about token swapping, specifically, showing that the optimal reconfiguration has a particular form. These challenges arise in our proofs as well. Notably, our parallel reduction uses subdivided stars (the generalization of brooms to allow each ``bristle'' to be an arbitrary-length path) and our sequential reduction uses graphs that are close to subdivided stars (generalized so that each bristle path has one additional leaf attached), making our NP-hardness results strikingly close to the polynomial case of brooms. In the \defn{colored} generalization of token swapping \cite{yamanaka2018colored}, some subsets of tokens have identical labels (colors), so each of these subsets (color classes) can be permuted arbitrarily. This setting arises naturally in applications where agents (tokens) do not densely fill locations (vertices): one color class can represent ``empty'' vertices. Colored sequential token swapping is NP-hard even with just three color classes, but polynomial-time with two color classes \cite{yamanaka2018colored}. Miltzow et al.'s $4$-approximation algorithm for sequential token swapping \cite{miltzow2016approximation} generalizes to this setting. Exact solutions for paths and stars generalize to colored sequential token swapping, even with weights on tokens \cite{tree-token-swapping}. NP-hardness for weighted colored sequential token swapping on trees was proved recently \cite{tree-token-swapping}; we remove both the ``colored'' and ``weighted'' qualifiers on this result. Parallel token swapping is known to be NP-complete in bipartite maximum-degree-$3$ graphs, NP-complete even when restricted to just three rounds, but polynomial-time when restricted to one or two rounds, but NP-complete again for colored tokens restricted to two rounds \cite{banerjee2017new,kawahara2019time}. Two approximation results are known: an additive approximation for paths which uses only one extra round \cite{kawahara2019time}, and a multiplicative $O(1)$-approximation for the $n \times n$ grid graph \cite{MotionPlanning_SoCG2018}.% \footnote{The results of \cite{MotionPlanning_SoCG2018} are phrased in terms of motion planning for robots, and in terms of a model where an arbitrary disjoint collection of cycles can rotate one step in a round. However, the techniques quickly reduce to the model of swapping disjoint pairs of robots, so they apply to parallel motion planning as well. They show that there is always a solution within a constant factor of the obvious lower bound on the number of rounds: the maximum distance between any token's start and destination.} For other special graph classes, there are tighter worst-case bounds on the diameter of the Cayley graph \cite{alon1994routing,li2010routing,banerjee2017new}. Other models for moving tokens in graphs have been introduced. In ``sliding tokens'' \cite{NCL_TCS}, some vertices do not have tokens, vertices with tokens must always form an independent set, tokens are all identical (one color class), and the goal is to decide whether reconfiguration is even possible (a variation of independent set reconfiguration \cite{NPReconfiguration_TCS}). This problem is PSPACE-complete even for planar graphs \cite{NCL_TCS}, but polynomial on trees \cite{TokenReconfigurationTrees_TCS2015}. The associated Cayley graphs are called ``token graphs'', whose properties such as $k$-connectivity are well-studied; see \cite{fabila2020token}. In ``movement problems'' \cite{Movement_TAlg,Movement_APPROX2011,MovementFPT_TALG}, the problem is further relaxed to allow multiple tokens on the same vertex, and the goal is for the vertices with tokens to induce a subgraph with a particular property such as connectivity. In ``sequentially swapping'' \cite{SequentialTokenSwapping_JGAA2019}, the entire reconfiguration sequence consists of moving one token (conceptually, a blank space) along a nonsimple path in the graph, swapping each token encountered with the previous position in the path, and the goal is to minimize the length of the path. This model is a natural graph generalization of the Fifteen Puzzle (which is itself NP-hard on an $n \times n$ grid \cite{ratner1990n2,FifteenPuzzle_TCS}). This problem can be solved exactly on trees, complete graphs, and cycles; and with two color classes, it is APX-hard \cite{SequentialTokenSwapping_JGAA2019}. There is recent work exploring a version of token swapping where some specified pairs of tokens may not swap~\cite{defant2020friends}. Many of these problems have applications in AI, robotics, motion planning, and quantum circuit compilation. See \cite{surynek2019multi} for a recent survey on the practical side. There are also game-theoretic models for token swapping, where vertices are selfish players each of which has a strict total order on their preference among the tokens (called objects). A swap between adjacent vertices is possible only when it benefits both vertices (each player obtaining a higher object in their total order). In this setting, deciding whether a given configuration can be reached is NP-complete but polynomial on trees; deciding whether a given token can reach a specified vertex is NP-complete even for a tree but polynomial on paths and stars; and finding an equilibrium (Pareto-efficient) configuration is NP-complete but polynomial on paths and stars and open on trees \cite{gourves2017object}. \section*{Acknowledgments} This research was initiated at the 34th Bellairs Winter Workshop on Computational Geometry, co-organized by Erik Demaine and Godfried Toussaint, held on March 22--29, 2019 in Holetown, Barbados. We thank the other participants of that workshop for providing a stimulating research environment. Research supported in part by NSERC. Zuzana Mas\'arov\'a supported by Wittgenstein Prize, Austrian Science Fund (FWF), grant no.~Z 342-N31 Virginia Vassilevska Williams supported by an NSF CAREER Award, NSF Grants CCF-1528078, CCF-1514339 and CCF-1909429, a BSF Grant BSF:2012338, a Google Research Fellowship and a Sloan Research Fellowship. Nicole Wein supported by NSF Grant CCF-1514339. \input{intro.tex} \input{NP-hard_weighted.tex} \input{NP-hard_unweighted.tex} \input{no_better_algs.tex} \input{parallel.tex} \input{conclusion.tex} \section{Known techniques preclude approximation factors less than 2} \label{sec:inapprox} Previous results about sequential token swapping on trees include three different polynomial time 2-approximation algorithms and some lower bounds on approximation factors. The three algorithms all have the property that if a token at a leaf is at its destination (i.e., it is a ``happy leaf token'') then the algorithm will not move it. Biniaz et al.~\cite{tree-token-swapping} proved that any algorithm with this property has a (worst case) approximation factor at least $\frac{4}{3}$. They also proved via ad-hoc arguments that the approximation factor is exactly 2 for two of the known 2-approximation algorithms (the ``Happy Swap Algorithm'' and the ``Cycle Algorithm''). For the third 2-approximation algorithm, Vaughan's algorithm, they could not prove a lower bound better than $\frac{4}{3}$. This section contains two results: we prove that Vaughan's algorithm has approximation factor exactly 2. We also extend the approximation lower bounds of Biniaz et al.~by proving that the approximation factor is at least 2 for a larger family of algorithms. % We formalize this family as follows. For token $t$ let $P_t$ be the path from $t$'s initial position to its final position. A sequence of token swaps is \defn{$\ell$-straying} if at all intermediate points along the sequence, every token $t$ is within distance $\ell$ of the last vertex of $P_t$ that it has reached up to this point. A token swapping algorithm is \defn{$\ell$-straying} if it produces $\ell$-straying sequences. Both approximation lower bounds will be proved for the same family of trees that was used by Biniaz et al.~\cite{tree-token-swapping}. For any $k$ and any odd $b$ we define a tree $T_{k,b}$ together with initial and final positions of tokens. $T_{k,b}$ has $b$ paths of length $k$ attached to a central vertex, $c$, and a set $L$ of $k$ leaves also attached to $c$. See Figure~\ref{fig:branch-example}. The tokens at $c$ and $L$ are \defn{happy}---they are at their final positions. The tokens in branch $i, 0 \le i \le b-1$ have their final positions in branch $i+1$, addition modulo $b$, with the initial and final positions equally far from the center $c$. \begin{figure}[htb] \centering \includegraphics[width=.3\textwidth]{Figures/T43.pdf} \caption{Tree $T_{k,b}$ with $b=3$ branches each of length $k=4$, and with $k=4$ leaves attached to the center node. The dashed arrows go from a token's initial to final positions.} \label{fig:branch-example} \end{figure} Biniaz et al.~\cite{tree-token-swapping} proved that the optimum number of swaps for $T_{k,b}$ is at most $(b+1) ({k+1 \choose 2} +2k)$. The solution repeatedly exchanges the tokens in branch $i, 0 \le i \le b - 1 $, modulo $b$, with the tokens at $L$. The first exchange moves the tokens initially at $L$ into branch 0, and the $(b+1)^{\rm st}$ exchange moves those tokens back to $L$. We prove that for $T_{k,b}$ the approximation factor is not better than 2 for $\ell$-straying algorithms (Subsection~\ref{sec:ell-straying}) and for Vaughan's algorithm (Subsection~\ref{sec:Vaughan}) \ifabstract in the Appendix \fi. \later{ \ifabstract \section{Proofs that known techniques preclude $<2$-approximations} \fi \subsection{\texorpdfstring{$\ell$}{l}-straying algorithms do not achieve better than 2-approximation} \label{sec:ell-straying} Before proving the main result, we compare $\ell$-straying algorithms to previous algorithms/properties. It is easy to show that the Happy Swap Algorithm and the Cycle Algorithm are 1-straying (see ~\cite{tree-token-swapping} for descriptions of these algorithms). Thus our lower bound of 2 on the approximation factor replaces the ad hoc arguments of Biniaz et al.~\cite{tree-token-swapping}. We next compare the property of being $\ell$-straying to the property of fixing happy leaves. A swap sequence is \defn{minimal} if it never swaps the same two tokens more than once. It is easy to test this property and eliminate duplicate swaps. \begin{claim} A minimal 1-straying sequence does not move happy leaf tokens. \end{claim} \begin{proof} Suppose there is a happy leaf vertex $v$ with a token $t$ that is at its destination. Let $u$ be the vertex adjacent to $v$. The path $P_t$ from $t$'s initial to final vertex consists only of vertex $v$ so in a 1-straying swap sequence, token $t$ can only be at vertex $v$ or $u$. Suppose that at some point in the sequence there is a swap that moves $t$ to $u$ and moves a token, say $s$, from $u$ to $v$. The next time token $t$ moves, it must move back to $v$, and since $v$ is a leaf, token $s$ is stuck at $v$ until then. % Thus tokens $t$ and $s$ must re-swap on edge $uv$ at some later point in the sequence. Removing the two swaps of tokens $t$ and $s$ yields a shorter equivalent 1-straying sequence. \end{proof} We now prove the main result of this section. \begin{theorem} % $\ell$-straying algorithms do not achieve approximation factor less than 2. More precisely, for every small $\epsilon, \gamma > 0$, there exists an $n$ and an instance of token swapping on an $n$-node tree so that any $\ell$-straying algorithm for $\ell\leq n^{1-\gamma}$ cannot achieve an approximation factor better than $2-\epsilon$. \end{theorem} \begin{proof} We will prove a lower bound on the number of swaps used by any $\ell$-straying algorithm on $T_{k,b}$. Then we will choose values of $b$ and $k$ to get the ratio of the algorithm versus the optimum arbitrarily close to 2. We count two kinds of swaps performed by an $\ell$-straying algorithm: type-A swaps between tokens with initial positions in the same branch; and type-B swaps between tokens with initial positions in different branches. \begin{lemma} \label{lemma:typeA} The number of type-A swaps is at least $\frac{1}{2} b (k-b\ell)^2$. \end{lemma} \begin{proof} We count the number of type-A swaps for one branch $B$. Fix a token $t$ whose initial position is branch $B$ and at distance $i$ from the center, $1 \le i \le k$. Let $S(t)$ be the set of tokens whose initial position is in branch $B$ and closer to the center than $t$'s initial position. Then $|S(t)| = i-1$. Intuitively, we can think of $S(t)$ as a set of tokens that $t$ must swap with if we restrict to $t$'s initial and final branches. Let $H$ be the set of vertices within distance $\ell$ of the center. Observe that $|H| = b\ell + k + 1$. Let $H(t)$ be the tokens at vertices of $H$ at the point in time right before $t$ moves from the center vertex into its final branch for the first time. Intuitively, the only tokens of $S(t)$ that can ``hide'' and avoid swapping with $t$ are in $H(t)$. \begin{claim} \label{claim:same-branch-swaps} Token $t$ swaps with every token in $S(t) \setminus H(t)$. \end{claim} Before proving the claim we work out the bounds. The token initially at the center and the tokens at the $k$ leaves attached to the center were happy initially so they must stay within distance $\ell$ of their initial positions, and thus within distance $\ell$ of the center, which means that these tokens lie in $H(t)$. Also $t$ lies in $H(t)$. Thus $|S(t) \cap H(t)| \le b\ell -1$, and $|S(t) \setminus H(t)| \ge (i-1) - (b\ell-1) = i - b \ell$. Then the number of swaps per branch is at least $$\sum_{i=b\ell}^{k} (i-b\ell) = \sum_{i=0}^{k-b\ell} i = \frac{1}{2}(k-b\ell +1)(k-b\ell).$$ Summing over all $b$ branches gives a total of at least $\frac{1}{2} b (k-b\ell )^2$ type-A swaps. \begin{proof}[Proof of Claim~\ref{claim:same-branch-swaps}] Fix a token $t' \in S(t) \setminus H(t)$. Note that $t'$ always lies in its initial or final branch or at a vertex of $H$. At the point in time right before $t$ moves from the center vertex into its final branch for the first time, $t'$ is outside $H$, so it must be more than distance $\ell$ from the center and either: (1) in its initial branch; or (2) in its final branch. In case (1) $t'$ has never reached the center by the definition of $\ell$-straying. But $t$ has reached the center, and was initially further from the center than $t'$, so $t$ and $t'$ must have swapped in the past. In case (2) $t'$ will never leave its final branch in the future by the definition of $\ell$-straying. Meanwhile, $t$ is currently closer to the center than $t'$ and will end farther from the center than $t'$ and on the same branch. This means that $t$ and $t'$ must swap in the future. \end{proof} This completes the proof of Lemma~\ref{lemma:typeA}. \end{proof} \begin{lemma} \label{lemma:typeB} The number of type-B swaps is at least $\frac{1}{2}b(k-2\ell)^2$. \end{lemma} \begin{proof} Fix a branch $B$, and consider its \defn{tail} $T$ which consists of its last (furthest from the center) $k-2\ell$ vertices. Let $I(B)$ [$F(B)$] be the set of tokens whose initial [final, respectively] position is in the branch, and let $I(T)$ [$F(T)$] be the set of tokens whose initial [final] position is in the tail. If a token $t$ outside $I(B)$ enters the tail at some point in time, then, by the definition of $\ell$-straying, $t$'s final position cannot be outside $B$, nor among the first $\ell$ vertices of $B$. This implies that, from this time on, $t$ must stay in $B$. Thus at all points in time, the tokens in the tail are a subset of $I(B) \cup F(B)$. Every one of the $k - 2\ell$ tokens in $F(T)$ must enter the tail at some point in time. (Note that other tokens of $F(B)$ may enter the tail and then leave the tail.) Let $t_1, t_2, \ldots, t_{k-2\ell}$ be a list of the first $k-2\ell$ tokens of $F(B)$ that enter the tail, ordered by their first entry time. When $t_i$ is about to enter the tail, there are at most $i-1$ tokens of $F(B)$ in the tail, so there are at least $k-2\ell-(i-1)$ tokens of $I(B)$ in the tail. Furthermore, $t_i$ must swap with all of them, since they leave $B$ and $t_i$ stays inside $B$ from this point on. Thus the total number of swaps between a token of $F(B)$ and a token of $I(B)$ is at least $$\sum_{i=1}^{k-2\ell} (k-2\ell-(i-1)) = \sum_{j=1}^{k-2\ell} j = \frac{1}{2}(k-2\ell+1)(k-2\ell).$$ The total over all $b$ branches is then at least $\frac{1}{2} b (k - 2\ell)^2$. \end{proof} To complete the proof of the theorem we calculate the approximation factor for $T_{k,b}$. Let ALG be the number of swaps performed by an $\ell$-straying algorithm, and let OPT be the optimum number of swaps. By the above two lemmas, ${\rm ALG} \ge \frac{1}{2}b (k-b\ell)^2 + \frac{1}{2}b(k-2\ell)^2 \ge b(k-b\ell)^2$ for $b \ge 2$. Biniaz et al.~\cite{tree-token-swapping} proved that ${\rm OPT} \le (b+1) ({k+1 \choose 2} +2k)$. Choose $b = k^\delta$ for any small $\delta$, $0 < \delta < \frac{1}{2}$. Then ${\rm OPT} \le \frac{1}{2} k^{2+\delta} + O(k^{2})$ and ${\rm ALG} \ge k^{2+\delta} - O(k^{1 + 2 \delta}\ell)$. This gives ${\rm ALG}/{\rm OPT} \ge 2 - O(\frac{1}{k^\delta})$. To prove the stronger claim in the theorem, let $\epsilon,\gamma>0$ be given. Pick $k$ large enough so that $\epsilon$ is bigger than $24/k^\delta$. Let $b=k^\delta$ as before. However, now pick $\delta$ in terms of $\gamma$, so that $k^{1-2\delta}=(kb)^{1-\gamma}=k^{1+\delta-\gamma-\delta\gamma}$, and hence $\delta=\gamma/(1.9-\gamma)$ suffices. \end{proof} The fact that the lower bound on the approximation factor holds even if $\ell$ grows almost linearly in the size of the tree is interesting because it means that any approximation algorithm that performs better than the current best-known algorithms must be drastically different. \subsection{Vaughan's algorithm does not achieve better than 2-approximation} \label{sec:Vaughan} The previous section shows that any $\ell$-straying algorithm for token swapping on a tree cannot achieve an approximation factor better than 2. Of the three known approximation algorithms, two of them---the Happy Swap Algorithm and the Cycle Algorithm---are 1-straying. (This follows easily from the descriptions of those algorithms in ~\cite{tree-token-swapping}.) The third algorithm, Vaughan's algorithm, does not have this property, since tokens can stray far from their shortest paths. In this section we prove that Vaughan's algorithm cannot achieve an approximation factor better than 2. \subsubsection{Description of Vaughan's algorithm} Most token swapping algorithms find the sequence of swaps in order from first to last, i.e., based on the initial and final token configurations, the algorithm decides on the first swap to be made. This swap changes the initial token configuration, and the algorithm is applied recursively to the new initial configuration and the unchanged final configuration. Vaughan's algorithm is different. It exploits the symmetry that the reverse of a token swapping sequence changes the final configuration to the initial one. In particular, her algorithm may add a swap to either the start or the end of the sequence. If a swap is added at the start of the sequence, the initial configuration changes. If a swap is added at the end of the sequence, the final configuration changes. In either case, the algorithm is applied recursively. We describe and analyze her algorithm by thinking of each token as a pair of tokens, $t,t_f$, where $t$ is our usual token and $t_f$ is a ``destination token'' that is placed initially on $t$'s destination node. The goal is to get $t$ and $t_f$ to the same node of the tree. At any point in time any tree node has one token and one destination token. Swapping adjacent tokens $s$ and $t$ is the usual operation. Swapping adjacent destination tokens $s_f$ and $t_f$ means that the \emph{last} swap in the sequence will be of tokens $s$ and $t$. \paragraph*{Notation:} If a token and its destination are at the same node we say that the token and the destination token are \defn{happy}. We say that an unhappy token \defn{wants} to move along its incident edge towards its destination token. Symmetrically, we say that a destination token \defn{wants} to move along its incident edge towards its corresponding token. Vaughan's algorithm uses the following three operations. See also Figure~\ref{fig:Vaughan-swaps}. \begin{description} \item[Happy swap.] If $s$ and $t$ are two adjacent tokens that want to move towards each other, then output the swap $(s,t)$ and recursively solve the problem that results from swapping $s$ and $t$. \item[Happy destination swap.] If $t_f$ and $s_f$ are two adjacent destination tokens that want to move towards each other, then recursively solve the problem that results from swapping $t_f$ and $s_f$, and then output the swap $(s,t)$. \item[Symmetric shove.] Suppose $u$ and $v$ are adjacent nodes, where $u$ has token $t$ and destination token $r_f$, and $v$ has token $s$ and destination $s_f$ (so $s$ and $s_f$ are happy). Suppose that $t$ and $r_f$ both want to move towards $v$. Then output the swap $(s,t)$, recursively solve the problem that results from swapping $s,t$ and swapping $r_f,s_f$, then output the swap $(r,s)$. \end{description} \begin{figure}[h] \centering \includegraphics[width=.7\textwidth]{Figures/Vaughan-swaps.pdf} \caption{The three operations of Vaughan's algorithm. An arrow beside a [destination] token indicates the direction it wants to move.} \label{fig:Vaughan-swaps} \end{figure} Vaughan's algorithm applies these operations in order. If there is a happy swap or a happy destination swap that can be performed, do so. Otherwise perform a symmetric shove---she proves that one exists in this situation. Then repeat. Vaughan's algorithm has several important properties: \begin{description} \item{(P1)} Once a token is happy it stays happy. \item{(P2)} Unhappy tokens and destination tokens only move in the direction they want to move (while happy tokens can move arbitrarily). \item{(P3)} If $\sigma$ is a sequence of swaps returned by the algorithm then the reverse of $\sigma$ is a possible output of the algorithm for the instance where tokens and their destinations are flipped, i.e., each pair $t, t_f$ is replaced by $t_f, t$. \end{description} Property (P1) is true because the only operation that involves a happy token is a symmetric shove and the happy token $s$ remains happy. Property (P2) is true because every operation that moves an unhappy [destination] token moves it in the direction it wants to go. Property (P3) was observed by Vaughan. It is true because in the reversed problem happy swaps and happy destination swaps exchange roles, and a symmetric shove remains a symmetric shove. \begin{remark} We note that Vaughan's algorithm is not $\ell$-straying even if $\ell$ is $(n-1)/2$, and even if the tree is just a path. Say $n=2k+1$ is odd. The tokens in consecutive order on the path are $k+2,k+3,\ldots,2k+1,k+1,1,2,\ldots,k$, and the target of token $i$ is position $i$ of the path. Token $k+1$ is happy. A valid application of Vaughan's algorithm repeats the following for each $i$ from $k$ down to $1$: perform a symmetric shove of token $k+1+i$ with token $k+1$, and then use only happy swaps to move token $k+1+i$ to position $k+1+i$. This causes token $k+1$ to end up in position $1$, which is at distance $(n-1)/2$ from its desired destination and path. \end{remark} \subsubsection{Vaughan's algorithm on \texorpdfstring{$T_{k,b}$}{T\_\{k,b\}}} \begin{theorem} \label{thm:Vaughan-bound} The approximation factor of Vaughan's algorithm is not less than 2. \end{theorem} \begin{proof} We will show that on the tree $T_{k,b}$ the number of swaps, ALG, performed by Vaughan's algorithm is at least $bk(k-3)$ swaps. Recall that the optimum number of swaps, OPT, is at most $(b+1)({{k+1} \choose 2} +2k) $. For $k=b$, we get ${\rm OPT} \le \frac{1}{2} k^3 + \Theta(k^2)$, and ${\rm ALG} \ge k^3 - \Theta(k^2)$. Then ${\rm ALG} / {\rm OPT} \ge 2 - \Theta(\frac{1}{k})$, which proves the theorem. It remains to show that Vaughan's algorithm performs at least $bk(k-3)$ swaps on $T_{k,b}$. We will consider the dynamically changing quantity $D=\sum_t d(t,t_f)$, that is, the sum over all tokens $t$ of the distance from the current position of $t$ to the current position of the destination token $t_f$. Note that a happy swap and a happy destination swap both decrease $D$ by 2. A symmetric shove also decreases $D$ by 2, however it performs two swaps so a symmetric shove decreases $D$ by an average of 1 per swap. Since happy swaps and happy destination swaps are ``cheaper'' in this sense than symmetric shoves, to prove a lower bound on the number of swaps, we will prove an \emph{upper bound} on the number of happy swaps and happy destination swaps. Specifically, we will prove that the total number of happy swaps is at most $bk$. \begin{lemma} \label{lemma:happy-swap-bound} The total number of happy swaps is at most $bk$. \end{lemma} We first show that this lemma gives the bound we want. By Property (P3) the lemma also implies that the total number of happy destination swaps is at most $bk$. Now consider the quantity $D$ defined above. Initially, $D=b\sum_{i=1}^k 2i=bk(k+1)$ and at the end, $D=0$. Since each happy swap and each happy destination swap decreases $D$ by 2, these two operations can each decrease $D$ by a total of at most $4bk$. Thus, symmetric shoves account for decreasing $D$ by at least $bk(k+1)-4bk=bk(k-3)$. Since each swap in a symmetric shove decreases D by an average of 1, the total number of swaps is at least $bk(k-3)$, as required. It remains to prove Lemma~\ref{lemma:happy-swap-bound}. We begin with two claims about the relative ordering of tokens and their destination tokens during the course of Vaughan's algorithm on the tree of branches. \noindent \textbf{Notation:} For any token $t$, let $Q_t$ be the path consisting of the branch initially containing $t$ followed by the center node followed by the branch initially containing $t_f$. \begin{claim} \label{claim:ordering} If $t$ is unhappy, then $t$ and $t_f$ are on path $Q_t$, and appear in the order $t,t_f$. \end{claim} \begin{proof} By Property (P2), since $t$ is unhappy, so far $t$ and $t_f$ have only moved in the direction they want to go, which is along $Q_t$. Thus, $t$, and $t_f$ are both on $Q_t$. Note that $t$ initially appears before $t_f$ on $Q_t$. We will show that $t$ and $t_f$ have not switched order. Since $t$ and $t_f$ have never left $Q_t$, the only way for them to have switched order is for them to have swapped or for them to have arrived at the same node. It is not possible for $t$ and $t_f$ to swap because every swap either involves two tokens or two destinations. If they arrive at the same node then $t$ becomes happy and, by Property (P1), stays happy, contradicting our assumption that $t$ is unhappy. \end{proof} \begin{claim} \label{claim:pair-ordering} Suppose tokens $t$ and $s$ have the same initial branch, with $t$ further from the center. If $t$ and $s$ are unhappy, then their order along the path $Q_t=Q_s$ is $t, s, s_f, t_f$. \end{claim} \begin{proof} Initially, the tokens appear in the order $t,s,s_f,t_f$ along the path. By Claim~\ref{claim:ordering}, $s$ and $s_f$ maintain that order while $s$ is unhappy. Thus, the only way the ordering could change is if $t$ and $s$ change order, or $s_f$ and $t_f$ change order. Consider $t$ and $s$. They cannot lie at the same node, so the only way they can change order is by swapping, but this involves $s$ moving away from $s_f$. Similarly, if $s_f$ and $t_f$ change order then $s_f$ moves away from $s$. Thus the four tokens remain in their initial order. \end{proof} In order to prove Lemma~\ref{lemma:happy-swap-bound} (that there are at most $bk$ happy swaps), we will prove that during every happy swap, one of the tokens involved becomes happy. Since there are $bk$ unhappy tokens in the initial configuration, the result follows. Thus it remains to prove: \begin{lemma} \label{lemma:every-swap-happy} Suppose there is a happy swap of tokens $t$ and $s$, with $s$ closer to (or at) the center. Then the swap causes $s$ to become happy. \end{lemma} \begin{proof} Suppose $t$ and $s$ are at nodes $u$ and $v$, respectively and that $u$ is part of branch $B$. Node $v$ is either part of branch $B$ or the center node. Suppose the destination token at $u$ is $r_f$. Note that $r \ne t$ since $t$ is not happy. We aim to prove that $r=s$ which implies that $s$ and $s_f$ are at the same node after the swap. If $r_f$ wants to move away from the center, then $r$ must lie in branch $B$, further from the center. Then tokens $r$ and $t$ both had their initial positions in $B$. Along the path $Q_r=Q_t$ we find $r$, then $t,r_f$ at the same node, then $t_f$, a contradiction to Claim~\ref{claim:pair-ordering}. Thus $r_f$ wants to move towards the center. Suppose $r \ne s$. Because $s$ and $r$ both have their destinations in this branch, they had a common initial branch. Along the path $Q_r=Q_s$, the ordering is $r,s,r_f,s_f$, a contradiction to Claim~\ref{claim:pair-ordering}. Therefore $r=s$. \end{proof} This completes the proof of Theorem~\ref{thm:Vaughan-bound}. \end{proof} } \section{Parallel token swapping on trees is NP-complete} \label{sec:parallel} The parallel token swapping problem is like sequential token swapping, except that swaps that do not involve the same token can occur simultaneously ``in parallel''. In particular, time is measured in rounds where in each round a matching of adjacent tokens is selected and all of those swaps then occur simultaneously during that round. Instead of asking how many swaps are required to bring the tokens to their target destinations, we now ask how many rounds are needed. Precisely, in the \defn{parallel token swapping} problem, the input consists of a graph $G$, an integer $K$, and a permutation $\pi$ on the vertices of $G$. Place a unique token on every vertex of $G$. During a \defn{round}, we choose a matching in $G$ and then for every edge in the matching, \defn{swap} the tokens at the endpoints. In the \defn{parallel token swapping} problem, the goal is to determine whether it is possible to rearrange the tokens via a sequence of $K$ rounds such that for every vertex $v$ in $G$, the token starting in $v$ ends in $\pi(v)$. In this section, we will prove that the parallel token swapping problem remains hard even when the input graph is restricted to be a particular type of tree: a subdivided star. A \defn{subdivided star} is a graph consisting of any number of paths all joined at a single endpoint which we will call the \defn{root}. See Figure~\ref{figure:star_example} for an example. We will prove this by reducing from Star STS. As in previous sections, since we are reducing from a token swapping problem to another token swapping problem, we will introduce a difference in terminology: as before, we will call the tokens from the Star STS instance \defn{items}, and we will call the leaves of the graph in the Star STS instance \defn{slots}. \begin{figure}[!htb] \centering \includegraphics[scale=.4]{Figures/star_example} \caption{An example of a subdivided star} \label{figure:star_example} \end{figure} In Section~\ref{sec:parallel-intuition}, we will lay out the intuition behind the reduction. Then in Section~\ref{sec:parallel-reduction}, we will formally describe the reduction. Next, in Section~\ref{sec:parallel-forward} we will show how to solve the parallel token swapping instance produced by the reduction when the input Star STS instance was possible to solve. Finally, in Section~\ref{sec:parallel-backward} we will show the reverse direction: that any solution to a parallel token swapping instance produced by the reduction can be used to construct a solution to the input Star STS instance. Together, these last two sections combine to prove that the reduction is answer-preserving, allowing us to conclude: \begin{theorem} \label{thm:parallel-NP-hard} Parallel token swapping on trees in NP-hard. \end{theorem} \subsection{Proof idea} \label{sec:parallel-intuition} The most basic concept of this reduction is the same as the prior reduction for Token Swapping on trees. We represent each item in the Star STS instance with a token in the parallel token swapping instance (an item token) and associate some of the branches of the subdivided star (slot branches) with the slots of the Star STS graph. If an item is located at the root of the star, then the corresponding item token will be located at the root of the subdivided star. If an item token is located in a slot, then the corresponding item token will be located somewhere in the corresponding slot branch. In order to make that basic idea work, we need to be able to control which tokens can pass through the root and at which time. We want to restrict the possible transitions of an item token through the root rather than allow arbitrary traversal of the root. Using the root as a bottleneck for tokens swapping into their target branch will be a keystone idea in the proof. For this purpose, we introduce a second set of tokens, which we call \defn{enforcement tokens}. The enforcement tokens will enforce the behavior of the swaps near the root by creating ``congestion'' at the root. This will be achieved by placing the enforcement tokens a distance $K$ away from their targets, forcing the enforcement tokens to take the shortest path to their destination and thus needing to swap into the root at specific times. Each enforcement token will start at some distance $d$ from the root and end at distance $K-d$ from the root in a different branch. The token's destination is a distance of $K$ from its starting location, so therefore the enforcement token will have to move one step towards its target location every round in order to reach its destination by the $K$ round deadline. In particular, during round $d$ the token will swap into the root from its starting branch and during round $d+1$ the token will swap out of the root into its destination branch. Since the root vertex can only be involved in one swap on any given round, these swaps are going to be the only swaps involving the root during rounds $d$ and $d+1$. We want the root to have a swap involving an enforcement token at every round, so we can create one enforcement token, call it $e_1$, with $d=1$, another ($e_3$) with $d=3$, another ($e_5$) with $d=5$, and so on up to a final enforcement token, $e_{K-1}$, with $d=K-1$. This will make it so that there is a forced swap involving the root vertex during every single round (rounds $1$ and $2$ due to $e_1$, rounds $3$ and $4$ due to $e_3$, etc...). So let's say we set this up exactly like that. When can an item token (or any other non-enforcement token) pass through the root? There is a swap involving an enforcement token and the root during every round, so a token can pass through the root only if it is swapping with an enforcement token. An enforcement token enters the root every odd numbered round and exits every even numbered round. Therefore a token could be able to enter the root on some round $2t$ while enforcement token $e_{2t-1}$ is exiting the root and then exit the root on round $2t+1$ while enforcement token $e_{2t+1}$ is entering the root. If this occurs, however, the token must start in the branch that is the destination branch of token $e_{2t-1}$ and end in the branch that is the source branch of token $e_{2t+1}$. Therefore, not only have we restricted the possible traversals through the root, we also have a way to fine tune exactly which branches we allow swaps between and when by setting the source and destination branches of the enforcement tokens. Unfortunately, setting things up this way also gives us an additional constraint: for each branch, it cannot be the case that an enforcement token leaves that branch after another enforcement token enters the branch. The problem is that the two tokens, each on its own inexorable path towards its destination will end up colliding inside the branch. Two enforcement tokens can never swap with each other due to a parity argument (all enforcement tokens always have the same parity of distance from the root, as they all swap into the root on even numbered rounds), so there is no way for the two tokens to pass each other. In other words, if the constraint is violated then a solution to the parallel token swapping instance will be impossible. The constraint that all enforcement tokens leave a branch before any other enforcement tokens enter is equivalent to the constraint that all non-enforcement tokens that are going to enter a branch do so before any non-enforcement tokens leave the branch. This seems like a problem. How can we use a branch to represent a slot if the branch has the constraint that item tokens never enter after other item tokens have exited? After all, in Star STS, slots are used and re-used repeatedly. The solution to this problem is the second key idea of the reduction. Unlike in the sequential token swapping case, we will allow the correspondence between slots and branches to change over time. At any given time a particular branch will represent a slot, but which branch represents that slot can change. This makes it so that we don't have to keep returning tokens into the same branches again after tokens have already left the branch; instead, we just move those tokens into new branches and re-label the correspondence between branches and slots. So how do we actually position the start and end branches of the enforcement tokens so that the desired swaps between item tokens are possible? We will use 8 rounds for every swap. If we are trying to swap some slot $s$, here's the effect of these 8 rounds on the non-enforcement tokens: \begin{enumerate} \item the item token at the root moves into a branch $w$ dedicated to this swap \item the item token in the branch $b_s$ currently associated with slot $s$ moves into the root \item the item token now at the root moves into branch $w$; there are now two item tokens in branch $w$ \item some non-enforcement token moves into the root \item the token at the root moves into another branch (these two swaps provide an extra rounds in which the optional swap of the item tokens can occur) \item an item token from $w$ moves into the root \item the item token at the root moves into a new branch $b_s'$, which as the name suggests will become the new branch associated with slot $s$ \item the remaining item token in $w$ moves into the root \end{enumerate} Of course, to achieve these effects we set the start and destination branches of the enforcement tokens, rather than setting the start and destination branches of the item tokens as described in the list, since the latter is not something we can directly control. Notice that during rounds 4 and 5 in the above list, there are two item tokens in branch $w$: the item token that was at the root and the one which was in branch $b_s$ (corresponding with the item in slot $s$). During these rounds, the two tokens can (optionally) swap. Then the rest of the rounds move these two item tokens into their two new locations: branch $b_s'$ and the root. In other words, depending on which token ends up where, there may have been a swap. Since we can simulate a swap, we can just use the target locations of the item tokens to encode the target permutation of the items. The only remaining question is what to do about all the other tokens we haven't introduced. For this we bring back the concept of the scaffold solution. We know that certain swaps, the swaps of the enforcement tokens, are forced. Therefore, we can consider what happens if we do only those swaps; that is the scaffold solution. Now consider what happens if we place a token on every vertex, and then go through the scaffold solution. The enforcement tokens will all reach their destinations. The item tokens might end up shuffled among themselves (relative to where they should end up), but as a group of tokens, the item tokens will end up occupying exactly the group's target locations. Then for all non-item non-enforcement tokens, we can just set the target destination to be whatever the destination ends up under the scaffold solution. \subsection{Reduction} \label{sec:parallel-reduction} Suppose we have a Star STS instance consisting of: a star with center 0 and slots $1, \ldots, m$, each of which initially has an item of its same label; a permutation $\pi$ of the items; and a sequence $s_1, \ldots, s_n$ of slots that specify the allowed swaps. We will construct a parallel token swapping instance consisting of: the round limit $K$, a subdivided star, and a permutation $\pi$ of the vertices indicating for every vertex $v$ the target location $\pi(v)$ for the token that starts at $v$. For the parallel token swapping construction we will generally use a superscript to refer to the index of the branch and a subscript to refer to a distance from the root. For example, we might discuss the $i^{th}$ branch $b^i$ or the vertex $b^i_j$ which is in branch $i$ and a distance of $j$ away from the root. \subsubsection{Time limit \texorpdfstring{$K$}{K} and the subdivided star} As described in the proof idea section, each swap in the Star STS instance will be represented by $8$ rounds in the Parallel Token Swapping instance. Therefore, we set $K = 8n$. For the subdivided star, we will use the root $r$, together with a total of $n+(m+n)+2$ branches, each of length $K$. For each branch $b$, we will refer to the vertices of the branch starting from the end closest to the root as $b_1, b_2, \ldots, b_K$. These are also shown in Figure~\ref{fig:ParallelTokenOverview}. \begin{itemize} \item $n$ of these branches are \defn{swap branches} $w^t$ for $t=1,\ldots,n$. Each swap branch will be used for one of the swaps to temporarily hold the two swapping item tokens together (so that they can optionally swap). \item $m+n$ of the branches are \defn{slot branches} $s^i$ with $i = 1, 2, \ldots, m+n$. Obviously there are more slot branches than slots, but this is because not every slot branch will represent a specific slot at any given time. Rather, at any given time, $m$ of the branches will be \defn{active}, and those will be the branches which currently represent a slot. Since a swap needs a new branch to occur, we need an additional $n$ branches some of which will only temporarily represent a specific slot. More details on how the mapping will change over time are given in the next section. \item The final two branches are \defn{garbage branches} $g$ and $g'$. Tokens will move between these branches as a way of wasting time. \end{itemize} \begin{figure} \centering \includegraphics[scale=.5]{Figures/ParallelTokenOverview.pdf} \caption{The overall structure of the Parallel Token Swapping instance. Each branch is labeled with its name on the right, and each vertex initially containing an item token is labeled with the name of that token.} \label{fig:ParallelTokenOverview} \end{figure} All that's left is to define the permutation $\pi$. We will do this a piece at a time by considering the three types of tokens described in the proof idea section: item tokens, enforcement tokens, and the remaining, non-item non-enforcement, tokens, which we will refer to as \defn{filler tokens}. \subsubsection{Item tokens} Before considering the item tokens, we first turn our attention to the active branches. We define a function $a$ that tells us which branches are active at any time. In particular, if $1 \le i \le m$ and $0 \le t \le n$ then $a(i, t)$ is defined such that $s^{a(i,t)}$ is the slot branch which represents slot $i$ at time $t$. We say that, at time $t$, $\{s^{a(i, t)} \mid 1\le i \le m\}$ are the active slot branches and the other slot branches are inactive. At time $t=0$, slot branches $1$ through $m$ will represent slots $1$ through $m$, and so $a(i, 0) = i$. Then for every $t > 0$, we define $a(\cdot, t)$ recursively. In particular, during swap $t$, the slot branch that used to represent slot $s_t$ becomes inactive and instead slot branch $m+t$ becomes active in order to represent that slot. In other words, $a(i, t) = a(i, t-1)$ for $i \ne s_t$ and $a(s_t, t) = m+t$. With that done, we can define the initial and final positions of the item tokens. There are $m+1$ item tokens, which we refer to as $0, 1, \ldots, m$, named after their corresponding items. Item $0$ starts at the root of the star, so we will initially place item token $0$ at the root $r$. Each other item $i$ starts in slot $i$, so we will initially place the corresponding item token $i$ in the active branch (at time $t=0$) representing slot $i$ next to the root. In other words, we place item token $i$ at vertex $s^{a(i, 0)}_1=s^i_1$. For the final positions, consider the item which, according to $\pi$, should end up at the root of the star. We give this item token a final destination of $r$. For every other item $i$, the item is supposed to end up in slot $\pi(i)$. Therefore, we give the corresponding item token $i$ a final destination which is in the active branch (at time $t=n$) representing slot $\pi(i)$ next to the root. In other words, we give item token $i$ a final destination of $s^{a(\pi(i), n)}_1$. Notice that since the initial branches assigned to each item token are disjoint (with the exception of one item token starting at the root, which is not assigned an initial branch at all), each item token is given a unique start location. Similarly, the final locations of the item token ends are in disjoint branches (with the exception of one item token at the root), so each item token is given a unique end location. \subsubsection{Enforcement Tokens} Now we will describe the \defn{enforcement tokens}. There will be $\frac{K}{2}$ enforcement tokens $e_1, e_3, \ldots, e_{K-1}$. Enforcement token $e_d$ will start in some branch $x^d$ at distance $d$ from the root and end in some other branch $y^d$ at distance $K-d$ from the root. In other words, the token will start at vertex $x^d_d$ and end at vertex $y^d_{K-d}$. All that's left to make these positions precise is to identify the start and end branches $x^d$ and $y^d$ for $d = 1, 3, \ldots, K-1$. Here is how these branches are assigned: For each $t$ with $1 \le t \le n$, we assign branches as follows \begin{itemize} \item $x^{8t-7} = w^t$ \item $y^{8t-7} = s^{a(s_t, t-1)}$ \item $x^{8t-5} = w^t$ \item $y^{8t-5} = g$ \item $x^{8t-3} = g'$ \item $y^{8t-3} = w^t$ \item $x^{8t-1} = s^{a(s_t, t)}=s^{m+t}$ \item $y^{8t-1} = w^t$ \end{itemize} Note that these 8 branches in this order are exactly the 8 branches from the proof idea section list of token movements through the root corresponding with a swap. It is simple to argue using the distance from the root that each enforcement token has a unique start location and a unique end location. Furthermore, we also wish to claim that no enforcement token shares a start location or an end location with an item token. Since item tokens start and end at distance $0$ or $1$ from the root, $e_1$ is the only enforcement token that could possibly share a start location with an item token and $e_{K-1}$ is the only enforcement token that could possibly share an end location with an item token. However, $e_1$ starts in branch $w^1$ and $e_{K-1}$ ends in branch $w^n$, neither of which are slot branches. No item token starts or ends in a non-slot branch, so we can conclude that the item and enforcement token start locations are all unique, as are their end locations. \subsubsection{Filler Tokens} \label{sec:Filler Tokens} For every vertex that does not initially contain an enforcement token or an item token, we place a filler token initially at that vertex. In order to identify the target destination for these tokens, we make use of the scaffold solution. Define the \defn{scaffold solution} to be a set of swaps for times $1 \le t \le K$. At every time $t$, we will include one swap for each enforcement token: the swap that brings that token one step towards its destination. \footnote{Note, scaffold solution only defines a subset of swaps which must occur based on the enforcement token. It is not based on an `intended solution' like the scaffold solution for the single swap reduction. Thus, although both set up a structure of moves which must be followed, they have somewhat different intuition and technical differences which should not be confused with each other. } We will later prove the following lemma: \begin{lemma} \label{lemma:parallel-scaffold-legal} The scaffold solution does not include any pair of simultaneous swaps that share a vertex. \end{lemma} Using this lemma and the fact that no two item or enforcement tokens share a start position, we can unambiguously execute the scaffold solution starting with the initial position of all the tokens. (Note that if we tried to execute a timeline of swaps including simultaneous swaps sharing a vertex, we would have an ambiguity; where would the token at that vertex go?). Define the target destination of each filler token to be the destination of that token when we execute the scaffold solution. We showed previously that every vertex is the start position of at most one item or enforcement token. Since we started a filler token in every vertex not starting with an item or enforcement token, we now have that every token has a unique starting position and that every vertex is the starting location of some token. What about ending locations? We saw previously that every item and enforcement token has a unique end location. In order to consider the end locations of the filler tokens we have to examine the behavior of the tokens under the scaffold solution. First of all, every enforcement token is clearly moved to its target location by the scaffold solution. This is because the moves included in the scaffold solution are exactly the ones that are necessary in order to move the enforcement tokens to their target destinations. For the item tokens, we use the following lemma: \begin{lemma} \label{lemma:parallel-scaffold-item} The scaffold solution brings each item token to a final location that is the target location of some item token (though not necessarily the token's own target destination). \end{lemma} Then we can ask the question of where the scaffold solution brings the filler tokens. The enforcement tokens each end up in their own target locations. The $m+1$ item tokens each end up in a target location of an item token, and since there are only $m+1$ such locations (and the scaffold solution certainly doesn't bring two item tokens into the same location), we can conclude that the $m+1$ item tokens end up in the $m+1$ item token target locations. Therefore the end locations of the filler tokens under the scaffold solution are exactly those vertices that are not target locations of item or enforcement tokens. Since the target location of a filler token is defined to be its end location under the scaffold solution, we can conclude that every token is assigned a unique target location. \subsubsection{Permutation \texorpdfstring{$\pi$}{σ}} Since we have defined the start and end positions of the three types of tokens, we can define the permutation $\pi$. For every vertex $v$, let $\pi(v)$ be the end location of the token that starts at $v$. Since every vertex has exactly one token starting there, this is well defined. Since no two tokens share an end location, this is a permutation. \subsubsection{Proof of Lemmas~\ref{lemma:parallel-scaffold-legal} and \ref{lemma:parallel-scaffold-item}} In Section~\ref{sec:Filler Tokens}, we left out the proofs of two lemmas. Provided that those two lemmas hold, the reduction is clearly well defined and furthermore can be computed in polynomial time. Thus, all that's left in order to conclude NP-hardness of parallel token swapping is to prove the lemmas, which we do here, and prove the answer-preserving property of the reduction, which we do in the following sections. \begin{proof}[Proof of Lemma~\ref{lemma:parallel-scaffold-legal}] \emph{The scaffold solution does not include any pair of simultaneous swaps that share a vertex.} Every swap in the scaffold solution includes an enforcement token. All enforcement tokens always share the same parity of distance from $r$. Therefore, the only two ways for the scaffold solution to include a pair of simultaneous swaps that share a vertex is (1) two enforcement tokens both swap into the same vertex, or (2) two enforcement tokens at the same vertex both swap out of that vertex. In either case, there must be two enforcement tokens in the same place in order for the scaffold solution to have a pair of simultaneous swaps sharing a vertex. Clearly no pair of enforcement tokens is ever at $r$ at the same time (since each $e_d$ is at $r$ immediately after round $d$). Therefore, in order to be in the same place at the same time, the enforcement tokens would have to meet inside some branch. But then, some enforcement token would have to enter a branch before a different enforcement token exits that branch. Note that this is the condition that the proof idea section explicitly said we would need to avoid. Checking that no branch has an enforcement token enter before another one leaves is tedious but not difficult. We now consider, in turn, each type of branch: the swap branch, the garbage branch, and the slot branch. For each \textbf{swap branch} $w^t$ only four enforcement tokens ever enter or leave. The two that leave are $e_{8t-7}$, which exits during round $8t-7$, and $e_{8t-5}$, which exits during round $8t-5$. The two that enter are $e-{8t-3}$, which enters during round $8t-2$, and $e_{8t-1}$, which enters during round $8t$. Clearly, enforcement tokens never enter before another enforcement token leaves. The \textbf{garbage branch} $g$ only ever has enforcement tokens enter it, while the other garbage branch $g'$ only ever has enforcement tokens exit it. Each \textbf{slot branch} $s^i$ has at most one enforcement token enter it. This is because the only enforcement tokens to enter a slot branch are the ones of the form $e_{8t-7}$, which enter branch $y^{8t-7} = s^{a(s_t,t-1)}$ during round $8t-6$. For every $t$, $a(s_t,t-1)$ is a unique value (since by the definition of $a$, once $a(s_t,t-1)$ is replaced by $a(s_t,t)=m+t$, the value $a(s_t,t-1)$ can never occur again as an output of $a$). Therefore each such enforcement token enters exactly one such slot branch. Similarly, each slot branch $s^i$ has at most one enforcement token exit it. This is because the only enforcement tokens to exit a slot branch are the ones of the form $e_{8t-1}$, which exit branch $x^{8t-1} = s^{a(s_t,t)}=s^{m+t}$ during round $8t-1$. In order for an enforcement token to enter a slot branch before a different enforcement token exits the branch, it would have to be the case that $i = a(s_t,t-1)$ and $i = m+t'$ with $8t-6 < 8t'-1$. This is equivalent to $t \le t'$. But notice that the maximum value of $a(\cdot, \tau)$ is always $m+\tau$. Therefore $i = a(s_t,t-1) \le m + t - 1 \le m+t' - 1 = i - 1$. Clearly it cannot be that $i \le i-1$, and so we conclude that an enforcement token enters a slot branch $s^i$ only after other enforcement tokens have exited the branch. This concludes the casework, proving that two enforcement tokens never collide in the scaffold solution and therefore that the scaffold solution never includes two simultaneous swaps sharing a vertex. \end{proof} \begin{proof}[Proof of Lemma~\ref{lemma:parallel-scaffold-item}] \emph{The scaffold solution brings each item token to a final location that is the target location of some item token (though not necessarily the token's own target destination).} In order to prove this, we will prove by induction that for $0 \le t \le n$, after round $8t$, the item tokens are located at $r$ and at vertices $s^{a(i, t)}_1$ for $1 \le i \le m$. By definition this is true for $t = 0$: After round $0$ (that is, right at the beginning), the item tokens were defined to be at locations $r$ and $s^{a(i,0)}_1$ for $1 \le i \le m$, exactly where we wanted to show they would be. Next suppose that for some $1\le t \le n$, it was the case that after round $8(t-1)$, the item tokens are located at $r$ and at vertices $s^{a(i, t-1)}_1$ for $1 \le i \le m$. Let's see what happens in the scaffold solution over the course of rounds $8t-7$ through $8t$. This is depicted in Figure~\ref{fig:ParallelSwap}. The item tokens are all located within distance $1$ of $r$, and so the only enforcement tokens that can move the item tokens are the ones that get close to $r$ during these 8 rounds. In particular, it is easy to verify that the only relevant enforcement tokens are $e_{8t-7}$, $e_{8t-5}$, $e_{8t-3}$, and $e_{8t-1}$. Token $e_{8t-7}$ moves from $w^t_1$ to $s^{a(s_t, t-1)}_7$ over these 8 rounds. $e_{8t-5}$ moves from $w^t_3$ to $g_5$. $e_{8t-3}$ moves from $g'_5$ to $w^t_3$. $e_{8t-1}$ moves from $s^{a(s_t, t)}_7$ to $w^t_1$. \begin{figure} \centering \includegraphics[width=.8\linewidth]{Figures/parallelTokenFigures.pdf} \caption{Position of item and enforcement tokens during rounds $8t-7$ to $8t$. Branches as well as vertices containing enforcement and item tokens are labeled.} \label{fig:ParallelSwap} \end{figure} Here's the effect of these enforcement tokens on the item tokens. On round $8t-7$, token $e_{8t-7}$ moves the item token at $r$, call it $A$, into $w^t_1$. Next, on round $8t-6$, token $e_{8t-5}$ moves that same item token, $A$, into $w^t_2$, while simultaneously $e_{8t-7}$ moves the item token at $s^{a(s_t, t-1)}_1$, call it $B$, into $r$. On round $8t-5$, token $e_{8t-5}$ moves $B$ into $w^t_1$. During rounds $8t-4$ and $8t-3$, no item tokens move. On round $8t-2$, token $e_{8t-3}$ moves into $w^t_1$ from $r$, and as a result $B$ moves back into $r$. Next, on round $8t-1$, token $e_{8t-3}$ moves $A$ into $w^t_1$, while simultaneously token $e_{8t-1}$ moves $B$ from $r$ into $s^{a(s_t,t)}_1$. Finally, on round $8t$, token $e_{8t-1}$ moves $A$ into $r$. All other movements of non-enforcement tokens due to the scaffold solution are not movements of item tokens. The result on item tokens is that $A$, which started at $r$, is moved back into $r$, while $B$, which started at $s^{a(s_t, t-1)}_1$, is moved into $s^{a(s_t, t)}_1$. Note that $s^{a(i, t-1)}_1 = s^{a(i,t)}_1$ whenever $i \ne s_t$. Therefore, all the other item tokens, which started at $s^{a(i, t-1)}_1$ with $i \ne s_t$, end up at $s^{a(i,t)}_1$. And as we saw, the item token ($A$) that was previously at $r$ stays at $r$ and the item token ($B$) that was previously at $s^{a(i, t-1)}_1$ with $i = s_t$ ends up at $s^{a(i, t)}_1$. Thus, as desired, after round $8t$, the item tokens are located at $r$ and at vertices $s^{a(i, t)}_1$ for $1 \le i \le m$. By induction, this same statement holds for every $t$ with $0 \le t \le n$. In particular, applying it to $t = n$, we see that the item tokens are located at $r$ and the vertices $s^{a(i, n)}_1$ for $1 \le i \le m$ after $8n$ rounds of the scaffold solution (i.e. at the end of it). But those are exactly the target locations of item tokens, which is what we wanted to prove. \end{proof} \subsection{Star STS solution \texorpdfstring{$\to$}{-->} parallel token swapping solution} \label{sec:parallel-forward} Suppose we have a solution to a Star STS instance. Then consider the parallel token swapping instance produced by the reduction from the previous section. Let $S$ be the scaffold solution. We will build a different solution $S'$ by adding some swaps to $S$. Consider the solution to the Star STS instance. For $1\le t \le n$, if swap $t$ is used in the Star STS solution, then add a swap of vertices $w^t_1$ and $w^t_2$ during round $8t-4$ to $S'$. First of all, it is easy to verify that no enforcement token swaps into or out of either $w^t_1$ or $w^t_2$ during round $8t-4$. Therefore, $S'$ is a valid schedule of swaps for the parallel token swapping instance. In fact, we will show that $S'$ solves the instance. The main idea of this proof is that $S'$ maintains the following invariant: \begin{lemma} \label{lemma:parallel-forward-lemma-1} If $0 \le t \le n$ then after round $8t$ of $S$, one of the item tokens is located at $r$ and the other $m$ item tokens are in the active slot branches $s^{a(\cdot, t)}$, each in the vertex of that branch which is adjacent to the root. In particular, consider the state of the Star STS instance after the first $t$ swaps are each either used or not according to the solution. The item token located at $r$ will correspond to the item at the root, while the item token in active slot branch $s^{a(i, t)}$ will correspond to the item in slot $i$. \end{lemma} In the process of proving this, we will also show the following: \begin{lemma} \label{lemma:parallel-forward-lemma-2} During round $8t-4$ of $S'$, the two tokens in vertices $w^t_1$ and $w^t_2$ will always be item tokens. \end{lemma} We can use these two lemmas to prove that $S'$ brings every token to its target destination (within $K$ rounds), and therefore that $S'$ is a solution to the parallel token swapping instance. Consider first any token that is not an item token. We know that the scaffold solution $S$ brings every such token to its target location. But $S'$ is just $S$ with some swaps added. In particular, by Lemma~\ref{lemma:parallel-forward-lemma-2}, we know that every swap that was added is between two item tokens. Therefore, the result of $S'$ will be the same as the result of $S$, but with the item tokens permuted in some way. In particular, just as $S$ brings the non-item tokens to their target locations, $S'$ does the same. Now consider the item tokens. Let $i$ be an item token. There are two cases. Either the final position of the corresponding item $i$ is $\pi(i) = 0$ or the final position of item $i$ is some slot $\pi(i)$. In the first case, item $i$ ends up at the root ($\pi(i) = 0$). Therefore, in the Star STS solution, item $i$ is at the root after the entire solution. Phrased a little more verbosely, we have that after the first $t=n$ swaps are each either used or not according to the Star STS solution, item $i$ is at the root. But then by Lemma~\ref{lemma:parallel-forward-lemma-1} applied to $t = n$, we know that the item token at $r$ after $8t = 8n = K$ rounds of $S'$ (the entirety of $S'$) is exactly the item token $i$. But when we were defining the target location of an item token, we gave the item token $i$ for which $\pi(i)=0$ the vertex $r$ as its target location. Therefore in this case the item token is brought to its target location by $S'$. In the second case, the final position of item $i$ is some slot $\pi(i)$. Then in the Star STS solution, item $i$ is in slot $\pi(i)$ after the entire solution, or equivalently after the first $t=n$ swaps are each either used or not according to the Star STS solution. Then by Lemma~\ref{lemma:parallel-forward-lemma-1} applied to $t = n$, we know that the item token at $s^{a(\pi(i),t)} = s^{a(\pi(i),n)}$ after $8t = 8n = K$ rounds of $S'$ (the entirety of $S'$) is exactly the item token $i$. If we look back at the target location that was assigned to an item token $i$ with $\pi(i) \ne 0$, the target location was $s^{a(\pi(i), n)}$. Thus, in this case also we see that the item token is brought to its target location by $S'$. Since $S'$ consists of $K$ legal rounds of swaps which bring every token to its target location, we can conclude that as desired, $S'$ solves the parallel token swapping instance. \subsubsection{Proof of Lemma~\ref{lemma:parallel-forward-lemma-1} and~Lemma~\ref{lemma:parallel-forward-lemma-2}} \begin{proof}[Proof of Lemma~\ref{lemma:parallel-forward-lemma-1}] \emph{ If $0 \le t \le n$ then after round $8t$ of $S$, one of the item tokens is located at $r$ and the other $m$ item tokens are in the active slot branches $s^{a(\cdot, t)}$, each in the vertex of that branch which is adjacent to the root. In particular, consider the state of the Star STS instance after the first $t$ swaps are each either used or not according to the solution. The item token located at $r$ will correspond to the item at the root, while the item token in active slot branch $s^{a(i, t)}$ will correspond to the item in slot $i$. } This Lemma can be proved by an inductive argument almost identical to the proof of Lemma~\ref{lemma:parallel-scaffold-item}. The only difference is that instead of tracking the positions of the item tokens as a group, we track the position of each item token individually. Also, due to the swap that may have been added, the two item tokens that were called $A$ and $B$ in the proof may end up swapped (this is because the swap that might have been added to $S$ to get $S'$ depending on the Star STS solution, is a swap of two vertices which contain $A$ and $B$ at the time). Figure~\ref{fig:ParallelSwap} remains an accurate depiction, except that $A$ and $B$ will be swapped after round $8t-4$. In this new induction, if the Star STS solution does not involve a swap, then the analysis is exactly the same as in the previous proof: $A$ starts at $r$ and ends at $r$, $B$ starts at $s^{a(s_t, t-1)}_1$, and ends at $s^{a(s_t, t)}_1$, and every other item token starts at $s^{a(i, t-1)}_1$ and ends at $s^{a(i, t)}_1$ (which happens to be the same vertex). Under the correspondence with the Star STS instance, this corresponds with none of the items moving. If, on the other hand, the Star STS solution involves a swap, then as previously mentioned, the end result is that item tokens $A$ and $B$ are swapped. $A$ and $B$ are the tokens which were previously at $r$ and $s^{a(s_t, t-1)}_1$, which means that they corresponded to the items previously at the root and in slot $s_t$. Then the result of these 8 rounds is that the two item tokens are swapped relative to their positions in the previous case, which exactly corresponds to the fact that during step $t$ of the Star STS solution, the item in slot $s_t$ and the item at the root swap. \end{proof} \begin{proof}[Proof of Lemma~\ref{lemma:parallel-forward-lemma-2}] \emph{ During round $8t-4$ of $S'$, the two tokens in vertices $w^t_1$ and $w^t_2$ will always be item tokens.} This follows directly from the previous proof, where we saw that the two tokens in these positions at that time are the item tokens referred to as $A$ and $B$. \end{proof} \subsection{Parallel Token Swapping solution \texorpdfstring{$\to$}{-->} Star STS solution} \label{sec:parallel-backward} Suppose we started with a Star STS instance and used the reduction to construct the corresponding parallel token swapping instance, and that this instance had a solution $S'$. We will show that $S'$ can be used to construct a solution to the Star STS instance, which together with the results of the previous section shows that the reduction is answer-preserving. The key idea will be to consider the location of each item token after rounds $0,8,16,\ldots, 8n=K$ of $S'$. In particular, we will care only about whether the token is at the root or otherwise which branch the token is in, not where in a branch the item token can be found. We know that each enforcement token must move a distance of $K$ from its start location to its target destination. Therefore, the token must be swapped towards its destination during every round of $S'$. Thus every swap from the scaffold solution $S$ must be present in $S'$. We wish to know how the branches of the item tokens change over time. But a token switches branches only by passing through $r$. Therefore, we can consider which swaps of $S'$ involve $r$. In fact, the enforcement tokens were specifically chosen so that $S$ would include a swap involving $r$ on every round. Therefore, the only swaps involving $r$ in $S'$ are the swaps involving $r$ from $S$. What are those swaps? Well if $d$ is odd, then on round $d$, enforcement token $e_d$ swaps into $r$ from vertex $x^d_1$, and on round $d+1$, enforcement token $e_d$ swaps out of $r$ and into vertex $y^d_1$. Phrased differently, if $d$ is odd, then on round $d$, a non-enforcement token moves from $r$ into branch $x^d$, and on round $d+1$, a non-enforcement token moves from branch $y^d$ into $r$. Then let us consider the 8 such movements starting after round $8t-8$ and ending after round $8t$: \begin{itemize} \item On round $8t-7$, the token at $r$ moves into branch $x^{8t-7}=w^t$ \item On round $8t-6$, some non-enforcement token in branch $y^{8t-7}=s^{a(s_t, t-1)}$ moves into $r$ \item On round $8t-5$, the token at $r$ moves into branch $x^{8t-5}=w^t$ \item On round $8t-4$, some non-enforcement token in branch $y^{8t-5}=g$ moves into $r$ \item On round $8t-3$, the token at $r$ moves into branch $x^{8t-3}=g'$ \item On round $8t-2$, some non-enforcement token in branch $y^{8t-3}=w^t$ moves into $r$ \item On round $8t-1$, the token at $r$ moves into branch $x^{8t-1}=s^{a(s_t, t)}$ \item On round $8t$, some non-enforcement token in branch $y^{8t-1}=w^t$ moves into $r$ \end{itemize} As before, these correspond to swaps depicted in Figure~\ref{fig:ParallelSwap}. Some of these bullet points can be combined together. Overall, the effect of these 8 rounds (starting after round $8t-8$ and ending after round $8t$) on the branches of non-enforcement tokens is the following: \begin{enumerate} \item the token at $r$ moves into branch $w^t$ \item some non-enforcement token in branch $s^{a(s_t, t-1)}$ moves into branch $w^t$ \item some non-enforcement token in branch $g$ moves into branch $g'$ \item some non-enforcement token in branch $w^t$ moves into branch $s^{a(s_t, t)}$ \item some non-enforcement token in branch $w^t$ moves into $r$ \end{enumerate} In fact, we will show that most of these movements are movements of not just non-enforcement tokens, but more specifically item tokens. \begin{lemma} \label{lemma:parallel-backward-lemma} Every movement of non-enforcement tokens between branches in $S'$ (as described by the above list) is either a movement from branch $g$ into branch $g'$ or a movement of an item token. \end{lemma} Assuming that can be proven, we can then show that the movement of item tokens between branches in $S'$ corresponds to the movement of items between slots in the Star STS instance. In particular, after round $8t$ for $0 \le t \le n$, there will be one item token at $r$, and one item token in slot branch $s^{a(i, t)}$ for each $i \in \{1, \ldots, m\}$. Furthermore, the change between round $8(t-1)$ and round $8t$ will always correspond to either using or not using the swap $s_t$. Certainly, for $t=0$, this holds: there is one item token, $0$, at $r$, and each item token $i$ for $i\in \{1, \ldots, m\}$ is in slot branch $s^{a(i, 0)} = s^i$. In the Star STS instance, item $0$ is at the root, while each other item $i$ is in slot $i$. Next, suppose by the inductive hypothesis that for some $1 \le t \le n$, the above statement holds with $t-1$: after round $8(t-1)$ of $S'$, there was one item token at $r$, and one item token in slot branch $s^{a(i, t)}$ for each $i \in \{1, \ldots, m\}$. Let's see what movements of item tokens happen between rounds $8(t-1)$ and $8t$. According to the list above, (1) the item token at $r$ moves into branch $w^t$, (2) the item token in branch $s^{a(s_t, t-1)}$ moves into branch $w^t$, (3) some non-enforcement token in branch $g$ moves into branch $g'$, (4) an item token in branch $w^t$ moves into branch $s^{a(s_t, t)}$, and (5) the final item token in branch $w^t$ moves into $r$. Note that since there are no item tokens in $g$, the token moving in (3) must be a filler token. Thus, the overall movement of item tokens is this: first the item tokens at $r$ and in branch $s^{a(s_t, t-1)}$ are moved into $w^t$, then one of those tokens moves into branch $s^{a(s_t, t)}$, and the other moves to $r$. Every other item token, in branch $s^{a(i, t-1)}$ with $i \ne s_t$, stays in that branch. But by the definition of $a$, $a(i, t) = a(i, t-1)$ precisely when $i \ne s_t$. So the item token from branch $s^{a(i, t-1)}$ with $i \ne s_t$ ended up in branch $s^{a(i, t)}$, while the two item tokens at $r$ and in branch $s^{a(s_t, t-1)}$ ended up at $r$ and in branch $s^{a(s_t, t)}$, in some order. Then the inductive hypothesis holds: after round $8t$ of $S'$, there is one item token at $r$, and one item token in slot branch $s^{a(i, t)}$ for each $i \in \{1, \ldots, m\}$. Furthermore, as we wanted to prove, the change between round $8(t-1)$ and round $8t$ always corresponds to either using or not using the swap $s_t$, depending on the arrangement of the two item tokens that moved from vertex $r$ and branch $s^{a(s_t, t-1)}$ to vertex $r$ and branch $s^{a(s_t, t)}$. Thus, we can simply read off the movement of the items in a solution to the Star STS instance from the movement of the item tokens in $S'$. Now all that remains is to prove the needed lemma. \begin{proof}[Proof of Lemma~\ref{lemma:parallel-backward-lemma}] \emph{ Every movement of non-enforcement tokens between branches in $S'$ (as described by the above list) is either a movement from branch $g$ into branch $g'$ or a movement of an item token.} The list is reproduced below: \begin{enumerate} \item the token at $r$ moves into branch $w^t$ \item some non-enforcement token in branch $s^{a(s_t, t-1)}$ moves into branch $w^t$ \item some non-enforcement token in branch $g$ moves into branch $g'$ \item some non-enforcement token in branch $w^t$ moves into branch $s^{a(s_t, t)}$ \item some non-enforcement token in branch $w^t$ moves into $r$ \end{enumerate} For the moment, assume the following three statements which will be argued at the end of the proof: \begin{enumerate} \item For every slot branch $s^i$, there is exactly one way that an item token can get into the branch; either the slot token starts there or there is one movement according to the list which can move a non-enforcement token into the branch. \item Similarly, for every slot branch $s^i$, either there is an item token that has that branch as a target location, or there is exactly one movement according to the list which can move a non-enforcement token out of the branch, but not both. \item Finally, every swap branch $w^t$ has two movements on the list that can move a non-enforcement token into $w^t$, followed by two movements that can move a non-enforcement token out of $w^t$. \end{enumerate} We can combine these facts into a proof by induction. Consider all of the movements from the list other than those from $g$ to $g'$ in order according to $S'$. We will prove that all of these movements are movements of an item token. Suppose this is true up to a certain movement, call it $M$ in the list. Case 1: $M$ moves a non-enforcement token from a slot branch $s^i$ into some other branch. By applying fact 2 to $s^i$, we know that $M$ is the only time that a non-enforcement token can leave branch $s^i$ and also that no item token has a target location in $s^i$. We can also apply fact 1 from the list above to $s^i$, yielding two cases. Case 1a: $s^i$ started with an item token in it. Since no item token has a target location in $s^i$ and $M$ is the only opportunity for the item token to leave $s^i$, the token must take that opportunity in order to be able to reach its target location. Thus, $M$ must have been used to move an item token. Case 1b: there is one movement $M'$ somewhere in the list which can move a non-enforcement token into $s^i$. $M'$ must have occurred before $M$. This is because $M'$ corresponds to an enforcement token leaving $s^i$, $M$ corresponds to an enforcement token entering $s^i$, and as we saw in Lemma~\ref{lemma:parallel-scaffold-legal}, an enforcement token never enters a branch before another enforcement token leaves that same branch. Since $M'$ occurred before $M$, the inductive hypothesis applies: $M'$ must have moved an item token. But then there is an item token currently in $s^i$. As in case 1a, $M$ is the only opportunity for that item token to leave $s^i$, and so the token must take that opportunity in order to be able to reach its target location. Thus, $M$ must have been used to move an item token. Case 2: $M$ moves a non-enforcement token from a swap branch $w^t$ into another branch. Applying fact 3 from above, we see that $M$ must be one of the two movements $M_{out}^1$ or $M_{out}^2$ out of $w^t$ and must be preceded by exactly two movements $M_{in}^1$ and $M_{in}^2$ into $w^t$. The inductive hypothesis applies to both $M_{in}^1$ and $M_{in}^2$ since they precede $M$. Therefore, each of them moved an item token into $w^t$. As a result, after $M_{in}^1$ and $M_{in}^2$, there were two item tokens in $w^t$, neither of which has a target location in $w^t$. Since there are only two opportunities for an item token to leave $w^t$ ($M_{out}^1$ and $M_{out}^2$), it must be the case that the two item tokens make use of those two opportunities to leave the swap branch, since otherwise they would be unable to reach their target locations. Thus, both $M_{out}^1$ and $M_{out}^2$ must move an item token, and so $M$, which is one of the two, must have been used to move an item token. Since in all cases we conclude that $M$ moved an item token, the proof by induction goes through; every movement on the list other than those from $g$ to $g'$ must move an item token. All that's left is to confirm the three facts listed at the top of this proof. Proof of Fact 1: The only movements on the list that are directed into a slot branch $s^i$ are the movements from $w^t$ to $s^{a(s_t, t)}$ for $1\le t \le n$. There are two cases. If $i \in \{a(j, 0) \mid 1 \le j \le m\}=\{1, \ldots, m\}$, then $1 \le i \le m$. On the other hand $a(s_t, t) = m+t > m$, and so in this case the branch $s^{a(s_t, t)}$ will never equal $s^i$. We also see that in this case $s^i$ is exactly one of the slot branches that initially contains an item token. On the other hand, if $i \not\in \{a(j, 0) \mid 1 \le j \le m\}$ then $i > m$, and so $a(s_{i-m}, {i-m}) = m + (i-m) = i$. Thus, exactly one of the movements from $w^t$ to $s^{a(s_t, t)}$ (in particular the one with $t = i-m$) will move a non-enforcement token into $s^i$. Notice, however, that in this case $s^i$ does not start with an item token. Thus we have shown exactly fact 1: for every slot branch $s^i$, there is exactly one way that an item token can get into the branch; either the slot token starts there or there is one movement according to the list which can move a non-enforcement token into the branch. Proof of Fact 2: The only movements on the list that are directed out of a slot branch $s^i$ are the ones from $s^{a(s_t, t-1)}$ to $w^t$. Recall the recursive definition of $a$: $a(\cdot, 0)$ takes on the values $1$ through $m$, $a(\cdot, 1)$ replaces one of those values, $a(s_1,0)$ with $a(s_1, 1) = m+1$, then $a(\cdot, 2)$ replaces one of the remaining values, $a(s_2, 1)$, with $a(s_2, 2) = m+2$, etc... If $i \in \{a(j, n) \mid 1 \le j \le m\}$, then the value $i$ was never replaced out of the range of $a(\cdot, t)$ all the way until $t = n$. Therefore, in this case we see that $a(s_t, t-1)$ was not equal to $i$ for any $t$, and so none of the movements from $s^{a(s_t, t-1)}$ to $w^t$ are directed out of $s^i$. Note, however, that since $i \in \{a(j, n) \mid 1 \le j \le m\}$, we have that $s^i = s^{a(j, n)}$ for some $j$, and therefore that $s^i$ contains the target destination of some item token. On the other hand, if $i \not\in \{a(j, n) \mid 1 \le j \le m\}$, then the value $i$ was replaced out of the range of $a(\cdot, t)$ at some $t$. Therefore, in this case we see that $a(s_t, t-1)$ was equal to $i$ for exactly one $t$, and so exactly one of the movements from $s^{a(s_t, t-1)}$ to $w^t$ must have been directed out of $s^i$. In other words, we have demonstrated fact 2: for every slot branch $s^i$, either there is an item token that has that branch as a target location, or there is exactly one movement according to the list which can move a non-enforcement token out of the branch, but not both. Proof of Fact 3: Consider any swap branch $w^t$, the only occurrences of that branch are for the instance of the list of movements which corresponds with this specific value of $t$. In this instance of the list, there are four movements involving $w^t$. There are two movements on the list that can move a non-enforcement token into $w^t$, followed by two movements that can move a non-enforcement token out of $w^t$. \end{proof}
{'timestamp': '2021-03-12T02:25:31', 'yymm': '2103', 'arxiv_id': '2103.06707', 'language': 'en', 'url': 'https://arxiv.org/abs/2103.06707'}
arxiv
\section{Submission of conference papers to ICLR 2021} ICLR requires electronic submissions, processed by \url{https://openreview.net/}. See ICLR's website for more instructions. If your paper is ultimately accepted, the statement {\tt {\textbackslash}iclrfinalcopy} should be inserted to adjust the format to the camera ready requirements. The format for the submissions is a variant of the NeurIPS format. Please read carefully the instructions below, and follow them faithfully. \subsection{Style} Papers to be submitted to ICLR 2021 must be prepared according to the instructions presented here. Authors are required to use the ICLR \LaTeX{} style files obtainable at the ICLR website. Please make sure you use the current files and not previous versions. Tweaking the style files may be grounds for rejection. \subsection{Retrieval of style files} The style files for ICLR and other conference information are available online at: \begin{center} \url{http://www.iclr.cc/} \end{center} The file \verb+iclr2021_conference.pdf+ contains these instructions and illustrates the various formatting requirements your ICLR paper must satisfy. Submissions must be made using \LaTeX{} and the style files \verb+iclr2021_conference.sty+ and \verb+iclr2021_conference.bst+ (to be used with \LaTeX{}2e). The file \verb+iclr2021_conference.tex+ may be used as a ``shell'' for writing your paper. All you have to do is replace the author, title, abstract, and text of the paper with your own. The formatting instructions contained in these style files are summarized in sections \ref{gen_inst}, \ref{headings}, and \ref{others} below. \section{General formatting instructions} \label{gen_inst} The text must be confined within a rectangle 5.5~inches (33~picas) wide and 9~inches (54~picas) long. The left margin is 1.5~inch (9~picas). Use 10~point type with a vertical spacing of 11~points. Times New Roman is the preferred typeface throughout. Paragraphs are separated by 1/2~line space, with no indentation. Paper title is 17~point, in small caps and left-aligned. All pages should start at 1~inch (6~picas) from the top of the page. Authors' names are set in boldface, and each name is placed above its corresponding address. The lead author's name is to be listed first, and the co-authors' names are set to follow. Authors sharing the same address can be on the same line. Please pay special attention to the instructions in section \ref{others} regarding figures, tables, acknowledgments, and references. There will be a strict upper limit of 8 pages for the main text of the initial submission, with unlimited additional pages for citations. Note that the upper page limit differs from last year!Authors may use as many pages of appendices (after the bibliography) as they wish, but reviewers are not required to read these. During the rebuttal phase and for the camera ready version, authors are allowed one additional page for the main text, for a strict upper limit of 9 pages. \section{Headings: first level} \label{headings} First level headings are in small caps, flush left and in point size 12. One line space before the first level heading and 1/2~line space after the first level heading. \subsection{Headings: second level} Second level headings are in small caps, flush left and in point size 10. One line space before the second level heading and 1/2~line space after the second level heading. \subsubsection{Headings: third level} Third level headings are in small caps, flush left and in point size 10. One line space before the third level heading and 1/2~line space after the third level heading. \section{Citations, figures, tables, references} \label{others} These instructions apply to everyone, regardless of the formatter being used. \subsection{Citations within the text} Citations within the text should be based on the \texttt{natbib} package and include the authors' last names and year (with the ``et~al.'' construct for more than two authors). When the authors or the publication are included in the sentence, the citation should not be in parenthesis using \verb|\citet{}| (as in ``See \citet{Hinton06} for more information.''). Otherwise, the citation should be in parenthesis using \verb|\citep{}| (as in ``Deep learning shows promise to make progress towards AI~\citep{Bengio+chapter2007}.''). The corresponding references are to be listed in alphabetical order of authors, in the \textsc{References} section. As to the format of the references themselves, any style is acceptable as long as it is used consistently. \subsection{Footnotes} Indicate footnotes with a number\footnote{Sample of the first footnote} in the text. Place the footnotes at the bottom of the page on which they appear. Precede the footnote with a horizontal rule of 2~inches (12~picas).\footnote{Sample of the second footnote} \subsection{Figures} All artwork must be neat, clean, and legible. Lines should be dark enough for purposes of reproduction; art work should not be hand-drawn. The figure number and caption always appear after the figure. Place one line space before the figure caption, and one line space after the figure. The figure caption is lower case (except for first word and proper nouns); figures are numbered consecutively. Make sure the figure caption does not get separated from the figure. Leave sufficient space to avoid splitting the figure and figure caption. You may use color figures. However, it is best for the figure captions and the paper body to make sense if the paper is printed either in black/white or in color. \begin{figure}[h] \begin{center} \fbox{\rule[-.5cm]{0cm}{4cm} \rule[-.5cm]{4cm}{0cm}} \end{center} \caption{Sample figure caption.} \end{figure} \subsection{Tables} All tables must be centered, neat, clean and legible. Do not use hand-drawn tables. The table number and title always appear before the table. See Table~\ref{sample-table}. Place one line space before the table title, one line space after the table title, and one line space after the table. The table title must be lower case (except for first word and proper nouns); tables are numbered consecutively. \begin{table}[t] \caption{Sample table title} \label{sample-table} \begin{center} \begin{tabular}{ll} \multicolumn{1}{c}{\bf PART} &\multicolumn{1}{c}{\bf DESCRIPTION} \\ \hline \\ Dendrite &Input terminal \\ Axon &Output terminal \\ Soma &Cell body (contains cell nucleus) \\ \end{tabular} \end{center} \end{table} \section{Default Notation} In an attempt to encourage standardized notation, we have included the notation file from the textbook, \textit{Deep Learning} \cite{goodfellow2016deep} available at \url{https://github.com/goodfeli/dlbook_notation/}. Use of this style is not required and can be disabled by commenting out \texttt{math\_commands.tex}. \centerline{\bf Numbers and Arrays} \bgroup \def1.5{1.5} \begin{tabular}{p{1in}p{3.25in}} $\displaystyle a$ & A scalar (integer or real)\\ $\displaystyle {\bm{a}}$ & A vector\\ $\displaystyle {\bm{A}}$ & A matrix\\ $\displaystyle {\tens{A}}$ & A tensor\\ $\displaystyle {\bm{I}}_n$ & Identity matrix with $n$ rows and $n$ columns\\ $\displaystyle {\bm{I}}$ & Identity matrix with dimensionality implied by context\\ $\displaystyle {\bm{e}}^{(i)}$ & Standard basis vector $[0,\dots,0,1,0,\dots,0]$ with a 1 at position $i$\\ $\displaystyle \text{diag}({\bm{a}})$ & A square, diagonal matrix with diagonal entries given by ${\bm{a}}$\\ $\displaystyle {\textnormal{a}}$ & A scalar random variable\\ $\displaystyle {\mathbf{a}}$ & A vector-valued random variable\\ $\displaystyle {\mathbf{A}}$ & A matrix-valued random variable\\ \end{tabular} \egroup \vspace{0.25cm} \centerline{\bf Sets and Graphs} \bgroup \def1.5{1.5} \begin{tabular}{p{1.25in}p{3.25in}} $\displaystyle {\mathbb{A}}$ & A set\\ $\displaystyle \mathbb{R}$ & The set of real numbers \\ $\displaystyle \{0, 1\}$ & The set containing 0 and 1 \\ $\displaystyle \{0, 1, \dots, n \}$ & The set of all integers between $0$ and $n$\\ $\displaystyle [a, b]$ & The real interval including $a$ and $b$\\ $\displaystyle (a, b]$ & The real interval excluding $a$ but including $b$\\ $\displaystyle {\mathbb{A}} \backslash {\mathbb{B}}$ & Set subtraction, i.e., the set containing the elements of ${\mathbb{A}}$ that are not in ${\mathbb{B}}$\\ $\displaystyle {\mathcal{G}}$ & A graph\\ $\displaystyle \parents_{\mathcal{G}}({\textnormal{x}}_i)$ & The parents of ${\textnormal{x}}_i$ in ${\mathcal{G}}$ \end{tabular} \vspace{0.25cm} \centerline{\bf Indexing} \bgroup \def1.5{1.5} \begin{tabular}{p{1.25in}p{3.25in}} $\displaystyle {a}_i$ & Element $i$ of vector ${\bm{a}}$, with indexing starting at 1 \\ $\displaystyle {a}_{-i}$ & All elements of vector ${\bm{a}}$ except for element $i$ \\ $\displaystyle {A}_{i,j}$ & Element $i, j$ of matrix ${\bm{A}}$ \\ $\displaystyle {\bm{A}}_{i, :}$ & Row $i$ of matrix ${\bm{A}}$ \\ $\displaystyle {\bm{A}}_{:, i}$ & Column $i$ of matrix ${\bm{A}}$ \\ $\displaystyle {\etens{A}}_{i, j, k}$ & Element $(i, j, k)$ of a 3-D tensor ${\tens{A}}$\\ $\displaystyle {\tens{A}}_{:, :, i}$ & 2-D slice of a 3-D tensor\\ $\displaystyle {\textnormal{a}}_i$ & Element $i$ of the random vector ${\mathbf{a}}$ \\ \end{tabular} \egroup \vspace{0.25cm} \centerline{\bf Calculus} \bgroup \def1.5{1.5} \begin{tabular}{p{1.25in}p{3.25in}} $\displaystyle\frac{d y} {d x}$ & Derivative of $y$ with respect to $x$\\ [2ex] $\displaystyle \frac{\partial y} {\partial x} $ & Partial derivative of $y$ with respect to $x$ \\ $\displaystyle \nabla_{\bm{x}} y $ & Gradient of $y$ with respect to ${\bm{x}}$ \\ $\displaystyle \nabla_{\bm{X}} y $ & Matrix derivatives of $y$ with respect to ${\bm{X}}$ \\ $\displaystyle \nabla_{\tens{X}} y $ & Tensor containing derivatives of $y$ with respect to ${\tens{X}}$ \\ $\displaystyle \frac{\partial f}{\partial {\bm{x}}} $ & Jacobian matrix ${\bm{J}} \in \mathbb{R}^{m\times n}$ of $f: \mathbb{R}^n \rightarrow \mathbb{R}^m$\\ $\displaystyle \nabla_{\bm{x}}^2 f({\bm{x}})\text{ or }{\bm{H}}( f)({\bm{x}})$ & The Hessian matrix of $f$ at input point ${\bm{x}}$\\ $\displaystyle \int f({\bm{x}}) d{\bm{x}} $ & Definite integral over the entire domain of ${\bm{x}}$ \\ $\displaystyle \int_{\mathbb{S}} f({\bm{x}}) d{\bm{x}}$ & Definite integral with respect to ${\bm{x}}$ over the set ${\mathbb{S}}$ \\ \end{tabular} \egroup \vspace{0.25cm} \centerline{\bf Probability and Information Theory} \bgroup \def1.5{1.5} \begin{tabular}{p{1.25in}p{3.25in}} $\displaystyle P({\textnormal{a}})$ & A probability distribution over a discrete variable\\ $\displaystyle p({\textnormal{a}})$ & A probability distribution over a continuous variable, or over a variable whose type has not been specified\\ $\displaystyle {\textnormal{a}} \sim P$ & Random variable ${\textnormal{a}}$ has distribution $P$\\% so thing on left of \sim should always be a random variable, with name beginning with \r $\displaystyle \mathbb{E}_{{\textnormal{x}}\sim P} [ f(x) ]\text{ or } \mathbb{E} f(x)$ & Expectation of $f(x)$ with respect to $P({\textnormal{x}})$ \\ $\displaystyle \mathrm{Var}(f(x)) $ & Variance of $f(x)$ under $P({\textnormal{x}})$ \\ $\displaystyle \mathrm{Cov}(f(x),g(x)) $ & Covariance of $f(x)$ and $g(x)$ under $P({\textnormal{x}})$\\ $\displaystyle H({\textnormal{x}}) $ & Shannon entropy of the random variable ${\textnormal{x}}$\\ $\displaystyle D_{\mathrm{KL}} ( P \Vert Q ) $ & Kullback-Leibler divergence of P and Q \\ $\displaystyle \mathcal{N} ( {\bm{x}} ; {\bm{\mu}} , {\bm{\Sigma}})$ & Gaussian distribution % over ${\bm{x}}$ with mean ${\bm{\mu}}$ and covariance ${\bm{\Sigma}}$ \\ \end{tabular} \egroup \vspace{0.25cm} \centerline{\bf Functions} \bgroup \def1.5{1.5} \begin{tabular}{p{1.25in}p{3.25in}} $\displaystyle f: {\mathbb{A}} \rightarrow {\mathbb{B}}$ & The function $f$ with domain ${\mathbb{A}}$ and range ${\mathbb{B}}$\\ $\displaystyle f \circ g $ & Composition of the functions $f$ and $g$ \\ $\displaystyle f({\bm{x}} ; {\bm{\theta}}) $ & A function of ${\bm{x}}$ parametrized by ${\bm{\theta}}$. (Sometimes we write $f({\bm{x}})$ and omit the argument ${\bm{\theta}}$ to lighten notation) \\ $\displaystyle \log x$ & Natural logarithm of $x$ \\ $\displaystyle \sigma(x)$ & Logistic sigmoid, $\displaystyle \frac{1} {1 + \exp(-x)}$ \\ $\displaystyle \zeta(x)$ & Softplus, $\log(1 + \exp(x))$ \\ $\displaystyle || {\bm{x}} ||_p $ & $L^p$ norm of ${\bm{x}}$ \\ $\displaystyle || {\bm{x}} || $ & $L^2$ norm of ${\bm{x}}$ \\ $\displaystyle x^+$ & Positive part of $x$, i.e., $\max(0,x)$\\ $\displaystyle \bm{1}_\mathrm{condition}$ & is 1 if the condition is true, 0 otherwise\\ \end{tabular} \egroup \vspace{0.25cm} \section{Final instructions} Do not change any aspects of the formatting parameters in the style files. In particular, do not modify the width or length of the rectangle the text should fit into, and do not change font sizes (except perhaps in the \textsc{References} section; see below). Please note that pages should be numbered. \section{Preparing PostScript or PDF files} Please prepare PostScript or PDF files with paper size ``US Letter'', and not, for example, ``A4''. The -t letter option on dvips will produce US Letter files. Consider directly generating PDF files using \verb+pdflatex+ (especially if you are a MiKTeX user). PDF figures must be substituted for EPS figures, however. Otherwise, please generate your PostScript and PDF files with the following commands: \begin{verbatim} dvips mypaper.dvi -t letter -Ppdf -G0 -o mypaper.ps ps2pdf mypaper.ps mypaper.pdf \end{verbatim} \subsection{Margins in LaTeX} Most of the margin problems come from figures positioned by hand using \verb+\special+ or other commands. We suggest using the command \verb+\includegraphics+ from the graphicx package. Always specify the figure width as a multiple of the line width as in the example below using .eps graphics \begin{verbatim} \usepackage[dvips]{graphicx} ... \includegraphics[width=0.8\linewidth]{myfile.eps} \end{verbatim} or \begin{verbatim} \usepackage[pdftex]{graphicx} ... \includegraphics[width=0.8\linewidth]{myfile.pdf} \end{verbatim} for .pdf graphics. See section~4.4 in the graphics bundle documentation (\url{http://www.ctan.org/tex-archive/macros/latex/required/graphics/grfguide.ps}) A number of width problems arise when LaTeX cannot properly hyphenate a line. Please give LaTeX hyphenation hints using the \verb+\-+ command. \subsubsection*{Author Contributions} If you'd like to, you may include a section for author contributions as is done in many journals. This is optional and at the discretion of the authors. \subsubsection*{Acknowledgments} Use unnumbered third level headings for the acknowledgments. All acknowledgments, including those to funding agencies, go at the end of the paper. \subsubsection*{References}} \usepackage{mathtools} \usepackage{booktabs} \usepackage{tikz} \usepackage{nicefrac} \usepackage{amsfonts, amssymb} \usepackage{graphicx} \usepackage{subcaption} \usepackage{wrapfig} \usepackage{adjustbox} \usepackage{enumitem} \usepackage{microtype} \usepackage{booktabs} \usepackage{adjustbox} \usepackage{wrapfig} \newcommand{\Enc}[2]{{q_{\phi}(#1|#2)}} \newcommand{\HEnc}[2]{{q_{\theta, \phi}(#1|#2)}} \newcommand{\Dec}[2]{{p_{\theta}(#1|#2)}} \newcommand{D_{\mathrm{KL}}}[2]{{\mathrm{KL}\left[#1 \|#2 \right]}} \newcommand{\mathcal{N}}{\mathcal{N}} \newcommand{\mathrm{diag}}{\mathrm{diag}} \newcommand{\jt}[1]{{\color{blue}#1}} \newcommand{\ak}[1]{{\color{cyan}#1}} \newcommand{\Max}[1]{{\color{red}#1}} \title{Diagnosing Vulnerability of Variational Auto-Encoders to Adversarial Attacks} \author{Anna Kuzina \\ Vrije Universiteit Amsterdam\\ \texttt{[email protected]} \And Max Welling \\ Universiteit van Amsterdam \\ \texttt{[email protected]} \\ \And Jakub M. Tomczak \\ Vrije Universiteit Amsterdam\\ \texttt{[email protected]} } \iclrfinalcopy \begin{document} \maketitle \begin{abstract} In this work, we explore adversarial attacks on the Variational Autoencoders (VAE). We show how to modify data point to obtain a prescribed latent code (supervised attack) or just get a drastically different code (unsupervised attack). We examine the influence of model modifications ($\beta$-VAE, NVAE) on the robustness of VAEs and suggest metrics to quantify it. \footnote{The code is published at \texttt{https://github.com/AKuzina/attack\_vae}} \end{abstract} \section{Introduction}\label{sec:intro} \begin{wrapfigure}{r}{0.53\textwidth} \vskip -20pt \centering \includegraphics[width=0.975\linewidth]{img/intro_im.pdf} \caption{Example of a supervised attack on VAE with 2D latent space. Given a single reference point we learn additive perturbation $\epsilon$, s.t. perturbed input has the same latent representation as a target image. We observe that a single reference point can be mapped to extremely different regions of the latent space.} \label{fig:toy_exaple} \vskip -15pt \end{wrapfigure} Variational Autoencoders (VAEs) \citep{kingma2013auto, rezende2014stochastic} are deep generative models used in various domains. Recent works show that deep Variational Autoencoders models can generate high-quality images \citep{Vahdat2020-xe, Child2020-ze}. These works employ hierarchical structure \citep{Ranganath2016-yg}, coupled with skip-connections \citep{Maaloe2019-bp, So_nderby2016-en}. An additional advantage of VAE is that it has a meaningful latent space induced by the Encoder. This motivates us to explore the \textit{robustness} of the resulting latent representations. \textit{Adversarial attack} is one way to assess the robustness of a deep neural network. Robustness to the attacks is a crucial property for VAEs, especially in such applications as anomaly detection \citep{an2015variational, Maaloe2019-bp} or compression \citep{balle2018variational}. \cite{Gondim-Ribeiro2018-cu} propose to minimize the KL-divergence between an adversarial and a target input to learn an adversarial attack on the standard VAE model. We show that we can use a similar strategy to attack hierarchical VAEs. \cite{Willetts2019-mu} suggest a modified VAE objective coupled with hierarchical structure as a way to increase VAE robustness to adversarial attacks. \cite{camuto2020towards} show that $\beta$-VAE tend to be more robust to adversarial attacks in terms of proposed $r$-metric. In our work, we test both $\beta$-VAE and hierarchical NVAE and show that we can attack them successfully. In Figure \ref{fig:toy_exaple} we show an example of the \textit{supervised} attack on VAE with the 2D latent space. We show that we can add noise $\epsilon$ to a reference image so that the resulting adversarial input (second column) is encoded to a new point in the latent space. This new point is defined by the target image (first column). In \textit{unsupervised} attacks, on the other hand, we assume that the target image is not given. We show that it is still possible to construct an effective attack in this setting. The research goals of this work are the following: \begin{itemize}[leftmargin=*] \item Defining robustness measures to understand how VAEs behave for adversarial attacks both in the latent space and the pixel space. \item Assessing robustness of hierarchical and $\beta$-VAEs to adversarial attacks. \end{itemize} \section{Methodology} \subsection{Variational Autoencoders} Let us consider a vector of observable random variables, ${\mathbf{x}} \in \mathcal{X}^{D}$ (e.g., $\mathcal{X} = \mathbb{R}$) sampled from the empirical distribution $p_{e}(\mathbf{{\mathbf{x}}})$, and vectors of latent variables ${\mathbf{z}}_{l} \in \mathbb{R}^{M_{l}}$, $l=1, 2, \ldots, L$. First, we focus on a model with $L=1$ and the joint distribution $p_{\theta}({\mathbf{x}}, {\mathbf{z}}) = \Dec{{\mathbf{x}}}{{\mathbf{z}}} p({\mathbf{z}})$. The marginal likelihood is then equal to $p({\mathbf{x}}) = \int p({\mathbf{x}}, {\mathbf{z}}) \mathrm{d} {\mathbf{z}}$. VAEs exploit variational inference \citep{jordan1999introduction} with a family of variational posteriors $\{\Enc{{\mathbf{z}}}{{\mathbf{x}}}\}$, also referred to as encoders, that results in a tractable objective function, i.e., Evidence Lower BOund (ELBO): \begin{align}\label{eq:elbo} \mathcal{L}(\phi, \theta) = \mathbb{E}_{p_{e}(\mathbf{{\mathbf{x}}})}\left( \mathbb{E}_{\Enc{{\mathbf{z}}}{{\mathbf{x}}}}\ln \Dec{{\mathbf{x}}}{{\mathbf{z}}} - D_{\mathrm{KL}}{\Enc{{\mathbf{z}}}{{\mathbf{x}}}}{p({\mathbf{z}})} \right). \end{align} $\beta$-VAE \citep{higgins2016beta} uses a slightly modifier objective, weighting the second term by $\beta > 0$. In case of $L>1$, we consider a hierarchical latent structure with the generative model of the following form: $p_{\theta}({\mathbf{x}}, {\mathbf{z}}_1, \ldots, {\mathbf{z}}_L) = \Dec{{\mathbf{x}}}{{\mathbf{z}}_{1}} \prod_{l=1}^{L}p({\mathbf{z}}_{l}|{\mathbf{z}}_{l+1})$, where ${\mathbf{z}}_{L+1} \equiv \emptyset$. There are various possible formulations of the family of variational posteriors, however, here we follow the proposition of \cite{So_nderby2016-en} where the inference model with skip-connections was proposed, namely: \begin{equation} \Enc{{\mathbf{z}}_1, \ldots, {\mathbf{z}}_L}{{\mathbf{x}}} = \Enc{{\mathbf{z}}_L}{{\mathbf{x}}}\prod_{i=1}^{L-1}\HEnc{{\mathbf{z}}_i}{{\mathbf{z}}_{>i}, {\mathbf{x}}}. \end{equation} This formulation was used in NVAE \citep{Vahdat2020-xe}. It allows to share data-dependent information between the inference model and the generative model, because of the top-down structure. \subsection{Adversarial attacks} \label{sect:adversarial_attacks} An \textit{adversarial attack} is a slightly deformed data point ${\mathbf{x}}$ that results in an undesired or unpredictable performance of a model. In the case of a VAE, we construct an adversarial input ${\mathbf{x}}^a$ as a deformation of a reference point ${\mathbf{x}}^r$ to satisfy the following conditions: (\textit{i}) ${\mathbf{x}}^a$ should be close\footnote{Either visually or in terms of the pixel values.} to ${\mathbf{x}}^r$; (\textit{ii}) the variational distribution $\Enc{{\mathbf{z}}}{{\mathbf{x}}}$ for the ${\mathbf{x}}^r$ and the ${\mathbf{x}}^a$ should be different, and the same should hold for the conditional likelihood $\Dec{{\mathbf{x}}}{{\mathbf{z}}}$. Next, we define a framework that can be used to define and compare adversarial attacks and, most importantly, evaluate the VAE robustness to them. \paragraph{Attacks construction} We define an adversarial point as a result of the additive perturbation of the reference point, ${\mathbf{x}}^{a} = {\mathbf{x}}^{r} + \epsilon^{*}$, where the perturbation $\epsilon^{*}$ is a solution of an optimization problem. We distinguish between the \textit{supervised attack}, when we have access to a target point, ${\mathbf{x}}^{t}$ and the \textit{unsupervised attack}, when ${\mathbf{x}}^{t}$ is not available. In the former case, we propose to solve the following optimization problem:\footnote{$ \mathrm{SKL}[p_1 , p_2] = \frac{1}{2}\mathrm{KL}[p_1 || p_2] + \frac{1}{2}\mathrm{KL}[p_2 || p_1]$ is the symmetric version of the Kullback-Leibler divergence} \begin{equation}\label{eq:supervised_attack} {\mathbf{\epsilon}}^* = \argmin_{\|{\mathbf{\epsilon}}\|\leq 1} \mathrm{SKL}[\Enc{{\mathbf{z}}}{{\mathbf{x}}^{r}+{\mathbf{\epsilon}}} , \Enc{{\mathbf{z}}}{{\mathbf{x}}^{t}}] \end{equation} In the unsupervised case, we formulate the following optimization problem: \begin{align}\label{eq:unsupervised_attack} &{\mathbf{\epsilon}}^* = \argmax_{\|{\mathbf{\epsilon}}\|\leq 1} \Delta[\Enc{{\mathbf{z}}}{{\mathbf{x}}^{r}+\epsilon} , \Enc{{\mathbf{z}}}{{\mathbf{x}}^{r}}] = \argmax_{\|{\mathbf{\epsilon}}\|\leq 1} \| \mathbf{J}_{{\mathbf{x}}^{r}}^{q} \epsilon\|_{2}^{2} \end{align} where $\mathbf{J}_{{\mathbf{x}}^{r}}^{q}$ is the Jacobian of $\Enc{{\mathbf{z}}}{{\mathbf{x}}^{r}}$ at point ${\mathbf{x}}^{r}$. See Appx. \ref{appendix:delta} for the details for this objective. \paragraph{Robustness measures} It is important to define proper quantitative measures that will reflect our expectations from adversarial attacks discussed in Section \ref{sect:adversarial_attacks}. First, we focus on measuring differences in the latent spaces. For this purpose, we propose to use the following measure: \begin{equation} \Omega = \sum_{{\mathbf{x}}^{r}} \sum_{{\mathbf{x}}^{a}|{\mathbf{x}}^{r}} \mathrm{SKL}[\Enc{{\mathbf{z}}}{{\mathbf{x}}^{a}} , \Enc{{\mathbf{z}}}{{\mathbf{x}}^{r}}] , \end{equation} where the value of $\epsilon$ is a solution from either (\ref{eq:supervised_attack}) or (\ref{eq:unsupervised_attack}). Further, we would like to measure similarities between ${\mathbf{x}}^{r}$ and ${\mathbf{x}}^{a}$, and their reconstructions. Here, we propose to use the Multi-Scale Structural Similarity Index Measure ($\mathrm{MSSSIM}$) \citep{wang2003multiscale} which is a perception-based measure calculated at different scales, $\mathrm{MSSSIM} \in [0, 1]$: \begin{itemize}[leftmargin=*] \item $\mathrm{MSSSIM}[{\mathbf{x}}^{r}, {\mathbf{x}}^{a}]$: the similarity between a reference and the corresponding adversarial input; \item $\mathrm{MSSSIM}[\widetilde{{\mathbf{x}}}^{r}, \widetilde{{\mathbf{x}}}^{a}]$: the similarity between reconstructions of ${\mathbf{x}}^{r}$ and the corresponding ${\mathbf{x}}^{a}$; \end{itemize} A successful adversarial attack would have large $\mathrm{MSSSIM}[{\mathbf{x}}^{r}, {\mathbf{x}}^{a}]$ (close to 1) and small $\mathrm{MSSSIM}[\widetilde{{\mathbf{x}}}^{r}, \widetilde{{\mathbf{x}}}^{a}]$. Moreover, for \textit{supervised attacks} we will measure similarity between reconstructions of the target and the adversarial image, $\mathrm{MSSSIM}[\widetilde{{\mathbf{x}}}^{t}, \widetilde{{\mathbf{x}}}^{a}]$. Large value of the latter would indicate a successful supervised attack. \section{Experiments} \label{sec:experiments} In this section we consider attacking a 1-level VAE trained on the Fashion MNIST dataset \citep{xiao2017fashion} and NVAE trained on the CelebA dataset \citep{liu2015faceattributes}. All the metrics are averaged over the reference, target, and adversarial inputs. In Appx. \ref{appendix:experiments} we provide details on the selection of the reference and target points for both datasets. \subsection{VAE and \texorpdfstring{$\beta$-VAE}.} \begin{figure}[t] \begin{center} \vskip -10pt \centering \includegraphics[width=0.95\linewidth]{img/fashion_mnist_res} \end{center} \vskip -5pt \caption{Robustness results for $\beta$-VAEs trained on Fashion MNIST dataset.} \vskip -10pt \label{fig:fmnist_res} \end{figure} We start with the experiments on the VAE with one level of latent variables. We train both VAE and $\beta$-VAE \citep{higgins2016beta}. The latter weights the KL-term in eq. (\ref{eq:elbo}) with $\beta > 0$. It is said that the larger values of $\beta$ encourage disentangling of latent representations \citep{chen2018isolating} and improve the model robustness as observed by \cite{camuto2020towards}. In Appx. \ref{appendix:beta_vae} we provide details on the architecture, optimization, and results on the test dataset for VAE trained with different values of $\beta$. We observe that optimal value in terms of NLL is $\beta=1$. Larger values of $\beta$ are supposed to improve robustness in exchange for the reconstruction quality. \begin{wrapfigure}{l}{0.46\textwidth} \vskip 5pt \begin{subfigure}{0.49\linewidth} \centering \includegraphics[width=\textwidth]{img/supervised_sample_beta1} \caption{$\beta$ = 1} \label{fig:supervised_1} \end{subfigure} \begin{subfigure}{0.49\linewidth} \centering \includegraphics[width=\textwidth]{img/supervised_sample_beta10} \caption{$\beta$ = 10} \label{fig:supervised_10} \end{subfigure} \caption{Supervised attack: adversarial inputs (\textit{row 1}), their reconstructions (\textit{row 2}) and reconstructions of the corresponding target points (\textit{row 3}).} \label{fig:sup_samples} \vskip -10pt \begin{center} \begin{subfigure}{0.38\linewidth} \centering \includegraphics[width=\textwidth]{img/unsupervised_sample_beta1} \caption{$\beta$ = 1} \label{fig:unsupervised_1} \end{subfigure} \begin{subfigure}{0.38\linewidth} \centering \includegraphics[width=\textwidth]{img/unsupervised_sample_beta10} \caption{$\beta$ = 10} \label{fig:unsupervised_10} \end{subfigure} \caption{Unsupervised attack: adversarial inputs (\textit{row 1}) and their reconstructions (\textit{row 2}).} \label{fig:unsup_samples} \end{center} \vskip -35pt \end{wrapfigure} \paragraph{Supervised attack} We train supervised attacks using eq. (\ref{eq:supervised_attack}). Figure \ref{fig:fmnist_res} depicts result for different values of $\beta$. We observe that robustness of the encoder increases if measured by distance between adversarial and reference point in the latent space ($\Omega$). On the other hand, we still observe that in terms of reconstructions the adversarial inputs are closer to the target points than to the reference (plot (b) ad (c)). Moreover, we do not observe higher distortion levels, that is, adversarial inputs itself are still close to the reference (plot (a)). In Figure \ref{fig:sup_samples} we provide examples of adversarial inputs for a single reference point and 5 different targets. \paragraph{Unsupervised attack} We present results for the unsupervised attacks trained with eq. (\ref{eq:unsupervised_attack}) in Figure \ref{fig:fmnist_res} and examples of learned adversarial inputs for a single reference point in Figure \ref{fig:unsup_samples}. We observe behavior similar to supervised tasks, where even for large values of $\beta$ we can construct a successful adversarial attack. \subsection{Hierarchical VAE: NVAE} In this section, we explore the robustness of deep hierarchical VAE. It was also studied in \cite{Willetts2019-mu}, where authors notice that pure hierarchical VAE with up to 5 levels of latent variables are not gaining any robustness. We construct a supervised adversarial attack for NVAE \citep{Vahdat2020-xe}, a recently proposed VAE with state-of-the-art performance in terms of image generation. We use a model trained on CelebA dataset using the official NVAE implementation\footnote{The code and model weight were taken from \texttt{https://github.com/NVlabs/NVAE}}. We notice that to effectively attack a hierarchical VAE model, one has to consider only higher-order levels of latent variables, e.g. $\{z_{L-k_A}, z_{L-k_A+1}, \dots, z_L\}$. That being said, we formulate adversarial attacks using eq. (\ref{eq:supervised_attack}), with $\Enc{{\mathbf{z}}}{{\mathbf{x}}} = \prod_{i = L-k_A}^{L} \Enc{{\mathbf{z}}_i}{{\mathbf{x}}, {\mathbf{z}}_{>i}}$, where $k_A$ is number of latent variables considered during attack construction. We assume that lower-order latent variables are responsible for the specific details of an image and are less useful to learn an adversarial input. A similar approach was suggested in \cite{Maaloe2019-bp} for anomaly detection. They use modified ELBO $\mathcal{L}^{>k}$, where they use prior instead of variational approximation for the first $k$ latent variables. In Table \ref{tab:nvae_res} we present numerical results for attacks with $k_A = \{1, 2, 4, 8\}$. We also plot examples of the learned adversarial inputs with their reconstructions and corresponding target images in Figure \ref{fig:sup_samples_nvae}. In Figure \ref{fig:nvae_elbo} we plot $- \mathcal{L}^{>k}$ from \cite{Maaloe2019-bp} for all possible values of $k$. We see that curves for adversarial inputs are always above those for the real images from the dataset (either target or reference ones). Moreover, according to our metrics, we are able to obtain an adversarial input that has reconstructions close to the target images rather than to the reference ones. This makes us question the robustness of the hierarchical models to adversarial attacks. \begin{figure} \centering \begin{minipage}{.57\textwidth} \begin{center} \begin{subfigure}{0.1\linewidth} \centering \includegraphics[width=\textwidth]{img/nvae_Target.pdf} \caption{${\mathbf{x}}^t$} \label{fig:nvae_trg} \end{subfigure} \begin{subfigure}{0.2\linewidth} \centering \includegraphics[width=\textwidth]{img/Sup_sample_c1.pdf} \caption{$k_A = 1$} \label{fig:nvae_1} \end{subfigure} \begin{subfigure}{0.2\linewidth} \centering \includegraphics[width=\textwidth]{img/Sup_sample_c2.pdf} \caption{$k_A = 2$} \label{fig:nvae_2} \end{subfigure} \begin{subfigure}{0.2\linewidth} \centering \includegraphics[width=\textwidth]{img/Sup_sample_c4.pdf} \caption{$k_A = 4$} \label{fig:nvae_4} \end{subfigure} \begin{subfigure}{0.2\linewidth} \centering \includegraphics[width=\textwidth]{img/Sup_sample_c8.pdf} \caption{$k_A = 8$} \label{fig:nvae_8} \end{subfigure} \caption{Supervised attacks on NVAE. We plot target images in (a). In (b) - (e) we plot adversarial inputs (\textit{column 1}) and their reconstructions (\textit{column 2}). $k_A$ stands for number of top level latent variables considered while learning ${\mathbf{x}}^a$. We observe that adversarial reconstructions are able to mimic such high level features of the target as face orientation, hairstyle and smile.} \label{fig:sup_samples_nvae} \end{center} \end{minipage}% \begin{minipage}{.03\textwidth} \hskip 2pt \end{minipage}% \begin{minipage}{.39\textwidth} \vskip -10pt \begin{center} \includegraphics[width=1.05\linewidth]{img/elbo_k.pdf} \end{center} \vskip -10pt \caption{Negative ELBO $\mathcal{L}_k$ from \cite{Maaloe2019-bp}. Higher values indicate anomaly.} \label{fig:nvae_elbo} \end{minipage} \end{figure} \begin{table}[t] \vskip -0pt \caption{Supervised adversarial attacks on NVAE in terms of proposed metrics.} \vskip -9pt \label{tab:nvae_res} \begin{center} \begin{adjustbox}{max width=.9\linewidth}{} \begin{tabular}{l|cccc} \toprule \small $k_A$ & \small $\mathrm{MSSSIM}[{\mathbf{x}}^{r}, {\mathbf{x}}^{a}]$ & \small $\mathrm{MSSSIM}[\widetilde{{\mathbf{x}}}^{r}, \widetilde{{\mathbf{x}}}^{a}]$ & \small $\mathrm{MSSSIM}[\widetilde{{\mathbf{x}}}^{t}, \widetilde{{\mathbf{x}}}^{a}]$ & \small $\Omega$ \\\midrule 1 & 0.99& 0.25& 0.51 & 270\\ 2 & 0.97& 0.25& 0.65 & 281 \\ 4 & 0.98& 0.30& 0.55 & 328\\ 8 & 0.99& 0.46& 0.42 & 803\\ \bottomrule \end{tabular} \end{adjustbox} \end{center} \end{table} \section{Conclusion} In this work, we have explored the robustness of VAEs to adversarial attacks. We have suggested metrics that are easily interpretable. We have used these metrics as well as the proposed definition of supervised and unsupervised attacks to show that VAE and $\beta$-VAE are prone to adversarial attacks. Moreover, we were able to attack deep hierarchical VAE to produce high quality adversarial inputs and reconstructions. \section*{Acknowledgements} This research was (partially) funded by the Hybrid Intelligence Center, a 10-year programme funded by the Dutch Ministry of Education, Culture and Science through the Netherlands Organisation for Scientific Research, https://hybrid-intelligence-centre.nl. \bibliographystyle{iclr2021_conference} \subsubsection*{References}} \usepackage{mathtools} \usepackage{booktabs} \usepackage{tikz} \newcommand{\swap}[3][-]{#3#1#2} \title{Instructions for Authors: Title in Title Case} \author[1]{\href{mailto:Harry Q. Bovik <[email protected]>?Subject=Your UAI 2021 paper}{Harry~Q.~Bovik}{}} \author[2]{Coauthor~One} \author[1,2]{Coauthor~Two} \author[3]{Further~Coauthor} \author[1]{Further~Coauthor} \author[3]{Further~Coauthor} \author[3,1]{Further~Coauthor} \affil[1]{% Computer Science Dept.\\ Cranberry University\\ Pittsburgh, Pennsylvania, USA } \affil[2]{% Affiliation\\ Address\\ … } \affil[3]{…} \begin{document} \maketitle \begin{abstract} This is the abstract for this article. It should give a self-contained single-paragraph summary of the article's contents, including context, results, and conclusions. Avoid citations; but if you do, you must give essentially the whole reference. For example: This whole paper is devoted to praising É. Š. Åland von Vèreweg's most recent book (“Utopia's government formation problems during the last millenium”, Springevier Publishers, 2016). Also, do not put mathematical notation and abbreviations in your abstract; be descriptive. So not “we solve \(x^2+A xy+y^2\), where \(A\) is an RV”, but “we solve quadratic equations in two unknowns in which a single coefficient is a random variable”. The reason is that mathematical notation will not display correctly when the abstract is reused on the proceedings website, for example, and that one should not assume the abstract's reader knows the abbreviation. Of course the same remarks hold for your paper's title. \end{abstract} \section{Introduction}\label{sec:intro} UAI 2021 papers have to be prepared using \LaTeX. To start writing your paper, copy \texttt{uai2021-template.tex} and replace title, authorship, and content with your own. The UAI 2021 paper style is based on a custom \textsf{uai2021} class. The class file sets the page geometry and visual style.\footnote{% The class uses the packages \textsf{adjustbox}, \textsf{environ}, \textsf{letltxmacro}, \textsf{geometry}, \textsf{footmisc}, \textsf{caption}, \textsf{titlesec}, \textsf{titling}, \textsf{authblk}, \textsf{enumitem}, \textsf{microtype}, \textsf{lastpage}, and \textsf{kvoptions}. } The class file also loads basic text and math fonts.\footnote{% Fonts loaded are \textsf{mathptmx} (roman, including math), \textsf{helvet} (sanserif), \textsf{courier} (fixed-width), and \textsf{textcomp} (common symbols). } \emph{You may not modify the geometry or style in any way, for example, to squeeze out a little bit of extra space.} (Also do not use \verb|\vspace| for this.) Feel free to use convenience functionality of loaded packages such as \textsf{enumitem}. The class enables hyperlinking by loading the \textsf{hyperref} package. You are free to load any packages available in \TeX{Live}~2020 that are compatible with the UAI class.\footnote{In case this template or your submission does not compile, always first make sure your \TeX\ installation is up-to-date.} (Mik\TeX{} and Mac\TeX{} generally contain the same packages.) Do not load conflicting packages—you will get an error message—, as this complicates creating the proceedings. Please avoid using obsolete commands, such as \verb|\rm|, and obsolete packages, such as \textsf{epsfig}.\footnote{% See \url{https://ctan.org/pkg/l2tabu}. } \swap[ ]{in the header of your source file.}{Feel free to include your own macros} \section{General Formatting Instructions} As a general rule: \emph{follow the template}. \subsection{Authorship} Reviewing is double-blind. However, you can already fill in your author names and affiliations in the \verb|\author| block in the preamble following the example of the template because the class will remove it as long as the option \textsf{accepted} is not passed to the class. Nevertheless, make sure any other information in the paper does not disclose your identity, for example URLs to supplementary material. \subsection{Sectioning} Three numbered sectioning commands are provided: \verb|\section|, \verb|\subsection|, and \verb|\subsubsection|. Please respect their order, so do not put a \verb|\subsubsection| directly beneath a \verb|\section|. One unnumbered sectioning command is provided, \verb|\paragraph|. It can be used directly below any numbered section level. Do not use any other sectioning commands. \subsubsection{Typing the Section Titles} The \verb|\section| and \verb|\subsection| titles are uppercased by the class. Please type them in title case. (This is used in the PDF bookmarks.) Please also write the \verb|\subsubsection| titles in title case. \paragraph{What is title case?} \href{https://en.wikipedia.org/wiki/Title_case}{Wikipedia} explains: \begin{quote} Title case or headline case is a style of capitalization used for rendering the titles of published works or works of art in English. When using title case, all words are capitalized except for ‘minor’ words (typically articles, short prepositions, and some conjunctions) unless they are the first or last word of the title. \end{quote} \subsection{References, Citations, Footnotes}\label{sec:etc} \subsubsection{Cross-Referencing} Always use \verb|\label| and \verb|\ref|—or a command with a similar effect—when cross-referencing. For example, this subsection is Section~\ref{sec:etc}. \subsubsection{Citations} Citations should include the author's last name and year. They should be part of the sentence. An example parenthetical citation: “Good introductions to the topic are available \citep{latexcompanion}.” An example textual citation: “\citet{einstein} discusses electrodynamics of moving bodies.” Do not use a parenthetical citation where a textual one is appropriate. An example of what \emph{not} to do: “\citep{einstein} discusses electrodynamics of moving bodies.” We strongly advise to use reference list software such as Bib\TeX{} and a citation package such as \textsf{natbib}. The reference style you use should be compatible with the author-year citations. Both the citation style and reference style used should be consistent. For the original submission, take care not to reveal the authors' identity through the manner in which one's own previous work is cited. For example, writing “I discussed electrodynamics of moving bodies before \citep{einstein}.” would be inappropriate, as it reveals the author's identity. Instead, write “\citet{einstein} discussed electrodynamics of moving bodies.” \subsubsection{Footnotes} You can include footnotes in your text.\footnote{ Use footnotes sparingly, as they can be distracting, having readers skip back and forth between the main text and the foot of the page. } The footnote mark should follow the fragment to which it refers, so a footnote\footnote{ A footnote is material put at the foot of a page. } for a word has a footnote mark attached to that word and a footnote for a phrase or sentence has a footnote mark attached to the closing punctuation. \section{Math}\label{sec:math} The class file does not load any math support package like \textsf{amsmath}\footnote{% See the \textsf{amsmath} documentation at \url{https://ctan.org/pkg/amsmath} for further details. }. We advise using the \textsf{mathtools}\footnote{% See the \textsf{mathtools} documentation at \url{https://ctan.org/pkg/mathtools} for further details. } package, which extends \textsf{amsmath} with fixes and even more useful commands. Feel free to load other support packages for symbols, theorems, etc. Use the \textsf{amsmath} environments for displayed equations. So, specifically, use the \texttt{equation} environment instead of \verb|$$...$$| and the \texttt{align} environment instead of \texttt{eqnarray}.\footnote{For reasons why you should not use the obsolete \texttt{eqnarray} environment, see Lars Madsen, \textit{Avoid eqnarray!} TUGboat 33(1):21--25, 2012.} An \texttt{equation}: \begin{equation}\label{eq:example} 0 = 1 - 1. \end{equation} Two \texttt{align}'ed equations: \begin{align*} 1 + 2 &= 3,\\ 1 - 2 &= -1. \end{align*} Equations can also be put inline, of course. For example, Equation~\eqref{eq:example}: \(0=1+1\). (Notice that both inline and displayed math are part of the sentence, so punctuation should be added to displayed math.) The \textsf{amsmath} and \textsf{mathtools} packages provide a lot of nice functionality, such as many common math operators, e.g., \(\sin\) and \(\max\), and also commands for defining new ones. \section{Floats}\label{sec:floats} Floats, such as figures, tables and algorithms, are moving objects and are supposed to float to the nearest convenient location. Please do not force them to go in the middle of a paragraph. They must respect the column width. Two-column floats are possible. They appear at the top of the next page, so strategic placement may be necessary. For an example, see Figure~\ref{fig:tikz}. They may not enter the margins. \begin{figure*} \centering \begin{tikzpicture}[xscale=1.5] \coordinate (origin); \draw[->] (origin) -- +(1cm,0) node[below] {$x$}; \draw[->] (origin) -- +(0,1cm) node[left] {$y$}; \fill[gray] (45:1cm) circle[radius=.2cm]; \end{tikzpicture} \caption{A Nice Filled Ellipse with a Pair of Coordinate Axes.}\label{fig:tikz} \end{figure*} All material in floats should be legible and of good quality. So avoid very small or large text and pixelated or fuzzy lines. \subsection{Figures}\label{sec:figures} Figures should go in the \texttt{figure} environment and be centered therein. The caption should go below the figure. Use \verb|\includegraphics| for external graphics files but omit the file extension. Supported formats are \textsf{pdf} (preferred for vector drawings and diagrams), \textsf{png} (preferred for screenshots), and \textsf{jpeg} (preferred for photographs). Do not use \verb|\epsfig| or \verb|\psfig|. If you want to scale the image, it is better to use a fraction of the line width rather than an explicit length. For example, see Figure~\ref{fig:toronto}. \begin{figure} \centering \includegraphics[width=0.7\linewidth,page=3]{toronto} \caption{A View of a Nice City.}\label{fig:toronto} \end{figure} Do not use \verb|\graphicspath|. If the images are contained in a subdirectory, specify this when you include the image, for example \verb|\includegraphics{figures/mypic}|. \subsection{Tables}\label{sec:tables} Tables should go in the \texttt{table} environment and be centered therein. The caption should go above the table and be in title caps. For an example, see Table~\ref{tab:data}. \begin{table} \centering \caption{An Interesting Table.}\label{tab:data} \begin{tabular}{rl} \toprule \bfseries Dataset & \bfseries Result\\ \midrule Data1 & 0.12345\\ Data2 & 0.67890\\ Data3 & 0.54321\\ Data4 & 0.09876\\ \bottomrule \end{tabular} \end{table} \subsection{Algorithms}\label{sec:algorithms} You can load your favorite algorithm package, such as \textsf{algorithm2e}\footnote{See the \textsf{algorithm2e} documentation at \url{https://ctan.org/pkg/algorithm2e}.}. Use the environment defined in the package to create a centered float with an algorithm inside. \section{Back Matter} There are a some final, special sections that come at the back of the paper, in the following order: \begin{itemize} \item Author Contributions \item Acknowledgements \item References \end{itemize} They all use an unnumbered \verb|\subsubsection|. For the first two special environments are provided. (These sections are automatically removed for the anonymous submission version of your paper.) The third is the ‘References’ section. (See below.) (This ‘Back Matter’ section itself should not be included in your paper.) \begin{contributions} Briefly list author contributions. This is a nice way of making clear who did what and to give proper credit. H.~Q.~Bovik conceived the idea and wrote the paper. Coauthor One created the code. Coauthor Two created the figures. \end{contributions} \begin{acknowledgements} Briefly acknowledge people and organizations here. \emph{All} acknowledgements go in this section. \end{acknowledgements}
{'timestamp': '2021-05-07T02:13:12', 'yymm': '2103', 'arxiv_id': '2103.06701', 'language': 'en', 'url': 'https://arxiv.org/abs/2103.06701'}
arxiv
\section{Introduction} Public opinion has been shown to be significantly influenced by \textit{framing effects.} Framing refers to the presentation of an issue, where even small changes may have outsized effects on beliefs \cite{Chong2007FramingT}. For example, when asked about ``welfare,'' the American public is largely against increasing spending (with only 20\% in favor), but when asked about ``assistance to the poor,'' 65\% believe that the government is not spending enough \cite{Rasinski1989THEEO}. While other research has focused on \textit{syntactic} framing \cite{greene-resnik-2009-words} or \textit{issue} framing \cite{hartmann-2019-predicting}, we focus specifically on \textit{lexical} framing, distinguishing sentences by their \textit{connotative} meaning even where they have the same \textit{denotative} meaning. According to \newcite{FregeberSU}, two sentences with the same truth conditions may refer to the same entities or state of affairs (\textit{``reference,''} also known as denotation) but be presented differently (\textit{``sense''} or connotation). For example, ``undocumented workers'' and ``illegal aliens'' have the same denotation but different connotations \cite{webson-etal-2020-undocumented}. \begin{table}[t] \small \centering \begin{tabular}{|l|l|} \hline Arg1 & \begin{tabular}[c]{@{}l@{}}Alabama's Supreme Court Chief Justice was \\suspended... for ordering state probate\\ judges not to grant \textit{\color{red}marriage licenses} to gay \\couples...\end{tabular} \\ \hline \begin{tabular}[c]{@{}l@{}}Rf\\ Arg1\end{tabular} & \begin{tabular}[c]{@{}l@{}}Alabama's Supreme Court Chief Justice was \\suspended... for ordering state probate\\ judges not to grant \textit{\color{blue}legal marriage equality} \\to gay couples... \end{tabular} \\ \hline\hline Arg2 & \begin{tabular}[c]{@{}l@{}}Every nation with \textit{\color{red}territorial claims} in the\\ arctic is a member of NATO, except Russia.\end{tabular} \\ \hline \begin{tabular}[c]{@{}l@{}}Rf\\ Arg2\end{tabular} & \begin{tabular}[c]{@{}l@{}}Every nation with \textit{\color{blue}sovereign competence} in the\\ arctic is a member of NATO, except Russia.\end{tabular} \\ \hline\hline Arg3 & \begin{tabular}[c]{@{}l@{}}At this \textit{\color{red}dire} moment , we all need to amplify our \\voices in \textit{\color{red}defense} of free speech . \end{tabular} \\ \hline \begin{tabular}[c]{@{}l@{}}Rf\\ Arg3\end{tabular} & \begin{tabular}[c]{@{}l@{}}At this \textit{\color{blue}crucial} moment , we all need to amplify\\ our voices in \textit{\color{blue}support} of free speech. \end{tabular} \\ \hline\hline Arg4 & \begin{tabular}[c]{@{}l@{}}It is difficult to think of any single act that\\ would do more to restore America's \textit{\color{red}soft power}\\ than the election of Obama to the presidency\end{tabular} \\ \hline \begin{tabular}[c]{@{}l@{}}Rf\\ Arg4\end{tabular} & \begin{tabular}[c]{@{}l@{}}It is difficult to think of any single act that\\ would do more to restore America's \textit{\color{blue}diplomatic}\\ \textit{\color{blue}credibility} than the election of Obama to the \\presidency\end{tabular} \\ \hline \end{tabular} \caption{Examples of arguments (Arg1, Arg2) with high partisan skew collocations (in red) \cite{webson-etal-2020-undocumented} as well as appeal to fear or prejudice argument fallacies (Arg3, Arg4) \cite{da2019fine}, along with reframed arguments as an attempt by our model \textbf{ENTRUST} to improve trustworthiness.} \label{table:example1} \end{table} The examples in Table \ref{table:example1} are instances of \textit{lexical} framing, where word choice determines the difference in presentation \cite{Mccombs2001TheCO}. For example, Arg1 and Arg2 contain collocations (in red) that have a high partisan skew \cite{webson-etal-2020-undocumented}, while Arg 3 and Arg 4 are examples of appeal to fear or prejudice argument fallacies from propagandist news articles \cite{da2019fine}. The goal is to reframe such arguments to be more trustworthy (e.g., less partisan, no appeal to fear fallacy). Connotations may be distinguished along the dimensions of politeness, sentiment, or tangibility, among others \cite{allaway2020unified}, but in our work we consider emotional association such as fear and trust. Appeal to \textit{fear} is considered an argumentative fallacy \cite{Walton2006FundamentalsOC, Thierer2012TechnopanicsTI} and appears prominently in manipulative text such as propaganda \cite{da2019fine}. On the other hand, arguments with \textit{trusted} language align with the Aristotelian modes of persuasion, specifically ethos \cite{Aristotle2019AristotlesO}. In our work, we leverage such a lexical resource for connotations \cite{allaway2020unified} to reframe arguments to be more trustworthy (e.g., less partisan, no appeal to fear fallacy), while maintaining the same denotative meaning. While retrieve-and-replace methods perform well on other attribute transfer tasks such as sentiment \cite{li2018delete,sudhakar2019transforming}, our task is more dependent on broader context within a sentence even though we are performing localized replacement. Thus, there are two main challenges we need to address: 1) the lack of a parallel dataset of negatively and positively framed arguments (naturally-occurring); and 2) a generation approach that can not only change the connotative meaning but also keep the same denotative meaning of the input argument. We introduce our approach called \textbf{ENTRUST }: Argum\textbf{ENT} \textbf{R}eframing with lang\textbf{U}age model\textbf{S} and en\textbf{T}ailment, with the following contributions: 1) A Connotation-guided Masked Language Model approach to generate a parallel dataset of naturally occuring arguments and their reframings (Section \ref{section:data1}); 2) A method for argument reframing that combines controllable text generation (connotative meaning associated with trust) and entailment (same denotative meaning) (Section \ref{sec:method}); 3) An evaluation on two different tasks --- reframing partisan arguments and appeal to fear/prejudice fallacies --- showing that our method is preferred over a strong retrieval-based baseline \cite{sudhakar2019transforming} and state-of-the-art pretrained language model \cite{lewis2019bart}, and it is close to human performance on several evaluation criteria such as fluency, meaning, trustworthiness/reduction in fear. Code, data, and models available at \url{https://github.com/tuhinjubcse/ArgReframingNAACL2021} \section{Automatic Parallel Data Creation} \label{section:data1} To facilitate the reframing of arguments, we require a large-scale parallel corpora of sentences with the same denotation but different connotative meaning. \paragraph{Selection of naturally-occurring arguments.} Since our goal is to re-write arguments, it is essential to identify an abundant source of naturally-occurring arguments. The \textit{Change My View} subreddit, an argumentative discussion forum intended for persuasion on diverse topics, has been used extensively in computational argumentation research \cite{tan2016winning,wei2016post,musi2018changemyview,chakrabarty2019imho, chakrabarty2019ampersand,hidey2017analyzing}. We collect sentences from the same source and classify them as \textit{claim}, \textit{premise}, or \textit{non-argument} using the fine-tuned BERT model released by \citet{chakrabarty2019ampersand}. This results in 301,166 arguments labeled as premises. We consider only premises to create our parallel data because argumentative appeals occur within justifications (premises) for or against the speaker's claim. \paragraph{Connotation-guided Masked Language Model.} \citet{allaway2020unified} provide a resource with words labeled for lexical connotations, using the aspects of \textit{Social Value, Politeness, Impact, Factuality, Sentiment, Emotional Association}. For our work we only consider \textit{Emotional Association}, although in future work our methods could be applied for other aspects. To create a parallel corpus, we use this lexical resource and the 301,166 automatically identified premises from \textit{Change My View} to obtain candidate words within those premises for replacement. We match words from the premises to those that have entries in the dictionary with \textit{emotional} connotations such as fear, trust, anticipation, and joy. To generate replacements for these words, we need to find substitutions that maintain denotative meaning while changing connotative meaning. We use the connotation dictionary to address the latter. However, to address the former, we need to provide only paraphrases that consider the context in which these words occur. We thus use a masked language model (MLM). \begin{figure*} \centering \includegraphics[scale=0.65]{sysdiagram1.pdf} \caption{\label{figure:sim} A schematic illustration of our system ENTRUST, where the top block shows our \textbf{training} process where we use MLM along with connotation resource to transform an original argument to an argument bearing different emotional connotation and use them to fine-tune BART. The block below shows the \textbf{inference} step (test time) where we use fine-tuned BART to reframe the argument containing \textit{partisan collocation} along with a NLI component to ensure the same denotation with the input argument.} \vspace{-.5em} \end{figure*} Masked language modeling approaches like BERT \cite{devlin2018bert} and RoBERTa \cite{liu2019roberta} can be considered \textit{cloze} or ``fill-in-the-blank'' tasks, where the model uses the context surrounding a masked-out token to try to predict what the masked word should be. We borrow this framework (RoBERTa-large, in particular) to mask the candidate words we identified via the connotation lexicon. However, the rank of a predicted token from an MLM is based on the language model probability -- it provides no information about lexical connotations. A premise re-written from MLM replacements may thus have the same connotative meaning. To avoid this scenario, we restrict the MLM replacements to be words with different connotations than the original masked word (i.e., different Emotional Association). Our data creation process is depicted in Figure \ref{figure:sim}. In example 2, the word \textit{``resources''} has the connotations \textit{joy;trust} in our dictionary. The MLM generates the replacement \textit{``tools,''} which we verify has a different connotation (\textit{emotionally neutral}). For example 1, the words \textit{"prepare,"} \textit{"real,"} and \textit{"defense"} have the emotional connotations \textit{anticipation}, \textit{trust}, and \textit{anticipation;anger;fear} respectively. These words are replaced with \textit{plan}, \textit{your}, and \textit{safety}, using our MLM. We treat the original premises as the ``target'' and the connotation-guided MLM generated premises as the ``source" for our method of argument reframing detailed in the next section (Figure \ref{figure:sim}). While this process provides us with a parallel dataset for reframing, we enhance the source-side of the data to provide additional control during generation. Motivated by the work of \citet{schiller2020aspect}, which used aspect as a ``control code'' \cite{keskar2019ctrl} for argument generation, we also prepend the emotional associations of the replaced words. Using the connotations from the lexical resource, we add all listed emotions as control codes by separating them with a special token (``[DELIM]'') (the top right block of Figure \ref{figure:sim}). During inference, we thus have more control over the emotion of the words we are generating (in our case we specifically use \text{trust} as the control code). For additional control, we also insert demarcator tokens (``[SEP]'') at the boundary of the words we aim to replace to provide our generative model with a better signal on what to replace or rewrite. While the downside is that we need to identify spans for replacement at test/inference time, our experiments will show that using collocations or fear words makes it unnecessary. By using the lexical connotation resource we do not have to rely on a separate module/tagger based approach like that of \citet{pryzant2020automatically} to find biased or problematic words that may introduce additional noise during training. Our parallel data has 271,022 pairs for training and 30,114 for validation on which perplexity is evaluated. \section{Method for Argument Reframing} \label{sec:method} As our goal is to change \textit{connotation} while maintaining \textit{denotation}, we divide our approach to re-writing arguments into two primary tasks: 1) generating the appropriate lexical substitutions while being pertinent to the context; 2) ensuring that re-written arguments reflect the desired emotional association while maintaining the same denotative meaning as the input. \subsection{Controllable Text Generation} BART \cite{lewis2019bart} is a pre-trained model combining bidirectional and auto-regressive transformers that achieves state-of-the-art results in several text generation tasks. It is implemented as a sequence-to-sequence model with a bidirectional encoder over corrupted text and a left-to-right auto-regressive decoder. In principle, the pre-training procedure has two stages: (1) text is corrupted with an arbitrary noising function, and (2) a transformer-to-transformer model is learned to reconstruct the original text. Because BART has an auto-regressive decoder, it can be directly fine-tuned for most sequence generation tasks. Here, the encoder input is a sequence of words, and the decoder generates outputs auto-regressively. We refer the reader to \cite{lewis2019bart} for further details. For our task, we fine-tune BART on our parallel data, where the reframed argument using MLM \& connotation dictionary is the encoder source and the original argument is the decoder target (Figure \ref{figure:sim}). The emotional connotations added to the source via the special token DELIM (see Section \ref{section:data1}) act as a ``control code'' for generation. Moreover, for lexical framing, subtle differences in word choices matter the most. By explicitly using special tokens ([SEP]) in our parallel data during fine-tuning, the BART model learns what to edit, instead of editing random words in the sentence, a common issue often found in attribute transfer models \cite{li2018delete,sudhakar2019transforming}. At test time, therefore, we can ensure the model reframes a desired content span. All hyper-parameters are mentioned in the \textbf{Appendix A}. Post fine-tuning at the decoding step, we use a top-k sampling strategy \cite{fan2018hierarchical} to reframe arguments conditioned on a input argument and a target emotion. \begin{table}[] \small \centering \begin{tabular}{|l|l|} \hline Source & \begin{tabular}[c]{@{}l@{}}trust \textless{}V\textgreater I suppose we could argue that they're \\much better at \textit{\color{red}soft power} than Nazi Germany \\or the USSR, but come on\end{tabular} \\ \hline BART & \begin{tabular}[c]{@{}l@{}}I suppose we could argue that they're much \\better at \textit{\color{blue}military strength} than .......... \end{tabular} \\ \hline \begin{tabular}[c]{@{}l@{}}BART\\ + NLI\end{tabular} & \begin{tabular}[c]{@{}l@{}}I suppose we could argue that they're much\\ better at \textit{\color{teal}diplomatic communication} than ......\end{tabular} \\ \hline \end{tabular} \caption{Generation from fine-tuned BART without control for entailment can sometime contradict the input thereby failing to maintain the same denotative meaning} \label{table:contradict} \vspace{-4ex} \end{table} \subsection{Post-decoding NLI} Our task is challenging in comparison to traditional text attribute transfer tasks as we need to maintain the same denotative meaning as the input. While in most cases BART is able to generate content which is semantically similar to the input, it sometimes contradicts the input. For example, Table \ref{table:contradict} shows that BART changes \textit{soft power} to \textit{military strength}. Here the denotative meaning changes. To control for this, we introduce an additional post-processing step. We generate multiple outputs by varying the value of \textit{k} (between 5 and 50) while conducting top-k sampling. We then calculate the entailment scores of these outputs with the input argument respectively using a RoBERTa \cite{liu2019roberta} model fine-tuned on the Multi-NLI dataset \cite{N18-1101} and then select the output having the best entailment score. We also experimented with other methods for incorporating entailment during decoding based on prior work (Section \ref{sec:related}), but found these techniques to be less effective than our method. As pre-trained sequence-to-sequence language models are good at copying input and generating natural-sounding output, we hypothesize that our approach will better allow us to change connotative meaning without affecting fluency and denotation. In contrast, approaches such as ``vocab boosting'' \cite{ghosh-etal-2017-affect} increase the logits of key connotative words, which would necessarily decrease the probabilities of functional words and words necessary for maintaining denotative meaning. Other approaches such as reinforcement learning \cite{pasunuru2017reinforced} may further decrease these desired qualities, while trying to maximize another objective. \section{Evaluation Tasks and Test Data} To evaluate our methods for argument reframing we need to look beyond our automatically labeled data. We consider two tasks: 1) reframing an argument that contains partisan language to a less partisan argument; and 2) reframing an appeal to fear or prejudice fallacy to an argument without this fallacy. Recently \citet{webson-etal-2020-undocumented}, proposed resources and methods to disentangle denotation and connotation in vector spaces. They evaluate their methods on a sample of around 300 collocations from vocabulary of Congressional records \cite{gentzkow2019measuring} and Hyper-partisan News \cite{kiesel-etal-2019-semeval} that occur at least 100 times and have high partisan skew. We use these words to filter arguments from the subreddits \textit{ChangeMyView} and \textit{Politics}. Some of these collocations include phrases such as \textit{abortion providers, investment vehicles, broken system, soft power,} and \textit{territorial claims}. We randomly sample 100 such arguments to benchmark the performance of our model and further use towards human evaluation. In addition, we test our models on propaganda techniques employed in news articles with an \textit{Appeal to Fear or Prejudice} \cite{da2019fine}. There are a total of 182 sentence-level text fragments labeled as Appeal to Fear or Prejudice in the dataset released by \citet{da2019fine}. We classify these 182 fragments as claims/premises/non-argument and randomly sample 50 premises. Our goal is to reduce the fallacious nature of the argument without changing the denotative meaning. As our training distribution is different from these two datasets, these tasks and test sets allow us to better test the generalization capabilities of our models. Furthermore, almost none of the collocations introduced by \citet{webson-etal-2020-undocumented} appear in the connotation dictionary of \citet{allaway2020unified}, which helps us avoid the risk of mimicking replacements from our training data. \begin{table}[] \small \centering \begin{tabular}{|l|l|} \hline INP1 & \begin{tabular}[c]{@{}l@{}}It would be \textit{\color{red}dangerous , suicidal folly} for \\infidels to pretend that ramadan is not the \\month of jihad\end{tabular} \\ \hline HUM1 & \begin{tabular}[c]{@{}l@{}}It would be \textit{\color{blue}counterproductive and}\\ \textit{\color{blue}unreasonable} for infidels to ........ jihad\end{tabular} \\ \hline INP2 & \begin{tabular}[c]{@{}l@{}}Trump backs away from further \\ \textit{\color{red}military confrontation} with Iran\end{tabular} \\ \hline HUM2 & \begin{tabular}[c]{@{}l@{}}Trump backs away from further \\ \textit{\color{blue}military} \textit{\color{blue}engagement} with Iran\end{tabular} \\ \hline \end{tabular} \caption{INP1 and INP2 are test data instances where INP1 is a Appeal to Fear example while INP2 is an argument containing partisan collocation } \label{table:test} \end{table} For both of these tasks, we ask humans to generate reframings based on our input test data for comparison and benchmark. We recruit two experts with argumentation and journalism background (not authors of this paper) to reframe arguments. For Appeal to Fear the instructions given were to make it less fallacious by reducing the fear and rephrasing the argument (HUM1 in Table \ref{table:test}), while for arguments with partisan collocation the human was instructed to change the collocation so as to make it trustworthy (HUM2 in Table \ref{table:test}). \section{Experimental Setup} \label{section:exp} To compare the quality of the reframed arguments, we benchmark our ENTRUST model against human performance and four baseline systems described below. For the data containing collocations from \cite{webson-etal-2020-undocumented}, because we know they represent partisan language the ideal goal is to reframe them. For Appeal to Fear or Prejudice data we reframe words which portray an emotion of fear based on the popular NRC Emotion Lexicon \cite{mohammad2013crowdsourcing}. \subsection{Baseline Systems} As argument reframing is a new task, we adapt several baselines that have been used for other generation tasks and also compare with human-generated reframings. \paragraph{\textbf{Bart wIthout Demarcator and ENtailment (BART$^{w/o}_{D+EN}$)}:} This is the pre-trained BART model fine-tuned on our parallel data without explicitly adding signals on what to edit or reframe and without post-processing based on entailment scores. This experiment helps us understand if BART learns to adapt to the emotional connotations and can automatically edit partisan collocations or words inducing fear without control. \paragraph{\textbf{Bart without EnTAilment (BART$^{w/o}_{EN}$)}:} This is the pre-trained BART model fine-tuned on our parallel data with explicit signals ([SEP] token) but without the NLI component as a post-processing tool. This experiment helps us understand how well BART learns to adapt to the emotional connotations without altering the denotative meaning once guided with what to reframe. \paragraph{\textbf{Lexical Replacement (LEXREP)}:} We use a similar method employed for our parallel data creation. We rely on Masked Language Models for lexical substitutions. Because our goal is to reframe arguments to be trustworthy we prefer substitutions which have a connotation of trust in the resource by \citet{allaway2020unified}. In case we cannot find the substitution in the connotation dictionary we honor default MLM predicted infilling. \paragraph{\textbf{Generative Style Transformer (GST)}:} We use the state of art for text style transfer by \citet{sudhakar2019transforming}, which is a part of a larger ``\textit{Delete Retrieve Generate}" framework \cite{li2018delete}. To maintain parity with other baselines, instead of letting the model delete attribute keywords we delete the partisan collocations or fear related words from the arguments as the first step, followed by the usual retrieve and generate steps. Our training data for this method includes only arguments labeled with their attribute (e.g., positive or negative). Arguments containing lexical connotations catering to trust are positive, while those not catering to trust are negative. \begin{table}[] \small \centering \begin{tabular}{|l|l|l|} \hline System & Partisan Task & Appeal to Fear Task \\ \hline BART$^{w/o}_{D+EN}$ & 64.1 & 38.5 \\ \hline BART$^{w/o}_{EN}$ & 91.9 & 43.1 \\ \hline GST & 86.4 & 38.3 \\ \hline LEXREP & 92.4 & \underline{44.3} \\ \hline ENTRUST & \underline{92.9} & \textbf{44.5} \\ \hline\hline HUMAN & \textbf{93.9} & 41.6 * \\ \hline \end{tabular} \caption{Semantic Similarity of reframed arguments with input arguments. (*) Here human did not restrict themselves to just lexical framing, so automated metrics might penalize them for more reframing.} \label{table:simscore} \end{table} \begin{table}[] \small \centering \begin{tabular}{|p{1.5cm}|p{1.1cm}|p{1cm}|l|l|} \hline System & Fluency & Meaning & \vline Trust $\uparrow$ & Fear$\downarrow$ \\ \hline INPUT & - & - & \vline 3.24 & 3.36 \\ \hline BART$^{w/o}_{D+EN}$ & 2.78 & 2.56 & \vline2.60 & 3.01 \\ \hline BART$^{w/o}_{EN}$ & 3.39 & 3.00 & \vline 3.13 & 2.58 \\ \hline LEXREP & 3.38 & 3.00 & \vline3.08 & 2.54 \\ \hline GST & 2.14 & 1.81 & \vline 2.01 & \underline{2.44} \\ \hline ENTRUST & \underline{3.51 } & \underline{3.30} & \vline \underline{3.52} & \textbf{2.39} \\ \hline\hline HUMAN & \textbf{3.72} & \textbf{3.63} & \vline \textbf{3.71} & 2.59 \\ \hline \end{tabular} \caption{Fluency and Meaning Preservation scores given by human judges on a scale of (1-5) for reframed arguments with respect to input arguments. Fluency and Meaning Preservation ratings are for all arguments in test set, while Trust ratings are for arguments with Partisan collocation (higher scores better), and Fear ratings for Appeal To Fear or Prejudice ones only (lower scores better).} \label{table:human} \end{table} \subsection{Evaluation Criteria} \paragraph{Automatic evaluation.} One important criterion is to measure if the reframed arguments are faithful to the input. Even though we are changing the argument for connotations, it should still maintain the same denotative meaning as the input. To this end we calculate \textbf{Semantic Similarity} with our input using SENTENCE BERT(SBERT) \cite{reimers2019sentence}. \paragraph{Human evaluation.} We use Amazon Mechanical Turk to evaluate on a total of 900 utterances, 750 generated from 5 systems and 150 utterances generated by humans. We proposed a set of 3 criteria to evaluate the generated output: (1) \textbf{Fluency (F)} (``How fluent and grammatical are the utterances?''), (2) \textbf{Meaning Preservation (M)} (``How well does the reframed argument capture the same denotative meaning as the input argument?''), (3) \textbf{Trustworthiness/Presence of Fear(T/PF)}. For the 100 input arguments reflecting partisan view we ask Turkers to rate reframed arguments based on trustworthiness with respect to the input. For the 50 Appeal to Fear or Prejudice fallacies we ask Turkers to rate reframed arguments based on presence of fear (the intention behind this being that we want to rank systems which portray the least amount of fear). In both of these ratings we still ask Turkers to keep into account the denotative meaning (i.e., making it trustworthy or less fallacious at the expense of meaning alterations should be scored lower). We hired 40, 25, 39 (23 and 16) Turkers for the three separate tasks respectively. The computed IAA using Krippendorff's alpha for Fluency, Meaning Preservation , Trust-Worthiness and Presence of Fear is 0.62, 0.65, 0.51, 0.46, respectively. \begin{table*}[!ht] \small \centering \begin{tabular}{|@{ }p{3.8cm}@{ }|l@{ }|@{ }p{7.8cm}@{ }|@{ }l@{ }|@{ }l@{ }|@{ }l@{ }|} \hline Original Argument & System & reframed Argument & F & M & T$\uparrow$/PF$\downarrow$ \\ \hline \multirow{6}{*}{\begin{tabular}[c]{@{}l@{}} It is difficult to think of any\\ single act that would do \\more to restore America's\\ \textit{\color{red}soft power} than the election\\ of Obama to the presidency \end{tabular}} & BART$^{w/o}_{D+EN}$ & \begin{tabular}[c]{@{}l@{}} It is difficult to think of any single act that would do more to \\restore America's \textit{\color{red}soft power} than the election of Obama to \\the presidency \end{tabular} & 3.7 & 2.3 & 3.3 \\ \cline{2-6} & BART$^{w/o}_{EN}$ & \begin{tabular}[c]{@{}l@{}} It is difficult to think of any single act that would do more to \\restore America's \textit{\color{blue}moral authority} than the election of Obama\\ to the presidency \end{tabular} &3.7 & 3.3 & 3.0\\ \cline{2-6} & LEXREP & \begin{tabular}[c]{@{}l@{}} It is difficult to think of any single act that would do more to \\restore America's \textit{\color{blue}moral standing} than the election of Obama\\ to the presidency \end{tabular} & 3.7 & 3.3 & 2.7 \\ \cline{2-6} & GST & \begin{tabular}[c]{@{}l@{}} \textit{\color{blue}Hated} it is difficult to think of any single act that would do\\ more to restore America's \textit{\color{blue}economy} than the election of\\ Obama to the presidency \end{tabular} & 1.7 & 1.7 & 2.7 \\ \cline{2-6} & ENTRUST & \begin{tabular}[c]{@{}l@{}} It is difficult to think of any single act that would do more to \\restore America's \textit{\color{blue}diplomatic credibility} than the \\election of Obama to the presidency \end{tabular} & \textbf{4.3} & \textbf{3.7} & \textbf{5.0} \\ \cline{2-6} & HUMAN & \begin{tabular}[c]{@{}l@{}} It is difficult to think of any single act that would do more to \\restore America's \textit{\color{blue}political and economic influence} than the \\election of Obama to the presidency \end{tabular} & 4.0 & 3.3 & 4.0 \textbf{} \\ \cline{2-6} \hline\hline \multirow{6}{*}{\begin{tabular}[c]{@{}l@{}} Or he can \textit{\color{red}seize} this \\opportunity and use his\\ \textit{\color{red}government's} diplomatic\\ \textit{\color{red}influence} to \textit{\color{red}defend} the life of\\ an australian citizen , whose\\ \textit{\color{red}courageous} public service is \\recognised by countless \\people across the world \end{tabular}} & BART$^{w/o}_{D+EN}$ & \begin{tabular}[c]{@{}l@{}} Or he can \textit{\color{red}seize} this opportunity and use his \textit{\color{red}governments's} \\diplomatic \textit{\color{red}influence} to \textit{\color{red}defend} the life of an australian citizen \\, whose courageous \textit{\color{blue} military} service is recognised by\\ countless people across the world \end{tabular} & 2.7 & 3.0 & 2.3 \\ \cline{2-6} & BART$^{w/o}_{EN}$ & \begin{tabular}[c]{@{}l@{}} Or he can \textit{\color{blue}honor} this opportunity and use his \textit{\color{blue}nation's} \\diplomatic \textit{\color{blue}resources} to \textit{\color{blue}honor} the life of an australian citizen \\, whose \textit{\color{blue} unwavering} public service is recognised by countless \\people across the world \end{tabular} & 4.0 & 4.7 & \textbf{1.3}\\ \cline{2-6} & LEXREP & \begin{tabular}[c]{@{}l@{}} Or he can \textit{\color{blue}take} this opportunity and use his \textit{\color{blue}nations's} \\diplomatic \textit{\color{blue}resources} to \textit{\color{red}defend} the life of an australian citizen \\, whose courageous \textit{\color{blue} military} service is recognised by \\countless people across the world \end{tabular} & \textbf{4.7} & 4.0 & 2.0\\ \cline{2-6} & GST & \begin{tabular}[c]{@{}l@{}} Or he can \textit{\color{blue}do} this opportunity and use his \\diplomatic \textit{\color{blue}expertise} to \textit{\color{red}change} the life of an australian citizen \\, whose public service is recognised by countless \\people across the world \end{tabular} & 1.7 & 2.0 &2.0 \\ \cline{2-6} & ENTRUST & \begin{tabular}[c]{@{}l@{}} Or he can \textit{\color{blue}honor} this opportunity and use his \textit{\color{blue}nation's} \\diplomatic \textit{\color{blue}resources} to \textit{\color{blue}vindicate} the life of an australian\\ citizen , whose \textit{\color{blue}unwavering} public service is recognised \\by countless people across the world \end{tabular} & \textbf{4.7} & \textbf{4.7} & \textbf{1.3} \\ \cline{2-6} & HUMAN & \begin{tabular}[c]{@{}l@{}}Or he can \textit{\color{blue}pick up} this opportunity and use his government’s\\diplomatic influence to defend the life of an Australian\\ citizen, whose \textit{\color{blue}actions have been publicly recognized as} \\\textit{\color{blue}highly relevant at an international level}. \end{tabular} & 3.7 & 4.0 & 2.3 \\ \cline{2-6} \hline \end{tabular} \caption{Examples of generated outputs from different systems (with human reframed argument as references) for arguments containing partisan collocations and appeal to fear, respectively. We show average scores (over three annotators) on a 1-5 scale with 1 denotes the worst and 5 be the best. More examples in Appendix} \label{table:all} \end{table*} \section{Results} \paragraph{Automatic Evaluation.} As can be seen in Table \ref{table:simscore} our model ENTRUST maintains the denotative meaning with the input better than other systems ($p<.001$ using approximate randomization tests) and only marginally behind humans when it comes to arguments with partisan collocations. For Appeal to Fear or Prejudice our system maintains better denotative meaning than all systems except LEXREP ($p<.001$). The automatic metric somewhat penalizes humans for changing more content than just targeted words; this unreliability is a known issue with automated metrics \cite{novikova-etal-2017-need} and strongly implies a need for human evaluation. \paragraph{Human Evaluation.} Table \ref{table:human} shows the results of our human-based evaluations. For fluency, meaning preservation, trustworthiness, and reduction of fear the ENTRUST model is better than all the baselines ($p<.001$ using approximate randomization tests). It is further encouraging to see that the entailment step helps us maintain better denotative meaning (See Table \ref{table:human} Col3: Row 4 vs Row 7). For Presence of Fear, Turkers often rate our ENTRUST model to be the least fearful, including slightly when compared to reframings of an expert. We hypothesize this is because the human judges found it difficult to completely remove fear while keeping the denotative meaning (indeed the humans scores slightly better on meaning comparing with our system ENTRUST). Sometimes, an ungrammatical generation or a reframing which change the meaning will contain less fear (rating 1 meaning no fear at all). However, to avoid this we explicitly asked Turkers to rate those samples as moderate so as to not bias the overall results. \section{Analysis and Discussion} As can be seen in Table \ref{table:all}, the ENTRUST model accurately captures \textit{diplomatic credibility} as an alternate for \text{soft power} which is encouraging as soft power is measured through \textit{culture, diplomacy, education, business/innovation, and government.}\footnote{\url{https://en.wikipedia.org/wiki/Soft_power}} The BART$^{w/o}_{D+EN}$ model often fails to reframe anything, which shows the importance of adding [SEP] tokens as explicit supervision so that the model knows what to edit. The GST model fails at both grammaticality and meaning preservation, which makes it harder to judge its trustworthiness and ability to ameliorate fearful appeal. Finally, ENTRUST reframings are not static. Table \ref{table:context} shows that for the same collocation of \textit{targeted killing}, the reframings are different, contingent on the context. This goes on to prove that our model not only generalizes to unseen test data, but can produce novel, grammatical and meaningful edits based on context. \begin{table}[] \small \centering \begin{tabular}{|l|} \hline \begin{tabular}[c]{@{}l@{}}An Iranian government official seemed to suggest that \\President Trump’s properties could be potential targets\\ in retaliation for the US \textit{\color{red}targeted killing} of Iranian\\ general Qassem Soleimani.\end{tabular} \\ \hline \begin{tabular}[c]{@{}l@{}}An Iranian government official seemed to .... suggest that \\President Trump’s properties .... in retaliation for the US\\ \textit{\color{blue}involvement in the execution} of Iranian .....\end{tabular} \\ \hline\hline \begin{tabular}[c]{@{}l@{}}A federal appeals court ordered the U.S. Department of \\Justice to turn over key portions of a memorandum\\ justifying the government's \textit{\color{red}targeted killing} of people \\linked to terrorism, including Americans\end{tabular} \\ \hline \begin{tabular}[c]{@{}l@{}}A federal appeals court ordered the U.S. Department of \\Justice to turn ......... justifying the government's \\\textit{\color{blue}extrajudicial execution} of people ... terrorism, .........\end{tabular} \\ \hline \end{tabular} \caption{Different reframed arguments by ENTRUST model based on same collocation} \label{table:context} \end{table} \section{Related Work} \label{sec:related} The effects of lexical framing have been studied for social and political issues, although our work is the first to use lexical framing in generation for positive framing effects (less partisan, no appeal to fear fallacy). \citet{demszky2019analyzing} and \citet{tyagi2020computational} study political polarization and how this manifests in differences in word choice among different groups; \citet{khudabukhsh2020we} provide an interpretable framework using machine translation between groups to generate differences. While these works encourage computational approaches to reframe arguments for better lexical choice, these approaches do not control for denotation or connotation and thus may cause differences in word choice to result in a change in meaning. The most similar work to ours is that of \citet{pryzant2020automatically}, who use a corpus of Wikipedia edits to train a model for debiasing, which includes framing. However, in their work communicative intent is left implicit; the corpus is only labeled for types of debiasing, which includes framing at a high level and not the connotations involved. Thus, their model only learns lexical differences, whereas our model is controllable. While our focus is on lexical framing, other work has investigated the identification of other types of frames and their effects. \newcite{greene-resnik-2009-words} studied \textit{syntactic} framing, finding a link between implicit sentiment and syntactic packagings. Previous studies have also involved \textit{emphasis} framing -- \newcite{ding-pan-2016-personalized} find that emphasizing aspects of products given personal information is more effective for content selection in advertisements. Other research has involved \textit{issue} framing -- \newcite{ajjour-etal-2019-modeling} and \newcite{hartmann-etal-2019-issue} study how arguments are framed in debates (e.g., in terms of economics or safety). \citet{Nguyen2013LexicalAH} and \citet{field2018framing} study ``agenda-setting'' for news and congressional debates and \newcite{DBLP:journals/pacmhci/AugustOTSR18} for study recruitment. \newcite{cano-basave-he-2016-study} and \newcite{Musi2019FramingFS} leverage \textit{semantic} frames for distant labeling and analysis of arguments in political debates, respectively, and find, for example, that evidence and reasoning are among the most common. However, these approaches have focused on identification rather than generation. Finally, our work is also related to style transfer and controllable generation. Much of the work in ``style transfer'' has referred to changing the sentiment of a statement, which changes the truth condition and thus the denotative meaning. Sentiment is often explicitly marked and thus approaches such as deleting and replacing lexical markers are effective \cite{li-etal-2018-delete, sudhakar-etal-2019-transforming}, although our experiments showed the difficulty of applying these techniques to our task. To control text generation by limiting contradictions, \citet{pasunuru2017reinforced} use an entailment score as a reward in Reinforcement Learning, ensuring that a generated text is logically implied by the ground-truth text. \citet{holtzman2018learning} utilize a discriminative model trained on SNLI \cite{bowman2015large} to complement an RNN generator and guide the decoding process to improve contradictions in generation. Although we experimented with both of these approaches, including the approach of \citet{holtzman2018learning} with MNLI to account for entailment in text generation, none of them yielded better results than our method. Other approaches have explored ``vocab boosting'' \cite{ghosh-etal-2017-affect} for tasks such as de-biasing \cite{ma2020powertransformer}, which involves increasing the values of certain words; however, as these values are on the simplex, the softmax function necessarily decreases the values of other logits which are key to fluency such as function words. \section{Conclusion} Our experiments showed that our approach is effective in reframing partisan arguments and appeals to fear for increased trustworthiness. We provided a method for creating a dataset using a lexical resource for connotations and masked language modeling. We used this dataset to fine-tune a controllable text generation model for the task of changing connotative meaning and used a model trained for natural language inference to maintain the denotative meaning. Our evaluations found that our approach generalized to two different tasks and data sets. In future work, we plan to directly incorporate the role of stance in framing (for arguments and counter-arguments). We also plan to expand our work to generating concessions \cite{Musi2018HowDY}, where the goal is for the speaker to portray some point of agreement in a positive light before disagreeing. \section{Ethics} Our data is collected from Reddit and we understand and respect user privacy. Our models are fine-tuned on sentence level data obtained from user posts. These do not contain any explicit detail which leaks information about a users name, health, negative financial status, racial or ethnic origin, religious or philosophical affiliation or beliefs, sexual orientation, trade union membership, alleged or actual commission of crime. Second, although we use language models trained on data collected from the Web, which have been shown to have issues with bias and abusive language \cite{sheng-etal-2019-woman, wallace-etal-2019-universal}, the inductive bias of our models should limit inadvertent negative impacts. Unlike model variants such as GPT, BART is a conditional language model, which provides more control of the generated output. We have two levels of control on our generation approach: lexical replacements via connotations associated with trust and an entailment method that aims to keep the same denotation of the original argument. While dual-use concerns are certainly possible here, we think that open-sourcing this technology will help to generate arguments with more balanced and trusted language that are less targeted towards partisanship or appeals to fear. Finally, while there may be concerns about building generative models for persuasion, social scientists distinguish persuasion from manipulation based on two aspects: dissimulation and constraint \cite{Nettel2012}. Dissimulation involves concealing intention, which requires hiding information, whereas constraint involves removing options from the audience and forcing them to accept the conclusion. Our work on reframing arguments does not aim to hide information about a topic or present it as the only choice, but aims to provide the same argument using more balanced and trusted language. We achieve this by two key components of our technology: controllable text generation (connotation associated with trust) and entailment model to ensure same denotation. The technology should be used responsibly, particularly making sure the generation is controllable for trust and positive emotion and that the entailment component is used for ensuring the same denotation with the original argument. Finally we pay the Turkers at a rate of 15\$/hour, complying with minimum wage standards in most places. \section{Results} \subsection{Automatic Evaluation} As can be seen in Table \ref{table:simscore} our model ENTRUST maintains the denotative meaning with input better ($p<.001$ using approximate randomization tests) than other systems and only marginally behind humans when it comes to arguments with partisan collocations. For Appeal to Fear or Prejudice our system maintains better denotative meaning than all systems except LEXREP ($p<.001$). It somewhat penalizes humans for changing more content than just words which makes automated metrics not reliable always\cite{novikova-etal-2017-need}. This implicates strong need for human evaluation. \subsection{Human Evaluation} For fluency and meaning we see how the ENTRUST model is better than all the baselines ($p<.001$ using approximate randomization tests). It is further encouraging to see that the entailment step helps us in maintaining better denotative meaning (See Table \ref{table:human} Col3: Row 4 vs Row 7). For Fearness ratings from MTurk results, we see that they often rate ENTRUST model to be least fearful especially in comparison to a human expert. We hypothesize this is because human judges correlate degree of fear to the amount of fear bearing words present in an argument. Sometimes, an ungrammatical generation or a re-framing which totally change the meaning will contain less fear (rating 1 meaning no fear at all) but to avoid this we explicitly asked Turkers to rate those samples as moderate so as to not bias the overall results. \smnote{I will work a bit on the interpretation of the results above} \section{Analysis and Discussion} \begin{table}[] \small \centering \begin{tabular}{|l|} \hline \begin{tabular}[c]{@{}l@{}}An Iranian government official seemed to suggest that \\President Trump’s properties could be potential targets\\ in retaliation for the US \textit{\color{red}targeted killing} of Iranian\\ general Qassem Soleimani.\end{tabular} \\ \hline \begin{tabular}[c]{@{}l@{}}An Iranian government official seemed to .... suggest that \\President Trump’s properties could be potential targets\\ in retaliation for the US \textit{\color{blue}involvement in the execution}\\ of Iranian general Qassem Soleimani.\end{tabular} \\ \hline\hline \begin{tabular}[c]{@{}l@{}}A federal appeals court ordered the U.S. Department of \\Justice to turn over key portions of a memorandum\\ justifying the government's \textit{\color{red}targeted killing} of people \\linked to terrorism, including Americans\end{tabular} \\ \hline \begin{tabular}[c]{@{}l@{}}A federal appeals court ordered the U.S. Department of \\Justice to turn over key portions of a memorandum\\ justifying the government's \textit{\color{blue}extrajudicial execution} of \\people linked to terrorism, including Americans\end{tabular} \\ \hline \end{tabular} \caption{Different Re-framed arguments by ENTRUST model based on same collocation} \label{table:context} \end{table} The effects of lexical framing have been studied for social and political issues, although our work is the first to use lexical framing in generation for positive framing effects. \citet{field2018framing} proposed new ways to identify subtle media manipulation strategies at the intersection of agenda-setting and framing. \citet{demszky2019analyzing} show how social media discussion of mass shootings is highly polarized politically and that this polarization is primarily driven by partisan differences in framing rather than topic choice. \citet{tyagi2020computational} discussed how a major political party in India used polarized hashtags and called for escalation of conflict more so than politicians from other parties. \citet{khudabukhsh2020we} use modern machine translation methods to provide an interpretable framework to understand polarization and the differences between political framing at the granularity of words. \citet{pryzant2020automatically} rely on Wikipedia edits that removed various framings, presuppositions, and attitudes from biased sentences and train a sequence to sequence model to neutralize such biases. These works encourage computational applications of natural language processing to reframe arguments for better lexical choice. While our focus is on lexical framing, other work has investigated the identification of other types of frames and their effects. \newcite{greene-resnik-2009-words} studied \textit{syntactic} framing, finding a link between implicit sentiment and synactic packaging (e.g. the difference between active and passive voice). Previous studies have also involved \textit{emphasis} framing -- \newcite{ding-pan-2016-personalized} find that emphasizing aspects of products given personal information is more effective for content selection in advertisements. Other research has involved \textit{issue} framing -- \newcite{ajjour-etal-2019-modeling} and \newcite{hartmann-etal-2019-issue} use an argument-specific set of frames, such as economics, feasibility, and safety,with \newcite{ajjour-etal-2019-modeling} predicting frames using multi-task learning and \newcite{hartmann-etal-2019-issue} clustering frames in a latent semantic space. \newcite{cano-basave-he-2016-study} leverage \textit{semantic} frames for distant labeling of arguments in political debates.\newcite{Musi2019FramingFS} study the use of semantic frames in fracking debates, finding that evidence and reasoning are among the most common.\newcite{DBLP:journals/pacmhci/AugustOTSR18} also use a targeted set of frames and find that alternative slogans in advertisements improve self-selection for experimental online studies. Finally, our work is also related to style transfer and controllable generation. Much of the work in ``style transfer'' has referred to changing the sentiment of a statement, which changes the truth condition and thus the denotative meaning. Sentiment is often explicitly marked and thus approaches such as deleting and replacing lexical markers are effective \cite{li-etal-2018-delete, sudhakar-etal-2019-transforming}, although our experiments showed the difficulty of applying these techniques to our task. To control text generation by limiting contradictions, \citet{pasunuru2017reinforced} use an entailment score as a reward in Reinforcement Learning, ensuring that a generated text is logically implied (i.e., is a paraphrase or directed partial match with) by the ground-truth text. \citet{holtzman2018learning} utilize a discriminative model trained on SNLI \cite{bowman2015large} to complement an RNN generator and guide the decoding process to improve contradictions in generation. We experimented with both these approaches, especially the approach of \citet{holtzman2018learning} even with MNLI to account for entailment in text generation, however none of them yielded better results than our method. Other approaches have explored ``vocab boosting'' \cite{ghosh-etal-2017-affect} for tasks such as de-biasing \cite{ma2020powertransformer}, which involves increasing the values of certain words; however, as these values are on the simplex, the softmax function necessarily decreases the values of other logits which are key to fluency such as function words.
{'timestamp': '2021-04-13T02:14:17', 'yymm': '2103', 'arxiv_id': '2103.06758', 'language': 'en', 'url': 'https://arxiv.org/abs/2103.06758'}
arxiv
\section{Introduction} Poroelasticity deals with the mechanical and hydraulic responses of the materials consisting of an elastic porous solid matrix interacting with viscous fluid percolating its pores. This field covers a wide range of applications from soil and rock mechanics to soft biological tissues such as the brain and cancerous ones \cite{Biot1941,FRANCESCHINI20062592}. There are different theories developed for poroelastic problems, including the phenomenological Biot's theory \cite{Biot1941} and microstructure-derived equations in \cite{burrigekeller}. The former considers only the homogenised form to be fitted into experiments while the latter is based on asymptotic homogenisation providing analytical relationships, in the form of PDEs to be solved in the cell domain, between the microscale and effective properties. The cell problems, then, can be solved using numerical tools such as Finite Element (FE) method as in \cite{PENTA201580, Hdehghani, HdehghaniThesis} which, later on, improved by means of Artificial Intelligence (AI) in \cite{HDAZ2020}. One considerable limitation of using asymptotic homogenisation is that the upscaling procedure is only straightforward for infinitesimal deformations which restricts us to the choice of linear poroelasticity (in the sense of linear constitutive equations). On the other hand, the phenomenological approaches such as Biot's poroelastic theory \cite{Biot1941} and biphasic mixture theory \cite{BOWEN19801129} have been developed to predict the nonlinear poroelastic behaviour of soft tissues \cite{simon1983poroelastic, Oomens1985, Mow1986, Simon1991, Simon1992, alfio_grillo}. These theories, however, do not provide sufficient links between micro and macro scales, which considering the complexity and multiscale and multiphysics nature of poroelastic problems, is crucial for a realistic analysis of the scenarios of interest. The fluid flow in poroelastic media is usually described via linear Darcy's law \cite{Darcy1856}, which again is valid in the cases with infinitesimal fluid velocity and solid deformation. Nonlinear fluid flow in poroelastic media has been considered as another challenge which, so far, is addressed via cubic and quadratic corrections (in terms of averaged velocity or Reynolds number) to linear Darcy's law in a rigid porous media \cite{forchheimer1901, mei_auriault_1991, Wodie1991CorrectionNL, Firdaouss1997}. However, not only another parameter (apart from hydraulic conductivity) is to be assumed/determined for the correction term but also the solid deformation does not play any role in the fluid flow nonlinearity using such models. In this study, we aim at overcoming the mentioned hurdles to achieve a more accurate model describing mechanical and hydraulic behaviour of poroelastic media by means of an incremental remodelling-based nonlinear method for numerical analysis of such complex problems. Incremental analysis of structures has long been used in the numerical analysis of "path-dependent" problems such as soil mechanics, plasticity, large (geometric) deformations, etc. \cite{Roger1958, Yarimci1966, Christian1977, YAGHMAI19711375, Sharifi1971NonlinearBA, David1969}. In such frameworks, three configurations are considered in the deformation history, namely, \emph{reference configuration} which is the original state at the beginning of the analysis, the current \emph{deformed configuration} at time $t + \Delta t$, and the \emph{intermediate configuration} at time $t$ just before the deformed configuration. In other words, the intermediate configuration is at the beginning of the time increment, which ends at the deformed configuration. The path from the former to the latter is usually linear, while the transformation from the reference configuration to the deformed configuration can be nonlinear. Although, in linear poroelastic problems, the constitutive equations are linear the nonlinearity of mechanical and hydraulic response arises from solid-fluid interaction. In fact, as a poroelastic problem is generally history/path-dependent, it is usually performed in an incremental numerical framework regardless of being linear \cite{Hdehghani1} or nonlinear \cite{Simon1991}, however, the full potential of such frameworks have not been exploited. In particular, this framework allows the rearrangement of material properties in each time increment (remodelling) without considerable loss of efficiency if the updated properties are available in real-time. A similar approach is exploited in poroplastic models in \cite{alfio_grillo} in which the structural reorganisation is assumed to obey a phenomenological flow rule driven by stress. In the field of heterogeneous media, the microstructural evolution is captured based on asymptotic homogenisation in \cite{RAMIREZTORRES2018245} which is limited to solving the cell problems at each time increment and spatial point to update the macroscopic properties imposing a high computational cost. A similar framework is also applicable in the field of poroelasticity. However, due to the inefficiency imposed by the upscaling and localisation, it is not feasible for real-world problems. The key to overcoming this problem could be found in Artificial Intelligence (AI). Data-driven modelling has been successfully applied in a wide range of problems from marketing \cite{Malhotra1999} to computational analysis of mechanics problems. The well known Artificial Neural Networks (ANNs) \cite{Rosenblatt58theperceptron} has been successfully applied in the field of computational mechanics by providing a powerful interpolation mean. This method is inspired by human brain architecture, acting as a transfer function by providing accurate outputs from given inputs. An ANN consists of some hidden layers each adopting a number of neurones (see, Figure \ref{fig_ANN_Parallel} for ANN architecture) which includes a weight and a bias to be tuned during an optimisation procedure called ANN training. The number of hidden layers and the neurones inside each are chosen based on the user's experience. Having a large number of neurones and layers could lead to inefficiency of training and output calculation (so-called feed-forward procedure) while having a small number of neurones can lead to a loss of accuracy. The training procedure, which determines the network's accuracy, is based on an optimisation procedure minimising a distance function from, in the simplest case, \emph{a priori} provided training dataset consisting of a number of \emph{exact} outputs with their corresponding inputs. In computational mechanics, ANNs are employed to complement standard approaches such as FE \cite{HDAZ2020} or, in specific cases, to carry out the whole computations \cite{Raissi2018, dehghani2020hybrid}. In poroelasticity, ANNs are employed for effective model parameter identification in order to efficiently solve complex problems with spatially dependent porosity and solid matrix properties by the present authors in \cite{HDAZ2020}. The training dataset in the latter study was acquired by solving a certain number of cell problems. We employ ANNs for fast computation of both effective model parameters and coefficients required for localisation procedure. Here, we integrate the mentioned techniques and develop an ANN-informed incremental computational methodology for numerical analysis of poroelastic media under finite deformation considering rearrangement of microstructural properties (porosity and material properties of the solid matrix) and their effects on the effective coefficients of homogenised system of PDEs. The following steps are taken for this purpose: \begin{itemize} \item First, a certain number of cell problems are solved in order to provide a training dataset with inputs being the microscopic properties and the outputs being the tensors required for effective properties calculation as well as localisation procedure. \item A suitable ANN is designed and trained via the provided training dataset replacing the time-consuming FE analysis of the cell problems for the calculation of the effective properties of the medium. \item Then, the time domain is discretised, ensuring infinitesimal deformation in each time increment followed by the space discretisation of macroscale domain for FE analysis. \item The homogenised system of PDEs obtained via asymptotic homogenisation multiscale analysis for poroelastic media \cite{burrigekeller} (linear poroelasticity) is employed for numerical analysis of macroscopic response in one increment. \item With the help of ANN, this is followed by localisation analysis which calculates the average microscale solid matrix deformation due to the macroscale mechanical and hydraulic response. \item The porosity and solid matrix material properties, using a specific strain energy function (here, neo-Hookean), are updated based on the current microscopic deformation (remodelling). \item The ANN, again, is employed to carry out upscaling for rearranged effective coefficients identification based on the current (updated) microscopic properties. \item The new properties of macroscale system of PDEs are used for the numerical analysis of the next time increment starting from the fourth step. \end{itemize} The governing equations of the mentioned framework are presented in details in Section \ref{sec:2}. In Section \ref{Sec_numericalExamples}, the described methodology is employed, first, for the analysis of a simple poroelastic problem in order to study the micro-macro interdependency of deformation and properties highlighting the feasibility and importance of the present methodology. Then, Darcy's experiment is simulated showing that employing this framework, there is no need for any correction to Darcy's law as the nonlinear fluid flow is captured automatically by updating the hydraulic conductivity. Last but not least, a cyclic uniaxial test, similar to the experiments on the brain tissue in \cite{FRANCESCHINI20062592}, is carried out showing the viability of the simulation of complex real-world problems by the present computational framework. The promising results of the numerical examples open several directions for the future works, which together with discussion and conclusions are provided in Section \ref{Sec_conclusions}. Furthermore, a part of the previously developed homogenisation procedure is placed in Appendix \ref{Homo_app}. \section{Governing equations} \label{sec:2} Let us consider an arbitrary poroelastic domain $\Omega \in \mathbb R^3$ which consists of the solid matrix $\Omega_s$ and interstitial fluid $\Omega_f$ such that $\Omega = \Omega_s \cup \Omega_f$. We assume that the poroelastic medium has the average pore size $d$ which is infinitesimal compared to the medium size $L$ (e.g. as shown in Figure \ref{fig:lenghtscale}). As the exploited analytical homogenisation and localisation are valid for infinitesimal strain, the time discretisation is the first matter to consider, clarifying the applicability of the multiscale methodology. The time-dependent state $\vett U_t$ (at time $t$) of the problem is advanced to the time instant $t+\Delta t$ as follows: In one increment, $\vett U_{t+\Delta t}$ is calculated from the intermediate configuration (configuration at time $t$), the time increment $\Delta t$, and solution increment $\Delta \vett U$. As the intermediate configuration and $\Delta t$ are fixed, the problem decreases to finding $\Delta \vett U$ and consequently $\vett U_{t+\Delta t} $ via \begin{equation} \vett U_{t+\Delta t} = \vett U_t + \Delta \vett U \label{timedisc} \end{equation} At this stage, for the sake of simplicity, we drop $\Delta$ notation, however, we emphasise that the following equations and mechanical relationships are considered to be within one increment (i.e. from time $t$ to $t + \Delta t$), thus, applying the infinitesimal deformation assumptions. Considering the mentioned condition, in one increment, the solid compartment is linear elastically interacting with incompressible Newtonian fluid percolating its pores with no-slip boundary condition on the solid-fluid interface. The corresponding equations are \begin{align} \nabla \cdot \tens{\tau}&=0 &\textrm{in}\,\,\Omega_s\label{eq:solid} \\ \tens{\tau}&=\mathbb{C} \xi(\vett u) &\textrm{in}\,\,\Omega_s \label{eq:solidstress} \\ \nonumber \\ \nonumber \\ \label{eq:fluido} \nabla \cdot \tens{\sigma}&=0 &\textrm{in}\,\,\Omega_f\\ \tens{\sigma}&=-p\tens{I}+2\mu \xi(\vett{v}) &\textrm{in}\,\,\Omega_f \label{fluidstress}\\ \nabla \cdot \vett{v}&=0 &\textrm{in}\,\,\Omega_f \\ \nonumber \\ \nonumber \\ \label{eq:stress} \tens{\tau}\vett{n}&=\tens{\sigma}\vett{n} &\textrm{on}\,\,\Gamma\,\,\\ \dot{\vett{u}}&=\vett{v} &\textrm{on}\,\,\Gamma\,\, \label{eq:tangente} \end{align} for solid, fluid, and interface conditions, respectively, where $\vett u$ indicates the displacement of solid phase, $\vett{v}$ represents the fluid velocity, $\mathbb{C}$ is the fourth rank solid matrix elasticity tensor, and $\mu$ is the interstitial fluid dynamic viscosity. $\tau$ and $\sigma$ are the solid Cauchy and fluid viscous stress tensors, respectively. Furthermore, the symmetric gradient operator $\xi$ is defined as \begin{equation} \label{eq:symgrad21} \xi{(\,\begin{picture}(-1,1)(-1,-3)\circle*{3}\end{picture}\;\,)} = \frac{1}{2}\left[ \nabla(\,\begin{picture}(-1,1)(-1,-3)\circle*{3}\end{picture}\;\,)+[\nabla(\,\begin{picture}(-1,1)(-1,-3)\circle*{3}\end{picture}\;\,)]^{\tens T}\right]. \end{equation} \subsection{Non-dimensionalisation} Poroelasticity has a wide range of applications from soil and rock mechanics to different biological tissues (such as brain tissue). It also has a complex interdependency between the units of measurement due to its multiscale and multiphysics nature which is a significant source of ambiguity leading to a misunderstanding of the model parameters and response \cite{Firdaouss1997}. In this study, before we proceed further, we take advantage of Non-dimensionalisation procedure which is similar to the one in \cite{growing}. For each example, we adopt four formally independent characteristic values for macroscale length $L$, average microscale cell dimension $d$, fluid viscosity $\mu_c$, and force $f_c$ such that \begin{equation} \vett{x}=L\vett{x}',\quad \vett y = d \vett y', \quad \vett F = f_c \vett F' \quad \mu=\mu_c \mu', \label{nondim2} \end{equation} where $\vett x$ and $\vett y$ are macroscale and microscale spatial variables, $\vett F$ is (any) force, and $\mu$ is the interstitial fluid dynamic viscosity. All other parameters in this study are non-dimensionalised with respect to the mentioned independent characteristic values as \begin{align} \nonumber &\vett u = L \vett u',\quad \vett{v}=\frac{f_cd^2}{L^3\mu_c}\vett{v}', \quad \mathbb{C}=\frac{f_c}{L^2 }\mathbb{C}', \quad t = \frac{L^4 \mu_c}{f_c d^2} t',\\ \nonumber & \quad \quad\quad \vett{\tens K} = \frac{d^2}{\mu_c}\vett{\tens K}', \quad M = \frac{f_c}{L^2 } M', \quad \tilde{\mathbb{C}}=\frac{f_c}{L^2 }\tilde{\mathbb{C}'} \end{align} where $\,\begin{picture}(-1,1)(-1,-3)\circle*{3}\end{picture}\;\,'$ indicates the non-dimensional parameter. $\vett{\tens K}$, $M$, and $\tilde{\mathbb C}$ are the hydraulic conductivity, Biot modulus, and effective (drained) elasticity tensor which are to be defined in Section \ref{physical}. \subsection{Homogenisation} \label{physical} In this section, we outline the mathematical two-scale homogenisation based on non-dimensionalised parameters which is developed and employed in several studies in the literature \cite{burrigekeller, HdehghaniThesis, growing}. For the reader's convenience and as we will refer to the notations later on, we provide more details of this procedure in Appendix \ref{Homo_app}. Removing the prime symbol (indicating non-dimens- ionalised variables), for the sake of simplicity, all the Equations \eqref{eq:solid}-\eqref{eq:tangente} will be written the same except for Equation \eqref{fluidstress} which adopts the form \begin{equation} \tens{\sigma}=-p\tens{I}+\epsilon^22\mu \xi(\vett{v}) \quad \quad\quad\quad\,\,\,\textrm{in}\,\,\Omega_f \label{Nonfluidstress} \end{equation} where $ \epsilon=d/L \ll 1 $ is the length scale separation parameter. The coefficient $\epsilon^2$ appears due to the scaling of Stokes flow in porous media (see e.g. \cite{burrigekeller, growing}). An infinitesimal length scale separation parameter $\epsilon$ allows to make use of asymptotic homogenisation technique. We assume that $\vett{x}$ and $\vett{y}$ ($ \vett{y}=\vett{x}/\epsilon $) indicate two formally independent macroscale and microscale spatial variables, respectively. \begin{figure*} \centering \includegraphics[width=12cm]{ScalesNN} \label{fig:lenghtscale} \centering \caption{A periodic multiphysics cell is assumed based on the initial peoperties of the poroelastic medium via Path 1. The governing equations of homogenised medium (in $\Omega_h$) are constructed (Path 2) and characterised (via auxiliary cell problems considered as Path 3) based on the assumed cell properties (upscaling or homogenisation). Based on the response of the homogenised model and identified parameters in Path 3, the deformation of solid matrix ($\Omega_s$) is determined via localisation (Path 4). The fluid volume fraction (porosity) and solid material properties are modified via solid phase kinematics and (arbitrary) material model. Note that Path 1 and Path 2 are only considered once for each problem (which are equivalent for a wide range of problems) but the loop, Path 3--macroscale analysis--Path 4--cell remodelling, is performed at each time increment. The ANN is employed in Path 3 and Path 4. } \label{fig:lenghtscale} \end{figure*} Then, the differential operators transform into two independent ones for macroscale and microscale as \begin{equation} \nabla \rightarrow \nabla_{\vett{x}}+\frac{1}{\epsilon} \nabla_{\vett{y}} \label{eq:gradnew} \end{equation} and, similarly, \begin{equation} \xi \rightarrow \xi_{\vett{x}}+\frac{1}{\epsilon} \xi_{\vett{y}} \label{eq:xiTransform} \end{equation} which separates the problem into two-scales. Applying the transformation \eqref{eq:gradnew} and \eqref{eq:xiTransform} into Equations \eqref{eq:solid}-\eqref{eq:tangente} yields the multiscale equations (Equations \eqref{eq:hstruttura}-\eqref{eq_dispinterface} in Appendix \ref{Homo_app}). Equating the coefficients of $\epsilon^0$ and $\epsilon^1$, by replacing every field (stress, displacements etc.) by its power of series representation, $\psi_{\epsilon}(\vett{x},\vett{y})=\sum_{l=0}^{\infty}\psi^{(l)}(\vett{x},\vett{y})\epsilon^ l$, yields zero-th and first order equations (i.e. by choosing $l=0,1$) (Equations \eqref{eq:zstruttura}-\eqref{eq:utangente} in Appendix \ref{Homo_app}) which are the principal ones of the upscaling process based on which the leading order solid displacement $\vett{u}^{(0)}$ and hydrostatic pressure $p^{(0)}$ are microscale independent (locally constant) and could be referred to as macroscale variables. The zero-th (leading) and first order variables are shown by $\,\begin{picture}(-1,1)(-1,-3)\circle*{3}\end{picture}\;\,^{(0)}$ and $\,\begin{picture}(-1,1)(-1,-3)\circle*{3}\end{picture}\;\,^{(1)}$, respectively. As the relative fluid velocity and the solutions of the cell problems (will be defined later) are not constant at the microscale, we apply the integral average \begin{equation} \label{eq:intavg} \left\langle \psi \right\rangle_k= \frac{1}{|\Omega|}\int_{\Omega_k}\psi(\vett{x},\vett{y})\,\textrm{d}\vett{y} \quad k=f,s, \end{equation} to exploit the acquired equations in the homogenisation process and macroscale. Assuming $\vett{y}$-periodicity, no-growth limit \cite{growing}, and the following ansatzes \begin{align} \vett{u}^{(1)}&=\mathcal{A}\xi_{\vett{x}}(\vett u^{(0)}) +\vett{a}p^{(0)} \label{ansatzsolid}\\ \vett{v}_{rf}&=-\vett{\tens{W}}\nabla_{\vett{x}}p^{(0)},\label{eq:vzero}\\ p^{(1)}&=-\vett{P}\cdot\nabla_{\vett{x}}p^{(0)},\label{eq:puno} \end{align} the system of PDEs governing the macroscale problems (in homogenised domain $\Omega_h$) in a time increment is obtained as \begin{align} \displaystyle \nabla_{\vett{x}}\cdot \boldsymbol{\boldsymbol{\tens{\tau}}}_E&=\boldsymbol 0, &\textrm{in}\,\,\Omega_h \label{macroequi}\\ \boldsymbol{\boldsymbol{\tens{\tau}}}_E &\coloneqq \mathbb{\tilde{C}}\, {:}\, \vett \varepsilon^{(0)}-\tens{\tilde{\vett{\alpha}}}p^{(0)} &\textrm{in}\,\,\Omega_h \label{solidCons} \\ \dot{p}^{(0)}&=-M[\,\tens{\tilde{\vett{\alpha}}}\, {:}\, \dot{\vett \varepsilon}^{(0)} + \nabla_{\vett{x}}\cdot \vett{v}_{rf}] &\textrm{in}\,\,\Omega_h\label{eqMassC} \\ \vett{v}_{rf}&=-\boldsymbol{\tens{K}} \nabla_{\vett{x}}p^{(0)}. &\textrm{in}\,\,\Omega_h \label{eqDarcy} \intertext{where,} \boldsymbol{\boldsymbol{\tens{\tau}}}_E &= \langle \boldsymbol{\boldsymbol{\tens{\tau}}}^{(0)} \rangle - \phi p^{(0)} \boldsymbol{\boldsymbol{\tens{I}}}\\ \vett \varepsilon^{(0)}&= \xi_{\vett{x}}(\vett u^{(0)})\\ \vett{v}_{rf} &= \left\langle \vett{v}^{(0)}\right\rangle_f-\phi\dot{\vett{u}}^{(0)} \label{eq_vfr} \end{align} indicate effective stress, macroscopic strain tensor, and relative fluid velocity. This system of PDEs is characterised by some coefficients, namely, effective elasticity tensor, Biot coefficient and modulus, and hydraulic conductivity, that are defined, respectively, as \begin{align} \tilde{\mathbb{C}}\coloneqq &\left\langle \mathbb{C}+\mathbb{C}\mathbb{M}\right \rangle_s, \label{eq_TildeC} \\ \tens{\tilde{\vett{\alpha}}}\coloneqq &\phi \boldsymbol{\tens{I}} - \Tr{\left\langle \mathbb{M}\right\rangle_s}, \\ M\coloneqq & -\frac{1}{\left\langle \Tr{\boldsymbol{\tens{Q}} }\right\rangle_s}, \\ \boldsymbol{\tens{K}} \coloneqq &\left\langle \boldsymbol{\tens{W} } \right\rangle_f, \label{eq_HydraulicConductivity} \end{align} where, $\mathbb{C}$ and $\phi$ indicate the elasticity tensor of solid matrix and porosity (i.e. volume fraction of fluid phase), respectively. The fourth rank tensor $\mathbb{M}$ and the second rank tensors $\boldsymbol{\tens{Q}} $ and $\boldsymbol{\tens{W}} $ are the solutions of three systems of PDEs resulted from the multiscale procedure (for more details regarding the auxiliary cell problems please see Appendix \ref{Homo_app} and \cite{Hdehghani}). \paragraph{Remark.} \label{Qremark1} Although the solution of the auxiliary cell problems are obtained by solving a linear elastic type problem via FEM, considering Equation \eqref{eq:unoutside21}, the second rank tensor $\xi_{\vett{y}} (\vett{a})$ has the dimension $\left[\frac{L^2}{f_c}\right]$ meaning that Biot modulus $M$ has the same dimension as $\mathbb{C}$ which is correct according to Equation \eqref{eqMassC}. We highlight that, consequently, the vector $\vett a$ has the characteristic dimension $\left[\frac{dL^2}{f_c}\right]$ which agrees with the solid ansatz \eqref{ansatzsolid}. \subsection{Localisation} In this section, based on the asymptotic homogenisation, we develop an analytical localisation and properties rearrangement procedure in order to obtain the microscopic deformation due to the macroscale mechanical and hydraulic response. The Ansatz \eqref{ansatzsolid}-\eqref{eq:puno}, in fact, are the bridge between microscale and macroscale. As we mentioned earlier (and from Equation \eqref{eq:zsolidstress} in Appendix \ref{Homo_app}) $\vett{u}^{(0)}$ is locally-constant meaning that it can only cause rigid body motions which does not affect the microscale deformation gradient tensor. The same condition holds for $p^{(0)}$ (see Equations \eqref{eq:zfluido} and \eqref{eq:zfluidstress} in Appendix \ref{Homo_app}). Taking the microscopic spatial gradient of Equation \eqref{ansatzsolid} reads \begin{equation} \xi_{\vett{y}}(\vett{u}^{(1)}) = \xi_{\vett{y}}(\mathcal{A} \vett \varepsilon^{(0)}) + \xi_{\vett{y}}(\vett{a}p^{(0)}) \end{equation} which, taking into account that $\varepsilon^{(0)}$, and $p^{(0)}$ are microscale spatially independent (locally constant), reduces to \begin{align} \xi_{\vett{y}}(\vett{u}^{(1)}) = \xi_{\vett{y}}(\mathcal{A}) \vett \varepsilon^{(0)} + \xi_{\vett{y}}(\vett{a})p^{(0)} \label{eq_micro_disp} \end{align} Thus, taking the integral average from both sides yields \begin{equation} \langle\vett{\varepsilon}^{(1)} \rangle= \langle\mathbb{M}\rangle \vett{\varepsilon}^{(0)} + \langle\boldsymbol{\tens{Q}}\rangle p^{(0)} \label{eqMicroStrain} \end{equation} where, $ \langle\vett{\varepsilon}^{(1)}\rangle = \langle\xi_{\vett{y}} \vett{u}^{(1)}\rangle$ is exploited to update solid matrix Young's modulus and Poisson's ratio, as well as porosity. The coefficients of macroscale system of PDEs are computed based on the averaged values of stain/velocity components over their corresponding phase in the cell problem. Taking the integral average of Equation \eqref{eq:puno} we can write \begin{equation} \left\langle p^{(1)} \right\rangle_f = - \left\langle \vett{P} \right\rangle_f \cdot \phi \nabla_{\vett{x}}p^{(0)}, \end{equation} which, considering the uniqueness condition \eqref{equnique}, results in $ \left\langle p^{(1)} \right\rangle_f = 0$ and highlights that $p^{(1)}$ does not play a role in material properties update as they are considered in an average sense. Consequently, $\langle\vett{\varepsilon}^{(1)} \rangle$ is the only parameter that plays a role in this procedure so we call it \emph{microscopic strain tensor}. \subsubsection{Microscopic properties update} At this stage, we flash back to the increment notation $\Delta$ (so $\langle\vett{\varepsilon}^{(1)} \rangle$ becomes $\langle\Delta\vett{ \varepsilon}^{(1)} \rangle$) for clarification in updating the stiffness/tangent tensor of the solid phase based on the current strain tensor $\langle\vett{\varepsilon}^{(1)}_{t+\Delta t} \rangle$. The latter can be calculated via \begin{equation} \langle\vett{\varepsilon}^{(1)}_{t+\Delta t} \rangle = \langle\vett{\varepsilon}^{(1)}_{t} \rangle + \langle\Delta \vett{\varepsilon}^{(1)} \rangle. \end{equation} We make use of the Lagrangian-based formulation to update the solid matrix mechanical properties. For the sake of clarification, we highlight that this formulation is only used for determining the updated stiffness tensor and can be replaced by other methods. Assuming that the pore section remains circular (so one can consider that the average microscopic displacement gradient tensor is symmetric), the deformation gradient tensor $\boldsymbol{\tens F}$ and Green strain tensor $\boldsymbol{\tens E}$ can be calculated via \begin{align} \boldsymbol{\tens F} &= \langle\vett{\varepsilon}^{(1)}_{t+\Delta t} \rangle/(1-\phi) + \boldsymbol{\tens I} \\ \boldsymbol{\tens E} &= \frac{1}{2} \left(\boldsymbol{\tens F}^T \cdot \boldsymbol{\tens F} - \boldsymbol{\tens I} \right), \end{align} where $\boldsymbol{\tens I}$ is the second rank identity tensor. We highlight that $ \langle\vett{\varepsilon}^{(1)} \rangle$ is the integral average over the entire cell which could be transformed to the integral average over the solid matrix by using the coefficient $\frac{|\Omega|}{|\Omega_s|}$ which is equal to $\frac{1}{1-\phi}$ in the case of the assumed unit cube cell As the fluid part is assumed incompressible, then $\phi$, $V_s^i$, and $\phi_i$ are related b \begin{align} \phi &= 1 - (V_s^iJ) \label{phiupdate} \intertext{and} \phi &= 1- (1- \phi_i)J \label{phiupdate1}, \end{align} where, $J \coloneqq \det(\boldsymbol{\tens F})$ is the total solid matrix volume change at the point. $V_s^i$ and $\phi_i$ are, respectively, the solid and fluid phase volume fractions in the reference configuration. In this study, we consider isotropic compressible neo-Hookean strain energy function, which can be written as \cite{bonet_wood_2008} \begin{equation} W(I_1, J) = C_{10}(I_1 - 3) - 2C_{10} \ln(J) + \frac{1}{D_1} \ln(J)^2. \label{Neo_hookean} \end{equation} where $C_{10}$ and $D_1$ are material parameters. We determine the latter parameters based on initial Young's modulus $E_i$ and Poisson's ratio $\nu_i$ vi \begin{align} C_{10} &= \frac{E_i}{4(1+\nu_i)} \label{eqC10},\\ D_1&=\frac{6(1-2\nu_i)}{E_i} \label{eqD1}. \end{align} The components of the deformation dependent tangent matrix for this material are given by \begin{equation} C_{ijkl}^t= \frac{\partial W}{\partial{E_{ij}} \partial{E_{kl}}}. \label{eqTangent} \end{equation The fourth rank tensor $C_{ijkl}^t$ (note that the superscript $t$, here, does not indicate the time) is the deformation dependent tangent matrix calculated based on $\langle\vett{\varepsilon}^{(1)}_{t+\Delta t} \rangle$. We take this tensor as the current stiffness tensor for the next time increment. In other words, for each increment, we use the rearranged stiffness tensor based on the intermediate configuration. Having sufficiently small strain increments one can assume $C_{ijkl}^t \approx C_{ijkl}$, where $C_{ijkl}^t = \frac{\partial S_{ij}}{\partial E_{kl}}$ and $C_{ijkl} = \frac{ \Delta \sigma_{ij}}{ \Delta \varepsilon_{kl}}$ for the next increment. In this study, for the sake of simplicity, we assume that the solid matrix remains isotropic under the deformation so that its Young's modulus and Poisson's ratio can be updated by \begin{align} E&=\frac{{C}_{11}({C}_{11}+{C}_{12})-2{C}^2_{12}}{{C}_{11}+{C}_{12}}, \label{effectiveE} \\ \nu&=\frac{{C}_{12}}{{C}_{11}+{C}_{12}}. \label{effectiveNu} \end{align} \subsection{ANN application for localisation and homogenisation} In order to obtain the coefficients of the system of PDEs governing the macroscale mechanical and hydraulic response (e.g. Biot modulus and coefficient), the tensors $\mathbb M$, $\boldsymbol{\tens{Q}}$, and $\boldsymbol{\tens{K}}$ are required which could be determined by solving the auxiliary cell problems (defined via Equations \eqref{equnique}-\eqref{6solid21} in Appendix \ref{Homo_app}). On the other hand, $\mathbb M$ and $\boldsymbol{\tens{Q}}$ are necessary to carry out the localisation to update the solid matrix elasticity tensor and the cell porosity. We notice that due to the inhomogeneous/une- qual strain and pore pressure distribution in the space and time the mentioned cell properties are spatially and temporally dependent imposing the need to solve the cell problems at each spatial point and time increment which is not feasible (or too expensive). In order to address above mentioned issue, we employ Artificial Neural Networks (ANNs) \cite{Rosenblatt58theperceptron} in a similar way that is used in a former study of the current authors \cite{HDAZ2020}. However, here, instead of computing the coefficients of macroscale system of PDEs, we make use of the capacity of ANNs to calculate $\mathbb M$, $\boldsymbol{\tens{Q}}$, and $\boldsymbol{\tens{K}}$ so that we carry out the localisation procedure using the same outputs which means increasing the efficiency of the framework. This network can be written as a micro-macro scale transfer function i.e. \begin{equation} (\mathbb M, \boldsymbol{\tens{Q}}, \boldsymbol{\tens{K}}) = \mathit{ANN}(\mathbb C, \mu, \phi) \end{equation} which, assuming solid matrix isotropy and geometric rotational invariance with respect to three orthogonal axes, reduces to \cite{Hdehghani1, HdehghaniThesis} \begin{equation} (M_{11},M_{12},M_{44}, Q_{11}, K_{11}) = \mathit{ANN}(E, \nu, \mu, \phi) \end{equation} Considering that throughout the homogenisation procedure the parameters $E$ and $\mu$ are non-dimensionalised and the problems are linear elastic solid and newtonian fluid types one can reduce the input size of the ANNs to \begin{equation} (M_{11},M_{12},M_{44}, Q_{11}, K_{11}) = \mathit{ANN}(\nu, \phi) \end{equation} At this point we highlight that, according to Equation \eqref{eqMassC} and Remark \ref{Qremark1}, if the nondimensional solid matrix Young's modulus $E$ is different from its initial value (which is the case when including material remodelling), as it is excluded from ANN inputs, one should consider its effects on $Q_{11}$ multiplying it by $\frac{E_i}{E}$. In this study, we make use of five parallel networks each responsible for only one of the outputs in order to decrease the complexity while increase the accuracy of the training procedure. Figure \ref{fig_ANN_Parallel} schematically shows the configuration of this type of ANNs while, mathematically, the \emph{feed-forward} process which calculates the output based on the inputs through hidden layers can be expressed via \begin{align} z^{(i)}_k&=w^{(i)}_{kj}a^{(i-1)}_j+b^{(i)}_k \\ a^{(i)}_k&=ReLU(z^{(i)}_k) \end{align} where $a^{(i)}_k$ is the value of the $k$ -$th$ neurone in the $(i)$ -$th$ layer, $(i)\quad i \in(0,1,..,L)$ is the number of hidden layers, $k$ and $j$ indicate the number of the neurones in the $(i)$ -$th$ and $(i-1)$ -$th$ layers, respectively. The \emph{activation function} $ReLU(x) = \max (0,x)$ determines whether a neurone is active (adopts nonzero value). \begin{figure*} \centering \includegraphics[width=12cm]{ANN-Parallel} \caption{Schematic representation of feed-forward procedure via Parallel ANNs for upscaling, as well as downscaling, providing real-time solution to auxiliary cell problems. Note that each parallel network can have distinct number of neurones $n$ and hidden layers $L$. In this study, respectively from upper network to the bottom, the parameters are $n=50$ $L = 3$, $n=50$ $L=3$, $n=20$ $L=3$, $n=50$ $L=3$, and $n=10$ $L=3$. We note that, in total, the network size is even smaller than the one in \cite{HDAZ2020} but, although the relationship is more complex here, the results are more accurate.} \label{fig_ANN_Parallel} \end{figure*} At this stage, in order to achieve accurate outputs, we need to \emph{train} the networks which is viable, in the simplest case, by means of a training dataset consisting of sufficiently rich "exact" outputs each corresponding to distinct inputs. The later information, in this case, is provided by solving the auxiliary cell problems via FE method. We solve the cell problems for 50 different porosities $\phi$ covering the interval from 0.082 to 0.783 with fine steps and for each porosity 50 different Poisson's ratio $\nu$ are considered so that the role of both variables are well reflected. In the training procedure, the ANNs are fed with the same inputs ($\phi$ and $\nu$) as the one in the FE problems (the target ones). Then, based on the later target, the $L^2$ error is computed and an optimiser (in this case Adam optimiser is chosen \cite{kingma2014adam}) to minimise the difference between the ANNs output and the target values (more details are available widely in the literature, e.g. \cite{HDAZ2020, OISHI2017327, KIRCHDOERFER201681}). \subsection{Incremental nonlinear algorithm} In strongly coupled solid-fluid problems such as the poroelastic models, fine discretisation of both space and time is required even assuming infinitesimal deformations. The latter is achieved by means of the incremental solution via Finite Element Method in which the total time of the problem is divided into sufficiently small increments $\Delta t$ so that accurate numerical temporal integration/differentiation can be achieved. Here, the simple linear time integration scheme is used. The time discretisation described via Equation \eqref{timedisc} can be rewritten for the macroscopic poroelastic case as \begin{align} \vett u^{(0)}_{t+\Delta t} &= \vett u^{(0)}_t + \Delta \vett u^{(0)} \label{timediscu}\\ p^{(0)}_{t+\Delta t} &= p^{(0)}_{t} + \Delta p^{(0)} \label{timediscp} \end{align} In other words, the force vector and fluid relative velocity (which are history dependent) are calculated based on the intermediate configuration (configuration at time $t$), the time increment $\Delta t$, and displacement and pore pressure increment $\Delta \vett u^{(0)}$ and $\Delta p^{(0)}$, respectively. As the intermediate configuration and $\Delta t$ are fixed, the problem decreases to finding $\Delta \vett u^{(0)}$ and $\Delta p^{(0)}$ for which the infinitesimal deformation assumption is valid, thus, the employed mathematical homogenisation and localisation are applicable. Consider a vector of DOF increments that must yield balance of linear momentum and the mass conservation provided, respectively, by Equations \eqref{macroequi} and \eqref{eqMassC} which can be approximated using the weak formulation. The latter can be obtained by integrating mentioned equations with respect to the corresponding volume and multiplying them with arbitrary test functions. In this case, two test functions $\delta\vett{u}^{(0)}$ and $\delta p^{(0)}$ which represent the variation of the macro\-scale displacement and pore pressure are required. Using Equations \eqref{timediscu} and \eqref{timediscp} and applying the divergence theorem the weak form of the governing equations to be solved in each increment is \begin{align} {0} =& \int_{\partial\mathcal{B}} (\vett t_s^t + \Delta \vett t_s) \cdot \delta\vett{u}^{(0)} \, \mathrm{d}S - \int_{\mathcal{B}} (\boldsymbol{\tens{\tau}}_E^t + \Delta \boldsymbol{\tens{\tau}}_E) {:} \nabla_{\vett{x}} \, \delta\vett{u}^{(0)}\, \mathrm{d}V \nonumber \\ &+ \int_{\mathcal{B}} \frac{1}{M_t} \, (\dot p^{(0)}_t + \Delta \dot p^{(0)}) \, \delta p^{(0)} \, \mathrm{d} V + \int_{\partial\mathcal{ B}} (\vett{v}_{rf}^t + \Delta \vett{v}_{rf}) \cdot \vett n \, \delta p^{(0)} \, \mathrm{d}S \nonumber \\ &- \int_{\mathcal{B}} (\vett{v}_{rf}^t + \Delta \vett{v}_{rf}) \cdot \nabla_{\vett{x}} \, \delta p^{(0)} \, \mathrm{d} V + \int_{\mathcal{B}} \tilde{\boldsymbol{\alpha}}: (\dot{\vett \varepsilon}_t + \Delta \dot{\vett \varepsilon}) \, \delta p^{(0)} \, \mathrm{d} V \nonumber\\ &\quad \forall\;\delta\vett{u}^{(0)},\,\delta p^{(0)}. \label{eq:weak_continuity_Delta} \end{align} which $\,\begin{picture}(-1,1)(-1,-3)\circle*{3}\end{picture}\;\,^t$ or $\,\begin{picture}(-1,1)(-1,-3)\circle*{3}\end{picture}\;\,_t$ show the situation of $\,\begin{picture}(-1,1)(-1,-3)\circle*{3}\end{picture}\;\,$ at the intermediate configuration (at time $t$). We highlight that the first terms inside each integral are fixed and known which form the residuals of the intermediate configuration and could be factorised. However, in this study, in order to avoid the accumulation of the residuals (numerical errors), we consider them in the formulation and implementation \cite{HOFMEISTER}. Then substituting the constitutive equations \eqref{solidCons} and \eqref{eqDarcy} into \eqref{eq:weak_continuity_Delta} yields \begin{align} {0} =& \int_{\partial\mathcal{B}} (\vett t_s^t + \Delta \vett t_s) \cdot \delta\vett{u}^{(0)} \, \mathrm{d}S - \int_{\mathcal{B}} \left(\boldsymbol{\tens{\tau}}_E^t + (\mathbb{\tilde{C}}_t\, {:}\, \Delta \vett \varepsilon^{(0)}-\tens{\tilde{\vett{\alpha}}}_t \Delta p^{(0)})\right) {:} \nabla_{\vett{x}} \, \delta\vett{u}^{(0)}\, \mathrm{d}V \nonumber \\ &+ \int_{\mathcal{B}} \left(\frac{1}{M_{t-\Delta t}} \dot p^{(0)}_t + \frac{1}{M_t} \Delta \dot p^{(0)}\right) \, \delta p^{(0)} \, \mathrm{d} V + \int_{\partial\mathcal{ B}} (\vett{v}_{rf}^t -\boldsymbol{\tens{K}}_t \Delta \nabla_{\vett{x}}p^{(0)}) \cdot \vett n \, \delta p^{(0)} \, \mathrm{d}S \nonumber \\ &- \int_{\mathcal{B}} (\vett{v}_{rf}^t - \boldsymbol{\tens{K}}_t \Delta \nabla_{\vett{x}}p^{(0)}) \cdot \nabla_{\vett{x}} \, \delta p^{(0)} \, \mathrm{d} V + \int_{\mathcal{B}} \left(\tilde{\boldsymbol{\alpha}}_{t-\Delta t}: \dot{\vett \varepsilon}_t + \tilde{\boldsymbol{\alpha}}_t: \Delta \dot{\vett \varepsilon}\right) \, \delta p^{(0)} \, \mathrm{d} V \nonumber\\ &\quad \forall\;\delta\vett{u}^{(0)},\,\delta p^{(0)}. \label{eq:weak_continuity_Delta_1} \end{align} The coefficients $\mathbb{\tilde{C}}_t$, $\tens{\tilde{\vett{\alpha}}}_t$, $M_t$, and $\boldsymbol{\tens{K}}_t$ are the updated ones based on the updated microscopic material and geometrical parameters on the intermediate configuration. As in \cite{HDAZ2020}, free drainage can be introduced on a surface by enforcing \begin{equation} \vett{v}_{rf} = \boldsymbol{\tens{K}} \frac{\Delta p^{(0)}}{\Delta x} \quad \quad \textrm{on}\quad \quad S_{fd} \end{equation} as a part of the fourth term on the right hand side of Equation \eqref{eq:weak_continuity_Delta_1}. Here, $\Delta p$ and $\Delta x$ are the differences in pressure and distance between the surface of free drainage ($S_{fd}$) and the environment. If this condition is not introduced, an impermeable boundary condition is imposed. \subsection{Implementation verification} Due to the complexity of the methodology, the verification procedure is not a straight forward task. In this case, we divide the framework into simpler cases and verify them step by step. \begin{itemize} \item The upscaling at the beginning of each iteration is carried out via ANN which is verified by producing random test dataset and observing high accuracy shown in Figure \ref{fig_ANNtest} and as is done in \cite{HDAZ2020}. \begin{figure*} \centering \begin{subfigure}{5.8cm} \includegraphics[width = 5.8cm]{ANNalpha} \caption{The trained ANN predicts Biot coefficients corresponding to a wide range of porosities and solid matrix Poisson's ratio.\vspace{0.38cm}} \label{fig_ANNalpha} \end{subfigure} \quad \begin{subfigure}{5.8cm} \includegraphics[width = 5.8cm]{ANNK11} \caption{The hydraulic conductivity at different porosities, which is a source of nonlinearity in our methodology, can be approximated accurately in real-time via the trained ANN.} \label{fig_ANNK11} \end{subfigure} \caption{The trained ANN is tested, as usual, by means of a test dataset. The latter consists of the known results of the cell problems with properties different from the training dataset. Figures \ref{fig_ANNalpha} and \ref{fig_ANNK11} are two examples of this procedure.} \label{fig_ANNtest} \end{figure*} \item At each iteration a linear consolidation problem is solved. This part is verified agreeing Terzaghi's analytical solution for a column of poroelastic material as in \cite{Hdehghani1, HdehghaniThesis}. \item In order to verify the general incremental nonlinear analysis based on the specified strain energy function we perform a uniaxial test a linear elastic model, a typical nonlinear model, and the remodelling based incremental nonlinear analysis. The results are provided in Figure \ref{fig_Hyper_test}. \begin{figure} \centering \includegraphics[width=8cm]{P_Lmda} \caption{The incremental nonlinear analysis procedure is tested and verified via an elastic problem. The dashed line shows the Hookean linear elastic response, the solid line is the results of the Neo-Hookean nonlinear elastic material (Lagrangian formulation), and the curves in between are the results of the described incremental nonlinear analysis procedure with different increment numbers (N).} \label{fig_Hyper_test} \end{figure} \item Finally, in order to verify the integrity of the presented incremental nonlinear poroelastic framework we compare the maximum settlement of a column of poroelastic material under compression computed by the presented incremental nonlinear model with the linear one shown in Figure \ref{fig_MaxSettlement_T}. Furthermore, the results provided in the next section are also helpful for verification purposes. The associated model geometry, material properties, BCs etc. is the same as the first numerical example. \begin{figure} \includegraphics[width=8cm]{MaxSettlement-T} \centering \caption{The smaller settlement computed via our novel incremental nonlinear analysis for poroelastic media (dashed line) compared with the standard linear poroelasticity (solid line) is due to the strain stiffening imposed by the chosen material model which verifies the overall integrity of the model.} \label{fig_MaxSettlement_T} \end{figure} \end{itemize} \section{Numerical examples} \label{Sec_numericalExamples} We have, so far, dedicated our attention to developing an AI-assisted incremental computational method based on remodelling and asymptotic homogenisation/- localisation able to analyse nonlinear poroelastic problems. One major advantage of this method over the other methods in the field of nonlinear poroelasticity is that this framework, for the first time, considers the full macro and micro scale response/properties interdependencies. Hence it responds to several questions, in this study, including how are the microscale, as well as effective, properties affected by the macroscale mechanical and hydraulic response? Is an appropriate deviation from the overall linear Darcy's law for fluid flow in porous media (under finite deformation) enforced or fractional/exponential Darcy's law is needed? Why the preconditioning effects (residual strains), hysteresis response, and Mullins effects appear in poroelastic media such as brain tissue under cyclic loading? And, finally, how important is (or when is it important) to employ such a nonlinear method? The numerical examples performed in this section respond to the above-mentioned questions. \subsection{Uni-axial consolidation test} Let us start from a simple example which has been exploited many times through the history of fully or partially fluid-saturated porous media. In this test, a column of poroelastic material is compressed by a constant mechanical pressure with free drainage BC on top. The model is given sufficient time to approach the steady-state where the time-dependent variations become negligible. Although this test is very simple, it is helpful to gain a better insight and to observe basic facts during the consolidation procedure. Let us assume initial isotropic solid matrix Young's modulus and Poisson's ratio, respectively, equal to $E_i=15e{6} [Pa]$ and $\nu_i=0.3$ with initial porosity of $\phi_i = 0.3$. The mechanical pressure is assumed $P=0.2E_i$ and the fluid is free to drain only from the top of the column. Prior to load application, the length of the tube is $L=7.5 [m]$ and the width is $B=0.1 [m]$. Zero displacements in all directions are applied at the bottom and the body is able to move only in the axial direction on the sides (the width remains constant). The load is applied in a very short time but in several increments ensuring the applicability of linear response in each increment (similar to the conditions of the hyperelastic test performed as a verification tool). We, first, visualise the macroscale response together with microscale and effective properties in order to understand their interdependency. Figure \ref{fig_macro_response} shows the mac- roscale response of the model along the axial axis (length) at different times with Figure \ref{fig_SettlementNL_Z} and Figure \ref{fig_PPNL_Z} being the settlement and interstitial pore pressure, respectively. The study of the spatial profile of settlement (which is the major displacement component in this study) and pore pressure are important and the starting point to understand the profile of micro and macro scale properties during the analysis. Considering Equation \eqref{eqMicroStrain}, we notice that shortly after the load application, in the major part of the length, pore pressure profile is the variable enforcing the variation of the micro and macro scale properties, while the spatial gradient of displacement affects only the part near the top of the model. This is due to the sharp decrease in pore pressure which is a consequence of the free drainage BC at top. In fact, the profiles of the properties at short times, mostly, should follow the variations of a high pore pressure while at longer times they are dominated by the solid strain. \begin{figure*} \centering \begin{subfigure}{5.8cm} \includegraphics[width = 5.8cm]{SettlementNL-Z} \caption{Shortly after the load application the settlement varies nonlinearly along the depth while the degree of nonlinearity decreases at greater times until it reaches linear spatial profile at steady-state. \vspace{0.38cm}} \label{fig_SettlementNL_Z} \end{subfigure}\quad \begin{subfigure}{5.8cm} \includegraphics[width = 5.8cm]{PPNL-Z} \caption{Pore pressure starts from a high value with great spatial gradient near the free drainage surface after the loading. The pore pressure spatial gradient drives the fluid flow approaching zero with pore pressure equal to the ambient pressure.} \label{fig_PPNL_Z} \end{subfigure} \caption{A representation of the spatial profile of DOFs at different times which determines the variation of material properties.} \label{fig_macro_response} \end{figure*} \begin{figure*} \centering \begin{subfigure}{5.8cm} \includegraphics[width = 5.8cm]{PhiNL-Z} \caption{Although the final value of porosity at steady-state is determined by the solid phase deformation, its variation during the transient state is similar to the pore pressure spatial and temporal profile.} \label{fig_PhiNL_Z} \end{subfigure}\quad \begin{subfigure}{5.8cm} \includegraphics[width = 5.8cm]{ENL-Z} \caption{Similar to the porosity in Figure \ref{fig_PhiNL_Z} is the Solid Matrix Young's modulus profile.\vspace{0.38cm}\vspace{0.38cm}\vspace{0.38cm}} \label{fig_ENL_Z} \end{subfigure} \begin{subfigure}{5.8cm} \includegraphics[width = 5.8cm]{NuNL-Z} \caption{Solid Matrix Poisson's ratio shows inverse relationship with both pore pressure and settlement so it is below the initial value at all the times.\vspace{0.38cm}\vspace{0.38cm}} \label{fig_NuNL_Z} \end{subfigure}\quad \begin{subfigure}{5.8cm} \includegraphics[width = 5.8cm]{KbulkNL-Z} \caption{The matrix bulk modulus as a measure of compressibility depicts the expected behaviour. A contraction in solid matrix makes it less compressible while inverse effect is shown under the expansion.} \label{fig_KbulkNL_Z} \end{subfigure} \caption{The effect of macroscopic mechanical and hydraulic response on the spatial profile of microscopic properties at different times based on neo-Hookean material model.} \label{fig_micro_prop} \end{figure*} At small times, the porosity distribution shown in Figure \ref{fig_PhiNL_Z} (which is similar to the studies focused on the porosity variation such as \cite{Lee1981}) reveals sharp spatial variations starting from the values below the initial porosity at the top of the model due to the solid strain (which shows a volume increase in the solid matrix) reaching to the values greater than the initial one under the influence of pore pressure. The latter highlights the fact that under the positive pore pressure, due to external compressive load, the porosity increases, causing a contraction in the solid matrix. However, as time passes, the pore pressure decreases and the porosity profile follows the macroscale solid strain showing an obvious effect of consolidation, which means higher volume fraction of the solid matter. We highlight that the direction of a positive pore fluid hydrostatic pressure acting on the solid-fluid interface is from the centre of the pore towards the solid domain. The solid matrix material properties (Young's modulus and Poisson's ratio) are updated by the linearisation of the strain energy function given by Equations \eqref{Neo_hookean} and \eqref{eqTangent} based on the microscale kinematics. Figure \ref{fig_ENL_Z} shows that considering the porosity variation, the solid matrix Young's modulus is smaller than its initial value when there is an expansion in the solid domain showing strain-softening, while it is greater than the initial value in the area undergoing solid matrix contraction following the strain-hardening property of the neo-Hookean material model in compression. On the other hand, this profile is not the same in the case of Poisson's ratio shown in Figure \ref{fig_NuNL_Z}. In fact, the latter decreases in both contraction and expansion as it is lower than its initial value in all the model. As the profile of Poisson's ratio and Young's modulus are not varying in the same direction, in order to monitor the overall material compressibility we compute and provide the variation of the bulk modulus which includes both Young's modulus and Poisson's ratio and considered directly as a measure of the compressibility (and consequently strain-softening or hardening). Figure \ref{fig_KbulkNL_Z} reveals that the solid domain properties variation obeys the given neo-Hookean material model, which could be served as a verification of the FE implementation. \begin{figure*} \centering \begin{subfigure}{5.8cm} \includegraphics[width = 5.8cm]{EpNL-Z} \caption{The profile of the effective Young's modulus is a results of the mixed roles of porosity and solid matrix elastic properties. } \label{fig_EpNL_Z} \end{subfigure}\quad \begin{subfigure}{5.8cm} \includegraphics[width = 5.8cm]{MupNL-Z} \caption{The effective shear modulus varies similar to the effective Young's modulus which is also observed in \cite{Hdehghani}.\vspace{0.4cm } \label{fig_MupNL_Z} \end{subfigure} \begin{subfigure}{5.8cm} \includegraphics[width = 5.8cm]{NupNL-Z} \caption{The effective Poisson's ration ranges from values above the initial one to the values below the latter. } \label{fig_NupNL_Z} \end{subfigure}\quad \begin{subfigure}{5.8cm} \includegraphics[width = 5.8cm]{MNL-Z} \caption{Since the Biot modulus increases at increasing porosity and Solid matrix bulk modulus \cite{Hdehghani}, its variation is reasonable } \label{fig_MNL_Z} \end{subfigure} \begin{subfigure}{5.8cm} \includegraphics[width = 5.8cm]{K11NL-Z} \caption{Hydraulic conductivity depends only on porosity, although porosity depends on solid matrix deformation and, consequently, its properties.} \label{fig_K11NL_Z} \end{subfigure}\quad \begin{subfigure}{5.8cm} \includegraphics[width = 5.8cm]{AlphaNL-Z} \caption{Biot coefficient depends on solid matrix Poisson's ratio and porosity.\vspace{0.38cm}\vspace{0.38cm}} \label{fig_AlphaNL_Z} \end{subfigure} \caption{The profiles of the effective poroelastic properties calculated based on the macroscopic mechanical and hydraulic response. We highlight that, due to the nonlinear and asymptotic nature of upscaling, the shown results and conclusions for the problems might vary at different ranges of initial values.} \label{fig_macro_prop} \end{figure*} At this stage, exploiting the instant upscaling computation via ANN, the fourth rank tensor $\mathbb M$, the second rank tensor $\boldsymbol{\tens Q}$, and the hydraulic conductivity $\boldsymbol{\tens{K}}$ are obtained. The poroelastic properties $\mathbb{\tilde C}$, $\boldsymbol{\tilde{\tens{\alpha}}}$, $\boldsymbol{\tens{K}}$, and $M$ used in the homogenised model (see Equations \eqref{macroequi}-\eqref{eqDarcy}), are calculated via Equations \eqref{eq_TildeC}-\eqref{eq_HydraulicConductivity}. Furthermore, the effective Young's modulus, Poisson's ratio, and shear modulus are calculated based on cubic symmetric $\mathbb{\tilde C}$ via Equations \eqref{effectiveE}-\eqref{effectiveNu} replacing $C_{ij}$ by $\tilde C_{ij}$. Figure \ref{fig_macro_prop} shows the coefficients of macroscale system of equations that characterise the macroscale mechanical and hydraulic response of the homogenised model. The profile of effective Young's modulus demonstrated in Figure \ref{fig_EpNL_Z} is derived from displacement and pore pressure profiles and the resultant interaction of varying porosity and solid matrix stiffening/softening. In other words, as demonstrated in the literature \cite{Hdehghani, HdehghaniThesis}, increasing porosity at constant solid matrix properties results in a decrease in effective Young's modulus, while, considering remodelling of the solid material properties, it causes higher solid matrix Young's modulus. The latter, in turn, at constant porosity, increases the effective Young's modulus. A decrease in porosity has inverse effects. The result of this complex behaviour can only be determined using the provided AI-assisted multiscale framework. It worth to note that, despite the complex behaviour, effective solid matrix Young's modulus stands at a higher value than its initial value throughout the time and space in the problem. Effective shear modulus in Figure \ref{fig_MupNL_Z} has a similar complexity as effective Young's modulus although its profile is, somehow, smoother. In fact, similar to effective Young's modulus, it adopts values higher than the initial one resulting in strain stiffening. Effective Poisson's ratio provided in Figure \ref{fig_NupNL_Z} has a less complex profile as it depends only on the solid matrix Poisson's ratio and porosity. As an overall description, effective Poisson's ratio decreases, increasing the pore pressure and increases, due to the consolidation at the steady-state. The fluid drainage and consolidation procedure is considerably influenced by Biot modulus, Hydraulic conductivity, and Biot coefficient. Biot modulus determines the rate of change in pore pressure due to the macroscopic solid and fluid volume change. Figure \ref{fig_MNL_Z} shows that this parameter exhibits an increase due to the positive pore pressure while it decreases due to the negative macroscale solid strain. The considerable decrease in hydraulic conductivity and Biot coefficient in Figures \ref{fig_K11NL_Z} and \ref{fig_AlphaNL_Z} is due to the decreasing porosity at the top of the model as well as, in the case of Biot coefficient, the resultant change in the solid matrix material properties. We highlight that Biot coefficient acts as the coupling term between solid and fluid and hydraulic conductivity relates the spatial gradient of pore pressure to the fluid velocity relative to the solid displacement rate. The overall effects and importance of the variation in the effective poroelastic properties are reflected in the macroscopic response of the medium. As a comparison mean and to understand the influences of the interplay between macroscale response and macroscale/microscale properties, the settlement and pore pressure profiles of both linear Biot consolidation and the present method are provided in Figures \ref{fig_macroLNL_response}. The latter shows a higher polynomial degree of nonlinearity during the transient state while the difference between them is closer to a coefficient change approaching the steady-state. \begin{figure*} \centering \begin{subfigure}{5.8cm} \includegraphics[width = 5.8cm]{SettlementLNL-Z} \caption{The smaller settlement values calculated via the presented incremental nonlinear poroelasticity ("NL") agrees with the strain stiffening in compression imposed by the chosen material model (neo-Hookean).} \label{fig_SettlementLNL_Z} \end{subfigure}\quad \begin{subfigure}{5.8cm} \includegraphics[width = 5.8cm]{PPLNL-Z} \caption{The maximum pore pressure of "NL" case is slightly smaller than the the "L" case shortly after the loading while it is considerably greater than "L" case at longer times.\vspace{0.38cm}} \label{fig_PPLNL_Z} \end{subfigure} \begin{subfigure}{5.8cm} \includegraphics[width = 5.8cm]{Vrf_Z_LNL} \caption{Although the pore pressure of "NL" case is greater than "L" case the relative fluid velocity is slightly smaller than in the "L" case due to the considerable decrease in Hydraulic conductivity shown in Figure \ref{fig_K11NL_Z}.} \label{fig_Vrf_Z_LNL} \end{subfigure}\quad \begin{subfigure}{5.8cm} \includegraphics[width = 5.8cm]{divUrf_T} \caption{Agreeing with the maximum settlement (Figure \ref{fig_MaxSettlement_T}) and relative fluid velocity profile (Figure \ref{fig_Vrf_Z_LNL}), the fluid drainage in the "NL" case is smaller than the "L" case.\vspace{0.38cm}} \label{fig_divUrf_T} \end{subfigure} \caption{A comparison between the final response of the poroelastic medium calculated via the presented incremental nonlinear method (labeled as "NL") and the outcome of the linear poroelasticity (labeled as "L").} \label{fig_macroLNL_response} \end{figure*} Applying divergence theorem and having small time incrementation the fluid drainage in one time increment from unit section surface area could be computed via \begin{equation} \Delta \varepsilon_{vf} =(\vett v_{rf} \cdot \vett n) \Delta t. \end{equation} We can also compute the total fluid drainage until $m$ th increment via \begin{equation} \varepsilon_{vf}^m= \sum_{n=1}^m \Delta \varepsilon_{vf}^n \end{equation} Figure \ref{fig_divUrf_T} shows the normalised fluid drainage (w.r.t the maximum value of the linear case) Noteworthy is that all the mentioned properties in both scales are spatially dependent during the transient state while they become homogeneous at the steady-state. This highlights the fact that considering the described material response-properties interdependency is particularly more important in transient problems, e.g. cyclic loading. The effects of spatially dependent solid matrix material properties and porosity is thoroughly discussed in \cite{HDAZ2020}. \subsection{Deviation from Darcy's law} \begin{figure*} \centering \begin{subfigure}{5.8cm} \includegraphics[width = 5.8cm]{Vrf_DeltaP_Normal_PD} \caption{Although linear Darcy's law is used in each time increment, the overall hydraulic response calculated via the present incremental nonlinear method deviates from Darcy's law for linear poroelasticity, which is due to the hydraulic conductivity rearrangement after each increment.} \label{fig_Vrf_DeltaP_Normal_PD} \end{subfigure}\quad \begin{subfigure}{5.8cm} \includegraphics[width = 5.8cm]{DfD_Re_PD} \caption{The dimensionless deviation from the linear case (Darcy's law) is close to the quadratic deviation relationship proposed in the literature (e.g. \cite{Firdaouss1997, forchheimer1901}).\vspace{0.38cm}\vspace{0.38cm}\vspace{0.38cm}\vspace{0.38cm}} \label{fig_DfD_Re} \end{subfigure} \begin{subfigure}{5.8cm} \includegraphics[width = 5.8cm]{Dvrf_d_PD} \caption{For a fixed $\Delta P$ the average cell dimension nonlinearly affects the deviation from the Darcy's law.\vspace{0.38cm}} \label{fig_Dvrf_d_PD} \end{subfigure}\quad \begin{subfigure}{5.8cm} \includegraphics[width = 5.8cm]{Dvrf_nui_PD} \caption{The initial solid matrix Poisson's ratio is another important parameter affecting, nonlinearly, the deviations from Darcy's law. } \label{fig_Dvrf_nui} \end{subfigure} \caption{The deviations from overall linear Darcy's law (without remodelling) is due to poroelastic properties rearrangements. The observed agreement with different experimental results in the literature suggests that, using the present incremental nonlinear method (updating the hydraulic conductivity after each increment), there is no need to any correction to Darcy's law used inside each time increment.} \label{fig_Darcy_Ex} \end{figure*} The applicability of Darcy's law \cite{Darcy1856} into poroelastic problems in asymptotic range (at small Reynolds number) has been under debate since its publication. In \cite{Firdaouss1997} it is mentioned that the linear fit to the experimental data yields a negative pressure gradient when the flow rate is zero (e.g. $-\vett{\nabla} p = -0.745773 + 0.640324 q$ where $q$ is the flow rate) which means that there is a need to nonlinear corrections to Darcy's law. In this study, we model the Darcy's filtration experiment for a wide range of pressure differences ($\Delta P$) reaching to a maximum $\Delta P_{max} = E_i/4$ (where $E_i$ is the initial solid matrix Young's modulus). We calculate the relative fluid velocity when the simulation reaches the steady-state with criterion $\frac{v_{rf}^{in} - v_{rf}^{out}}{v_{rf}^{in}} \leq 1e{-3}$. We calculate the dimensionless deviation from Darcy's law via \begin{equation} y = \frac{v_{rf}- (K_i \Delta P) }{v_{rf,max}-( K_i \Delta P_{max})}, \label{Eqy} \end{equation} where $K_i$ and $\,\begin{picture}(-1,1)(-1,-3)\circle*{3}\end{picture}\;\,_{max}$ are the initial hydraulic conductivity and the maximum value of $\,\begin{picture}(-1,1)(-1,-3)\circle*{3}\end{picture}\;\,$ throughout the experiment, respectively. $\vett v_{rf}$ is the relative fluid velocity computed via the presented incremental nonlinear method in which the solid matrix properties and porosity (consequently hydraulic conductivity) are updated at each increment. Figure \ref{fig_Vrf_DeltaP_Normal_PD} shows that $\vett{v}_{rf}$ deviates considerably from the relative fluid velocity computed via Darcy's law (with the initial hydraulic conductivity) at pressure differences higher than $0.2\Delta P_{max}$ which agrees with the information provided in the literature (see, e.g. \cite{Clark1907}). The non-dimensional deviation value $y$ in Equation \eqref{Eqy} at different pressure drops is provided in Figure \ref{fig_DfD_Re}. The latter provides a mean to compare the results provided via the presented method with the linear and quadratic deviations (i.e. $\vett y = (\Delta P/\Delta P_{max})$ and $\vett y = (\Delta P/\Delta P_{max})^2$, respectively) which shows a great match with the quadratic one. The latter was also concluded in several studies such as in \cite{Firdaouss1997, forchheimer1901}. The average cell dimension $d=1e{-4}[m]$ was assumed so far. Figure \ref{fig_Dvrf_d_PD} reveals the fact that the average cell dimension plays an important role in the deviation from the linear Darcy's law highlighting that the more the average cell dimension, the more the deviation. One could also conclude that the more the cell average dimension, the less is $\Delta P$ limit at which the nonlinear model starts to, considerably, deviate from the linear. This can be seen in the definition of dimensional hydraulic conductivity which is directly proportional to $d^2$. The results provided in Figure \ref{fig_Dvrf_d_PD} is, qualitatively, in agreement with the effect of the soil grain size on deviation from Darcy's law provided by means of experimental results of \cite{Lopik2017}. From the microscale cell problems which are solved to determine the hydraulic conductivity and the dimensionalisation procedure we notice that, apart from average cell dimension and viscosity, porosity is another important parameter in this problem which is considerably affected by solid matrix Poisson's ratio ($\nu$) at a specific pore pressure distribution. The reason is that $\nu$ plays a major role in the solid matrix volume change leading to a change in porosity. Figure \ref{fig_Dvrf_nui} shows the influence of solid matrix Poisson's ratio on deviation from linear poroelasticity. From our observations, we conclude that considering the medium remodelling after each time increment, there is no need for the formerly proposed corrections to Darcy's law. \subsection{Uniaxial cyclic test on brain tissue} Detailed understanding of complex and important mechanical properties and response of brain tissues provides us with vital accurate predictions for the design of treatment protocols and assessment of risk. For this purpose, numerical analysis with appropriate models and accurate parameters can provide crucial information on the effects of external loads. The application of these external loads can be slow or fast and their effects can be short or long term. It is seen that the brain tissue mechanical response differs considerably in each case. The complexity of this tissue behaviour is well studied in \cite{Budday2020} introducing several challenges in this field, however, an appropriate poroelastic modelling of brain tissue was missing. The mechanical response of brain tissue under uniaxial experimental tests at free drainage from, respectively, sides and top of the model in \cite{FRANCESCHINI20062592} provides the first direct evidence of poroelastic behaviour of brain parenchyma which is proven by comparing the results of uniaxial consolidation experiment with Terzaghi's analytical solution. However, the numerical/analytical models for modelling the uniaxial cyclic experiments are not considered via poroelastic models. According to the latter study, under uniaxial cyclic loading, "brain tissue exhibits a peculiar nonlinear mechanical behaviour, exhibiting hysteresis, Mullins effect and residual strain, qualitatively similar to that observed in filled elastomers". In this subsection, we consider the application of the presented framework into the mechanical modelling of biological soft tissues which are typically considered as nonlinear problems. In order to focus on the role of the novel incremental nonlinear poroelastic methodology for mechanical response analysis of the medium, we, again, choose the simple neo-Hookean hyperelastic model for the solid matrix properties rearrangement. We show, for the first time, that the poroelastic nature of brain tissue considering microscopic properties rearrangement due to the macroscopic mechanical and hydraulic response plays a major role (if not the only reason) in the appearance of the mentioned peculiar behaviour. \begin{figure*} \centering \begin{subfigure}{5.8cm} \includegraphics[width = 5.8cm]{CyclicT108} \caption{The model response under cyclic uniaxial test for 20 cycles simulated via the present method. The hysteresis behaviour and preconditioning effects are similar to the experimental tests carried out in \cite{FRANCESCHINI20062592}. We consider this model as the reference case.} \label{fig_Cyclic_NL} \end{subfigure}\quad \begin{subfigure}{5.8cm} \includegraphics[width = 5.8cm]{CyclicT108Linear} \caption{The mechanical response based on the classical linear Biot poroelastic case (without remodelling). Although the hysteresis behaviour is observed the preconditioning effects are negligible. Furthermore, the shape of the cycle is different from the incremental nonlinear case.} \label{fig_Cyclic_L} \end{subfigure} \caption{A comparison between classical Biot poroelastic model and incremental nonlinear method. The model response shows that the latter is more accurate, particularly, in case of soft poroelastic tissues. We highlight that, in the nonlinear case, the material model of the solid phase of the cell is assumed neo-Hookean with initial elastic properties adopted from the linear one.} \label{fig_Cyclic_NL_L} \end{figure*} \begin{figure*} \centering \begin{subfigure}{5.8cm} \includegraphics[width = 5.8cm]{CyclicT54} \caption{In case of doubled loading rate, the hysteresis area is smaller than the "reference case" (the one in Figure \ref{fig_Cyclic_NL}) while the preconditioning remains more or less similar.} \label{fig_CyclicT54} \end{subfigure}\quad \begin{subfigure}{5.8cm} \includegraphics[width = 5.8cm]{CyclicT27} \caption{Decreasing the loading time to one fourth of the reference case, the preconditioning magnitude starts decreasing and the hysteresis area continues to drop.\vspace{0.38cm}} \label{fig_CyclicT27} \end{subfigure} \begin{subfigure}{5.8cm} \includegraphics[width = 5.8cm]{CyclicT13} \caption{A slight strain-hardening appears more evidently which is expected to be a consequence of insufficient drainage time for the model in which the model approaches to a less compressible elastic type response.\vspace{0.38cm}\vspace{0.38cm}} \label{fig_CyclicT13} \end{subfigure}\quad \begin{subfigure}{5.8cm} \includegraphics[width = 5.8cm]{CyclicT03} \caption{At almost instant loading, there is no hysteresis and preconditioning in the model response as the fluid is trapped inside the solid matrix due to insufficient time. In fact, the material properties is similar to an elastic one with undrained elasticity tensor (see Equation \eqref{Eq_undrained}.)\vspace{0.38cm}} \label{fig_CyclicT3} \end{subfigure} \caption{The effects of increasing loading speed on the model response showing the feasibility of the present method to overcome a source of ambiguity (analysis time) in understanding the brain tissue's mechanical behaviour.} \label{fig_Cyclic_Stimes} \end{figure*} First, one should pay attention to the characteristic values of the parameters of this application. For example, due to small dimension of the tissue, it is more convenient if the macroscale average length scale is millimetres ($L = 10^{-3}[m]$) so that one can also avoid numerical errors due to very small dimensions of the elements. One can perform the calculations based on dimensionless parameters calculated via \eqref{nondim2} in order to avoid ambiguity. The dynamic viscosity of cerebrospinal fluid CSF \cite{CSFviscosity} is assumed as the characteristic one $\mu_c = 10^{-3}[Pa.s]$. Average microscopic periodic cell dimension $d = 20^{-6}[m]$ is chosen from the literature \cite{WANG20092371,KimECMsize, Baker2009} and unit force $F_c = 10^{-3}[N]$ is adopted to reach an appropriate unit pressure. For example, characteristic time and pressure are $t_c = 1[s]$ and $P_c = 10^{3} [Pa]$, respectively, and, assuming solid matrix initial Poisson's ratio $\nu_i = 0.3[-]$ and Young's modulus $E_i = 13.5\times 10^{3} [Pa]$, the dimensionless initial Young's modulus is $E'_i = 13.5[-]$ which is the same as the one assumed in ANN training. We first make use of the conventional linear poroelastic model, providing a comparison mean to understand to what extend the provided incremental nonlinear framework is important in mechanical modelling of brain tissue. Figure \ref{fig_Cyclic_L} shows that, provided appropriate parameters, even the linear poroelastic model shows the hysteresis behaviour (indicating the energy dissipation) of the tissue without introducing viscoelasticity, damage, etc. The preconditioning effect, however, is considerably smaller than the empirically captured values in \cite{FRANCESCHINI20062592}. We highlight that the cycle time $T_{cycle} =108[s]$ is chosen to introduce, more or less, the same loading conditions as in the latter study. Employing the presented incremental method for this brain tissue deformation example, a considerable difference is observed. The mechanical response of the model shown in Figure \ref{fig_Cyclic_NL} exhibits the effect of preconditioning to a larger extent which agrees with the experimental results provided in \cite{FRANCESCHINI20062592} for brain tissue (and in \cite{MillerPreconditioning,QuinnPrecon} for fibrous connective tissues such as ligament) highlighting the importance of considering remodelling and micro-macro interaction of nonlinear poroelastic media under finite deformation. The preconditioning effects causes the cycles to move to the right hand side of the plot which means that the deformed length of the model increases after each cycle which was again observed in the latter study \cite{FRANCESCHINI20062592}. Furthermore, the hysteresis behaviour is slightly different from the linear poroelastic one and is closer to the experimentally observed ones. \begin{figure*} \centering \begin{subfigure}{5.8cm} \includegraphics[width = 5.8cm]{CyclicT216} \caption{Extending the hysteresis area and decreasing the number of middle cycles (the cycles needed to reach the final cycle state) is observed as the first effects of a greater loading time than the reference one (Figure \ref{fig_Cyclic_NL}).\vspace{0.38cm}\vspace{0.38cm}} \label{fig_CyclicT216} \end{subfigure}\quad \begin{subfigure}{5.8cm} \includegraphics[width = 5.8cm]{CyclicT1080} \caption{Increasing the cycle time to $1080[s]$ the final state is reached at the second cycle, however, the hysteresis area is considerably greater than the case in Figure \ref{fig_CyclicT216}. Furthermore, a similar stretch value to the reference case is obtained at smaller loads (see the values in vertical direction).} \label{fig_CyclicT1080} \end{subfigure} \begin{subfigure}{5.8cm} \includegraphics[width = 5.8cm]{CyclicT10800} \caption{At $T_{cycle}=10800[s]$ the preconditioning effects is negligible and hysteresis area is considerably smaller approaching to an elastic-like mechanical response. Moreover, the model response is softer (more compressible) than the previous cases (see the values in vertical direction).\vspace{0.38cm}} \label{fig_CyclicT10800} \end{subfigure}\quad \begin{subfigure}{5.8cm} \includegraphics[width = 5.8cm]{CyclicT1080000} \caption{At infinitesimal strain rates the fluid has the sufficient time to drain without considerable interactions with the solid phase. The overall mechanical model response is elastic-like with drained elasticity tensor ($\tilde{\mathbb C}$) which could be considerably more compressible than the undrained one.} \label{fig_CyclicT108000} \end{subfigure} \caption{The effects of increasing $T_{cycle}$. We highlight that all other properties are the same as the reference case shown in Figure \ref{fig_Cyclic_NL}.} \label{fig_Cyclic_times} \end{figure*} After the first cycle, there is a considerable \textit{cycle residual strain} (the gap between the beginning of the loading and the end of the unloading path in one cycle) which is related to the fluid absorption due to the model deformation. As the fluid flow inside the medium requires time, we expect that increasing the loading rate the cycle residual strain and consequently, the preconditioning effects decreases and the medium responds similarly to an elastic one. Figure \ref{fig_Cyclic_Stimes} highlights that not only the preconditioning effects but also the hysteresis behaviour are due to fluid flow and its interaction with the solid phase. Furthermore, it is shown that by increasing the loading rate, the minimum stretch decreases, which means a decrease in the medium compressibility. In this case, the incompressible interstitial fluid does not percolate through the porous medium due to the insufficient time in which case static fluid phase filling the pores could be assumed (undrained case). Considering Equations \eqref{solidCons} and \eqref{eqMassC} the model deformation follows the undrained elasticity tensor (for more details see \cite{Hdehghani, growing, burrigekeller}) \begin{equation} \tilde{\mathbb C} + M \tilde{\alpha} \tilde{\alpha}, \label{Eq_undrained} \end{equation} which expected to be far less compressible than the drained medium \cite{Hdehghani}. On the other hand, decreasing the strain rate, the given time for a small deformation increases which, in turn, decreases the resultant pore pressure driven by the solid deformation (see Equation \eqref{eqMassC}) approaching the overall material response to the undrained case. The latter is expected to be considerably more compressible and softer as without Equation \eqref{eqMassC} the pores could be considered as void spaces. Figure \ref{fig_Cyclic_times} shows that increasing the cycle time, the dissipated energy due to the hysteresis response as well as the preconditioning effects and residual strains increases up to a maximum point (see Figures \ref{fig_CyclicT216} and \ref{fig_CyclicT1080}) from which they decrease approaching zero at very long times shown in Figures \ref{fig_CyclicT10800} and \ref{fig_CyclicT108000}. The latter shows the undrained response of the porous media under cyclic loading which is, compared with Figure \ref{fig_CyclicT3}, considerably softer and more compressible (note the difference in the applied load). In the experiments carried out in \cite{FRANCESCHINI20062592} a behaviour similar to what is called Mullins effect \cite{Mullins} together with residual strain is observed. In \cite{FRANCESCHINI20062592} this behaviour is modelled by means of the pseudo-elastic model provided in \cite{ogden_pseudoelastic} neglecting the solid-fluid interaction, multiscale nature of the problem, and the observed residual strain. Figure \ref{fig_Mullins} shows that the present modelling methodology results in a macroscopic mechanical response similar to what is observed in the experiments, however, based on simple compressible neo-Hookean material employed in the present multiscale and multiphysics methodology. In this figure, the model deformation under both cyclic and monotonic loading is provided so that the dependence of the model response on the previous cycles or the deformation history is clear. As there is no term in the material model accounting for the Mullins effect, we conclude that this type of response is due to the nonlinear poroelastic nature of the medium. Furthermore, due to the chosen material model which imposes strain-softening in tensile deformation and strain-hardening is compressive one, as expected, a greater residual strain is captured under tensile loading (shown in Figure \ref{fig_Mullins_tensile}) compared with the compression test (shown in \ref{fig_Mullins_compressive}). The authors highlight that, although several key features and aspects of the brain tissue response to the external loads are addressed, the accurate modelling and simulation of this complex tissue requires further study and effort focused, for example, on the solid phase material model as well as the cell geometry properties. \begin{figure*} \centering \begin{subfigure}{5.8cm} \includegraphics[width = 5.8cm]{Mullins_tensile} \caption{Comparison between monotonic and cyclic loading in a tensile test.} \label{fig_Mullins_tensile} \end{subfigure}\quad \begin{subfigure}{5.8cm} \includegraphics[width = 5.8cm]{Mullins_compressive} \caption{Comparison between monotonic and cyclic loading in a compressive test.} \label{fig_Mullins_compressive} \end{subfigure} \caption{The mechanical response of the poroelastic models with the same properties as in the reference case shows Mullins-like effects with preconditioning (residual strain).} \label{fig_Mullins} \end{figure*} \section{Conclusions and future work} \label{Sec_conclusions} In this study, ANNs, a standard multiscale approach (asymptotic or two-scale homogenisation), and an incremental FE analysis framework are integrated to provide a novel and robust computational method for analysis of multiphysics and multiscale poroelastic problems under global deformations that are large enough to invalidate the assumptions of infinitesimal strain theory. This framework considers the full interdependency between the homogenised hydraulic and mechanical response and microscopic (and, consequently, macroscopic) properties rearrangement (multiscale remodelling) which encompasses different sources of nonlinearity, namely, solid-fluid interaction as well as the nonlinear governing equations (due to updating effective coefficients). The whole procedure is based on non-dimesionalised variables and properties so that it is applicable in a wide range of problems in different scales such as soil and biomechanics. Applied into the soil mechanics (in the sense of the characteristic values), Terzaghi's consolidation and Dar- cy's fluid filtration tests are reconstructed numerically under finite deformation providing detailed information on the combined effects of the solid deformation and pore pressure on the microscopic and effective properties of the medium, as well as its overall response. Agreeing with the experimental results in the literature, for example, the fluid filtration example shows that, employing the presented method, there is no need to the corrections to Darcy's law for fluid flow in poroelastic media. Furthermore, the average cell dimension (grain size) and initial Poisson's ratio nonlinearly increase and decrease the deviation from Darcy's law, respectively. In Terzaghi's test, the distribution (in space and time) of the mechanical and hydraulic response, as well as microscopic and effective properties are monitored until the steady-state is reached. In general, we observe spatially and time-dependent distribution of the properties and variables highlighting the complexity of the problem. Among many other results, we show that, in this problem, the porosity of the medium under mechanical pressure increases instantly after loading (due to the resultant pore pressure) while it decreases during the transient state, as a consequence of the consolidation and fluid drainage, reaching a constant value smaller than the initial one at the steady-state. Moreover, the captured dependency of the effective properties on the changes in microscopic properties (porosity and solid matrix material properties) due to the solid matrix contraction/expansion and its effects on the overall response of the media highlights the importance of employing the presented method. Furthermore, we simulate a uniaxial cyclic test on the brain tissue as a poroelastic medium (which is known for its complex and peculiar mechanical response). The test is characterised to mimic the conditions of the experimental tests so that we can evaluate the results. The hysteresis and preconditioning effects together with a behaviour similar to the observed response in Mullins tests are captured for the first time only based on the poroelastic nature of the tissue. The effects of the loading/deformation rate is thoroughly studied as an important source of ambiguity in brain tissue properties identification. Although the numerical results agree with the experimental ones in several aspects, more effort is required for accurate modelling of brain tissue which can be the subject of a future study. Apart from the development of the mentioned method, several aspects of fundamental issues in the context of poroelasticity has been addressed for the first time in this study. However, there are more challenges to be overcome in the future studies which can be divided into three directions. Firstly, an application-specific and robust nonlinear material law for the solid matrix, able to accurately describe the complex poroelastic media such as brain tissue, is to be chosen/discovered. This, in turn, requires a robust and specific framework for microscopic model parameter identification using AI (similar to poroelastography but considering solid matrix properties). Secondly, the future works could be oriented to remove some simplifying assumptions such as pore section and solid matrix material, respectively, remaining circular and isotropic under the deformation during the analysis etc. Last but not least, based on the observations using the presented computational framework, phenomenological homogenised material models can be adopted/introduced considering the mentioned interdependencies and interactions between the micro and macro properties and responses. In other words, as soft poroelastic tissues may not be easily available, one can partially replace the experiments with the numerical simulations using the present method to gain a deep insight of the required elements in the material models for poroelastic media. \section*{Acknowledgements} We acknowledge the support of this research work via the framework of DTU DRIVEN, funded by the Luxembourg National Research Fund (PRIDE17/12252781), and the project CDE-HUB, funded by the Luxembourg Ministry of Economy (FEDER 2018-04-024). The authors would like to thank Prof. Davide Bigoni for providing additional information about experimental test data published in \cite{FRANCESCHINI20062592}.
{'timestamp': '2021-03-12T02:18:26', 'yymm': '2103', 'arxiv_id': '2103.06569', 'language': 'en', 'url': 'https://arxiv.org/abs/2103.06569'}
arxiv
\section{$\beta$-CROWN for Complete and Incomplete Verification} \vspace{-5pt} \label{sec:algorithm} In this section, we first give intuitions on how $\beta$-CROWN handles neuron split constraints without costly LP solvers. Then we formally state the main theorem of $\beta$-CROWN from both primal and dual spaces, and discuss how to tighten the bounds using free parameters $\alphavar$, $\betavar$. Lastly, we propose $\beta$-CROWN BaB, a complete verifier that is also a strong incomplete verifier when stopped early. \vspace{-5pt} \subsection{$\beta$-CROWN: Linear Bound Propagation with Neuron Split Constraints} \label{sec:beta_crown_primal} \vspace{-5pt} The NN verification problem under neuron split constraints can be seen as an optimization problem: % \begin{equation} \min_{x \in {\mathcal{C}}, z \in {\mathcal{Z}}} f(x). \label{eq:constrained_obj} \end{equation} Bound propagation methods like CROWN can give a relatively tight lower bound for $\min_{x \in {\mathcal{C}}} f(x)$ but they \emph{cannot handle the neuron split constraints} $z \in {\mathcal{Z}}$. Before we present our main theorem, we first show the intuition on how to apply split constraints to the bound propagation process. To encode the neuron splits, we first define diagonal matrix $\S{i}~\in~\mathbb{R}^{d_i \times d_i}$ in~\eqref{eq:S} where $i \in [1, \cdots L-1], j \in [1, \cdots, d_i]$ are indices of layers and neurons, respectively: \begin{equation} \S{i}{j,j} = -1 (\text{if split }\z{i}{j} \geq 0);\quad\S{i}{j,j} = +1 (\text{if split }\z{i}{j} < 0);\quad\S{i}{j,j} = 0 (\text{if no split }\z{i}{j}) \label{eq:S} \end{equation} We start from the last layer and derive linear bounds for each intermediate layer $\z{i}$ and $\hz{i}$ with both constraints $x \in {\mathcal{C}}$ and $\z \in \setz$. We also assume that pre-ReLU bounds $\bl{i} \leq \z{i} \leq \bu{i}$ for each layer $i$ are available (see discussions in Sec.~\ref{sec:optimization_variable} on these intermediate layer bounds). We initially have: \begin{equation} \begin{split} \min_{\substack{x \in {\mathcal{C}}, z \in \setz}} f(x) = \min_{\substack{x \in {\mathcal{C}}, z \in \setz}} \W{L} \hz{L-1} + \bias{L}. \end{split} \label{eq:layer_L_1} \end{equation} Since $\hz{L-1}=\mathrm{ReLU}(\z{L-1})$, we can apply Lemma~\ref{lemma:relax_single} to relax the ReLU neuron at layer $L-1$, and obtain a linear lower bound for $f(x)$ w.r.t.\ $\z{L-1}$ (we omit all constant terms to avoid clutter): \[ \begin{split}\small \min_{\substack{x \in {\mathcal{C}}, z \in \setz}} f(x) & \geq \min_{\substack{x \in {\mathcal{C}}, z \in \setz}} \W{L} \D{L-1} \z{L-1} + \text{const}. \end{split} \] To enforce the split neurons at layer $L-1$, we use a Lagrange function with $\betavar{L-1}^\top \S{L-1}$ multiplied on $\z{L-1}$: \begin{equation}\small \begin{split} \min_{\substack{x \in {\mathcal{C}}, z \in \setz}} &f(x) \geq \min_{\substack{x \in {\mathcal{C}} \\ \tz{L-2} \in \tsetz{L-2}}} \max_{\betavar{L-1} \geq 0} \W{L} \D{L-1} \z{L-1} + {\betavar{L-1}}^\top \S{L-1} \z{L-1} + \text{const} \\ &\geq \max_{\betavar{L-1} \geq 0} \min_{\substack{x \in {\mathcal{C}} \\ \tz{L-2} \in \tsetz{L-2}}} \Big (\W{L} \D{L-1} + {\betavar{L-1}}^\top \S{L-1} \Big ) \z{L-1} + \text{const} \label{eq:layer_activation} \end{split} \end{equation} The first inequality is due to the definition of the Lagrange function: we remove the constraint $\z{L-1} \in \setz{L-1}$ and use a multiplier to replace this constraint. The second inequality is due to weak duality. Due to the design of $\S{L-1}$, neuron split $\z{L-1}{j} \geq 0$ has a negative multiplier $- \betavar{L-1}{j}$ and split $\z{L-1}{j} < 0$ has a positive multiplier $ \betavar{L-1}{j}$. Any $\betavar{L-1} \geq 0$ yields a lower bound for the constrained optimization problem. Then we substitute $\z{L-1}$ with $\W{L-1} \hz{L-2} + \bias{L-1}$ for next layer: \begin{equation}\small \min_{\substack{x \in {\mathcal{C}}, z \in \setz}} f(x) \geq \max_{\betavar{L-1} \geq 0} \min_{\substack{x \in {\mathcal{C}} \\ \tz{L-2} \in \tsetz{L-2}}} \Big ( \W{L} \D{L-1} + {\betavar{L-1}}^\top \S{L-1} \Big ) \W{L-1} \hz{L-2} + \text{const} \label{eq:layer_L_2} \end{equation} We define a matrix $\A{i}$ to represent the linear relationship between $f(x)$ and $\hz{i}$, where $\A{L-1}=\W{L}$ according to~\eqref{eq:layer_L_1} and $\A{L-2}=(\A{L-1} \D{L-1} + {\betavar{L-1}}^\top \S{L-1}) \W{L-1}$ by~\eqref{eq:layer_L_2}. Considering 1-dimension output $f(x)$, $\A{i}$ has only 1 row. With $\A{L-2}$, \eqref{eq:layer_L_2} becomes: \[\small \min_{\substack{x \in {\mathcal{C}}, z \in \setz}} f(x) \geq \max_{\betavar{L-1} \geq 0} \min_{\substack{x \in {\mathcal{C}} \\ \tz{L-2} \in \tsetz{L-2}}} \A{L-2} \hz{L-2} + \text{const}, \] which is in a form similar to~\eqref{eq:layer_L_1} except for the outer maximization over $\betavar{L-1}$. This allows the back-substitution process (\eqref{eq:layer_L_1}, \eqref{eq:layer_activation}, and~\eqref{eq:layer_L_2}) to continue. In each step, we swap $\max$ and $\min$ as in~\eqref{eq:layer_activation}, so every maximization over $\betavar{i}$ is outside of $\min_{x \in {\mathcal{C}}}$. Eventually, we have: \[\small \min_{\substack{x \in {\mathcal{C}}, z \in \setz}} f(x) \geq \max_{\betavar \geq 0} \min_{x \in {\mathcal{C}}} \A{0} x + \text{const}, \] where $\betavar := \left [\betavar{1}^\top \ \betavar{2}^\top \ \cdots \ \betavar{L-1}^\top \right ]^\top$ concatenates all $\betavar{i}$ vectors. Following the above idea, we present the main theorem in Theorem~\ref{thm:beta_CROWN} (proof is given in Appendix~\ref{ref:app_proof}). \begin{theorem}[$\beta$-CROWN bound] \label{thm:beta_CROWN} Given an $L$-layer NN $f(x): \mathbb{R}^{d_0} \rightarrow \mathbb{R}$ with weights $\W{i}$, biases $\bias{i}$, pre-ReLU bounds $\bl{i} \leq \z{i} \leq \bu{i}$ ($1 \leq i \leq L$), input bounds ${\mathcal{C}}$, split constraints $\setz$. We have: \begin{equation} \min_{\substack{x \in {\mathcal{C}}, z \in \setz}} f(x) \geq \max_{\betavar \geq 0} \min_{x \in {\mathcal{C}}} (\aaa + \bbb \betavar)^\top x + \ccc^\top \betavar + \constc, \label{eq:beta_crown_linear} \end{equation} where $\aaa\in \mathbb{R}^{d_0}$,$\bbb \in \mathbb{R}^{d_0 \times (\sum_{i=1}^{L-1} {d_i})}$,$\ccc \in \mathbb{R}^{\sum_{i=1}^{L-1} d_i}$ and $c\in \mathbb{R}$ are functions of $\W{i}$, $\bias{i}$, $\bl{i}$, $\bu{i}$. \end{theorem} Detailed formulations for $\aaa$, $\bbb$, $\ccc$ and $c$ are given in Appendix~\ref{ref:app_proof}. Theorem~\ref{thm:beta_CROWN} shows that when neuron split constraints exist, $f(x)$ can still be bounded by a linear equation containing optimizable multipliers $\betavar$. Observing~\eqref{eq:layer_activation}, the main difference between CROWN and $\beta$-CROWN lies in the relaxation of each $\mathrm{ReLU}$ layer, where we need an extra term $\betavar{i}^\top \S{i}$ in the linear relationship matrix (for example, $\W{L}\D{L-1}$ in~\eqref{eq:layer_activation}) between $f(x)$ and $\z{i}$ to enforce neuron split constraints. This extra term in every $\mathrm{ReLU}$ layer yields $\bbb$ and $\ccc$ in~\eqref{eq:beta_crown_linear} after bound propagations. To solve the optimization problem in~\eqref{eq:beta_crown_linear}, we note that in the $\ell_p$ norm robustness setting (${\mathcal{C}} = \{ x \ | \ \| x - x_0 \|_p \leq \epsilon \}$), the inner minimization has a closed solution: \begin{equation} \min_{\substack{x \in {\mathcal{C}}, z \in \setz}} f(x) \geq \max_{\betavar \geq 0} - \|\aaa + \bbb \betavar\|_q \epsilon + (\bbb^\top x_0 + \ccc)^\top \betavar + \aaa^\top x_0 + c := \max_{\betavar \geq 0} g(\betavar) \label{eq:beta_crown_lp} \end{equation} where $\frac{1}{p}+\frac{1}{q}=1$. The maximization is concave in $\betavar$ ($q \geq 1$), so we can simply optimize it using projected (super)gradient ascent with gradients from an automatic differentiation library. Since any $\betavar \geq 0$ yields a valid lower bound for $\min_{\substack{x \in {\mathcal{C}}, z \in \setz}} f(x)$, convergence is not necessary to guarantee soundness. $\beta$-CROWN is efficient - it has the same asymptotic complexity as CROWN when $\betavar$ is fixed. When $\betavar=0$, $\beta$-CROWN yields the same results as CROWN; however the additional optimizable $\betavar$ allows us to maximize and tighten the lower bound due to neuron split constraints. We define $\alphavar{i} \in \mathbb{R}^{d_i}$ for free variables associated with unstable ReLU neurons in Lemma~\ref{lemma:relax_single} for layer $i$ and define all free variables $\alphavar = \{ \alphavar{1} \cdots \alphavar{L-1} \}$. Since any $0 \leq \alphavar{i}{j} \leq 1$ yields a valid bound, we can optimize it to tighten the bound, similarly as done in~\citep{xu2020fast}. Formally, we rewrite~\eqref{eq:beta_crown_lp} with $\alphavar$ explicitly: \begin{equation} \min_{\substack{x \in {\mathcal{C}}, z \in \setz}} f(x) \geq \max_{\substack{0 \leq \alphavar \leq 1, \ \betavar \geq 0}} g(\alphavar, \betavar). \label{eq:opt_alpha_beta} \end{equation} \subsection{Connections to the Dual Problem} \label{sec:algorithm_dual} In this subsection, we show that $\beta$-CROWN can also be derived from a dual LP problem. Based on~\eqref{eq:nn_verify} and linear relaxations in Section~\ref{ref:verification_problem}, we first construct an LP problem for $\ell_\infty$ robustness verification in~\eqref{eq:lp_verify_split} where $i \in \{1, \cdots, L-1\}$. \begin{equation} \begin{split} &\hspace{15em}\min \ f(x) := \z{L}(x) \quad \text{s.t. } \\ &\text{Network and Input Bounds: } \z{i} = \W{i}\hz{i-1} + \bias{i}; \hz{0} \geq x_0 - \epsilon; \hz{0} \leq x_0 + \epsilon;\\ &\text{Stable ReLUs: } \hz{i}{j} = \z{i}{j} \ (\text{if }\bl{i}{j} \geq 0); \hz{i}{j} = 0 \ (\text{if }\bu{i}{j} \leq 0); \\ &\text{Unstable: } \hz{i}{j} \geq 0, \hz{i}{j} \geq \z{i}{j},\hz{i}{j} \leq \textstyle\frac{\bu{i}{j}}{\bu{i}{j} - \bl{i}{j}} \left ( \z{i}{j} - \bl{i}{j} \right ) (\text{if }\bl{i}{j} < 0 < \bu{i}{j}, j \notin \setzp{i} \cup \setzn{i})\\ &\text{Neuron Split Constraints: } \hz{i}{j} = \z{i}{j}, \z{i}{j} \geq 0 \ (\text{if }j \in \setzp{i}); \hz{i}{j} = 0, \z{i}{j} < 0 \ (\text{if } j \in \setzn{i}) \\ \end{split} \label{eq:lp_verify_split} \end{equation} Compared to the formulation in~\citep{wong2018provable}, we have neuron split constraints. Many BaB based complete verifiers~\citep{bunel2018unified,lu2019neural} use an LP solver for~\eqref{eq:lp_verify_split} as the incomplete verifier. We first show that it is possible to derive Theorem~\ref{thm:beta_CROWN} from the dual of this LP, leading to Theorem~\ref{thm:objective_dual}: \begin{theorem} \label{thm:objective_dual} The objective $d_{\text{LP}}$ for the dual problem of~\eqref{eq:lp_verify_split} can be represented as \[ d_{\text{LP}} = -\|\aaa + \bbb \betavar\|_1 \cdot \epsilon + (\bbb^\top x_0 + \ccc)^\top \betavar + \aaa^\top x_0 + c, \label{eq:beta_crown_linear_lp} \] where $\aaa$, $\bbb$, $\ccc$ and $c$ are defined in the same way as in Theorem~\ref{thm:beta_CROWN}, and $\betavar \geq 0$ corresponds to the dual variables of neuron split constraints in~\eqref{eq:lp_verify_split}. \end{theorem} A similar connection between CROWN and dual LP based verifier~\citep{wong2018provable} was shown in~\citep{salman2019convex}, and their results can be seen as a special case of ours when $\betavar=0$ (none of the split constraints are active). An immediate consequence is that $\beta$-CROWN can potentially solve~\eqref{eq:lp_verify_split} as well as using an LP solver: \begin{corollary} \label{corollary:optimal_alpha_beta} When $\alphavar$ and $\betavar$ are optimally set and intermediate bounds $\bl, \bu$ are fixed, $\beta$-CROWN produces $p^*_{\text{LP}}$, the optimal objective of LP with split constraints in~\eqref{eq:lp_verify_split}: \[ \max_{0 \leq \alphavar \leq 1, \betavar \geq 0} g(\alphavar, \betavar) = p^*_{\text{LP}}, \] \end{corollary} In Appendix~\ref{ref:app_proof}, we give detailed formulations for conversions between the variables $\alphavar$, $\betavar$ in $\beta$-CROWN and their corresponding dual variables in the LP problem. \vspace{-5pt} \subsection{Joint Optimization of Free Variables in $\beta$-CROWN} \label{sec:optimization_variable} \vspace{-5pt} In~\eqref{eq:opt_alpha_beta}, $g$ is also a function of $\bl{i}{j}$ and $\bu{i}{j}$, the intermediate layer bounds for each neuron $\z{i}{j}$. They are also computed using $\beta$-CROWN. To obtain $\bl{i}{j}$, we set $f(x) := \z{i}{j}(x)$ and apply Theorem~\ref{thm:beta_CROWN}: \begin{equation} \min_{\substack{x \in {\mathcal{C}}, \tz{i-1} \in \tsetz{i-1}}} \z{i}{j}(x) \geq \max_{\substack{0 \leq \alphavar^\prime \leq 1, \ \betavar^\prime \geq 0}} g^\prime(\alphavar^\prime, \betavar^\prime) := \bl{i}{j} \end{equation} For computing $\bu{i}{j}$ we simply set $f(x) := -\z{i}{j}(x)$. Importantly, during solving these intermediate layer bounds, the $\alphavar^\prime$ and $\betavar^\prime$ are \emph{independent sets of variables}, not the same ones for the objective $f(x) := \z{L}$. Since $g$ is a function of $\bl{i}{j}$, it is also a function of $\alphavar^\prime$ and $\betavar^\prime$. In fact, there are a total of $\sum_{i=1}^{L-1} d_i$ intermediate layer neurons, and each neuron is associated with a set of independent $\alphavar^\prime$ and $\betavar^\prime$ variables. Optimizing these variables allowing us to tighten the relaxations on unstable ReLU neurons (which depend on $\bl{i}{j}$ and $\bu{i}{j}$) and produce tight final bounds, which is impossible in LP. In other words, we need to optimize $\hat{\alphavar}$ and $\hat{\betavar}$, which are two vectors concatenating $\alphavar$, $\betavar$ as well as a large number of $\alphavar^\prime$ and $\betavar^\prime$ used to compute each intermediate layer bound: \begin{equation} \min_{\substack{x \in {\mathcal{C}}, z \in \setz}} f(x) \geq \max_{\substack{0 \leq \hat{\alphavar} \leq 1, \ \hat{\betavar} \geq 0}} g(\hat{\alphavar}, \hat{\betavar}). \label{eq:opt_non_convex} \end{equation} This formulation is non-convex and has a large number of variables. Since any $0 \leq \hat{\alphavar} \leq 1$, $\hat{\betavar} \geq 0$ leads to a valid lower bound, the non-convexity does not affect soundness. When intermediate layer bounds are also allowed to be tightened during optimization, we can outperform the LP verifier for~\eqref{eq:lp_verify_split} using fixed intermediate layer bounds. Typically, in many previous works~\citep{bunel2018unified,lu2019neural,Bunel2020}, when the LP formulation~\eqref{eq:lp_verify_split} is formed, intermediate layer bounds are pre-computed with bound propagation procedures~\citep{bunel2018unified,lu2019neural}, which are far from optimal. To estimate the dimension of this problem, we denote the number of unstable neurons at layer $i$ as $s_i :=\Tr(|\S{i}|)$. Each neuron in layer $i$ is associated with $2 \times \sum_{k=1}^{i-1} s_k$ variables $\alphavar^\prime$. Suppose each hidden layer has $d$ neurons ($s_i = O(d)$), then $\hat{\alphavar}$ has $2\times \sum_{i=1}^{L-1} d_i \sum_{k=1}^{i-1} s_k = O(L^2 d^2)$ variables in total. This can be too large for efficient optimization, so we share $\alphavar^\prime$ and $\betavar^\prime$ among the intermediate neurons of the same layer, leading to a total number of $O(L^2 d)$ variables to optimize. Note that a weaker form of joint optimization was also discussed in \citep{xu2020fast} without $\betavar$, and a detailed analysis can be found in~Appendix~\ref{app:gpu_comparison}. \subsection{$\beta$-CROWN with Branch and Bound ($\beta$-CROWN BaB)} \label{sec:alg_bab} \vspace{-5pt} We perform complete verification following BaB framework~\citep{bunel2018unified} using $\beta$-CROWN as the incomplete solver, and we use simple branching heuristics like {BaBSR}~\citep{bunel2020branch} or {FSB}~\citep{de2021improved}. To efficiently utilize GPU, we also use batch splits to evaluate multiple subdomains in the same batch as in~\citep{xu2020automatic,DePalma2021}. We list our full algorithm $\beta$-CROWN BaB in Appendix~\ref{sec:app_bab} and we show it is sound and complete here: \begin{theorem} \label{thm:soundness_completeness} $\beta$-CROWN with Branch and Bound on splitting ReLUs is sound and complete. \end{theorem} Soundness is trivial because $\beta$\nobreakdash-CROWN is a sound verifier. For completeness, it suffices to show that when all unstable ReLU neurons are split, $\beta$-CROWN gives the global minimum for~\eqref{eq:lp_verify_split}. In contrast, combining CROWN~\citep{zhang2018efficient} with BaB does \emph{not} yield a complete verifier, as it cannot detect infeasible splits and a slow LP solver is still needed to guarantee completeness~\citep{xu2020fast}. Instead, $\beta$-CROWN can detect infeasible subdomains - according to duality theory, an infeasible primal problem leads to an unbounded dual objective, which can be detected (see Sec.~\ref{sec:infeasible} for more details). Additionally, we show the potential of \emph{early stopping a complete verifier as an incomplete verifier}. BaB approaches the exact solution of~\eqref{eq:nn_verify} by splitting the problem into multiple subdomains, and more subdomains give a tighter lower bound for~\eqref{eq:nn_verify}. Unlike traditional complete verifiers, $\beta$-CROWN is efficient to explore a large number of subdomains during a very short time, making $\beta$-CROWN BaB an attractive solution for efficient incomplete verification. % \section{Background} \label{ref:verification_problem} \vspace{-5pt} \subsection{The neural network verification problem and its LP relaxation} \label{sec:nn_verification_problem} We define the input of a neural network as $x~\in~\mathbb{R}^{d_0}$, and define the weights and biases of an $L$-layer neural network as $\W{i} \in \mathbb{R}^{d_i \times d_{i-1}}$ and $\bias{i} \in \mathbb{R}^{d_i}$ ($i \in \{1, \cdots, L\}$) respectively. For simplicity we assume that $d_L=1$ so $\W{L}$ is a vector and $\bias{L}$ is a scalar. The neural network function $f: \mathbb{R}^{d_0}\rightarrow\mathbb{R}$ is defined as $f(x) = \z{L}(x)$, where $\z{i}(x)=\W{i} \hz{i-1}(x) + \bias{i}$, $\hz{i}(x) = \sigma(\z{i}(x))$ and $\hz{0}(x) = x$. $\sigma$ is the activation function and we use $\mathrm{ReLU}$ throughout this paper. When the context is clear, we omit $\cdot(x)$ and use $\z{i}{j}$ and $\hz{i}{j}$ to represent the \emph{pre-activation} and \emph{post-activation} values of the $j$-th neuron in the $i$-th layer. Neural network verification seeks the solution of the optimization problem in~\eqref{eq:nn_verify}: \begin{equation} \min f(x) := \z{L}(x)\quad \text{s.t. } \z{i} = \W{i}\hz{i-1} + \bias{i}, \hz{i} = \sigma(\z{i}), x \in {\mathcal{C}}, i \in \{1, \cdots, L-1\} \label{eq:nn_verify} \end{equation} The set ${\mathcal{C}}$ defines the allowed input region and our aim is to find the minimum of $f(x)$ for $x \in {\mathcal{C}}$, and throughout this paper we consider ${\mathcal{C}}$ as an $\ell_\infty$ ball around a data example $x_0$: ${\mathcal{C}} = \{ x \ | \ \| x - x_0 \|_\infty \leq \epsilon \}$ but other $\ell_p$ norms can also be supported. In practical settings, we typically have ``specifications'' to verify, which are (usually linear) functions of neural network outputs describing the desired behavior of neural networks. For example, to guarantee robustness we typically investigate the margin between logits. Because the specification can also be seen as an output layer of NN and merged into $f(x)$ under verification, we do not discuss it in detail in this work. We consider the canonical specification $f(x) > 0$: if we can prove that $f(x) > 0, \ \forall x \in {\mathcal{C}}$, we say $f(x)$ is verified. When ${\mathcal{C}}$ is a convex set, \eqref{eq:nn_verify} is still a non-convex problem because the constraints $\hz{i} = \sigma(\z{i})$ are non-convex. Given unlimited time, \emph{complete} verifiers can solve~\eqref{eq:nn_verify} exactly: $\f^* =\min f(x), \ \forall x \in {\mathcal{C}}$, so we can always conclude if the specification holds or not for any problem instance. On the other hand, \emph{incomplete} verifiers usually relax the non-convexity of neural networks to obtain a tractable lower bound of the solution $\lf \leq f^*$. If $\lf \geq 0$, then $f^* > 0$ so $f(x)$ can be verified; when $\lf < 0$, we are not able to infer the sign of $f^*$ so cannot conclude if the specification holds or not. A commonly used incomplete verification technique is to relax non-convex ReLU constraints with linear constraints and turn the verification problem into a linear programming (LP) problem, which can then be solved with linear solvers. We refer to it as the ``LP verifier'' in this paper. Specifically, given $\mathrm{ReLU}(\z{i}{j}):=\max(0, \z{i}{j})$ and its intermediate layer bounds $\bl{i}{j} \leq \z{i}{j} \leq \bu{i}{j}$, each ReLU can be categorized into three cases: (1) if $\bl{i}{j} \geq 0$ (ReLU in linear region) then $\hz{i}{j} = \z{i}{j}$; (2) if $\bu{i}{j} \leq 0$ (ReLU in inactive region) then $\hz{i}{j} = 0$; (3) if $\bl{i}{j} \leq 0 \leq \bu{i}{j}$ (ReLU is \emph{unstable}) then three linear bounds are used: $\hz{i}{j} \geq 0$, $\hz{i}{j} \geq \z{i}{j}$, and $\hz{i}{j} \leq$ {\small$ \textstyle\frac{\bu{i}{j}}{\bu{i}{j} - \bl{i}{j}} \left ( \z{i}{j} - \bl{i}{j} \right )$}; they are often referred to as the ``triangle'' relaxation~\citep{ehlers2017formal,wong2018provable}. The intermediate layer bounds $\bl{i}$ and $\bu{i}$ are usually obtained from a cheaper bound propagation method (see next subsection). LP verifiers can provide relatively tight bounds but linear solvers are still expensive especially when the network is large. Also, unlike our $\beta$-CROWN, they have to use fixed intermediate bounds and cannot use the joint optimization of intermediate layer bounds (Section~\ref{sec:optimization_variable}) to tighten relaxation. \vspace{-5pt} \subsection{CROWN: efficient incomplete verification by propagating linear bounds} \label{sec:background_crown} \vspace{-5pt} Another cheaper way to give a lower bound for the objective in~\eqref{eq:nn_verify} is through sound bound propagation. CROWN~\citep{zhang2018efficient} is a representative method that propagates a linear bound of $f(x)$ w.r.t.\ every intermediate layer in a backward manner until reaching the input $x$. CROWN uses two linear constraints to relax unstable $\mathrm{ReLU}$ neurons: a linear upper bound {\small $\hz{i}{j} \leq \frac{\bu{i}{j}}{\bu{i}{j} - \bl{i}{j}} \left ( \z{i}{j} - \bl{i}{j} \right )$} and a linear lower bound {$\hz{i}{j} \geq \alphavar{i}{j} \z{i}{j}$ ($0 \leq \alphavar{i}{j} \leq 1$)}. We can then bound the output of a ReLU layer: \begin{lemma}[ReLU relaxation in CROWN] \label{lemma:relax_single} Given $w, v \in \mathbb{R}^d, \bl \leq v \leq \bu$ (element-wise), we have \[ w^\top \mathrm{ReLU}(v) \geq w^\top \D v + b^\prime, \] where $\D$ is a diagonal matrix containing free variables $0 \leq \alphavar_j \leq 1$ only when $\bu_j > 0 > \bl_j$ and $w_j \geq 0$, while its rest values as well as constant $b'$ are determined by $\bl, \bu, w$. \end{lemma} Detailed forms of each term are listed in Appendix~\ref{ref:app_proof}. Lemma~\ref{lemma:relax_single} can be repeatedly applied, resulting in an efficient back-substitution procedure to derive a linear lower bound of NN output w.r.t.\ $x$: \begin{lemma}[CROWN bound~\citep{zhang2018efficient}] Given an $L$-layer ReLU NN {$f(x): \mathbb{R}^{d_0} \rightarrow \mathbb{R}$ with weights $\W{i}$}, biases $\bias{i}$, pre-ReLU bounds {$\bl{i} \leq \z{i} \leq \bu{i}$ ($1 \leq i \leq L$}) and input constraint {$x \in {\mathcal{C}}$}. We have \[ \min_{x \in {\mathcal{C}}} f(x) \geq \min_{x \in {\mathcal{C}}} \aaa_{\mathrm{\scriptscriptstyle CROWN}}^\top x + c_{\mathrm{\scriptscriptstyle CROWN}} \] where $\aaa_{\mathrm{\scriptscriptstyle CROWN}}$ and $c_{\mathrm{\scriptscriptstyle CROWN}}$ can be computed using $\W{i}, \bias{i}, \bl{i}, \bu{i}$ in polynomial time. \end{lemma} When ${\mathcal{C}}$ is an $\ell_p$ norm ball, minimization over the linear function can be easily solved using H\"older's inequality. The main benefit of CROWN is its efficiency: CROWN can be efficiently implemented on machine learning accelerators such as GPUs~\cite{xu2020automatic} and TPUs~\citep{zhang2019towards}, and it can be a few magnitudes faster than an LP verifier which is hard to parallelize on GPUs. CROWN was generalized to general architectures~\cite{xu2020automatic,shi2020robustness} while we only demonstrate it for feedforward ReLU networks for simplicity. Additionally, \citet{xu2020fast} showed that it is possible to optimize the slope of the lower bound, $\alphavar$, using gradient ascent, to further tighten the bound (sometimes referred to as $\alpha$-CROWN). \vspace{-3pt} \subsection{Branch and Bound and Neuron Split Constraints} \label{ref:branch_and_bound} \vspace{-3pt} Branch and bound (BaB) method is widely adopted in complete verifiers~\citep{bunel2018unified}: we divide the domain of the verification problem ${\mathcal{C}}$ into two subdomains ${\mathcal{C}}_1 = \{ x \in {\mathcal{C}}, \z{i}{j} \geq 0 \}$ and ${\mathcal{C}}_2 = \{ x \in {\mathcal{C}}, \z{i}{j} < 0 \}$ where $\z{i}{j}$ is an unstable ReLU neuron in ${\mathcal{C}}$ but now becomes linear for each subdomain. Incomplete verifiers can then estimate the lower bound of each subdomain with relaxations. If the lower bound produced for subdomain ${\mathcal{C}}_i$ (denoted by $\lf_{{\mathcal{C}}_i}$) is greater than 0, ${\mathcal{C}}_i$ is verified; otherwise, we further branch over domain ${\mathcal{C}}_i$ by splitting another unstable ReLU neuron. The process terminates when all subdomains are verified. The completeness is guaranteed when all unstable ReLU neurons are split. \paragraph{LP verifier with neuron split constraints.} A popular incomplete verifier used in BaB is the LP verifier. Essentially, when we split the $j$-th $\mathrm{ReLU}$ in layer $i$, we can simply add $\z{i}{j} \geq 0$ or $\z{i}{j} < 0$ to~\eqref{eq:nn_verify} and get a linearly relaxed lower bound to each subdomain. We denote the $\setzp{i}$ and $\setzn{i}$ as the set of neuron indices with positive and negative split constraints in layer $i$. We define the split constraints at layer $i$ as $\setz{i} := \{ \z{i} \ | \ \z{i}{j_1} \geq 0, \z{i}{j_2} < 0, \forall j_1 \in \setzp{i}, \forall j_2 \in \setzn{i} \}$. We denote the vector of all pre-ReLU neurons as $z$, and we define a set $\setz$ to represent the split constraints on $z$: $\setz = \setz{1} \cap \setz{2} \cap \cdots \cap \setz{L-1}$. For convenience, we also use the shorthand $\tsetz{i} := \setz{1} \cap \cdots \cap \setz{i}$ and $\tz{i} := \{ \z{1}, \z{2}, \cdots, \z{i} \}$. LP verifiers can easily handle these neuron split constraints but are more expensive than bound propagation methods like CROWN and cannot be accelerated on GPUs. \paragraph{Branching strategy.} Branching strategies (selecting which ReLU neuron to split) are generally agnostic to the incomplete verifier used in BaB but do affect the overall BaB performance. {BaBSR}~\citep{bunel2020branch} is a widely used strategy in complete verifiers, which is based on an fast estimates on objective improvements after splitting each neuron. The neuron with highest estimated improvement is selected for branching. Recently, Filtered Smart Branching ({FSB})~\citep{de2021improved} improves {BaBSR} by mimicking strong branching - it utilizes bound propagation methods to evaluate the best a few candidates proposed by BaBSR and chooses the one with largest improvement. Graph neural network (GNN) based branching was also proposed~\citep{lu2019neural}. Our $\beta$-CROWN BaB is a general complete verification framework fit for any potential branching strategy, and we evaluate both BaBSR and FSB in experiments. \section{Conclusion} \label{sec:conclusion} \vspace{-5pt} We proposed $\beta$-CROWN, a new bound propagation method that can fully encode the neuron split constraints introduced in BaB, which clearly leads in both complete and incomplete verification settings. The success of $\beta$-CROWN comes from a few factors: (1) In Section~\ref{sec:beta_crown_primal}, we show that $\beta$-CROWN is an GPU-friendly bound propagation algorithm \emph{significantly faster than LP solvers}. (2) In Section~\ref{sec:algorithm_dual}, we show that $\beta$-CROWN is solving an equivalent problem of the LP verifier \emph{with neuron split constraints}. (3) In Section~\ref{sec:optimization_variable}, we show that $\beta$-CROWN can jointly optimize intermediate layer bounds and \emph{achieve tighter bounds than typical LP verifiers} using fixed intermediate layer bounds. \paragraph{Limitations.} Our verifier has several limitations which are commonly shared by most existing BaB-based complete verifiers. First, we focused on ReLU which can be split into two linear cases. For other non-piecewise linear activation functions, although it is still possible to conduct branch and bound, it is difficult to guarantee completeness. Second, we discussed only the norm perturbations for input domains. In practice, the threat model may involve complicated and nonconvex perturbation specifications. Third, although our GPU accelerated verifier outperforms existing ones, all BaB based verifiers, including ours, are still limited to relatively small models far from the ImageNet scale. Finally, we have only demonstrated robustness verification of image classification tasks, and generalizing it to give verification guarantees for other tasks such as robust deep reinforcement learning~\citep{pattanaik2017robust,zhang2020robust,zhang2021robust} is an interesting direction for future work. \paragraph*{Societal Impact} NNs have been used in an increasingly wide range of real-world applications and play an important role in artificial intelligence (AI). The trustworthiness and robustness of NNs have become crucial factors since AI plays an important role in modern society. $\beta$-CROWN is a strong neural network verifier which can be used to check certain properties of neural networks, which can be helpful for guaranteeing the robustness, correctness, and fairness of NNs in applications that can directly or indirectly impact human life. We believe our work has overall positive societal impacts, although it may potentially be misused to identify the weakness of NNs and guide attacks. \section*{Acknowledgement} This work is supported by NSF grant CNS18-01426; an ARL Young Investigator (YIP) award; an NSF CAREER award; a Google Faculty Fellowship; a Capital One Research Grant; and a J.P. Morgan Faculty Award; Air Force Research Laboratory under FA8750-18-2-0058; NSF IIS-1901527, NSF IIS-2008173 and NSF CAREER-2048280; and NSF CNS-1932351. Huan Zhang is supported by funding from the Bosch Center for Artificial Intelligence. \section{Experimental Results} \vspace{-5pt} \label{sec:exp} \vspace{-3pt} \subsection{Comparison to Complete Verifiers} \vspace{-5pt} We evaluate complete verification performance on dataset provided in \citep{lu2019neural,DePalma2021} and used in VNN-COMP 2020~\citep{vnn2020}. The benchmark contains three CIFAR-10 models (Base, Wide, and Deep) with 100 examples each. Each data example is associated with an $\ell_\infty$ norm $\epsilon$ and a target label for verification (referred to as a \emph{property} to verify). The details of neural network structures and experimental setups can be found in Appendix~\ref{sec:app_exp}. We compare against multiple baselines for complete verification: (1) {BaBSR}~\citep{bunel2020branch}, a basic BaB and LP based verifier; (2) {MIPplanet}~\citep{ehlers2017formal}, a customized MIP solver for NN verification where unstable ReLU neurons are randomly selected for splitting; (3) ERAN~\citep{singh2019beyond,singh2018fast,singh2019abstract,singh2018boosting}, an abstract interpretation based verifier which performs well on this benchmark in VNN-COMP 2020; (4) {GNN-Online}~\cite{lu2019neural}, a BaB and LP based verifiers using a learned Graph Neural Network (GNN) to guide the ReLU splits; (5) {BDD+ BaBSR}~\citep{Bunel2020}, a verification framework based on Lagrangian decomposition on GPUs ({BDD+}) with {BaBSR} branching strategy; (6) OVAL (BDD+ GNN)~\citep{Bunel2020,lu2019neural}, a strong verifier in VNN-COMP 2020 using {BDD+} with {GNN} guiding the ReLU splits; (7) {A.set BaBSR} and (8) {Big-M+A.set BaBSR}~\citep{DePalma2021}, very recent dual-space verifiers on GPUs with a tighter linear relaxation than triangle LP relaxations; (9) {Fast-and-Complete}~\citep{xu2020fast}, which uses CROWN (LiRPA) on GPUs as the incomplete verifier in BaB without neuron split constraints; (10) BaDNB ({BDD+ FSB})~\citep{de2021improved}, a concurrent state-of-the-art complete verifier, using {BDD+} on GPUs with FSB branching strategy. $\beta$-CROWN BaB can use either BaBSR or FSB branching heuristic, and we include both in evaluation. All methods use a 1 hour timeout threshold. We report the average verification time and branch numbers in Table~\ref{table:average_complete} and plot the percentage of solved properties over time in Figure~\ref{fig:rate_time_complete}. {$\beta$-CROWN FSB} achieves the fastest average running time compared to all other baselines with minimal timeouts, and also clearly leads on the cactus plot. When using a weaker branching heuristic, $\beta$-CROWN BaBSR still outperforms all literature baselines, including very recent ones such as {A.set BaBSR}~\citep{DePalma2021}, Fast-and-Complete~\citep{xu2020fast} and BaDNB~\citep{de2021improved}. Our benefits are more clearly shown in Figure~\ref{fig:rate_time_complete}, where we solve over 90\% examples under 10s and most other verifiers can verify much less or none of the properties within 10s. We see a 2 to 3 orders of magitudes speedup in Figure~\ref{fig:rate_time_complete} compared to CPU based verifiers such as MIPplanet and BaBSR. \begin{table*}[t] \centering \caption{\footnotesize Average runtime and average number of branches on three CIFAR-10 models over 100 properties. } \vspace{-5pt} \label{table:average_complete} \scriptsize \setlength{\tabcolsep}{4.2pt} \begin{adjustbox}{center} \begin{threeparttable}[hbt] \begin{tabular}{cccc|ccc|ccc} & \multicolumn{3}{ c }{CIFAR-10 Base} & \multicolumn{3}{ c }{CIFAR-10 Wide} & \multicolumn{3}{ c }{CIFAR-10 Deep} \\ \toprule \multicolumn{1}{ c| }{Method} & \multicolumn{1}{ c }{time(s)} & \multicolumn{1}{ c }{branches} & \multicolumn{1}{ c| }{$\%$timeout} & \multicolumn{1}{ c }{time(s)} & \multicolumn{1}{ c }{branches} & \multicolumn{1}{ c| }{$\%$timeout} & \multicolumn{1}{ c }{time(s)} & \multicolumn{1}{ c }{branches} & \multicolumn{1}{ c }{$\%$timeout} \\ \cmidrule(lr){1-1} \cmidrule(lr){2-4} \cmidrule(lr){5-7} \cmidrule(lr){8-10} \multicolumn{1}{ c| }{{BaBSR}~\citep{bunel2020branch}} &2367.78 &1020.55 &36.00 &2871.14 &812.65 &49.00 &2750.75 &401.28 &39.00\\ \multicolumn{1}{ c| }{{MIPplanet}~\citep{ehlers2017formal}} & 2849.69 & - & 68.00 &2417.53 &- &46.00 &2302.25 &- &40.00\\ \multicolumn{1}{ c| }{{ERAN}$^*$\citep{singh2019beyond,singh2018fast,singh2019abstract,singh2018boosting}} & 805.94 & - & 5.00 &632.20 &- &9.00 &545.72 &- &\textbf{0.00}\\ \multicolumn{1}{ c| }{{GNN-online}~\citep{lu2019neural}} &1794.85 &565.13 &33.00 &1367.38 &372.74 &15.00 &1055.33 &131.85 &4.00 \\ \multicolumn{1}{ c| }{{BDD+ BaBSR}~\citep{Bunel2020}} &807.91 &195480.14 &20.00 &505.65 &74203.11 &10.00 &266.28 &12722.74 &4.00 \\ \multicolumn{1}{ c| }{{OVAL (BDD+ GNN)}$^*$\citep{Bunel2020,lu2019neural}} &662.17 &67938.38 &16.00 &280.38 &17895.94 &6.00 &94.69 &1990.34 &1.00 \\ \multicolumn{1}{ c| }{{A.set BaBSR}~\citep{DePalma2021}} &381.78 &12004.60 &{7.00} &{165.91} &2233.10 &{3.00} &190.28 &2491.55 &2.00 \\ \multicolumn{1}{ c| }{{BigM+A.set BaBSR}~\citep{DePalma2021}} &390.44 &11938.75 &{7.00} &172.65 &4050.59 &{3.00} &177.22 &3275.25 &2.00\\ \multicolumn{1}{ c| }{{Fast-and-Complete}~\citep{xu2020fast}} &695.01 &119522.65 &17.00 &495.88 &80519.85 &9.00 &105.64 &2455.11 &1.00\\ \multicolumn{1}{ c| }{BaDNB ({BDD+ FSB})\citep{de2021improved}} &309.29 &38239.04 &7.00 &165.53 &11214.44 &4.00 &10.50 &368.16 &\textbf{0.00}\\ \hline \multicolumn{1}{ c| }{{$\beta$-CROWN BaBSR}} &{226.06} &509608.50 &6.00 &118.26 &217691.24 &{3.00} &{6.12} &204.66 &\textbf{0.00} \\ \multicolumn{1}{ c| }{{$\beta$-CROWN FSB }} &\textbf{118.23} &208018.21 &\textbf{3.00} &\textbf{78.32} &116912.57 &\textbf{2.00} &\textbf{5.69} &{41.12} &\textbf{0.00}\\ \bottomrule \end{tabular} \begin{tablenotes} \item [*] OVAL (BDD+ GNN) and ERAN results are from VNN-COMP 2020 report~\citep{vnn2020}. Other results were reported by their authors. \end{tablenotes} \end{threeparttable} \end{adjustbox} \vspace{-10pt} \end{table*} \begin{figure*}[t] \centering % \begin{tabular}{ccc} % \hspace{-2mm} \includegraphics[width=.42\textwidth]{figures/complete/rate_time_base_100_3600_nips_final.pdf} &\hspace{-5mm} \includegraphics[width=.275\textwidth]{figures/complete/rate_time_wide_100_3600_nips_final.pdf} & \hspace{-5mm} \includegraphics[width=.275\textwidth]{figures/complete/rate_time_deep_100_3600_nips_final.pdf} \end{tabular} \vspace{-7pt} \caption{Percentage of solved properties with growing running time. $\beta$-CROWN {FSB} (light green) and $\beta$-CROWN {BaBSR} (dark green) clearly lead in all 3 settings and solve over 90\% properties within 10 seconds.} \label{fig:rate_time_complete} \vspace{-15pt} \end{figure*} \begin{table}[t] \centering \caption{{\bf Verified accuracy (\%)} and avg.\ time (s) of 1000 images evaluated on the ERAN models in~\cite{singh2019beyond,tjandraatmadja2020convex,muller2021precise}. kPoly, OptC2V and PRIMA are strong incomplete verifiers that can break the convex relaxation barrier~\citep{salman2019convex}. The average time reported by us excludes examples that are classified incorrectly.} \label{tab:eran_model} \adjustbox{max width=1.0\textwidth}{ \begin{threeparttable}[hbt] \begin{tabular}{c|c|rr|rr|rr|rr|rr|r} \toprule Dataset & Model & \multicolumn{2}{c|}{CROWN/DeepPoly$^*$\citep{singh2019abstract}} & \multicolumn{2}{c|}{kPoly~\citep{singh2019beyond}} & \multicolumn{2}{c|}{OptC2V~\cite{tjandraatmadja2020convex}} & \multicolumn{2}{c|}{PRIMA$^\dagger$~\cite{muller2021precise}} & \multicolumn{2}{c|}{{$\beta$-CROWN FSB}} & Upper \\ \multicolumn{2}{c|}{(Same settings as {\citep{singh2019beyond,tjandraatmadja2020convex,muller2021precise}})} & Verified\% & Time (s) & Ver.\% & Time(s) & Ver.\% & Time(s) & Ver.\% & Time(s) & Ver.\% & Time(s) & bound\\ \midrule \multirow{3}{*}{MNIST} & MLP $5 \times 100^\ddagger$ & 16.0 & 0.7 & 44.1 & 307 & 42.9 & 137 & 51.0 & 159 & \textbf{69.9} & 102 & 84.2 \\ & MLP $8 \times 100$ & 18.2 & 1.4 & 36.9 & 171 & 38.4 & 759 & 42.8 & 301 & \textbf{62.0} & 103 & 82.0 \\ & MLP $5 \times 200$ & 29.2 & 2.4 & 57.4 & 187 & 60.1 & 403 & 69.0 & 224 & \textbf{77.4} & 86 & 90.1 \\ & MLP $8 \times 200$ & 25.9 & 5.6 & 50.6 & 464 & 52.8 & 3451 & 62.4 & 395 & \textbf{73.5} & 95 & 91.1 \\ & ConvSmall & 15.8 & 3 & 34.7 & 477 & 43.6 & 55 & 59.8 & 42 & {\bf 72.7} & 7.0 & 73.2 \\ & ConvBig & 71.1 & 21 & 73.6 & 40 & 77.1 & 102 & {77.5} & 11 & \textbf{79.3} & 3.1 & 80.4 \\ \hline \multirow{3}{*}{CIFAR} & ConvSmall & 35.9 & 4 & 39.9 & 86 & 39.8 & 105 & 44.6 & 13 & {\bf 46.3} & 6.8 & 48.1 \\ & ConvBig & 42.1 & 43 & 45.9 & 346 & \multicolumn{2}{c|}{No public code} & 48.3 & 176 & {\bf 51.6} & 15.3 &55.0 \\ & ResNet & 24.1 & 1 & 24.5 & 91 & \multicolumn{2}{c|}{cannot run} & \textbf{24.8} & 1.7 & {\bf 24.8} & 1.6 &24.8 \\ \bottomrule \end{tabular} \begin{tablenotes}[flushleft,para] \item [*] CROWN/DeepPoly evaluated on CPU. $^\dagger$ PRIMA is a concurrent work and its results are from~\citep{muller2021precise} (Oct 26, 2021 version), except that ResNet results are from personal communications with the authors due to a different input normalization used. \item [$\ddagger$] Because these MLP models are fairly small, some of their intermediate layer bounds are computed by mixed integer programming (MIP) using 80\% time budget before branch and bound starts and $\beta$-CROWN FSB is used during the branch and bound process. We find that tighter intermediate bounds by MIP is beneficial for these small MLP models. \end{tablenotes} \end{threeparttable} } \label{tab:verified_acc_eran} \vspace{-15pt} \end{table} \begin{table}[] \small \caption{{\bf Verified accuracy (\%)} and avg.\ per-example verification time (s) on 7 models from SDP-FO~\cite{dathathri2020enabling}. CROWN/DeepPoly are fast but loose bound propagation based methods, and they cannot be improved with more running time. SDP-FO uses stronger semidefinite relaxations, which can be very slow and sometimes has convergence issues. PRIMA, a concurrent work, is the state-of-the-art relaxation barrier breaking method; we did not include kPoly and OptC2V because they are weaker than PRIMA (see Table~\ref{tab:eran_model}).} % \centering \label{tab:sdp_model} \adjustbox{max width=.95\textwidth}{ \begin{threeparttable}[hbt] \begin{tabular}{c|c|rr|rr|rr|rr|r} \toprule Dataset & Model & \multicolumn{2}{c|}{CROWN/DeepPoly} & \multicolumn{2}{c|}{SDP-FO~\cite{dathathri2020enabling}$^*$} & \multicolumn{2}{c|}{PRIMA~\cite{muller2021precise}} & \multicolumn{2}{c|}{{$\beta$-CROWN FSB}} & Upper \\ \multicolumn{2}{c|}{$\epsilon=0.3$ and $\epsilon=2/255$} & Verified\% & Time (s) & Ver.\% & Time(s) & Ver.\% & Time(s) & Ver.\% & Time(s) & bound \\ \midrule MNIST & CNN-A-Adv & 1.0 & 0.1 & 43.4 & $>$20h & 44.5 & 135.9 & \textbf{70.5} & 21.1 & 76.5 \\ \hline \multirow{6}{*}{CIFAR} & CNN-B-Adv & 21.5 & 0.5 & 32.8 & $>$25h & 38.0 & 343.6 & \textbf{46.5} & 32.2 & 65.0 \\ & CNN-B-Adv-4 & 43.5 & 0.9 & 46.0 & $>$25h & 53.5 & 43.8 & \textbf{54.0} & 11.6 & 63.5 \\ & CNN-A-Adv & 35.5 & 0.6 & 39.6 & $>$25h & 41.5 & 4.8 & \textbf{44.0} & 5.8 & 50.0 \\ & CNN-A-Adv-4 & 41.5 & 0.7 & 40.0 & $>$25h & 45.0 & 4.9 & \textbf{46.0} & 5.6 & 49.5 \\ & CNN-A-Mix & 23.5 & 0.4 & 39.6 & $>$25h & 37.5 & 34.3 & \textbf{41.5} & 49.6 & 53.0 \\ & CNN-A-Mix-4 & 38.0 & 0.5 & 47.8 & $>$25h & 48.5 & 7.0 & \textbf{50.5} & 5.9 & 57.5 \\ \bottomrule \end{tabular} \begin{tablenotes}[flushleft,para] \item [\textsuperscript{*}] SDP-FO results are directly from their paper due to its very long running time (>20h per example). \item [$\dagger$] PRIMA experiments were done using commit \href{https://github.com/eth-sri/eran/commit/396dc7a118d0b8772b4f0e9684f9203c9c9b6f63}{396dc7a}, released on June 4, 2021. PRIMA and $\beta$-CROWN FSB results are on the same set of 200 examples (first 200 examples of CIFAR-10 dataset) and we don't run verifiers on examples that are classified incorrectly or can be attacked by a 200-step PGD. $\beta$-CROWN uses 1 GPU and 1 CPU; PRIMA uses 1 GPU and 20 CPUs. \end{tablenotes} \end{threeparttable} } \label{tab:verified_acc_sdp} \vspace{-15pt} \end{table} \vspace{-5pt} \subsection{Comparison to Incomplete Verifiers} \vspace{-5pt} \label{sec:exp_incomplete} \paragraph{Verified accuracy.} In Table~\ref{tab:verified_acc_eran}, we compare against a few representative and strong incomplete verifiers on 5 convolutional networks and 4 MLP networks for MNIST and CIFAR-10 under the same set of 1000 images and perturbation $\epsilon$ as reported in~\citep{singh2019beyond,tjandraatmadja2020convex,muller2021precise}. Among the baselines, kPoly~\citep{singh2019beyond}, OptC2V~\citep{tjandraatmadja2020convex} and PRIMA~\citep{muller2021precise} utilize state-of-the-art multi-neuron linear relaxation for ReLUs and can bypass the single-neuron convex relaxation barrier~\citep{salman2019convex}, and are among the strongest incomplete verifiers. $\beta$-CROWN FSB achieves better verified accuracy on all models using a similar or less amount of time. Some models, such as MNIST ConvBig and CIFAR ConvBig, are quite challenging - the verified accuracy obtained by $\beta$-CROWN FSB is close to the upper bound found via PGD attack. To make more comprehensive evaluations, in Table~\ref{tab:verified_acc_sdp} we further compare against a state-of-the-art semidefinite programming (SDP) based verifier, SDP-FO~\citep{dathathri2020enabling}, on one MNIST and six CIFAR-10 models reported in their paper. The models were trained using adversarial training, which posed a challenge for verification~\citep{raghunathan2018semidefinite}. The SDP formulation can be tighter than linear relaxation based ones, but it is computationally expensive - SDP-FO takes 2 to 3 hours to converge on one GPU for verifying a single property, resulting 5,400 GPU hours to verify 200 testing images with 10 labels each. Due to resource limitations, we directly quote SDP-FO results from~\cite{dathathri2020enabling} on the same set of models. We evaluate verified accuracy on the same set of 200 test images for other baselines. We include a concurrent work PRIMA~\citep{muller2021precise}, the strongest multi-neuron linear relaxation baseline in Table~\ref{tab:eran_model}, which generally outperforms kPoly and OptC2V. Table~\ref{tab:verified_acc_sdp} shows that overall we are 3 orders of magnitude faster than SDP-FO while still achieving consistently higher verified accuracy on average. \vspace{-10pt}\paragraph{Tightness of verification.} In Figure~\ref{fig:tightness}, we compare the tightness of verification bounds against SDP-FO on two adversarially trained networks from~\cite{dathathri2020enabling}. Specifically, we use the verification objective $\f(x):=z^{(L)}_{y}(x)-z^{(L)}_{y'}(x)$, where $z^{(L)}$ is the logit layer output, $y$ and $y'$ are the true label and the runner-up label. For each test image, a 200-step PGD attack~\cite{madry2017towards} provides an adversarial upper bound $\overline{\f}$ of the optimal objective: $\f^*\leq\overline{\f}$. Verifiers, on the other hand, can provide a verified lower bound $\underline{\f}\leq f^*$. Bounds from tighter verification methods lie closer to line $y=x$ in Figure~\ref{fig:tightness}. Figure~\ref{fig:tightness} shows that on both PGD adversarially trained networks, {$\beta$-CROWN FSB} consistently outperforms SDP-FO for all 100 random test images. Importantly, for each point on the plots, {$\beta$-CROWN FSB} needs 3 minutes while SDP-FO needs 178 minutes on average. LP verifier with triangle relaxations produces much looser bounds than {$\beta$-CROWN FSB} and SDP-FO. Additional results are in Appendix~\ref{app:additional_exp}. \vspace{-5pt} \paragraph{VNN-COMP 2021 results.} We encourage the readers to checkout the report of the Second International Verification of Neural Networks Competition (VNN-COMP 2021)~\citep{bak2021second} with 9 additional benchmarks and 12 competing methods evaluated in a standardized testing environment on AWS. Our entry $\alpha,\!\beta$-CROWN is based on the $\beta$-CROWN algorithm in this work and uses the same codebase. \begin{figure}[] \centering \vspace{-15pt} \begin{tabular}{cc} \includegraphics[width=.43\linewidth]{figures/mnist_a_adv.pdf} & \includegraphics[width=.43\linewidth]{figures/cifar_b_adv.pdf} \\ {\scriptsize (a) MNIST CNN-A-Adv, runner-up targets, $\epsilon=0.3$} & {\scriptsize (b) CIFAR CNN-B-Adv, runner-up targets, $\epsilon=2/255$} \end{tabular} \vspace{-5pt} \caption{\small Verified lower bound v.s.\ PGD adversarial upper bound. A lower bound closer to the upper bound (closer to the line $y=x$) is better. % {$\beta$-CROWN FSB} uses 3mins while SDP-FO needs 2 to 3 hours per point.} \label{fig:tightness} \end{figure} \vspace{-5pt} \section{Introduction} As neural networks (NNs) are being deployed in safety-critical applications, it becomes increasingly important to formally verify their behaviors under potentially malicious inputs. Broadly speaking, the neural network verification problem involves proving certain desired relationships between inputs and outputs (often referred to as \emph{specifications}), such as safety or robustness guarantees, for all inputs inside some domain. Canonically, the problem can be cast as finding the global minima of some functions on the network's outputs (e.g., the difference between the predictions of the true label and another target label), within a bounded input set as constraints. This is a challenging problem due to the non-convexity and high dimensionality of neural networks. We first focus on \emph{complete} verification: the verifier should give a definite ``yes/no'' answer given sufficient time. Many complete verifiers rely on the branch and bound (BaB) method~\citep{bunel2018unified} involving (1) branching by recursively splitting the original verification problem into subdomains (e.g., splitting a ReLU neuron into positive/negative linear regions by adding split constraints) and (2) bounding each subdomain with specialized incomplete verifiers. Traditional BaB-based verifiers use expensive linear programming (LP) solvers~\citep{ehlers2017formal,lu2019neural,bunel2020branch} as incomplete verifiers which can fully encode neuron split constraints. Meanwhile, a recent verifier, Fast-and-Complete~\citep{xu2020fast}, demonstrates that cheap incomplete verifiers can significantly accelerate complete verification on GPUs over LP-based ones thanks to their efficiency. Many cheap incomplete verifiers are based on \emph{bound propagation methods}~\citep{zhang2018efficient,wong2018provable,wang2018formal,dvijotham2018dual,gehr2018ai2,singh2019abstract,xu2020automatic}, i.e., maintaining and propagating tractable and sound bounds through networks, and CROWN~\citep{zhang2018efficient} is a representative which propagates a linear or quadratic bound. However, unlike LP based verifiers, existing bound propagation methods lack the power to handle neuron split constraints introduced by BaB. For instance, given inputs $x,y\in[-1,1]$, they can bound a ReLU's input $x+y$ as $[-2,2]$ but they have no means to consider neuron split constraints such as $x-y\geq0$ introduced by splitting another ReLU to the positive linear region. Such a problem causes looser bounds and unnecessary branching, hurting the verification efficiency. Even worse, without considering these split constraints, bound propagation methods cannot detect many infeasible subdomains in BaB~\citep{xu2020fast}, leading to incompleteness unless costly checking is performed. In our work, we develop a new, fast bound propagation based incomplete verifier, $\beta$-CROWN. It solves an optimization problem equivalent to the expensive LP based methods with neuron split constraints while still enjoying the efficiency of bound propagation methods. $\beta$-CROWN contains optimizable parameters $\betavar$ which come from propagation of Lagrangian multipliers, and any valid settings of these parameters yield sound bounds for verification. These parameters are optimized using a few steps of (super)gradient ascent to achieve bounds as tight as possible. Optimizing $\betavar$ can also eliminate many infeasible subdomains and avoid further useless branching. Furthermore, we can jointly optimize intermediate layer bounds similar to~\citep{xu2020automatic} but also with the additional parameters $\betavar$, allowing $\beta$-CROWN to tighten relaxations and outperform typical LP verifiers with fixed intermediate layer bounds. Unlike traditional LP-based BaB methods, $\beta$-CROWN can be efficiently implemented with an automatic differentiation framework on GPUs to fully exploit the power of modern accelerators. The combination of $\beta$-CROWN and BaB ($\beta$-CROWN BaB) produces a complete verifier with GPU acceleration, reducing the verification time of traditional LP based BaB verifiers~\citep{bunel2018unified} by up to \emph{three orders of magnitudes} on a commonly used benchmark suite on CIFAR-10~\citep{Bunel2020,DePalma2021}. Compared to all state-of-the-art GPU-based complete verifiers~\citep{bunel2020branch,xu2020fast,DePalma2021,lu2019neural,Bunel2020,de2021improved}, our approach is noticeably faster with lower timeout rates. Our algorithm empowered the tool $\alpha,\!\beta$-CROWN (\texttt{alpha-beta-CROWN}), which won the 2nd International Verification of Neural Networks Competition~\citep{bak2021second} (VNN-COMP 2021) with the highest total score and verified the most number of problem instances in 8 benchmarks. Finally, by terminating our complete verifier $\beta$-CROWN BaB early, our approach can also function as a more accurate incomplete verifier by returning an incomplete but sound lower bound of all subdomains explored so far. We achieve better verified accuracy on a few benchmarking models over powerful incomplete verifiers including those based on tight linear relaxations~\citep{singh2019beyond,tjandraatmadja2020convex,muller2021precise} and semidefinite relaxations~\citep{dathathri2020enabling}. Compared to the typically tightest but very costly incomplete verifier SDP-FO~\citep{dathathri2020enabling} based on the semidefinite programming (SDP) relaxations~\citep{raghunathan2018semidefinite,dvijotham2020efficient}, our method obtains consistently higher verified accuracy while reducing verification time by three orders of magnitudes. \section{Related Work} \vspace{-10pt} Many early complete verifiers for neural networks relied on existing solvers such as MILP or SMT solvers~\citep{katz2017reluplex,ehlers2017formal,huang2017safety,dutta2018output,tjeng2017evaluating} and were limited to very small problem instances. Branch and bound (BaB) based method was proposed to better exploit the network structure using LP-based incomplete verifier for bounding and ReLU splits for branching~\citep{bunel2018unified,wang2018efficient,lu2019neural,botoeva2020efficient}. Besides branching on ReLU neurons, input domain branching was also considered in~\citep{wang2018formal,royo2019fast,anderson2019optimization} but limited by input dimensions~\citep{bunel2018unified}. Recently, a few approaches have been proposed to use efficient iterative solvers or bound propagation methods on GPUs without relying on LP solvers. \citet{Bunel2020} decomposed the verification problem layer by layer, solved each layer in a closed form on GPUs, and used Lagrangian to enforce consistency between layers. However, their formulation only has the same power as LP and needs many iterations to converge. \citet{DePalma2021} used a dual-space verifier with a linear relaxation~\citep{anderson2020strong,tjandraatmadja2020convex} tighter than triangle LP relaxation, but in most settings the extra computational costs and difficulties for an efficient implementation offset its benefits (more discussions in section~\ref{app:gpu_comparison}). {A concurrent work BaDNB~\citep{de2021improved} proposed a new branching strategy, filtered smart branching (FSB), combined with Lagrangian decomposition to get better verification performance.} \citet{xu2020automatic} used CROWN as a massively paralleled incomplete solver on GPUs for complete verification, but it cannot handle neuron split constraints, leading to suboptimal efficiency and high timeout rates. For incomplete verification, \citet{salman2019convex} shows the inherent limitation of using per-neuron convex relaxations for verification problems. \citet{singh2019beyond} and \citet{muller2021precise} broke this barrier by considering constraints involving multiple ReLU neurons; \citet{tjandraatmadja2020convex} proposed to relax a linear layer with a ReLU neuron together using a strong mixed-integer programming formulation~\citep{anderson2019optimization}. SDP based relaxations~\citep{raghunathan2018semidefinite,fazlyab2020safety,dvijotham2020efficient} typically produce tight bounds but with significantly higher cost. The most recent GPU based SDP verifier~\citep{dathathri2020enabling} is still relatively slow and can take 2 hours to verify a single image. In this work, we impose neuron split constraints using $\beta$-CROWN and combine it with branch and bound done in parallel on GPUs. Although for each subdomain in BaB, $\beta$-CROWN is still subject to the convex relaxation barrier, the efficiency of $\beta$-CROWN BaB allows it to quickly explore a very large number of subdomains and outperform existing convex barrier breaking incomplete verifiers under many scenarios in both runtime and tightness. Additionally, another line of works train networks to enhance verified accuracy, typically using cheap incomplete verifiers at training time~\citep{wong2018provable,wang2018mixtrain,mirman2018differentiable,wong2018scaling,gowal2018effectiveness,mirman2018differentiable,zhang2019towards,balunovic2020adversarial,shi2021fast}. Traditionally only these verification-customized networks can have reasonable verified accuracy, while $\beta$-CROWN BaB can also give non-trivial verified accuracy on relatively large networks agnostic to verification. \section{More details on $\beta$-CROWN with branch and bound (BaB)} \label{sec:app_bab} \subsection{$\beta$-CROWN with branch and bound for complete verification} We list our $\beta$-CROWN with branch and bound based complete verifier (\textsc{$\beta$-CROWN BaB}) in Algorithm~\ref{alg:bab}. The algorithm takes a target NN function $f$ and a domain ${\mathcal{C}}$ as inputs. The subprocedure $\mtt{optimized\_beta\_CROWN}$ optimizes $\hat{\alphavar}$ and $\hat{\betavar}$ (free variables for computing intermediate layer bounds and last layer bounds) as~\eqref{eq:opt_non_convex} in Section~\ref{sec:optimization_variable}. It operates in a batch and returns the lower and upper bounds for $n$ selected subdomains simultaneously: a lower bound is obtained by optimizing~\eqref{eq:opt_non_convex} using $\beta$-CROWN and an upper bound can be the network prediction $f(x^*)$ given the $x^*$ that minimizes~\eqref{eq:beta_crown_linear}\footnote{We want an upper bound of the objective in~\eqref{eq:nn_verify}. Since~\eqref{eq:nn_verify} is an minimization problem, any feasible $x$ produces an upper bound of the optimal objective. When \eqref{eq:nn_verify} is solved exactly as $f^*$ (such as in the case where all neurons are split), we have $f^*=\underline{f}=\overline{f}$. See also the discussions in Section I.1 of~\citet{DePalma2021}.}. Initially, we don't have any splits, so we only need to optimize $\hat{\alphavar}$ to obtain $\underline{f}$ for $x \in {\mathcal{C}}$ (Line 2). Then we utilize the power of GPUs to split in parallel and maintain a global set ${\mathbb{P}}$ storing all the sub-domains which does not satisfy $\underline{f}_{{\mathcal{C}}_i} < 0$ (Line 5-10). Specifically, $\mtt{batch\_pick\_out}$ extends branching strategy BaBSR~\citep{bunel2018unified} or FSB~\citep{de2021improved} in a parallel manner to select $n$ (batch size) sub-domains in ${\mathbb{P}}$ and determine the corresponding ReLU neuron to split for each of them. If the length of ${\mathbb{P}}$ is less than $n$, then we reduce $n$ to the length of ${\mathbb{P}}$. $\mtt{batch\_split}$ splits each selected ${\mathcal{C}}_i$ to two sub-domains ${\mathcal{C}}_i^l$ and ${\mathcal{C}}_i^u$ by forcing the selected unstable ReLU neuron to be positive and negative, respectively. $\mtt{Domain\_Filter}$ filters out verified sub-domains (proved with $\underline{f}_{{\mathcal{C}}_i} \geq 0$) and we insert the remaining ones to ${\mathbb{P}}$. The loop breaks if the property is proved ($\underline{f} \geq 0$), or a counter-example is found in any sub-domain ($\overline{f} < 0$), or the lower bound $\underline{f}$ and upper bound $\overline{f}$ are sufficiently close, or the length of sub-domains ${\mathbb{P}}$ reaches a desired threshold $\eta$ (maximum memory limit). \begin{algorithm}[t] \caption{$\beta$-CROWN with branch and bound for complete verification. \textcolor{brown}{Comments} are in brown. } \label{alg:bab} {\small \begin{algorithmic}[1] \State \textbf{Inputs}: $f$, ${\mathcal{C}}$, $n$ (batch size), $\delta$ (tolerance), $\eta$ (maximum length of sub-domains) % \State \textcolor{black}{($\underline{f}, \overline{f}) \gets {\mtt{optimized\_beta\_CROWN}}(f, [{\mathcal{C}}])$} \Comment{\textcolor{brown}{Initially there is no split, so optimization is done over $\hat{\alphavar}$}}\label{alg:initial_bound} \State ${\mathbb{P}} \gets \left[ (\underline{f}, \overline{f}, {\mathcal{C}}) \right]$ \Comment{\textcolor{brown}{${\mathbb{P}}$ is the set of all unverified sub-domains}} \While{$\underline{f} < 0$ \textbf{and} $\overline{f} \geq 0$ \textbf{and} $\overline{f} - \underline{f} > \delta$ \textbf{and} $\mtt{length({\mathbb{P}})} < \eta$} \State \textcolor{black}{$( {\mathcal{C}}_1, \dots, {\mathcal{C}}_n ) \gets \mtt{batch\_pick\_out}({\mathbb{P}}, n)$} \Comment{\textcolor{brown}{Pick sub-domains to split and removed them from ${\mathbb{P}}$}} \State \textcolor{black}{$\left[ {\mathcal{C}}_1^l, {\mathcal{C}}_1^u, \dots, {\mathcal{C}}_n^l, {\mathcal{C}}_n^u \right] \gets \mtt{batch\_split}( {\mathcal{C}}_1, \dots, {\mathcal{C}}_n)$} \Comment{\textcolor{brown}{Each ${\mathcal{C}}_i$ splits into two sub-domains ${\mathcal{C}}_i^l$ and ${\mathcal{C}}_i^u$}} % \State \textcolor{black}{$\left[ \underline{f}_{{\mathcal{C}}_1^l}, \overline{f}_{{\mathcal{C}}_1^l}, \underline{f}_{{\mathcal{C}}_1^u}, \overline{f}_{{\mathcal{C}}_1^u}, \dots, \underline{f}_{{\mathcal{C}}_n^l}, \overline{f}_{{\mathcal{C}}_n^l}, \underline{f}_{{\mathcal{C}}_n^u}, \overline{f}_{{\mathcal{C}}_n^u} \right]\gets {\mtt{optimized\_beta\_CROWN}}(f, \left[ {\mathcal{C}}_1^l, {\mathcal{C}}_1^u, \dots, {\mathcal{C}}_n^l, {\mathcal{C}}_n^u \right])$}\Comment{\textcolor{brown}{Compute lower and upper bounds by optimizing $\hat{\alphavar}$ and $\hat{\betavar}$ mentioned in Section~\ref{sec:optimization_variable} in a batch}}\label{alg:inner_loop} % \State ${\mathbb{P}} \leftarrow {\mathbb{P}} \bigcup \mtt{Domain\_Filter} \left( [\underline{f}_{{\mathcal{C}}_1^l}, \overline{f}_{{\mathcal{C}}_1^l}, {\mathcal{C}}_1^l], [\underline{f}_{{\mathcal{C}}_1^u}, \overline{f}_{{\mathcal{C}}_1^u}, {\mathcal{C}}_1^u], \dots, [\underline{f}_{{\mathcal{C}}_n^l}, \overline{f}_{{\mathcal{C}}_n^1}, {\mathcal{C}}_n^l], [\underline{f}_{{\mathcal{C}}_n^u}, \overline{f}_{{\mathcal{C}}_n^u}, {\mathcal{C}}_n^u] \right)$\Comment{\textcolor{brown}{Filter out verified sub-domains, insert the left domains back to ${\mathbb{P}}$}} \State $\underline{f} \gets \min\{\underline{f}_{{\mathcal{C}}_i}\ |\ (\underline{f}_{{\mathcal{C}}_i}, \overline{f}_{{\mathcal{C}}_i}, {\mathcal{C}}_i) \in {\mathbb{P}}\}$, $i = 1, \dots, n$ \Comment{\textcolor{brown}{To ease notation, ${{\mathcal{C}}_i}$ here indicates either ${{\mathcal{C}}_i^u}$ or ${{\mathcal{C}}_i^l}$}} \State $\overline{f} \gets \min\{\overline{f}_{{\mathcal{C}}_i}\ |\ (\underline{f}_{{\mathcal{C}}_i}, \overline{f}_{{\mathcal{C}}_i}, {\mathcal{C}}_i) \in {\mathbb{P}}\}$, $i = 1, \dots, n$ \EndWhile \State \textbf{Outputs:} $\underline{f}$, $\overline{f}$ % \end{algorithmic} } \end{algorithm} Note that for models evaluated in our paper, we find that computing intermediate layer bounds in every iteration at line~\ref{alg:inner_loop} is too costly (although it is possible and supported) so we only compute intermediate layer bounds once at line~\ref{alg:initial_bound}. At line~\ref{alg:inner_loop}, only the neuron with split constraints have their intermediate layer bounds updated, and other intermediate bounds are not recomputed. This makes the intermediate layer bounds looser but it allows us to quickly explore a large number of nodes on the branch and bound search tree and is overall beneficial for verifying most models. A similar observation was also found in~\citet{DePalma2021} (Section 5.1.1). \subsection{Comparisons to other GPU based complete verifiers} \label{app:gpu_comparison} \citet{Bunel2020} proposed to reformulate the linear programming problem in~\eqref{eq:lp_verify_split} through Lagrangian decomposition. \eqref{eq:lp_verify_split} is decomposed layer by layer, and each layer is solved with simple closed form solutions on GPUs. A Lagrangian is used to enforce the equality between the output of a previous layer and the input of a later layer. This optimization formulation has the same power as a LP (\eqref{eq:lp_verify_split}) under convergence. The main drawback of this approach is that it converges relatively slowly (it typically requires hundreds of iterations to converge to a solution similar to the solution of a LP), and it also cannot easily jointly optimize intermediate layer bounds. In Table~\ref{table:average_complete} (\textsc{Prox BaBSR}) and Figure~\ref{fig:rate_time_complete} (\textsc{BDD+ BaBSR}, which refers to the same method) we can see that this approach is relatively slow and has high timeout rates compared to other GPU accelerated complete verifiers. Recently, \citet{de2021improved} proposed a better branching strategy, filtered smart branching (FSB), to further improved verification performance of \citep{Bunel2020}, but the Lagrangian Decomposition based incomplete verifier and the branch and bound procedure stay the same. \citet{DePalma2021} used a tighter convex relaxation~\citep{anderson2020strong} than the typical LP formulation in~\eqref{eq:lp_verify_split} for the incomplete verifier. This tighter relaxation may contain exponentially many constraints, and \citet{DePalma2021} proposed to solve the verification problem in its dual form where each constraint becomes a dual variable. A small active set of dual variables is maintained during dual optimization to ensure efficiency. This tighter relaxation allows it to outperform~\citep{Bunel2020}, but it also comes with extra computational costs and difficulties for an efficient implementation (e.g.\ a ``masked'' forward/backward pass is needed which requires a customised low-level convolution implementation). Additionally, \citet{DePalma2021} did not optimize intermediate layer bounds jointly. \citet{xu2020fast} used CROWN~\citep{zhang2018efficient} (categorized as a linear relaxation based perturbation analysis (LiRPA) algorithm) as the incomplete solver in BaB. Since CROWN cannot encode neural split constraints, \citet{xu2020fast} essentially solve~\eqref{eq:lp_verify_split} \emph{without} neuron split constraints ($\z{i}{j} \geq 0, i \in \{1, \cdots, L-1\}, j \in \setzp{i}$ and $\z{i}{j} < 0, i \in \{1, \cdots, L-1\}, j \in \setzn{i}$) in~\eqref{eq:lp_verify_split}. The missing constraints lead to looser bounds and unnecessary branches. Additionally, using CROWN as the incomplete solver leads to incompleteness - even when all unstable ReLU neurons are split, \citet{xu2020fast} still cannot solve \eqref{eq:nn_verify} to a global minimum, so a LP solver has to be used to check inconsistent splits and guarantee completeness. Our $\beta$-CROWN BaB overcomes these drawbacks: we consider per-neuron split constraints in $\beta$-CROWN which reduces the number of branches and solving time (Table~\ref{table:average_complete}). Most importantly, $\beta$-CROWN with branch and bound is sound and complete (Theorem~\ref{thm:soundness_completeness}) and we do not rely on any LP solvers. Another difference between \citet{xu2020fast} and our method is the joint optimization of intermediate layer bounds (Section~\ref{sec:optimization_variable}). Although \citep{xu2020fast} also optimized intermediate layer bounds, they only optimize $\alphavar$ and do not have $\betavar$, and they share the same variable $\alphavar$ for all intermediate layer bounds and final bounds, with a total of $O(Ld)$ variables to optimize. Our analysis in Section~\ref{sec:optimization_variable} shows that there are in fact, $O(L^2 d^2)$ free variables to optimize, and we share less variables as in~\citet{xu2020fast}. This allows us to achieve tighter bounds and improve overall performance. \subsection{Detection of Infeasibility} \label{sec:infeasible} Maximizing~\eqref{eq:beta_crown_lp} with infeasible constraints leads to unbounded dual objective, which can be detected by checking if this optimized lower bound becomes \emph{greater than the upper bound} (which is also maintained in BaB, see Alg.1 in Sec.\ B.1). For the robustness verification problem, a subdomain that has lower bound greater than 0 is dropped, which includes the unbounded case. Due to insufficient convergence, this cannot always detect infeasibility, but it \emph{does not affect soundness}, as this infeasible subdomain only leads to worse overall lower bound in BaB. To guarantee \emph{completeness}, we show that when all unstable neurons are split the problem is concave (see Section~\ref{sec:proof_sound_complete}); in this case, we can use line search to guarantee convergence when feasible, and detect infeasibility if the objective exceeds the upper bound (line search guarantees the objective can eventually exceed upper bound). In most real scenarios, the verifier either finishes or times out before all unstable neurons are split. \section{Details on Experimental Setup and Results} \label{sec:app_exp} \subsection{Experimental Setup } We run our experiments on a machine with a single NVIDIA RTX 3090 GPU (24GB GPU memory), a AMD Ryzen 9 5950X CPU and 64GB memory. Our $\beta$-CROWN solver uses 1 CPU and 1 GPU only, except for the MLP models in Table~\ref{tab:verified_acc_eran} where 16 threads are used to compute intermediate layer bounds with Gurobi\footnote{Note that our $\beta$-CROWN verifier does not rely on MILP/LP solvers. For these very small MLP models, we find that a MILP solver can actually compute intermediate layer bounds pretty quickly and using these tighter intermediate bounds are quite helpful for $\beta$-CROWN. This also enables us to utilize both CPUs and GPUs on a machine. For all other models, intermediate layer bounds are computed through optimizing~\eqref{eq:opt_non_convex}. Practically, MILP is not scalable beyond these very small MLP models and these small models are not the main focus of this work.}. We use the Adam optimizer~\citep{kingma2014adam} to solve both $\hat{\alphavar}$ and $\hat{\betavar}$ in \eqref{eq:opt_non_convex} with 20 iterations. The learning rates are set as 0.1 and 0.05 for optimizing $\hat{\alphavar}$ and $\hat{\betavar}$ respectively. We decay the learning rates with a factor of 0.98 per iteration. To maximize the benefits of parallel computing on GPU, we use batch sizes $n=$1024 for Base (CIFAR-10), Wide (CIFAR-10), Deep (CIFAR-10), CNN-A-Adv (MNIST) and ConvSmall (MNIST), $n=$2048 for ConvSmall (CIFAR-10), $n=$4096 for CNN-A-Adv (CIFAR-10), CNN-A-Adv-4 (CIFAR-10), CNN-A-Mix (CIFAR-10) and CNN-A-Mix-4 (CIFAR-10), $n=$256 for CNN-B-Adv (CIFAR-10) and CNN-B-Adv-4 (CIFAR-10), $n=$1024 for ConvBig (MNIST), $n=$10 for ConvBig (CIFAR-10), $n=$8 for ResNet (CIFAR-10) respectively. The CNN-A-Adv, CNN-A-Adv-4, CNN-A-Mix, CNN-A-Mix-4, CNN-B-Adv and CNN-B-Adv-4 models are obtained from the authors or \citep{dathathri2020enabling} and are the same as the models used in their paper. We summarize the model structures in both incomplete verification and complete verification (Base, Wide and Deep) experiments in Table~\ref{tab:model_structres}. Our code is available at \url{http://PaperCode.cc/BetaCROWN}. \begin{table*}[h] \centering \caption{Model structures used in our experiments. For example, Conv(1, 16, 4) stands for a conventional layer with 1 input channel, 16 output channels and a kernel size of $4 \times 4$. Linear(1568, 100) stands for a fully connected layer with 1568 input features and 100 output features. We have ReLU activation functions between two consecutive layers.} \label{tab:model_structres} \scriptsize \begin{tabular}{c|c} \toprule Model name & Model structure \\ \midrule CNN-A-Adv (MNIST) & Conv(1, 16, 4) - Conv(16, 32, 4) - Linear(1568, 100) - Linear(100, 10)\\ ConvSmall (MNIST) & Conv(1, 16, 4) - Conv(16, 32, 4) - Linear(800, 100) - Linear(100, 10)\\ ConvBig (MNIST) & Conv(1, 32, 3) - Conv(32, 32, 4) - Conv(32, 64, 3) - Conv(64, 64, 4) - Linear(3136, 512) - \\ & Linear(512, 512) - Linear(512, 10)\\ ConvSmall (CIFAR-10) & Conv(3, 16, 4) - Conv(16, 32, 4) - Linear(1152, 100) - Linear(100, 10)\\ ConvBig (CIFAR-10) & Conv(3, 32, 3) - Conv(32, 32, 4) - Conv(32, 64, 3) - Conv(64, 64, 4) - Linear(4096, 512) - \\ & Linear(512, 512) - Linear(512, 10)\\ CNN-A-Adv/-4 (CIFAR-10) & Conv(3, 16, 4) - Conv(16, 32, 4) - Linear(2048, 100) - Linear(100, 10)\\ CNN-B-Adv/-4 (CIFAR-10)& Conv(3, 32, 5) - Conv(32, 128, 4) - Linear(8192, 250) - Linear(250, 10) \\ CNN-A-Mix/-4 (CIFAR-10) & Conv(3, 16, 4) - Conv(16, 32, 4) - Linear(2048, 100) - Linear(100, 10)\\ \midrule Base (CIFAR-10) & Conv(3, 8, 4) - Conv(8, 16, 4) - Linear(1024, 100) - Linear(100, 10) \\ Wide (CIFAR-10) & Conv(3, 16, 4) - Conv(16, 32, 4) - Linear(2048, 100) - Linear(100, 10) \\ Deep (CIFAR-10)& Conv(3, 8, 4) - Conv(8, 8, 3) - Conv(8, 8, 3) - Conv(8, 8, 4) - Linear(412, 100) - Linear(100, 10) \\ \bottomrule \end{tabular} \end{table*} \subsection{Additional Experiments} \label{app:additional_exp} \paragraph{More results on incomplete verification} In this paragraph we compare our $\beta$-CROWN FSB to many other incomplete verifiers. WK~\citep{wong2018provable} and CROWN~\citep{zhang2018efficient} are simple bound propagation methods; CROWN-OPT uses the joint optimization on intermediate layer bounds (optimizing~\eqref{eq:opt_non_convex} with no $\hat{\betavar}$, as done in~\citep{xu2020fast}). We also include triangle relaxation based LP verifiers with intermediate layer bounds obtained from WK, CROWN and CROWN-OPT. In our experiments in Table~\ref{fig:rate_time_complete}, we noticed that \textsc{BigM+A.Set BaBSR}~\citep{DePalma2021} and Fast-and-Complete~\citep{xu2020fast} are also very competitive among existing state-of-the-art complete verifiers\footnote{The concurrent work BaDNB (BDD+ FSB) does not have public available code when our paper was submitted.} - they runs fast in many cases with low timeout rates. Therefore, we also evaluate \textsc{BigM+A.Set BaBSR} and Fast-and-Complete with an early stop of 3 minutes for the incomplete verification setting as an extension of Section~\ref{sec:exp_incomplete}. The verified accuracy obtained from each method are reported in Table~\ref{tab:verified_acc_sdp_aset}. \textsc{BigM+A.Set BaBSR} and Fast-and-Complete sometimes produce better bounds than SDP-FO, however \textsc{$\beta$-CROWN FSB} consistently outperforms both of them. Additionally, we found that intermediate layer bounds are important for LP verifier on some models, although even with the tightest possible CROWN-OPT bounds the verified accuracy gap between LP verifiers and ours is still large. Additionally, LP verifiers need significantly more time. \paragraph{Additional results on the tightness of verification.} In Figure~\ref{fig:tightness_lp}, we include LP based verifiers as baselines and compare the lower bound from verification to the upper bound obtained by PGD. The LP verifiers use the triangle relaxations described in Section~\ref{sec:nn_verification_problem}, with intermediate layer bounds from WK~\citep{wong2018provable}, CROWN~\citep{zhang2018efficient} and CROWN with joint optimization on intermediate layer bounds (denoted as CROWN-OPT). We find that tighter intermediate layer bounds obtained by CROWN can greatly improve the performance of the LP verifier compared to those using looser ones obtained by~\citet{wong2018provable}. Furthermore, using intermediate layer bounds computed by joint optimization can achieve additional improvements. However, our branch and bound with $\beta$-CROWN can significantly outperform these LP verifiers. This shows that BaB is an effective approach for incomplete verification, outperforming the bounds produced by a single LP. \begin{table}[htb] \small \caption{{\bf Verified accuracy (\%)} and avg.\ per-example verification time (s) on 7 models from SDP-FO~\cite{dathathri2020enabling}. % } \setlength{\tabcolsep}{2.5pt} \centering \label{tab:verified_acc_sdp_aset} \adjustbox{max width=\textwidth}{ \begin{threeparttable}[hbt] \begin{tabular}{c|rr|rr|rr|rr|rr|rr|rr} \toprule Dataset & \multicolumn{2}{c|}{MNIST $\epsilon=0.3$} & \multicolumn{12}{c}{CIFAR $\epsilon=2/255$} \\ \midrule Model & \multicolumn{2}{c|}{CNN-A-Adv} & \multicolumn{2}{c|}{CNN-B-Adv} & \multicolumn{2}{c|}{CNN-B-Adv4} & \multicolumn{2}{c|}{CNN-A-Adv} & \multicolumn{2}{c|}{CNN-A-Adv4} & \multicolumn{2}{c|}{CNN-A-Mix} & \multicolumn{2}{c}{CNN-A-Mix4} \\ Methods & Verified\% & Time (s) & Ver.\% & Time(s) & Ver.\% & Time(s) & Ver.\% & Time(s) & Ver.\% & Time(s) & Ver.\% & Time(s) & Ver.\% & Time(s) \\ \midrule WK~\citep{wong2018provable} & 0 & 0.1 & 8.5 & 0.4 & 34.5 & 0.8 & 32.5 & 0.4 & 39.5 & 0.5 & 15.0 & 0.3 & 30.0 & 0.4 \\ CROWN~\citep{zhang2018efficient} & 1.0 & 0.1 & 21.5 & 0.5 & 43.5 & 0.9 & 35.5 & 0.6 & 41.5 & 0.7 & 23.5 & 0.4 & 38.0 & 0.5 \\ CROWN-OPT~\citep{xu2020fast} & 14.0 & 2.7 & 21.5 & 5.5 & 45.0 & 4.0 & 36.0 & 2.0 & 42.0 & 1.6 & 25.0 & 2.3 & 38.5 & 2.0\\ LP (WK)$^\mathsection$ & 0.5 & 16 & 14.5 & 612 & 41.0 & 1361 & 35.0 & 114 & 41.5 & 140 & 19.0 & 84 & 36.5 & 117 \\ LP (CROWN) & 3.5 & 22 & 21.5 & 941 & 45.0 & 1570 & 36.0 & 123 & 41.5 & 147 & 24.0 & 119 & 38.5 & 126 \\ LP (CROWN-OPT) & 14.0 & 40 & 21.5 & 977 & 45.0 & 1451 & 36.0 & 122 & 42.0 & 152 & 25.0 & 94.8 & 38.5 & 127\\ SDP-FO~\citep{dathathri2020enabling}$^*$ & 43.4 & $>$20h & 32.8 & $>$25h & 46.0 & $>$25h & 39.6 & $>$25h & 40.0 & $>$25h & 39.6 & $>$25h & 47.8 & $>$25h \\ PRIMA~\citep{muller2021precise} & 44.5 & 136 & 38.0 & 344 & 53.5 & 44 & 41.5 & 4.8 & 45.0 & 4.9 & 37.5$^\ddagger$ & 34 & 48.5 & 7.0 \\ {{BigM+A.Set}~\cite{DePalma2021}} & 63.0 & 117 & N/A$^\dagger$ & N/A & N/A & N/A & 41.0 & 79 & \textbf{46.0} & 39 & 30.0 & 122 & 47.0 & 71 \\ Fast-and-Complete$^\mathsection$ & {66.0} & 49 & {38.5} & 64 & {51.5} & 21 & {41.5} & 14 & \textbf{46.0} & 4.2 & {33.0} & 79 & {46.0} & 10 \\ $\beta$-CROWN FSB & \textbf{70.5} & 21 & \textbf{46.5} & 32 & \textbf{54.0} & 12 & \textbf{44.0} & 5.8 & \textbf{46.0} & 5.6 & \textbf{41.5} & 50 & \textbf{50.5} & 5.9 \\ \hline Upper Bound (PGD) & 76.5 & - & 65.0 & - & 63.0 & - & 50.0 & - & 49.5 & - & 53.0 & - & 57.5 & - \\ \bottomrule \end{tabular} \begin{tablenotes} \item [$^\mathsection$] Names in parentheses are methods to compute intermediate layer bounds for the LP verifier. \item [*] SDP-FO results are directly from their paper due to the very long running time. All other methods are tested on the same set of 200 examples. \item [$\dagger$] The implementation of {BigM+A.Set BaBSR} is not compatible with CNN-B-Adv and CNN-B-Adv4 models which have an convolution with asymmetric padding. \item [$\ddagger$] A recent version (Oct 26, 2021) of~\citep{muller2021precise} reported better results on CNN-A-Mix. We found that their results were produced on a selection of 100 data points, and reruning their method using the same command on the same set of 200 random examples as used in other methods in this table produces different results, as reported here. \item [$\mathsection$] We use our $\beta$-CROWN code and turn off $\beta$ optimization to emulate the algorithm used in~\citep{xu2020fast}. This in fact leads to better performance than the original approach in~\citep{xu2020fast} because we allow more $\alpha$ variables to be optimized and our implementation is generally better. \end{tablenotes} \end{threeparttable} } % \end{table} \begin{figure}[htb] \vspace{-5pt} \centering \caption{\small Verified lower bound on $\f(x)$ by $\beta$-CROWN FSB compared against incomplete LP verifiers using different intermediate layer bounds obtained from~\cite{wong2018provable} (denoted as LP (WK)), CROWN~\cite{zhang2018efficient} (denoted as LP (CROWN)), and jointly optimized intermediate bounds in~\eqref{eq:opt_non_convex} (denoted as LP (CROWN-OPT)), v.s.\ the adversarial upper bound on $\f(x)$ found by PGD. LPs need much longer time to solve than $\beta$-CROWN on CIFAR-10 models (see Table~\ref{tab:verified_acc_sdp_aset}). % } \includegraphics[width=.47\linewidth]{figures/mnist_a_adv_lp.pdf} \includegraphics[width=.47\linewidth]{figures/cifar_b_adv_lp.pdf} {\small (a) MNIST CNN-A-Adv, runner-up targets, $\epsilon=0.3$ \hspace{4mm} (b) CIFAR CNN-B-Adv, runner-up targets, $\epsilon=2/255$} \label{fig:tightness_lp} \end{figure} \paragraph{Lower bound improvements over time} In Figure~\ref{fig:convergence_time}, we plot lower bound values vs.\ time for \textsc{$\beta$-CROWN BaBSR} and \textsc{BigM+A.set BaBSR} (one of the most competitive methods in Table~\ref{table:average_complete}) on the CNN-A-Adv (MNIST) model. Figure~\ref{fig:convergence_time} shows that branch and bound can indeed quickly improve the lower bound, and our \textsc{$\beta$-CROWN BaBSR} is consistently faster than \textsc{BigM+A.set BaBSR}. In contrast, SDP-FO~\citep{dathathri2020enabling}, which typically requires 2 to 3 hours to converge, can only provide very loose bounds during the first 3 minutes of optimization (out of the range on these figures). \begin{figure} \centering \caption{For the CNN-A-Adv (MNIST) model, we randomly select four examples from the incomplete verification experiment and plot the lower bound v.s. time (in 180 seconds) of \textsc{$\beta$-CROWN BaBSR} and \textsc{BigM+A.set BaBSR}. Larger lower bounds are better. $\beta$-CROWN BaBSR improves bound noticeably faster in all four situations.} \label{fig:convergence_time} \includegraphics[width=0.24\textwidth]{figures/ConvergencePlot_1.pdf} \includegraphics[width=0.24\textwidth]{figures/ConvergencePlot_2.pdf} \includegraphics[width=0.24\textwidth]{figures/ConvergencePlot_3.pdf} \includegraphics[width=0.24\textwidth]{figures/ConvergencePlot_4.pdf} \end{figure} \begin{comment} \paragraph{Complete verification performance with averaged metrics} In Section~\ref{sec:exp} we presented the median of verification time in Table~\ref{fig:rate_time_complete}. We include mean verification time and number of branches in Table~\ref{table:average_complete}. The average verification time is heavily affected by timed out examples. For example, on the Deep model, our $\beta$-CROWN with BaBSR significantly outperforms other baselines by over 10X because we have no timeout. This comparison can be misleading because two factors are mixed: the efficiency of the verifier (reflected in verification time for \emph{most} examples) and the capability of the verifier (reflected in the capability of verifying hard examples and producing less timeouts). Instead, median runtime (with timeout rates also in consideration) and the cactus plots in Figure~\ref{fig:rate_time_complete} are more appropriate means to gauge the performance of each complete verifier. \begin{table*}[!hbt] \vspace{-5pt} \centering \caption{\small Median runtime and median number of branches on three models over 100 properties. We report the median because the average runtime significantly biases towards timed out samples (3600s) while most samples are solved by us within 10s, making the metric ineffective. \textsc{Fast-and-complete} is faster than many baselines but has a high timeout rate due to the lack of split constraint checking. Our $\beta$-CROWN \textsc{BaBSR} is faster than all baselines and also achieves low timeout rates. We include average metrics in Appendix~\ref{sec:app_exp}.} \label{table:median_complete} \small \setlength{\tabcolsep}{3pt} \begin{adjustbox}{max width=0.98\textwidth} \begin{tabular}{cccc|ccc|ccc} & \multicolumn{3}{ c }{CIFAR-10 Base} & \multicolumn{3}{ c }{CIFAR-10 Wide} & \multicolumn{3}{ c }{CIFAR-10 Deep} \\ \toprule \multicolumn{1}{ c| }{Method} & \multicolumn{1}{ c }{median time(s)} & \multicolumn{1}{ c }{branches} & \multicolumn{1}{ c| }{$\%$timeout} & \multicolumn{1}{ c }{median time(s)} & \multicolumn{1}{ c }{branches} & \multicolumn{1}{ c| }{$\%$timeout} & \multicolumn{1}{ c }{median time(s)} & \multicolumn{1}{ c }{branches} & \multicolumn{1}{ c }{$\%$timeout} \\ \cmidrule(lr){1-1} \cmidrule(lr){2-4} \cmidrule(lr){5-7} \cmidrule(lr){8-10} \multicolumn{1}{ c| }{\textsc{BaBSR}} &2421.03 &729 &36.00 &3490.12 &573 &49.00 &2982.27 &398 &39.00\\ \multicolumn{1}{ c| }{\textsc{MIPplanet}} &3600.00 &- &68.00 &3129.05 &- &46.00 &2606.58 &- &40.00\\ \multicolumn{1}{ c| }{\textsc{GNN-online}} &1198.55 &400 &33.00 &890.02 &281 &15.00 &793.91 &101 &4.00 \\ \multicolumn{1}{ c| }{\textsc{BDD+ BaBSR}} &16.01 &2866 &20.88 &30.05 &4414 &10.00 &15.53 &870 &4.00 \\ \multicolumn{1}{ c| }{\textsc{A.set BaBSR}} &39.74 &813 &{7.00} &27.68 &174 &{3.00} &45.96 &401 &2.00 \\ \multicolumn{1}{ c| }{\textsc{Big-M+A.set BaBSR}} &28.56 &2839 &{7.00} &40.84 &2123 &{3.00} &17.5 &955 &2.00 \\ \multicolumn{1}{ c| }{\textsc{Fast-and-Complete}} &8.85 &499 &17.00 &10.17 &354 &9.00 &10.28 &101 &1.00 \\ \multicolumn{1}{ c| }{\textsc{$\beta$-CROWN BaBSR}} &{8.80} &{325} &{7.00} &{8.36} &{99} &{3.00} &{7.47} &{59} &\textbf{0.00} \\ \multicolumn{1}{ c| }{\textsc{BDD+ FSB}} &\textbf{7.83} &{971} &{7.00} &\textbf{6.77} &{228} &{3.00} &\textbf{6.43} &119 &\textbf{0.00} \\ \multicolumn{1}{ c| }{\textsc{$\beta$-CROWN FSB}} &{8.46} &\textbf{251 } &\textbf{3.00} &{7.32} &\textbf{62} &\textbf{2.00} &6.94 &\textbf{27} &\textbf{0.00} \\ \bottomrule \end{tabular} \end{adjustbox} \vspace{-15pt} \end{table*} \end{comment} \paragraph{Ablation study of running time on GPUs and CPUs} We conduct the same experiments as in Table~\ref{table:average_complete} but run $\beta$-CROWN FSB on CPUs instead of GPUs. As shown in Table~\ref{table:cpu_ablation}, our method is strong even on a single CPU, showing that the good performance does not only come from GPU acceleration; our efficient algorithm also contributes to our success. On the other hand, using GPU can boost the performance by at least 2x. Importantly, the models evaluated in this table are very small ones. Massive parallelization on GPU will lead to more significant acceleration on larger models. The speedup on multi-core CPU is not obvious, possibly due to the limitation of underlying implementations of PyTorch. \begin{table*}[h] \centering \caption{\footnotesize Average runtime and average number of branches on three CIFAR-10 models over 100 properties (the same setting as in Table~\ref{table:average_complete}) by using different numbers of CPU cores, as well as using a single GPU. } \vspace{-5pt} \label{table:cpu_ablation} \scriptsize \setlength{\tabcolsep}{4.2pt} \begin{adjustbox}{center} \begin{threeparttable}[hbt] \begin{tabular}{crrr|rrr|rrr} & \multicolumn{3}{ c }{CIFAR-10 Base} & \multicolumn{3}{ c }{CIFAR-10 Wide} & \multicolumn{3}{ c }{CIFAR-10 Deep} \\ \toprule \multicolumn{1}{ c| }{Hardware} & \multicolumn{1}{ c }{time(s)} & \multicolumn{1}{ c }{branches} & \multicolumn{1}{ c| }{$\%$timeout} & \multicolumn{1}{ c }{time(s)} & \multicolumn{1}{ c }{branches} & \multicolumn{1}{ c| }{$\%$timeout} & \multicolumn{1}{ c }{time(s)} & \multicolumn{1}{ c }{branches} & \multicolumn{1}{ c }{$\%$timeout} \\ \cmidrule(lr){1-1} \cmidrule(lr){2-4} \cmidrule(lr){5-7} \cmidrule(lr){8-10} \multicolumn{1}{ r| }{{1 CPU}} &249.49 &7886.37 &4.00 &178.01 &2749.96 &4.00 &47.46 &41.12 &0.00\\ \multicolumn{1}{ r| }{{4 CPU}} & 228.28 & 9575.52 & 4.00 &172.55 &3956.17 &4.00 & 45.35 &41.12 &0.00\\ \multicolumn{1}{ r| }{{16 CPU}} & 222.71 & 10271.08 & 4.00 &172.40 &4087.15 &4.00 &43.97 &41.12 &0.00 \\ \multicolumn{1}{ r| }{{1 GPU}} &{118.23} &208018.21 &{3.00} &{78.32} &116912.57 &{2.00} &{5.69} &{41.12} &{0.00}\\ \bottomrule \end{tabular} \end{threeparttable} \end{adjustbox} \end{table*} \paragraph{Ablation study on the impact of $\alpha$, $\beta$, and their joint optimization} We conduct the same experiments as in Table~\ref{table:average_complete} but turn on or turn off $\alpha$ and $\beta$ optimization to see the contribution of each part. As shown in Table~\ref{table:opt_ablation}, optimizing both $\alpha$ and $\beta$ leads to optimal performance. Optimizing beta has a greater impact than optimizing $\alpha$. Joint optimization is helpful for CIFAR10-Base and CIFAR10-Wide models, reducing the overall runtime. For simple models like CIFAR10-Deep, disabling joint optimization can help slightly because this model is very easy to verify (within a few seconds) and using looser bounds reduces verification cost. \begin{table*}[h] \centering \caption{\footnotesize Ablation study on the CIFAR-10 Base, Wide and Deep models (the same setting as in Table~\ref{table:average_complete}), including combinations of optimizing or not optimizing $\alpha$ and/or $\beta$ variables, and using or not using joint optimization for intermediate layer bounds. } \vspace{-5pt} \label{table:opt_ablation} \scriptsize \setlength{\tabcolsep}{4.2pt} \begin{adjustbox}{center} \begin{threeparttable}[hbt] \begin{tabular}{ccc|rrr|rrr|rrr} \multicolumn{3}{ c }{}& \multicolumn{3}{ c }{CIFAR-10 Base} & \multicolumn{3}{ c }{CIFAR-10 Wide} & \multicolumn{3}{ c }{CIFAR-10 Deep} \\ \toprule joint opt & $\alpha$ & $\beta$ & \multicolumn{1}{ c }{time(s)} & \multicolumn{1}{ c }{branches} & \multicolumn{1}{ c| }{$\%$timeout} & \multicolumn{1}{ c }{time(s)} & \multicolumn{1}{ c }{branches} & \multicolumn{1}{ c| }{$\%$timeout} & \multicolumn{1}{ c }{time(s)} & \multicolumn{1}{ c }{branches} & \multicolumn{1}{ c }{$\%$timeout} \\ \cmidrule(lr){1-3} \cmidrule(lr){4-6} \cmidrule(lr){7-9} \cmidrule(lr){10-12} & $\checkmark$ & & 233.86 & 233233.70 & 6.00 &148.46 &113017.10 &4.00 &5.77 &260.18 &0.00\\ & & $\checkmark$ & 174.10 & 163037.05 & 4.00 & 102.65 &86571.18 &2.00 & 5.73 & 134.76 &0.00\\ & $\checkmark$ & $\checkmark$ &139.83 &133346.44 &3.00 &91.01 &73713.30 &2.00 &5.22 &100.44 &0.00\\ \cmidrule(lr){1-3} \cmidrule(lr){4-6} \cmidrule(lr){7-9} \cmidrule(lr){10-12} $\checkmark$ & $\checkmark$ & & 163.69 & 160058.80 & 4.00 &149.00 &115509.71 &4.00 &8.58 &65.70 &0.00\\ $\checkmark$ & & $\checkmark$ & 162.95 & 150631.49 & 4.00 &89.22 &72479.96 &2.00 &8.38 &52.26 &0.00 \\ $\checkmark$ & $\checkmark$ & $\checkmark$ &{118.23} &208018.21 &{3.00} &{78.32} &116912.57 &{2.00} &{5.69} &{41.12} &{0.00}\\ \bottomrule \end{tabular} \end{threeparttable} \end{adjustbox} \end{table*} \section{Proofs for $\beta$-CROWN} \label{ref:app_proof} \subsection{Proofs for deriving $\beta$-CROWN using bound propagation} \label{subsec:primal_proof} Lemma~\ref{lemma:relax_single} is from part of the proof of the main theorem in~\citet{zhang2018efficient}. Here we present it separately to use it as an useful subprocedure for our later proofs. \begin{customlemma}{\ref{lemma:relax_single}}[Relaxation of a ReLU layer in CROWN] Given two vectors $w, v \in \mathbb{R}^d, \bl \leq v \leq \bu$ (element-wise), we have \[ w^\top \mathrm{ReLU}(v) \geq w^\top \D v + b^\prime, \] where $\D$ is a diagonal matrix defined as: \begin{equation} \D_{j,j} = \begin{cases} 1, & \text{if $\bl_j \geq 0$} \\ 0, & \text{if $\bu_j \leq 0$} \\ \alphavar_j, & \text{if $\bu_j > 0 > \bl_j$ and $w_j \geq 0$} \\ \frac{\bu_j}{\bu_j - \bl_j}, & \text{if $\bu_j > 0 > \bl_j$ and $w_j < 0$}, \end{cases} \label{eq:relax_single_d} \end{equation} $0 \leq \alphavar_j \leq 1$ are free variables, $b^\prime = w^\top \lowerb$ and each element in $\lowerb$ is \begin{equation} \lowerb_j = \begin{cases} 0, & \text{if $\bl_j > 0$ or $\bu_j \leq 0$} \\ 0, & \text{if $\bu_j > 0 > \bl_j$ and $w_j \geq 0$} \\ -\frac{\bu_j \bl_j}{\bu_j - \bl_j}, & \text{if $\bu_j > 0 > \bl_j$ and $w_j < 0$}. \end{cases} \label{eq:relax_single_b} \end{equation} \end{customlemma} \begin{proof} For the $j$-th ReLU neuron, if $\bl_j \geq 0$, then $\mathrm{ReLU}(v_j)=v_j$; if $\bu_j < 0$, then $\mathrm{ReLU}(v_j)=0$. For the case of $\bl_j < 0 < \bu_j$, the $\mathrm{ReLU}$ function can be linearly upper and lower bounded within this range: \[ \alphavar_j v_j \leq \mathrm{ReLU}(v_j) \leq \frac{\bu_{j}}{\bu_{j} - \bl_{j}} \left (v_j - \bl_{j} \right ) \quad \forall \ \bl_j \leq v_j \leq \bu_j \] where $0 \leq \alphavar_j \leq 1$ is a free variable - any value between 0 and 1 produces a valid lower bound. To lower bound $w^\top \mathrm{ReLU}(v) = \sum_j w_j \mathrm{ReLU}(v_j)$, for each term in this summation, we take the lower bound of $\mathrm{ReLU}(v_j)$ if $w_j$ is positive and take the upper bound of $\mathrm{ReLU}(v_j)$ if $w_j$ is negative (reflected in the definitions of $\D$ and $\lowerb$). This conservative choice allows us to always obtain a lower bound $\forall \ \bl \leq v \leq \bu$: \[ \sum_j w_j \mathrm{ReLU}(v_j) \geq \sum_j w_j \left ( \D_{j,j} v_j + \lowerb_j \right ) = w^\top \D v + w^\top \lowerb = w^\top \D v + b^\prime \] where $\D_{j,j}$ and $\lowerb_j$ are defined in \eqref{eq:relax_single_d} and \eqref{eq:relax_single_b} representing the lower or upper bounds of ReLU. \end{proof} Before proving our main theorem (Theorem~\ref{thm:beta_CROWN}), we first define matrix $\AA$, which is the product of a series of model weights $\W$ and ``weights'' for relaxed ReLU layers $\D$: \begin{definition} Given a set of matrices $\W{2}, \cdots, \W{L}$ and $\D{1}, \cdots, \D{L-1}$, we define a recursive function $\AA{k}{i}$ for $1 \leq i \leq k \leq L$ as \[ \AA{i} = \bm{I}, \ \AA{k\!+\!1}{i} = \W{k+1} \D{k} \AA{k}{i} \] \end{definition} For example, $\AA{3}{1}=\W{3}\D{2}\W{2}\D{1}$, $\AA{5}{2}=\W{5}\D{4}\W{4}\D{3}\W{3}\D{2}$. Now we present our main theorem with each term explicitly written: \begin{customthm}{\ref{thm:beta_CROWN}}[$\beta$-CROWN bound] \label{thm:beta_CROWN_full} Given a $L$-layer neural network $f(x): \mathbb{R}^{d_0} \rightarrow \mathbb{R}$ with weights $\W{i}$, biases $\bias{i}$, pre-ReLU bounds $\bl{i} \leq \z{i} \leq \bu{i}$ ($1 \leq i \leq L$), input constraint ${\mathcal{C}}$ and split constraint $\setz$. We have \begin{equation} \min_{\substack{x \in {\mathcal{C}}, z \in \setz}} f(x) \geq \max_{\betavar \geq 0} \min_{x \in {\mathcal{C}}} (\aaa + \bbb \betavar)^\top x + \ccc^\top \betavar + \constc, \label{eq:beta_crown_linear_app} \end{equation} where $\bbb \in \mathbb{R}^{d_0 \times (\sum_{i=1}^{L-1} {d_i})}$ is a matrix containing blocks $\bbb:=\left [ \bbb{1}^\top \ \bbb{2}^\top \ \cdots \ \bbb{L-1}^\top \right ]$, $\ccc \in \mathbb{R}^{\sum_{i=1}^{L-1} d_i}$ is a vector $\ccc := \left [ \ccc{1}^\top \ \cdots \ \ccc{L-1}^\top \right ]^\top$, and each term is defined as: \begin{equation} \aaa = \left [ \AA{L}{1} \W{1} \right ]^\top \in \mathbb{R}^{d_0 \times 1} \end{equation} \begin{equation} \bbb{i} = \S{i} \AA{i}{1} \W{1} \in \mathbb{R}^{d_i \times d_0}, \quad \forall \ 1 \leq i \leq L-1 \end{equation} \begin{equation} \ccc{i} = \sum_{k=1}^{i} \S{i} \AA{i}{k} \bias{k} + \sum_{k=2}^{i} \S{i} \AA{i}{k} \W{k} \lowerb{k-1} \in \mathbb{R}^{d_i}, \quad \forall \ 1 \leq i \leq L-1 \end{equation} \begin{equation} \constc = \sum_{i=1}^{L} \AA{L}{i} \bias{i} + \sum_{i=2}^{L} \AA{L}{i} \W{i} \lowerb{i-1} \end{equation} diagonal matrices $\D{i}$ and vector $\lowerb{i}$ are determined by the relaxation of ReLU neurons, and $\A{i} \in \mathbb{R}^{1 \times d_i}$ represents the linear relationship between $f(x)$ and $\hz{i}$. $\D{i}$ and $\lowerb{i}$ depend on $\A{i}$, $\bl{i}$ and $\bu{i}$: \begin{equation} \D{i}{j,j} = \begin{cases} 1, & \text{if $\bl{i}{j} \geq 0$ or $j \in \setzp{i}$} \\ 0, & \text{if $\bu{i}{j} \leq 0$ or $j \in \setzn{i}$}\\ \alphavar_j, & \text{if $\bu{i}{j} > 0 > \bl{i}{j}$ and $j \notin \setzp{i} \cup \setzn{i}$ and $\A{i}{1,j} \geq 0$} \\ \frac{\bu_j}{\bu_j - \bl_j}, & \text{if $\bu{i}{j} > 0 > \bl{i}{j}$ and $j \notin \setzp{i} \cup \setzn{i}$ and $\A{i}{1,j} < 0$} \end{cases} \label{eq:definition_D} \end{equation} \begin{equation} \lowerb{i}{j} = \begin{cases} 0, & \text{if $\bl{i}{j} > 0$ or $\bu{i}{j} \leq 0$ or $j \in \setzp{i} \cup \setzn{i}$} \\ 0, & \text{if $\bu{i}{j} > 0 > \bl{i}{j}$ and $j \notin \setzp{i} \cup \setzn{i}$ and $\A{i}{1,j} \geq 0$} \\ -\frac{\bu{i}{j} \bl{i}{j}}{\bu{i}{j} - \bl{i}{j}}, & \text{if $\bu{i}{j} > 0 > \bl{i}{j}$ and $j \notin \setzp{i} \cup \setzn{i}$ and $\A{i}{1,j} < 0$} \end{cases} \label{eq:definition_lowerb} \end{equation} \begin{equation} \A{i} = \begin{cases} \W{L}, & i = L - 1 \\ (\A{i+1} \D{i+1} + \betavar{i+1}^\top \S{i+1}) \W{i+1}, & 0 \leq i \leq L - 2 \end{cases} \label{eq:definition_A} \end{equation} \end{customthm} \begin{proof} We prove this theorem by induction: assuming we know the bounds with respect to layer $\hz{m}$, we derive bounds for $\hz{m-1}$ until we reach $m=0$ and by definition $\hz{0} = x$. We first define a set of matrices and vectors $\aaa{m}$, $\bbb{}{m}$, $\ccc{}{m}$, $\constc{m}$, where $\bbb{}{m} \in \mathbb{R}^{d_m \times (\sum_{i=m+1}^{L-1} {d_i})}$ is a matrix containing blocks $\bbb:=\left [ \bbb{m+1}{m}^\top \ \cdots \ \bbb{L-1}{m}^\top \right ]$, $\ccc \in \mathbb{R}^{\sum_{i=m+1}^{L-1} d_i}$ is a vector $\ccc := \left [ \ccc{m+1}{m}^\top \ \cdots \ \ccc{L-1}{m}^\top \right ]^\top$, and each term is defined as: \begin{equation} \aaa{m} = \left [ \AA{L}{m+1} \W{m+1} \right ]^\top \in \mathbb{R}^{d_{m} \times 1} \label{eq:aaa_m} \end{equation} \begin{equation} \bbb{i}{m} = \S{i} \AA{i}{m+1} \W{m+1} \in \mathbb{R}^{d_i \times d_m}, \quad \forall \ m+1 \leq i \leq L-1 \label{eq:bbb_m} \end{equation} \begin{equation} \ccc{i}{m} = \sum_{k=m+1}^{i} \S{i} \AA{ i}{k} \bias{k} + \sum_{k=m+2}^{i} \S{i} \AA{i}{k} \W{k} \lowerb {k-1} \in \mathbb{R}^{d_m}, \quad \forall \ m+1 \leq i \leq L-1 \label{eq:ccc_m} \end{equation} \begin{equation} \constc{m} = \sum_{i=m+1}^{L} \AA{L}{i} \bias{i} + \sum_{i=m+2}^{L} \AA{L}{i} \W{i} \lowerb{i-1} \label{eq:constc_m} \end{equation} and we claim that \begin{equation} \min_{\substack{x \in {\mathcal{C}} \\ z \in \setz}} f(x) \geq \max_{\tbetavar{m+1} \geq 0} \min_{\substack{x \in {\mathcal{C}} \\ \tz{m} \in \tsetz{m}}} (\aaa{m} + \bbb{}{m} \tbetavar{m+1})^\top \hz{m} + \ccc{}{m}^\top \tbetavar{m+1} + \constc{m} \label{eq:proof_layer_m} \end{equation} where $\tbetavar{m+1} := \left [ \betavar{m+1}^\top \cdots \betavar{L-1}^\top \right ]^\top$ concatenating all $\betavar{i}$ variables up to layer $m+1$. For the base case $m = L-1$, we simply have \[ \begin{split} \min_{\substack{x \in {\mathcal{C}}, z \in \setz}} f(x) = \min_{\substack{x \in {\mathcal{C}}, z \in \setz}} \W{L} \hz{L-1} + \bias{L}. \end{split} \] No maximization is needed and $\aaa{m}=\left[\AA{L}{L} \W{L}\right]^\top = {\W{L}}^\top$, $\constc{m}=\sum_{i=L}^{L} \AA{L}{i} \bias{i}=\bias{L}$. Other terms are zero. In Section~\ref{sec:beta_crown_primal} we have shown the intuition of the proof by demonstrating how to derive the bounds from layer $\hz{L-1}$ to $\hz{L-2}$. The case for $m=L-2$ is presented in~\eqref{eq:layer_L_2}. Now we show the induction from $\hz{m}$ to $\hz{m-1}$. Starting from~\eqref{eq:proof_layer_m}, since $\hz{m} = \mathrm{ReLU}(\z{m})$ we apply Lemma~\ref{lemma:relax_single} by setting $w = \left[\aaa{m} + \bbb{}{m} \tbetavar{m+1}\right]^\top := \A{m}$. It is easy to show that $\A{m}$ can also be equivalently and recursively defined in~\eqref{eq:definition_A} (see Lemma~\ref{lemma:connection}). Based on Lemma~\ref{lemma:relax_single} we have $\D{m}$ and $\lowerb{m}$ defined as in~\eqref{eq:definition_D} and~\eqref{eq:definition_lowerb}, so~\eqref{eq:proof_layer_m} becomes \begin{equation} \begin{split} \min_{\substack{x \in {\mathcal{C}} \\ z \in \setz}} f(x) \geq \max_{\tbetavar{m+1} \geq 0} &\min_{\substack{x \in {\mathcal{C}} \\ \tz{m} \in \tsetz{m}}} (\aaa{m} + \bbb{}{m}\tbetavar{m+1})^\top \D{m} \z{m} \\ &\quad+(\aaa{m} + \bbb{}{m}\tbetavar{m+1})^\top \lowerb{m} + \ccc{}{m}^\top \tbetavar{m+1} + \constc{m} \end{split} \label{eq:proof_layer_m_next_2} \end{equation} Note that when we apply Lemma~\ref{lemma:relax_single}, for $j \in \setzp{i}$ (positive split) we simply treat the neuron $j$ as if $\bl{i}{j} \geq 0$, and for $j \in \setzn{i}$ (negative split) we simply treat the neuron $j$ as if $\bu{i}{j} \leq 0$. Now we add the multiplier $\betavar{m}$ to $\z{m}$ to enforce per-neuron split constraints: \begin{alignat*}{2} \min_{\substack{x \in {\mathcal{C}} \\ z \in \setz}} f(x) & \geq \max_{\tbetavar{m+1} \geq 0} \min_{\substack{x \in {\mathcal{C}} \\ \tz{m-1} \in \tsetz{m-1}}} \max_{\betavar{m} \geq 0} & (\aaa{m} + \bbb{}{m}\tbetavar{m+1})^\top \D{m} \z{m} + \betavar{m}^\top \S{m} \z{m} \\ & &+ (\aaa{m} + \bbb{}{m}\tbetavar{m+1})^\top \lowerb{m} + \ccc{}{m}^\top \tbetavar{m+1} + \constc{m} \\ & \geq \max_{\tbetavar{m} \geq 0} \min_{\substack{x \in {\mathcal{C}} \\ \tz{m-1} \in \tsetz{m-1}}} & (\aaa{m}^\top\D{m} + \tbetavar{m+1}^\top {\bbb{}{m}}^\top\D{m} + \betavar{m}^\top \S{m}) \z{m} \\ & &+ (\aaa{m} + \bbb{}{m}\tbetavar{m+1})^\top \lowerb{m} + \ccc{}{m}^\top \tbetavar{m+1} + \constc{m} \end{alignat*} Similar to what we did in~\eqref{eq:layer_activation}, we swap the $\min$ and $\max$ in the second inequality due to weak duality, such that every maximization on $\betavar{i}$ is before $\min$. Then, we substitute $\hz{m}=\W{m}\hz{m-1} + \bias{m}$ and obtain: \begin{alignat*}{2}\small \min_{\substack{x \in {\mathcal{C}} \\ z \in \setz}} f(x) & \geq \max_{\tbetavar{m} \geq 0} \min_{\substack{x \in {\mathcal{C}} \\ \tz{m-1} \in \tsetz{m-1}}} (\aaa{m}^\top\D{m} + \tbetavar{m+1}^\top {\bbb{}{m}}^\top\D{m} + \betavar{m}^\top \S{m})^\top \W{m} \hz{m-1} \\ &\quad+ (\aaa{m}^\top\D{m} + \tbetavar{m+1}^\top {\bbb{}{m}}^\top\D{m} + \betavar{m}^\top \S{m})^\top\bias{m} \\ &\quad+ (\aaa{m} + \bbb{}{m}\tbetavar{m+1})^\top \lowerb{m} + \ccc{}{m}^\top \tbetavar{m+1} + \constc{m} \\ & = \left [ \underbrace{\left[\aaa{m}^\top\D{m}\W{m}\right]^\top}_{\aaa^\prime} + \underbrace{(\tbetavar{m+1}^\top {\bbb{}{m}}^\top\D{m}\W{m} + \betavar{m}^\top \S{m}\W{m})}_{\bbb^\prime\tbetavar{m}} \right ]^\top \hz{m-1} \\ &\quad+ \underbrace{\left ( ({\bbb{}{m}}^\top\D{m} \bias{m} + {\bbb{}{m}}^\top \lowerb{m} + \ccc{}{m})^\top \tbetavar{m+1} + (\S{m} \bias{m})^\top \betavar{m} \right )}_{{\ccc^\prime}^\top \tbetavar{m}} \\ &\quad+ \underbrace{{\aaa{m}}^\top\D{m} \bias{m} + \aaa{m}^\top \lowerb{m} + \constc{m}}_{\constc^\prime} \end{alignat*} \normalsize Now we evaluate each term $\aaa^\prime$, $\bbb^\prime$, $\ccc^\prime$ and $\constc^\prime$ and show the induction holds. For $\aaa^\prime$ and $\ccc^\prime$ we have: \[ \aaa^\prime = \left[\aaa{m}^\top\D{m}\W{m}\right]^\top = \left[\AA{L}{m+1} \W{m+1} \D{m}\W{m}\right]^\top = \left[\AA{L}{m} \W{m}\right]^\top = \aaa{m-1} \] \begin{align*} \constc^\prime &= \constc{m} + \AA{L}{m+1} \W{m+1} \D{m}\bias{m} + \AA{L}{m+1} \W{m+1} \lowerb{m} \\ &= \sum_{i=m+1}^{L} \AA{L}{i} \bias{i} + \sum_{i=m+2}^{L} \AA{L}{i} \W{i} \lowerb{i-1} + \AA{L}{m}\bias{m} + \AA{L}{m+1} \W{m+1} \lowerb{m}\\ &= \sum_{i=m}^{L} \AA{L}{i} \bias{i} + \sum_{i=m+1}^{L} \AA{L}{i} \W{i} \lowerb{i-1} \\ &= \constc{m-1} \end{align*} For $\bbb^\prime := \left [ \bbb^\prime_{m}{}^\top \ \cdots \ \bbb^\prime_{L-1}{}^\top \right ]$, we have a new block $\bbb^\prime_{m}$ where \[ \bbb^\prime_{m} = \S{m}\W{m} = \S{m} \AA{m}{m} \W{m} = \bbb{m}{m-1} \] for other blocks where $m+1 \leq i \leq L-1$, \[ \bbb^\prime_{i} = \bbb{i}{m}\D{m}\W{m} = \S{i} \AA{i}{m+1} \W{m+1}\D{m}\W{m} = \S{i}\AA{i}{m}\W{m} = \bbb{i}{m-1} \] For $\ccc^\prime := \left [ \ccc^\prime_{m}{}^\top \ \cdots \ \ccc^\prime_{L-1}{}^\top \right ]$, we have a new block $\ccc^\prime_{m}$ where \[ \ccc^\prime_{m} = \S{m}\bias{m} = \sum_{k=m}^{m} \S{i} \AA{i}{k} \bias{i} = \ccc{m}{m-1} \] for other blocks where $m+1 \leq i \leq L-1$, \begin{align*}\small \ccc^\prime_{i} &= \ccc{i}{m} + {\bbb{}{m}}^\top\D{m} \bias{m} + {\bbb{}{m}}^\top \lowerb{m} \\ &= \sum_{k=m+1}^{i} \S{i} \AA{ i}{k} \bias{k} + \sum_{k=m+2}^{i} \S{i} \AA{i}{k} \W{k} \lowerb {k-1} + \bbb{}{m}^\top\D{m} \bias{m} + \bbb{}{m}^\top \lowerb{m} \\ &= \sum_{k=m+1}^{i} \S{i} \AA{ i}{k} \bias{k} + \sum_{k=m+2}^{i} \S{i} \AA{i}{k} \W{k} \lowerb {k-1} \\ &\quad+ \S{i} \AA{i}{m+1} \W{m+1}\D{m} \bias{m} + \S{i} \AA{i}{m+1} \W{m+1} \lowerb{k} \\ &= \sum_{k=m+1}^{i} \S{i} \AA{ i}{k} \bias{k} + \sum_{k=m+2}^{i} \S{i} \AA{i}{k} \W{k} \lowerb {k-1} + \S{i} \AA{i}{m} \bias{m} \\ &\quad+ \S{i} \AA{i}{m+1} \W{m+1} \lowerb{m} \\ &= \sum_{k=m}^{i} \S{i} \AA{ i}{k} \bias{k} + \sum_{k=m+1}^{i} \S{i} \AA{i}{k} \W{k} \lowerb {k-1} \\ &= \ccc{i}{m-1} \end{align*} Thus, $\aaa^\prime = \aaa{m-1}$, $\bbb^\prime = \bbb{}{m-1}$, $\ccc^\prime = \ccc{}{m-1}$ and $\constc^\prime = \constc{m-1}$ so the induction holds for layer $\hz{m-1}$: \begin{equation} \min_{\substack{x \in {\mathcal{C}} \\ z \in \setz}} f(x) \geq \max_{\tbetavar{m} \geq 0} \min_{\substack{x \in {\mathcal{C}} \\ \tz{m-1} \in \tsetz{m-1}}} (\aaa{m-1} + \bbb{}{m-1}\tbetavar{m})^\top \hz{m-1} + \ccc{}{m-1}^\top \tbetavar{m}+ \constc{m-1} \label{eq:proof_layer_m_1} \end{equation} Finally, Theorem~\ref{thm:beta_CROWN} becomes the special case where $m = 0$ in~\eqref{eq:aaa_m}, \eqref{eq:bbb_m}, \eqref{eq:ccc_m} and \eqref{eq:constc_m}. \end{proof} The next Lemma unveils the connection with CROWN~\citep{zhang2018efficient} and is also useful for drawing connections to the dual problem. \begin{lemma} \label{lemma:connection} With $\D$, $\lowerb$ and $\A$ defined in~\eqref{eq:definition_D}, \eqref{eq:definition_lowerb} and \eqref{eq:definition_A}, we can rewrite~\eqref{eq:beta_crown_linear_app} in Theorem~\ref{thm:beta_CROWN} as: \begin{equation} \label{eq:eq_a} \min_{\substack{x \in {\mathcal{C}} \\ z \in \setz}} f(x) \geq \max_{\betavar \geq 0} \min_{x \in {\mathcal{C}}} \A{0} x + \sum_{i=1}^{L-1} \A{i} (\D{i} \bias{i} + \lowerb{i}) \end{equation} where $\A{i}$, $0 \leq i \leq L-1$ contains variables $\betavar$. \end{lemma} \begin{proof} To prove this lemma, we simply follow the definition of $\A{i}$ and check the resulting terms are the same as~\eqref{eq:beta_crown_linear_app}. For example, \begin{align*} \A{0} &= (\A{1} \D{1} + \betavar{1}^\top \S{1}) \W{1} \\ &=\A{1} \D{1} \W{1} + \betavar{1}^\top \S{1} \W{1} \\ &= (\A{2} \D{2} + \betavar{2}^\top \S{2}) \W{2} \D{1} \W{1} + \betavar{1}^\top \S{1} \W{1} \\ &= \A{2} \D{2} \W{2} \D{1} \W{1} + \betavar{2}^\top \S{2} \W{2} \D{1} \W{1} + \betavar{1}^\top \S{1} \W{1} \\ &= \cdots \\ &= \AA{L}{1} \W{1} + \sum_{i=1}^{L-1} \betavar{i}^\top \S{i} \AA{i}{1} \W{1}\\ &= \left[\aaa + \bbb\betavar \right]^\top \end{align*} Other terms can be shown similarly. \end{proof} With this definition of $\A$, we can see~\eqref{eq:beta_crown_linear_app} as a modified form of CROWN, with an extra term $\betavar{i+1}^\top \S{i+1}$ added when computing $\A{i}$. When we set $\betavar=0$, we obtain the same bound propagation rule for $\A$ as in CROWN. Thus, only a small change is needed to implement $\beta$-CROWN given an existing CROWN implementation: we add $\betavar{i+1}^\top \S{i+1}$ after the linear bound propagates backwards through a ReLU layer. We also have the same observation in the dual space, as we will show this connection in the next subsection. \subsection{Proofs for the connection to the dual space} \begin{customthm}{\ref{thm:objective_dual}} The objective $d_{\text{LP}}$ for the dual problem of~\eqref{eq:lp_verify_split} can be represented as \[ d_{\text{LP}} = -\|\aaa + \bbb\betavar\|_1 \cdot \epsilon + (\bbb^\top x_0 + \ccc)^\top\betavar + \aaa^\top x_0 + c, % \] where $\aaa$, $\bbb$, $\ccc$ and $c$ are defined in the same way as in Theorem~\ref{thm:beta_CROWN}, and $\betavar \geq 0$ corresponds to the dual variables of neuron split constraints in~\eqref{eq:lp_verify_split}. \end{customthm} \begin{proof} To prove the Theorem~\ref{thm:objective_dual}, we demonstrate the detailed dual objective $d_{\text{LP}}$ for~\eqref{eq:lp_verify_split}, following a construction similar to the one in ~\citet{wong2018provable}. We first associate a dual variable for each constraint involved in~\eqref{eq:lp_verify_split} including dual variables $\betavar$ for the per-neuron split constraints introduced by BaB. Although it is possible to directly write the dual LP for~\eqref{eq:lp_verify_split}, for easier understanding, we first rewrite the original primal verification problem into its Lagrangian dual form as~\eqref{eq:beta_dual}, with dual variables $\nuvar, \xivar^+, \xivar^- \muvar, \gammavar, \lambdavar, \betavar$: \begin{equation} \begin{aligned}\relax &L(\z,\hz;\nuvar, \xivar, \muvar,\gammavar,\lambdavar,\betavar) = \z{L}+ \sum_{i=1}^{L}{\nuvar{i}}^\top(\z{i}-\W{i}\hz{i-1}-\bias{i})\\ &\quad + {\xivarp}^\top (\hz{0}-x_0-\epsilon)+{\xivarn}^\top (-\hz{0}+x_0-\epsilon)\\ &\quad+ \sum_{i=1}^{L-1}\sum_{\substack{j \notin \setzp{i}\bigcup\setzn{i} \\ \bl{i}{j}<0<\bu{i}{j}}} \left[ {\muvar{i}{j}}^\top (-\hz{i}{j})+ {\gammavar{i}{j}}^\top (\z{i}{j}-\hz{i}{j}) + {\lambdavar{i}{j}}^\top (-\bu{i}{j}\z{i}{j}+(\bu{i}{j}-\bl{i}{j})\hz{i}{j}+\bu{i}{j}\bl{i}{j}) \right]\\ &\quad+ \sum_{i=1}^{L-1} \left[ \sum_{\z{i}{j}\in\setzn{i}} \betavar^{(i)}_j \z{i}{j} + \sum_{\z{i}{j}\in\setzp{i}} -\betavar^{(i)}_j \z{i}{j}\right]\\ & \text{Subject to:}\\ % % & \quad \xivar^+\geq 0, \xivar^-\geq 0, \muvar\geq 0, \gammavar\geq 0, \lambdavar\geq 0, \betavar \geq 0 \end{aligned} \label{eq:beta_dual} \end{equation} The original minimization problem then becomes: \[ \max_{\nuvar, \xivar^+, \xivar^-, \muvar,\gammavar,\lambdavar,\betavar}\min_{\z, \hz}L(\z,\hz,\nuvar, \xivar^+, \xivar^-, \muvar,\gammavar,\lambdavar, \betavar) \] Given fixed intermediate bounds $\bl, \bu$, the inner minimization is a linear optimization problem and we can simply transfer it to the dual form. To further simplify the formula, we introduce notations similar to those in~\citep{wong2018provable}, where $\hnuvar{i-1}={\W{i}}^\top\nuvar{i}$ and $\alphavar{i}{j}=\frac{\gammavar{i}{j}}{\muvar{i}{j}+\gammavar{i}{j}}$. Then the dual form can be written as~\eqref{eq:final_beta_dual}. \begin{equation} \begin{aligned}\relax &\max_{0\leq\alphavar\leq1, \betavar\geq0} g(\alphavar, \betavar), \text{ where }\\ & g(\alphavar, \betavar) = -\sum_{i=1}^{L}\nuvar{i}^\top\bias{i}-\hnuvar{0}^\top x_0-||\hnuvar{0}||_1\cdot\epsilon + \sum_{i=1}^{L-1}\sum_{\substack{j \notin \setzp{i}\bigcup\setzn{i}\\\bl{i}{j}<0<\bu{i}{j}}} \bl{i}{j}[\nuvar{i}{j}]^+\\ & \text{Subject to:}\\ & \quad \nuvar{L}=-1, \hnuvar{i-1}={\W{i}}^\top\nuvar{i}, \quad i\in\{1,\dots, L\} \\ & \quad \nuvar{i}{j}=0, \quad \text{when } \bu{i}{j}\leq0, i\in\{1,\dots, L-1\}\\ & \quad \nuvar{i}{j}=\hnuvar{i}{j}, \quad \text{when } \bl{i}{j}\geq0, i\in\{1,\dots, L-1\}\\ & \begin{rcases} & [\nuvar{i}{j}]^+=\bu{i}{j}\lambdavar{i}{j}, [\nuvar{i}{j}]^-=\alphavar{i}{j}[\hnuvar{i}{j}]^-\\ & \lambdavar{i}{j}=\frac{[\hnuvar{i}{j}]^+}{\bu{i}{j}-\bl{i}{j}}, \alphavar{i}{j}=\frac{\gammavar{i}{j}}{\muvar{i}{j}+\gammavar{i}{j}} \end{rcases} \text{when } \bl{i}{j}<0<\bu{i}{j}, j \notin \setzp{i}\bigcup\setzn{i}, i\in\{1,\dots, L-1\} \\ & \quad {\color{blue} \nuvar{i}{j}=-\betavar{i}{j}, \quad j\in\setzn{i}, i\in\{1,\dots, L-1\}}\\ & \quad {\color{blue} \nuvar{i}{j}= \betavar{i}{j}+\hnuvar{i}{j}, \quad j\in\setzp{i}, i\in\{1,\dots, L-1\}} \\ & \quad \muvar\geq 0, \gammavar\geq 0, \lambdavar\geq 0, \betavar \geq 0, 0\leq \alphavar\leq1 \end{aligned} \label{eq:final_beta_dual} \end{equation} Similar to the dual form in~\cite{wong2018provable} (our differences are highlighted in \textcolor{blue}{blue}), the dual problem can be viewed in the form of another deep network by backward propagating $\nuvar{L}$ to $\hnuvar{0}$ following the rules in~\eqref{eq:final_beta_dual}. If we look closely at the conditions and coefficients when backward propagating $\nuvar{i}{j}$ for $j$-th ReLU at layer $i$ in~\eqref{eq:final_beta_dual}, we can observe that they match exactly to the propagation of diagonal matrices $\D{i}$, $\S{i}$, and vector $\lowerb{i}$ defined in~\eqref{eq:definition_D} and~\eqref{eq:definition_lowerb}. Therefore, using notations in~\eqref{eq:definition_D} and~\eqref{eq:definition_lowerb} we can essentially simplify the dual LP problem in~\eqref{eq:final_beta_dual} to: \begin{equation} \begin{aligned} \nuvar{L}=-1, \hnuvar{i-1}={\W{i}}^\top\nuvar{i}, \nuvar{i}=\D{i}\hnuvar{i}-\betavar{i}\S{i}, i\in\{L,\cdots,1\}\\ \sum_{\substack{\bl{i}{j}<0<\bu{i}{j}\\ j \notin \setzp{i}\bigcup\setzn{i}}} \bl{i}{j}[\nuvar{i}{j}]^+=-\hnuvar{i}^T\lowerb{i}, j\in\{1,\cdots,d_i\}, i\in\{L-1,\cdots,1\} \end{aligned} \label{eq:nu_eq} \end{equation} Then we prove the key claim for this proof with induction where $\aaa{m}$ and $\bbb{}{m}$ are defined in~\eqref{eq:aaa_m} and~\eqref{eq:bbb_m}: \begin{equation} \hnuvar{m} = -\aaa{m}-\bbb{}{m}\tbetavar{m+1} \label{eq:nu_claim} \end{equation} When $m=L-1$, we can have $\hnuvar{L-1} = -\aaa{L-1}-\bbb{}{L-1}\tbetavar{L}=-\left[\AA{L}{L}\W{L}\right]^\top-\bm{0}=-{\W{L}}^\top$ which is true according to~\eqref{eq:nu_eq}. Now we assume that $\hnuvar{m} = -\aaa{m}-\bbb{}{m}\tbetavar{m+1}$ holds, and we show that $\hnuvar{m-1} = -\aaa{m-1}-\bbb{}{m-1}\tbetavar{m}$ will hold as well: \begin{align*} \hnuvar{m-1}&={\W{m}}^\top\left(\D{m}\hnuvar{m}-\betavar{m}\S{m}\right)\\ &=-{\W{m}}^\top\D{m}\aaa{m}-{\W{m}}^\top\D{m}\bbb{}{m}\tbetavar{m+1}-{\W{m}}^\top\betavar{m}\S{m}\\ &=-\aaa{m-1}-\left[\left(\S{m}\W{m}\right)^\top, \left(\bbb{}{m}^\top\D{m}\W{m}\right)^\top\right]\left[\betavar{m}, \tbetavar{m+1}\right]\\ &=-\aaa{m-1}-\bbb{}{m-1}\tbetavar{m} \end{align*} Therefore, the claim~\eqref{eq:nu_claim} is proved with induction. Lastly, we prove the following claim where $\ccc{}{m}$ and $\constc{m}$ are defined in~\eqref{eq:ccc_m} and~\eqref{eq:constc_m}. \begin{equation} -\sum_{i=m+1}^{L}\nuvar{i}^\top\bias{i}+ \sum_{i=m+1}^{L-1}\sum_{\substack{\bl{i}{j}<0<\bu{i}{j}\\ j \notin \setzp{i}\bigcup\setzn{i}}} \bl{i}{j}[\nuvar{i}{j}]^+=\ccc{}{m}^\top\tbetavar{m+1}+\constc{m} \label{eq:const_claim} \end{equation} This claim can be proved by applying~\eqref{eq:nu_eq} and~\eqref{eq:nu_claim}. \begin{align*} \small -\sum_{i=m+1}^{L}&\nuvar{i}^\top\bias{i}+ \sum_{i=m+1}^{L-1}\sum_{\substack{\bl{i}{j}<0<\bu{i}{j}\\ j \notin \setzp{i}\bigcup\setzn{i}}} \bl{i}{j}[\nuvar{i}{j}]^+ \\ &= -\sum_{i=m+1}^{L}\left(\D{i}\hnuvar{i}-\betavar{i}\S{i}\right)^\top\bias{i}+\sum_{i=m+2}^{L}\left(-\hnuvar{i-1}^T\lowerb{i-1}\right)\\ & = \sum_{i=m+1}^{L}\left[\left(\aaa{i}^\top+\tbetavar{i+1}^\top\bbb{}{i}^\top\right)\D{i}\bias{i}+{\betavar{i}}^\top\S{i}\bias{i}\right]\\ &\quad+\sum_{i=m+2}^{L}\left(\aaa{i-1}^\top+\tbetavar{i}^\top{\bbb{}{i-1}}^\top\right)\lowerb{i-1}\\ & = \sum_{i=m+1}^{L}\tbetavar{i}^\top\left[\S{i}, \bbb{}{i}^\top\D{i}\right]\bias{i}+\sum_{i=m+2}^{L}\tbetavar{i}^\top\bbb{}{i-1}^\top\lowerb{i-1} \\ &\quad+\sum_{i=m+1}^{L}\aaa{i}^\top\D{i}\bias{i}+\sum_{i=m+2}^{L}\aaa{i-1}^\top\lowerb{i-1}\\ & = \ccc{}{m}^\top \tbetavar{m+1} + \constc{m} \end{align*} Finally, we apply claims~\eqref{eq:nu_claim} and~\eqref{eq:const_claim} into the dual form solution~\eqref{eq:final_beta_dual} and prove the Theorem~\ref{thm:objective_dual}. \begin{align*} \small g(\alphavar, \betavar) &= -\sum_{i=1}^{L}\nuvar{i}^\top\bias{i}-\hnuvar{0}^\top x_0-||\hnuvar{0}||_1\cdot\epsilon + \sum_{i=1}^{L-1}\sum_{\substack{\bl{i}{j}<0<\bu{i}{j}\\ j \notin \setzp{i}\bigcup\setzn{i}}} \bl{i}{j}[\nuvar{i}{j}]^+\\ &= -||-\aaa{0}-\bbb{}{0}\tbetavar{1}||_1\cdot\epsilon+\left(\aaa{0}^\top+\tbetavar{1}^\top\bbb{}{0}^\top\right)x_0+ \ccc{}{0}^\top\tbetavar{1} + \constc{0}\\ &= -||\aaa+\bbb\tbetavar{1}||_1\cdot\epsilon+\left(\bbb^\top x_0+\ccc\right)^\top\tbetavar{1} +\aaa^\top x_0 + \constc \end{align*} \textbf{A more intuitive proof.} Here we provide another intuitive proof showing why the dual form solution of verification objective in~\eqref{eq:final_beta_dual} is the same as the primal one in Thereom~\ref{thm:beta_CROWN}. $d_{\text{LP}}=g(\alphavar, \betavar)$ is the dual objective for~\eqref{eq:lp_verify_split} with free variables $\alphavar$ and $\betavar$. We want to show that the dual problem can be viewed in the form of backward propagating $\nuvar{L}$ to $\hnuvar{0}$ following the same rules in $\beta$-CROWN. \citet{salman2019convex} showed that CROWN computes the same solution as the dual form in~\citet{wong2018provable}: $\hnuvar{i}$ is corresponding to $-\A{i}$ in CROWN (defined in the same way as in~\eqref{eq:definition_A} but with $\betavar{i+1}=0$) and $\nuvar{i}$ is corresponding to $-\A{i+1}\D{i+1}$. When the split constraints are introduced, extra terms for the dual variable $\betavar$ modify $\nuvar{i}$ (highlighted in \textcolor{blue}{blue} in~\eqref{eq:final_beta_dual}). The way $\beta$-CROWN modifies $\A{i+1}\D{i+1}$ is exactly the same as the way $\betavar{i}$ affects $\nuvar{i}$: when we split $\z{i}{j} \geq 0$, we add $\betavar{i}{j}$ to the $\nuvar{i}{j}$ in~\citet{wong2018provable}; when we split $\z{i}{j} \geq 0$, we add $-\betavar{i}{j}$ to the $\nuvar{i}{j}$ in~\citet{wong2018provable} ($\nuvar{i}{j}$ is 0 in this case because it is set to be inactive). To make this relationship more clear, we define a new variable $\nuvar^\prime$, and rewrite relevant terms involving $\nuvar$, $\hnuvar$ below: \begin{equation} \begin{aligned} & \nuvar{i}{j}=0 , \quad j\in\setzn{i};\\ & \nuvar{i}{j}=\hnuvar{i}{j}, \quad j\in\setzp{i};\\ & \nuvar{i}{j} \text{ is defined in the same way as in~\eqref{eq:final_beta_dual} for other cases}\\ & \nuvar{i}{j}'=-\betavar{i}{j}+\nuvar{i}{j}, \quad j\in\setzn{i};\\ & \nuvar{i}{j}'= \betavar{i}{j}+\nuvar{i}{j}, \quad j\in\setzp{i};\\ & \nuvar{i}{j}'= \nuvar{i}{j}, \quad \text{otherwise}\\ & \hnuvar{i-1}={\W{i}}^\top\nuvar{i}^\prime;\\ \end{aligned} \end{equation} It is clear that $\nuvar^\prime$ corresponds to the term $-(\A{i+1} \D{i+1} + \betavar{i+1}^\top \S{i+1})$ in~\eqref{eq:definition_A}, by noting that $\nuvar{i}$ in~\citep{wong2018provable} is equivalent to $-\A{i+1} \D{i+1}$ in CROWN and the choice of signs in $\S{i+1}$ reflects neuron split constraints. Thus, the dual formulation will produce the same results as~\eqref{eq:eq_a}, and thus also equivalent to~\eqref{eq:beta_crown_linear_app}. \end{proof} \begin{customcorollary}{\ref{corollary:optimal_alpha_beta}} When $\alphavar$ and $\betavar$ are optimally set, $\beta$-CROWN produces the same solution as LP with split constraints when intermediate bounds $\bl, \bu$ are fixed. Formally, \vspace{-1mm} \[ \max_{0 \leq \alphavar \leq 1, \betavar \geq 0} g(\alphavar, \betavar) = p^*_{\text{LP}} \vspace{-1mm} \] where $p^*_{\text{LP}}$ is the optimal objective of~\eqref{eq:lp_verify_split}. \end{customcorollary} \begin{proof} Given fixed intermediate layer bounds $\bl$ and $\bu$, the dual form of the verification problem in~\eqref{eq:lp_verify_split} is a linear programming problem with dual variables defined in~\eqref{eq:beta_dual}. Suppose we use an LP solver to obtain the optimal dual solution $\nuvar^*, \xivar^*, \muvar^*,\gammavar^*,\lambdavar^*, \betavar^*$. Then we can set $\alphavar{i}{j} = \frac{\gammavar{i}{j}{}^*}{\muvar{i}{j}{}^*+\gammavar{i}{j}{}^*}$, $\betavar = \betavar^*$ and plug them into~\eqref{eq:final_beta_dual} to get the optimal dual solution $d_{\text{LP}}^*$. Theorem~\ref{thm:objective_dual} shows that, $\beta$-CROWN can compute the same objective $d_{\text{LP}}^*$ given the same $\alphavar{i}{j} = \frac{\gammavar{i}{j}{}^*}{\muvar{i}{j}{}^*+\gammavar{i}{j}{}^*}$, $\betavar = \betavar^*$, thus $\max_{0 \leq \alphavar \leq 1, \betavar \geq 0} g(\alphavar, \betavar) \geq d^*_{\text{LP}}$. On the other hand, for any setting of $\alphavar$ and $\betavar$, $\beta$-CROWN produces the same solution $g(\alphavar, \betavar)$ as the rewritten dual LP in~\eqref{eq:final_beta_dual}, so $g(\alphavar, \betavar) \leq d^*_{\text{LP}}$. Thus, we have $\max_{0 \leq \alphavar \leq 1, \betavar \geq 0} g(\alphavar, \betavar) = d^*_{\text{LP}}$. Finally, due to the strong duality in linear programming, $p_{\text{LP}}^*=d_{\text{LP}}^*=\max_{0 \leq \alphavar \leq 1, \betavar \geq 0} g(\alphavar, \betavar)$. \end{proof} The variables $\alphavar$ in $\beta$-CROWN can be translated to dual variables in LP as well. Given $\alphavar$ in $\beta$-CROWN, we can get the corresponding dual LP variables $\muvar, \gammavar$ given $\alphavar$ by setting $\muvar{i}{j}=(1-{\alphavar{i}{j}})[\hnuvar{i}{j}]^-$ and $\gammavar{i}{j}={\alphavar{i}{j}}[\hnuvar{i}{j}]^-$. \subsection{Proof for soundness and completeness} \label{sec:proof_sound_complete} \begin{customthm}{\ref{thm:soundness_completeness}} $\beta$-CROWN with branch and bound on splitting ReLU neurons is sound and complete. \end{customthm} \begin{proof} \textbf{Soundness.} Branch and bound (BaB) with $\beta$-CROWN is sound because for each subdomain ${\mathcal{C}}_i := \{ x \in {\mathcal{C}}, z \in \setz_i \}$, we apply Theorem~\ref{thm:beta_CROWN} to obtain a sound lower bound $\underline{f}_{{\mathcal{C}}_i}$ (the bound is valid for any $\betavar \geq 0$). The final bound returned by BaB is $\min_i \underline{f}_{{\mathcal{C}}_i}$ which represents the worst case over all subdomains, and is a sound lower bound for $x \in {\mathcal{C}} := \cup_i {\mathcal{C}}_i$. \textbf{Completeness.} To show completeness, we need to solve~\eqref{eq:nn_verify} to its global minimum. When there are $N$ unstable neurons, we have up to $2^N$ subdomains, and in each subdomain we have all unstable ReLU neurons split into one of the $\z{i}{j} \geq 0$ or $\z{i}{j} < 0$ case. The final solution obtained by BaB is the min over these $2^N$ subdomains. To obtain the global minimum, we must ensure that in every of these $2^N$ subdomain we can solve~\eqref{eq:lp_verify_split} exactly. When all unstable neurons are split in a subdomain ${\mathcal{C}}_i$, the network becomes a linear network and neuron split constraints become linear constraints w.r.t.\ inputs. Under this case, an LP with ~\eqref{eq:lp_verify_split} can solve the verification problem in ${\mathcal{C}}_i$ exactly. In $\beta$-CROWN, we solve the subdomain using the usually non-concave formulation~\eqref{eq:opt_non_convex}; however, in this case, it becomes concave in $\hat{\betavar}$ because no intermediate layer bounds are used (no $\alphavar^\prime$ and $\betavar^\prime$) and no ReLU neuron is relaxed (no $\alphavar$), thus the only optimizable variable is $\betavar$ (\eqref{eq:opt_non_convex} becomes \eqref{eq:beta_crown_lp}). \eqref{eq:beta_crown_lp} is concave in $\betavar$ so (super)gradient ascent guarantees to converge to the global optimal $\betavar^*$. To ensure convergence without relying on a preset learning rate, a line search can be performed in this case. Then, according to Corollary~\ref{corollary:optimal_alpha_beta}, this optimal $\betavar^*$ corresponds to the optimal dual variable for the LP in~\eqref{eq:lp_verify_split} and the objective is a global minimum of~\eqref{eq:lp_verify_split}. \end{proof}
{'timestamp': '2021-11-02T01:23:58', 'yymm': '2103', 'arxiv_id': '2103.06624', 'language': 'en', 'url': 'https://arxiv.org/abs/2103.06624'}
arxiv
\section{Introduction} Digital terrain models are representations of (parts of) the earth's surface and are used to solve a variety of problems in geographic information science (GIS). An important task for which terrain models are used is visibility analysis: determining which parts of a terrain are visible from some other point(s). A point $q$ on the terrain is said to be {\em visible} from $p$ if the line segment $\overline{pq}$ does not intersect the interior of the terrain. The \emph{viewshed} of $p$ is the set of all points that are visible from a given \emph{viewpoint} $p$. Viewsheds are useful, for example, in evaluating the visual impact of potential constructions~\cite{Danese2011short}, analyzing the coverage of an area by fire watchtowers~\cite{klms-papgpt-14}, or measuring the scenic beauty of a landscape~\cite{SCHIRPKE20131}. There are two major ways to represent terrains in GIS: as a \emph{raster}, i.e., a rectangular grid where each cell stores an elevation, or as a \emph{polyhedral terrain}, a triangulation of a set of points in the plane, where each point has an elevation. In this paper we focus on the latter, which is the standard model in computational geometry. A polyhedral terrain can be seen as an $xy$-monotone polyhedral surface in $\mathbb{R}^3$. This is sometimes called a \emph{2.5D} terrain. From a theoretical standpoint, it will be also interesting to consider the simpler setting of {1.5D} terrains, defined as $x$-monotone polygonal lines in $\mathbb{R}^2$. In a 2.5D polyhedral terrain, a viewshed is formed by the union of the maximal parts of each terrain triangle that are visible from at least one viewpoint. In 1.5D, a viewshed is composed of parts of terrain edges. The computational study of viewsheds focuses on two main aspects: the complexity of the viewsheds, and their efficient computation. In a $1.5$D terrain, the viewshed of one viewpoint can have a complexity that is linear on the number of vertices, and can be computed in linear time~\cite{JoeS87}. In contrast, in $2.5$D terrains the complexity of the viewshed of one viewpoint can be quadratic in the number of vertices~\cite{McKenna87}, which makes its computation too slow for most practical uses when terrains are large. \begin{figure} \begin{center} \includegraphics[width=0.32\textwidth]{quadratic_example} \end{center} \caption{A 2.5D terrain where the visible triangles form a viewshed of quadratic complexity.} \label{fig:quadratic} \end{figure} A typical quadratic construction is shown schematically in Fig.~\ref{fig:quadratic}, where the viewpoint would be placed at the center of projection, and both the number of vertical and horizontal triangles is $\Theta(n)$, for $n$ terrain vertices. Notice that the vertical peaks form a grid-like pattern with the horizontal triangles, leading to $\Theta(n^2)$ visible triangle pieces. \blue{There exist several output-sensitive algorithms to compute the viewshed for a $2.5$D terrain~\cite{KatzOS92,ReifS89short}.} While a viewshed in a 2.5D terrain can have quadratic complexity, this seems to be uncommon in real terrains~\cite{BergHT09short}. Indeed, there have been attempts to define theoretical conditions for a terrain to be ``realistic'' that guarantee, among others, that viewsheds cannot be that large. In particular, Moet et al.~\cite{MOET200848} showed that if terrain triangles satisfy certain ``realistic'' shape conditions, viewsheds have $O(n \sqrt{n})$ complexity. De Berg et al.~\cite{BergHT09short} showed that similar conditions are enough to guarantee worst-case expected complexity of $\Theta(n)$ when the vertex heights are subject to uniform noise. \subsection{Viewsheds and peaks} The topography of the terrain has a strong influence on the potential complexity of the viewshed (something well-studied for sitting observers on terrains to maximize coverage, see e.g.,~\cite{KIM20041019}). To give an extreme example, in a totally concave\footnote{In this work, as is common in terrain analysis but unlike functional analysis, a vertex $v$ of a 2.5D terrain is {\em convex} (resp., {\em concave}) if there exists a non-vertical plane through $v$ leaving all neighboring vertices below it (resp., above it). Convex/concave vertices of 1.5D terrains are defined analogously using lines rather than planes.} terrain, the viewshed of any viewpoint will be the whole terrain, so it will have a trivial description. \blue{Intuitively, to obtain a high complexity viewshed as in the figure above, one needs a large number of obstacles obstructing the visibility from the viewpoint, which in turn requires a somewhat rough topography.} In fact, it is well-established that viewsheds tend to be more complex in terrains that are more ``rugged'' \cite {KIM20041019}. This leads to the natural question of describing the terrain characteristics that can create high complexity (i.e., quadratic) viewsheds. Many topographic attributes have been proposed to capture different aspects of the shape or roughness of a terrain, such as the \emph{terrain ruggedness index}~\cite{Riley1999TRI}, the \emph{terrain shape index}~\cite{McNab1989TSI}, or the \emph{fractal dimension}~\cite{Mandelbrot1982}. These measures focus on aspects like the amount of elevation change between adjacent parts of a terrain, its overall shape, or the terrain complexity. \blue{However, none of them is particularly aimed either to capture the possibility to produce high complexity viewsheds or to show any theoretical evidence for such a correlation.} One very simple and natural measure of the ruggedness of a terrain that is relevant for viewshed complexity is to simply count the number of local maxima, or ``peaks'', in a terrain. There has been evidence that areas with higher elevation difference, and hence, more peaks, cause irregularities in viewsheds \cite {franklin,klms-papgpt-14}, and this idea aligns with our theoretical understanding: the quadratic example from Fig.~\ref{fig:quadratic} is designed by creating an artificial row of peaks, and placing a viewpoint behind it. However, there is no theoretical correlation between the number of peaks and the viewshed complexity, as is easily seen by performing a simple trick: any terrain can be made arbitrarily flat by scaling it in the $z$-dimension by a very small factor, and then tilted slightly---this results in a valid terrain without any peaks, but retains the same viewshed complexity. In fact, viewshed complexity is invariant under affine transformations of the terrain, and hence, any measure that has provable correlation with it must be affine-invariant as well. \blue{This is a common problem to establish theoretical guarantees on viewshed complexity, or to design features of ``realistic'' terrains in general~\cite{BergHT09short,MOET200848}.} \subsection{Prickliness} In this work we explore a new topographic attribute: the \emph{prickliness}. The definition follows directly from the above observations: it counts the number of peaks in a terrain, but does so {\em for every possible affine transformation} of the terrain. Formally, let $T$ be a polyhedral surface. We say that $T$ is a {\em terrain} if the surface is $xy$-monotone; that is, if any vertical line intersects $T$ at most once. Let $A$ be an affine transformation. We define the number of {\em peaks} or {\em local maxima} of $A(T)$, $m(A(T))$, to be the number of internal and convex vertices of $T$\footnote {We explicitly only count vertices which are already convex in the {\em original} terrain, since some affine transformations will transform local minima / concave vertices of the original terrain into local maxima.} which are extremal in the $z$-direction in $A(T)$; that is, all adjacent vertices have a lower or equal $z$-coordinate. Let ${\cal A}(T)$ be the set of all affine transformations of $T$. Then we define the {\em prickliness} of $T$, $\pi(T)$, to be the maximum number of local maxima over all transformation of $T$;\footnote{It might happen that, in the affine transformation achieving prickliness, some of the vertices considered local maxima have neighbors at the same height, which might be considered non-desirable. However, under certain reasonable non-degeneracy assumptions for the terrain, there exists a small perturbation of that transformation giving one fewer local maxima and such that in that transformation all vertices considered local maxima have all neighbors at strictly lower height. An assumption guaranteeing this property is that no two edges of $T$ have the same slope, and no two faces are parallel.} that is, $\pi(T) = \max_{A \in {\cal A(T)}} m(A(T))$. We start by observing that, essentially, the prickliness considers all possible {\em directions} in which the number of peaks are counted, and we can, in fact, provide an alternative definition that will be helpful in our analysis of the concept. Let $\vec v$ be a vector in $\mathbb{R}^3$. Let $\pi_{\vec v} (T)$ be the number of internal and convex vertices of $T$ that are local maxima of $T$ in direction $\vec v$; that is, the number of internal and convex vertices of $T$ for which the local neighborhood does not extend further than that vertex in direction $\vec v$. \begin {observation} \label{obs:pric} $\pi(T) = \max_{\vec v} \pi_{\vec v} (T)$ \end {observation} \begin {proof} Clearly, for every vector $\vec v$ there exists an affine transformation $A$ such that $m(A(T)) = \pi_{\vec v}(T)$: choose for $A$ the rotation that makes $\vec v$ vertical. We will show that also for every affine transformation $A$ there exists a vector $\vec v$ for which $m(A(T)) = \pi_{\vec v}(T)$. In particular this then implies that the maximum value of $m(A(T))$ over all $A$ is equal to the maximum value of $\pi_{\vec v}(T)$ over all $\vec v$. Let $A$ be an affine transformation, and let $H$ be the horizontal plane $z=0$. Consider the transformed plane $H' = A^{-1}(H)$. Then any vertex of $T$ which has the property that all neighbours are on the same side of $H'$ in $T$, will be a local maximum or local minimum in $A(T)$. Now, choose for $\vec v$ the vector perpendicular to $H'$ and pointing in the direction which will correspond to local maxima. \qed \end {proof} Using this observation, we reduce the space of all possible affine transformations to essentially the 2-dimensional space of all possible directions. Further note that, since $T$ is a terrain, for any $\vec v$ with a negative $z$-coordinate we have $\pi_{\vec v} (T) = 0$ by definition. This provides a natural way to visualize the prickliness of a terrain. Fig.~\ref {fig:example} shows a small terrain and the resulting prickliness, shown as a function of the direction of $\vec v$. \begin{figure}[tb] \centering \includegraphics[scale=0.16]{small_hills_tin_col.PNG} \includegraphics[scale=0.75]{small_hills_prickliness_8x8_O_0_to_8.pdf} \caption {(left) A polyhedral terrain $T$. Triangulation edges are shown in black, height ($z$-coordinates) are indicated using colors. (right) A visualization of the prickliness $\pi_{\vec v} (T)$ as a function of $\vec v$, in degrees from vertical $(0,0,1)$. The maximum prickliness is $8$, attained at a direction about $13^\circ$ north-east from the origin.} \label {fig:example} \end {figure} \paragraph{Results and organization} The paper is organized as follows. \begin {itemize}[leftmargin=*] \item In Section~\ref{subsec:compl-15D}, we show that the prickliness of a $1.5$D terrain and the viewshed complexity of a single viewpoint are not related: we given examples where one is constant and the other is linear. \item In contrast, we show in Section~\ref{subsec:compl-25D} that such a correlation does exist for $2.5$D terrains: we show that the viewshed complexity of a single viewpoint cannot be higher than $O(n\cdot\pi(T))$, and this is tight. \item In Section~\ref {sec:comp15D}, we consider the question of how to compute the prickliness of a $1.5$D terrain. We provide an algorithm that runs in $O(n \log n)$ time, as well as a matching lower bound. \item In Section~\ref {sec:comp25D}, we consider the question of how to compute the prickliness of a $2.5$D terrain. We provide an $O(n^2)$ time algorithm, and show that this is near-optimal by proving that the problem is 3SUM-hard. \item Finally, in Section~\ref {sec:exp}, we report on experiments that measure the prickliness of real terrains, and confirm the correlation between prickliness and viewshed complexity in practice. \end {itemize} \section {Prickliness and viewshed complexity in 1.5D terrains}\label{subsec:compl-15D} The prickliness of a $1.5$D terrain and the viewshed complexity of a single viewpoint do not seem to be related. In order to show it, we need to introduce some notation. For every internal and convex vertex $v$ in $T$, we are interested in the vectors $\vec w$ such that $v$ is a local maximum of $T$ in direction $\vec w$. Note that these feasible vectors $\vec w$ can be represented as unit vectors, and then the feasible set becomes a region of the unit circle $\mathbb{S}^1$, which we denote by $se(v) \subset \mathbb{S}^1$. To find $se(v)$, for each edge $e$ of $T$ incident to $v$ we consider the line $\ell$ through $v$ which is perpendicular to $e$. Then we take the half-plane bounded by $\ell$ and opposite to $e$, and we translate it so that its boundary contains the origin. Finally, we intersect this half-plane with $\mathbb{S}^1$, which yields a half-circle. We intersect the two half-circles associated to the two edges of $T$ incident to $v$, and obtain a sector of $\mathbb{S}^1$. For each direction $\vec w$ contained in the sector, the two corresponding edges do not extend further than $v$ in direction $\vec w$. Thus, $v$ is a local maxima in direction $\vec w$ and this sector indeed represents $se(v)$. See Fig.~\ref{fig:angle} for an example. \begin{figure}[ht] \centering \includegraphics[]{angle1.pdf} \caption{In shaded, $se(v)$ for the corresponding vertices.}\label{fig:angle} \end{figure} \begin {theorem} \label{thm:1.5Dexample} There exists a 1.5D terrain $T$ with $n$ vertices and constant prickliness, and a viewpoint on $T$ with viewshed complexity $\Theta(n)$. \end {theorem} \begin{proof} The construction is illustrated in Fig.~\ref{fig:1.5Dex}. From a point $p$, we shoot $n/2$ rays in the fourth quadrant of $p$ such that the angle between any pair of consecutive rays is $2/n$. On the $i$th ray, there are two consecutive vertices of the terrain, namely, $v_i$ and $w_i$. The vertices are placed so that $\angle w_{i-1}v_iw_{i}=180-3/n$. \begin{figure}[ht] \centering \includegraphics{example15.pdf} \captionof{figure}{Terrains with low prickliness can have high viewshed complexity.} \label{fig:1.5Dex} \end {figure} For every $i$, we have that $se(v_i)$ has angle $3/n$, while $se(w_i)$ is empty because $w_i$ is not convex. Since the angle between $w_{i-1}v_i$ and $w_{i}v_{i+1}$ is $2/n$ and the angle between $v_iw_i$ and $v_{i+1}w_{i+1}$ is also $2/n$, we have that $se(v_{i+1})$ can be obtained by rotating counterclockwise $se(v_i)$ by an angle of $2/n$. Thus, $se(v_i)\cap se(v_{i+1})$ has angle $1/n$, and $se(v_i)\cap se(v_{i+j})$ is empty for $j\geq 2$. We conclude that the prickliness of the terrain is constant. If a viewpoint is placed very near $p$ along the edge emanating to the right of $p$, then for every $i$ the section $v_iw_iv_{i+1}$ contains a non-visible portion followed by a visible one. Hence, the complexity of the viewshed of the viewpoint is $\Theta(n)$. \qed \end{proof} \section{Prickliness and viewshed complexity in 2.5D terrains} \label{subsec:compl-25D} Surprisingly, and in contrast to Theorem~\ref {thm:1.5Dexample}, we will show in Theorem~\ref{thm:2.5comp} that in 2.5D there is a provable relation between prickliness and viewshed complexity. We recall some terminology introduced in~\cite{fishy2014}. Let $v$ be a vertex of $T$, and let $p$ be a viewpoint. We denote by $\uparrow_p^v$ the half-line with origin at $v$ in the direction of vector $\overrightarrow{pv}$. Now, let $e=uv$ be an edge of $T$. The \emph {vase} of $p$ and $e$, denoted $\uparrow_p^e$, is the region bounded by $e$, $\uparrow_p^u$, and $\uparrow_p^v$ (see Fig.~\ref{fig:vases}). \begin{figure}[!ht] \centering \includegraphics[scale=0.6]{vase.pdf} \caption{A vase.} \label{fig:vases} \end{figure} Vertices of the viewshed of $p$ can have three types~\cite{fishy2014}. A vertex of type 1 is a vertex of $T$, of which there are clearly only $n$. A vertex of type 2 is the intersection of an edge of $T$ and a vase. A vertex of type 3 is the intersection of a triangle of $T$ and two vases. With the following two lemmas we will be able to prove Theorem~\ref{thm:2.5comp}. \begin {lemma} \label{cl:type2} There are at most $O(n \cdot \pi(T))$ vertices of type $2$. \end {lemma} \begin {proof} Consider an edge $e$ of $T$ and let $H$ be the plane spanned by $e$ and $p$. Consider the viewshed of $p$ on $e$. Let $qr$ be a maximal invisible portion of $e$ surrounded by two visible ones. Since $q$ and $r$ are vertices of type 2, the open segments $pq$ and $pr$ pass through a point of $T$. On the other hand, for any point $x$ in the open segment $qr$, there exist points of $T$ above the segment $px$. This implies that there is a continuous portion of $T$ above $H$ such that the vertical projection onto $H$ of this portion lies on the triangle $pqr$. Such portion has a local maximum in the direction perpendicular to $H$ which is a convex and internal vertex of $T$. In consequence, each invisible portion of $e$ surrounded by two visible ones can be assigned to a distinct point of $T$ that is a local maximum in the direction perpendicular to $H$. Hence, in the viewshed of $p$, $e$ is partitioned into at most $2 \pi(T) +3$ parts.\footnote{We obtain $2 \pi(T) +3$ parts when the first and last portion of $e$ are invisible; otherwise, we obtain fewer parts.}\qed \end{proof} \begin{figure}[tb] \centering \includegraphics[scale=0.6]{claim52.pdf} \caption{The situation in the proof of Lemma~\ref{cl:type3}.} \label{fig:type3} \end{figure} \begin {lemma} \label{cl:type3} There are at most $O(n \cdot \pi(T))$ vertices of type $3$. \end {lemma} \begin {proof} Let $q$ be a vertex of type 3 in the viewshed of $p$. Point $q$ is the intersection between a triangle $t$ of $T$ and two vases, say, $\uparrow_p^{e_1}$ and $\uparrow_p^{e_2}$; see Fig.~\ref{fig:type3}. Let $r$ be the ray with origin at $p$ and passing through $q$. Ray $r$ intersects edges $e_1$ and $e_2$. First, we suppose that $e_1$ and $e_2$ do not share any vertex and, without loss of generality, we assume that $r\cap e_1$ is closer to $p$ than $r\cap e_2$. Notice that $r\cap e_2$ is a vertex of type 2 because it is the intersection of $e_2$ and $\uparrow_p^{e_1}$, and $\uparrow_p^{e_1}$ partitions $e_2$ into a visible and an invisible portion. Thus, we charge $q$ to $r\cap e_2$. If another vertex of type 3 was charged to $r\cap e_2$, then such a vertex would also lie on $r$. However, no point on $r$ after $q$ is visible from $p$ because the visibility is blocked by $t$. Hence, no other vertex of type 3 is charged to $r\cap e_2$. If $e_1$ and $e_2$ are both incident to a vertex $v$, since $t\, \cap \uparrow_p^{e_1} \cap \uparrow_p^{e_2}$ is a type 3 vertex, we have that $r$ passes through $v$. Therefore, $q$ is the first intersection point between $r$ (which can be seen as the ray with origin at $p$ and passing through $v$) and the interior of some triangle in $T$. Therefore, any vertex $v$ of $T$ creates at most a unique vertex of type 3 in this way.\qed \end {proof} \begin {theorem} \label{thm:2.5comp} The complexity of a viewshed in a 2.5D terrain is $O(n \cdot \pi(T))$. \end {theorem} Next we describe a construction showing that the theorem is best possible. \begin{theorem} \label{obs:lowerbound2.5D} There exists a 2.5D terrain $T$ with $n$ vertices and prickliness $\pi(T)$, and a viewpoint on $T$ with viewshed complexity $\Theta(n \cdot \pi(T))$. \end{theorem} \begin{proof} Consider the standard quadratic viewshed construction, composed of a set of front mountains and back triangles (Fig.~\ref{fig:lower_bound} (left)). Notice that there can be at most $\pi(T)$ mountains ``at the front''. We add a surrounding box around the construction, see Fig.~\ref{fig:lower_bound} (right), such that each vertex of the back triangles is connected to at least one vertex on this box. We set the elevation of the box so that it is higher than all the vertices of the back triangles, but lower than those of the front mountains. In this way, no vertex of the back triangles will be a local maximum in any direction, and all local maxima will come from the front.\qe \end{proof} \begin{figure}[t] \centering\includegraphics[scale=0.5]{lower_bound.pdf} \caption{Schematic top-down view of the classic quadratic construction (left), and the same adapted to have small prickliness (right). The camera with quadratic behaviour is at $(0, -\infty)$ (see Fig.~\ref {fig:quadratic} for the resulting view). Blue vertices/edges are low, red are medium hight, and green are high. The right construction introduces a new height (yellow) between medium and high, and changes the triangulation slightly, to ensure that all convex vertices in the construction are green.} \label{fig:lower_bound} \end{figure} \section {Prickliness computation in 1.5D terrains} \label {sec:comp15D} \subsection{Algorithm} \label {sec:alg1} For every internal and convex vertex $v$ in $T$, we compute $se(v)$ in constant time using the characterization given in Section~\ref{subsec:compl-15D}. The prickliness of $T$ is the maximum number of sectors of type $se(v)$ whose intersection is non-empty. We sort the bounding angles of the sectors in $O(n \log n)$ time, and obtain the maximum in a single pass. Thus, we obtain: \begin{theorem} The prickliness of a 1.5D terrain can be computed in $O(n\log n)$ time. \end{theorem} \subsection{Lower bound} Now we show that $\Omega(n \log n)$ is also a lower bound for finding prickliness in a 1.5D terrain. The reduction is from the problem of checking distinctness of $n$ integer elements, which has an $\Omega(n \log n)$ lower bound in the bounded-degree algebraic decision tree model~\cite{LubiwR-lb,Yao-lb} Suppose we are given a set ${\cal S}=\{x_1,x_2,\ldots,x_n\}$ of $n$ integer elements, assumed w.l.o.g. to be positive. We multiply all elements of $\cal S$ by $180/(\max{\cal S}+1)$ and obtain a new set ${\cal S'}=\{x'_1,x'_2,\ldots,x'_n\}$ such that $0 < x'_i < 180$, for each $x'_i$. We construct a terrain $T$ that will be an instance of the prickliness problem. For each $x'_i$, we create in $T$ a convex vertex $v_i$ such that $se(v_i)=[x'_i - \varepsilon, x'_i + \varepsilon]$, where $\varepsilon =18/(\max{\cal S}+1)$, and such that its two neighbors are at distance $1$ from $v_i$.\footnote{We sometimes write $se(v)=[\alpha,\beta]$, where $\alpha$ and $\beta$ are the angles bounding the sector.} See Fig.~\ref{fig:lb} for an example. We denote the incident vertices to $v_i$ to its left and right by $w^l_i$ and $w^r_i$, respectively. \begin{figure}[t] \centering \includegraphics[scale=0.4]{proof21.pdf} \caption{(a) Sectors associated to the element set $\{160,25\}$. (b) The corresponding convex vertices. (c) Construction of the terrain.}\label{fig:lb} \end{figure} We arrange these convex vertices in the order of the elements in ${\cal S'}$ from left to right, and we place all of them at the same height. Then we place a dummy vertex $u_i$ between every pair of consecutive vertices $v_i$ and $v_{i+1}$, and connect $u_i$ to $w^r_i$ and $w^l_{i+1}$; see Fig.~\ref{fig:lb}c. The height of $u_i$ is chosen so that its two neighbors become concave vertices, and also so that $[\min{(\cal S')}- \varepsilon,\max{(\cal S')}+ \varepsilon] \subseteq se(u_i)$. This is possible because moving $u_i$ upwards increases its feasible region $se(u_i)$, the limit being $[0, 180]$. The following lemma allows us to prove Theorem~\ref{thm:lower} below. \begin{lemma}\label{lem:lb} The prickliness of $T$ is $n$ if and only if all elements in ${\cal S}$ are distinct. \end{lemma} \begin{proof} Every vertex of type $u_i$ satisfies that $ [\min{(\cal S')} - \varepsilon,\max{(\cal S')}+ \varepsilon] \subseteq se(u_i)$. Thus the prickliness of $T$ is at least $n-1$. For every vertex of type $v_i$, $se(v_i)$ has an angle of $2\varepsilon$. Finally, the vertices of type $w^l_i$ and $w^r_i$ are concave, so $se(w^l_i)$ and $se(w^r_i)$ are empty. Consequently, the prickliness of $T$ is $n$ if and only the sectors of type $se(v_i)$ are pairwise disjoint, which happens if and only if the elements in ${\cal S}$ are all distinct.\qed \end{proof} \begin{theorem} \label{thm:lower} The problem of computing the prickliness of a 1.5D terrain has an $\Omega(n \log n)$ lower bound in the bounded-degree algebraic decision tree model. \end{theorem} \section{Prickliness computation in 2.5D terrains} \label {sec:comp25D} \subsection{Algorithm} A basic observation is that the sphere of potential directions is subdivided into $n^2$ cells by the $n$ planes through the origin parallel to the triangles of $T$. For any pair of directions $\vec v$ and $\vec w$ in the same cell, the values of $\pi_{\vec v}$ and $\pi_{\vec w}$ are equal. This gives a trivial $O(n^3)$ time algorithm to calculate the prickliness: compute this subdivision, for each cell take a single vector, and for this vector count the number of local maxima (testing whether a vertex is a local maximum is a local operation that takes time proportional to the degree of the vertex; the sum of degrees of all vertices is linear) We propose a faster algorithm that extends the idea from Section~\ref {sec:alg1} to 2.5D terrains as follows: For every convex terrain vertex $v$, we compute the region of the unit sphere $\mathbb{S}^2$ containing all vectors $\vec w$ such that $v$ is a local maximum of $T$ in direction $\vec w$. As we will see, such a region is a cone and we denote it by $co(v)$. Furthermore, we denote the portion of $co(v)$ on the surface of the sphere by $co_{\mathbb{S}^2}(v)$. In order to compute $co(v)$, we consider all edges of $T$ incident to $v$. Let $e=vu$ be such an edge, and consider the plane orthogonal to $e$ through $v$. Let $H$ be the half-space which is bounded by this plane and does not contain $u$. We translate $H$ so that the plane bounding it contains the origin; let $H_e$ be the intersection of the obtained half-space with the unit sphere $\mathbb{S}^2$. The following property is satisfied: For any unit vector $\vec w$ in $H_e$, the edge $e$ does not extend further than $v$ in direction $\vec w$. We repeat this procedure for all edges incident to $v$, and consider the intersection $co(v)$ of all the obtained half-spheres $H_e$. For any unit vector $\vec w$ in $co(v)$, none of the edges incident to $v$ extends further than $v$ in direction $\vec w$. Since $v$ is convex, this implies that $v$ is a local maxima in direction $\vec w$. Once we know all regions of type $co(v)$, computing the prickliness of $T$ reduces to finding a unit vector that lies in the maximum number of such regions. To simplify, rather than considering these cones on the sphere, we extend them until they intersect the boundary of a unit cube $\mathbb{Q}$ centered at the origin. The conic regions of type $co(v)$ intersect the faces of $\mathbb{Q}$ forming (overlapping) convex regions. Notice that the problem of finding a unit vector that lies in the maximum number of regions of type $co(v)$ on $\mathbb{S}$ is equivalent to the problem of finding a point on the surface of $\mathbb{Q}$ that lies in the maximum number of ``extended" regions of type $co(v)$. The second problem can be solved by computing the maximum overlap of convex regions using a topological sweep~\cite{edels1989}, for each face of the cube. Computing the intersection between the extended regions of type $co(v)$ (for all convex vertices $v$) and the boundary of $\mathbb{Q}$ takes $O(n \log n)$ time, and topological sweep to find the maximum overlap takes $O(n^2)$ time. We obtain the following: \begin{theorem} \label {thm:2D} The prickliness of a 2.5D terrain can be computed in $O(n^2)$ time. \end{theorem} \subsection{Lower bound} In this section we show that the problem of computing the prickliness of a 2.5D terrain is 3SUM-hard. This implies our result in Theorem~\ref {thm:2D} is likely to be close to optimal: The best-known algorithm for 3SUM runs in $O(n^2(\log\log n)^{O(1)}/(\log n)^{2})$ time, and it is believed there are no significantly faster solutions \cite{DBLP:journals/talg/Chan20}. The reduction is from the following problem, which is known to be 3SUM-hard \cite{gajentaan1995class}: Given a square $Q$ and $m$ strips of infinite length, does there exist a point in $Q$ not covered by any of these $m$ strips? Let us take an instance of the problem above. The complement of each strip is given by two half-planes. Let us consider the $2m$ half-planes obtained in this way, together with the square $Q$. Answering the above question is equivalent to answering whether there exists a point in $Q$ covered by $m$ of the half-planes. For every half-plane, if it does not intersect $Q$, we discard it. Otherwise, we replace the half-plane by the smallest-area rectangle that contains the intersection of $Q$ with the half-plane; see Fig.~\ref{fig:rectangles}. Then the problem becomes determining whether there exists a point in $Q$ covered by $m$ of these rectangles. \begin{figure}[tb] \centering \includegraphics[scale=0.5]{rectangles.pdf} \caption{Instance of the problem of coverage with strips (left), and the equivalent problem of coverage with rectangles (right).}\label{fig:rectangles} \end{figure} Let $\mathcal{A}$ be the arrangement containing $Q$ and the rectangles. By construction, we have: \begin{observation} \label{obs1:3sum} Any point is covered by at most $m+1$ objects of $\mathcal{A}$. If a point is covered by $m+1$ objects of $\mathcal{A}$, it lies inside $Q$. \end{observation} Next we consider the plane containing $\mathcal{A}$ as a horizontal plane in $\mathbb{R}^3$ such that $(0,0,2)$ lies on $Q$. For every object in $\mathcal{A}$, we connect all its vertices to $(0,0,0)$, which gives a cone, and we intersect this cone with the unit sphere centered at $(0,0,0)$. The intersection of the cone with the surface of the sphere is referred to as the ``projection'' of the original object in $\mathcal{A}$. We denote the projection of $Q$ by $\tilde{Q}$, and the projection of rectangle $R_i$ by $\tilde{R}_i$. With some abuse of notation, we still refer to the objects $\tilde{R}_i$ as ``rectangles''. Let $\tilde{\mathcal{A}}$ be the arrangement containing the projection of the objects in $\mathcal{A}$. Observation~\ref{obs1:3sum} implies: \begin{observation} \label{obs2:3sum} Any point is covered by at most $m+1$ objects of $\tilde{\mathcal{A}}$. If a point is covered by $m+1$ objects of $\tilde{\mathcal{A}}$, it lies inside $\tilde{Q}$. \end{observation} We next construct a terrain $T$. The terrain contains {\em red}, {\em green} and {\em blue} vertices. We associate one red vertex to $\tilde{Q}$ and to each of the rectangles intersecting it. The red vertices are placed at height two, and the distance between any pair of them is at least three. Each red vertex has four green vertices as neighbors, placed as follows. Let $\tilde{R}_i$ be one of the rectangles on the sphere (either $\tilde{Q}$ or one of the rectangles intersecting it), and let $v_i$ be the red vertex of $T$ associated to $\tilde{R}_i$. For each of the sides of $\tilde{R}_i$, consider the plane containing the side of $\tilde{R}_i$ and passing through the origin. Consider the half-space $H$ that is bounded by this plane and contains $\tilde{R}_i$. Take a normal vector $w$ of the plane that does not point towards $H$. Then place a green vertex $x$ of $T$ such that the vector $\vec{v_ix}$ is congruent to $w$ and has length one.\footnote{Since red vertices have height two, the obtained green vertex has positive height.} By following this procedure for all sides of $\tilde{R}_i$, we obtain four green vertices of $T$ which are adjacent to $v_i$. We denote this set of vertices by $N(v_i)$. There are no more vertices of $T$ adjacent to $v_i$. \begin{lemma} \label{lem:3sum} Vertex $v_i$ satisfies: \begin{itemize} \item[(a)] It is a convex vertex of $T$. \item[(b)] If we project $v_i$ and $N(v_i)$ onto the $XY$-plane, then the convex hull of the projection of the vertices in $N(v_i)$ contains the projection of $v_i$. \item[(c)] $co_{\mathbb{S}^2}(v_i)=\tilde{R}_i$. \end{itemize} \end{lemma} \begin{proof} The intersection of the four half-spaces associated to the four sides of $\tilde{R}_i$ forms a cone that can be described as the set of points $\bar{x}\in \mathbb{R}^3$ satisfying the equation $A\bar{x}\leq 0$, where $A$ is a $4 \times 3$ matrix. It can also be described as $cone(W)$ --the conic hull of vectors in $W$--, where $W$ is the set of four vectors pointing from the origin to the four endpoints of $R_i$. Let $\tilde{W}$ be the $4 \times 3$ matrix where each row corresponds to the components of one of the vectors in $W$. Let $\tilde{A}$ be the set of four vectors corresponding to the four rows of $A$. By polar duality, the cones described by $\tilde{W}\bar{x}\leq 0$ and $cone(\tilde{A})$ are also the same Notice that the vectors of $\tilde{A}$ are the four vectors used to place the four neighbors of $v_i$ in $T$. Therefore, (b) is equivalent to the following: If we project the endpoints of the vectors of $\tilde{A}$ onto the $XY$-plane, then the convex hull of the projected points contains the origin. We will prove that $(0,0,-1)\in cone(\tilde{A})$, which implies this claim. Since the four endpoints of $\tilde{R}_i$ have positive $z$-coordinate, $(0,0,-1)$ satisfies the equation $\tilde{W}\bar{x}\leq 0$. Since the cones $\tilde{W}\bar{x}\leq 0$ and $cone(\tilde{A})$ are the same, we obtain $(0,0,-1)\in cone(\tilde{A})$. Regarding (a), let $\alpha\neq (0,0,0)$ be such that $A\alpha\leq 0$. Then $cone(\tilde{A})$ is contained in the half-space $\alpha^Tx \leq 0$, which proves that $v_i$ is a convex vertex of $T$. By construction of $N(v_i)$ and the fact that $v_i$ is a convex vertex of $T$, (c) follows.\qed \end{proof} By Lemma~\ref{lem:3sum}b (and the facts that red vertices are at pairwise distance at least three and each red vertex has its green neighbors at distance one), the projection of the red and green vertices, and the edges among them, onto the $XY$-plane is a set of pairwise disjoint wheel graphs. Next, we triangulate this graph. Then, for every triangle defined by three green vertices, we place a blue vertex inside the triangle and we connect this vertex to the three vertices of the triangle (see Fig.~\ref{fig:3sum}). It only remains to specify the height of the blue vertices. Each blue vertex $u$ is placed at a height high enough so that: (i) the three neighboring green vertices become non-convex vertices of $T$, and (ii) $co_{\mathbb{S}^2}(u)$ contains $\tilde{Q}$. Regarding (ii), if $u$ is placed higher than all of its neighbors (which are all green, so they already have specified heights), then $co_{\mathbb{S}^2}(u)$ contains the north pole. By moving $u$ upwards, $co(u)$ becomes bigger and bigger, the limit being the upper hemisphere of $\mathbb{S}$. Therefore, from some height onwards $co_{\mathbb{S}^2}(u)$ contains $\tilde{Q}$. Let $\tilde{\mathcal{A}}^{+}$ be the arrangement $\tilde{\mathcal{A}}$ augmented with $co_{\mathbb{S}^2}(u)$ for all blue vertices $u$. Let the number of blue vertices be $k$. By Observation~\ref{obs2:3sum}, \begin{figure}[tb] \begin{center} \includegraphics[width=0.38\textwidth]{3sum_hard.pdf} \end{center} \caption{Projection of $T$ onto the $XY$-plane.}\label{fig:3sum} \end{figure} \begin{observation} \label{obs3:3sum} Any point is covered by at most $m+1+k$ objects of $\tilde{\mathcal{A}}^{+}$. If a point is covered by $m+1+k$ objects of $\tilde{\mathcal{A}}^{+}$, it lies inside $\tilde{Q}$. \end{observation} \begin{lemma}\label{lem:nsc} The prickliness of $T$ is $m+k+1$ if and only if there is a point in $Q$ covered by $m$ rectangles. \end{lemma} \begin{proof} Suppose that the prickliness of $T$ is $m+k+1$. This means that, when we compute $co(v)$ for all vertices $v$ of $T$, a unit vector that is covered by the maximum number of such cones is covered by $m+k+1$ cones. If $v$ is a blue vertex, $co_{\mathbb{S}^2}(v)$ contains $\tilde{Q}$. If $v$ is a green vertex, $co(v)$ is empty because $v$ is a concave vertex of $T$. If $v$ is a red vertex, either $v$ is associated to $\tilde{Q}$ or $v=v_i$ for some $i$. By Lemma~\ref{lem:3sum}c, in the first case $co_{\mathbb{S}^2}(v)=\tilde{Q}$, while in the second case $co_{\mathbb{S}^2}(v)=\tilde{R_i}$. Therefore, the problem of computing the prickliness of $T$ is equivalent to the problem of finding a point in $\tilde{\mathcal{A}}^{+}$ covered by the maximum number of objects. By Observation~\ref{obs2:3sum}, if the prickliness of $T$ is $m+k+1$, there is a point in $\tilde{Q}$ covered by $m+1+k$ objects of $\tilde{\mathcal{A}}^{+}$. This implies that there is a point in $Q$ covered by $m$ rectangles. If there is a point in $Q$ covered by $m$ rectangles, there is a point in $\tilde{Q}$ covered by $m+1+k$ objects of $\tilde{\mathcal{A}}^{+}$. By Observation~\ref{obs2:3sum}, there is no point in $\tilde{\mathcal{A}}^{+}$ covered by more than $m+1+k$ objects, so the prickliness of $T$ is $m+k+1$.\qed \end{proof} Thus we have the following: \begin{theorem} The problem of computing the prickliness of a 2.5D terrain is 3SUM-hard. \end{theorem} \section {Experiments} \label {sec:exp} \begin {figure}[tb] \centering \includegraphics{plots/9VPs_Highest_Prickly_50_TIN_Verts} \qquad \includegraphics{plots/9VPs_Highest_Prickly_50_TIN} \caption {(left) The prickliness values for the terrains we considered. (right) The relation between the (median) viewshed complextity of the high viewpoints in a terrain and its prickliness.} \label{fig:plots} \end {figure} We briefly report on some experiments relating the prickliness to the viewshed complexity in real world 2.5D terrains (see~\cite{thesis/gert} for details). We considered a collection of 52 real-world terrains around the world. They varied in ruggedness, including mountainous regions (Rocky mountains, Himalaya), flat areas (farmlands in the Netherlands), and rolling hills (Sahara), and in number of vertices. For each of these terrains we computed the prickliness, and the viewsheds of nine ``sufficiently separated'' high points on the terrain. We refer to~\cite{thesis/gert} on how we pick these points exactly. Fig.~\ref{fig:plots} (left) shows the number of vertices in each of the terrains and their prickliness. We see that the prickliness is generally much smaller than the number of vertices. See also Fig.~\ref{fig:real}. Fig.~\ref{fig:plots} (right) then shows the relation between the prickliness and the viewshed complexities. The viewshed complexities seem to scale nicely with the prickliness. These results suggest that the prickliness may indeed be a valuable terrain descriptor. % \begin {figure}[tb] \centering \includegraphics [scale=.15] {california_hot_springs.png} \includegraphics [scale=.75] {calhs_prickliness_8x8_O_0_to_62} \caption {A real-world terrain with $583$ vertices from the neighborhood of California Hot Springs whose prickliness is only $62$. On the right the value $\pi_{\vec{v}}$ for vectors near $(0,0,1)$.}\label{fig:real} \end {figure} % \section {Conclusions} We introduced the {\em prickliness} as a new measure of terrain ruggedness, and showed that for 2.5D terrains it has a direct correlation with viewshed complexity. As far as we know, this constitutes the first topographic attribute that has a provable connection with viewshed complexity, and is independent of the viewpoint location. Furthermore, we presented near-optimal algorithms to compute the prickliness of 1.5D and 2.5D terrains. We also performed some experiments indicating that, in real-world terrains, prickliness is significantly smaller than the number of vertices, and also that the correlation between prickliness and viewshed complexity translates into practice. An intriguing question is whether the computation of the prickliness itself can be done more efficiently on real terrains, as our lower bound construction results in a very artificial terrain. It is conceivable that one could achieve this assuming, for instance, {\em realistic terrain} conditions~\cite{MOET200848}, or a {\em slope} condition~\cite{Schreiber10}. Finally, extending our study to viewsheds of multiple viewpoints, whose complexity was studied recently for the first time~\cite{fishy2014}, is another interesting direction for further research. \section* {Acknowledgments} The authors would like to thank Jeff Phillips for a stimulating discussion that, years later, led to the notion of prickliness. A. A., R. J., and M. S. were supported by the Czech Science Foundation, grant number GJ19-06792Y, and by institutional support RVO: 67985807. M.L. was partially supported by the Netherlands Organization for Scientific Research (NWO) under project no. 614.001.504. R. S. was supported by projects MINECO PID2019-104129GB-I00 and Gen. Cat. DGR 2017SGR1640. \bibliographystyle{splncs04}
{'timestamp': '2021-03-12T02:25:08', 'yymm': '2103', 'arxiv_id': '2103.06696', 'language': 'en', 'url': 'https://arxiv.org/abs/2103.06696'}
arxiv
\section{Introduction} \IEEEPARstart{T}{he} prodigious development of the digital camera, computer hardware, Internet technology, and machine learning technologies makes millions or even billions of images accessible to people. Large scale image annotation has therefore become essential for many practical applications in image processing, computer vision and multimedia. Since it is expensive to label a large number of images to train a robust learning model for image annotation, semi-supervised learning (SSL) has been introduced to semi-automatic image annotation and exploits both a small number of labeled images and a large number of unlabeled images to improve the generalization ability of a learning model. The most common class of methods for SSL is based on the manifold assumption \cite{Belkin2006}, that is, two examples with similar features tend to share the same class label. Manifold regularization tries to explore the geometry of the intrinsic data probability distribution by penalizing the regression function along the potential manifold. Laplacian regularization (LR) \cite{Belkin2001,Belkin2006} is one of the representative works in which the geometry of the underlying manifold is determined by the graph Laplacian. LR-based SSL has received intensive attention and many algorithms have been developed, such as Laplacian regularized least squares (LapLS) and Laplacian support vector machines (LapSVM) \cite{Belkin2006}. Although LR has shown its effectiveness in SSL, it is short of extrapolating power. The null space of the graph Laplacian is a constant function along the compact support of the marginal distribution and thus the solution of the LR is biased towards a constant function. This means that the function whose values are beyond the range of the training outputs is always a constant function, which causes LR-based SSL particularly to suffer when there are only few labeled examples. In contrast to Laplacian, Hessian can properly exploit the intrinsic local geometry of the data manifold. Hessian has a richer nullspace and drives the learned function which varies linearly along the underlying manifold \cite{Eells1983,Donoho2003,Steinke2008,Kim}. Thus Hessian regularization (HR) cannot only properly fit the data within the domain defined by training samples, but it can also nicely predict the data points beyond the boundary of the domain. Compared to LR, HR is preferable for SSL for encoding the local geometry of the data distribution and thus can boost the SSL performance. In \cite{Kim}, the effectiveness of HR has been demonstrated for kernel regression. The aforementioned learning methods, however, are only applicable to data represented by single view features, whereas in image annotation, images are naturally represented by multiview features, such as color, shape and texture. Each view of a feature summarizes a specific characteristic of the image, and features for different views are complementary to one another. Although we can concatenate different features into a long vector, this concatenation strategy (1) improperly treats different features carrying different physical characteristics, and (2) results in an over-fitting problem when the size of the training set is small. Therefore compared to single view learning, multiview learning can significantly improve performance especially when the weaknesses of one view can be reduced by the strengths of others. In this paper, we present multiview Hessian regularization (mHR) for image annotation. Significantly, mHR optimally combines multiview features and Hessian regularizations obtained from different views. The advantages of mHR lie in the fact that: (1) mHR can steer the learned function which varies linearly along the underlying manifold and then extrapolate unseen data well; and (2) mHR can effectively explore the complementary properties of different features from different views and thus boost the image annotation performance significantly. We introduce mHR to kernel least squares and support vector machines for image annotation and conduct experiments on the PASCAL VOC'07 dataset \cite{EveringhamL2007}. To evaluate the performance of mHR, we also compare mHR with a number of baseline algorithms including Hessian SVM, Laplacian SVM, Hessian least squares, Laplacian least squares. The experimental results demonstrate the effectiveness of mHR by comparison with the baseline algorithms. The rest of the paper is organized as follows. In section 2, we survey related work on SSL and multiview learning. Section 3 presents the proposed mHR framework and Section 4 details the implementation of mHR for least squares and support vector machines. Experimental results are detailed in Section 5, followed by the conclusion in Section 6. \section{Related Work} The proposed mHR framework is motivated by manifold regularization-based SSL \cite{Donoho2003,Belkin2006,Kim} and graph ensemble-based multiview learning \cite{Xia2010a,Xie2011}. This section briefly reviews the related works for better understanding mHR. \subsection{SSL: Semi-supervised Learning} In recent years, many SSL algorithms have been developed, and these algorithms can be grouped into the following three categories: generative models \cite{Miller1996,KamalNi,Fujino2005,caoliangliang2010a}, transductive support vector machines (TSVM) \cite{Vapnic1998} and graph-based methods \cite{Belkin2006}. Generative models assume that examples are clustered and generated by the same parametric model. The purpose of these models is to learn the missing model parameters by employing the expectation-maximization algorithm \cite{Dempster1977}. Some typical models are mixture of Gaussian \cite{caoliangliang2010a}, mixture of experts \cite{Miller1996} and Na\"{\i}ve Bayes \cite{KamalNi,Tian2008}, \emph{etc.} TSVM \cite{Vapnic1998} assigns potential labels to unlabeled data by initiating SVM using labeled examples; hence, in TSVM, a linear boundary has the maximum margin on both the labeled data and the unlabeled data. Unlabeled data guide the linear boundary traverse through the low density regions. To tackle the non-convexity of the loss function and computation complexity of TSVM, various methods have been proposed \cite{Chapelle2005,Collobert2006}. Graph-based models assume that labels smooth over the graph and these models define a graph over training examples (labeled and unlabeled) to encode the similarity between examples. According to the regularization framework \cite{Belkin2006}, there are two terms in these methods: a loss function and a regularizer. By defining different loss functions and regularizers, a dozen methods can be obtained \cite{Elmoataz2008,Wangmeng2007}. Essentially, the graph regularizer plays a critical role and affects classification performance \cite{Zhu2007}. \subsection{Multiview Learning} Popular multiview learning algorithms can be grouped into the following three categories: co-training, multiple kernel learning and graph ensemble learning. Co-training based algorithms learn from two different views \cite{Blum1998} which assumes that the features obtained from the two different views are sufficient to train a good classifier. Co-training methods effectively exploit unlabeled data to improve the classification performance, especially when the two views are conditionally independent of one another \cite{Nigam2000}. Several extensions of co-training have been proposed in recent years, such as co-EM \cite{Jones2005}, SVM-2K \cite{Farquhar} and co-SVM \cite{Brefeld2006}. Theoretical justifications can be found in \cite{Dasgupta2001}. Multiple kernel learning (MKL) algorithms learn a kernel machine from multiple Gram kernel matrices \cite{Lanckriet2004,Bach2004,Sonnenburg2006,McFee2011,Meh2011}, each of which is built from a particular view of a feature. Lanckriet \emph{et al.} applied semidefinite programming (SDP) to MKL \cite{Lanckriet2004}. Bach \emph{et al.} \cite{Bach2004} applied sequential minimal optimization (SMO) to MKL and made MKL applicable to large scale data analytics problems. Sonnenburg \emph{et al.} \cite{Sonnenburg2006} reformulated the binary classification MKL problem as a semi-infinite linear programming problem. Gonen \emph{et al.} \cite{Meh2011} compared different MKL algorithms by performing experiments on real-world datasets. Graph ensemble-based multiview learning algorithms integrate multiple graphs to explore the complementary properties of different views, each of which encodes the local geometry of a particular view. For example, Xia \emph{et al.} \cite{Xia2010a} developed multiview spectral embedding for data clustering, which linearly combined different graph Laplacians through a set of optimal combination coefficients. Xie \emph{et al.} \cite{Xie2011} proposed a multiview stochastic neighbor embedding for data visualization, which integrated multiple features into a unified representation by learning the combination coefficients of different views based on the robust stochastic gradient descent method. \section{mHR: Multiview Hessian Regularization} In multiview semi-supervised learning (mSSL), we are given $l$ labeled examples $\mathcal{L}=\{(x_i^1,x_i^2,...,x_i^{N_v},y_i)\}_{i=1}^l$ and $u$ unlabeled examples $\mathcal{U}=\{x_i^1,x_i^2,...,x_i^{N_v}\}_{i=l+1}^{l+u}$, where $N_v$ is the number of views, $x_i^k\in \mathcal{X}^k$ for $k\in\{1,2,...,N_v \}$ is the $k^{th}$ view feature vector of the $i^{th}$ example (in the following section of this paper, we use $x_i=\{x_i^1,x_i^2,...,x_i^{N_v}\}$ to denote the $i^{th}$ example,$x^k$ denote the $k^{th}$ view feature), $y_i\in \{\pm 1\}$ is the label of $x_i$. Labeled examples are $(x,y)\in\mathcal{L}$ pairs drawn from a probability $\mathcal{P}$, and unlabeled examples are simply $x\in \mathcal{X}$ drawn according to the marginal distribution $\mathcal{P_X}$ of $\mathcal{P}$, in which $\mathcal{P_X}$ is a compact manifold $\mathcal{M}$. That means the conditional distribution $\mathcal{P}(y|x)$ varies smoothly along the geodesics in the intrinsic geometry of $\mathcal{M}$. And typically $l\ll u$. As usual, the goal is to predict the labels of unseen examples. By incorporating an additional regularization term to control the complexity of the function along the manifold $\mathcal{M}$, the mSSL problem, similar to SSL, can be written as the following optimization problem \begin{equation} \label{eq1} \min_{f\in \mathcal{H}_K }\frac{1}{l}\sum_{i=1}^l {\psi (f,x_i,y_i)}+\mathcal{G}(\| f \|) , \end {equation} where $\mathcal{G}(\| f \|)=\gamma_A \| f \|_K^2+\gamma_I\|f\|_K^2$, $\|f\|_K^2$ is the classifier complexity penalty term in an appropriate reproducing kernel Hilbert space (RKHS) $\mathcal{H}_K$, $\|f\|_I^2$ penalizes $f$ along the compact manifold $\mathcal{M}$, $\psi$ is a general loss function, and parameters $\gamma_A$ and $\gamma_I$ balance the loss function and regularizations $\|f\|_K^2$ and $\|f\|_I^2$ respectively. It transpires that the regularization term \(\|f\|_I^2\), estimated from the unlabeled examples, can help us explore the geometry of the marginal distribution \(\mathcal{P_X}\) which is usually unknown in practice. Although there are different choices for \(\|f\|_I^2\), Laplacian regularization (LR) \cite{Belkin2001,Belkin2006} has received intensive attention. In mSSL, it is important to precisely explore the local geometry of \(\mathcal{M}\), because of the underlying assumption that close examples \(x_i\) and \(x_j\) indicate similar conditional distributions \(\mathcal{P}(y_i |x_i )\) and \(\mathcal{P}(y_j |x_j )\). However, LR biases the classification function \(f\) towards a constant function \cite{Kim}, even though it can only handle examples represented by a single view feature. In this paper, we introduce the multiview Hessian regularization (mHR) to mSSL-based image annotation. The proposed mHR contains \(N_v\) Hessian regularizations \(H^k (f)\) for \(k \in {1,2,...,N_v }\), each of which is the matrix of the second order derivative of \(f\) with respect to the \(k^{th}\) view feature \(x^k\). It varies along the coordinate system and the coordinate system changes along the manifold. Thus, the Frobenius norm of \(H^k (f)\) is used as a regularizer for encoding an intriguing generalization of the thin-plate splines, because it is invariant along the manifold. We summary the computation of \(H^k (f)\) for the \(k^{th}\) view in the following 4 steps. \begin{itemize} \item For each example \(x_i^k\), we find its \(k\)-nearest neighbors and denote the collection of neighbors as \(\mathcal{N}_i^k\). Form a \(k\times(l+u)\) matrix \(X_i^k\) whose rows consist of the centralized examples \(x_j^k-x_i^k\) for all \(j\in \mathcal{N}_i^k\). This is different from Hessian Eigenmaps \cite{Donoho2003} that takes the mean of \(x_i^k\) and its \(k\)-nearest neighbors. We choose a different centralization method according to \cite{Kim} to obtain a robust estimation. \item Estimate the tangent space by performing a singular value decomposition of \(X_i^k=UDV^T\), the first \(m\) columns of \(U\) with the largest \(m\) eigenvalues give the tangent coordinates of examples in \(\mathcal{N}_i^k\). \item Perform the Gram-Schmidt orthonormalization process on the matrix \(M_i^k=[1\ U_1\ ...\ U_m\ U_{11}\ U_{12}\ ...\ U_{mm} ]\) which consists of the following columns: the first column is a vector of ones, and then the first \(m\) columns of \(U\); the last \(m(m+1)/2\) columns consist of the various cross-products and squares of those \(m\) columns yielding a matrix \(\hat{M}_i^k\), and then taking the last \(m(m+1)/2\) columns of \(\hat{M}_i^k\) as \(H_i\). The Frobenius norm of the Hessian of \(f\) on example \(x_a^k\), \(x_b^k (a,b\in\mathcal{N}_i^k)\) at example \(x_i^k\) is \(H_{iab}=\{(H_i )^T H_i\}_{ab}\). \item Summing up all the matrices \(H_{iab}\) yields an accumulated matrix \(H^k (f)\) and then the Hessian regularization for the \(k^{th}\) view is given by \(\mathbf{f}^T H^k \mathbf{f}\), \(\mathbf{f}=[f(x_1 ),f(x_2 ),...,f(x_{l+u} )]^T\). \end{itemize} In contrast to the LR, mHR enjoys the following advantages: (1) mHR constructs a Hessian regularization (HR) for each view which has a rich nullspace and drives the learned classification function which varies linearly along the manifold; and (2) mHR explores the complementary properties of multiview features. Thus, mHR can better exploit the intrinsic geometry of the marginal distribution \(\mathcal{P_X}\). \subsection{The General Framework} In multi-view learning, examples are represented by multiple features. The proposed framework integrates multiple kernel learning and ensemble graph learning. We first construct a new kernel from kernels defined on each view. Suppose \(K^k\), \(k=1,...,N_v\) is a valid (symmetric, positive definite) kernel on the \(k^{th}\) view, and then we define the new multiview kernel \begin{eqnarray} \label{eq2} \textbf{\emph{K}}=\sum_{k=1}^{N_v}{\theta^k K^k}, \hspace{1in}\\ s.t. \sum_{k=1}^{N_v}{\theta^k}=1, \theta^k\geq 0, k=1,...,N_v.\nonumber \end{eqnarray} Given a set of valid kernels \(\mathcal{K}=\{K^1,K^2,...,K^{N_v }\}\), we denote the convex hull of the set \(\mathcal{A}\) as \begin{eqnarray} \mathbf{conv}\mathcal{A}=\{\sum_{k=1}^{N_v}{\theta^k A^k}|\sum_{k=1}^{N_v}{\theta^k}=1, A^k\in \mathcal{A}, \theta^k\geq 0,\nonumber \\ k=1,...,N_v \}. \nonumber \end{eqnarray} Therefore, we have \(\emph{\textbf{K}}\in conv\mathcal{K}\). In the Appendix, we show that \(\textbf{\emph{K}}\) is a valid (symmetric, positive definite) kernel. We then have the regularization term \begin{eqnarray} \|f\|_K^2=\mathbf{f}^T K \mathbf{f}=\mathbf{f}^T (\sum_{k=1}^{N_v}{\theta^k K^k}) \mathbf{f}=\sum_{k=1}^{N_v} {\theta^k {\|f\|_K^2}_{(k)}}.\nonumber \end{eqnarray} Subsequently, we approximate the intrinsic geometry of a manifold using the convex hull of manifold candidates on each view. Suppose \(H^j\) is the Hessian of the \(j^{th}\) view, we denote \begin{eqnarray} \label{eq3} \textbf{\emph{H}}=\sum_{j=1}^{N_v}{\beta^j H^j}, \hspace{1in}\\ s.t. \sum_{j=1}^{N_v}{\beta^j} =1,\beta^j \geq 0,j=1,...,N_v.\nonumber \end{eqnarray} If we define a set of Hessians \(\mathcal{H}=\{H^1,H^2,...,H^{N_v }\}\), we have \(\textbf{\emph{H}}\in conv\mathcal{H}\) and mHR is defined by \begin{eqnarray} \|f\|_I^2=\mathbf{f}^T \textbf{\emph{H}}\mathbf{f}=\mathbf{f}^T (\sum_{j=1}^{N_v}{\beta^j H^j})\mathbf{f}=\sum_{j=1}^{N_v}{\beta^j {\|f\|_I^2}_{(j)}}.\nonumber \end{eqnarray} Therefore, we can obtain the mHR framework for multiview learning \begin{eqnarray} \label{eq4} \min_{f \in \mathcal{H}_K, \theta \in \mathbf{R}^{N_v}, \beta \in \mathbf{R}^{N_v}}{\frac{1}{l} \sum_{i=1}^l {\psi (f,x_i,y_i)} + \gamma_A \sum_{k=1}^{N_v}{\theta^k {\|f\|_K^2}_{(k)}}} \nonumber \\ { + \gamma_I \sum_{j=1}^{N_v}{\beta^j {\|f\|_I^2}_{(j)}} + \gamma_\theta \|\theta\|_2^2 + \gamma_\beta \|\beta\|_2^2 }, \hspace{0.1in}\\ s.t. \sum_{k=1}^{N_v}\theta^k =1,\theta^k \geq 0,k=1,...,N_v, \hspace{0.5in}\nonumber \\ \sum_{j=1}^{N_v}\beta^j =1,\beta^j \geq 0,j=1,...,N_v, \hspace{0.5in}\nonumber \end{eqnarray} where the regularization terms \(\|\theta\|_2^2\) and \(\|\beta\|_2^2\) are introduced to avoid the model parameter overfitting to only one view kernel or manifold, and \(\gamma_\theta \in \mathbf{R}^+ \)and \(\gamma_\beta \in \mathbf{R}^+\) are the trade-off parameters to control the contributions of the regularization terms \(\|\theta\|_2^2\) and \(\|\beta\|_2^2\) respectively. For fixed \(\theta\) and \(\beta\), (\ref{eq4}) degenerates to (\ref{eq1}), with \( \textbf{\emph{K}}=\sum_{k=1}^{N_v}{\theta^k K^k} \)and \(\textbf{\emph{H}}=\sum_{j=1}^{N_v}{\beta^j H^j}\). On the other hand, for fixed \(f\) and \(\beta\), (\ref{eq4}) can be simplified to: \begin{eqnarray} \label{eq5} \theta^*={\arg\min}_{\theta \in \mathbf{R}^{N_v } }{\sum_{k=1}^{N_v}{\theta^k h^k} +\theta^T \textbf{\emph{B}} \theta},\\ s.t. \sum_{k=1}^{N_v}\theta^k =1,\theta^k \geq 0,k=1,...,N_v),\nonumber \\ \textbf{\emph{B}}=\textbf{\emph{K}}^T \textbf{\emph{H}} \textbf{\emph{K}}.\hspace{1.3in}\nonumber \end{eqnarray} And for fixed \(f\) and \(\theta\), (\ref{eq4}) can be simplified to: \begin{eqnarray} \label{eq6} \theta^*={\arg\min}_{\beta \in \mathbf{R}^{N_v } }{\sum_{k=1}^{N_v}{\beta^k h^k} + \gamma_\beta \|\beta\|_2^2},\\ s.t. \sum_{k=1}^{N_v}\beta^k =1,\beta^k \geq 0,k=1,...,N_v.\nonumber \end{eqnarray} The solution of (\ref{eq5}) and (\ref{eq6}) can be viewed as the learning of the optimal linear combination of the kernels or Hessians over different views. \subsection{Representer Theorem and Convergence Analysis} This section shows the representer theorem of mHR and the convergence analysis for the alternating optimization of (\ref{eq4}). Detailed proofs are given in the appendix. We first show the following lemmas which are essential for the representer theorem. \emph{Lemma 1:} If \(\mathcal{G}(\|f\| )\) is a strictly monotonically increasing real-valued function with respect to \(\|f\|\), the minimizer of the optimization problem (\ref{eq1}) admits an expansion \begin{eqnarray} f^*=\sum_{i=1}^{l+u}{\alpha_i K(x_i,x)} \nonumber \end{eqnarray} in terms of the labeled and unlabeled examples. \emph{Lemma 2:} \(\textbf{\emph{K}}\in conv\mathcal{K}\) is a valid kernel. \emph{Lemma 3:} \(\textbf{\emph{H}}\in conv\mathcal{H}\) is semi-definite positive. \textbf{Theorem 1.} The minimization of (\ref{eq4}) w.r.t. \(f\) with fixed \(\theta\) and \(\beta\), exits and has the representation \begin{equation} \label{eq7} f^*=\sum_{i=1}^{l+u}{\alpha_i \textbf{\emph{K}}(x_i,x)}=\sum_{i=1}^{l+u}{\alpha_i \sum_{k=1}^{N_v}{\theta^k K^k (x_i^k,x^k)}}, \end{equation} which is an expansion in terms of the labeled and unlabeled example. The representer theorem shows the solution of (\ref{eq4}) exists and has the general form of (\ref{eq7}) given fixed \(\beta\) and \(\theta\). The purpose of mHR is to learn the classifier \(f\), and the combination coefficients \(\beta\) and \(\theta\). In this paper, we use the alternating optimization \cite{Bezdek2003} to iteratively solve (\ref{eq4}). First, fix \(\theta\) and \(\beta\) to optimize \(\alpha\). Then, fix \(\alpha\) and \(\beta\) to optimize \(\theta\). Finally, fix \(\alpha\) and \(\theta\) to optimize \(\beta\). We conduct the above three steps iteratively until convergence. The above alternating iteration process is convergent, and the convergence theorem is given below. \textbf{Theorem 2.} Given a convex loss function \(\psi\), the alternating optimization for solving (\ref{eq4}) produces a monotonically decreasing sequence that converges to a local minimum. The proof of Theorem 2 shows that for a convex loss function, (\ref{eq4}) is convex w.r.t. \(f\) for fixed \(\theta\) and \(\beta\), and w.r.t \(\theta\) (or \(\beta\)) for fixed \(f\) and \(\beta\) (or \(\theta\)). However, (\ref{eq4}) is not convex for \((f,\theta,\beta)\) jointly. Fortunately, we can initialize \(\theta^k=1/N_v\) and \(\beta^k=1/N_v\) for all \(k=1,...,N_v\). This initialization empirically results in a satisfied solution of (\ref{eq4}). \section{Example Algorithms} Generally, \(\psi(f,x_i,y_i )\) can be any loss function and mHR can be applied to general purpose mSSL-based applications. In this section, we show the implementations of mHR through kernel least squares (KLS) and SVM. \subsection{mHR support vector machines (mHR-SVM)} SVM minimizes the hinge loss, \emph{i.e.} \(\psi(f,x_i,y_i )={(1-y_i f(x_i))}_+=\max{(0,1-y_i f(x_i))}\). By introducing mHR to SVM, we can obtain mHR-SVM \begin{eqnarray} \label{eq8} \min_{f \in \mathcal{H}_K,\theta \in \mathbf{R}^{N_v},\beta \in \mathbf{R}^{N_v} }{\gamma_A \sum_{k=1}^{N_v}{\theta^k {\|f\|_K^2}_{(k)}} +\gamma_I \sum_{j=1}^{N_v}{\beta^j {\|f\|_I^2}_{(j)}}} \nonumber \\ {+ \frac{1}{l} \sum_{i=1}^l{{(1-y_i f(x_i))}_+} + \gamma_\theta \|\theta\|_2^2 + \gamma_\beta \|\beta\|_2^2},\\ s.t. \sum_{k=1}^{N_v}\theta^k =1,\theta^k \geq 0,k=1,...,N_v, \hspace{0.5in}\nonumber \\ \sum_{j=1}^{N_v}\beta^j =1,\beta^j \geq 0,j=1,...,N_v.\hspace{0.5in}\nonumber \end{eqnarray} Given fixed \(\beta\) and \(\theta\), (\ref{eq8}) can be expressed as following by substituting (\ref{eq7}) into (\ref{eq8}) \begin{eqnarray} \label{eq9} \min_{\alpha\in\mathbf{R}^{l+u},\theta\in\mathbf{R}^{N_v },\beta\in\mathbf{R}^{N_v}} {\gamma_A \alpha^T \textbf{\emph{K}} \alpha + \gamma_I \alpha^T \textbf{\emph{KHK}} \alpha } \nonumber \\ {+\frac{1}{l} \sum_{i=1}^l{{(1-y_i \textbf{\emph{K}}(x_i,x)\alpha)}_+} + \gamma_\theta \|\theta\|_2^2 + \gamma_\beta \|\beta\|_2^2}, \\ s.t. \sum_{k=1}^{N_v}{\theta^k} =1,\theta^k \geq 0,k=1,...,N_v, \nonumber\\ \sum_{j=1}^{N_v}{\beta^j} =1,\beta^j \geq 0,j=1,...,N_v, \nonumber \end{eqnarray} where \(\textbf{\emph{K}}=\sum_{k=1}^{N_v}{\theta^k K^k}\), \(\textbf{\emph{H}}=\sum_{j=1}^{N_v}{\beta^j H^j}\), and \({(1-y_i \textbf{\emph{K}}(x_i,x)\alpha)}_+=\max{(0,1-y_i \textbf{\emph{K}}(x_i,x)\alpha)}\) is the hinge loss function. Given fixed \(\theta\) and \(\beta\), (\ref{eq9}) can be rewritten as \begin{equation} \label{eq10} \min_{\alpha \in \mathbf{R}^{l+u}}{F(\alpha)=R(\alpha)+\psi(\alpha)}, \end{equation} where \(R(\alpha)=\gamma_A \alpha^T \textbf{\emph{K}} \alpha +\gamma_I \alpha^T \textbf{\emph{KHK}} \alpha + \gamma_\theta \|\theta\|_2^2 + \gamma_\beta \|\beta\|_2^2 \) and \(\psi(\alpha)=\frac{1}{l} \sum_{i=1}^l{{(1-y_i \textbf{\emph{K}}(x_i,x)\alpha)}_+} \). The loss function part \(\psi(\alpha)\) is non-differentiable. Hence, we firstly smooth the hinge loss and then use Nesterov's optimal gradient method \cite{Nesterov2005a} to solve (\ref{eq10}). In the \(t^{th}\) iteration round, two auxiliary optimizations are introduced to compute the solution. Suppose \(F_\mu(\alpha)\) is a smooth function of \(F(\alpha)\), \(L_\mu\) is the Lipschitz constant of \(F_\mu (\alpha)\), \(\alpha^{(t)}\) is the solution at the \(t^{th}\) iteration, the two auxiliary optimizations are given by \begin{eqnarray} \min_{\mathrm{y} \in \mathbf{R}^{l+u} }{<\nabla F_\mu(\alpha^{(t)}),\mathrm{y}-\alpha^{(t)}> + \frac{L_\mu}{2} \|\mathrm{y}-\alpha^{(t)}\|_2^2}, \nonumber \end{eqnarray} and \begin{eqnarray} \min_{z \in \mathbf{R}^{l+u}}{ \sum_{i=1}^t{\frac{i+1}{2} [F_\mu (\alpha^{(i)} ) + < \nabla F_\mu (\alpha^{(i)}),z-\alpha^{(i)}>]}} \nonumber \\ {+ \frac{L_\mu}{2} \|z-\hat{\alpha}\|_2^2 }, \nonumber \end{eqnarray} where \(\hat{\alpha}\) is a guess solution of \(\alpha\). The solutions of the two optimizations are \begin{eqnarray} \label{eq11} \mathrm{y}^{{t}}=\alpha^{(t)}-\frac{1}{L_\mu} \nabla F_\mu(\alpha^{(t)}), \end{eqnarray} \begin{eqnarray} \label{eq12} z^{(t)}=\hat{\alpha}-\frac{1}{L_\mu} \sum_{i=1}^t{\frac{i+1}{2} \nabla F_\mu (\alpha^{(i)})}. \end{eqnarray} By using the weighted sum of \(\mathrm{y}^{(t)}\) and \(z^{(t)}\), we obtain the solution of (\ref{eq9}) after the \(t^{th}\) iteration round, \begin{eqnarray} \label{eq13} \alpha^{(t+1)}=\frac{2}{t+3} z^{(t)} + \frac{t+1}{t+3} \mathrm{y}^{(t)}. \end{eqnarray} According to \cite{Nesterov2005a}, the hinge loss can be smoothed by subtracting a strongly convex function from its saddle point function. The smoothed hinge loss can then be written as \begin{eqnarray} \label{eq14} \psi_\mu=\max_{\mathbf{u} \in \mathcal{Q}}{\mathbf{u}_i (1-y_i \textbf{\emph{K}}(x_i,x)\alpha) - \frac{\mu}{2} \|\textbf{\emph{K}}(x_i,x)\|_\infty \mathbf{u}_i^2}, \\ \mathcal{Q}=\{\mathbf{u}: 0 \leq \mathbf{u}_i \leq 1, \mathbf{u} \in \mathbf{R}^l \}, \nonumber \end{eqnarray} where \(\mu\) is the smooth parameter. To solve (\ref{eq14}), \(\mathbf{u}_i\) can be computed and projected on \(\mathcal{Q}\) by using \begin{eqnarray} \label{eq15} \mathbf{u}_i=median\{0,1,\frac{1-y_i \textbf{\emph{K}}(x_i,x)\alpha}{\mu\|\textbf{\emph{K}}(x_i,x)\|_\infty }\}. \end{eqnarray} Then the gradient \(\nabla F_\mu (\alpha^t )\) is \begin{eqnarray} \label{eq16} \nabla F_\mu(\alpha^t)=2(\gamma_A \textbf{\emph{K}} + \gamma_I \textbf{\emph{KHK}}) \alpha - \frac{1}{l}{(Y\textbf{\emph{K}}(x_i,x))}^T \mathbf{u}, \end{eqnarray} where \(Y=diag(y)\). The Lipschitz constant of \(\psi(\alpha)\) is \begin{eqnarray} L^\psi=\frac{1}{\mu} \max_i{\frac{\|\textbf{\emph{K}}(x_i,x)^T \textbf{\emph{K}}(x_i,x)\|_2}{\|\textbf{\emph{K}}(x_i,x)\|_\infty}}. \nonumber \end{eqnarray} Then the Lipschitz constant of \(F_\mu(\alpha)\) is given by \begin{eqnarray} \label{eq17} F_\mu = L^R + L^\psi = \|2(\gamma_A \textbf{\emph{K}} + \gamma_I \textbf{\emph{KHK}})\|_2 \nonumber \\ + \frac{1}{\mu} \max_i{\frac{\|\textbf{\emph{K}}(x_i,x)^T \textbf{\emph{K}}(x_i,x)\|_2}{\|\textbf{\emph{K}}(x_i,x)\|_\infty}}. \end{eqnarray} After substituting (\ref{eq17}) into (\ref{eq11}), (\ref{eq12}), we obtain \(\alpha\) according to (\ref{eq13}). The procedure for optimizing \(\theta\) given fixed \(\alpha\) and \(\beta\) is the same as that for optimizing \(\beta\) given fixed \(\alpha\) and \(\theta\). The convergence analysis in Theorem 2 ensures the alternating optimization obtains a local optimal solution. In this paper, we initialize \(\theta^k=1/N_v\) and \(\beta^k=1/N_v\) for all \(k=1,...,N_v\), and update them by using the coordinate descent method. \begin{figure*}[!t] \centering \includegraphics[width=5in]{figure1} \caption{Example images of PASCAL VOC'07 including person, bird, cat, cow, dog, horse, sheep, aeroplane, bicycle, boat, bus, car, motorbike, train, bottle, chair, dining table, potted plant, sofa, tv/monitor.} \label{fig1} \end{figure*} \begin{table*}[!t] \caption{List of algorithms} \label{Table1} \centering \begin{tabular}{|l|l|l|} \hline abbreviation & method & feature/view\\ \hline \hline SVM & support vector machine & different visual feature/single view\\ \hline LapSVM & Laplacian regularized SVM & different visual feature/single view\\ \hline HesSVM & Hessian regularized SVM & different visual feature /single view\\ \hline ConSVM & support vector machine & concatenation of 15 different visual features /multiview\\ \hline LapCSVM & Laplacian regularized SVM & concatenation of 15 different visual features /multiview\\ \hline HesCSVM & Hessian regularized SVM & concatenation of 15 different visual features /multiview\\ \hline AveSVM & support vector machine & average of 15 different kernels /multiview\\ \hline LapASVM & Laplacian regularized SVM & average of 15 different kernels /multiview\\ \hline HesASVM & Hessian regularized SVM & average of 15 different kernels /multiview\\ \hline mHesSVM & multi-view Hessian regularized SVM & multiple kernels /multiview\\ \hline \hline KLS & Kernel least squares & different visual feature /single view\\ \hline LapLS & Laplacian regularized least squares & different visual feature /single view\\ \hline HesLS & Hessian regularized least squares & different visual feature /single view\\ \hline ConLS & Kernel least squares & concatenation of 15 different visual features /multiview\\ \hline LapCLS & Laplacian regularized least squares & concatenation of 15 different visual features /multiview\\ \hline HesCLS & Hessian regularized least squares & concatenation of 15 different visual features /multiview\\ \hline AveLS & Kernel least squares & average of 15 different kernels /multiview\\ \hline LapALS & Laplacian regularized least squares & average of 15 different kernels /multiview\\ \hline HesALS & Hessian regularized least squares & average of 15 different kernels /multiview\\ \hline mHesLS & multi-view Hessian regularized LS & multiple kernels /multiview\\ \hline \end{tabular} \end{table*} \subsection{mHR kernel least squares (mHR-KLS)} The loss in regularized kernel least squares is defined by the squared loss, \emph{i.e.} \(\psi(f,x_i,y_i )={(y_i-f(x_i))}^2\). By introducing mHR to regularized KLS, we have mHR-KLS \begin{eqnarray} \label{eq18} \min_{f \in \mathcal{H}_K,\theta \in \mathbf{R}^{N_v},\beta \in \mathbf{R}^{N_v}}{ \gamma_A \sum_{k=1}^{N_v}{\theta^k {\|f\|_K^2}_{(k)}} + \gamma_I \sum_{j=1}^{N_v}{\beta^j {\|f\|_I^2}_{(j)}} } \nonumber \\ {+ \frac{1}{l} \sum_{i=1}^l{{(y_i - f(x_i))}^2} + \gamma_\theta \|\theta\|_2^2 + \gamma_\beta \|\beta\|_2^2}. \end{eqnarray} According to Theorem 1, given fixed \(\beta\) and \(\theta\), we substitute (\ref{eq7}) into (\ref{eq18}) and obtain \begin{eqnarray} \label{eq19} \min_{\alpha \in \mathbf{R}^{l+u},\theta \in \mathbf{R}^{N_v },\beta \in \mathbf{R}^{N_v}} { \gamma_A \alpha^T \textbf{\emph{K}} \alpha + \gamma_I \alpha^T \textbf{\emph{KHK}} \alpha}\nonumber \\ {+\frac{1}{l} \sum_{i=1}^l{{(Y-J\textbf{\emph{K}}\alpha)}^T (Y-J\textbf{\emph{K}}\alpha)} + \gamma_\theta \|\theta\|_2^2 + \gamma_\beta \|\beta\|_2^2}, \\ s.t. \sum_{k=1}^{N_v}{\theta^k} =1,\theta^k \geq 0,k=1,...,N_v, \nonumber\\ \sum_{j=1}^{N_v}{\beta^j} =1,\beta^j \geq 0,j=1,...,N_v, \nonumber \end{eqnarray} where \(\textbf{\emph{K}}=\sum_{k=1}^{N_v}{\theta^k K^k}\), \(\textbf{\emph{H}}=\sum_{j=1}^{N_v}{\beta^j H^j}\),\ \(Y=[y_1,y_2,...,y_l,0,...,0] \in \mathbf{R}^{l+u}\) is an \((l+u)\)-dimensional vector and \(J \in \mathbf{R}^{l+u} \times \mathbf{R}^{l+u}\) is a diagonal matrix with the first \(l\) diagonal elements as 1 and the rest 0. The solution of (\ref{eq19}) can be obtained by setting the derivatives of its object function w.r.t \(\alpha\) to zero. Then we have \begin{eqnarray} \label{eq20} \alpha^* = {(J\textbf{\emph{K}} + \gamma_A l I_{l+u} + \gamma_I l \textbf{\emph{HK}})}^{-1} Y, \end{eqnarray} where \(I_{l+u}\in \mathbf{R}^{l+u} \times \mathbf{R}^{l+u}\) is an identity matrix. The procedure for optimizing \(\theta\) given fixed \(\alpha\) and \(\beta\) and optimizing \(\beta\) given fixed \(\alpha\) and \(\theta\) is similar to that used in mHR-SVM. The convergence analysis in Theorem 2 ensures the alternating optimization obtains a local optimal solution. In this paper, we initialize \(\theta^k=1/N_v\) and \(\beta^k=1/N_v\) for all \(k=1,...,N_v\), and update them by using the coordinate descent method. \begin{figure*}[!t] \centering \includegraphics[width=7in]{figure2} \caption{The mAP of different SVM methods on 2250 labeled images. For each feature/view, the methods from left to right are SVM, LapSVM and HesSVM.} \label{fig2} \end{figure*} \section{Experiments} To evaluate the effectiveness of the proposed mHR, we apply mHR-SVM and mHR-KLS to image annotation \cite{Caoliangliang2010} and conduct experiments on the PASCAL VOC'07 dataset \cite{EveringhamL2007}. This dataset contains 9,963 images of 20 visual object classes. Figure 1 shows 20 example images sampled from these 20 classes. In our experiments, 15 visual features provided by Guillaumin \emph{et al.} \cite{Guillaumin2010} are used, including GIST feature, 2 RGB features, 2 Lab features, 2 HSV features, 2 Hue features, 2 SIFT features, 2 Harris features, and 2 Harris+SIFT features. We use the standard training/test partition according to \cite{EveringhamL2007}, in which the training set contains 5,011 images and the test set contains 4,952 images. To choose suitable model parameters, we divide the training set into two subsets; one contains 4,500 images for model training and one contains 511 images for model parameter tuning. We randomly divide the training set 10 times to examine the robustness of different learning models. In the semi-supervised learning experiments, in particular, we assign 10\%, 20\%, 30\%, 50\%, 70\% and 90\% as labeled data and the rest as unlabeled data. All parameters are tuned in the case of 10\% labeled data and 90\% unlabeled data. Particularly, parameters \(\gamma_A\), \(\gamma_I\), \(\gamma_\theta\) and \(\gamma_\beta\) are tuned from the candidate set \(\{10^e |e=-10,-9,...,9,10\}\) on validation set in the case of 10\% labeled data and 90\% unlabeled data. And the parameter \(k\) which is the number of the neighbors in \(k\)-nearest neighbors in computing Hessian and graph Laplacian is fixed to 100 for all experiments. We compare the proposed mHR-SVM with SVM and Laplacian regularized SVM (LapSVM), and compare mHR-KLS with KLS and Laplacian regularized KLS (LapKLS). By replacing the Laplacian matrix in LapSVM and LapKLS with the Hessian matrix, we obtain Hessian regularized SVM (HesSVM) and Hessain regularized KLS (HesKLS), respectively. HesSVM and HesKLS are important to validate the effectiveness of Hessian regularization in SSL. To comprehensively examine the effectiveness of mHR, we also compare mHR-SVM (mHR-KLS) with the feature concatenation method (by concatenating 15 different visual features into a long feature vector) and average kernel method (by taking the average of 15 different kernels, each of which is obtained from a particular visual feature) used in SVM (KLS), LapSVM (LapKLS), and HesSVM (HesKLS). In summary, we have 18 baseline algorithms listed in Table 1. We use the average precision (AP) \cite{Wangmeng2009} for each class and mean average precision (mAP) of all classes as measure criteria. In our experiments, the AP and mAP are computed using PASCAL VOC method \cite{EveringhamL2007}, \emph{i.e.} \begin{eqnarray} AP=\frac{1}{11}\sum_t{[\max_{p(k)\geq t}{p(k)}]},t \in \{0, 0.1, 0.2, ..., 1.0\},\nonumber \end{eqnarray} and \begin{eqnarray} mAP=\frac{\sum_{i=1}^\#{AP_i}}{\#\{visual\ object\ classes\}}, \nonumber \end{eqnarray} where \(p(k)\) is the precision at the cut-off of the rank index of positive sample \(k\). And to demonstrate the robustness of the algorithms, we report the results (AP and mAP) using the error bars which can show the confidence intervals of data and notched box plot in which five values from a set of data are conventionally used (the extremes, the upper and lower hinges, and the median) and the notches surrounding the medians provide a measure of the rough significance of differences between the values. \subsection{Effectiveness of HR} To evaluate the effectiveness of HR, we construct HesSVM (HesLS), LapSVM (LapLS) and SVM (KLS) over 20 visual object classes on different 15 features respectively. We also construct mHesSVM (mHesLS) and the corresponding feature concatenation method and average kernel method over all visual object classes. Figure 2 is a notched box plot of the mAP of different SVM methods on 2250 labeled images. From Figure 2, we can see that HR performs better than LR in most cases. Figure 2 also shows that the multiview methods are significantly better than single view methods and mHR outperforms other multiview methods. \begin{figure*}[!t] \centering \includegraphics[width=7.1in]{figure3} \caption{The AP of different multiview methods on some classes including boat, bottle, car, cow, dog, horse, person and potted plant. The upper 8 subfigures are SVM methods, and the lower 8 are LS methods.} \label{fig3} \end{figure*} \subsection{Performance of mHR} To further evaluate the performance of mHR, we compare the AP of mHR with the feature concatenation method and average kernel method over each visual object class. We also compare the mAP of different methods over all classes. Figure 3 is the AP of different multiview methods on selected visual object classes. Each subfigure corresponds to one visual object class of the dataset. The x-coordinate is the number of labeled images. From Figure 3, we can see that mHR significantly boosts performance, especially when the number of labeled images is small. Figure 4 is the mAP boxplot of different multiview methods. The subfigures correspond to the performance on different numbers (450, 900, 1350, 2250, 3150 and 4050) of labeled images. From Figure 4, we can see that the average kernel method performs better than the feature concatenation method in SVM implementation. However, the feature concatenation method performs better than the average kernel method in KLS implementation, and in both SVM and KLS implementations, mHR outperforms the other multiview methods. \begin{figure*}[!t] \centering \includegraphics[width=7in]{figure4} \caption{The mAP of different multiview methods. The upper 6 subfigures are SVM methods, and the lower 6 are LS methods.} \label{fig4} \end{figure*} \section{Concluding Remarks} Manifold regularization-based semi-supervised learning algorithms have been successfully applied to image annotation. However, most of the existing methods are based on Laplacian regularization which suffers from the lack of extrapolating power, particularly when the number of labeled examples is small. In addition, conventional methods are often designed to cover single views, which is not applicable to the practical multiview applications. Therefore, we present multiview Hessian regularization (mHR) to tackle the above two problems for image annotation. The proposed mHR can naturally combine both multiple kernels and Hessian regularizations obtained from different views to boost learning performance. With the help of Hessian regularization and the multi-view feature, mHR can steer the learned function which varies linearly along the data manifold and can competently explore the complementary information from different view features. We apply mHR to kernel least squares and support vector machines as two implementations for image annotation. Extensive experiments on the PASCAL VOC'07 dataset demonstrate that the proposed mHR significantly outperforms LR-based and other related algorithms. \appendices \section{Proof of Lemma 1} \begin{IEEEproof} Suppose we project \(f\) onto the subspace \(S=span{K(x_i,x):1 \leq i \leq l+u} \) spanned by kernels. Any \(f \in \mathcal{H}_K\) can then be represented as \(f=f_S+f_{S^\perp}\), where \(f_S\) is the component along the subspace and \(f_{S^\perp}\) is the component perpendicular to the subspace. Then we have \(\|f\|^2=\|f_S\|^2 + \|f_{S^\perp}\|^2 \geq \|f_S\|^2\). Since \(\mathcal{G}(\|f\| )\) is a strictly monotonically increasing real-valued function on \(\|f\|\), we have \(\mathcal{G}(\|f\|^2 )\geq \mathcal{G}(\|f_S\|^2 )\). This implies that \(\mathcal{G}(\|f\| )\) is minimized if \(f\) lies in the subspace. Note the reproducing property of the kernel \(K\), then \(f(x_i )=<f,K(x_i,x)>=<f_S,K(x_i,x)> + <f_{S^\perp},K(x_i,x)>=f_S (x_i )\). That means the loss function part of (\ref{eq1}) only depends on \(f_S\). Thus, the minimizer of the optimization problem (\ref{eq1}) can be obtained when \(f\) lies in the subspace \(S\), that is \(f^*=\sum_{i=1}^{l+u}{\alpha_i K(x_i,x)}\). This completes the proof of Lemma 1. \end{IEEEproof} \section{Proof of Lemma 2} \begin{IEEEproof} Suppose \(K^k=<\phi_k (w^k ),\phi_k (v^k )>:\mathcal{X} \times \mathcal{X} \mapsto \mathbf{R} \) is valid (symmetric, positive definite) for all \(k=1,...,N_v\). Then we have \(\theta^k K^k (w^k,v^k)=<\sqrt{\theta^k} \phi_k (w^k ),\sqrt{\theta^k} \phi_k (v^k )>\). Then \begin{eqnarray} &&\textbf{\emph{K}}(w,v)=\sum_{k=1}^{N_v}{\theta^k K^k (w^k,v^k)} \nonumber \\ &&=\sum_{k=1}^{N_v}{<\sqrt{\theta^k} \phi_k (w^k ),\sqrt{\theta^k} \phi_k (v^k )>} \nonumber \\ &&=<\mathbf{W},\mathbf{V}>, \nonumber \end{eqnarray} where \(\mathbf{W}=[\sqrt{\theta^1} \phi_1 (w^1 )...\sqrt{\theta^k} \phi_k (w^k )...\sqrt{\theta^{N_v}} \phi_{N_v} (w^{N_v} )]\), \(\mathbf{V}=[\sqrt{\theta^1} \phi_1 (v^1 )...\sqrt{\theta^k} \phi_k (v^k )...\sqrt{\theta^{N_v}} \phi_{N_v} (v^{N_v} ) ]\). We can see that \( \textbf{\emph{K}}(w,v)\) can be represented as an inner product, and thus it is also a valid kernel. \end{IEEEproof} \section{Proof of Lemma 3} \begin{IEEEproof} For any \(\beta\) that satisfies the constraints in (\ref{eq3}), \(\textbf{\emph{H}}=\sum_{j=1}^{N_v}{\beta^j H^j}\) is a convex combination of the Hessian energy in the set \(\mathcal{H}\). According to the computation procedure of Hessian, we have \(H^j=\sum_i{H_{iab}^j},\ i=1,2,...,l+u\), where \(H_{iab}^j=\{{(H_i^j )}^T H_i^j\}_{ab}\) is the Frobenius norm of the Hessian of \(f\) on example \(x_a^j,x_b^j (a,b \in \mathcal{N}_i^j)\) at example \(x_i^j\). \(H_{iab}^j\) is semi-definite positive, then we have \(H^j\) is semi-definite positive. Hence for any \(\beta^j \geq 0\), \( \textbf{\emph{H}}=\sum_{j=1}^{N_v}{\beta^j H^j}\) is semi-definite positive \cite{Horn1990}. \end{IEEEproof} \section{Proof of Theorem 1} \begin{IEEEproof} Since \(\textbf{\emph{K}}\) is a valid kernel and \(\textbf{\emph{H}}\) is semi-definite positive, \(\|f\|_K^2 = \mathbf{f}^T \textbf{\emph{K}} \mathbf{f} = \mathbf{f}^T (\sum_{k=1}^{N_v}{\theta^k K^k})\mathbf{f}=\sum_{k=1}^{N_v}{\theta^k {\|f\|_K^2}_{(k)}}\) and \(\|f\|_I^2 =\mathbf{f}^T \textbf{\emph{H}}\mathbf{f}=\mathbf{f}^T (\sum_{j=1}^{N_v}{\beta^j H^j})\mathbf{f}=\sum_{j=1}^{N_v}{\beta^j {\|f\|_I^2}_{(j)}}\), then \(\mathcal{G}(\|f\| )=\gamma_A \|f\|_K^2 + \gamma_I \|f\|_I^2\) is a monotonically increasing real-valued function on \(\|f\|\). According to Lemma 1, the proof of Theorem 1 is complete. \end{IEEEproof} \section{Proof of Theorem 2} \begin{IEEEproof} Denote the objective function in (\ref{eq4}) as \(F\), the solution at the \(t^{th}\) iteration round as \((f^{(t)},\theta^{(t)},\beta^{(t)})\). Given fixed \(\theta^{(t-1)}\) and \(\beta^{(t-1)}\) obtained at the \({(t-1)}^{th}\) iteration round, the optimization of (\ref{eq4}) w.r.t. \(f\) at the \(t^{th}\) iteration round degenerates to (\ref{eq1}). This degenerated problem is convex, because the loss function \(\psi\) is convex. Then we have that at the \(t^{th}\) iteration round, \begin{eqnarray} F(f^{(t)},\theta^{(t-1)},\beta^{(t-1)}) \leq F(f^{(t-1)},\theta^{(t-1)},\beta^{(t-1)}).\nonumber \end{eqnarray} On the other hand, for fixed \(f^{(t)}\) and \(\beta^{(t-1)}\) , the optimization of (\ref{eq4}) w.r.t. \(\theta\) generates to (\ref{eq5}). If \(\textbf{\emph{B}}\) is positive semi-definite, (\ref{eq5}) is a quadratic programming problem. By solving (\ref{eq5}), we have \begin{eqnarray} F(f^{(t)},\theta^{(t)},\beta^{(t-1)}) \leq F(f^{(t)},\theta^{(t-1)},\beta^{(t-1)}).\nonumber \end{eqnarray} Then for fixed \(f^{(t)}\) and \(\theta^{(t)}\), the minimizing of (\ref{eq4}) w.r.t. \(\beta\) degenerates to (\ref{eq6}) . By solving (\ref{eq6}), we have \begin{eqnarray} F(f^{(t)},\theta^{(t)},\beta^{(t)}) \leq F(f^{(t)},\theta^{(t)},\beta^{(t-1)}) \hspace{0.6in} \nonumber\\ \leq F(f^{(t)},\theta^{(t-1)},\beta^{(t-1)}) \leq F(f^{(t-1)},\theta^{(t-1)},\beta^{(t-1)}).\nonumber \end{eqnarray} That implies the objective function \(F\) consistently decreases. Therefore, this completes the proof of Theorem 2. \end{IEEEproof} \ifCLASSOPTIONcaptionsoff \newpage \fi
{'timestamp': '2019-04-24T02:04:26', 'yymm': '1904', 'arxiv_id': '1904.10100', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.10100'}
arxiv
\section{The Discrete Fourier Transform} In this section, we briefly present the decomposition of both the 1D and multi dimensional DFTs, expressing the algorithms in terms of linear algebra operations and outlining the possibilities for parallelization. \begin{figure}[t] \centering \includegraphics[width=0.45\textwidth]{dft16.png} \caption{The decomposition of the 1D DFT using the Cooley-Tukey algorithm for a given problem size of $16 = 4\cdot 4$. The algorithm requires four steps, namely two batch DFTs (I) and (IV) of size $4$, a point-wise operation (II) and a transposition (III). Data is stored in column major order.} \label{fig:1dct} \vspace{-5mm} \end{figure} \subsection{The 1D Discrete Fourier Transform} The 1D DFT is a matrix-vector multiplication, where given the input $x$, the output $y$ is obtained as \begin{align}\label{eq:1ddft} y = DFT_n\cdot x. \end{align} The $DFT_n$ is the $n \times n$ DFT dense matrix, defined as \begin{align} DFT_n = \begin{bmatrix}\omega^{l k}_n\end{bmatrix}_{0\leq l, k < n}, \end{align} with $\omega_n = e^{-k\frac{2\pi}{n}}$ being the complex root of unity. Typically, the computation of the DFT is implemented using the Fast Fourier Transforms (FFT), where instead of performing $O(n^2)$ complex arithmetic operations by doing the matrix-vector multiplication, a recursive decomposition of the DFT matrix is performed to obtain an $O(n \log(n))$ algorithm. The most widely-know of these algorithms is the Cooley-Tukey algorithm~\cite{cooley1965algorithm}. The Cooley-Tukey algorithm is described as a factorization of the DFT matrix of size $n$ when $n$ is a composite number such as $n = n_0 n_1$. \begin{figure}[b] \centering \includegraphics[width=0.4\textwidth]{dft16parallel.png} \caption{The parallel implementation of the Cooley-Tukey algorithm for the $DFT_{16}$ on $p = 2$ processors. Data is distributed between the processors, each processor does its local computation and then exchanges the data. This parallel implementation requires three communication stages.} \label{fig:parallelct} \end{figure} An alternative view of the mathematical description of the Cooley-Tukey algorithm defined in~\cite{cooley1965algorithm} is as follows: \begin{align}\label{eq:ct} \tilde{y} = \left(Twid_{n_0\times n_1}\odot\left(\tilde{x}\cdot DFT_{n_1}\right)\right)^T\cdot DFT_{n_0}, \end{align} where $\tilde{x}$ and $\tilde{y}$ are two matrices of size $n_0\times n_1$ and $n_1\times n_0$, that represent the input $x$ and output $y$, respectively. The columns of matrix $\tilde{x}$ ($\tilde{y}$) are $n_1$ ($n_0$) contiguous sub-vectors (i.e. $x_i$, $0\leq i < n_0$ or $y_i$, $0\leq i < n_1$) of the input (output) vector $x$ ($y$), and are obtained by splitting $x$ ($y$) into sub-vectors of size $n_0$ ($n_1$) as follows \begin{align*} \tilde{x} = \begin{bmatrix}x_0 & | & x_1 & |& \ldots&|& x_{n_1-1}\end{bmatrix}. \end{align*} The matrix $\tilde{y}$ is similarly constructed. The reason for the formulation of the Cooley-Tukey algorithm as described by Equation~\ref{eq:ct} is that the four stages of the algorithm (as depicted in Figure~\ref{fig:1dct}) are made explicit. The first step applies the $DFT_{n_1}$ on the rows of the matrix $\tilde{x}$ (I), assuming data is stored in column major order. The elements within each column of either matrix $\tilde{x}$ or $\tilde{y}$ are in consecutive locations in memory. This means that in order to compute the first stage of the DFT, elements are accessed at a stride of $n_0$. The result of the first compute stage is then point-wise multiplied with the so-called twiddle matrix (II), which is defined as \begin{align} Twid_{n_0\times n_1} = \begin{bmatrix}\omega^{k l}_n\end{bmatrix}_{0\leq l < n_0\text{ and } 0\leq k < n_1}, \end{align} where $\omega_n$ represents the complex roots of unity. The resultant matrix is then transposed (III) and finally the second DFT of size $n_0$ is applied in the rows (IV). Again, the elements required for the fourth stage of the computation are read at a stride. The second DFT cannot start computation until all previous stages have been completed, because of the transposition stage. \subsection{Parallelizing the 1D DFT} Parallelizing the 1D DFT on $p$ processors requires the parallelization of all four compute stages. Traditionally, the input matrix $\tilde{x}$ (stored in column major order) is split such that each processor receives $n_1 / p$ columns of size $n_0$. Distributing the data using this data layout implies that computation cannot start since each processor does not have the necessary data points. As such, an all-to-all communication step is needed to re-distributes the data such that each processor receives $n_0/p$ rows of size $n_1$. The first and second stage of the Cooley-Tukey algorithm can then be applied locally. A second all-to-all communication is performed to transpose (stage III) the global data across the different processors. After this communication step, each processor owns $n_1 / p$ rows of size $n_0$ and thus can locally compute the last stage of the algorithm. Storing the data in the correct order requires a third communication step. The described computation gives the so-called six step algorithm~\cite{VanLoan} defined as \begin{align} \tilde{y} = \left(DFT_{n_0}\cdot\left(Twid_{n_0\times n_1}\odot\left(DFT_{n_1}\cdot\tilde{x}^T\right)\right)^T\right)^T. \label{eqn:ctparallel} \end{align} The parallel implementation of the six step algorithm is depicted in Figure~\ref{fig:parallelct}, and it requires a total of three communication steps. The astute reader will recognize that \emph{some of the communication steps can be avoided by storing the initial data in a different layout. This has been observed in literature, but seldom exploited in practice}. \subsection{$n$-Dimensional DFTs} \begin{figure} \centering \includegraphics[width=0.4\textwidth]{3dfft.png} \caption{Two algorithms for computing the 3D DFT. The slab-pencil algorithm (a) decomposes the 3D DFT into a 2D DFT and a 1D DFT. When applied, the 2D DFT is decomposed into the corresponding 1D transforms. The pencil-pencil-pencil algorithm (b) decomposes the 3D DFT into three 1D DFTs applied in the corresponding dimensions.} \label{fig:3ddftopt} \vspace{-3mm} \end{figure} Multi-dimensional DFTs can be defined in terms of multiple 1D DFTs and multi-dimensional DFTs of lower dimensions. For example, Figure~\ref{fig:3ddftopt} shows two variants for computing the 3D DFT. The first algorithm represents the so-called slab pencil decomposition~\cite{swarztrauber1987multiprocessor, foster1997parallel, sweet1991ffts}, where the 3D DFT is decomposed into a 2D DFT followed by a batch of multiple 1D DFTs. The second algorithm represents the pencil-pencil-pencil decomposition~\cite{swarztrauber1987multiprocessor, foster1997parallel, sweet1991ffts}, where the 3D DFT is decomposed into three batches of 1D DFTs, where each 1D DFT is applied in the three dimensions. The slab-pencil decomposition views the input (output) column vectors $x$ ($y$) as 2D matrices $\tilde{x}$ ($\tilde{y}$) of size $\left(n_0 n_1\right)\times n_2$. Mathematically the decomposition is expressed as \begin{align} \tilde{y} = \left(DFT_{n_0\times n_1}\cdot\tilde{x}\right)\cdot DFT_{n_2} \end{align} Data is stored in column major, hence the 2D DFT is applied on the columns, while the 1D DFT is applied on the rows. The pencil-pencil-pencil algorithm views the input (output) vectors are reshaped into 3D cubes $\hat{x}$ ($\hat{y}$) of size $n_0\times n_1\times n_2$. The input (output) column vector $x$ ($y$) is decomposed into $n_2$ groups of $n_1$ subgroups of size $n_0$. Hence, the 3D cube $\hat{x}$ can be viewed as matrix of matrices such as \begin{align} \hat{x} = \begin{bmatrix}\tilde{x}_0| & \tilde{x}_1| & \ldots| & \tilde{x}_{n_2}\end{bmatrix}, \end{align} where each $\tilde{x}_i$ is the 2D matrix of size $n_0\times n_1$ for all values $0\leq i < n_2$. Mathematically, the pencil-pencil-pencil algorithm is expressed as \begin{align} \hat{y} = \begin{bmatrix}\left(DFT_{n_0}\cdot\tilde{x}_0\right)\cdot DFT_{n_1}| & \ldots| & \left(DFT_{n_0}\cdot\tilde{x}_{n_2}\right)\cdot DFT_{n_1}\end{bmatrix}\cdot DFT_{n_2} \end{align} where the $DFT_{n_0}$ is applied in the depth dimension, the $DFT_{n_1}$ is applied in the column dimension and finally the $DFT_{n_2}$ is applied in the row dimension. Data is store in column major and therefore the dimension corresponding to $n_0$ is laid out in the fastest dimension in memory, while the dimension corresponding to $n_2$ is in the slowest dimension in memory. \begin{figure}[h] \centering \includegraphics[width=0.45\textwidth]{slabpencil.png} \caption{The parallel implementation of the slab-pencil algorithm for computing the 3D DFT on a 1D mesh of two processors. Each processor applies a 2D DFT followed by a 1D. The implementation requires two communications stages.} \label{fig:3dslabpencil} \end{figure} \begin{figure*}[t] \centering \includegraphics[width=\textwidth]{pencilpencilpencil.png} \caption{The parallel implementation of the pencil-pencil-pencil algorithm for computing the 3D DFTs on a 2D mesh of size $2\times 2$ processors. Each processor 1D DFTs in each dimension. The implementation requires three communications stages.} \label{fig:3dpencilpencil} \end{figure*} \subsection{Parallelizing the $n$-Dimensional DFTs} Since the multi-dimensional DFT can be decomposed into multiple lower-dimensional DFTs, most prevalent DFT frameworks exploit this feature for parallelization. We illustrate this parallelization scheme on the two algorithms for computing the 3D DFT that were presented previously. Parallelizing the slab-pencil algorithm is performed by viewing the processors as a 1D grid and distributing the data cube such that each processor receives a slab of $n_2/p$ 2D data of size $n_0\times n_1$. Each processor then locally computes multiple 2D DFTs on the slabs. Data is then exchanged across processors so that each processor can compute $(n_0 \times n_1) / p$ 1D DFT of size $n_2$. Finally, another communication step is required to store the data in the correct format as seen in Figure~\ref{fig:3dslabpencil}. The pencil-pencil-pencil algorithm is parallelized in the two dimensions corresponding to $n_1$ and $n_2$ across a mesh of processors of size $p_y\times p_z$. Each processor receives a batch of 1D pencils as seen in Figure~\ref{fig:3dpencilpencil}. Each processor can apply the local 1D DFTs. In order to apply the other two 1D DFTs data is first exchanged between the processors in the $p_y$ dimension of the mesh, followed by the communication between the processors on the $p_z$ dimension. Each communication stage rotates the data cube from $xyz$ to $yzx$ and $zxy$ as seen in Figure~\ref{fig:3dpencilpencil}. Each communication step requires data to be packed and un-packed before and after the all-to-all communication. Finally, in order to store the data in the correct format a global communication between all processors is required. However, the DFT is typically used in larger applications like convolutions or PDE solvers, therefore the last stage of communication for both the slab-pencil and pencil-pencil-pencil can be dropped. This improves reduces execution time in favor of having the data in shuffled format. \subsection{Limitations of existing parallelization schemes} Notice that in both cases, the amount of parallelism is limited by the size of a particular dimension of the data. For the slab-pencil algorithm, the maximum number of processors that can participate in the computation is $\max({n_0, n_1, n_2})$ as each processor is assigned a 2D slab of data. Similarly for the pencil-pencil-pencil case, the number of participating processors is upper bound by $\max(n_0n_1, n_1n_2, n_0n_2)$ since each processor is assigned at least one 1D DFT to compute locally. The level of parallelism within the communication is also limited by the size of a particular dimension of the data. The slab-pencil distribution spreads the data on a one dimensional grid. Hence, exchanging the data for computing the 1D DFT require all processors to communicate. The pencil-pencil-pencil case parallelizes the communication in two dimensions, which is done between groups of processors. All frameworks that implement the parallelization across the 1D DFT depend on efficient all-to-all communications~\cite{bruck1997efficient, prisacari2013bandwidth}. However, as we will briefly show in the result section, the all-to-all communication cannot efficiently scale as the number of processors increase. \section{Conclusion} In this paper, we presented a flexible framework for implementing parallel multi-dimensional DFTs on multi-dimensional processing grids. Specifically, we show that for different input problem size and different computational resource availability, different parallel multi-dimensional DFT algorithms are necessary for attaining efficient performance. In addition, we show that it is necessary to parallelize within the 1D DFT in order to scale the computation of the multi-dimensional DFT towards higher number of processing units. Despite incurring more rounds of communication, we show that for large enough data sizes, parallelizing with the 1D DFTs can improve the overall execution time over the conventional approach of simply parallelizing across multiple 1D DFTs. While we showed improved performance as we scale to larger number of nodes, further improvements to performance can be attained. As shown in Figure~\ref{fig:256_strongk}, a drawback of the current ROTE framework is that a local packing step is required to repack the data back into elemental-cyclic form after the collective communication. The time for the repacking is significant as it could be as much as 50\% of the overall execution time. One possibility for reducing this packing time is to expose the packing performed by ROTE or allow ROTE to accept data in packed form. This is something we are currently exploring. We also believe that the ROTE notation for describing data layout and processing grid can be extended to other architectures such as GPUs and multi-GPU systems. This can be achieved by replacing the MPI routines with the appropriate data movement primitives for GPUs and multi-GPUs. As the hierarchy of threads, thread blocks, streaming processors, and GPUs can be described as a multi-dimensional array, this suggest that ROTE can be used as the notation for porting the existing code to GPUs and multi-GPUs systems. \section{Introduction} The multi-dimensional discrete Fourier transform (DFT) has proven to be an ubiquitous mathematical kernel, that is widely used in a multitude of applications from different scientific fields like molecular dynamics~\cite{Plimpton97particle-meshewald, sirk2013characteristics, plimpton2012computational}, material sciences~\cite{chang2004numerical, vay2018warp, almgren2013nyx, lebensohn2012elasto}, quantum mechanics~\cite{kendall2000high,valiev2010nwchem,straatsma2011advances, canning2000parallel}. As most of these applications spend a significant amount of the total execution on computing multi-dimensional DFTs, it is vital that parallel multi-dimensional DFT be efficient as we move into the exa-scale era. As multi-dimensional DFTs are defined in terms of multiple 1D DFTs and, parallel implementations of the multi-dimensional DFTs can be classified into two distinct classes. The first class focuses on exploiting parallelism within the 1D DFTs, while the second class exploits the inherent parallelism across multiple distinct 1D DFTs. Most state-of-the-art frameworks for computing 3D DFTs like FFTW~\cite{FFTW}, P3DFFT~\cite{pekurovsky_p3dfft:_2012-1}, FFTE~\cite{DBLP:conf/ppam/Takahashi09} opt to parallelize across the 1D DFTs. \begin{figure}[t] \centering \includegraphics[width=0.45\textwidth]{dft1024_3_strong_scaling.png} \caption{Strong scaling results for two 3D DFTs of size $64^3$ and $1024^3$ using the slab-pencil, pencil-pencil-pencil and volumetric decomposition on the K-Computer. The execution time is shown in log scale.} \label{fig:1024strongk} \end{figure} We illustrate the limitations of the conventional approach of parallelizing multi-dimensional DFTs in Figure~\ref{fig:1024strongk}, where we report the performance of three different parallelization schemes for computing the 3D DFT of $64^3$ and $1024^3$ on the K-Computer. Notice that for data set of size $64^3$, parallelizing the 3D-DFT on a 1D grid of processor such that each processors computes a 2D plane yielded the shortest execution time. However, for the $1024^3$ input, the same parallelization scheme scales only to $32$ processors, while better performance can be attained by switching to a parallelization scheme comprising of a 2D grid of processors where each processor computes a small batch of 1D DFTs. Just as with the 1D parallelization scheme, the parallelism with a 2D grid of processors is restricted to at most $1024$ processors. By parallelizing within the 1D DFT for the last dimension, we obtain an even shorter execution time using a much greater number of processors. These observations highlight two major limitations of existing approaches: 1) there is a need for a framework that allows one to seamlessly switch between parallel algorithms for computing the multi-dimensional DFT as different parallel algorithms are superior for different problem sizes, and 2) there is a need to parallelize both across and within the 1D DFTs to scale to larger number of compute nodes. There is an increasing interest in scaling the parallel implementations of the multi-dimensional DFT to higher number of nodes using higher dimensional grids as shown in Jung et. al.~\cite{jung2016parallel}. These newer algorithms are a subset of the parallel DFT algorithms highlighted in Johnson et. al.~\cite{johnson2003recursive}, that showed that a significant number of algorithms can arise from the parallelization both within and across multiple 1D DFTs. However, these algorithms are largely unexplored in practice as the existing parallel DFT frameworks make implementing them quite difficult. Due to the rigidity of the existing frameworks, the resulting performance is still unsatisfactory. Therefore, in this work we present a flexible framework for employing different parallelization schemes to compute the multi-dimensional DFT on a multi-dimensional computation grid of processors. By recognizing that the inputs and outputs of a multi-dimensional DFT are multi-dimensional arrays of data, we leverage insights from the multi-linear algebra (tensor) community to simplify the management of communication and data layout on a multi-dimensional grid. {\bf{Contributions.}} The paper makes the following contributions: \begin{itemize} \item A flexible framework that unifies both parallelization schemes for multi-dimensional DFTs on multi-dimensional grids, built on top a tensor framework. \item Demonstrate the need for a family of parallel DFT algorithms in order to attain high performance for any given problem size and network configurations. \end{itemize} \section{$n$-Dimensional DFTs in ROTE} The inputs and outputs of any multi-dimensional DFT are multi-dimensional data arrays. Multi-dimensional arrays are commonly referred to as tensors in the multi-linear algebra community. As such, we leverage the insights from that community for distributed data management on a distributed grid through the use of the Redistribution Operations and Tensor Expressions (ROTE) framework~\cite{schatz2015distributed}. \subsection{The Redistribution Operations and Tensor Expressions Framework} The Redistribution Operations and Tensor Expressions (ROTE) framework provides a formal notation for describing the data layout of tensors that are distributed on multi-dimensional meshes. By describing the data layouts before and after a data redistribution operation, ROTE provides the infrastructure to map the necessary data movement into a sequence of one or more collective communication subroutines to achieve the desired data movement. In order to make the paper self-contain, we present a high-level overview of the notation of ROTE and refer the reader to existing documentations on ROTE~\cite{schatz2015distributed} for more details. \subsubsection{Describing Data and Processing Grid} Within ROTE, data and processing grids are viewed as multi-dimensional arrays or tensors. A tensor is a $d$-dimensional, or a $d$-mode, array. The order of a tensor represents the number of dimensions or the number of modes represented by the tensor. The dimension of each mode refers to the length or size of a specific mode. For example, the $2 \times 8$ matrix defined as \begin{align} A^{\iota \eta} = \begin{bmatrix} a_{0,0} & a_{0,1} & a_{0,2} & a_{0,3} & a_{0,4} & a_{0,5} & a_{0,6} & a_{0,7}\\ a_{1,1} & a_{1,1} & a_{1,2} & a_{1,3} & a_{1,4} & a_{1,5} & a_{1,6} & a_{1,7}\\ \end{bmatrix} \end{align} is an order-2 tensor. For consistency within the paper, we use the terms "dimensions", and "size" to refer to the order of the tensor, and dimension of the mode respectively. To make things clearer, we annotate the matrix $A$ with two superscripts ($\iota$ and $\eta$) to denote the size of the two modes such that $A$ is $\iota \times \eta$. \begin{figure} \centering \includegraphics[width=0.45\textwidth]{distributions.png} \caption{Data layouts for distributing the 2D matrix $A^{\iota\eta}$ on the 2D grid $G^{\rho\nu}$. A. represents the elemental cyclic distribution of the row dimension across the two processors. B. represents the block distribution for the row dimension.} \label{fig:datadistrib} \end{figure} Multi-dimensional processing grids are defined within ROTE as multi-dimensional arrays of processing units. Let $G$ be the d-dimensional grid size. Similar to the data tensors, an order-d $G$ grid will have $d$ dimensions and each dimension have a specific number of processors. For example, the 1D grid defined as \begin{align} G^{\rho\nu} = \begin{bmatrix} p_{0} & p_{1} \end{bmatrix} \end{align} is a $1\times 2$ processor mesh on which data can be distributed. $\rho$ represents the column dimension of size one, while $\nu$ represents the row dimension of size two. \subsubsection{Describing Global Data Distributions} One of ROTE's key aspects is the way in multi-dimensional data sets are described and distributed across multi-dimensional meshes. The description is based on the idea of distributing each dimension of the data over specific dimensions of the processor grid. We illustrate this aspect in the following example. Consider distributing the two dimensional tensor $A^{\iota \eta}$ across the 1D processor grid, $G^{\rho \nu}$ such that columns of $A^{\iota \eta}$ are distributed in a cyclic fashion across the processors (i.e. Figure~\ref{fig:datadistrib}). This is described in ROTE with as $A^{\iota \eta}$ having the distribution \[ A^{\iota\eta}[()(0)]. \] To understand the expression, note that there are two pairs of round parenthesis within the square brackets. The pair of round brackets tells us that $A^{\iota\eta}$ is a two-dimensional tensor. In addition, note that there is only a single value, $0$, within the round brackets. This number specifies that the specific dimension of the data is distributed on the dimension of the processor grid specified by that value. Therefore, the zero within the second parenthesis tells us that the second dimension of $A$, i.e. the columns of $A^{\iota\eta}$, is distributed across the $0$-th dimension of the processor grid. The distribution is an elemental-cyclic distribution of the columns of $A^{\iota\eta}$ across the grid. The notation can easily be extended to describe blocked data layouts. Blocked distributions are also an important data layout for the computation of the multi-dimensional DFT. The key difference between the blocked and the elemental-cyclic distributions is the number of consecutive elements that are distributed to each of the processors on the mesh. The elemental-cyclic distribution assumes the data being distributed at the granularity of one element, while the blocked distribution assumes that each processor receives $b$ consecutive elements. Expressing the blocked distribution of the matrix $A$ in ROTE notation can be done as follows \begin{align} A^{\iota\eta_0\eta_1}[()()(0)], \end{align} where the column dimension of size $\eta = \eta_0 \eta_1$ is blocked or tiled by the $\eta_0$ size. Blocking or tiling the data with a block of size $b$ can be interpreted as adding an another dimension to the data set as shown in~\cite{bondhugula2008practical}. In the previous example, the dimension described by $\eta$ is split into two, namely $\eta_0$ and $\eta_1$ and $\eta_0$ is set to the block size (in this case, 4). The dimension corresponding to $\eta_1$ is distributed across the two processors on the grid as denoted by the zero value within the third pair of parenthesis. Each processor receives a block of $\eta_0$ elements in a cyclic fashion. \begin{figure} \centering \includegraphics[width=0.45\textwidth]{distrib1D.png} \caption{Transposing the matrix $A^{\iota\eta}[()(0)]$. The transposition is broken into a block transposition and multiple within-block transpositions. The operations from matrix $A^{\iota\eta}[()(0)]$ to matrix $B^{\iota\eta}[(0)()]$ represents the block transposition over the network (packing, all-to-all, un-packing). The last stage $C^{\eta\iota}[()(0)]$ does the local transpositions.} \label{fig:dataredist} \end{figure} \subsubsection{From Distribution to Communication} ROTE implements data communication over the computation grid by specifying the original and final data layout. For example, the following expression \begin{align} B^{\iota\eta}[(0)()] = A^{\iota\eta}[()(0)] \end{align} describes the original tensor $A$, where the columns of the matrix $A$ are distributed element cyclic across the processor grid, being mapped to the new tensor $B$, where the rows of the tensor are distributed in an elemental-cyclic fashion. ROTE maps the above description to the all-to-all collective communication. Given the before and after data distributions, the infrastructure within ROTE determines the necessary packing, collective communication and un-packing required. The detailed steps that ROTE takes in order to perform the redistribution of the tensor $A$ from the initial distribution to the final distribution expressed as tensor $B$ are captured in Figure~\ref{fig:dataredist}. \begin{figure*}[t] \centering \includegraphics[width=\textwidth]{volumetric.png} \caption{The parallel implementation of the 3D DFT using the volumetric decomposition. The data is distributed elemental cyclic in all three dimensions across a 3D mesh of processors of size $2\times 2\times 2$. The implementation requires three communication steps and the elemental cyclic distribution is preserved between the computed stages.} \label{fig:cuboid} \end{figure*} \subsection{Parallel 1D DFT using ROTE} In this section, we describe how ROTE can be used as our framework for computing the 1D DFT using the Cooley-Tukey algorithm. Recall that the Cooley-Tukey algorithm decompose the computation of the 1D DFT of size $n = n_0 n_1$ into four stages involving computations with two dimensional tensors (i.e. matrices). Using the notation from ROTE, we can re-express Equation~\ref{eq:ct} as \begin{align}\label{eq:cteinstein} \tilde{Y}^{\eta_1\eta_0} = \left(\left(Twid^{\iota_0\eta_1}_{n_0\times n_1}\odot\left( \tilde{X}^{\iota_0\iota_1}\cdot DFT^{\iota_1\eta_1}_{n_1}\right)\right)^T\right)\cdot DFT^{\iota_0\eta_0}_{n_0}. \end{align} ${\iota_0\iota_1}$ and ${\eta_1\eta_0}$ represent the size of the two-dimensional tensors of the input and output respectively. In the following paragraphs, we derive the 1D DFT parallelization across $p$ processors using ROTE's notation. Recall that the input matrix is distributed across the processors (in a one dimensional grid) such that each processor has $\eta_1/p$ columns. However under this data layout, the computation requires an initial redistribution of the input data such that each processor holds the row of the input matrix $\tilde{X}^{\iota_0\iota_1}$. Naturally, this suggest that the input data (to avoid the redistribution at the start) has to be distributed as \[ \tilde{X}^{\iota_0\iota_1}[(0)()], \] where the rows are distributed in elemental cyclic fashion. Notice that while $\iota_0 \times \iota_1$ must be equal to the input size, the Cooley-Tukey algorithm places no other constraints on what $\iota_0$ and $\iota_1$ must be. However, it is natural to make $\iota_1 = p$ since that will ensure that the rows are cyclic-ly distributed across all $p$ processors. The computation stage of the parallel 6-steps algorithm is then able to perform the local DFT computation, followed by the local point-wise multiplication with the twiddle matrix $Twid_0$. Since the computation is an element-wise complex multiplication it follows that the distribution of the twiddle matrix $Twid_0$ must be the same with that of the input $\tilde{X}$, i.e. \[ Twid_0^{\iota_0\eta_1}[(0)()]. \] After the first two steps, the intermediate result in the temporary array $T$ is as follows \begin{align} T_0^{\iota_0\eta_1}[(0)()] = \left(Twid^{\iota_0\eta_1}_{n_0\times n_1}[(0)()]\odot\left( \tilde{X}^{\iota_0\iota_1}[(0)()]\cdot DFT^{\iota_1\eta_1}_{n_1}\right)\right), \end{align} where $T_0^{\iota_0\eta_1}[(0)()]$ has the same distribution as the input $\tilde{X}^{\iota_0\iota_1}$. The 1D DFT requires a transposition of the array $T_0^{\iota_0\eta_1}$. Figure~\ref{fig:dataredist} shows the steps required to perform the transposition. First the block transposition is applied such that \begin{align} T_1^{\iota_0\eta_1} [()(0)] = T_0^{\iota_0\eta_1}[(0)()]. \end{align} This operation is mapped to the all-to-all collective communication. Each processor then transposes the data locally such that \begin{align} T_2^{\eta_1\iota_0}[(0)()] &= T_1^{\iota_0\eta_1} [()(0)] \end{align} Finally, each processor applies its local computation of the last stage of the Cooley Tukey algorithm. The output $Y$ is computed as \begin{align} \tilde{Y}^{\eta_1\eta_0}[(0)()] &= T_2^{\eta_1\iota_0}[(0)()]\cdot DFT^{\iota_0\eta_0}_{n_0}. \end{align} The computation between the two matrices is paired on the dimension corresponding to $\iota_0$. Note that $\tilde{X}^{\iota_0\iota_1}[(0)()]$ and $\tilde{Y}^{\eta_1\eta_0}[(0)()]$ have the same distribution. The first local computation does the DFT of size $n_1$ followed by the twiddle scaling, while the second local computation does a transposition and the DFT of size $n_0$. An instantiation of the parallel algorithm in the ROTE framework is shown in Figure~\ref{fig:roteC}. Notice that the besides the advantage of removing redundant communication with the elemental cyclic distribution, the computation of the DFT using ROTE has the property that the {\it{data remains in elemental cyclic distribution after the computation of the 1D DFT}}~\cite{inda2001simple}. In addition, {\it{for a problem size $n = n_0 n_1$, where $p|n_0$ and $p|n_1$, the 1D DFT algorithm requires only one communication stage}} and not three as in the case of the blocked distribution. If one of the conditions is not satisfied then either the mesh is modified or extra communication is required as shown in Inda et. al~\cite{inda2001simple}. We leave the scenario when the above conditions are not satisfied as future work. \begin{figure}[t] \centering \begin{lstlisting} // create the processing grid ObjShape gridShape(1); gridShape[0] = 4; const Grid g(MPI_COMM_WORLD, gridShape); // create the shape and size of the data tensors ObjShape shapeX(2); shapeX[0] = 16; shapeX[1] = 16; // input and output tensors DistTensor<complex<double>> A(shapeX, "[(0),()]", g); DistTensor<complex<double>> B(shapeX, "[(),(0)]", g); fftw_complex *ABuff = (fftw_complex*) A.Buffer(); fftw_complex *BBuff = (fftw_complex*) B.Buffer(); // batch DFT_16 in the rows fftw_execute_dft(batch_4_dft_16, ABuff, ABuff); // point-wise multiplication with twiddle factors for(int i = 0; i != 64; ++i) { ABuff[i] = ABuff[i] * twidd_local[i]; } // redistribution B.AllToAllRedistFrom(A, 0, 0); // transposition and batch DFT_16 in the rows fftw_execute_dft(transpose_batch_4_dft_16, BBuff + , BBuff); \end{lstlisting} \caption{Code snippet for computing a DFT of size $256$. The 1D DFT is parallelized across $4$ processors on a 1D grid. Computation is done using FFTW. The grid configuration, tensor definition and data distribution is done using ROTE.} \label{fig:roteC} \end{figure} \section{Experimental Results} In this section, we describe the experimental setup and the results obtained on the K-Computer, outlining the importance of having a flexible framework that allows one to chose the appropriate algorithm for a given problem size. We begin by presenting the characteristics of the system and then briefly outline some of the implementation details for parallelizing the computation using MPI and OpenMP. We emphasize the simplicity of expressing the computation within the framework. Lastly, we analyze the strong scaling of the 3D DFT for $64^3$, $256^3$ and $1024^3$ using all three decomposition (slab-pencil, pencil-pencil-pencil and volumetric). We give a breakdown of the performance. We show that there is no one decomposition that gives the shortest time to solution. \subsection{System Configuration} The Riken AICS K-Computer consists of approximately $80,000$ SPARC$64$ VIIIfx processors. Each compute node has a single CPU with $16$ GB of main memory and a total bandwidth of $64$ GB/s (main memory bandwidth). Each SPARC$64$ VIIIfx has $8$ cores with one thread per core running at $2.0$ Ghz and $6$ MB of L$2$ cache. Each core can do $128$-bit single instruction multiple data (SIMD) instructions, giving a peak performance for double precision fused multiply-add instructions of $128$ GFlops. Each compute node is connected with a 6D mesh/torus network (TOFU interconnect). The TOFU interconnect provides a logical 3D torus network for each job. Each node has $10$ links with a bandwidth of $10 GB/s$ full-duplex and the network allows for multiple pathways to communicate data. The infrastructure allows programs to be adapted to one, two and three dimensional torus networks. The maximum number of processors in one dimension is $54$, while the maximum torus size is $48\times 54\times 32$~\cite{riken}. The K-Computer provides its own customize software, ranging from the compilers and the libraries for Fourier transforms and linear algebra operations to the infrastructure for OpenMP and MPI. The current implementation of the DFT framework presented in this work uses FFTW for the local DFT computation and OpenMP to parallelize the computation across the threads. The DFT framework is built on top of ROTE, which allows one to easily describe the data distribution and the communication between the compute nodes. Underneath, ROTE uses MPI to do the collective communication between the compute nodes. The entire framework is compiled with the Fujitsu custom compiler. All optimization are set to \texttt{-O2}. In addition, the \texttt{-fopenmp} and \texttt{-lfftw3} flags are enabled for compilation. \subsection{OpenMP + MPI Parallelism} \begin{figure} \centering \includegraphics[width=0.45\textwidth]{parallelism.png} \caption{Example of applying thread level parallelism on the local computation using OpenMP. Each processor receives a cube of data points, that is divided between the threads. Each thread takes ownership on that chunk of data and applies its computation and data transformations. In this example, each thread applies computation in two dimensions followed by a rotation across the main diagonal of the data cube.} \label{fig:parallel} \end{figure} The framework uses OpenMP~\cite{openmp08} parallelism for the local computation and MPI~\cite{MPI2} for the distributed computation. The MPI is hidden away by the ROTE infrastructure. As seen in Figure~\ref{fig:roteC}, where we parallelize the 1D DFT of size $256$ on four processors, ROTE allows users to specify the grid, the tensors, the distribution and the communication. Writing the communication is straightforward. The construction of the processor grid \texttt{g} requires the \texttt{MPI\_COMM\_WORLD} global communicator and the shape of the grip \texttt{gridShape}. Based on the shape of the grid, the global communicator is split accordingly. The construction of the tensors \texttt{A} and \texttt{B} requires the shape of the data tensor, the distribution and the grid on which the data is distributed on. For example, order-2 tensor \texttt{A} is is distributed on the first dimension $[(0)()]$, while order-2 tensor \texttt{B} is distributed on the second dimension $[()(0)]$. Each tensor object provides the necessary functionalities to specify the communication. For the 1D DFT the \texttt{AlltoAllRedistFrom} is used to specify the all-to-all communication described in Figure~\ref{fig:dataredist}. Parallelizing the computation using OpenMP is made explicit. We uses \texttt{\#pragma omp parallel region} to specify and create a pool of threads. Based on the thread id (\texttt{omp\_get\_thread\_num}), each thread will compute on its own chunk of data as shown in Figure~\ref{fig:parallel}. The figure outlines that once the computation is complete, threads rotate the data. This step is required so that the subsequent MPI all-to-all function call does not incur penalties from accessing data in local memory. We use the clause \texttt{\#pragma omp barrier} to synchronize the threads and the clause \texttt{\#pragma omp master} to specify that only the master thread can perform the communication. Previously, this clause was used around the redistribution function \texttt{AlltoAllRedistFrom} and within the redistribution function other threads were created to perform the packing before and after the MPI call. However, modifications to the original ROTE framework were done and the \texttt{\#pragma omp\_master} was moved around the \texttt{MPI\_Alltoall}, within ROTE's redistribution function. The overall benefit is that a single pool of threads is created up front and those threads are used for both performing the computation and the packing/un-packing of the data. The K-Computer provides eight threads in total, and in the current implementation we use all of them. \begin{table} \centering \begin{tabular}{c c c c} \toprule \# of processors & 1D Grid & 2D Grid & 3D Grid\\ \midrule 2 & (2) & - & - \\ 4 & (4) & (2,2) & - \\ 8 & (8) & (4,2) & (2,2,2)\\ 16 & (16) & (4,4) & (4,2,2)\\ 32 & (32) & (8,2) & (4,4,2)\\ 64 & - & (8,8) & (4,4,4)\\ 128 & - & (16,8) & (8,4,4)\\ 256 & - & (16,16) & (8,8,4)\\ 512 & - & (32,16) & (8,8,8)\\ 1k & - & (32,32) & (16,8,8)\\ 2k & - & - & (16,16,8)\\ 4k & - & - & (16,16,16)\\ 8k & - & - & (32,16,16)\\ 16k & - & - & (32,32,16)\\ 32k & - & - & (32,32,32)\\ \bottomrule \end{tabular} \newline\newline \caption{Table showing the different configurations for the 1D, 2D and 3D grids. The maximum number for each grid represents the maximum size that can be created for the given grid taking into account that the maximum torus size allowed on the K-Computer is $48\times 54\times 32$~\cite{riken}.}\label{table:grid_dims} \vspace{-3mm} \end{table} \subsection{Results and Discussion} In the following paragraphs, we focus on the performance obtained by our 3D DFT framework on the K-Computer. We compare the execution time of cubic 3D DFTs of size $64^3$, $256^3$ and $1024^3$, using all three algorithms, slab-pencil, pencil-pencil and volumetric decomposition. For all of the configurations, we report strong scaling results, where we keep the problem size fixed and increase the number of processor in each dimension as shown in Table~\ref{table:grid_dims}. We focus on power of two-sized processing grids, where the number of processor does not exceed the number of processor specified in~\cite{riken} in each dimension. We measure the entire 3D DFT computation end-to-end. The actual measurement executes the computation within a loop for $10$ minutes. We then take the average execution time for each experiment. Before the measurement, each MPI process sleeps for approximately one minute. Then $10$ dry runs of the 3D DFT are executed without recording the actual execution time. The two steps are meant to reduce noise on the network. {\textbf{A - $64^3$ Problem Size.}} We first present the strong scaling results of the 3D DFT when the problem size is small, i.e. $64^3$ complex data points. As seen in Figure~\ref{fig:1024strongk}, the slab-pencil algorithm for this problem size gives the shortest execution time and it also scales to eight compute nodes (64 cores). For this specific problem size the slab-pencil algorithm cannot be execute on more than eight processors, since we impose the input and output to be in elemental cyclic-ly distributed. Changing the algorithm from slab-pencil to pencil-pencil or volumetric to expose more parallelism, does not provide improvements. Execution suffers slowdowns and in addition the execution of both algorithms tappers off as the number of processors increases. This behaviour is directly related to the all-to-all communication and the number of all-to-alls. Depending on the parallel algorithm (slab-pencil, pencil-pencil or volumetric), the 3D DFT may require one or more all-to-all communication steps. Therefore, the scaling behaviour of the 3D DFT is highly dependent on the scaling behaviour of the all-to-all communications. Figure~\ref{fig:all2all} reports the strong scaling of the all-to-all for the same problems size using one/two/three all-to-alls, similar to the three implementations of the 3D DFT. The all-to-alls codes are obtained by removing the local computation and packing. Note that the execution times of the three scenarios exhibit the same trend as the 3D DFT execution times. The slab-pencil approach achieves the shortest execution time and scales to more than eight processors. The pencil-pencil and volumetric variants of the data movement experience slowdowns for a small number of processors and show diminishing returns as the number of processors increased. \begin{figure}[t] \centering \includegraphics[width=0.45\textwidth]{alltoall2.png} \caption{The execution of one, two and three all-to-alls applied on 1D, 2D and 3D grid of processors for the small problem size of $64^3$. Each all-to-all is applied in one dimension. The data cube is distributed between the processors.} \label{fig:all2all} \end{figure} \begin{figure*}[t] \centering \minipage{0.5\textwidth} \includegraphics[width=\linewidth]{alltoall.png} \endminipage\hfill \minipage{0.5\textwidth} \includegraphics[width=\linewidth]{alltoall1.png} \endminipage \caption{The execution of one, two and three all-to-alls applied on 1D, 2D and 3D grid of processors. Each all-to-all is applied in one dimension. The left plot shows the strong scaling of a three dimensional cube of size $256^3$, while the right plot outlines the scaling of a cube of size $1024^3$, respectively. The data cube is distributed between the processors.} \label{fig:all2all1} \end{figure*} The slowdowns and the diminishing returns can be understood by analyzing the lower bounds of the collective communications. Since the K-Computer has its own all-to-all collectives, we discuss the key aspects of the communication by analyzing the lower bounds outlined in Bruck et. al~\cite{bruck1997efficient}. The paper presents the lower bounds for the all-to-all communication as follows \begin{align} \log_{k+1}(p)\alpha + \log_{k+1}(p)\frac{n}{(k+1)p}\beta\label{eq:mst_alg},\\ \ceil[\big]{\frac{p-1}{k}}\alpha + \ceil[\big]{\frac{p-1}{k}}\frac{n}{p^2}\beta\label{eq:bkt_alg}, \end{align} where $p$ represents the number of processors, $n$ represents the total amount of data across all $p$ and $k$ represents the number of ports a compute node can send and receive. $\alpha$ represents the start-up cost and $\beta$ represents the inverse of the bandwidth on each of the links. Equation~\ref{eq:mst_alg} represents the lower bound of the all-to-all that minimizes the number of transfers between the nodes, while Equation~\ref{eq:bkt_alg} minimizes the amount of data that is being transferred in each step. The first minimizes the $\alpha$ term, while the second minimizes the $\beta$ term. No one algorithm minimizes both at the same time. The all-to-all communication becomes latency bound as the number of processors is increased. Not that the latency term $\log_{k+1}(p)\alpha$ ($\ceil[\big]{\frac{p-1}{k}}\alpha$) increases while the bandwidth term $\log_{k+1}(p)\frac{n}{(k+1)p}\beta$ ($\ceil[\big]{\frac{p-1}{k}}\frac{n}{p^2}\beta$) decreases as the number of processors $p$ is increased. Therefore, if $p$ is sufficiently large such that \begin{align} p\geq \frac{n\beta}{(k + 1)\alpha} \end{align} for Equation~\ref{eq:mst_alg} and \begin{align} p^2\geq \frac{n\beta}{\alpha} \end{align} for Equation~\ref{eq:bkt_alg}, the execution time of the all-to-all becomes latency dominated. In addition, as the number of processors $p$ is increased above those threshold the execution time of the all-to-all should increase. This can be observed in the empirical results outlined in Figure~\ref{fig:all2all}. This provides an explanation to why the DFT for the a size of $64^3$ complex points plateaus as the number of processor is increased. The number of ports $k$ lowers the bounds of the all-to-all communication, if the node has sufficient ports/connections to satisfy the $k$ value. The $k$ value provides a possible reason why multiple all-to-alls are slower compared to a single all-to-all for the same number of processors $p$. For example, the $k$ number of ports can be equal to one, two or three when the slab-pencil algorithm is applied on $p = 4$ compute nodes. However, the pencil-pencil algorithm with two all-to-alls on the same amount of processors $p = 4$ has $k$ equal to one. Evaluating the above equations, the slab-pencil algorithm where one all-to-all is used can provide better execution time compared to the other two. However, this effect cannot be seen as $p$ increases, due to the latency aspect that was explained above. While, empirically results as seen in Figure~\ref{fig:all2all} and Figure~\ref{fig:all2all1} seem to back up this aspect, further investigation is needed, especially since the all-to-alls are treated as black boxes. We use the MPI collectives offered by the K-Computer infrastructure. {\textbf{B - $256^3$ 3D DFT.}} In Figure~\ref{fig:256_strongk}, we analyze the strong scaling behaviour of the 3D DFT for a medium size problem of $256^3$ complex data points. Compared to the small size, the amount of data increases by $64$ times, which suggests the problem size can be scaled to larger number of compute nodes. The top left plot outlines the strong scaling of the 3D DFT. Note that when the number of processors is small ($\leq 16$), the slab-pencil decomposition outperforms the other two implementations. However as the number of processors increases, the other two algorithms thrive. Ultimately, the volumetric decomposition offers the best scaling to $4096$ cores/$32768$ threads. Similar behaviour can be seen in the data movement in the left plot in Figure~\ref{fig:all2all1}, where we remove the local computation and packing. Note that as the number of processors is increased, the scaling of the slab-pencil all-to-all diminishes and catches up to the pencil-pencil approach where two all-to-alls are used. Subsequently, the volumetric all-to-all where three all-to-alls are needed catches up and scales to the corresponding number of processors. This emphasizes the need for a more detailed analysis on how the all-to-all is implemented and when to decide to change algorithms for both the all-to-all and the 3D DFT, aspect which we leave for future work. \begin{figure*}[t] \minipage{0.5\textwidth} \includegraphics[width=\linewidth]{dft256_strong_scaling.png} \endminipage\hfill \minipage{0.5\textwidth} \includegraphics[width=\linewidth]{1d256breakdown.png} \endminipage\\ \minipage{0.5\textwidth}% \includegraphics[width=\linewidth]{2d256breakdown.png} \endminipage\hfill \minipage{0.5\textwidth}% \includegraphics[width=\linewidth]{3d256breakdown.png} \endminipage \caption{Strong scaling results for the 3D DFT of size $256^3$. The top-left plot shows the scaling results for the 3D DFT using all three implementations (blue line for the slab-pencil decomposition, yellow line for the pencil-pencil-pencil decomposition and red line for the volumetric decomposition). The top-right, bottom-left and bottom-right show the execution breakdown for the three decomposition as the number of processors is increased. The blue portion represents the time spent in network communication, while the yellow and red represent the packing and computation times, respectively.} \label{fig:256_strongk} \vspace{-2mm} \end{figure*} Data movement across the network is one aspect of the 3D DFT computation, however the local computation and packing also plays a role. The top-right, bottom-left and bottom-right plots in Figure~\ref{fig:256_strongk} show the breakdown of the execution time for all three algorithms, slab-pencil, pencil-pencil and volumetric, respectively. The slab-pencil and pencil-pencil-pencil decomposition show a significant percentage of the execution time to be sent in the local DFT computation. The local computation is basically batches of 1D and 2D DFTs followed by point-wise multiplications that are done outside the DFT. The point-wise computation is not merged since FFTW does not provide such features. For small number of nodes, the amount of local data may reside in local DRAM. As shown in~\cite{Popovici:18}, the DFT is a latency bound computation, therefore applying the double buffering technique on the computation may reduce local computation when the number of processors is small. However, as the number of processors increases the amount of computation is significantly reduced. Note that the data packing becomes a significant part of the overall computation. This suggests that there is still room for improvement by optimizing the packing routines within the ROTE framework or exposing the ROTE packing routines in order to fuse the packing with the computation. {\textbf{C - $1024^3$ 3D DFT.}} Finally, we report strong scaling results for a large problem size of $1024^3$ complex data points. Figure~\ref{fig:1024strongk} shows the strong scaling behaviour of the entire 3D DFT for this problem size. Similar to the $256^3$ case, the slab-pencil decomposition performs better for small number of processors of up to $32$. However, as the number of processors increases, the volumetric decomposition yields better results. In addition, the volumetric implementation almost linearly scales to $32,768$ compute nodes ($2626,144$ cores), and outperforms for $16,768$ and $32,768$ compute nodes both algorithms presented in~\cite{jung2016parallel}. Note that the pencil-pencil decomposition follows the volumetric decomposition until scaling the problem to $512$ compute nodes. Similar to the $256^3$ case, computation can still be improved for the case where the number of processors is small. The same cannot be said as the number of processors is increased beyond $4096$ compute nodes. Computation and packing becomes insignificant compare to the data movement. The execution of the 3D DFT for large number of nodes follows within $10\%$ the execution of the all-to-all communication depicted in Figure~\ref{fig:all2all1}.
{'timestamp': '2019-12-24T02:15:48', 'yymm': '1904', 'arxiv_id': '1904.10119', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.10119'}
arxiv
\section{Introduction} Fisheye cameras have been widely used in many computer vision tasks~\cite{szeliski1997creating,xiong1997creating,bertozzi2000vision,huang20176,alhaija2018augmented} because of their large field of view (FOV), however, the images taken by fisheye cameras always suffer from severe geometric distortion simultaneously. When processing the geometric toward vision systems equipped with fisheye lens, calibrating the intrinsic parameters is usually the first step we should do to rectify the distorted images. \subsection{Motivation and Objective} Early work viewed the calibration of fisheye cameras as an optimization problem by fitting the relationship between 2D/3D calibration patterns from images with different viewpoints~\cite{kannala2006generic,Grossberg2001A,Sturm2004A,ScaramuzzaMS06}. But these methods usually demand pre-prepared calibration patterns and extra manual operations, and even often involve heavy off-line estimations, which seriously limit their usage scenarios in real applications. \begin{figure}[t] \includegraphics[width=0.24\linewidth]{fig1/00066069_0_fish_ROI_new.png} \includegraphics[width=0.24\linewidth]{fig1/00075615_0_fish_ROI_new.png} \includegraphics[width=0.24\linewidth]{fig1/00509283_0_fish_ROI_new.png} \includegraphics[width=0.24\linewidth]{fig1/00063799_0_fish_ROI_new.png} \vspace{.5mm} \includegraphics[width=0.24\linewidth]{fig1/00066069_0_fish_ROI_line.png} \includegraphics[width=0.24\linewidth]{fig1/00075615_0_fish_ROI_line.png} \includegraphics[width=0.24\linewidth]{fig1/00509283_0_fish_ROI_line.png} \includegraphics[width=0.24\linewidth]{fig1/00063799_0_fish_ROI_line.png} \vspace{.5mm} \includegraphics[width=0.24\linewidth]{fig1/figure1_6.png} \includegraphics[width=0.24\linewidth]{fig1/figure1_7.png} \includegraphics[width=0.24\linewidth]{fig1/figure1_8.png} \includegraphics[width=0.24\linewidth]{fig1/figure1_5.png} \caption{Learning to calibrate straight lines for fisheye image rectification. {\bf \bm{$1^{st}$}-Row:} original fisheye images overlaid by detected {\em distorted lines} which should be straight after calibration; {\bf \bm{$2^{nd}$}-Row:} rectified straight lines; {\bf \bm{$3^{rd}$}-Row:} rectified image. } \vspace{-15pt} \label{fig:1} \end{figure} To overcome these limitations and toward an automatic self-calibration solution, subsequent investigations were proposed to detect geometric objects ({\em e.g., conics and lines}) from a single image and further exploit their correspondences in 3D world ~\cite{devernay2001straight,zhang2015line,barreto2009automatic,melo2013unsupervised,bukhari2013automatic,aleman2014automatic}. These approaches have reported promising performances on fisheye camera calibrations only when specified geometric objects in fisheye images can be accurately detected. Nevertheless, it is worth noticing that the involved detection of geometric objects in fisheye images itself is another challenging problem in computer vision. Recently, alternative approaches have been proposed based on deep convolutional neural networks (CNNs)~\cite{rong2016radial,yin2018fisheyerecnet}. Avoiding the difficult to directly detect the geometric objects, these methods tried to learn more discriminative visual features with CNNs to rectify the distorted image. Although aforementioned methods have reported the state-of-the-art performances on fisheye image rectifications, as well as avert the difficulties of detecting geometric objects, the geometry characteristics in fisheye calibration task are not fully exploited using CNNs. Regardless of the difficulties to detect geometric objects in fisheye images, one should observe that the explicit scene geometries are still the strong constrains to rectify distorted images. It is of great interest to investigate how to apply the fundamental geometric property under the pinhole camera model, \ie, {\em the projection of straight line from space to the camera should be a line}~\cite{devernay2001straight}, to fisheye image calibration networks. As shown in Fig.~{\ref{fig:1}}, we propose a novel networks which further exploit this explicit scene geometries, aiming at solving the challenges of fisheye camera calibration and image rectification by a deep neural network simultaneously. \begin{figure*}[t] \centering \includegraphics[width=0.78\linewidth]{fig2/fisheye.png} \caption{Architecture of the overall system. The whole network architecture consists of three parts: line-guided parameter estimation module (LPE), {\em distorted line} segments perception module (DLP), and a rectification layer. DLP could detect the map of curves which should be straight line in rectified image, and take the ouput from DLP and RGB fisheye image into the LPE to estimate the global and local fisheye distortion parameters. The distortion parameters are used in rectification layer to implement the curvature constraint. } \label{fig:net} \vspace{-5pt} \end{figure*} \vspace{-1mm} \subsection{Overview of Our Method} The above-mentioned challenges motivate following two issues: (1) how to design a powful CNNs to explicitly depict the scene geometry in fisheye images. (2) how to train a deep network effectively and efficiently using geometric information. To address these problems, we propose to first train a neural network to detect {\em distorted lines} that should be straight after being rectified in fisheye images , and then feed these detected {\em distorted lines} into another deep sub-network to recover the distortion parameters of fisheye camera. As shown in Fig.~\ref{fig:net}, our network includes three main modules as follows: \vspace{-1mm} \begin{itemize} \item {\bf Module for detecting distorted straight lines.} This module is designed to extract {\em distorted lines} in the given input fisheye image, which are supposed to be straight in an expected rectified image. Some examples of detected {\em distorted lines} are displayed in the first row of Fig.~\ref{fig:1}. \vspace{-1mm} \item {\bf Module for recovering the distortion parameters.} Fed with detected {\em distorted lines} and the original fisheye image, this module attempts to recover the distortion parameters of the fisheye lens. In particular, multi-scale perceptron is desined to eliminate the nonlinearity of distortion distribution in fish-eye images by combining both the local and global learning. \vspace{-1mm} \item {\bf Rectification module.} This differentiable rectification module serves as a connector between distortion parameters and geometric constraint. As shown the second row in Fig.~\ref{fig:1}, the line map without distortion which are rectified from the {\em distorted lines} in the first row are displayed. \end{itemize} \vspace{-1mm} These three modules are trained by minimizing the loss function composed of three terms: a multi-scale constraint of global and local perception on distortion parameters, as well as a curvature constraint on detected {\em distorted lines}. Since all of the calibration and rectification steps are modeled with one deep neural network, it is naturally to train it in an end-to-end manner. To get a better performance of proposed network, well-annotations of {\em distorted lines} and distortion parameters are required for every fisheye image during the training phase. Thus, we create a new synthetic dataset for the fisheye lens calibration by converting the wireframe dataset~\cite{huang2018learning} to \emph{distorted Wireframe collections} (D-Wireframe) and the 3D model repository~\cite{song2016ssc} to \emph{fisheye SUNCG collections} (Fish-SUNCG). In detail, the D-wireframe collections is created by distorting the perspective images with randomly generated distortion parameters, and the Fish-SUNCG collections is built by rendering the formation of real fisheye lens in 3D virtual scenarios. \vspace{-1mm} \subsection{Related Work} In the past decades, many researches have been devoting themselves to fisheye calibration and distortion correction studies. Earlier works attempted to estimate the distortion parameters by correlating the detected 2D/3D features in specific calibration field~\cite{kannala2006generic,Grossberg2001A,Sturm2004A,ScaramuzzaMS06,aliaga2001accurate,barreto2005geometric,toepfer2007unifying}. However, it is costly to build such calibration fields of large-scale and high-precision as well as it usually turns to be laborious and time-consuming to manually label every calibration pattern. By contrast, self-calibration methods which rely on structural information detected in distorted images~\cite{devernay2001straight,zhang2015line,barreto2005geometric,melo2013unsupervised,bukhari2013automatic,aleman2014automatic,Peter2006Self} require less manual work and are more efficient. Devernay~\etal~\cite{devernay2001straight} proposed that the straight line segments in the real world should maintain their line property even after the projection of fisheye lens. Along this axis, Bukhari~\etal~\cite{bukhari2013automatic} recently proposed to use an extended Hough Transform of lines to correct radial distortions. With similar assumption, the `plumb-lines' have used to rectify fisheye distortions~\cite{zhang2015line,melo2013unsupervised,aleman2014automatic} . However, their correction effects are limited by the accuracy of geometric object detecting results. Our work in this paper also follows the same assumption as suggested in~\cite{devernay2001straight}, while we propose a deep convolutional neural network to handle the aforementioned problems and generate a more accurate result of {\em distorted lines} extraction in fisheye images. To mitigate the difficulty of detecting geometric objects in distorted images, the deep learning methods were proposed~\cite{rong2016radial,yin2018fisheyerecnet} which imposed the representational features learned by CNNs to the processes of fisheye calibration and image rectification. Among them, the FishEyeRecNet~\cite{yin2018fisheyerecnet} proposed an end-to-end CNNs which introduce scene parsing semantic into the rectification of fisheye images. It has reported promising results, but it is still not clear which kind of high-level geometric information learned from their networks are important for fisheye image rectification. Moreover, The works~\cite{zhang2015line,melo2013unsupervised,aleman2014automatic} explicit geometry like `plumb-lines' are very efficient for distortion corrections, but how to encode them with CNNs in an effective way is still an open problem. Another topic closely related to our work is {\em distorted lines} extraction in fisheye images. Various arc detection methods and optimizing strategies have been utilized in the calibrating process~\cite{brauer2001new,bazin2007rectangle,bukhari2013automatic,aleman2014automatic,zhang2015line}, but they are not robust to detect arcs especially in the environments with noises or texture absence. Although recent deep learning based methods~\cite{xie2015holistically,liu2017richer,Bertasius2014DeepEdge,Hwang2015Pixel, Piotr2015Fast} show a promising performance on edge detection, none of them is well qualified to deal with {\em ditorted lines} in fisheye images. \vspace{-1mm} \subsection{Our Contributions} In this paper, we propose a novel end-to-end network to calibrate fisheye lens and rectify distorted images simultaneously with further exploit of geometric constraints. Specifically, we make the following three contributions: \begin{itemize} \vspace{-1.5mm} \item We proposed an end-to-end CNNs to \emph{impose explicit geometry constraints} onto the process of fisheye lens calibration and distorted image rectification, which achieves the state-of-the-art performance. \vspace{-1.5mm} \item Multi-scale perception is designed to balance the nonlinear distribution of distortion effects in fish-eye images. And more robust distortion parameters obtained from global and local learning, so as to achieve better rectification effect. \vspace{-1.5mm} \item We construct a new large-scale fisheye dataset to train networks and to evaluate the effectiveness and efficiency of fisheye image rectification methods. \end{itemize} \vspace{-2mm} \section{General Fisheye Camera Model} Given a normal pinhole camera with focal length $f$ , the perspective projection model can be written as $r = f\tan\theta$, where $r$ indicates the projection distance between the principal point and the points in the image, and $\theta$ is the angle between the incident ray and the camera's optical axis. While, fisheye lens violates this perspective projection model~\cite{miyamoto1964fish,basu1995alternative}, and has been often approximated by a general polynomial projection model~\cite{kannala2006generic}, \ie, \begin{align} r(\theta)=\sum\nolimits_{i=1}^n k_i\theta^{2i-1}, \quad n=1, 2, 3, 4, \ldots \label{eq:2} \end{align} Usually, this model can accurately approximate the image formation of fisheye lenses when $n$ reaches $5$~\cite{kannala2006generic}. Given a 3D scene point $\mathbf P_c := (x_c,y_c,z_c)^T \in \mathbb{R}^3$ in the camera coordinate system, it will be projected into the image plane with $\mathbf{p}_d := (x_d,y_d)^T\in \mathbb{R}^2$ refracted by the fisheye lens and $\mathbf p :=(x,y)^T \in \mathbb{R}^2$ through perspective lens without distortion. The correspondence between $\mathbf p_d$ and $\mathbf p$ can be expressed as, $\mathbf p_d = r(\theta) (\cos{\varphi}, \sin{\varphi})^T$, with $\varphi=\arctan{((y_d-y)/(x_d-x))}$ indicating the angle between the ray that connects the projected point and the center of image and the $x$-axis of the image coordinate system. Assuming that the pixel coordinate system is orthogonal, we can get pixel coordinates $(u,v)$ converted by image coordinates $\mathbf p_d$ as \begin{align} \dbinom{u}{v}=\begin{pmatrix} m_u&0\\ 0&m_v \end{pmatrix} \dbinom{x_d}{y_d}+\dbinom{u_0}{v_0} \label{eq:project} \end{align} The principal point of fisheye image is represented as $(u_0,v_0)$, and $m_u$,$m_v$ describe the number of pixels per unit distance in horizontal and vertical direction respectively. By using Eq.~\eqref{eq:project}, the distortion effect of fisheye images can be rectified once we can get the parameters $K_d = (k_1,k_2,k_3,k_4,k_5,m_u,m_v,u_0,v_0) $. Therefore, we are going to accurately estimate the parameters $K_d$ for every given fisheye image and simultaneously eliminate the distortion in this paper. \section{Deep Calibration and Rectification Model} In this section, we mainly exploit the relationship between scene geometry of {\em distorted lines} and the corresponding distortion parameters of fisheye images by CNNs, and learn mapping functions from raw input fisheye image to the the rectified image. \subsection{Network Architecture} As shown in Fig.~\ref{fig:net}, our network is mainly composed of \emph{distorted lines perception module} (DLP) which solves the problem of {\em distorted lines} extraction, \emph{line-guided parameter estimation module} (LPE) which provides estimated distortion parameters $K_d$, as well as \emph{rectification module} which serves as connector between geometry and distortion parameters. For a RGB fisheye image $I$ with size of $H\times W$, the {\em distorted lines} map $h\in\mathbb{R}^{H\times W}$ could be acquired from DLP, and then fed the {distorted line} map $h$ and the original fisheye image $I$ together into LPE to learn the global and local parameters through multi-scale perception. And the rectification module could verify the accuracy of learned parameters $K_d$ by analyzing whether the lines in rectified {\em distorted lines} map $\hat{h}'$ have be straight after being rectified with $K_d$. Thereafter, we are able to learn the distortion parameters and rectified images without distortion in the end-to-end manner. Every training data sample for our network contains: (1) a fisheye image $I$, (2) the ground truth distortion parameters $\hat{K}_{gt}$, (3) the ground truth of {\em distorted lines} map $\hat{h}$ of image $I$, (4) the ground truth of the corresponding rectified line map $\hat{h}'$ and (5) the corresponding (rectified) line segments $L = \left\{\bm{x}_i,\bm{x}_i'\right\}_{i=1}^{K}$of image $I$, where the $\bm{x}_i\in\mathbb{R}^2$ and $\bm{x}_i'\in\mathbb{R}^2$ are two endpoints of a line segment. \vspace{-1mm} \paragraph{Distorted Line Perception Module.} Followed by the recent advances of edge and line segment detection~\cite{xie2015holistically, huang2018learning}, we use the Pyramid Residual Modules (RPM) and Stacked Hourglass network~\cite{Newell2016Stacked} to learn the {\em distorted line} segments map $h \in \mathbb{R}^{H\times W}$ from the input images. In details, we firstly use two RPMs to extract feature maps with size of $\frac{H}{4}\times\frac{W}{4}\times 256$ from input image with size of $H\times W \times 3$. Then, we pass the feature map into $5$ stacked hourglass modules. The resulted features are then upscaled by using two deconvolution layers to get the feature with size of $H\times W\times 16$. In the end, we use a convolutional layer with $1\times 1$ kernel size to predict the {\em distorted lines} map $h$. Excepting for the prediction layer, the Batch-Normalization and ReLU are used for each (de)convolution layer. The target of line segment map $\hat{h}$ is defined pixelwised by \begin{equation}\label{eq:line-map} \hat{h}(\bm{p}) = \left\{ \begin{array}{ll} d(\bm{l}) & \text{if}~~\bm{p}~\text{is (nearly) on } \bm{l} \in L,\\ 0 & \text{otherwise}, \end{array} \right. \end{equation} where the function $d(\bm{l}_i)$ is read as $d(\bm{l}_i) = \left\|\bm{x}_i - \bm{x}_i'\right\|_2$. The resulted map $h$ not only can indicate if a pixel $\bm{p}$ is passed through a line segment, the predicted length of rectified line segment also implicitly contains the information for the distortion parameters. \vspace{-1mm} \paragraph{Line-guided Parameters Estimation Module.} This module aims at estimating the distortion parameters from images. As mentioned above, the predicted {\em distorted lines} map could characterize the distortion of fisheye images in some extent. Based on this, regarding the {\em distorted lines} map $h$ output from DLP module as a geometric guidance providing high-level structural information to LPE, we concatenate it with the input fisheye image together with size of $H\times W \times 4$, as the input of LPE to estimate the mutli-scale distortion parameters. As shown in Fig.~\ref{fig:net}, we adopt the level 1 to 4 of the ResNet-50~\cite{he2016deep} as backbone of LPE module, and design a bifurcated structure with a global and a local stream respectively to multi-scale perception, considering the nonlinearity of the distortion distribution in the domain of fisheye images. The global stream treats the entire feature map to estimate the distortion parameters with $2$ convolutional layers and $3$ fully connected (FC) layers. Before the first FC layer of the global stream, we use the global average pooling operator to extract the abstracted global information from images. The last FC layer output a $9$-D vector representing the distortion parameters denoted by $K_g$. Because of the nonlinearity of the distortion distribution, we explicitly use the cropped feature maps from the output of the backbone to estimate the distortion parameters locally. We divide this sideoutput into five smaller blocks - the central region with size of $6\times6\times1024$ and four $5\times5\times1024$ feature maps of upper left, lower left, upper right and lower right, and then send these five set of sub-feature maps into two FC layers and a linear filter separately to predict the local parameters, denoted by $\{K_{loc}^k\}_{k=1}^5$. The parameter settings of these two FC layers are same as those in global stream, meanwhile the weight of them are shared across these five set of sub-feature maps. Since the parameters $m_u, m_v$ and $u_0, v_0$ are related to the entire image, the linear filter only reserve the first five distortion parameters $k_1,\ldots,k_5$ in the previous output. Each output $K_{loc}^k$ is thus a $5$D vector. In training phase, the predicted parameters $K_{loc}^k$ is used as a constraint to regularize the prediction of the global stream. And the output of DLP is the averaged distortion coefficients of global and local parameters, denoted as $K_d$. \vspace{-1mm} \paragraph{Rectification Module.} In this module, we take the predicted distortion parameters $K_{d}$ of LPE module as input to rectify the input fisheye image and the corresponding {\em distorted line} segments map from the DLP module. Suppose that the pixel coordinate in rectified and fisheye images are $\bm{p}=(x,y)$ and $\bm{p}_d=(x_d,y_d)$, their relationship can be read \begin{equation}\label{eq:rectify} \bm{p}_d = \mathcal{T}(\bm{p},K_d)=\begin{pmatrix} u_0\\v_0 \end{pmatrix} + \frac{r(\theta)\bm{p}}{\left\|\bm{p}\right\|_2} \end{equation} With the Eq.~\eqref{eq:rectify}, the {\em distorted lines} map and fisheye image can be rectified by using bilinear interpolation. The significance of the above rectification layer is to explicitly bridge the relation between distortion parameters and geometry structures. The more accurate the estimated distortion parameters, the {\em distorted lines} map will be rectified better. \subsection{Loss Function and Training Scheme}\label{subsec:train} In our network, we can end-to-end output the {\em distorted lines} map $h$, estimated distortion parameters $K_{g}$ and $K_{loc}^{k}, k=1,\ldots,5$ as well as the rectified line segment map for every input image $I$. Inspired by the deeply supervised net \cite{DSN2015} and HED \cite{xie2015holistically}, we make supervision to the outputs of each module. \vspace{-3pt} \paragraph{\bf Loss of Distorted Lines Map Learning.} Considering the fact that {\em distorted line} segments are $0$-measure geometric primitives in 2D images, most of pixels for the target $\hat{h}$ defined in Eq.~\eqref{eq:line-map} will be $0$. In other words, most of pixels will not be passed through any {\em distorted line} segment. For the sake of representation simplicity, the pixels not being on any {\em distorted line} segment are collected to the negative class $\Omega^-$ and the rest of pixels are collected in the positive class $\Omega^+$, with $\Omega^+ = \Omega - \Omega^- $. Then, we weight these two classes in the loss function as \begin{align} \mathcal{L}_{line} = \cfrac{|\Omega^-|}{|\Omega|}\sum_{\bm{p}\in \Omega^+}\mathcal{D}(\bm{p}) + \cfrac{|\Omega^+|}{|\Omega|} \sum_{\bm{p}\in \Omega^-}\mathcal{D}(\bm{p}), \label{eq:line_loss} \end{align} where $\mathcal{D}(\bm{p})$ is defined as $\mathcal{D}(\bm{p}) = \|h(\bm{p}) - \hat{h}(\bm{p})\|_2^2$. \vspace{-4pt} \paragraph{\bf Loss of Distortion Parameter Estimation.} In the LPE module, we try to learn the distortion parameters with a bifurcate structure, which results the parameters $K_{g}$ and $\{K_{loc}^{k}\}_{k=1}^5$. Ideally, we want the outputs of LPE module close to the ground-truth distortion parameters. For the output $K_{g}$, we define the loss as \begin{align} \mathcal{L}_g = \frac{1}{9}\sum_{i=1}^9 w_i (K_{g}(i) - K_{gt}(i))^2, \label{eq:global} \end{align} where the $K_g(i)$ and $K_{gt}(i)$ are the $i$-th component of predicted parameter $K_g$ and the ground truth $K_{gt}$. The weight $w_i$ is used to rescale the magnitude between different components of distortion parameter. On the other side of the bifurcate, the loss of parameters estimated by the sub feature maps are defined as \vspace{-1pt} \begin{align} \mathcal{L}_{loc}^k = \frac{1}{5} \sum_{i=1}^5 w_i(K_{loc}^k(i) - K_{gt}^k(i))^2, \label{eq:local} \end{align} where the $K_{loc}^k(i)$ is the $i$-th component of $K_{loc}^k$. \vspace{-4pt} \paragraph{\bf Global Curvature Constraint Loss.} The $\mathcal{L}_g$ and $\mathcal{L}_{loc}$ enforce the network fit the distortion parameters, however, only optimizing them is not enough and prone to get stuck in the local minimums. Meanwhile, the relation between the parameters and the geometry of {\em distorted line} which should be straight in rectified images provides a stronger constraint to boost the optimizing. If the {\em distorted line} is not completely corrected to a straight line, the estimated distortion parameters are not accurate enough, and vice versa. Therefore, we calculate the pixel-errors between the rectified line map by estimated parameters $K_d$ output from LPE and the ground truth of line map as the global curvature constraint loss $\mathcal{L}_c$: \vspace{-1pt} \begin{align} \mathcal{L}_c = \frac{1}{N}\sum_{\bm{p}_d\in \Omega^+}(\mathcal{F}(\bm{p}_d,K_d)-\mathcal{F}(\bm{p}_d,K_{gt}))^2, \label{eq:curloss} \end{align} \vspace{-3pt} where $\mathcal{F}$ is the inverse function of $\mathcal{T}$ which described in Eq.~\eqref{eq:rectify}, and $N$ is the number of pixels that belong to the {\em distorted line} segment. \vspace{-5mm} \paragraph{Training Scheme.} The network training procedure consists of two phases. In the first phase, we train the {\em distorted line} perception module from scratch with the loss function defined in Eq.~\eqref{eq:line_loss}. Once the DLP module is trained, we fix their parameters and then learn the distortion parameters in the second phase. The total loss we used here is defined as \begin{equation} \mathcal{L} = \lambda_{g}\mathcal{L}_{g}+\lambda_{loc}\sum_{k=1}^{5}\mathcal{L}_{loc}^k+\lambda_{c}\mathcal{L}_{c}, \label{eq:loss} \end{equation} which aims at fitting the parameters and simulating the distortion effect of fisheye during training. The $\lambda_{g}$, $\lambda_{loc}$ and $\lambda_c$ used in Eq.~\eqref{eq:loss} are weight parameters to balance the different terms. \vspace{-1mm} \section{Synthetic Dataset for Calibration} \label{section:dataset} There still remains a crucial problem for training the proposed neural network which requires real distortion parameters as well as well-annotated distorted and rectified line maps. However, to the best of our knowledge, there is no such large scale dataset that satisfy all above requirements. Thanks to the recently released wireframe dataset~\cite{huang20176} which has the labeling of straight lines and the large-scale dataset of 3D scenes SUNCG \cite{song2016ssc} which provides diverse semantic 3D scenes, we construct a new dataset with well-annotated 2D/3D line segments $L$ as well as the corresponding distortion parameters $K_{gt}$ for training. The two subsets of our dataset, the distorted wireframe collection (D-Wireframe) from wireframe dataset and the fisheye SUNCG collection (Fish-SUNCG) from 3D model repository, are described below, as shown in Fig.~{\ref{fig:dataset}}. \begin{figure}[t!] \def0.3\linewidth{0.3\linewidth} \def-5mm{-5mm} \hspace{-5mm} \begin{minipage}{0.05\linewidth} \begin{tikzpicture} \node[rotate=90] (Ours) at (0,0) {D-Wireframe}; \draw[opacity=0] (-0.3\linewidth*0.01,-0.3\linewidth*0.5) rectangle (0.3\linewidth*0.01,0.3\linewidth*0.5); \end{tikzpicture} \end{minipage} \begin{minipage}{1\linewidth} \includegraphics[width=0.15\linewidth]{fig3/fish1.png} \includegraphics[width=0.15\linewidth]{fig3/fish2.png} \includegraphics[width=0.15\linewidth]{fig3/fish3.png} \includegraphics[width=0.15\linewidth]{fig3/fish4.png} \includegraphics[width=0.15\linewidth]{fig3/fish5.png} \includegraphics[width=0.15\linewidth]{fig3/fish6.png} \includegraphics[width=0.15\linewidth]{fig3/fish7.png} \includegraphics[width=0.15\linewidth]{fig3/fish8.png} \includegraphics[width=0.15\linewidth]{fig3/fish9.png} \includegraphics[width=0.15\linewidth]{fig3/fish10.png} \includegraphics[width=0.15\linewidth]{fig3/fish11.png} \includegraphics[width=0.15\linewidth]{fig3/fish12.png} \end{minipage} \vspace{2mm} \hspace{-5mm} \begin{minipage}{0.05\linewidth} \begin{tikzpicture} \node[rotate=90] (Ours) at (0,0) {Fish-SUNCG}; \draw[opacity=0] (-0.3\linewidth*0.01,-0.3\linewidth*0.5) rectangle (0.3\linewidth*0.01,0.3\linewidth*0.5); \end{tikzpicture} \end{minipage} \begin{minipage}{1\linewidth} \includegraphics[width=0.15\linewidth]{fig3/render1.png} \includegraphics[width=0.15\linewidth]{fig3/render2.png} \includegraphics[width=0.15\linewidth]{fig3/render3.png} \includegraphics[width=0.15\linewidth]{fig3/render4.png} \includegraphics[width=0.15\linewidth]{fig3/render5.png} \includegraphics[width=0.15\linewidth]{fig3/render6.png} \includegraphics[width=0.15\linewidth]{fig3/render7.png} \includegraphics[width=0.15\linewidth]{fig3/render8.png} \includegraphics[width=0.15\linewidth]{fig3/render9.png} \includegraphics[width=0.15\linewidth]{fig3/render10.png} \includegraphics[width=0.15\linewidth]{fig3/render11.png} \includegraphics[width=0.15\linewidth]{fig3/render12.png} \end{minipage} \vspace{1mm} \caption{Data samples from the \emph{distorted wireframe} (top) and fisheye SUNCG collections (bottom) of our proposed dataset. Every data sample is shown vertically for the original image and corresponding fisheye image.} \label{fig:dataset} \vspace{-6mm} \end{figure} \begin{figure}[t] \centering \includegraphics[width=0.32\linewidth]{blender/5.png} \includegraphics[width=0.32\linewidth]{blender/per5.png} \includegraphics[width=0.32\linewidth]{blender/fish5.png} \vspace{1mm} \caption{Generation schematic diagram of Fish-SUNCG. Equip each camera with perspective lens and fisheye lens respectively. } \label{fig:gene_fish} \vspace{-5mm} \end{figure} \vspace{-1mm} \paragraph{Distorted Wireframe Collection (D-Wireframe).} For any image in the wireframes datase proposed by~\cite{huang20176} which contains 5462 normal perspective images marked with straight line segments, we randomly generate four different sets of distortion parameters $K_i$ to transform this perspective image into fisheye image with different distortion effects by Eq.~\eqref{eq:2}. Thus, the perspective image and the corresponding line segment annotations can be distorted to the fisheye image with {\em distorted line} segments. In summary, we generate this collection $\mathcal{D}_{wf}$ and split it into training set and testing set with $20,000$ and $1848$ samples respectively. \paragraph{Fisheye SUNCG Collection (Fish-SUNCG).} The D-wireframe collection could provide benefits in terms of diversity and flexibility of fisheye distortion types for the network training. However, artificially distorting the images which taken by perspective cameras cannot fully characterize the fisheye distortion for real scenarios. We address this problem by simulating the image formation for both perspective and fisheye cameras at the same observation positions from the 3D models of SUNCG \cite{song2016ssc} which contains 45K different virtual 3D scenes with manually created realistic room and furniture layouts. In details, we use the Blender~\cite{blender2014blender} to render images by specifying the camera pose and imaging formation models. The rendering protocol is illustrated in Fig.~{\ref{fig:gene_fish}}. For the line segments generating, we remove the texture of 3D models to get the wireframe model of 3D objects. After that, we manually remove the edges of wireframe manually to get the line segments that are on the boundary of objects. Since we are able to control the image formation without metric errors, the data samples can be used to train our network without loss of information. In the end, we generate 6,000 image pairs from 1,000 scenes for training and 300 image pairs from 125 scenes for testing. This collection is denoted as $\mathcal{D}_{sun}$. \vspace{-1mm} \section{Experiments} \vspace{-1mm} \subsection{Implementation Details}\label{section:training} We follow our training scheme described in the Section~\ref{subsec:train}. We use the distorted fisheye images and the corresponding line segment map of distorted wireframe collect $\mathcal{D}_{wf}$ for training the DLP module in the first step. After that, we fix the weights of DLP module and train the rest of our network by using the $\mathcal{D}_{wf}$ and $\mathcal{D}_{sun}$ together. The size of input images for our network is set as $320\times 320$ for both training and testing phases. The weight parameters in Eq.~\eqref{eq:loss} are set to as follow for our experiments: $\lambda_c = 50$, $\lambda_{loc}=\lambda_{g}=1$, and the balance parameters are set to as follow: $W=\{ w_1=0.1,w_2=0.1,w_3=0.5,w_4=1,w_5=1,w_6=0.1,w_7=0.1,w_8=0.1,w_9=0.1 \}$. The optimization method we used for the training is the stochastic steepest descent method (SGD). The initial learning rate is set to 0.01, and then decrease it by a multiple of 0.1 after 100 epochs. The network will converge after 300 epochs. And our network is implemented on the PyTorch platform with a single Titan-X GPU device. \subsection{Evaluation Metrics} Benefiting from the DLP module of our proposed approach, we are able to compare the effects of eliminating distortion and the performance on recovering line geometry by evaluating the rectified {\em distorted lines} map ${\hat{h}}^{'}$ from rectification module and the ground truth image $\hat{h}$. What's more, the {\em Precision} and {\em Recall} are redefined to quantitatively evaluate the error between ${\hat{h}}^{'}$ and $\hat{h}$. Further, the reprojection error (RPE) is proposed to evaluate the overall rectification effects by measuring the pixels deviation between rectified image and fish image. On the other hand, we also follow the evaluation metrics used in previous works \cite{rong2016radial,yin2018fisheyerecnet} that utilize the peak signal to noise ratio (PSNR) and structure similarity index (SSIM) for evaluating the rectified images. \vspace{-5pt} \paragraph{Precision v.s. Recall.} The precision and recall rate of the line segment map prediction is defined as \begin{equation} Precision = |P\cap G|/|P|, \ \ Recall = |P\cap G|/|G|, \end{equation} where the $P$ is the set of edge pixels on the rectified line segment map and $G$ is the set of edge pixels in the ground truth of line segment map without distortion. \vspace{-5pt} \paragraph{PSNR and SSIM.} These two metrics are widely used to describe the degree of pixel blurring and structure distortion respectively. We use them here for comparing the rectified fisheye images. In general, the larger the value of PSNR and SSIM, the better the rectification quality. \vspace{-5pt} \paragraph{\bf Reprejection Error (RPE).} This metric is generally used to quantify the distance between an estimate of a 2D/3D point and its true projection. So we use the real distortion parameters $K_{gt}$ and the estimated ones $K_d$ to rectify the pixels of fisheye image, and get the projection $\mathcal{F}(K_{gt})$ and $\mathcal{F}(K_d)$ respectively, where the $\mathcal{F}$ is the function representation of Eq.~\eqref{eq:curloss}. The mean square error (MSE) of the RPE in the whole fisheye image is defined by $\frac{1}{N}\sum_{\bm{p}_d\in \Omega}(\mathcal{F}(K_{gt})-\mathcal{F}(k_d))^2$. \begin{figure}[t] \begin{rotate}{90} \quad \ \ \ GT \end{rotate} \hspace{0.05cm} \centering \includegraphics[width=0.223\linewidth]{exp_line/00302938_0_fish_ROI_gt.png} \includegraphics[width=0.223\linewidth]{exp_line/00037538_0_fish_gt.png} \includegraphics[width=0.223\linewidth]{exp_line/00063799_0_fish_gt.png} \includegraphics[width=0.223\linewidth]{exp_line/00190925_0_fish_gt.png} \begin{rotate}{90} \ \ Detected \end{rotate} \hspace{0.05cm} \centering \includegraphics[width=0.223\linewidth]{exp_line/00302938_0_fish_ROI_new.png} \includegraphics[width=0.223\linewidth]{exp_line/00037538_0_fish_new.png} \includegraphics[width=0.223\linewidth]{exp_line/00063799_0_fish_new.png} \includegraphics[width=0.223\linewidth]{exp_line/00190925_0_fish_new.png} \caption{{\em Distorted lines} detection results from DLP. {\bf First Row} is ground truth with manual labeling of accurate {\em distorted lines} information. {\bf The Second Row} is the our detection.} \vspace{-10pt} \label{fig:line_dection} \end{figure} \begin{figure}[t] \subfigure[][{\scriptsize Distorted Lines}]{ \begin{minipage}[b]{0.19\linewidth} \includegraphics[width=1\linewidth]{exp_input_line/00077161.png} \includegraphics[width=1\linewidth]{exp_input_line/00192093.png} \end{minipage} } \hspace{-1.9ex} \subfigure[][{\scriptsize Bukhari~\cite{bukhari2013automatic}}]{ \begin{minipage}[b]{0.19\linewidth} \includegraphics[width=1\linewidth]{exp_input_line/00077161_buk.png} \includegraphics[width=1\linewidth]{exp_input_line/00192093_buk.png} \end{minipage} } \hspace{-1.9ex} \subfigure[][{\scriptsize AlemnFlores\cite{aleman2014automatic}}]{ \begin{minipage}[b]{0.19\linewidth} \includegraphics[width=1\linewidth]{exp_input_line/00077161_af.png} \includegraphics[width=1\linewidth]{exp_input_line/00192093_af.png} \end{minipage} } \hspace{-1.9ex} \subfigure[][{\scriptsize Rong~\cite{rong2016radial}}]{ \begin{minipage}[b]{0.19\linewidth} \includegraphics[width=1\linewidth]{exp_input_line/00077161_song.png} \includegraphics[width=1\linewidth]{exp_input_line/00192093_song.png} \end{minipage} } \hspace{-1.9ex} \subfigure[][{\scriptsize Ours}]{ \begin{minipage}[b]{0.19\linewidth} \includegraphics[width=1\linewidth]{exp_input_line/00077161_ours.png} \includegraphics[width=1\linewidth]{exp_input_line/00192093_ours.png} \end{minipage} } \caption{Rectify the distorted lines. First column is the detection results by DLP. Other columns is the rectification results by different methods.} \vspace{-1mm} \label{fig:input_line} \end{figure} \begin{figure}[t!] \vspace{-2mm} \centering \includegraphics[width=0.6\linewidth]{chart/plot3.png} \caption{The precision-recall curves of different rectification methods for the line map rectification~\cite{bukhari2013automatic,aleman2014automatic,rong2016radial}.} \vspace{-10pt} \label{fig:PR} \end{figure} \subsection{Comparison with State-of-the-art Methods} Our network mainly includes {\em distorted lines} detection in DLP and distortion parameters estimation in DPE, aiming at performing better rectification effects. For DLP, the highly accurate detection of {\em distorted lines} output from this module is the premise of accurate distortion parameters learning. As shown in Fig.~{\ref{fig:line_dection}}, the detection results by our method from DLP show excellent performance as well as close to the ground truth in visual effects. Instead of directly evaluating the result of {\em distorted line} detection, we jointly evaluate the performance of {\em distorted lines} detection and the accuracy of parameters estimation compared with existing state-of-the-art methods~\cite{bukhari2013automatic,aleman2014automatic,rong2016radial}, and the details will be discussed in the following. For DPE, the effective use of geometric constraints is the key to guarantee the rectification effects. According to previous analysis, the evaluation for the rectified line segment map can explicitly illustrate the geometric accuracy of rectification. In other words, if the rectified {\em distorted lines} map still exists curved geometry or has deviation from the ground truth, it shows that the learned distortion parameters are not accurate enough. In visual effect, we show the geometric rectification of the {\em distorted lines} map which output from the rectification module intuitively in Fig.~{\ref{fig:input_line}} to verify our network actually has the ability of recovering the straight line characteristics. The results show that the rectified line map through our network is indeed straightened, while those rectified by other methods are still distorted in some extent and it proves the validity of the geometric constraint in our network. Further more, we report the precision and recall curves in Fig.~{\ref{fig:PR}} to show the comparison in quantitative. Obviously, our method is far superior to other methods~\cite{bukhari2013automatic,aleman2014automatic,rong2016radial} in terms of line geometric structure recovery, and achieves the best result (F-value =.819). \begin{table}[t!] \centering \caption{Comparisons with the state-of-the-arts, using the PSNR, SSIM and reprojection error (RPE) calculated on rectified results obtained by different methods. } \vspace{1mm} \setlength{\tabcolsep}{0.7mm}{ \begin{tabular}{ccccc} \hline \small Methods& Bukhar\cite{bukhari2013automatic} & AlemnFlores\cite{aleman2014automatic}& Rong\cite{rong2016radial}& Ours\\ \hline PSNR& 9.3391& 10.23& 12.92& {\bf27.61}\\ SSIM& 0.1782& 0.2587& 0.3154& {\bf0.8746}\\ RPE&164.7 &125.4 & 121.6& {\bf0.4761}\\ \hline \end{tabular}} \label{table:1} \vspace{-5mm} \end{table} \begin{figure}[t] \centering \vspace{0mm} \begin{rotate}{90} \hspace{1ex} D-Wireframe \end{rotate} \hspace{0.1ex} \subfigure[]{ \begin{minipage}[b]{0.15\linewidth} \includegraphics[width=1\linewidth]{experiment1/00061141.png} \includegraphics[width=1\linewidth]{experiment1/00031810.png} \end{minipage} } \hspace{-1.9ex} \subfigure[]{ \begin{minipage}[b]{0.15\linewidth} \includegraphics[width=1\linewidth]{experiment1/00061141_buk.png} \includegraphics[width=1\linewidth]{experiment1/00031810_buk.png} \end{minipage} } \hspace{-1.9ex} \subfigure[]{ \begin{minipage}[b]{0.15\linewidth} \includegraphics[width=1\linewidth]{experiment1/00061141-af.png} \includegraphics[width=1\linewidth]{experiment1/00031810-af2.png} \end{minipage} } \hspace{-1.9ex} \subfigure[]{ \begin{minipage}[b]{0.15\linewidth} \includegraphics[width=1\linewidth]{experiment1/00061141_song2.png} \includegraphics[width=1\linewidth]{experiment1/00031810_song2.png} \end{minipage} } \hspace{-1.9ex} \subfigure[]{ \begin{minipage}[b]{0.15\linewidth} \includegraphics[width=1\linewidth]{experiment1/00061141_ours.png} \includegraphics[width=1\linewidth]{experiment1/00031810_ours.png} \end{minipage} } \hspace{-1.9ex} \subfigure[]{ \begin{minipage}[b]{0.15\linewidth} \includegraphics[width=1\linewidth]{experiment1/00061141_gt.png} \includegraphics[width=1\linewidth]{experiment1/00031810_gt.png} \end{minipage} } \\ \centering \vspace{-4.5ex} \begin{rotate}{90} \hspace{1ex} Fish-SUNGCG \end{rotate} \hspace{0.1ex} \subfigure[][{\scriptsize Input}]{ \begin{minipage}[b]{0.15\linewidth} \includegraphics[width=1\linewidth]{experiment-render/6128.png} \includegraphics[width=1\linewidth]{experiment-render/6010.png} \end{minipage} } \hspace{-1.9ex} \subfigure[][{\scriptsize Bukhari}]{ \begin{minipage}[b]{0.15\linewidth} \includegraphics[width=1\linewidth]{experiment-render/6128_buk.png} \includegraphics[width=1\linewidth]{experiment-render/6010_buk.png} \end{minipage} } \hspace{-1.9ex} \subfigure[][{\scriptsize AlemnFlores}]{ \begin{minipage}[b]{0.15\linewidth} \includegraphics[width=1\linewidth]{experiment-render/6128-af.png} \includegraphics[width=1\linewidth]{experiment-render/6010-af.png} \end{minipage} } \hspace{-1.9ex} \subfigure[][{\scriptsize Rong}]{ \begin{minipage}[b]{0.15\linewidth} \includegraphics[width=1\linewidth]{experiment-render/6128_song.png} \includegraphics[width=1\linewidth]{experiment-render/6010_song.png} \end{minipage} } \hspace{-1.9ex} \subfigure[][{\scriptsize Ours}]{ \begin{minipage}[b]{0.15\linewidth} \includegraphics[width=1\linewidth]{experiment-render/6128_ours.png} \includegraphics[width=1\linewidth]{experiment-render/6010_ours.png} \end{minipage} } \hspace{-1.9ex} \subfigure[][{\scriptsize GT}]{ \begin{minipage}[b]{0.15\linewidth} \includegraphics[width=1\linewidth]{experiment-render/6128_gt.png} \includegraphics[width=1\linewidth]{experiment-render/6010_gt.png} \end{minipage} } \caption{Qualitative rectification comparison on D-Wireframe dataset and fish-SUNGCG dataset. From left to right, the input fisheye images, the ground truth, results of three state-of-the-art methods (Bukhari~\cite{bukhari2013automatic}, AlemnFlores~\cite{aleman2014automatic}, Rong~\cite{rong2016radial}), our results.} \vspace{-7mm} \label{fig:parametric} \end{figure} \begin{figure*}[t] \centering \subfigure[][{\scriptsize Input}]{ \begin{minipage}[b]{0.09\linewidth} \includegraphics[width=1\linewidth]{experiment-real/fish_1.png} \includegraphics[width=1\linewidth]{experiment-real/fish_3.png} \end{minipage} } \hspace{-1.9ex} \subfigure[][{\scriptsize Bukhari~\cite{bukhari2013automatic}}]{ \begin{minipage}[b]{0.09\linewidth} \includegraphics[width=1\linewidth]{experiment-real/1-buk2.png} \includegraphics[width=1\linewidth]{experiment-real/3-buk2.png} \end{minipage} } \hspace{-1.9ex} \subfigure[][{\scriptsize\centering{AlemnFlores~\cite{aleman2014automatic}}}] { \begin{minipage}[b]{0.09\linewidth} \includegraphics[width=1\linewidth]{experiment-real/1-Alemn-Flores.png} \includegraphics[width=1\linewidth]{experiment-real/3-Alemn-Flores.png} \end{minipage} } \hspace{-1.9ex} \subfigure[][{\scriptsize Rong~\cite{rong2016radial}}]{ \begin{minipage}[b]{0.09\linewidth} \includegraphics[width=1\linewidth]{experiment-real/1-song.png} \includegraphics[width=1\linewidth]{experiment-real/3-song.png} \end{minipage} } \hspace{-1.9ex} \subfigure[][{\scriptsize Ours}]{ \begin{minipage}[b]{0.09\linewidth} \includegraphics[width=1\linewidth]{experiment-real/1-our4.png} \includegraphics[width=1\linewidth]{experiment-real/3-our2.png} \end{minipage} } \subfigure[][{\scriptsize Input}]{ \begin{minipage}[b]{0.09\linewidth} \includegraphics[width=1\linewidth]{experiment-real/fish_4.png} \includegraphics[width=1\linewidth]{experiment-real/5.png} \end{minipage} } \hspace{-1.9ex} \subfigure[][{\scriptsize Bukhari~\cite{bukhari2013automatic}}]{ \begin{minipage}[b]{0.09\linewidth} \includegraphics[width=1\linewidth]{experiment-real/4-buk2.png} \includegraphics[width=1\linewidth]{experiment-real/buk-5.png} \end{minipage} } \hspace{-1.9ex} \subfigure[][{\scriptsize\centering{AlemnFlores~\cite{aleman2014automatic}}}] { \begin{minipage}[b]{0.09\linewidth} \includegraphics[width=1\linewidth]{experiment-real/4-Alemn-Flores.png} \includegraphics[width=1\linewidth]{experiment-real/af-5.png} \end{minipage} } \hspace{-1.9ex} \subfigure[][{\scriptsize Rong~\cite{rong2016radial}}]{ \begin{minipage}[b]{0.09\linewidth} \includegraphics[width=1\linewidth]{experiment-real/4-song.png} \includegraphics[width=1\linewidth]{experiment-real/rong-5.png} \end{minipage} } \hspace{-1.9ex} \subfigure[][{\scriptsize Ours}]{ \begin{minipage}[b]{0.09\linewidth} \includegraphics[width=1\linewidth]{experiment-real/4-our2.png} \includegraphics[width=1\linewidth]{experiment-real/our-5.png} \end{minipage} } \caption{Qualitative rectification comparison on fisheye images taken by real fisheye cameras. } \vspace{-12pt} \label{fig:real} \end{figure*} \begin{figure*}[t] \centering \subfigure[][{Input}]{ \begin{minipage}[b]{0.12\linewidth} \includegraphics[width=1\linewidth]{experiment-net/00031841.png} \includegraphics[width=1\linewidth]{experiment-net/00055416.png} \end{minipage} } \hspace{-1.9ex} \subfigure[][\centering{w/o CVC\&MSP}]{ \begin{minipage}[b]{0.12\linewidth} \includegraphics[width=1\linewidth]{experiment-net/00031841_base.png} \includegraphics[width=1\linewidth]{experiment-net/00055416_base.png} \end{minipage} } \hspace{-1.9ex} \subfigure[][\centering{w/o CVC }]{ \begin{minipage}[b]{0.12\linewidth} \includegraphics[width=1\linewidth]{experiment-net/00031841_branch.png} \includegraphics[width=1\linewidth]{experiment-net/00055416_branch.png} \end{minipage} } \hspace{-1.9ex} \subfigure[][\centering{ w/o MSP}]{ \begin{minipage}[b]{0.12\linewidth} \includegraphics[width=1\linewidth]{experiment-net/00031841_curs.png} \includegraphics[width=1\linewidth]{experiment-net/00055416_curs.png} \end{minipage} } \hspace{-1.9ex} \subfigure[][{ only RGB}]{ \begin{minipage}[b]{0.12\linewidth} \includegraphics[width=1\linewidth]{experiment-net/new3.png} \includegraphics[width=1\linewidth]{experiment-net/new6.png} \end{minipage} } \hspace{-1.9ex} \subfigure[][{only Line}]{ \begin{minipage}[b]{0.12\linewidth} \includegraphics[width=1\linewidth]{experiment-net/new4.png} \includegraphics[width=1\linewidth]{experiment-net/new5.png} \end{minipage} } \hspace{-1.9ex} \subfigure[][{ Ours}]{ \begin{minipage}[b]{0.12\linewidth} \includegraphics[width=1\linewidth]{experiment-net/00031841_ours.png} \includegraphics[width=1\linewidth]{experiment-net/00055416_ours.png} \end{minipage} } \hspace{-1.9ex} \subfigure[][{ Ground Truth}]{ \begin{minipage}[b]{0.12\linewidth} \includegraphics[width=1\linewidth]{experiment-net/00031841_gt.png} \includegraphics[width=1\linewidth]{experiment-net/00055416_gt.png} \end{minipage} } \caption{Ablation experiments to verify effectiveness of the curvature constraint(CVC) and the local perception(LP) of fisheye image.} \vspace{-10pt} \label{fig:peeltest} \end{figure*} We also follow the evaluation metrics PSNR, SSIM as well as reprojection errors (RPE) for qualitative evaluation of all rectified fisheye images on our test set, as reported in Tab.~{\ref{table:1}}. From the evaluation results, it demonstrate that no matter in image rectification or in structure maintenance, our method is obviously superior to other methods and has achieved the highest score on PSNR, SSIM as well as RPE. It is worth mentioning that the reprojection error of the whole image calculated by our method is within one pixel, while other methods far behind us. Just for the reason that the estimated fisheye distortion parameters are highly consistent with the true parameters, our reprojection error can be controlled in such small range, resulting in the best rectification visual effect. For the rectification effects in visual effect, we visualize the rectification effects by our method and start-of-the-art methods~\cite{bukhari2013automatic,aleman2014automatic,rong2016radial} on the test set of D-Wireframe and Fish-SUNCG collections respectively, as shown in Fig.~{\ref{fig:parametric}}. For the D-Wireframe, we selected special images of different types of fisheye distortion, such as typical full-frame fisheye image, full circle fisheye image and drum fisheye image, and the results show that our method has excellent rectification effect in visual effects, while other methods can not satisfy the needs of correcting various distortion effects of fisheye images. For the Fish-SUNCG, our network also achieves the best rectification performance and the rectified fisheye image is more closer to ground truth. Finally, we add an additional set of comparison experiments to rectify the fisheye image in real world for the generalization performance of the proposed network, as shown in Fig.~{\ref{fig:real}}. Although we do not have the internal camera parameters for taking these fisheye images, it demonstrate that our method has excellent rectification performance even for real fisheye images from the visual effect and prove that our network has higher generalization ability. \subsection{Ablation Study} In this section, we mainly analyze the validity of our network structures involving geometric learning, including the fourth dimensional input of concatenating the input image and detected {\em distorted lines} map in LPE, curvature constraint (CVC), as well as multi-scale perception (MSP) for locally and globally estimating the distortion parameters. As shown in Fig.~{\ref{fig:peeltest}}, once there are lack of CVC or MSP, the rectification effect of the network will become unstable, meanwhile problems of over-rectified and under-rectified will occur, and the network with RGB fisheye image and one-dimensional line map input performs best in rectification performance. \begin{table}[t] \centering \caption{Ablation study to evaluate the rectified image quality of PSNR, SSIM and reprojection error (RPE).} \vspace{1mm} \setlength{\tabcolsep}{1mm}{ \begin{tabular}{c|c|ccc} \hline &Methods& PSNR& SSIM &RPE\\ \hline \multirow{3}{40pt}{\centering {\em Loss \\ Strategy}} & { w/o} CVC\&MSP& 13.05& 0.4222 &78.32\\ &{ w/o} CVC& 19.17& 0.7074& 4.326\\ &{ w/o} MSP& 19.78& 0.6999& 3.175\\ \hline \multirow{3}{*}{{\em Input}}& only RGB& {21.35}& {0.7158} &{ 1.872}\\ &only Line& {22.41}& {0.7369} &{ 1.568}\\ &Ours& {\bf27.61}& {\bf0.8746} &{\bf 0.4761}\\ \hline \end{tabular}} \label{table:2} \vspace{-5mm} \end{table} For qualitative evaluation, we evaluated the quality of rectified images on PSNR, SSIM and RPE, as shown in Tab.~{\ref{table:2}}. It demonstrates the ability level differences of rectification more intuitively, and proves that CVC, MSP, as well as the four-dimensional input (RGB+Line) do play critical roles in our network. According to our analysis, it is probably that the network learned high-level structural information from the {\em distorted lines} that boost the effects. In addition, the worst results in this experiment is still better than state-of-the-art methods. It also proves the scientificity and reasonability of our network. \vspace{-1mm} \section{Conclusion} \vspace{-1mm} In this paper, we proposed a network that utilize line constraints to calibrate the fisheye lenses and eliminate the distortion effects automatically from single image. To train the network, we reuse the existing datasets that have rich $2$D and $3$D geometric information to generate the a synthetic dataset for fisheye calibration. The proposed method takes the advantages of geometry aware deep features, curvature constraints and multi-scale perception blocks to achieve the best performance compared to the state-of-the-art methods, both qualitatively and quantitatively. \noindent{\bf Acknowledgment:} This work is supported by NSFC-projects under contracts No.61771350 and 61842102. Nan Xue is supported by China Scholarship Council. Thanks for the support and help from tutors and seniors. {\small \bibliographystyle{ieee}
{'timestamp': '2019-05-02T02:13:12', 'yymm': '1904', 'arxiv_id': '1904.09856', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.09856'}
arxiv
\section{Introduction} Formal analysis of cryptographic protocols has become one of the most successful applications of formal methods to security, with a number of tools available and many successful applications to the analysis of protocol standards. In the course of developing these tools it has become clear that there are certain universal features that can best be handled by accounting for them directly in syntax and semantics of the formal specification language, e.g., unguessable nonces, communication across a network controlled by an attacker, and support for the equational properties of cryptographic primitives. Thus a number of different languages have been developed that include these features. At the same time, it is necessary to provide support for more commonly used constructs, such as \emph{choice points} that cause the protocol to continue in different ways, and to do so in such a way that they are well integrated with the more specifically cryptographic features of the language. However, in their original form most of these languages do not support choice, or support it only in a limited way. In particular the strand space model \cite{strands}, one of the most popular models designed for use in cryptographic protocol analysis, does not support choice in its original form; strands describe linear sequences of input and output messages, without any branching. One response to dealing with this limitation, and to formalizing strand spaces in general has been to embed the strand space model in some other formal system that supports choice, e.g., event-based models for concurrency \cite{DBLP:conf/fsttcs/CrazzolaraW02}, Petri nets \cite{DBLP:journals/entcs/Froschle09}, or multi-set rewriting \cite{DBLP:conf/csfw/CervesatoDMLS00}. However, we believe that there is an advantage in introducing choice in the strand space model itself, while proving soundness and completeness with another formal system in order to validate the augmented model. This allows us to concentrate on handling the types of choice that commonly arise in cryptographic protocols. A detailed discussion of related work can be found at Section~\ref{sec:related-work}. \subsection{Contributions} This paper is an extended version of the conference paper \cite{YEMMS16}. We address the problem of representing choice in the strand space model, particularly as it is used in the Maude-NPA cryptographic protocol analysis tool. We have identified a class of choices which includes finite branching and some cases of infinite branching. At the theoretical level, we provide a bisimulation result between the expected forwards execution semantics of the new process algebra and the original symbolic backwards semantics of Maude-NPA. This requires extra intermediate forwards and backwards semantics that are included in this paper, together with all the proofs, but were not included in the conference paper \cite{YEMMS16}. What these results make possible is a sound and complete symbolic reachability analysis method for cryptographic protocols with choice \emph{modulo} equational properties of the cryptographic functions satisfying the finite variant property (FVP) (see \cite{MNPAmanual3.0} for a detailed explanation of how FVP theories are supported in Maude-NPA). At the tool level, we have fully integrated the process algebra syntax, and its transformation into strands, and have developed new methods to specify attack states using the process notation in the recent release of Maude-NPA 3.0 (see Section \ref{Integration}, and \cite{MNPAmanual3.0}). None of this was available at the time of the conference paper \cite{YEMMS16}. Furthermore, we illustrate the expressive power and naturalness of adding choice to strand spaces with various examples, and show how it can be effectively used in formal analysis. \subsection{Choice in Maude-NPA} Previous to this work, Maude-NPA offered some ways of handling choice, but its scope was limited, and a uniform semantics of choice was lacking. Several kinds of branching could be handled by a protocol composition method in which a single parent strand is composed with one or more child strands. Although protocol composition is intended for modular construction of protocols, with suitable restrictions it can also be used to express both non-deterministic branching and deterministic branching predicates on pattern matching of output parameters of the parent with the input parameters of the child. However, repurposing composition to branching has its limitations. First of all, it is possible to inadvertently introduce non-deterministic choice into what was intended to be deterministic choice by unwise choice of input and output parameters. Secondly, the limitation to pattern matching rules out certain types of deterministic choice conditioned on predicates that cannot be expressed this way, e.g., disequality predicates. Finally, implementation of choice via composition can be inefficient, since Maude-NPA must evaluate all possible child strands that match a parent strand. Maude-NPA, in common with many other cryptographic protocol analysis tools, also offers a type of implicit choice that does not involve branching: non-deterministic choice of the values of certain variables. For example, a strand that describes an initiator communicating with a responder generally uses variables for both the initiator and responder names; this represents a non-deterministic choice of initiator responder identities. However, the semantic implications of this kind of choice were not that well understood, which made it difficult to determine where it could safely be used. Clearly, a more unified treatment of choice was necessary, together with a formal semantics of choice. In support of this work we have developed a taxonomy of choice in which the categories of deterministic and non-deterministic choice are further subdivided. First of all, \allowbreak non-deterministic choice is subdivided into \emph{explicit} and \emph{implicit} non-deterministic choice. In explicit non-deterministic choice a role\footnote{As further explained later, the behaviors of protocol participants, e.g., sender, receiver, server, etc., are described by their respective \emph{roles}. Since a protocol may have multiple sessions, various participants, called \emph{principals}, may play the same role in different sessions.} chooses either one branch or another at a choice point \ non- deterministically. In implicit non-deterministic choice a logical \emph{choice variable} is introduced which may be non-deterministically instantiated by the role. Deterministic choice is subdivided into (explicit) \emph{if-then-else} choice and \emph{implicit deterministic choice}. In if-then-else choice a predicate is evaluated. If the predicate evaluates to true one branch is chosen, and if it evaluates to false another branch is chosen. Deterministic choice with more than two choices can be modeled by nesting of if-then-else choices. In implicit deterministic choice, a term pattern is used as an implicit guard, so that only messages matching such pattern can be chosen i.e., accepted, by the role. Although implicit deterministic choice can be considered a special case of if-then-else choice in which the second branch is empty, it is often simpler to treat it separately. Classifying choice in this way allows us to represent all possible behaviors of a protocol by a finite number of strands modeling possible executions, while still allowing the variables used in implicit non-deterministic and deterministic choice to be instantiated in an infinite number of ways. \subsection{A Motivating Example}\label{sec:ex} In this section we introduce a protocol that we will use as a running example. It is a simplified version of the handshake protocol in TLS 1.3 \cite{tls1.3.12}, a proposed update to the TLS standard for client-server authentication. This protocol, like most other protocol standards, offers a number of different choices that are applied in different situations. In order to make the presentation and discussion manageable, we present only a subset here: the client chooses a Diffie-Hellman group, and proposes it to the server. The server can either accept it or request that the client proposes a different group. In addition, the server has the option of requesting that the client authenticates itself. We present the protocol at a high level similar to the style used in \cite{tls1.3.12}. \begin{example}\label{ex:tlsinf} We let a dashed arrow $\dasharrow$ denote an optional message, and an asterisk * denote an optional field. \begin{enumerate} \item $C \rightarrow S:$ ClientHello, Key\_Share \\ The client sends a Hello message containing a nonce and the Diffie-Hellman group it wants to use. It also sends a Diffie-Hellman key share. \begin{itemize} \item{1.1} $S \dashrightarrow C:$ HelloRetryRequest \\ The server may optionally reject the Diffie-Hellman group proposed by the client and request a new one. \item{1.2} $C \dashrightarrow S:$ DHGroup, Key\_Share \\ The client proposes a new group and sends a new key share. \end{itemize} \item $S \rightarrow C:$ ServerHello, Key\_Share, \\\mbox{}\hspace{8ex} \{AuthReq*\},\{CertificateVerify\}, \{Finished\}\\ The server sends its own Hello message and a Diffie-Hellman key share. It may optionally send an AuthReq to the client to authenticate itself with a public key signature from its public key certificate. It then signs the entire handshake using its own public key in the CertificateVerify field. Finally, in the Finished field it computes a MAC over the entire handshake using the shared Diffie-Hellman key. The $\{\}$ notation denotes a field encrypted using the shared Diffie-Hellman key. \item $C \rightarrow S:$ $\{$CertificateVerify*$\}$, $\{$Finished$\}$ \\ If the client received an AuthReq from the server it returns its own CertificateVerify and Finished fields. \end{enumerate} \end{example} \subsection{Plan of the paper} The rest of the paper is organized as follows. After some preliminaries in Section \ref{sec:prelim} and a high level introduction of the Maude-NPA tool in Section \ref{sec:mnpa-syntax}, we first define the process algebra syntax and operational semantics in Section \ref{sec:PA}. In Section \ref{sec:Cstr} we extend Maude-NPA's strand space syntax to include choice operators. The main bisimulation results between the expected forwards semantics of the process algebra in Section \ref{sec:PA} and the original symbolic backwards strand semantics of Maude-NPA of Section \ref{sec:mnpa-syntax} are Theorems~\ref{thm: Soundness-PA}~and~\ref{thm: Completeness-PA}. They are proved by introducing an intermediate semantics, a forward strand space semantics originally introduced in \cite{Escobar2014FW}. First, in Section~\ref{sec:Cstr} we extend the strand space model with constraints, since strands are the basis of both the forwards semantics and the backwards semantics of Maude-NPA. In Section~\ref{sec:CstrFW} we augment the forwards strand space semantics of \cite{Escobar2014FW} with choice operators and operational semantic rules to produce a \emph{constrained forwards semantics}. In Section~\ref{sec:PA-CstrFW-bisim} we prove bisimilarity of the process algebra semantics of Section \ref{sec:PA} and the constrained forwards semantics of Section \ref{sec:CstrFW}. In~\cite{Escobar2014FW} the forwards strand space semantics was proved sound and complete w.r.t. the original symbolic backwards semantics of Maude-NPA and, therefore, such proofs had to be extended to handling constraints. In Section~\ref{sec:CstrBW} we augment the original symbolic backwards semantics of Maude-NPA with choice operators and operational semantic rules to produce a \emph{constrained backwards semantics}. In Section~\ref{sec:proof-CstrFW-CstrBW} we then prove that the constrained backwards semantics is sound and complete with respect to the constrained forwards semantics. By combining the bisimulation between the process algebra and the constrained forwards semantics on the one hand (Theorem~\ref{thm:Bisimulation}) and the bisimulation between the constrained forwards semantics and the constrained backwards semantics on the other hand (Theorems~\ref{thm:soundness} and~\ref{thm:completeness}) we obtain the main bisimulation results (Theorems~\ref{thm: Soundness-PA} and~\ref{thm: Completeness-PA}). Finally, in Section \ref{sec:Exp} we describe how the process algebra has been fully integrated into Maude-NPA and show some experiments we have run using Maude-NPA on various protocols exhibiting both deterministic and non-deterministic choice. In Section \ref{sec:related-work} we discuss related and future work, in particular the potential of using the process algebra syntax as a specification language. Finally, we conclude in Section~\ref{sec:Conclusion}. \section{Preliminaries}\label{sec:prelim} We follow the classical notation and terminology for term rewriting and for rewriting logic and order-sorted notions, see \cite{Meseguer92}. We assume an order-sorted signature ${\bf \Sigma} = (\sort{S}, \leq, \Sigma)$ with poset of sorts $(\sort{S}, \leq)$. We also assume an $\sort{S}$-sorted family $\caX=\{\caX_\sort{s}\}_{\sort{s} \in \sort{S}}$ of disjoint variable sets with each $\caX_\sort{s}$ countably infinite. $\TermsS{\sort{s}}$ is the set of terms of sort \sort{s}, and $\GTermsS{\sort{s}}$ is the set of ground terms of sort \sort{s}. We write $\TermsOn{\Symbols}{\Variables}{}{}{}$ and $\GTermsOn{\Symbols}{}$ for the corresponding order-sorted term algebras. For a term $t$, $\var{t}$ denotes the set of variables in $t$. A \textit{substitution} $\sigma\in\SubstOn{\Symbols}{\Variables}{}{}{}$ is a sorted mapping from a finite subset of $\caX$ to $\TermsOn{\Symbols}{\Variables}{}{}{}$. Substitutions are written as $\sigma=\{X_1 \mapsto t_1,\ldots,X_n \mapsto t_n\}$ where the domain of $\sigma$ is $\domain{\sigma}=\{X_1,\ldots,X_n\}$ and the set of variables introduced by terms $t_1,\ldots,\allowbreak t_n$ is written $\range{\sigma}$. The identity substitution is denoted $\textit{id}$. Substitutions are homomorphically extended to $\TermsOn{\Symbols}{\Variables}{}{}{}$. The application of a substitution $\sigma$ to a term $t$ is denoted by $t\sigma$. For simplicity, we assume that every substitution is idempotent, i.e., $\sigma$ satisfies $\domain{\sigma}\cap\range{\sigma}=\emptyset$. This ensures $t\sigma=(t\sigma)\sigma$. The restriction of $\sigma$ to a set of variables $V$ is $\subterm{\sigma}{V}$. Composition of two substitutions $\sigma$ and $\sigma'$ is denoted by $\sigma\circ\sigma'$. A substitution $\sigma$ is a ground substitution if $\range{\sigma} =\emptyset$. A \textit{$\Sigma$-equation} is an unoriented pair $t = t'$, where $t,t' \in \TermsS{s}$ for some sort $\sort{s}\in\sort{S}$. Given $\Sigma$ and a set $E$ of $\Sigma$-equations, order-sorted equational logic induces a congruence relation $\congr{E}$ on terms $t,t' \in \TermsOn{\Symbols}{\Variables}{}{}{}$. The $E$-equivalence class of a term $t$ is denoted by $[t]_E$ and $\TermsOn{\Symbols\!/\!E}{\Variables}{}{}{}$ and $\GTermsOn{\Symbols/E}{}$ denote the corresponding order-sorted term algebras modulo $E$. Throughout this paper we assume that $\GTermsS{s}\neq\emptyset$ for every sort \sort{s}, because this affords a simpler deduction system. An \emph{equational theory} $(\Sigma,E)$ is a pair with $\Sigma$ an order-sorted signature and $E$ a set of $\Sigma$-equations. The \textit{$E$-subsumption} preorder $\sqsupseteq_{E}$ (or just $\sqsupseteq$ if $E$ is understood) holds between $t,t' \in \TermsOn{\Symbols}{\Variables}{}{}{}$, denoted $t \sqsupseteq_{E} t'$ (meaning that $t$ is \emph{more general} than $t'$ modulo $E$), if there is a substitution $\sigma$ such that $t\sigma \congr{E} t'$; such a substitution $\sigma$ is said to be an \textit{$E$-match} from $t'$ to $t$. An \textit{$E$-unifier} for a $\Sigma$-equation $t = t'$ is a substitution $\sigma$ such that $t\sigma \congr{E} t'\sigma$. For $\var{t}\cup\var{t'} \subseteq W$, a set of substitutions $\csuV{t = t'}{W}{E}$ is said to be a \textit{complete} set of unifiers for the equality $t = t'$ modulo $E$ away from $W$ iff: (i) each $\sigma \in \csuV{t = t'}{W}{E}$ is an $E$-unifier of $t = t'$; (ii) for any $E$-unifier $\rho$ of $t = t'$ there is a $\sigma \in \csuV{t=t'}{W}{E}$ such that $\subterm{\sigma}{W} \sqsupseteq_{E} \subterm{\rho}{W}$; (iii) for all $\sigma \in \csuV{t=t'}{W}{E}$, $\domain{\sigma} \subseteq (\var{t}\cup\var{t'})$ and $\range{\sigma} \cap W = \emptyset$. If the set of variables $W$ is irrelevant or is understood from the context, we write $\csu{t = t'}{W}{E}$ instead of $\csuV{t = t'}{W}{E}$. An $E$-unification algorithm is \textit{complete} if for any equation $t = t'$ it generates a complete set of $E$-unifiers. A unification algorithm is said to be \textit{finitary} and complete if it always terminates after generating a finite and complete set of solutions. A \textit{rewrite rule} is an oriented pair $l \to r$, where\footnote{We do not impose the requirement $\var{r} \subseteq \var{l}$, since extra variables (e.g., choice variables) may be introduced in the righthand side of a rule. Rewriting with extra variables in righthand sides is handled by allowing the matching substitution to instantiate these extra variables in any possible way. Although this may produce an infinite number of one-step concrete rewrites from a term due to the infinite number of possible instantiations, the symbolic, narrowing-based analysis used by Maude-NPA and explained below can cover all those infinite possibilities in a finitary way. } $l \not\in \caX$ and $l,r \in \TermsS{s}$ for some sort $\sort{s}\in\sort{S}$. An \textit{(unconditional) order-sorted rewrite theory} is a triple $(\Sigma,E,R)$ with $\Sigma$ an order-sorted signature, $E$ a set of $\Sigma$-equations, and $R$ a set of rewrite rules. The rewriting relation on $\TermsOn{\Symbols}{\Variables}{}{}{}$, written $t \rewrite{R} t'$ or $t \rewrite{p,R} t'$ holds between $t$ and $t'$ iff there exist $p \in \funocc{t}$, $l \to r\in R$ and a substitution $\sigma$, such that $\subterm{t}{p} = l\sigma$, and $t' = \replace{t}{p}{r\sigma}$. The subterm $t|_{p}$ is called a \emph{redex}. The relation $\rewrite{R/E}$ on $\TermsOn{\Symbols}{\Variables}{}{}{}$ is ${\congr{E} ;\rewrite{R};\congr{E}}$, i.e., $t \rewrite{R/E} t'$ iff there exists $u,u'$ s.t. ${t \congr{E} u \rewrite{R} u' \congr{E} t'}$. Note that $\rewrite{R/E}$ on $\TermsOn{\Symbols}{\Variables}{}{}{}$ induces a relation $\rewrite{R/E}$ on the free $(\Sigma,E)$-algebra ${\TermsOn{\Sigma\!/\!{E}}{\caX}{}{}{}}$ by ${[t]_{E} \rewrite{R/E} [t']_{E}}$ iff $t \rewrite{R/E} t'$. The transitive (resp. transitive and reflexive) closure of $\rewrite{R/E}$ is denoted $\rewrite{R/E}^+$ (resp. $\rewrites{R/E}$). The $\rewrite{R/E}$ relation can be difficult to compute. However, under the appropriate conditions it is equivalent to the $R{,}E$ relation in which it is enough to compute the relationship on any representatives of two $E$-equivalence classes. A relation $\rewrite{R,E}$ on $\TermsOn{\Symbols}{\Variables}{}{}{}$ is defined as: $t \rewrite{p,R,E} t'$ (or just $t \rewrite{R,E} t'$) iff there exist $p \in \funocc{t}$, a rule $l \to r$ in $R$, and a substitution $\sigma$ such that $\subterm{t}{p} \congr{E} l\sigma$ and $t' = \replace{t}{p}{r\sigma}$. Let $t$ be a term and $W$ be a set of variables such that $\var{t} \subseteq W$, the $R,E$-\textit{narrowing} relation on $\TermsOn{\Symbols}{\Variables}{}{}{}$ is defined as $t \leadsto_{p,\sigma,R,E} t'$ ($\leadsto_{\sigma,R,E}$ if $p$ is understood, $\leadsto_{\sigma}$ if $R,E$ are also understood, and $\leadsto$ if $\sigma$ is also understood) if there is a non-variable position $p \in \funocc{t}$, a rule $l \to r \in R$ properly renamed s.t. $(\var{l}\cup\var{r})\cap W=\emptyset$, and a unifier $\sigma \in \csuV{\subterm{t}{p}=l}{W'}{E}$ for $W' = W\cup\var{l}$, such that $t'=(\replace{t}{p}{r})\sigma$. For convenience, in each narrowing step $t \leadsto_{\sigma} t'$ we only specify the part of $\sigma$ that binds variables of $t$. The transitive (resp. transitive and reflexive) closure of $\leadsto$ is denoted by $\leadsto^+$ (resp. $\leadsto^*$). We may write $t \narrowG{}{\sigma}{k} t'$ if there are $u_{1},\ldots,u_{k-1}$ and substitutions $\rho_{1},\ldots,\rho_{k}$ such that $t \narrow{}{\rho_{1}} \allowbreak u_{1} \allowbreak \cdots \allowbreak u_{k-1} \narrow{}{\rho_{k}} t'$, $k \geq 0$, and $\sigma = \rho_{1}\cdots\rho_{k}$. Maude-NPA uses \emph{backwards narrowing} (i.e., uses protocol rules $l \rightarrow r$ ``in reverse'' as rules $r \rightarrow l$) \emph{modulo} the algebraic properties of cryptographic functions as a \emph{sound and complete} reachability analysis method. Section \ref{sec:proof-CstrFW-CstrBW} gives a detailed proof of the soundness and completeness of this method for strands with choice. \section{Overview of Maude-NPA}\label{sec:mnpa-syntax} Here we give a high-level summary of Maude-NPA. For further details please see \cite{MNPAmanual3.0}. % Given a protocol $\mathcal{P}$, we define its specification in the strand space model as a rewrite theory of the form $(\Sigma_\mathit{{SS}_\mathcal{P}},E_\mathit{{SS}_\mathcal{P}}, R_\mathit{B\mathcal{_\caP}}^{-1})$, where (i) the signature $\Sigma_\mathit{{SS}_\mathcal{P}}$ is split into predefined symbols $\Sigma_\mathit{{SS}}$ for strand syntax and user-definable symbols $\Sigma_\caP$ based on a parametric sort \sort{Msg} of messages, (ii) the algebraic properties $E_\mathit{{SS}_\mathcal{P}}$ are also split into the algebraic properties of the strand notation $E_\mathit{SS}$ and the user-definable algebraic properties $E_{\caP}$ for the cryptographic functions, and (iii) the transition rules $R_\mathit{B\mathcal{_\caP}}^{-1}$ are defined on states, i.e., terms of a predefined sort \sort{State}. They are \emph{reversed} for backwards execution. In Maude-NPA states are modeled as elements of an initial algebra $\mathcal{T}_{\Sigma_\mathit{{SS}_\mathcal{P}}/E_\mathit{{SS}_\mathcal{P}}}$, i.e., an $E_\mathit{{SS}_\mathcal{P}}$-equivalence class $[t]_{E_\mathit{{SS}_\mathcal{P}}}\in {\cal T}_{\Sigma_\mathit{{SS}_\mathcal{P}}/ E_\mathit{{SS}_\mathcal{P}}}$ with $t$ a ground $\Sigma_\mathit{{SS}_\mathcal{P}}$-term. A state has the form $\{ S_1 \,\&\, \cdots \,\&\, S_n \,\&\, \{\textit{IK}\}\}$ where $\&$ is an associative-commutative union operator with identity symbol $\emptyset$. Each element in the set is either a \emph{strand} $S_i$ or the \emph{intruder knowledge} $\{\textit{IK}\}$ at that state. The \emph{intruder knowledge} $\{\textit{IK}\}$ belongs to the state and is represented as a set of facts using the comma as an associative-commutative union operator with identity element $empty$. There are two kinds of intruder facts: \emph{positive} knowledge facts (the intruder knows message $m$, i.e., $\inI{m}$), and \emph{negative} knowledge facts (the intruder \emph{does not yet know} $m$ but \emph{will know it in a future state}, i.e., $\nI{m}$), where $m$ is a message expression. A \emph{strand} \cite{strands} specifies the sequence of messages sent and received by a principal executing a given role in the protocol and is represented as a sequence of messages $ [\textit{msg}_1^\pm, \textit{msg}_2^\pm, \textit{msg}_3^\pm, \ldots,\allowbreak \textit{msg}_{k-1}^\pm, \textit{msg}_k^\pm] $ with $\textit{msg}_{i}^\pm$ either $\textit{msg}_i^-$ (also written $-\textit{msg}_i$) representing an input message, or $\textit{msg}_i^+$ (also written $+\textit{msg}_i$) representing an output message. Note that each $\textit{msg}_{i}$ is a term of a special sort \textsf{Msg}. Strands are used to represent both the actions of honest principals (with a strand specified for each protocol role) and the actions of an intruder (with a strand for each action an intruder is able to perform on messages). In Maude-NPA strands evolve over time; the symbol $|$ is used to divide past and future. That is, given a strand $[\ \textit{msg}_1^{\pm},\ \ldots,\ \textit{msg}_i^{\pm}\ |\allowbreak\ \textit{msg}_{i+1}^{\pm},\ \ldots,\ \textit{msg}_k^{\pm}\ ]$, messages $\textit{msg}_1^\pm,\linebreak[2] \ldots, \textit{msg}_{i}^\pm$ are the \emph{past messages}, and messages $\textit{msg}_{i+1}^\pm, \ldots,\textit{msg}_k^\pm$ are the \emph{future messages} ($\textit{msg}_{i+1}^\pm$ is the immediate future message). A strand $[\textit{msg}_1^\pm, \linebreak[2]\ldots, \linebreak[2] \textit{msg}_k^\pm]$ is shorthand for $[nil ~|~ \textit{msg}_1^\pm,\linebreak[2] \ldots,\linebreak[2] \textit{msg}_k^\pm , nil ]$. An \emph{initial state} is a state where the bar is at the beginning for all strands in the state, and the intruder knowledge has no fact of the form $\inI{\textit{m}}$. A \emph{final state} is a state where the bar is at the end for all strands in the state and there is no intruder fact of the form $\nI{\textit{m}}$. Since the number of states $T_{\Sigma_\mathit{{SS}_\mathcal{P}}/ E_\mathit{{SS}_\mathcal{P}}}$ is in general infinite, rather than exploring concrete protocol states $[t]_{E_\mathit{{SS}_\mathcal{P}}}\in T_{\Sigma_\mathit{{SS}_\mathcal{P}}/E_\mathit{{SS}_\mathcal{P}}}$ Maude-NPA explores \emph{symbolic strand state patterns} $[t(x_{1},\ldots,x_{n})]_{E_\mathit{{SS}_\mathcal{P}}} \in T_{\Sigma_\mathit{{SS}_\mathcal{P}}/ E_\mathit{{SS}_\mathcal{P}}}(\caX)$ on the free $(\Sigma_\mathit{{SS}_\mathcal{P}}, \allowbreak E_\mathit{{SS}_\mathcal{P}})$-algebra over a set of variables $\caX$. In this way, a state pattern $[t(x_{1},\ldots,x_{n})]_{E_\mathit{{SS}_\mathcal{P}}}$ represents not a single concrete state but a possibly infinite set of such states, namely all the \emph{instances} of the pattern $[t(x_{1},\ldots,x_{n})]_{E_\mathit{{SS}_\mathcal{P}}}$ where the variables $x_{1},\ldots,x_{n}$ have been instantiated by concrete ground terms. The semantics of Maude-NPA is expressed in terms of the following \emph{forward rewrite rules} that describe how a protocol moves from one state to another via the intruder's interaction with it. \begin{small} \begin{align} & \{ SS\ \&\ [L ~|~ M^-, L']\ \&\ \{\inI{M},IK\}\} \to \{ \textit{SS}\ \&\ [L, M^- ~|~ L']\ \&\ \{\inI{M},IK\} \} \eqname{-} \label{eq:negative-1} \\[1ex] & \{ SS\ \&\ [L ~|~ M^+, L']\ \&\ \{IK\} \} \to \{ SS \ \&\ [L, M^+ ~|~ L']\ \&\ \{IK\} \} \eqname{+} \label{eq:positiveNoLearn-2} \end{align} \begin{align} & \{ SS\ \&\ [L ~|~ M^+, L']\ \&\ \{\nI{M},IK\} \} \to \{ SS \ \&\ [L, M^+ ~|~ L']\ \&\ \{\inI{M}, IK\} \} \eqname{++} \label{eq:positiveLearn-4}\\[1ex] & { \begin{array}[t]{@{}l@{}} \forall \ [ l_1, u^+, l_2] \in {\cal P}: \{SS \, \& \, [\, l_1 | \, u^+, l_2\,] \,\&\, \{\nI{u},IK\}\} \to \{SS \, \& \, \{\inI{u},IK\}\} \end{array} \label{eq:newstrand-positive}% }\eqname{\&} \end{align}% \end{small} \noindent where $L$ and $L'$ are variables denoting a list of strand messages, $\textit{IK}$ is a variable for a set of intruder facts (\inI{m} or \nI{m}), $\textit{SS}$ is a variable denoting a set of strands, and $l_1$, $l_2$ denote a list of strand messages. The set $R_\mathit{B\mathcal{_\caP}}^{-1}$ of \emph{backwards} state transition rules is defined by reversing the direction of the above set of rules $\{ \eqref{eq:negative-1}, \eqref{eq:positiveNoLearn-2}, \eqref{eq:positiveLearn-4}\} \cup \eqref{eq:newstrand-positive} $. In the backwards executions of $\eqref{eq:newstrand-positive},\eqref{eq:positiveLearn-4}$, $\nI{u}$ marks when the intruder learnt $u$. One uses Maude-NPA to find an attack by specifying an insecure state pattern called an \emph{attack pattern}. Maude-NPA attempts to find a path from an initial state to the attack pattern via backwards narrowing (narrowing using the rewrite rules with the orientation reversed). That is, a narrowing sequence from an initial state to an attack state is searched \emph{in reverse} as a \emph{backwards path} from the attack state to the initial state. Maude-NPA attempts to find paths until it can no longer form any backwards narrowing steps, at which point it terminates. If at that point it has not found an initial state, the attack pattern is shown to be \emph{unreachable} modulo $E_\mathit{{SS}_\mathcal{P}}$. (Section \ref{sec:proof-CstrFW-CstrBW} gives a detailed proof of the soundness and completeness of this symbolic method for the Maude-NPA extension supporting strands with choice). Note that Maude-NPA places \emph{no bound on the number of sessions}, so reachability is undecidable in general. Note also that Maude-NPA does not perform any data abstraction such as a bounded number of nonces. However, the tool makes use of a number of sound and complete state space reduction techniques that help to identify unreachable and redundant states, and thus make termination more likely. \section{A Process Algebra for Protocols with Choice}\label{sec:PA} In this section we define a process algebra that extends the strand space model to naturally specify protocols exhibiting choice points. Throughout the paper we refer to this process algebra as the \emph{protocol process algebra}. The rest of this section is organized as follows. First, in Section~\ref{sec:syntaxPA} we define the syntax of the protocol process algebra and state the requirements that a \emph{well-formed process} must satisfy. Then in Section~\ref{sec:PASpecification}, we explain how \emph{protocol specifications} can be defined in this process algebra. In Section~\ref{sec:semanticsPA} we then define the \emph{operational semantics} of the protocol process algebra. Note that the operational semantics of Maude-NPA given in Section~\ref{sec:mnpa-syntax} corresponds to a symbolic backwards semantics while in Section~\ref{sec:semanticsPA} we give a rewriting-based forwards semantics for process algebra. Sections \ref{sec:PA-CstrFW-bisim} and \ref{sec:proof-CstrFW-CstrBW} will relate these two semantics using \emph{bisimulations}. \subsection{Syntax of the Protocol Process Algebra }\label{sec:syntaxPA} In the \emph{protocol process algebra} the behaviors of both honest principals and the intruder are represented by \emph{labeled processes}. Therefore, a protocol is specified as a set of labeled processes. Each process performs a sequence of actions, namely, sending or receiving a message, and may perform deterministic or non-deterministic choices. The protocol process algebra's syntax is parameterized\footnote{More precisely, as explained in Section \ref{sec:PASpecification}, they are parameterized by a user-definable equational theory $(\Sigma_{\mathcal{P}},E_{\mathcal{P}})$ having a sort \sort{Msg} of messages.} by a sort \sort{Msg} of messages and has the following syntax: \begin{align} \ProcConf~ &::= \LProc ~|~ \ProcConf ~\&~ \ProcConf ~|~ \emptyset \notag\\[-.8ex] \LProc ~&::= (\Role, I, J)~ \Proc \notag\\[-.8ex] \Proc~ &::= \mathit{nilP} ~ |~ +\Msg~ | ~ -\Msg ~|~ \Proc \cdot \Proc ~| \notag \\[-.8ex] &~~~~~~~ \Proc~?~\Proc ~ | ~\textit{if} ~\Cond~ \textit{then} ~\Proc~ \textit{else} ~\Proc \notag\\[-.8ex] \Cond~ &::= \Msg~ \neq~ \Msg ~| ~\Msg =~ \Msg \notag \end{align} \begin{itemize} \item $\ProcConf$ stands for a \emph{process configuration}, that is, a set of labeled processes. The symbol \& is used to denote set union for sets of labeled processes. \item $\LProc$ stands for a \emph{labeled process}, that is, a process $\Proc$ with a label $(\Role,I,J)$. $\Role$ refers to the role of the process in the protocol (e.g., initiator or responder). $I$ is a natural number denoting the identity of the process, which distinguishes different instances(sessions) of a process specification. $J$ indicates that the action at stage $J$ of the process specification will be the next one to be executed, that is, the first $J-1$ actions of the process for role $\Role$ have already been executed. Note that we omit $I$ and $J$ in the protocol specification when both $I$ and $J$ are $0$. \item $\Proc$ defines the actions that can be executed within a process. ${+\Msg}$, and ${-\Msg}$ respectively denote sending out or receiving a message $\Msg$. We assume a single channel, through which all messages are sent or received by the intruder. ``$\Proc~\cdot~\Proc$" denotes \emph{sequential composition} of processes, where symbol \verb!_._! is associative and has the empty process $\mathit{nilP}$ as identity. ``$\Proc~?~\Proc$" denotes an explicit \emph{nondeterministic choice}, whereas ``$\textit{if} ~\Cond~ \textit{then} \allowbreak ~\Proc~ \textit{else} ~\Proc$" denotes an explicit \emph{deterministic choice}, whose continuation depends on the satisfaction of the constraint $\Cond$. \item $\Cond$ denotes a constraint that will be evaluated in explicit deterministic choices. In this work we only consider constraints that are either equalities ($=$) or disequalities ($\neq$) between message expressions. \end{itemize} \vspace{-1ex} Let $PS,~QS$, and $RS$ be process configurations, and $P,~Q$, and $R$ be protocol processes. Our protocol syntax satisfies the following \emph{structural axioms}: \begin{small} \begin{minipage}{0.65\linewidth} \begin{gather} PS \, \& \, QS = QS \, \& \, PS \\ (PS \, \& \, QS) \, \& \, RS = PS \, \& \, ( QS \, \& \, RS)\\ (P \, \cdot \, Q) \cdot \, R = P \, \cdot \, (Q \, \cdot \, R) \end{gather} \end{minipage} \begin{minipage}{0.30\linewidth} \begin{gather} PS \& \emptyset = PS \\ P \, \cdot \, \mathit{nilP} = P \\ \mathit{nilP} \, \cdot \, P = P \end{gather} \end{minipage} \end{small} The specification of the processes defining a protocol's behavior may contain some variables denoting information that the principal executing the process does not yet know, or that will be different in different executions. In all protocol specifications we assume three disjoint kinds of variables: \begin{itemize} \item \textbf{\emph{fresh variables}}: these are not really variables in the standard sense, but \emph{names} for \emph{constant values} in a data type \sort{V_{fresh}} of unguessable values such as nonces. A \emph{fresh variable} $r$ is always associated with a role $ro\in Role$ in the protocol. For each protocol session $i$, we associate to $r$ a unique name $r.ro.i$ for a constant in the data type \sort{V_{fresh}}. What is assumed is that if $r.ro.i \neq r'.ro'.j$ (including the case $r.ro.i \neq r.ro.j$), the values interpreting $r.ro.i$ and $r'.ro'.j$ in \sort{V_{fresh}} are both \emph{different} and \emph{unguessable}. In particular, for role $ro\in Role$, the interpretation mapping $I: \{r.ro.i \mid i\in \mathbb{N}\} \rightarrow \sort{V_{fresh}}$ is \emph{injective} and \emph{random}. In our semantics, a constant $r.ro.i$ denotes its (unguessable) interpretation $I(r.ro.i) \in \sort{V_{fresh}}$. Throughout this paper we will denote this kind of variables as $r,r_1,r_2,\ldots$. \item \textbf{\emph{choice variables}}: variables first appearing in a \emph{sent message} $\mathit{+M}$, which can be substituted by any value arbitrarily chosen from a possibly infinite domain. A choice variable indicates an \emph{implicit non-deterministic choice}. Given a protocol with choice variables, each possible substitution of these variables denotes a possible continuation of the protocol. We always denote choice variables by uppercase letters postfixed with the symbol ``?'' as a subscript, e.g., $\chV{A},\chV{B},\ldots$. \item \textbf{\emph{pattern variables}}: variables first appearing in a \emph{received message} $\mathit{-M}$. These variables will be instantiated when matching sent and received messages. \emph{Implicit deterministic choices} are indicated by terms containing pattern variables, since failing to match a pattern term may lead to the rejection of a message. A pattern term plays the implicit role of a guard, so that, depending on the different ways of matching it, the protocol can have different continuations. This kind of variables will be written with uppercase letters, e.g., $A,B,N_A,\ldots$. \end{itemize} Note that fresh variables are distinguished from other variables by having a specific sort \sort{Fresh}. Choice variables or pattern variables can never have sort \sort{Fresh}. To guarantee the requirements on different kinds of variables that can appear in a given process, we consider only \emph{well-formed} processes. We make this notion precise by defining a function $\mathit{wf}: \mathit{\Proc} \rightarrow \mathit{Bool}$ checking whether a given process is well-formed. A labeled process is \emph{well-formed} if the process it labels is well-formed. A process configuration is \emph{well-formed} if all the labeled process in it are well-formed. The definition of $\mathit{wf}$ uses an auxiliary function $\mathit{shVar} : \mathit{\Proc} \rightarrow \mathit{VarSet}$, retrieving the ``shared variables'' of a process, i.e., the set of variables that show up in all branches. Below we define both functions, where $P,~Q,$ and $R$ are processes, $M$ is a message, and $T$ is a constraint. \vspace{-1.5ex} \begin{small} \begin{align*} & \bvar{+M ~\cdot P} = \var{M} \cup \bvar{P} \\[-.5ex] & \bvar{-M ~\cdot P} = \var{M} \cup \bvar{P} \\[-.5ex] & \bvar{ (\textit{if} ~T~ \textit{then} ~P~ \textit{else} ~Q) ~\cdot R} = \var{T} \cup (\bvar{P} \cap \bvar{Q}) \cup \bvar{R} \\[-.5ex] & \bvar{ (P~?~Q)~\cdot R } = ( \bvar{P} \cap \bvar{Q}) \cup \bvar{R} \\[-.5ex] & \bvar{\mathit{nilP}} = \emptyset \end{align*} \vspace{-4ex} \begin{align*} & \mathit{wf}(P \cdot +M) = \mathit{wf}(P) ~~~~~~~~ \textit{if} ~~ (\var{M} \cap \var{P}) \subseteq \bvar{P} \\[-.5ex] & \mathit{wf}( P \cdot -M) = \mathit{wf}(P) ~~~~~~~~ \textit{if} ~~ (\var{M} \cap \var{P}) \subseteq \bvar{P} \\[-.5ex] & \mathit{wf}( P \cdot (\textit{if} ~~T~ \textit{then} ~Q~ \textit{else} ~R)) = \mathit{wf}(P \cdot Q) \wedge \mathit{wf}(P \cdot R) ~~~~ \textit{if} \ P \neq \mathit{nilP} \ \textit{and } \ Q \neq \mathit{nilP} \ \textit{and } \\[-.5ex] & \hspace*{80mm} ~\var{T} \subseteq \bvar{P}\\[-.5ex] &\mathit{wf}(P \cdot (Q~?~R) )= \mathit{wf}(P \cdot Q) \wedge \mathit{wf}(P \cdot R) ~~~~ ~~~~ \textit{ if } Q \neq \mathit{nilP} \ \textit{or} R \neq \mathit{nilP} \\[-.5ex] &\mathit{wf}(P \cdot ~\mathit{nilP}) = \mathit{wf}(P) \\[-.5ex] &\mathit{wf}(\mathit{nilP}) = True. \end{align*} \end{small} \vspace{-4ex} \begin{remark} Note that the well-formedness property implies that if a process begins with a deterministic choice action \textit{if T then Q else R}, then all variables in $T$ must be instantiated, and thus only one branch may be taken. For this reason, it is undesirable to specify processes that begin with such an action. Furthermore, note that the well-formedness property avoids explicit choices where both possibilities are the $\mathit{nilP}$ process. That is, processes containing either \textit{(if T then nil else nil)}, or \textit{(nil ? nil)}, respectively. \end{remark} We illustrate the notion of well-formed process below. \begin{example}\label{ex:Det-tlslike} The behavior of a Client initiating an instance of the handshake protocol from Example~\ref{ex:tlsinf} with the Server, where the Server may or may not request the Client to authenticate itself, may be specified by the well-formed process shown below: \vspace{-3ex} \begin{small} \begin{align*} (\mathit{Client}) \ & +(hs ; n(\chV{C},r_1) ; \chV{G} ; gen(\chV{G}) ; keyG(\chV{G},\chV{C},r_2))\ \cdot \\[-.5ex] & -(hs ; N ; \chV{G} ; gen(\chV{G}) ; E ; Z(\mathit{AReq},\chV{G},E,\chV{C},r_1,S,HM))\ \cdot \\[-.5ex] & \mathit{if} ~( \mathit{AReq} = \mathit{authreq} ) \\[-.5ex] & \mathit{then} \\[-.8ex] & +(e(keyE (\chV{G},E,\chV{C},r_1), \\[-.5ex] & ~~~~~~~~ sig(C, W(HM,\mathit{AReq},\chV{S},G_?,E,\chV{C},r_1)) ; \\[-.5ex] & ~~~~~~~~ mac(keyE(\chV{G},E,,\chV{C},r_1), W(HM, \mathit{AReq},S,\chV{G},E,\chV{C},r_1))))\ \cdot \\[-.5ex] & \mathit{else} \\[-.5ex] & +(e(keyE( \chV{G},E,\chV{C},r_2), \\[-.5ex] & ~~~~~~~~ mac(keyE(\chV{G},E,\chV{C},r_2), W(HM, \mathit{AReq},S,\chV{G},E,\chV{C},r_1)))) \end{align*} \end{small} \vspace{-3ex} \noindent where $\mathit{KeyG}$, $Z$ and $W$ are macros used to construct messages sent in the protocol. The variables $\chV{C}$ and $\chV{G}$ are choice variables denoting the client and Diffie-Hellman group respectively, and the variables $r_1$ and $r_2$ are fresh variables. All other variables are pattern variables. In particular, the variable $\mathit{AReq}$ is a pattern variable that can be instantiated to either $\mathit{authreq}$ or $\mathit{noauthreq}$. The Client makes a deterministic choice whether or not to sign its next message with its digital signature, depending on which value of $\mathit{AReq}$ it receives. \end{example} \begin{example}\label{ex:non-tlslike} The behavior of a Server who may or may not request a retry from a Client in an instance of the handshake protocol from Example~\ref{ex:tlsinf} may be specified as follows: \vspace{-3ex} \begin{small} \begin{align*} (\mathit{Server}): \ & -(hs ; N ; G ; gen(G) ; E) \cdot \\[-.5ex] & (((+(hs ; retry) \cdot \\[-.5ex] & ~~~ -(hs ; N' ; G' ; gen(G') ; E') \cdot \\[-.5ex] & ~~~ +(hs ; n(\chV{S},r1) ; G' ; gen(G') ; keyG(G',\chV{S},r_2) ; Z(\chV{AReq},G',E',S,r_2,\chV{S},HM))) \\[-.5ex] & ? \\[-.5ex] & ( + (hs ; n(\chV{S},r1) ; G ; gen(G) ; keyG(G,S,r_2) ; Z(\chV{AReq},G,E,S,r_2,\chV{S},HM))))) \end{align*} \end{small} \end{example} In this case the server nondeterministically chooses to request or not to request a retry. In the case of a retry it waits for the retry message from the client, and then proceeds with the handshake message using the new key information from the client. In the case when it does not request a retry, it sends the handshake message immediately after receiving the client's Hello message. The variable $r_2$ is a fresh variable, while $\chV{S}$ and $\chV{AReq}$ are choice variables. $\chV{S}$ denotes the name of the server, and $\chV{AReq}$ is nondeterministically instantiated to $\mathit{authreq}$ or $\mathit{noauthreq}$. \begin{example}\label{ex:ill-formed} The following process does not satisfy the well-formedness property. \vspace{-3ex} \begin{small} \begin{align*} \mathit{(Resp)} &-(pk(B, A ; NA)) \cdot \\ & \ (+(pk(A, 1 ; n(B,r))) \ ? \ +(pk(A, 2))) \ \cdot \\ & +(pk(\chV{C}, n(B,r) )) \end{align*} \end{small} \vspace{-3ex} \noindent The problem with this process is the fresh variable $r$ appearing in message \allowbreak $+(pk(\chV{C}, n(B,r) ))$, since \begin{small} $$r \notin \bvar{ -(pk(B, A ; NA)) \cdot (+(pk(A, 1 ; n(B,r))) \ ? \ +(pk(A, 2)))}$$ \end{small} \noindent more specifically, because it does not appear in message $+(pk(A, 2))$, but $r \in \var{-(pk(B, A ; NA)) \cdot (+(pk(A, 1 ; n(B,r))) \ ? \ +(pk(A, 2)))}.$ \end{example} \subsection{Protocol Specification in Process Algebra} \label{sec:PASpecification} Given a protocol ${\cal P}$, we define its specification in the protocol process algebra, written $\caP_\mathit{PA}$, as a pair of the form $\caP_\mathit{PA} = ((\Sigma_\mathit{{PA}_\caP},E_\mathit{PA_\caP}), P_\mathit{PA})$, where $(\Sigma_\mathit{{PA}_\caP},E_\mathit{PA_\caP})$ is an equational theory explained below, and $P_\mathit{PA}$ is a term denoting a \emph{well-formed} process configuration representing the behavior of the honest principals as well as the capabilities of the attacker. That is, $P_\mathit{PA} = (\mathit{ro_1}) P_1 ~\&~ \ldots ~\&~ (\mathit{ro_i}) P_i $, where each $ro_k$, $1 \leq k \leq i$, is either the role of an honest principal or identifies one of the capabilities of the attacker. $P_\mathit{PA}$ cannot contain two processes with the same label, i.e., the behavior of each honest principal, and each attacker capability are represented by a \emph{unique} process. $E_\mathit{PA_\caP} =E_{\caP} \cup E_{\mathit{\caP+PA}}$ is a set of equations with $E_{\caP}$ denoting the protocol's cryptographic properties and $E_{\mathit{\caP+PA}}$ denoting the properties of process constructors. The set of equations $E_{\caP}$ is user-definable and can vary for different protocols. Instead, the set of equations $E_{\mathit{\caP+PA}}$ is always the same for all protocols. $\Sigma_\mathit{{PA}_\caP}=\Sigma_\caP \cup \Sigma_\mathit{PA}$ is the signature defining the sorts and function symbols as follows: \begin{itemize} \item $\Sigma_\caP$ is an order-sorted signature defining the sorts and function symbols for the messages that can be exchanged in protocol ${\cal P}$. However, independently of protocol ${\cal P}$, $\Sigma_\caP$ must always have a sort \sort{Msg} as the top sort in one of its connected components. We call a sort $\sort{S}$ a \emph{data sort} iff it is either a subsort of $\sort{Msg}$, or there is a message constructor $c : \sort{S_1}...\sort{S}...\sort{S_n} \rightarrow \sort{S'}$, with $\sort{S'}$ a subsort of $\sort{Msg}$. The specific sort \sort{Fresh} for fresh variables is an example of \emph{data sort}. Choice and pattern variables have sort \sort{Msg} or any of its subsorts. \item $\Sigma_\mathit{PA}$ is an order-sorted signature defining the sorts and function symbols of the \emph{process algebra infrastructure}. $\Sigma_\mathit{PA}$ corresponds exactly to the BNF definition of the protocol process algebra's syntax in Section \ref{sec:syntaxPA}. Although it has a sort \sort{Msg} for messages, it leaves this sort totally unspecified, so that different protocols ${\cal P}$ may use completely different message constructors and may satisfy different equational properties $E_{\caP}$. Therefore, $\Sigma_\mathit{PA}$ will be the same signature for any protocol specified in the process algebra. More specifically, $\Sigma_\mathit{PA}$ contains the sorts for process configurations (\sort{ProcConf}), labeled processes (\sort{LProc}), processes (\sort{Proc}), constraints (\sort{Cond}), and messages(\sort{Msg}), as well as the subsort relations $\sort{LProc} \, < \, \sort{ProcConf}$. Furthermore, the function symbols in $\Sigma_\mathit{PA}$ are also defined according to the BNF definition. \end{itemize} Therefore, the syntax $\Sigma_\mathit{{PA}_\caP}$ of processes for ${\cal P}$ will be in the union signature $\Sigma_\mathit{PA} \cup \Sigma_\caP$, consisting of the protocol-specific syntax $\Sigma_\caP$, and the generic process syntax $\Sigma_\mathit{PA}$ through the shared sort \sort{Msg}. \subsection{Operational Semantics of the Protocol Process Algebra}\label{sec:semanticsPA} Given a protocol $\mathcal{P}$, a \emph{state} of ${\cal P}$ consists of a set of (possibly partially executed) \emph{labeled processes}, and a set of terms in the intruder's knowledge $\{IK\}$. That is, a state is a term of the form $\{ LP_1 \,\&\, \cdots \,\&\, LP_n ~|~ \{\textit{IK}\}\}$. Given a state $St$ of this form, we abuse notation and write $LP_k \in St$ if $LP_k$ is a labeled process in the set $LP_1 \,\&\, \cdots \,\&\, LP_n$. The intruder knowledge $IK$ models the \emph{single} channel through which all messages are sent and received. We consider an active attacker who has complete control of the channel, i.e, can read, alter, redirect, and delete traffic as well as create its own messages by means of \emph{intruder processes}. That is, the purpose of some $LP_k \in St$ is to perform message-manipulation actions for the intruder. State changes are defined by a set $R_{\mathit{PA_\caP}}$ of \emph{rewrite rules}, such that the rewrite theory $(\Sigma_\mathit{{PA_\caP+State}}, E_\mathit{PA_\caP} , R_{\mathit{PA_\caP}})$ characterizes the behavior of protocol ${\cal P}$, where $\Sigma_\mathit{{PA_\caP+State}}$ extends $\Sigma_\mathit{{PA}_\caP}$ by adding state constructor symbols. We assume that a protocol's execution begins with an empty state, i.e., a state with an empty set of labeled processes, and an empty intruder knowledge. That is, the initial state is always of the form $ \{ \emptyset ~|~ \{empty\} \}$. Each transition rule in $R_{\mathit{PA_\caP}}$ is labeled with a tuple of the form $\mathit{(ro,i, j, a,n)}$, where: \begin{itemize} \item $\mathit{ro}$ is the role of the labeled process being executed in the transition. \item $i$ denotes the identifier of the labeled process being executed in the transition. Since there can be more than one process instance of the same role in a process state, $i$ is used to distinguish different instances, i.e., $ro$ and $i$ together uniquely identify a process in a state. \item $j$ denotes the process' step number since its beginning. \item $a$ is a ground term identifying the action that is being performed in the transition. It has different possible values: ``$+m$'' or ``$-m$'' if the message $m$ was sent (and added to the intruder's knowledge) or received, respectively; ``$m$'' if the message $m$ was sent but did not increase the intruder's knowledge, ``$?$'' if the transition performs an explicit non-deterministic choice, or ``$\mathit{T}$'' if the transition performs a explicit deterministic choice. \item $n$ is a number that, if the action that is being executed is an explicit choice, indicates which branch has been chosen as the process continuation. In this case $n$ takes the value of either $1$ or $2$. If the transition does not perform any explicit choice, then $n=0$. \end{itemize} Below we describe the set of transition rules that define a protocol's execution in the protocol process algebra, that is, the set of rules $R_{\mathit{PA_\caP}}$. Note that in the transition rules shown below, $PS$ denotes the rest of labeled processes of the state (which can be the empty set $\emptyset$). \begin{itemize} \item The action of \emph{sending a message} is represented by the two transition rules below. Since we assume the intruder has complete control of the network, it can learn any message sent by other principals. Rule~\eqref{eq:pa-output-modIK} denotes the case in which the sent message is added to the intruder's knowledge. Note that this rule can only be applied if the intruder has not already learnt that message. Rule~\eqref{eq:pa-output-noModIK} denotes the case in which the intruder chooses not to learn the message, i.e., the intruder's knowledge is not modified, and, thus, no condition needs to be checked. Since choice variables denote messages that are nondeterministically chosen, all (possibly infinitely many) admissible ground substitutions for the choice variables are possible behaviors. \begin{small} \begin{align} &\{ (ro,i, j)~( +M \cdot P) ~\&~ PS ~|~ \{IK\} \} \notag\\[-.5ex] & \longrightarrow_{(ro,i,j,+M\sigma,0)} \{ (ro,i, j+1)~P \sigma ~\&~ PS ~|~ \{ \inI{M\sigma}, IK\} \} \notag\\[-.5ex] & \textit{ if } ( \inI{M\sigma}) \notin \textit{IK} \notag\\[-.5ex] & \textit{where } \sigma \ \textit{is a ground substitution} \textit{ binding choice variables} \textit{ in} \ M \eqname{{\small PA++}} \label{eq:pa-output-modIK} \end{align} \begin{align} &\{ (ro,i, j)~( +M \cdot P) ~\&~ PS ~|~ \{IK\} \} \notag\\[-.5ex] & \longrightarrow_{(ro, i, j, M\sigma,0)} \{ (ro,i, j+1)~P\sigma ~\&~ PS ~|~ \{IK\} \} \notag\\[-.5ex] & \textit{where } \sigma \ \textit{is a ground substitution} \ \textit{binding choice variables} \textit{ in} \ M \eqname{PA+} \label{eq:pa-output-noModIK} \end{align} \end{small} \item As shown in the rule below, a process can \emph{receive a message} matching a pattern $M$ if there is a message $M'$ in the intruder's knowledge, i.e., a message previously sent either by some honest principal or by some intruder process, that matches the pattern message $M$. After receiving this message the process will continue with its variables instantiated by the matching substitution, which takes place modulo the equations $E_{\cal P}$. Note that the intruder can ``delete" a message via choosing not to learn it (executing Rule \ref{eq:pa-output-noModIK} instead of Rule \ref{eq:pa-output-modIK}) or not to deliver it (failing to execute Rule \ref{eq:pa-input}). \begin{small} \begin{align} &\{ (ro,i, j)~( -M\cdot P) ~\&~ PS \mid \{\inI{M'}, IK\} \}\notag\\[-.5ex] & \longrightarrow_{(ro,i,j,-M\sigma,0)} \{ (ro,i, j+1)~P\sigma ~\&~ PS \mid \{ \inI{M'}, IK\} \} \notag\\[-.5ex] &~\textit{if}~ M'=_{E_{\caP}} M\sigma \eqname{PA-} \label{eq:pa-input} \end{align} \end{small} \item The two transition rules shown below define the operational semantics of \emph{explicit deterministic choice}s. That is, the operational semantics of an $\textit{if} ~T~ \textit{then} ~P~ \allowbreak \textit{else} ~Q$ expression. More specifically, rule~\eqref{eq:pa-detBranch1} describes the \textit{then} case, i.e., if the constraint $T$ is satisfied, the process will continue as $P$. Rule~\eqref{eq:pa-detBranch2} describes the \textit{else} case, that is, if the constraint $T$ is \emph{not} satisfied, the process will continue as $Q$. Note that, since we only consider well-formed processes, these transition rules will only be applied if $j \ge 1$. Note also that since $T$ has been fully substituted by the time the if-then-else is executed, and the constraints that we considered in this paper are of the form $ m \neq_{E_{\caP}} m' $ or $m=_{E_{\caP}} m'$, the satisfiability of $T$ can be checked by checking whether the corresponding ground equality or disequality holds. \begin{small} \begin{align} & \{ (ro,i, j)~((\textit{if} ~T~ \textit{then} ~P~ \textit{else} ~Q) ~\cdot R) ~\&~ PS \mid \{IK\}\}\notag\\[-.5ex] & \longrightarrow_{(ro,i, j, T,1)} \{ (ro,i, j+1)~(P\cdot R) ~\&~ PS \mid \{IK\} \} ~~if~T \eqname{PAif1} \label{eq:pa-detBranch1} \end{align} \begin{align} & \{ (ro,i, j)~( (\textit{if} ~T~ \textit{then} ~P~ \textit{else} ~Q) ~\cdot R) ~\&~ PS \mid \{IK\} \} \notag\\[-.5ex] & \longrightarrow_{(ro,i,j,T,2)} \{ (ro,i, j+1)~(Q\cdot R) ~\&~ PS \mid \{IK\} \} ~~if~ \neg T \eqname{PAif2} \label{eq:pa-detBranch2} \end{align} \end{small} \item The two transition rules below define the semantics of \emph{explicit non-deterministic choice} $P~?~Q$. In this case, the process can continue either as $P$, denoted by rule~\eqref{eq:pa-nonDetBranch1}, or as $Q$, denoted by rule~\eqref{eq:pa-nonDetBranch2}. Note that this decision is made non-deterministically. \begin{small} \begin{align} & \{ (ro,i, j)~((P~?~Q)\cdot R) ~\&~ PS \mid \{IK\} \}\notag\\[-.5ex] &\longrightarrow_{(ro,i,j,?,1)} \{ (ro,i, j+1)~(P \cdot R) ~\&~ PS \mid \{IK\} \} \eqname{PA?1} \label{eq:pa-nonDetBranch1}\\[.5ex] & \{ (ro,i, j)~((P~?~Q)\cdot R) ~\&~ PS \mid \{IK\} \}\notag\\[-.5ex] &\longrightarrow_{(ro,i,j,?,2)} \{ (ro,i,j+1)(Q \cdot R) ~\&~ PS \mid \{IK\} \} \eqname{PA?2} \label{eq:pa-nonDetBranch2} \end{align} \end{small} \item The transition rules shown below describe the \emph{introduction of a new process} from the specification into the state, which allows us to support an unbounded session model. Recall that fresh variables are associated with a role and an identifier. Therefore, whenever a new process is introduced: (a) the largest process identifier $(i)$ will be increased by 1, and (b) new names will be assigned to the fresh variables in the new process. The function $\textit{MaxProcId}(PS, ro)$ in the transition rule below is used to get the largest process identifier $(i)$ of role $ro$ in the process configuration $PS$. The substitution $\rho_{ro, i+1}$ in the transition rule below takes a labeled process and assigns new names to the fresh variables according to the label. More specifically, $(ro,{i+1},1)~ P_k(r_1, \ldots, r_n)\rho_{ro, i+1} = (ro,i+1,1)~ P_k(r_1, \ldots, r_n) \{r_1 \mapsto r_1.ro.i+1, \ldots, r_n \mapsto r_n.ro.i+1 \}$. In a process state, a role name together with an identifier uniquely identifies a process. Therefore, there is a unique subset of fresh names for each process in the state. In the rest of this paper we will refer to this kind of substitutions as \emph{fresh substitutions}. \vspace{-1.5ex} \begin{small} \begin{align} \left \{ \begin{array}{@{}l@{}} \forall \ (ro)~ P_k \in P_\mathit{PA}\notag\\[.5ex] \{ PS \mid \{IK\} \} \notag\ \\[-.5ex] \longrightarrow_{(ro, i+1, 1,A,Num)} \{ (ro, i+1, 2)~P'_k ~\&~ PS \mid \{IK'\} \}\notag\\ [1ex] \textsf{IF} ~ \{(ro,i+1,1)~ P_k\rho_{ro,i+1} \mid \{IK\} \} \notag\\[-.5ex] \longrightarrow_{(ro,i+1, 1,A,Num)} \{ (ro,i+1, 2)~P'_k ~ \mid \{IK'\} \} \\[1ex] \textit{where } \rho_\mathit{ro,i+1} \ \textit{is a fresh substitution}, \notag\\ \ i= \textit{MaxProcId}(PS, ro) \end{array} \right \}\eqname{PA\&} \label{eq:pa-new} \end{align} \end{small} \vspace{-1.5ex} \noindent Note that $A$ denotes the action of the state transition, and can be of any of the forms explained above. The function $\textit{MaxProcId}$ is defined as follows: \vspace{-1.5ex} \begin{small} \begin{align*} & \textit{MaxProcId}(\emptyset, ro) = 0 \notag \\ & \textit{MaxProcId}((ro, i, j) P \& PS, ro) = max(\textit{MaxProcId}(PS, ro), i) \notag \\ & \textit{MaxProcId}((ro', i, j) P \& PS, ro) = \textit{MaxProcId}(PS, ro) \hspace*{10mm} \textit{if} \ ro \neq ro' \notag \end{align*} \end{small} \vspace{-1.5ex} \noindent where $PS$ denotes a process configuration, $P$ denotes a process, and $ro, ro'$ denote role names. \end{itemize} Therefore, the behavior of a protocol in the process algebra is defined by the set of transition rules $R_{\mathit{PA_\caP}} = \{ \eqref{eq:pa-output-modIK} , \ \eqref{eq:pa-output-noModIK} , \eqref{eq:pa-input} , \eqref{eq:pa-detBranch1} , \eqref{eq:pa-detBranch2} , \ \eqref{eq:pa-nonDetBranch1} , \ \allowbreak \eqref{eq:pa-nonDetBranch2} \} \cup \eqref{eq:pa-new} $. Our main result is a bisimulation between the state space generated by the transition rules $R_\mathit{B\mathcal{_\caP}}^{-1}$, associated to the symbolic backwards semantics of Section~\ref{sec:mnpa-syntax}, and the transition rules $R_{\mathit{PA_\caP}}$ above, associated to the forwards semantics for process algebra. This is nontrivial, since there are three major ways in which the two semantics differ. The first is that processes ``forget'' their past, while strands ``remember'' theirs. The second is that Maude-NPA uses backwards search, while the process algebra proceeds forwards. The third is that Maude-NPA performs symbolic reachability analysis using terms with variables, while the process algebra considers only ground terms. We systematically relate these different semantics by introducing an intermediate semantics, a forward strand space semantics extending that in \cite{Escobar2014FW}. First, in Section~\ref{sec:Cstr} we extend the strand space model with constraints, since strands are the basis of both the forwards semantics and the backwards semantics of Maude-NPA. In Section~\ref{sec:CstrFW} we augment the forwards strand space semantics of \cite{Escobar2014FW} with choice operators and operational semantic rules to produce a \emph{constrained forwards semantics}. In Section~\ref{sec:PA-CstrFW-bisim} we prove bisimilarity of the process algebra semantics of Section \ref{sec:PA} and the constrained forwards semantics of Section \ref{sec:CstrFW}. In~\cite{Escobar2014FW} the forwards strand space semantics was proved sound and complete w.r.t. the original symbolic backwards semantics of Maude-NPA. But now such proofs had to be extended to handle constraints. In Section~\ref{sec:CstrBW} we also augment the original symbolic backwards semantics of Maude-NPA with choice operators and operational semantic rules to produce a \emph{constrained backwards semantics}. In Section~\ref{sec:proof-CstrFW-CstrBW}, we then prove that the constrained backwards semantics is sound and complete with respect to the constrained forwards semantics. By combining the bisimulation between the process algebra and the constrained forwards semantics on the one hand, and the bisimulation between the constrained forwards semantics and the constrained backwards semantics on the other hand, we obtain the main bisimulation result. Besides providing a detailed semantic account of how the strand model can be extended with choice features, the key practical importance of these bisimulation results is that, with the relatively modest extensions to Maude-NPA described in Section \ref{Integration} and supported by its recent 3.0 release, sound and complete analysis of protocols with choice features specified in process algebra is made possible. \section{Constrained Protocol Strands with Choice} \label{sec:Cstr} To specify and analyze protocols with choices in Maude-NPA, in this section we extend Maude-NPA's strand notation by adding new symbols to support explicit choices. We refer to the strands in this extended syntax as \emph{constrained protocol strands}. In Section~\ref{sec:syntaxCstrFW} we describe the syntax for constrained protocol strands. Then, in Section~\ref{sec:mappingToCstrFW} we define a mapping from a protocol specification in the protocol process algebra, as described in Section ~\ref{sec:PASpecification}, to a specification based on constrained protocol strands. \subsection{Constrained Protocol Strands Syntax}\label{sec:syntaxCstrFW} In this section we extend Maude-NPA's syntax by adding \emph{constrained messages}, which are terms of the form $\{\mathit{Cstr}, \allowbreak \mathit{Num}\}$, where $\mathit{Cstr}$ is a constraint, and $\mathit{Num}$ is a natural number that identifies the continuation of the protocol's execution, among the two possibilities after an explicit choice point. More specifically, we extend the $\Sigma_\mathit{{SS}}$ part of the signature $\Sigma_\mathit{{SS}_\mathcal{P}}$ of the Maude-NPA's syntax we defined in Section \ref{sec:mnpa-syntax} as follows: \begin{itemize} \item A new sort \sort{Cstr} represents the constraints allowed in constrained messages, containing three symbols: (i)~$? \ : \ \to \sort{Cstr}$, (ii) $\_{=}\_ \ : \ \sort{Msg} \ \sort{Msg} \to \sort{Cstr}$, and (iii) $ \_{\neq}\_ \ : \ \sort{Msg} \ \sort{Msg} \to \sort{Cstr}$. \item A new sort \sort{CstrMsg} for constrained messages, such that \sort{CstrMsg} $<$ \sort{SMsg}, where \sort{SMsg} is an existing Maude-NPA sort denoting signed messages (i.e., messages with + or -). Therefore, now a strand is a sequence of output, input and constrained messages. \item A new operator $\{\_,\_\} : \sort{Cstr} \ \sort{Nat} \to \sort{CstrMsg} \ $ constructs constrained messages. \end{itemize} We refer to this extended signature as $\Sigma_\mathit{CstrSS_\caP}$. Note that the protocol signature $\Sigma_{\cal P}$ is contained in $\Sigma_\mathit{{SS}_\mathcal{P}}$, and therefore in $\Sigma_\mathit{CstrSS_\caP}$. Furthermore, in the constrained semantics we allow each honest principal or intruder capability strand to be \emph{labeled} by the ``role'' of that strand in the protocol (e.g., \texttt{(Client)} or \texttt{(Server)}). Therefore, strands are now terms of the form $(ro, i)[ u_1, \ldots, u_n]$, where $ro$ denotes the role of the strand in the protocol, $i$ is a unique identifier distinguishing different instances of strands of the same role, and each $u_i$ can be a sent or received message, i.e., a term of the form $M^\pm$, or a constraint message of the form $\{\mathit{Cstr},Num\}$. We often omit $i$, or both $ro$ and $i$ for clarity when they are not relevant. \subsection{Protocol Specification using Constrained Protocol Strands}\label{sec:mappingToCstrFW} The behavior of a protocol involving choices can be specified using the syntax presented in Section~\ref{sec:syntaxCstrFW} as described below. \begin{definition}[Constrained protocol strand specification]\label{def:specCstrFW} Given a protocol ${\cal P}$, we define its specification by means of constrained protocol strands, written $\caP_\mathit{CstrSS}$, as a tuple of the form $\caP_\mathit{CstrSS} = ((\Sigma_\mathit{CstrSS_\caP},E_\mathit{{SS}_\mathcal{P}}), \allowbreak P_\mathit{CstrSS})$, where $\Sigma_\mathit{CstrSS_\caP}$ is the protocol's signature (see Section~\ref{sec:syntaxCstrFW}), and $E_\mathit{{SS}_\mathcal{P}}=E_{\caP} \cup E_\mathit{SS} $ is a set of equations as we defined in Section~\ref{sec:mnpa-syntax}, where $E_{\caP}$ denotes the protocol's cryptographic properties and $E_\mathit{SS}$ denotes the protocol-independent properties of constructors of strands. That is, the set of equations $E_{\caP}$ may vary depending on different protocols, but the set of equations $E_\mathit{SS}$ is always the same for all protocols. $P_\mathit{CstrSS}$ is a set of constrained protocol strands as defined in Section~\ref{sec:syntaxCstrFW}, representing the behavior of the honest principals as well as the capabilities of the attacker. That is, $P_\mathit{CstrSS}$ is a set of labeled strands of the form: $P_\mathit{CstrSS} = \{ (\mathit{ro_1}) [u_{1,1}, \ldots, u_{1,n_1}] ~\&~ \allowbreak \ldots ~\&~ (\mathit{ro_m}) [u_{m,1}, \allowbreak \ldots, u_{m,n_m}] \}$, where, for each $ro_k$ such that $1 \leq k \leq i$, $ro_k$ is either the role of an honest principal, or identifies one of the capabilities of the attacker. We note that $P_\mathit{CstrSS}$ \emph{may contain several strands with the same label}, each defining one of the possible paths of such a principal. \end{definition} The protocol specification described above can be obtained by \emph{transforming} a specification in the process algebra of Section~\ref{sec:PASpecification} as follows. Given a protocol ${\cal P}$, its specification in the process algebra $P_\mathit{PA}$, consists of a set of \emph{well-formed} labeled processes. We transform a term denoting a set of labeled processes into a term denoting a set of constrained protocol strands by the mapping $\textit{toCstrSS}$. The intuitive idea is that, since our process contains no recursion, each process can be ``deconstructed" as a set of constrained protocol strands, where each such strand represent a possible execution path of the process. The mapping $\textit{toCstrSS}$ is specified in Definition~\ref{def:transf} below. \begin{definition}[Mapping labeled processes $\textit{toCstrSS}$]\label{def:transf} Given a labeled process $\mathit{LP}$ and a process configuration $\mathit{LPS}$, we define the mapping $\textit{toCstrSS} : {\cal T}_{\Sigma_\mathit{{PA}_\caP}}(\caX) \ \to {\cal T}_{\Sigma_\mathit{CstrSS_\caP}}(\caX)$ recursively as follows: \vspace{-1ex} \begin{small} \begin{align*} & \textit{toCstrSS}(\mathit{LP} \ \& \ \mathit{LPS}) = \textit{toCstrSS*}( \mathit{LP}, \mathit{nilP}) \ \& \ \textit{toCstrSS}( \mathit{LPS}) \\[-.5ex] & \textit{toCstrSS}(\emptyset) = \mathit{\emptyset} \end{align*} \end{small} \vspace{-1.5ex} \noindent where $\emptyset$ is the empty set of strands. $\textit{toCstrSS*}$ is an auxiliary mapping that maps a term denoting a labeled process to a term that denotes a set of constrained protocol strands. It takes two arguments: a labeled process, and a temporary store that keeps a sequence of messages. More specifically, $\textit{toCstrSS*} : {\cal T}_{\Sigma_\mathit{{PA}_\caP}}(\caX) \ \times {\cal T}_{\Sigma_\mathit{CstrSS_\caP}}(\caX) \to {\cal T}_{\Sigma_\mathit{CstrSS_\caP}}(\caX)$ is defined as follows: \vspace{-1ex} \begin{small} \begin{align*} & \textit{toCstrSS*}( (ro,i, j) \ \mathit{nilP}, L) = (ro, i) \ [ \ L \ ] \\[-.5ex] & \textit{toCstrSS*}( (ro,i, j) \ +M \ . \ P, L) = \textit{toCstrSS*}( (ro,i, j) \ P, (L, \ +M) ) \\[-.5ex] & \textit{toCstrSS*}( (ro,i, j) \ -M \ . \ P, \ L) = \textit{toCstrSS*}( (ro,i, j) \ P, (L, \ -M) ) \\[-.5ex] & \textit{toCstrSS*}((ro,i, j) \ \textit{ (if } T \textit{ then } P \textit{ else } Q ) \ . \ R, L) \\[-.5ex] & \hspace*{10mm} = \ \textit{toCstrSS*}((ro,i, j) \ P \ . \ R, (L, \ \{T,1\}) ) \ \&\ \textit{toCstrSS*}((ro,i, j) \ Q \ . \ R, (L, \ \{\neg T, 2\})) \\[-.5ex] & \textit{toCstrSS*}( (ro,i, j)\ (P \ ? \ Q)\ . \ R, L) \\[-.5ex] & \hspace*{10mm}= \ \textit{toCstrSS*}( (ro,i, j) \ P \ . \ R, (L,\ \{?,1\})) \ \&\ \textit{toCstrSS*}( (ro,i, j) \ Q\ . \ R, (L, \{?,2\})) \end{align*} \end{small} \vspace{-1ex} \noindent where $P$, $Q$, and $R$ denote processes, $M$ is a message, $T$ is a constraint, and $L$ denotes a list of messages, i.e., input, output or constraint messages. Note that $\textit{toCstrSS}$ does not modify output and input messages, since messages are actually terms in ${\cal T}_{\Sigma_\caP/E_{\caP}}(\caX)$ in both the protocol process algebra, and the constrained forwards semantics. $\textit{toCstrSS}$ can be used both as a map between specifications, and as a map from process configurations and strand sets appearing in states. \end{definition} We illustrate the $\textit{toCstrSS}$ transformation with the example below. \begin{example}\label{ex:toCstrFW} If we apply the mapping $\textit{toCstrSS}$ to the process in Example~\ref{ex:non-tlslike} we obtain the following term which denotes a set of strands: \vspace{-2ex} \begin{small} \begin{align*} (\textit{Server}) \ & [ \ \{?,1\}, \\[-.5ex] & -(hs ; N ; G ; gen(G) ; E) , \\[-.5ex] & +(hs ; retry) , \\[-.5ex] & -(hs ; N' ; G' ; gen(G') ; E')) , \\[-.5ex] & +(hs ; n(\chV{S},r1) ; G' ; gen(G') ; keyG(G',\chV{S},r_2) ; Z(\chV{AReq},G',E',S,r_2,\chV{S},HM)) ] \ \& \\[-.5ex] (\textit{Server}) \ &[ \ \{?,2\}, \\[-.5ex] & -(hs ; N ; G ; gen(G) ; E) , \\[-.5ex] & + (hs ; n(\chV{S},r1) ; G ; gen(G) ; keyG(G,S,r_2) ; Z(\chV{AReq},G,E,S,r_2,\chV{S},HM)) ] \end{align*} \end{small} \vspace{-5ex} \end{example} A protocol specification in the protocol process algebra can then be transformed into a specification of that protocol in the constrained protocol strands described below using $\textit{toCstrSS}$. \begin{definition}[Specification transformation]\label{def:transf-pa-Cstr} Given a protocol ${\cal P}$ and its protocol process algebra specification $\caP_\mathit{PA} = ((\Sigma_\mathit{{PA}_\caP},E_{\caP} \cup E_{\mathit{\caP+PA}}), P_\mathit{PA})$, with $P_\mathit{PA} = (ro_1) P_1 \& \ldots \& (ro_n) P_n $, its specification by means of constrained protocol strands is $\caP_\mathit{CstrSS} = ((\Sigma_\mathit{CstrSS_\caP},E_{\caP} \cup E_\mathit{SS}), \allowbreakP_\mathit{CstrSS})$ with $P_\mathit{CstrSS} = \textit{toCstrSS}(P_\mathit{PA})$. \end{definition} \section{Constrained Forwards Strand Semantics}\label{sec:CstrFW} In this section we extend Maude-NPA's rewriting-based forwards semantics in \cite{Escobar2014FW} by adding new transition rules for constrained messages. We refer to this extended forwards semantics as \emph{constrained forwards strand semantics}. We show that the process algebra semantics and the constrained forwards strand semantics are label bisimilar. Therefore, protocols exhibiting choices can be specified and executed in an equivalent way in both semantics. In the constrained forwards strand semantics, state changes are defined by a set $R_\mathit{CstrF_\caP}$ of \emph{rewrite rules}, so that the rewrite theory $(\Sigma_\mathit{CstrSS_\caP}, E_\mathit{{SS}_\mathcal{P}}, R_\mathit{CstrF_\caP})$ characterizes the behaviors of protocol ${\cal P}$. The set of transition rules $R_\mathit{CstrF_\caP}$ is an extension of the transition rules $R_\mathit{F_\caP}$ in \cite{Escobar2014FW}. The transition rules are generated from the protocol specification. A \emph{state} consists of a multiset of partially executed strands and a set of terms denoting the intruder's knowledge. The main differences between the sets $R_\mathit{CstrF_\caP}$ and $R_\mathit{F_\caP}$ are: (i) new transition rules are added in $R_\mathit{CstrF_\caP}$ to appropriately deal with constraint messages, (ii) strands are labeled with the role name, together with the identifier for distinguishing different instances, as explained in Section~\ref{sec:syntaxCstrFW}, (iii) transitions are also labeled, similarly as in the protocol process algebra, (iv) the global counter for generating fresh variables is deleted from the state. Instead, special unique names are assigned to fresh variable, which simplifies our notation. In the constrained forwards strand semantics we label each transition rule similarly as in Section~\ref{sec:semanticsPA}, that is, using labels of the form $(ro,i,j,a,n)$, where $ro$, $i$, $a$, and $n$ are as explained in Section~\ref{sec:semanticsPA}, and $j$ in this case is the position of the message that is being exchanged in the state transition. Also, similar to Section~\ref{sec:semanticsPA}, for transitions that send out messages containing choice variables, all (possibly infinitely many) admissible ground substitutions for the choice variables are possible behaviors. A similar mechanism for distinguishing different fresh variables is used as that explained in Section~\ref{sec:semanticsPA}. Since messages are introduced into strands in the state incrementally, we instantiate the fresh variables incrementally as well. Recall that fresh variables always first show up in a sent message. Therefore, each time a sent message is introduced into a strand in the state, we assign new names to the fresh variables in the message being introduced. The function $\textit{MaxStrId}$ for getting the max identifier for a constrained strand of a certain role is similar to $\textit{MaxProcId}$ in Section \ref{sec:semanticsPA}. Since now messages in a strand can be sent or received messages, i.e., terms of the form $m^+$ or $m^-$, as well as constraint messages $\{\mathit{Cstr},\mathit{Num}\}$, we represent them in the rules below simply as terms of the form $u_i$ when their exact form is not relevant. We will use the precise form of the message when disambiguation is needed. Before explaining the new transition rules for constraint messages, we show how the transition rules in \cite{Escobar2014FW} are labeled. The constrained forwards strand semantics extends Maude-NPA's forwards semantics in \cite{Escobar2014FW} by adding transition rules to handle constraint messages, i.e, messages of the form $\{\mathit{Cstr},\mathit{Num}\}$, where $Num$ can be either $1$ or $2$. First, we add the two transition rules below for the cases when such a constrained message comes from explicit choices. Note that, as a consequence of well-formedness, the constraints introduce no new variables, and since the constraints that we consider are of the form $ m \neq_{E_{\caP}} m' $ or $m=_{E_{\caP}} m'$, the satisfiability of $Cstr$ can be checked by checking whether the corresponding ground equality or disequality holds. \begin{small} \begin{align} \left\{ \begin{array}{@{}l@{}} \forall \ (ro) \ [ u_1,\ldots,u_{j-1},u_{j}^+,u_{j+1},\ldots,u_n] \in P_\mathit{CstrSS} \wedge j \textgreater 1: \\[1ex] \{SS \,\&\,\{IK\} \,\&\, (ro, i) \ [ u_1,\ldots,u_{j-1}]\} \\ \hspace{5ex} \hspace{-4ex}\to_{(ro,i, j,(u_{j}\rho_\mathit{ro,i}\sigma)^+,0)} \\ \{ SS \,\&\, \{\inI{u_{j}\rho_{ro,i}\sigma},IK\} \,\&\, (ro, i) \ [ u_1,\ldots,u_{j-1},(u_{j}\rho_\mathit{ro,i}\sigma)^+ ]\} \\ \hspace{8ex} \ \textsf{IF}\ (\inI{u_j\rho_\mathit{ro,i}\sigma}) \notin IK \\[1ex] \ \textit{where } \sigma \ \textit{is a ground substitution} \textit{ binding choice variables} \ \textit{in} \ u_j , \\ \ \rho_\mathit{ro,i} =\{r_1\mapsto r_1.ro.i, \ldots, r_n\mapsto r_n.ro.i \} \ \textit{is a fresh} \ \textit{substitution}. \end{array} \right\} \eqname{F++} \label{eq:forward-positive-modIK-Cstr} \end{align} \begin{align} \left\{ \begin{array}{@{}l@{}} \forall \ (ro) \ [ u_1,\ldots,u_{j-1},u_{j}^+,u_{j+1},\ldots,u_n] \in P_\mathit{CstrSS} \wedge j \textgreater 1: \\[1ex] \{SS \,\&\,\{IK\} \,\&\, (ro, i) \ [ u_1,\ldots,u_{j-1}]\} \\ \hspace{10ex} \hspace{-8ex}\to_{(ro,i,j,u_{j}\rho_\mathit{ro,i}\sigma,0)} \\ \{ SS \,\&\, \{IK\} \,\&\,(ro, i) \ [ u_1,\ldots,u_{j-1},(u_{j}\rho_\mathit{ro,i}\sigma)^+ ]\}\\ [1ex] \ \textit{where } \sigma \ \textit{is a ground substitution} \textit{ binding choice variables} \ \textit{in} \ u_j , \\ \ \rho_\mathit{ro,i} =\{r_1\mapsto r_1.ro.i, \ldots, r_n\mapsto r_n.ro.i \} \ \textit{is a fresh} \ \textit{substitution}. \end{array} \right\} \eqname{F+} \label{eq:forward-positive-Cstr} \end{align} \noindent \begin{align} \left\{ \begin{array}{@{}l@{}} \forall \ (ro) \ [ u_{1}^+,\ldots,u_n] \in P_\mathit{CstrSS}: \\[1ex] \{SS \,\&\,\{IK\} \} \to_{(ro, i+1, j,(u_{1}\rho_\mathit{ro,i+1}\sigma)^+,0)}\\[1ex] \{ SS \,\&\,(ro, i+1) \ [ (u_{1}\rho_\mathit{ro,i+1}\sigma)^+ ] \,\&\, \{\inI{u_{1}\rho_\mathit{ro,i+1}\sigma},IK\} \} \\ \hspace{2ex} \hspace{2ex} \ \textsf{IF}\ (\inI{u_1\rho_\mathit{ro,i+1}\sigma}) \notin IK \\ [1ex] \ \textit{where } \sigma \ \textit{is a ground substitution} \textit{ binding choice variables} \ \textit{in} \ u_1,\\ \ i=\textit{MaxStrId}(SS, ro), \\ \ \rho_\mathit{ro,i+1} =\{r_1\mapsto r_1.ro.i+1, \ldots, r_n\mapsto r_n.ro.i+1 \} \ \textit{is a fresh substitution}. \end{array} \right\} \eqname{F++\&} \label{eq:forward-positive2-modIK-Cstr} \end{align} \noindent \begin{align} \left\{ \begin{array}{@{}l@{}} \forall \ (ro) \ [ u_{1}^+,\ldots,u_n] \in P_\mathit{CstrSS}:\\[1ex] \hspace{5ex} \hspace{-5ex} \{SS \,\&\,\{IK\}\} \to_{(ro,i+1, j,u_{1}\rho_\mathit{ro,i+1}\sigma,0)}\\ \hspace{2ex}\{ SS \,\&\,(ro, i+1) \ [ (u_{1}\rho_\mathit{ro,i+1}\sigma)^+ ] \,\&\, \{IK\}\} \\[1ex] \ \textit{where } \sigma \ \textit{is a ground substitution} \textit{ binding choice variables} \ \textit{in} \ u_1, \\ \ i=\textit{MaxStrId}(SS, ro),\\ \ \rho_\mathit{ro,i+1} =\{r_1\mapsto r_1.ro.i+1, \ldots, r_n\mapsto r_n.ro.i +1 \} \ \textit{is a} \ \textit{fresh substitution}. \end{array} \right\} \eqname{F+\&} \label{eq:forward-positive2-Cstr} \end{align} \noindent \begin{align} \left\{ \begin{array}{@{}l@{}} \forall \ (ro) \ [ u_1,\ldots,u_{j-1},u_{j}^-,u_{j+1},\ldots,u_n] \in P_\mathit{CstrSS} \wedge j > 1: \\[1ex] \{SS \ \& \{\inI{u_{j}},IK\} \,\&\, (ro, i) \ [ u_1,\ldots,u_{j-1}]\} \\ \to_{(ro, i, j, u_j^-,0)}\\ \{ SS \,\&\, \{\inI{u_{j}},IK\} \,\&\, (ro, i) \ [ u_1,\ldots,u_{j-1},u_{j}^- ]\} \end{array} \right\} \eqname{F-} \label{eq:forward-negative-Cstr} \end{align} \noindent \begin{align} \left\{ \begin{array}{@{}l@{}} \forall (ro) \ [ u_{1}^-,u_{2},\ldots,u_n] \in P_\mathit{CstrSS} : \\[1ex] \{SS \,\&\,\{\inI{u_{1}},IK\} \} \\ \to_{(ro,i+1, 1, u_1^-,0)} \{ SS \ \& \ (ro, i+1) \ [ u_1^- ] \,\&\, \{\inI{u_{1}},IK\} \} \\ \ \ \textit{where } i=\textit{MaxStrId}(SS, ro) \end{array} \right\} \eqname{F-\&} \label{eq:forward-negative2-Cstr} \end{align} \end{small} \begin{small} \begin{align} \left\{ \begin{array}{@{}l@{}} \forall \ (ro) \ [ u_1,\ldots,u_{j-1},\{\mathit{Cstr},\mathit{Num}\},u_{j+1},\ldots,u_n] \in P_\mathit{CstrSS} \\ \wedge j > 1: \\[1ex] \{SS \ \& \{IK\} \,\&\,(ro, i) \ [ u_1,\ldots,u_{j-1}]\} \\ \to_{(ro,i,j,T,\mathit{Num})} \\ \{ SS \,\&\, \{IK\} \,\&\,(ro, i) \ [ u_1,\ldots,u_{j-1},\{\mathit{Cstr},\mathit{Num}\} ]\} \\ \hspace{2ex} \hspace{2ex} \ \textsf{IF}\ \mathit{Cstr} \end{array} \right\} \eqname{Fif} \label{eq:forward-CstrMsg-det} \end{align} \begin{align} \left\{ \begin{array}{@{}l@{}} \forall \ (ro) \ [ u_1,\ldots,u_{j-1},\{?,\mathit{Num}\},u_{j+1},\ldots,u_n] \in P_\mathit{CstrSS} \\ \wedge j > 1: \\[1ex] \{SS \ \& \{IK\} \,\&\,(ro, i) \ [ u_1,\ldots,u_{j-1}]\} \\ \to_{(ro,i,j,?,\mathit{Num})} \\ \{ SS \,\&\, \{IK\} \,\&\,(ro, i) \ [ u_1,\ldots,u_{j-1},\{?,\mathit{Num}\} ]\} \end{array} \right\} \eqname{F?} \label{eq:forward-CstrMsg-nonDet} \end{align} \end{small} The following set of transition rules adds to the state a new strand whose first message is a constraint message of the form $\{?,\mathit{Num}\}$: \noindent \begin{small} \begin{align} \left\{ \begin{array}{@{}l@{}} \forall \ (ro) \ [ \, \{?,\mathit{Num}\},u_{2},\ldots,u_n] \in P_\mathit{CstrSS} : \\[1ex] \{SS \,\&\,\{IK\} \} \\ \to_{(ro,i+1, 1,?,\mathit{Num})} \\ \{ SS \ \& \ (ro, i+1) \ [ \, \{?,\mathit{Num}\} \, ] \,\&\, \{IK\} \} \\ \ \ \textit{where } i=\textit{MaxStrId}(SS, ro) \end{array} \right\} \eqname{F?\&} \label{eq:forward-CstrMsg-first} \end{align} \end{small} \begin{definition}\label{def:CstrFW-semantics} Let $\mathcal{P}$ be a protocol with signature $\Sigma_\mathit{CstrSS_\caP}$ and equational theory $E_\mathit{{SS}_\mathcal{P}}$. We define the {\em constrained forwards rewrite theory characterizing $\mathcal{P}$} as $(\Sigma_\mathit{CstrSS_\caP}, E_\mathit{{SS}_\mathcal{P}}, \allowbreak R_\mathit{CstrF_\caP})$ where $R_\mathit{CstrF_\caP} = \eqref{eq:forward-positive-modIK-Cstr} \cup \eqref{eq:forward-positive-Cstr} \cup \eqref{eq:forward-positive2-modIK-Cstr} \cup \eqref{eq:forward-positive2-Cstr} \cup \eqref{eq:forward-negative-Cstr} \cup \eqref{eq:forward-negative2-Cstr} \cup \eqref{eq:forward-CstrMsg-det} \cup \eqref{eq:forward-CstrMsg-nonDet} \cup \eqref{eq:forward-CstrMsg-first}$. \end{definition} \section{Bisimulation between Constrained Forwards Strand Semantics and Process Algebra Semantics} \label{sec:PA-CstrFW-bisim} In this section we show that the process algebra semantics and the constrained forwards strand semantics are label bisimilar. We first define PA-State and FW-State, the respective notions of state in each semantics. \begin{definition}[PA-State] Given a protocol ${\cal P}$, a \emph{PA-State} of ${\cal P}$ is a state in the protocol process algebra semantics that is \emph{reachable} from the initial state. The initial PA-State is $P_{\mathit{init}}=\{\emptyset ~|~ \{empty\} \}$. \end{definition} \begin{definition}[FW-State] Given a protocol ${\cal P}$, a \emph{FW-State} of ${\cal P}$ is a state in the constrained forwards strand semantics that is \emph{reachable} from the initial state. The initial FW-State is $F_{\mathit{init}}= \{\emptyset ~\&~ \{empty\}\} $. \end{definition} The bisimulation relation is defined based on reachability, i.e., if a PA-State and a FW-State are in the relation $\caH$, then they both can be reached from their corresponding initial states by the same label sequence. Note that we only consider states that are reachable from the initial states. Let us first define the notation of label sequence that we will use throughout. \begin{definition}[Label Sequence] An ordered sequence $\alpha$ of transition labels is defined by using $\_.\_$ as an associative concatenation operator with $nil$ as an identity. The length of a label sequence $\alpha$ is denoted by $| \alpha |$. Given a label sequence $\alpha$, we denote by $\alpha|_{(ro, i)}$ the sub-sequence of labels in $\alpha$ that have $ro$ as role name, and $i$ as identifier, i.e., labels of the form $(ro, i, \_,\_,\_)$ ($\_$ is a shorthand for denoting any term). \end{definition} \begin{definition}[Relation $\caH$] Given a protocol ${\cal P}$, the relation $\caH$ is defined as: $\caH=\{(\mathit{Pst}, \mathit{Fst}) \in \textit{PA-State} \times \textit{FW-State} ~|~ \exists \ \textit{label sequence} \ \alpha \textit{ s.t. } P_{init}\rightarrow_{\alpha} \mathit{Pst}, \allowbreak ~F_{init} \rightarrow_{\alpha} \mathit{Fst} \}$. \end{definition} Recall that a process can be ``deconstructed" by the mapping $\textit{toCstrSS}$ into a set of constrained protocol strands, each representing a possible execution path. If a PA-State $\mathit{Pst}$ and a FW-State $\mathit{Fst}$ are related by $\caH$, then an important observation is that there is a \emph{duality} between individual processes in $\mathit{Pst}$ and strands in $\mathit{Fst}$: if there is a process in the $\mathit{Pst}$ describing a role's \emph{continuation} in the future, there will be a corresponding strand in $\mathit{Fst}$ describing the part of the process that has \emph{already been executed}, and vice versa. Another observation is that, since the intruder's knowledge is extracted from the communication history, following the definition of $\caH$, the states $\mathit{Pst}$ and $\mathit{Fst}$ have the same communication history, therefore they have the same intruder's knowledge. We formalize these observations in Lemmas \ref{lemm:equiv-PStr} and \ref{lemm:sameIK}. These lemmas then lead us to the main result that $\caH$ is a bisimulation relation. We now define the relation $\caH_\mathit{LP\_Str}$, which relates a possibly partially executed labeled process and a constrained strand. This relation defines the \emph{duality} relation between a labeled process and a constrained strands. If a labeled process $LP$ is related to a constrained strand $Str$ by the relation $\caH_\mathit{LP\_Str}$, then: (i) $LP$ and $Str$ denote the behavior of the same role with the same identity in the same protocol, and (ii) for any strand $Str_\mathit{LP}$, $Str_\mathit{LP}$ denotes a possible execution path of $LP$ iff $Str$ followed by $Str_\mathit{LP}$ forms a valid possible execution path of the protocol. \begin{definition}[Relation $\caH_\mathit{LP\_Str}$] Given a protocol ${\cal P}$, and a possibly partially executed labeled process $LP$ of ${\cal P}$, a possibly partially executed constrained strand $Str$ of ${\cal P}$, then $(LP , Str)\in \caH_\mathit{LP\_Str}$ iff \begin{quote} $\textit{toCstrSS}(LP) = \& \{ (ro, i) [u_{j+1},\ldots, u_n]\rho_{ro,i}\theta \mid \exists\ \textit{ground substitution}\ \theta \ \linebreak \exists (ro)[u_1,\ldots u_j, u_{j+1},\ldots, u_n] \in {\cal P}_\mathit{Cstr} \ \textit{s.t.} \ Str = (ro, i)[u_1,\ldots u_j]\rho_{ro,i}\theta \}$ \end{quote} \noindent where $\&\{S_1, S_2, \ldots , S_n\}$ is a shorthand for a term $S_1 \& S_2 \& \ldots \allowbreak \& S_n$ denoting a set of strands. $\rho_{ro,i}=\{r_1 \mapsto r_1.ro.i, \ldots, r_m\mapsto r_m.ro.i\}$ for fresh variables $r_1, \ldots, r_m$ in $[u_1,\ldots u_j, u_{j+1}, \ldots, u_n]$. \end{definition} \begin{example} Following Examples \ref{ex:non-tlslike} and \ref{ex:toCstrFW}, we show a process $LP$ and a strand $Str$ that are related by the relation $\caH_\mathit{LP\_Str}$. $LP$ (resp. $Str$) is the labeled process (resp. constrained strand) of the Server role after making the first explicit nondeterministic choice. \\ \begin{small} \begin{align*} LP= & (\mathit{Server, 1, 2}) \ \sigma (+(hs ; retry) \cdot -(hs ; N' ; G' ; gen(G') ; E') \cdot \\ & ~~~ +(hs ; n(\chV{S},r1) ; G' ; gen(G') ; keyG(G',\chV{S},r_2) ; \\ & ~~~~~~~~ Z(\chV{AReq},G',E',S,r_2,\chV{S},HM))) \\ Str= &(\mathit{Server, 1}) \ \sigma [ \ \{?,1\} , -(hs ; N ; G ; gen(G) ; E) ] \end{align*} \end{small} \noindent where $\sigma$ is a ground substitution to the pattern variables $N$, $G$, and $E$. \end{example} We then lift the duality relation between individual processes and strands to a duality relation between PA-State and FW-State. \begin{definition}[Relation $\caH_\mathit{PS\_FS}$] Let $\mathit{Pst}=\{LP_1 \& \allowbreak \ldots \& LP_n \mid \{\textit{IK}\} \}$ be a PA-State and $\mathit{Fst}=\{Str_1 \& \ldots \& Str_m \allowbreak \& \{\textit{IK}'\} \}$ be a FW-State, if $(\mathit{Pst}, \mathit{Fst}) \in \caH_\mathit{PS\_FS}$, then: \begin{itemize} \item[(i)] For each labeled process $LP_k \in \mathit{Pst}$, $1\leq k \leq n$, there exists a strand $Str_{k'} \in \mathit{Fst}$, $1\leq k' \leq m$, such that $(LP_k , Str_{k'}) \in \caH_\mathit{LP\_Str}$. \item[(ii)] For each strand $Str_{k'} \in \mathit{Fst}$, $1\leq k' \leq m$, there exists a labeled process $LP_k \in \mathit{Pst}$, $1\leq k \leq n$, such that $(LP_k , Str_{k'}) \in \caH_\mathit{LP\_Str}$. \end{itemize} \end{definition} The lemma below states that the relation $\caH$ induces the \emph{duality} relation $\caH_\mathit{PS\_FS}$. \begin{lemma}\label{lemm:equiv-PStr} Let $\mathit{Pst}=\{LP_1 \& \ldots \& LP_n \mid \{\textit{IK}\} \}$ be a PA-State and $\mathit{Fst}=\{Str_1 \& \ldots \allowbreak \& Str_m \& \{\textit{IK}'\} \}$ be a FW-State, if $(\mathit{Pst}, \mathit{Fst}) \in \caH$, i.e., exists a label sequence $\alpha$ such that $P_{\mathit{init}}\rightarrow_{\alpha} \mathit{Pst}$, and $F_{\mathit{init}}\rightarrow_{\alpha} \mathit{Fst}$, then $(\mathit{Pst}, \mathit{Fst}) \in \caH_\mathit{PS\_FS}$. \end{lemma} \begin{proof} We first prove property (i). If $|\alpha| =0$, since both the strand set and the process configuration are empty, the statement is vacuously true. Now suppose that $|\alpha| > 0$. Then, without loss of generality, assume there exists a labeled process $LP_k = ((ro,i, j) \ P_k)$ in $\mathit{Pst}$, with $i, j \ge 1$. Then there is at least one label in $\alpha$ of the form $(ro, i, \_,\_,\_ )$ ($\_$ is a short hand for any content), therefore, there is a strand $St_{k'}$ in $\mathit{Fst}$ of the form $(ro, i) [v_1, \ldots, v_{j'}]$. We then show that the above-mentioned $LP_k$ and $Str_{k'}$ are related by $\caH_\mathit{LP\_Str}$, i.e., $(LP_k,Str_{k'}) \in \caH_\mathit{LP\_Str}$. Since the state $Fst$ is reachable from the initial state by the label sequence $\alpha$, and $Str_{k'}\in Fst$, $[v_1, \ldots, v_{j'}]$ denotes exactly the sequence of messages in the unique sequence of labels $\alpha|_{(ro, i)}$. Moreover, $j'= j-1$. Since the process state $\mathit{Pst}$ is reachable from the initial state $P_{init}$ by label sequence $\alpha$, there exists a unique process $(ro) P_{spec}$ in the specification $P_\mathit{PA}$, and $LP_k$ represents all possible behaviors of $(ro) P_{spec}$ after the sequence of transitions $\alpha|_{(ro, i)}$. Therefore, $\textit{toCstrSS}(LP_k) =$ \begin{align*} &\& \{ (ro, i) [u_{j}, \ldots, u_n]\rho_{ro,i}\theta \mid \\[-.3ex] &\exists \ \textit{ground substitution} \ \theta \\[-.3ex] &\exists (ro)[u_1, \ldots, u_{j-1}, u_{j}, \ldots, u_n] \in \textit{toCstrSS}((ro)P_\mathit{spec}) \\[-.3ex] & \textit{s.t.} \ (ro, i)[u_1, \ldots, u_{j-1}]\rho_{ro,i}\theta = (ro, i)[v_1, \ldots, v_{j-1}]\} \end{align*} By the correspondence between protocol specifications defined in definition \ref{def:transf-pa-Cstr} , $ {\cal P}_{CstrF} =\textit{toCstrSS}(P_\mathit{PA})$. Also note that $(ro)P_{spec}$ is the only process in $P_\mathit{PA}$ that has $ro$ as its role name, therefore, $\textit{toCstrSS}((ro)P_{spec}) = \{ (ro)[u_1, \ldots, u_n] \mid (ro)[u_1, \ldots, u_n] \in {\cal P}_{CstrF} \}$. Therefore, $\textit{toCstrSS}(LP_k) =$ \begin{align*} & \&\{ (ro, i) [u_{j}, \ldots u_n]\rho_{ro,i}\theta \mid \\[-.3ex] &\exists \ \textit{ground substitution} \ \theta, \\[-.3ex] &\exists (ro)[u_1, \ldots, u_{j-1}, u_{j}, \ldots, u_n] \in {\cal P}_{CstrF} \\[-.3ex] &\textit{s.t.} \ (ro, i)[u_1, \ldots, u_{j-1}]\rho_{ro,i}\theta = (ro, i)[v_1, \ldots, v_{j-1}]\}. \end{align*} Therefore, $(LP_k,Str_{k'}) \in \caH_\mathit{LP\_Str}$. The proof for property (ii) is similar to the one for property (i). \end{proof} Lemma \ref{lemm:sameIK} below formalizes the observation that the equivalence of label sequence implies the same intruder knowledge. \begin{lemma}\label{lemm:sameIK} Given a PA-State $\mathit{Pst}$ and a FW-State $\mathit{Fst}$ such that $(\mathit{Pst}, \mathit{Fst}) \in \caH$, i.e., there exists a label sequence $\alpha$ such that $P_{init}\rightarrow_{\alpha} \mathit{Pst}$ and $F_{init}\rightarrow_{\alpha} \mathit{Fst}$, then the contents of intruder knowledge in $\mathit{Pst}$ and in $\mathit{Fst}$ are syntactically equal. \end{lemma} \begin{proof} In both semantics the only transition rules that add new elements to the intruder's knowledge are the ones whose label is of the form $(ro,i, j, +m,n)$. Therefore, given the two states $\mathit{Pst}$ and $\mathit{Fst}$ as described above, their intruder's knowledge can be computed from the sequence of labeled transitions $\alpha$ as \linebreak $\mathit{IK(\mathit{Pst}) = \{ \inI{m} \mid \allowbreak (\_, \_, \_, +m, \_) \in \alpha \} } = \mathit{IK(\mathit{Fst}) } $. \end{proof} Based on the lemmas above, we can now show that the relation $\caH$ is a bisimulation. Since the proof of Theorem \ref{thm:Bisimulation} requires a somewhat lengthy case analysis, it has been moved to Appendix \ref{bisim-proof-app}. \begin{theorem}[Bisimulation]\label{thm:Bisimulation} $\caH$ is a bisimulation. \end{theorem} \section{Constrained Backwards Strand Semantics}\label{sec:CstrBW} In this section we extend Maude-NPA's symbolic backwards semantics with rules for constrained messages of the form described in Section~\ref{sec:syntaxCstrFW}, so that it can analyze protocols exhibiting explicit choices. We refer to this extended backwards semantics as \emph{constrained backwards strand semantics}. We then show that the \emph{constrained backwards strand semantics} is sound and complete with respect to the constrained forwards strand semantics presented in Section~\ref{sec:CstrFW}, and the process algebra semantics presented in Section~\ref{sec:PA}. This result allows us to use Maude-NPA for analyzing protocols exhibiting choice, including both implicit and explicit choices, and in particular any protocol specified using the \emph{protocol process algebra}. The strand space model used in the constrained backwards strand semantics is the same as the one already used in Maude-NPA \cite{EscobarMM-fosad}, except for the following differences: \begin{itemize} \item Maude-NPA explores \emph{constrained states} as defined in \cite{EscobarMMS15}, that is, states that have an associated constraint store. More specifically, a \emph{constrained state} is a pair $\pair{St,\Psi}$ consisting of a state expression $St$ and a \emph{constraint}, i.e., a set $\Psi$ understood as a conjunction $\Psi = {\bigwedge^n_{i=1}} u_i \not= v_i$ of disequality constraints. \item Strands are now of the form $[ u_1, \ldots, u_i \mid u_{i+1}, \ldots u_n]$, where each $u_k$ can be of one of these forms: (i) $m^+$ if it is a sent message, (ii) $m^-$ if it is a received message, or (iii) $\{Cstr, Num\}$ if it is a constrained message. \end{itemize} State changes are described by a set $R_\mathit{CstrB_\caP}^{-1}$ of \emph{rewrite rules}, so that the rewrite theory $(\Sigma_\mathit{CstrSS_\caP},E_\mathit{{SS}_\mathcal{P}},R_\mathit{CstrB_\caP}^{-1})$ characterizes the behavior of protocol ${\cal P}$ modulo the equations $E_\mathit{{SS}_\mathcal{P}}$ for \emph{backwards} execution. The set of rules $R_\mathit{CstrB_\caP}^{-1}$ is obtained as follows. First, we adapt the set of rules $R_\mathit{B\mathcal{_\caP}}^{-1}$ in Section~\ref{sec:mnpa-syntax} to constrained states, which is an embedding of rules in $R_\mathit{B\mathcal{_\caP}}^{-1}$. Their forwards version is shown below: \begin{small} \begin{align} & \pair{ \{ SS\ \&\ [L ~|~ M^-, L']\ \&\ \{\inI{M},IK\}\}, \Psi} \notag\\[-.5ex] & \to \pair{\{ \textit{SS}\ \&\ [L, M^- ~|~ L']\ \&\ \{\inI{M},IK\} \} , \Psi} \eqname{B-} \label{eq:negative-1-CstrBW} \\[1ex] & \pair{ \{ SS\ \&\ [L ~|~ M^+, L']\ \&\ \{IK\} \} , \Psi} \notag\\[-.5ex] & \to \pair{ \{ SS \ \&\ [L, M^+ ~|~ L']\ \&\ \{IK\} \} , \Psi} \eqname{B+} \label{eq:positiveNoLearn-2-CstrBW} \end{align} \begin{align} & \pair{ \{ SS\ \&\ [L ~|~ M^+, L']\ \&\ \{\nI{M},IK\} \} , \Psi} \notag\\[-.5ex] &\to \pair{ \{ SS \ \&\ [L, M^+ ~|~ L']\ \&\ \{\inI{M}, IK\} \} , \Psi} \eqname{B++} \label{eq:positiveLearn-4-CstrBW}\\[1ex] & { \begin{array}[t]{@{}l@{}} \forall \ [ l_1, u^+, l_2] \in {\cal P}: \\ \pair{ \{ \{SS \, \& \, [\, l_1 | \, u^+, l_2\,] \,\&\, \{\nI{u},IK\}\} , \Psi} \\ \to \pair{ \{SS \, \& \, \{\inI{u},IK\}\} \} , \Psi} \end{array} \label{eq:newstrand-positive-CstrBW}% }\eqname{B\&} \end{align}% \end{small} \noindent where $L$ and $L'$ are variables denoting a list of strand messages, $\textit{IK}$ is a variable for a set of intruder facts (\inI{m} or \nI{m}), $\textit{SS}$ is a variable denoting a set of strands, and $l_1$, $l_2$ denote a list of strand messages. Then, we define new transition rules for constrained messages. That is, we add the reversed version of the following rules: \vspace{-2ex} \begin{small} \begin{align} & \pair{\{ SS \, \& \, \{IK'\} \, \& \, (ro)[L \mid \{?,\mathit{Num}\}, L' ] \} , \Psi} \notag\\[-.5ex] & \to \pair{\{ SS \, \& \, \{IK'\} \, \& \, (ro)[L, \{?,\mathit{Num}\} \mid L' ] \},\Psi} \eqname{B?} \label{eq:CstrBW-nonDet} \end{align} \vspace{-3ex} \begin{align} & \pair{\{ SS \, \& \, \{IK \} \, \& \, (ro)[L \mid \{ M =_{E_{\cal P}} M,\mathit{Num}\}, L' ] \}, \Psi} \notag\\[-.5ex] & \to \pair{\{ SS \, \& \, \{IK\} \, \& \, (ro)[L, \{M =_{E_{\cal P}} M,\mathit{Num}\} \mid L' ] \} ,\Psi} \eqname{Bif=} \label{eq:CstrBW-det-eq} \end{align} \vspace{-3ex} \begin{align} & \langle\{ SS \, \& \, \{IK\} \, \& \, (ro)[L \mid \{ M \neq M',\mathit{Num}\}, L' ] \} , (\Psi \wedge \allowbreak M \neq M') \rangle \notag\\ & \to \pair{\{ SS \, \& \, \{IK\} \, \& \, (ro)[L, \{M \neq M',\mathit{Num}\} \mid L' ] \} ,\Psi}\notag\\[-.5ex] & \mbox{if } (\Psi \wedge M \neq_{E_{\cal P}} M') \mbox{ is satisfiable in } {\cal T}_{\Sigma_\mathit{CstrSS_\caP}/ E_{\mathcal{P}}}(\caX)\ \eqname{Bif$\mathit{\neq}$} \label{eq:CstrBW-det-diseq} \end{align} \end{small} Rule~\eqref{eq:CstrBW-nonDet} processes a constraint message denoting an explicit non-deterministic choice with constant ``$?$''. The constraint store is not changed and no satisfiability check is required. Rules~\eqref{eq:CstrBW-det-eq} and \eqref{eq:CstrBW-det-diseq} deal with constrained messages associated to explicit deterministic choices. Since the only constraints we allow in explicit deterministic choices are equalities and disequalities, rule~\eqref{eq:CstrBW-det-eq} is for the case when the constraint is an equality, rule \eqref{eq:CstrBW-det-diseq} is for the case when the constraint is a disequality. The equality constraint is solved by $E_{\cal P}$-unification. The constraint in a \emph{constrained state} is therefore a \emph{disequality constraint}, i.e., $\Psi = {\bigwedge^n_{i=1}} u_i \neq_{E_{\caP}} v_i$. The \emph{semantics} of such a constrained state, written $\semantics{\pair{St,\Psi}}$ is the set of all ground substitution instances of the form: $$\semantics{\pair{St,\Psi}} = \{ St\theta \mid \theta \in [\caX \to {\cal T}_{\Sigma_\caP}] \wedge u_i\theta \neq_{E_{\cal P}} v_i\theta, 1 \leq i \leq n \} $$ The disequality constraints are then solved the same way as in \cite{EscobarMMS15}. \begin{definition} \label{def:CstrBW-semantics} Let $\mathcal{P}$ be a protocol with signature $\Sigma_\mathit{CstrSS_\caP}$ and equational theory $E_\mathcal{P}$. We define the {\em constrained backwards rewrite theory characterizing ${\cal P}$} to be \linebreak $(\Sigma_\mathit{CstrSS_\caP}, E_\mathit{{SS}_\mathcal{P}}, R_\mathit{CstrB_\caP}^{-1})$ where $E_\mathit{{SS}_\mathcal{P}}$ is same as explained in Section \ref{sec:mnpa-syntax}. $R_\mathit{CstrB_\caP}^{-1}$ is the result of reversing the rewrite rules $\{ \eqref{eq:negative-1-CstrBW} , \eqref{eq:positiveNoLearn-2-CstrBW} ,\allowbreak \eqref{eq:positiveLearn-4-CstrBW}, \eqref{eq:CstrBW-nonDet}, \eqref{eq:CstrBW-det-eq}, \eqref{eq:CstrBW-det-diseq}\} \cup \eqref{eq:newstrand-positive-CstrBW}$. \end{definition} \section{Soundness and Completeness of \allowbreak Constrained Backwards Strand Semantics} \label{sec:proof-CstrFW-CstrBW} The soundness and completeness proofs generalize the proofs in \cite{Escobar2014FW}. Recall that the state in the constrained states of constrained backwards strand semantics is a symbolic strand state, i.e., a state with variables. A state in the forwards strand semantics is a ground strand state, i.e., a state without variables. The lifting relation defines the instantiation relation between symbolic and ground states. We define a symbolic state and a ground state as follows. \begin{definition}[Symbolic Strand State] Given a protocol ${\cal P}$, a \emph{symbolic} strand state $S$ of ${\cal P}$ is a term of the form: \begin{align} S = \{ & ::r_{1_1}, \ldots, r_{m_1}::[ u_{1_1}, \ldots u_{i_1-1} ~\mid~ u_{i_1},\ldots, u_{n_1}] \ \& \notag\\ & \vdots \notag\\ & ::r_{1_k}, \ldots, r_{m_k}:: [ u_{1_k}, \ldots, u_{i_k-1} ~\mid~ u_{i_k},\ldots, u_{n_k}] \ \&\ SS\ \notag \\ & \{\inI{w_1}, \ldots, \inI{w_m}, \ \nI{w'_1}, \ldots, \nI{w'_{m'}}, IK\} \} \notag \end{align} \noindent where for each $1\leq j\leq k$, there exists a strand $[ m_{1_j}, \ldots m_{i_j-1}, \allowbreak m_{i_j},\ldots, m_{n_j}]\in P_\mathit{CstrSS}$ and a substitution $\rho_j:\caX\to{\cal T}_{\Sigma_\caP}(\caX)$ such that $m_{1_j}\rho_j \congr{E_{\cal P}} u_{1_j}$, \ldots, $m_{n_j}\rho_j \congr{E_{\cal P}} u_{n_j}$, $SS$ is a variable denoting a (possibly empty) set of strands, and $IK$ is a variable denoting a (possibly empty) set of intruder's knowledge facts. \end{definition} \begin{definition}[Ground Strand State] Given a protocol ${\cal P}$, a \emph{ground} strand state $s$ of ${\cal P}$ is a term without variables of the form: \begin{align} s = \{ & [ u_{1_1}, \ldots u_{i_1-1} ] \ \& \cdots \&\ [ u_{1_k}, \ldots, u_{i_k-1} ] \ \&\ \notag\\ & \{\inI{w_1}, \ldots, \inI{w_m}\}\ \} \notag \end{align} \noindent where for each $1\leq j\leq k$, there exists a strand $[ m_{1_j}, \ldots m_{i_j-1}, \allowbreak m_{i_j},\ldots, m_{n_j}]\in P_\mathit{CstrSS}$ and a substitution $\rho_j:\caX \to {\cal T}_{\Sigma_\caP}$ such that $m_{1_j}\rho_j \congr{E_{\cal P}} u_{1_j}$, \ldots, $m_{i_j}\rho_j \congr{E_{\cal P}} u_{i_j}$. \end{definition} The lifting relation in \cite{Escobar2014FW} is extended with constraints and constrained messages. Note that the $u_{i}$ in the definition below can be sent messages, received messages, or constrained messages. \begin{definition}[Lifting Relation] Given a protocol ${\cal P}$, a constrained symbolic strand state $\mathit{CstrS}=\cnt{S,\Psi}$ and a ground strand state $s$, we say that $s$ \emph{lifts} to $\mathit{CstrS}$, or that $\mathit{CstrS}$ \emph{instantiates} to $s$ with a \emph{ground} substitution $ \theta: (\var{S} - \{ \mathit{SS}, \mathit{IK} \}) \to {\cal T}_{\Sigma_\caP}$, written $\mathit{CstrS} >^\theta s$ iff % \begin{itemize} \item for each strand $::r_{1},\ldots,r_{m}::[ u_{1}, \ldots u_{i-1} \mid u_{i},\ldots, u_{n}]$ in $S$, there exists a strand $[ v_{1}, \ldots v_{i-1} ]$ in $s$ such that $\forall 1\leq j\leq i-1$, $v_j =_{E_{\cal P}} u_j\theta$. % \item for each positive intruder fact $\inI{w}$ in $S$, there exists a positive intruder fact $\inI{w'}$ in $s$ such that $w' \congr{E_{\cal P}} w\theta$, and % \item for each negative intruder fact $\nI{w}$ in $S$, there is no positive intruder fact $\inI{w'}$ in $s$ such that $w' \congr{E_{\cal P}} w\theta$. \item ${E_{{\cal P}}} \models \Psi\theta $. \end{itemize} \end{definition} \noindent In the following we show the soundness and completeness of transitions in constrained backwards strand semantics w.r.t. the constrained forwards strand semantics by proving two lemmas stating the completeness and soundness of one-step transition in the constrained backwards strand semantics w.r.t. the constrained forwards strand semantics. The soundness and completeness result directly follows these two lemmas. In the proofs we consider only transition rules added in both semantics to deal with explicit choices, that is, rules $\eqref{eq:forward-CstrMsg-det} \cup \eqref{eq:forward-CstrMsg-nonDet} \cup \eqref{eq:forward-CstrMsg-first}$ in the constrained forwards strand semantics and rules $\{ \eqref{eq:CstrBW-nonDet}, \eqref{eq:CstrBW-det-eq}, \eqref{eq:CstrBW-det-diseq} \}$ in the constrained backwards strand semantics. The proof of the soundness and completeness of one-step transitions performed in the constrained backwards strand semantics using rules $\{ \eqref{eq:negative-1-CstrBW} , \eqref{eq:positiveNoLearn-2-CstrBW}, \eqref{eq:positiveLearn-4-CstrBW}\} \cup \eqref{eq:newstrand-positive-CstrBW}$ w.r.t to one-step transitions performed in the constrained forwards strand semantics using rules $\eqref{eq:forward-positive-modIK-Cstr} \cup \eqref{eq:forward-positive-Cstr} \cup \eqref{eq:forward-positive2-modIK-Cstr} \cup \eqref{eq:forward-positive2-Cstr} \cup \eqref{eq:forward-negative-Cstr} \cup \eqref{eq:forward-negative2-Cstr} $ is the same as in \cite{Escobar2014FW}, since in these transitions no constraint is involved. Note that although in \cite{Escobar2014FW}, \emph{Choice Variables} were not defined explicitly, the proof extends to strands with choice variables naturally, since the lifting relation between a ground state and a symbolic state does not need to be changed to cover choice variables. Since the strand labels are irrelevant for the result of this section, we will omit the strand labels to simplify the notation from now on. Also, we include the fresh substitution in the substitutions and do not separate the fresh substitutions explicitly. Extending the proofs in \cite{Escobar2014FW}, we first prove how the lifting of a ground state to a symbolic state induces a lifting of a forwards rewriting step in the forwards semantics to a backwards narrowing step in the backwards semantics, i.e., the completeness of one-step transition. The lemma below extends the lifting lemma in \cite{Escobar2014FW} to strands with constrained messages. \begin{lemma}[Lifting Lemma]\label{lemm: constrained-completeness} Given a protocol ${\cal P}$, two ground strand states $s$ and $s'$, a constrained symbolic strand state $\mathit{CstrS}'=\cnt{S', \Psi'}$ and a substitution $\theta'$ s.t. $s \to s'$ and $\mathit{CstrS}' >^{\theta'} s'$, then there exists a constrained symbolic strand state $\mathit{CstrS}=\cnt{S, \Psi}$ and a substitution $\theta$ s.t. $\mathit{CstrS} >^{\theta} s$ and either $\mathit{CstrS} \narrowleft{\mu}{} \mathit{CstrS}'$ or $\mathit{CstrS} = \mathit{CstrS}'$. \end{lemma} The Lifting Lemma is illustrated by Figure \ref{fig:lift}. \begin{figure} \centering { $ \xymatrix@C=13pt@R=13pt{ \mathit{CstrS}\ar@{.>}[d]_{>^{\theta}} & \mathit{CstrS}'\ar@{.>}[l]\ar[d]^{>^{\theta'}} \\ s\ar[r] & s' }% $ } \caption{Lemma \ref{lemm: constrained-completeness}} \label{fig:lift} \end{figure} \begin{proof} As has been explained before, we only need to consider the new rules: \eqref{eq:forward-CstrMsg-det}, \eqref{eq:forward-CstrMsg-nonDet}, \eqref{eq:forward-CstrMsg-first}. The proof in \cite{Escobar2014FW} is structured by cases, some of which having specific requirements on intruder knowledge, or involve changes made to the intruder knowledge. Since all the new rules we are considering do not have specific requirements on the intruder knowledge, and do not change the intruder knowledge either, the cases that we need to consider are the following (cases $e$ and $f$ in the proof in \cite{Escobar2014FW}), which involve the appearance or non-appearance of certain strand(s): \begin{itemize} \item[e:] There is a strand $[u_1,\ldots,u_{j-1},u_j,\ldots,u_n]$ in $P_\mathit{CstrSS}$, $n \geq 1$, $1 \leq j \leq n$, and a substitution $\rho$ such that $[u_1,\ldots,u_{j-1},u_j]\rho$ is a strand in $s'$ and $[u_1,\ldots,u_{j-1}, u_j \mid u_{j+1},\ldots,u_n]\rho$ is a strand in $S'\theta'$. \item[f:] There is a strand $[u_1,\ldots,u_{j-1},u_j,\ldots,u_n]$ in $P_\mathit{CstrSS}$, $n \geq 1$, $1 \leq j \leq n$, and a substitution $\rho$ such that $[u_1,\ldots,u_{j-1},u_j]\rho$ is a strand in $s'$ but $[u_1,\ldots,u_{j-1}, u_j \mid u_{j+1} , \ldots,u_n]\rho$ is not a strand in $S'\theta'$. \end{itemize} Now we consider for the forward rewrite rule application in the step $s\rightarrow s'$. \begin{itemize} \item Given ground states $s$ and $s'$ s.t. $s\rightarrow s'$ using a rule in set \eqref{eq:forward-CstrMsg-det}, then there exists a ground substitution $\tau$, variables SS' and IK', and strand $ [ u_1,\ldots,u_{j-1}, \linebreak \{T, Num\}, u_{j+1},\ldots,u_n]$ in $P_\mathit{CstrSS}$, such that $s =\{SS'\tau \& \{IK'\tau\} \& (ro) [u_1\tau,\allowbreak \ldots,u_{j-1}\tau]\} $, and $s'=\{SS'\tau \& \{IK'\tau\} \& [u_1\tau,\ldots,u_{j-1}\tau, \{T\tau, Num\}]\} $ and $T\tau =_{E_{{\cal P}}} true$. Since there exists a substitution $\theta '$ s. t. $\mathit{CstrS}' >^{\theta'} s'$, we consider the following two cases: \begin{itemize} \item{Case e)} The strand appears in $S'\theta'$. More specifically, $[ u_1\sigma,\ldots, u_{j-1}\sigma, \linebreak \{T\sigma, Num\} \mid u_{j+1}\sigma,\ldots,u_n\sigma]$ is a strand in $S'$ s.t. $\sigma\theta' =_{E_{\cal P}} \tau$. If the constraint $T$ is an equality constraint, since $T\tau =_{E_{\cal P}} T\sigma\theta' =_{E_{{\cal P}}} true$, and by the lifting relation, $E_{\cal P} \models \Psi'\theta'$, rule \eqref{eq:CstrBW-det-eq} can be applied for the backwards narrowing $\mathit{CstrS}' \narrowleft{\mu}{} \mathit{CstrS}$, and $\mathit{CstrS} >^{\theta} s$ such that $\mu\theta =_{E_{\cal P}}\theta'$. If the constraint $T$ is a disequality constraint, since $T\tau =_{E_{\cal P}} T\sigma\theta' =_{E_{{\cal P}}} true$, and by the lifting relation, $E_{\cal P} \models \Psi'\theta'$, we have $E_{\cal P} \models T\sigma\theta' \wedge \Psi'\theta'$. Therefore, rule \eqref{eq:CstrBW-det-diseq} can be applied for the backwards narrowing, and $\mathit{CstrS} >^{\theta} s$. \item {Case f)} The strand does not appear in $S'\theta'$. Then $\theta'$ makes $S'$ as a valid symbolic strand state of $s$, i.e., $S = S'$ and $\mathit{CstrS}' >^{\theta'} s$. \end{itemize} \item Given ground strand states $s$ and $s'$ s.t. $s\rightarrow s'$ using a rule in set \eqref{eq:forward-CstrMsg-nonDet}, then we consider the following two applicable cases: \begin{itemize} \item {Case e)} The strand appears in $S'\theta'$ and thus we can perform a backwards narrowing step from $\mathit{CstrS}'$ with rule~\eqref{eq:CstrBW-nonDet}, i.e., $\mathit{CstrS}' \narrow{}{} \mathit{CstrS}$, and $\mathit{CstrS} >^{\theta'} s$. \item {Case f)} The strand does not appear in $S'\theta'$. Then $\theta'$ makes $\mathit{CstrS}'$ as a valid constraint symbolic state of $s$, i.e., $\mathit{CstrS} = \mathit{CstrS}'$ and $\mathit{CstrS} >^{\theta'} s$. \end{itemize} \item Given states $s$ and $s'$ s.t. $s\rightarrow s'$ using a rule in set \eqref{eq:forward-CstrMsg-first}, the proof is similar with using a rule in the set \eqref{eq:forward-CstrMsg-nonDet}. \end{itemize} \end{proof} Theorem \ref{thm:completeness} below then follows straightforwardly. \begin{theorem}[Completeness]\label{thm:completeness} Given a protocol ${\cal P}$, two ground strand states $s, s_0$, a constrained symbolic strand state $\mathit{CstrS}$ and a substitution $\theta$ s.t. (i) $s_0$ is an initial state, (ii) $s_0 \to^n s$, and (iii) $\mathit{CstrS} >^\theta s$. Then there exists a constrained symbolic initial strand state $\mathit{CstrS}_0$, two substitutions $\mu$ and $\theta'$, and $k \leq n$, s.t. $\mathit{CstrS}_0 \narrowleft{k}{\mu} \mathit{CstrS}$, and $\mathit{CstrS}_0 >^{\theta'} s_0$. \end{theorem} The Soundness Theorem from \cite{Escobar2014FW} can also be extended to constrained backwards and forwards strand semantics. We first show that Lemma 2 in \cite{Escobar2014FW}, which states the soundness of one-step transition, still holds after extending to constrained states. The Soundness Theorem then follows straightforwardly. \begin{lemma}\label{lemm: constrained-soundness} Given a protocol ${\cal P}$, two constrained symbolic states $\mathit{CstrS}=\cnt{S, \Psi}$ and $\mathit{CstrS}'=\cnt{S', \Psi' }$, a ground strand state $s$ and a ground substitution $\theta$, if $\mathit{CstrS} \narrowleftTop{\mu} \mathit{CstrS}'$ and $\mathit{CstrS} >^\theta s$, then there exists a ground strand state $s'$ and a ground substitution $\theta'$ such that $s \to s'$, and $\mathit{CstrS}' >^{\theta'} s'$. \end{lemma} Lemma \ref{lemm: constrained-soundness} is illustrated by the Figure \ref{fig:soundness}. \begin{figure} \centering { $ \xymatrix@C=13pt@R=13pt{ \mathit{CstrS}\ar[d]_{>^{\theta}} & \mathit{CstrS}'\ar@{~>}[l]\ar@{.>}[d]^{>^{\theta'}} \\ s\ar@{.>}[r] & s' }% $ } \caption{Lemma \ref{lemm: constrained-soundness}} \label{fig:soundness} \end{figure} \begin{proof} We only need to consider the new rules: rule \eqref{eq:CstrBW-det-eq}, \eqref{eq:CstrBW-det-diseq} and \eqref{eq:CstrBW-nonDet}. \\ 1) If $\mathit{CstrS} \narrowleftTop{\mu} {\mathit{CstrS}'}$ using rule \eqref{eq:CstrBW-nonDet}, then there are associated rules in the sets \eqref{eq:forward-CstrMsg-nonDet} and \eqref{eq:forward-CstrMsg-first}.\\ 2) If $\mathit{CstrS} \narrowleftTop{\mu} {\mathit{CstrS}'}$ using rule \eqref{eq:CstrBW-det-eq}, there is a strand $[ u_1\sigma,\ldots,u_{j-1}\sigma \mid \{(u=v)\sigma, Num\}, u_{j+1}\sigma,\ldots, u_n\sigma]$ in $S$, $[ u_1\sigma',\ldots,u_{j-1}\sigma', \{(u=v)\sigma', Num\} \mid u_{j+1}\sigma',\ldots, \allowbreak u_n\sigma']$ in $S'$ s.t. $\sigma=_{E_{\cal P}} \sigma'\mu$, $\Psi =_{E_{\cal P}} \Psi' \mu$ and $u\sigma=_{E_{\cal P}}v\sigma$, where $ [ u_1,\ldots,u_{j-1}, \{u=v, Num\},u_{j+1},\ldots,u_n]$ is a strand in $P_\mathit{CstrSS}$. Since $\mathit{CstrS} >^\theta s$, there is a ground strand $[ u_1\sigma\theta,\ldots, \allowbreak u_{j-1}\sigma\theta]$ in s, and $E_{\cal P} \models \Psi\theta $. Therefore, $E_{\cal P} \models \Psi' \mu\theta $ and $u\sigma\theta=_{E_{\cal P}}v\sigma\theta$. By rule \eqref{eq:forward-CstrMsg-det}, $s\rightarrow s'$, and $\mathit{CstrS}' >^{\mu\theta} s'$. If $\mathit{CstrS} \narrowleftTop{\mu} {\mathit{CstrS}'}$ using rule \eqref{eq:CstrBW-det-diseq}, there is a strand $[ u_1\sigma,\ldots,u_{j-1}\sigma \mid \{(u\neq v) \sigma, Num\}, u_{j+1}\sigma,\ldots, u_n\sigma]$ in $S$ , $[ u_1\sigma',\ldots,u_{j-1}\sigma', \{(u\neq v)\sigma', Num\} \mid u_{j+1}\sigma', \ldots, \allowbreak u_n\sigma']$ in $S'$ s.t. $\sigma=_{E_{\cal P}} \sigma'\mu$ and $\Psi =_{E_{\cal P}} \Psi'\mu \wedge (u\neq v) \sigma'\mu$, where $ [ u_1,\ldots,u_{j-1}, \{u\neq v, Num\},u_{j+1},\ldots,u_n]$ is a strand in $P_\mathit{CstrSS}$. Since $\mathit{CstrS} >^\theta s$, there is a ground strand $[ u_1\sigma\theta,\ldots, \allowbreak u_{j-1}\sigma\theta]$ in s, and $E_{\cal P} \models \Psi\theta$. Therefore, $E_{\cal P} \models \Psi'\mu\theta \wedge (u\neq v) \sigma'\mu\theta$. By rule \eqref{eq:forward-CstrMsg-det}, $s\rightarrow s'$, and $\mathit{CstrS}' >^{\mu\theta} s'$. \end{proof} The Soundness Theorem below shows that the backwards symbolic reachability analysis is \emph{sound} with respect to the forwards rewriting-based strand semantics. \begin{theorem}[Soundness]\label{thm:soundness} Given a protocol ${\cal P}$, two constrained symbolic strand states $\mathit{CstrS}_0, \mathit{CstrS}'$, an initial ground strand state $s_0$ and a substitution $\theta$ s.t. (i) $\mathit{CstrS}_0$ is a symbolic initial state, and (ii) $\mathit{CstrS}_0 \stackrel{*}{\leftsquigarrow} \mathit{CstrS}'$ , and (iii) $\mathit{CstrS}_0 >^{\theta} s_0$. Then there exists a ground strand state $s'$ and a substitution $\theta'$, s.t. (i) $s_0 \to^* s'$, and (ii) $\mathit{CstrS}' >^{\theta'} s'$. \end{theorem} The soundness and completeness results in Theorems~\ref{thm:soundness} and~\ref{thm:completeness} together with the bisimulation proved in Theorem~\ref{thm:Bisimulation} show that the backwards symbolic reachability analysis is \emph{sound} and \emph{complete} with respect to the process algebra semantics. \begin{theorem}[Soundness]\label{thm: Soundness-PA} Given a protocol ${\cal P}$, two constrained symbolic strand states $\mathit{CstrS}_0, \mathit{CstrS}$, the initial FW-State $F_{init}$, a substitution $\theta$, and the initial PA-State $P_{init}$ s.t. (i) $\mathit{CstrS}_0$ is a symbolic initial strand state, and (ii) $\mathit{CstrS}_0 \stackrel{*}{\leftsquigarrow}_{\mu} \mathit{CstrS}$, and (iii) $\mathit{CstrS}_0 >^{\theta} F_{init}$. Then there exists a FW-State $\mathit{Fst}$ such that $\mathit{CstrS} >^{\theta'} \mathit{Fst}$, and therefore, there is a PA-State $\mathit{Pst}$ such that $\mathit{Pst}\ \caH\ \mathit{Fst}$ \end{theorem} \begin{theorem}[Completeness]\label{thm: Completeness-PA} Given a protocol ${\cal P}$, a PA-State $\mathit{Pst}$, a FW-State $\mathit{Fst}$, a constrained symbolic strand state $\mathit{CstrS}$ s.t. (i) $\mathit{Pst}\ \caH\ \mathit{Fst}$, (ii) $\mathit{CstrS} >^{\theta'} \mathit{Fst}$. Then there is a backwards symbolic execution $\mathit{CstrS}_0 \stackrel{*}{\leftsquigarrow}_{\mu} \mathit{CstrS}$ s.t. $\mathit{CstrS}_0$ is a symbolic initial strand state as defined in Section \ref{sec:mnpa-syntax}, and $\mathit{CstrS}_0 >^{\theta} F_{init}$. \end{theorem} \section{Protocol Experiments} \label{sec:Exp} In this section we describe some experiments\footnote{Available at \url{http://personales.upv.es/sanesro/Maude-NPA-choice/choice.html}} that we have performed on protocols with choice. We have fully integrated the process algebra syntax, and its transformation into strands, and have developed new methods to specify attack states using the process notation in the recent release of Maude-NPA 3.0 (see \cite{MNPAmanual3.0}). \subsection{Integration of the Protocol Process Algebra in Maude-NPA} \label{Integration} We have fully implemented the process algebra notation in Maude-NPA. Strands represent each role behavior as a linear sequence of message outputs and inputs but processes represent each role behavior as a possibly non-linear sequence of message outputs and inputs. The honest principal specification is specified in the process algebra syntax. In order for Maude-NPA to accept process specifications, we have replaced the section \texttt{STRANDS-PROTOCOL} from the protocol template by a new section \texttt{PROCESSES-PROTOCOL}; see \cite{MNPAmanual3.0} for details. The intruder capabilities as well as the states generated by the tool still use the strand syntax. Attack patterns may be specified using the process algebra syntax, under the label \texttt{ATTACK-PROCESS}, or strand syntax, under the label \texttt{ATTACK-STATE}. We describe how they are specified in the process algebra syntax below. An attack pattern describes a state consisting of zero or more processes that must have executed, and zero or more terms in the intruder knowledge. It may also contain \emph{never patterns}, that is, descriptions of processes that must \emph{not} be executed at the time the state is reached. Never patterns can be used to reason about authentication properties, e.g., can Alice execute an instance of the protocol, apparently with Bob, without Bob executing an instance of the protocol with Alice. Note that processes in an attack pattern cannot contain explicit nondeterminism (?) or explicit deterministic choice (if), since one and only one behavior is provided in an attack pattern. This is achieve by requiring that any constraint $c$ appearing in an attack pattern must be \emph{strongly irreducible}, that is, it must not only be irreducible, but for any irreducible substitution $\sigma$ to the variables of $c$, $\sigma c$ must be irreducible as well. That is, imagine a process i the form $$-(m1)\ .\ +(m2)\ .\ if\ exp1\ =\ exp2\ then\ +(m3)\ else\ +(m4)$$ \noindent where each of the expressions $exp1$ and $exp2$ can evaluate to $yes$ or $no$ depending on the substitutions made to them. Then in the attack pattern one must specify one and only one of the following possibilities \begin{eqnarray} -(m1)\ .\ +(m2)\ .\ yes=yes\ .\ +(m3) \notag \\ -(m1)\ .\ +(m2)\ .\ yes \neq no\ .\ +(m4) \notag \\ -(m1)\ .\ +(m2)\ .\ no = no\ .\ +(m3) \notag \\ -(m1)\ .\ +(m2)\ .\ no \neq yes\ .\ +(m4) \notag \end{eqnarray} Finally, never patterns must satisfy a stronger condition: the entire never pattern must be strongly irreducible. This condition is inherited from the original Maude-NPA. \subsection{Choice of Encryption Type} This protocol allows either public key encryption or shared key encryption to be used by Alice to communicate with Bob. Alice initiates the conversation by sending out a message containing the chosen encryption mode, then Bob replies by sending an encrypted message containing his session key. The encryption mode is chosen nondeterministically by Alice. Therefore, it exhibits an \emph{explicit nondeterministic choice}. Below we show the protocol description: the first one reflects the case in which public key encryption (denoted by $PubKey$) is chosen. \begin{enumerate} \item $A \rightarrow B: A ; B ;\mathit{PubKey} $ \item $B \rightarrow A: pk(A, B; SK)$ \item $A\rightarrow B: pk(B, A ; SK ; N_A\}$ \item $B \rightarrow A : pk(A, B ; N_A )$ \end{enumerate} \noindent The second one reflects the case in which a shared key encryption (denoted by $SharedKey$) is chosen. \begin{enumerate} \item $A \rightarrow B: A ; B ;\mathit{SharedKey} $ \item $B \rightarrow A: shk(key(A,B), B ; SK)$ \item $A\rightarrow B: shk(key(A,B), A ; SK ; N_A)$ \item $B \rightarrow A : shk(key(A,B), B ; N_A)$ \end{enumerate} \noindent Note that $A$ and $B$ are names of principals, $SK$ denotes the session key generated by $B$, and $N_A$ denotes a nonce generated by $A$. There are different ways of encoding this protocol as two process expressions. We have chosen to treat the encryption mode as a choice variable which can be either public key encryption or shared key encryption, and then the receiver will perform an explicit deterministic choice depending on the value of this choice variable. The process specification is as follows: \begin{align*} (\mathit{Init}) \ ( & (+(\chV{A} \, ; \, \chV{B} \, ; \,\mathit{PubKey}) \cdot -(pk(\chV{A}, \chV{B} \, ; \, \mathit{SK})) \\[-.6ex] & ? \\[-.5ex] & (+(\chV{A} \,;\, \chV{B} \,;\, \mathit{SharedKey}) \cdot -(e(\mathit{key}(\chV{A},\chV{B}), \chV{B} \, ;\, \mathit{SK})) \\ (\mathit{Resp}) \ & -(A \, ; \, B \, ; \, \mathit{TEnc}) \ \cdot \\[-.6ex] & \mathit{if} \ TEnc = \mathit{PubKey} \\[-.6ex] & \hspace{3ex} \mathit{then } \ (+(pk(A, B \, ; \, \mathit{skey(A,B,r')})) \ \\[-.6ex] & \hspace{3ex} \mathit{else } \ (+(e(\mathit{key(A,B)}, B \, ; \, \mathit{skey(A,B,r')}))) \ \end{align*} We analyzed whether the intruder can learn the session key generated by Bob, when either the public key encryption or shared key encryption is chosen, assuming both principals are honest. \begin{verbatim} --- initiator accepts session key for shared key encryption and --- intruder learns it eq ATTACK-PROCESS(2) = -(a ; b ; mode) . (mode neq pubkey) . +(she(key(a, b), skey(b,r))) . -(she(key(a, b), skey(b,r) ; N)) . +(she(key(a, b), N)) || skey(b,r) inI || nil [nonexec] . --- initiator accepts session key for public key encryption and --- intruder learns it eq ATTACK-PROCESS(3) = -(a ; b ; mode) . (mode eq pubkey) . +(pk(a, b ; skey(b, r))) . -(pk(b, a ; skey(b,r) ; N)) . +(pk(a, b ; N)) || skey(b,r) inI || nil [nonexec] . \end{verbatim} For this property, Maude-NPA terminated without any attack being found for any of the two attack states. \subsection{Rock-Paper-Scissors} To evaluate our approach on protocols with explicit deterministic choices, we have used a simple protocol which simulates the famous Rock-Paper-Scissors game, in which Alice and Bob are the two players of the game. In this game, Alice and Bob commit to each other their hand shapes, which are later on revealed to each other after both players committed their hand shapes. The result of the game is then agreed upon between the two players according to the rule: rock beats scissors, scissors beats paper and paper beats rock. They finish by verifying with each other that they both reached the same conclusion. Thus, at the end of the protocol each party should know the outcome of the game and whether or not the other party agrees to the outcome. This protocol exhibits \emph{explicit deterministic choice}, because the result of the game depends on the evaluation of the committed hand shapes according to the game's rule. Note that this protocol also exhibits \emph{implicit nondeterministic choice}, since the hand shape of the players are chosen by the players during the game. The protocol proceeds as follows. First, both initiator and responder choose their hand shapes and send them to each other using a secure commitment scheme. Next, they both send each other the nonces that are necessary to open the commitments. Each of them then compares the two hand shapes and decides if the initiator wins, the responder wins, or there is a tie. The initiator then sends the responder the outcome. When the responder receives the initiator's verdict, it compares it against its own. It responds with ``finished'' if it agrees with the initiator and ``cheater'' if it doesn't. All messages are signed and encrypted, and the initiator's and responder's nonces are included in the messages concerning the outcome of the game. The actual messages sent and choices made are described in more detail below. \clearpage \begin{enumerate} \item $A \rightarrow B: pk(B, sign(A, commit(N_A, X_A) ) ) $ \item $B \rightarrow A: pk(A, sign(B, commit(N_B, X_B ) ) )$ \item $A \rightarrow B: pk(B, sign(A, N_A )) $ \item $B \rightarrow A: pk(A, sign(B, N_B)) $ \item $if \ (X_A \ beats \ X_B) \ $\\ $ then \ R = Win $ \\ $ else \ if \ (X_B \ beats \ X_A)$ \\ \hspace*{5mm} $ then \ R = Lose$ \\ \hspace*{5mm} $ else\ if \ (X_B \ = \ X_A) \\ \hspace*{13mm} then \ R = \ Tie$ \\ \hspace*{13mm} $ else\ \mathit{nilP}$ \item $A \rightarrow B : pk(B, sign(A, N_A ; N_B ; R ) ) $ \item $if \ (R = Win \& X_A \ beats \ X_ B ) $ \\ \hspace*{16mm} $ \ or \ (R \ = \ Lose \ \& \ X_B \ beats \ X_A )$\\ \hspace*{16mm} $\ or \ (R \ = \ Tie \ \& \ X_A \ = \ X_B) $\\ \hspace*{6mm} $ then \ B \rightarrow A: pk(A, sign(B, N_A ; N_B ; \ finished \ ) )$ \\ \hspace*{6mm} $ else\ B \rightarrow A: pk(A, sign(B, N_A ; N_B ; \ cheater \ ) )$ \end{enumerate} One interesting feature of the Rock-Scissors-Paper protocol, is that, in order to verify that the commitment has been opened successfully, i.e., that the nonce received is the nonce used to create the commitment, one must verify that the result of opening it is well-typed, i.e., that it is equal to ``rock'', ``scissors'', or ``paper''. This can be done via the evaluation of predicates. First, we create a sort Item and declare the constants ``rock'', ``scissors'', and ``paper'' to be of sort Item. Then we create a variable $X:Item$ of sort Item. We then define a predicate $item?$ such that $item? X:Item $ evaluates to true. Since only terms of sort Item can be unified with $X:Item$, this predicate can be used to check whether or not a term is of sort Item. The process specification for the initiator and the responder is as follows. \begin{align*} (Initiator) \ & +(pk(B, sig(A, com(n(A,r), XA))))\ .\\ & -(pk(A, sig(B, ComXB)))\ .\\ & +(pk(B, sig(A, n(A , r))))\ .\\ & -(pk(A, sig(B, NB)))\ .\\ & (if\ ((item?\ open(NB, ComXB))\ eq\ ok)\\ & then\ if\ ((XA\ beats\ open(NB, ComXB))\ eq\ ok)\\ & ~~~~~~~ then\ +(pk(B, sig(A, n(A, r)\ ;\ win))) \\ & ~~~~~~~ else\ if\ ((open(NB, ComXB)\ beats\ XA)\ eq\ ok)\\ & ~~~~~~~~~~~~ then\ +(pk(B, sig(A, n(A, r)\ ;\ lose )))\\ & ~~~~~~~~~~~~ else\ +(pk(B, sig(A, n(A, r)\ ;\ tie)))\\ & else\ nilP )\ .\\ & -(pk(A, sig(B, n(A,r) ; NB))\ ;\ S{:}Status) \end{align*} \begin{align*} (Responder) \ & -(pk(B, sig(A, ComXA)))\ .\\ & +(pk(A, sig(B, com(n(B,r), XB))))\ .\\ & -(pk(B, sig(A, NA)))\ .\\ & +(pk(A, sig(B, n(B, r))))\ .\\ & -(pk(B, sig(A, NA ; R)))\ .\\ & (if\ ((item?\ open(NA, ComXA))\ eq\ ok)\ then\\ & if\ (R\ eq\ win)\\ & then\ if\ ((open(NA, ComXA)\ beats\ XB)\ eq\ ok) \\ & ~~~~~~ then\ +(pk(A, sig(B, NA ; n(B,r)))\ ;\ finished)\\ & ~~~~~~ else\ +(pk(A, sig(B, NA ; n(B,r)))\ ;\ cheater)\\ & else\ if\ (R\ eq\ lose)\\ & ~~~~~~ then\ if\ ((XB\ beats\ open(NA, ComXA))\ eq\ ok)\\ & ~~~~~~~~~~~~ then\ +(pk(A, sig(B, NA ; n(B,r)))\ ;\ finished)\\ & ~~~~~~~~~~~~ else\ +(pk(A, sig(B, NA ; n(B,r)))\ ;\ cheater)\\ &~~~~~~ else\ if\ (R\ eq\ tie)\\ &~~~~~~~~~~~~ then\ if\ (XB\ eq\ open(NA, ComXA))\\ &~~~~~~~~~~~~~~~~~~ then\ +(pk(A, sig(B, NA ; n(B,r)))\ ;\ finished)\\ &~~~~~~~~~~~~~~~~~~ else\ +(pk(A, sig(B, NA ; n(B,r)))\ ;\ cheater)\\ &~~~~~~~~~~~~ else\ nilP\\ & else\ nilP ) \end{align*} \noindent We first tried to see whether the protocol can simulate the game successfully, so we asked for different scenarios in which the player Alice or Bob can win in a round of the game. Maude-NPA was able to generate the expected scenarios, and it did not generate any others. We then gave Maude-NPA a secrecy attack state, in which the intruder, playing the role of initiator against an honest responder, attempts to guess its nonce before the responder receives its commitment. \begin{verbatim} eq ATTACK-PROCESS(1) = -(pk(b,sig(i, ComXA:ComMsg))) . +(pk(i,sig(b, com(n(b, r:Fresh), XB:Item)))) . -(pk(b,sig(i, NA:Nonce))) || n(b, r:Fresh) inI || nil [nonexec] . \end{verbatim} Finally we specified an authentication attack state in which we asked if a responder could complete a session with an honest initiator with the conclusion that the initiator had carried out its rule faithfully, without that actually having happened. \begin{verbatim} eq ATTACK-PROCESS(2) = -(pk(b, sig(a, ComXA))) . +(pk(a, sig(b, com(n(b,r), XB)))) . -(pk(b, sig(a, NA))) . +(pk(a, sig(b, n(b, r)))) . -(pk(b, sig(a, NA ; win))) . ((item? open(NA, ComXA)) eq ok) . (win eq win) . ((open(NA, ComXA) beats XB) eq ok) . +(pk(a, sig(b, NA ; n(b,r))) ; finished) || empty || never( +(pk(b, sig(a, ComXA))) . -(pk(a, sig(b, com(n(b,r), XB)))) . +(pk(b, sig(a, NA))) . -(pk(a, sig(b, n(b,r)))) . (ok eq ok) . (ok eq ok) . +(pk(b, sig(a, NA ; win))) . -(pk(a, sig(b, NA ; n(b,r))) ; finished) || empty ) [nonexec] . \end{verbatim} For both of these attack states Maude-NPA finished its search without finding any attacks. \subsection{TLS} In Section \ref{sec:ex} we introduced a simplified version of the handshake protocol in TLS 1.3 \cite{tls1.3.12}. Even this simplified version produced a very large search space, because of the long list of messages and the concurrent interactions of a big amount of choices. We are however able to check the correctness of our specification by producing legal executions in Maude-NPA. Unlike TLS 1.3, we intentionally introduced a ``downgrade attack" in our version in which the attacker can trick the principals into using a weaker crypto system. However, we have not yet been able to produce this attack because of the very deep and wide analysis tree (i.e., long reachability sequences with many branches) that is produced. We are currently investigating more efficient ways of managing list processing. \section{Related Work}\label{sec:related-work} As we mentioned in the introduction, there is a considerable amount of work on adding choice to the strand space model that involves embedding it into other formal systems, including event-based models for concurrency \cite{DBLP:conf/fsttcs/CrazzolaraW02}, Petri nets \cite{DBLP:journals/entcs/Froschle09}, or multi-set rewriting \cite{DBLP:conf/csfw/CervesatoDMLS00}. Crazzolara and Winskel model nondeterministic choice as a form of composition, where a conflict relation is defined between possible child strands so that the parent can compose with only one potential child. In \cite{DBLP:journals/entcs/Froschle09} Fr{\"{o}}schle uses a Petri net model to add branching to strand space \emph{bundles}, which represent the concurrent execution of strand space roles. Note that we have taken the opposite approach of representing bundles as traces of non-branching strands, where a different trace is generated for each choice taken. Although this results in more bundles during forward execution, it makes little difference in backwards execution, and is more straightforward to implement in an already existing analysis tool. We also note that deterministic choice has been included in the applied pi calculus for cryptographic protocols \cite{DBLP:conf/popl/AbadiF01}, another widely used formal model, based on Milner's pi calculus \cite{DBLP:books/daglib/0098267}. The applied pi calculus includes the rule $\mathit{if} \ M = N \ \mathit{then} \ P \ \mathit{else} \ Q$, where $P$ and $Q$ are terms. This is similar to our syntax for deterministic choice. However our long-term plan is to add other types or predicates as well (e.g., $M \ \mathit{subsumes} \ N$) ; indeed our approach extends to any type of predicate that can be evaluated on a ground state. Although the applied pi calculus in its original form does not include nondeterministic choice, both nondeterministic and probabilistic choice have been added in subsequent work \cite{DBLP:conf/aplas/Goubault-LarrecqPT07}. In addition, Olarte and Valencia show in \cite{DBLP:conf/ppdp/OlarteV08} how a cryptographic protocol modeling language can be expressed in their universal timed concurrent constraint programming (utcc) model, a framework that extends the timed concurrent constraint programming model to express mobility. The language does not support choice, but utcc does. It seems that it would not be difficult to extend the language to incorporate the utcc choice mechanisms. The Tamarin protocol analysis tool \cite{DBLP:conf/cav/MeierSCB13} includes deterministic branching, which was used extensively in the analysis of TLS 1.3 \cite{tls-tamarin/2016}. In particular, it includes an optimization for roles of the form $P . ( \mathit{if} \ T \ \mathit{then} \ {Q} \ \mathit{else} \ R) . S$; when backwards search is used, it is sometimes possible to capture such an execution in terms of just one strand until the conditional is encountered, thus reducing the state space. Our approach produces two strands, but since the process algebra semantics makes it easy to tell whether or not $R$ behaves ``essentially'' the same no matter if $P$ or $Q$ is chosen, we believe that we have a pathway for including such a feature if desired. \section{Conclusions} \label{sec:Conclusion} We have provided an extension to the strand space model that allows for both deterministic and nondeterministic \allowbreak choice, together with an operational semantics for choice in strand spaces that not only provides a formal foundation for choice, but allows us to implement it directly in the Maude-NPA cryptographic protocol analysis tool. In particular, we have applied Maude-NPA to several protocols that rely on choice in order to validate our approach. This work not only provides a choice extension to strand spaces, but extends them in other ways as well. First of all, it provides a process algebra for strand spaces. This potentially allows us to relate the strand space model to other formal systems (e.g., the applied pi calculus \cite{DBLP:conf/podc/Abadi01}) giving a better understanding of how it compares with other formal models. In addition, the process algebra semantics provides a new specification language for Maude-NPA that we believe is more natural for users than the current strand-space language. Another contribution of this work is that it provides a means for evaluating both equality and disequality predicates in the strand space model and in Maude-NPA. This allows us to implement features such as type checking in Maude-NPA, via predicates such as $\mathit{foocheck(X)}$, where \allowbreak $\mathit{foocheck(0:Foo)} = tt$, that is, $\mathit{foocheck(X)}$ succeeds only if $X$ is of sort $Foo$. This proved to be very helpful, for example, in our specification of the Rock-Scissors-Paper protocol as we described earlier. We believe the expressiveness of Maude-NPA can be further increased at little cost by extending the types of predicates that can be evaluated, e.g., by including predicates for subsumption and their negations. This is another subject for further investigation.
{'timestamp': '2019-04-23T02:28:20', 'yymm': '1904', 'arxiv_id': '1904.09946', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.09946'}
arxiv
\section{Introduction} The field of population genetics is shaped by a continuing conversation between theory, methods, and data. We design experiments and collect data with the methods we will use to analyze them in mind, and those methods are based on theory developed to explain observations from data. With some exceptions, especially the work of Sewall Wright \citeyearpar{Wright1940,Wright1943,wright1946isolation} and Gustave Mal\'ecot \citeyearpar{malecot}, much of the early body of theory was focused on developing expectations for discrete populations. This focus was informed by early empirical datasets, most of which \citep[again, with exceptions, like][]{Dobzhansky_Wright1943, dobzhansky1947} were well-described as discrete populations -- like samples of flies in a vial \citep{lewontin1974}. In turn, the statistics used to analyze these datasets -- e.g., empirical measurements of $F_{ST}$ \citep{Wright1951} or tests of Hardy-Weinberg equilibrium \citep{hardy1908,weinberg1908} -- were defined based on expectations in discrete, well-mixed populations. In part, this was because much more detailed mathematical predictions were possible from such simplified models. The focus of theory and methods on discrete populations in turn influenced future sampling designs. To what degree does reality match this picture of clearly delimited yet randomly mating populations? Often, the answer is: not well. Organisms live, move, reproduce, and die, connected by a vast pedigree that is anchored in time and space. But, it is difficult to collect data and develop theory and methods that capture this complexity. Sampling and genotyping efforts are limited by access, time, and money. Developing theory to describe evolutionary dynamics without the simplifying assumption of random mating is more difficult. For example, without discrete populations, many commonly-estimated quantities in population genetics -- migration rate ($m_{ij}$), effective population size ($N_e$), admixture proportion -- are poorly defined. A long history of theoretical work describing geographical populations \citep[e.g.,][]{fisher1937wave,haldane1948theory,slatkin1973geneflow,nagylaki1975conditions,sawyer1976branching,barton1979dynamics} has not had that strong an effect on empirical work \citep[but see][]{landscape_genomics_review}. However, modern advances in acquiring both genomic and geospatial data is making it more possible -- and, necessary -- to explicitly model geography. Today's large genomic datasets are facilitating the estimation of the timing and extent of shared ancestry at a much finer geographic and temporal resolution than was previously possible \citep{Li_Durbin2011,Palamara_2012,Harris_Nielsen_2013,ralph2013geography}. And, advances in theory in continuous space \citep{felsenstein1975pain,barton1995genealogies,barton-depaulis-etheridge, barton2010newmodel, hallatschek2011noisy, barton2010modelling, Barton2013}, datasets of unprecedented geographical scale \citep[e.g.,][]{POBI, Aguillon2017deconstructing, Shaffer195743}, new computational tools for simulating spatial models \citep{haller2018forward,haller2019treesequence}, and new statistical paradigms for modeling those data \citep{petkova2016visualizing, ringbauer2017inferring, ringbauer2018estimating, conStruct, alasadi2018estimating} are together bringing an understanding of the geographic distribution of genetic variation into reach. The goal of this review is to frame some of the fundamental questions in spatial population genetics, and to highlight ways that new datasets and statistical methods can provide novel insights into these questions. In the process, we hope to provide an introduction for empirical researchers to the field. We focus on a small number of foundational questions about the biology and history of the organisms we study: where they are; how they move; where their ancestors were; how those quantities have changed over time, and whether there are groups of them. We discuss each question as a spatial population genetic problem, explored using the \emph{spatial pedigree}. It is our hope that by framing our discussion around the spatial pedigree, we can build intuition for -- and spur new developments in -- the study of spatial population genetics. \section{The spatial pedigree} The spatial pedigree encodes parent-child relationships of all individuals in a population, both today and back through time, along with their geographic positions (Figure \ref{spatial_pedigree}). If we had complete knowledge of this vast pedigree, we would know many evolutionary quantities that we otherwise would have to estimate from data, such as the true relatedness between any pair of individuals, or each individual's realized fitness. If we wanted to characterize the dispersal behavior of a species, we could simply count up the distances between offspring and their parents. Or, if we wanted to to know whether a particular allele was selected for in a given environment, we could compare the mean fitness of all individuals in that environment with that allele to that of those without the allele. The ``location'' of an individual can be a slippery concept, depending on the biology of the species in question (as can the concept of ``individual''). For instance, where in space does a barnacle hitchhiking on a whale live, or a huge, clonal stand of aspen? To reduce ambiguity, we will think of the location of an individual as the place it was born, hatched, or germinated. \begin{figure} \centering \includegraphics[width=\linewidth]{spatial_pedigree.pdf} \caption{ An example pedigree (left) of a focal individual sampled in the modern day, placed in its geographic context to make the spatial pedigree (right). Dashed lines denote matings, and solid lines denote parentage, with red hues for the maternal ancestors, and blue hues for the paternal ancestors. In the spatial pedigree, each plane represents a sampled region in a discrete (non-overlapping) generation, and each dot shows the birth location of an individual. The pedigree of the focal individual is highlighted back through time and across space. } \label{spatial_pedigree} \end{figure} In practice, we can never be certain of the exact spatial pedigree. Even if we could census every living individual in a species and establish the pedigree relationships between them all, we still would not know all relationships between -- and locations of -- individuals in previous, unsampled generations. And, in a highly dispersive species, or a species with a highly dispersive gamete, there may be only a weak relationship between observed location and birth location. Despite these complexities, the idea of the spatial pedigree is useful as a conceptual framework for spatial population genetics. Although it may be difficult or impossible to directly infer the spatial pedigree, we can still catch glimpses of it through the window of today's genomes. \subsection{Peeking at the spatial pedigree} Early empirical population genetic datasets were confined to investigations of a small number of individuals genotyped at a small number of loci in the genome. Many of the statistics measured from early data, such as $\pi$, $\theta$, or $F_{ST}$, rely on averages of allele frequencies at a modest number of loci, and thus reflect mostly deep structure at a few gene genealogies. These statistics are informative about the historical average of processes like gene flow acting over long time scales, but are relatively uninformative about processes in the recent past, or, more generally, about heterogeneity over time. However, the ability to genotype a significant proportion of a population and generate whole genome sequence data for many individuals is opening the door to inference of the recent pedigree via the identification of close relatives in a sample. In turn, we can use this pedigree, along with geographic information from the sampled individuals, to learn about processes shaping the pedigree in the recent past. \subsection{Simulating spatial pedigrees} It has only recently become possible to simulate whole genomes of reasonably large populations evolving across continuous geographic landscapes. Below, we illustrate concepts with simulations produced using SLiM v3.1 \citep{haller2018forward}, which enables rapid simulation of complex geographic demographies. We recorded the genealogical history along entire chromosomes of entire simulated populations as a \emph{tree sequence} \citep{haller2019treesequence}. In most simulations, we retained \emph{all} individuals alive at any time during the simulation in the tree sequence, allowing us to summarize not only genetic relatedness but also genealogical relatedness (e.g., to identify ancestors from whom an individual has not inherited any parts of their genome). We used tools from \texttt{pyslim} and \texttt{tskit} \citep{kelleher2018efficient} to extract relatedness information, and plotted the results in \texttt{python} with \texttt{matplotlib} \citep{hunter2007matplotlib}. Using SLiM's spatial interaction capabilities, we maintained stable local population densities by increasing mortality rates of individuals in regions of high density, and chose parameter values to generate relatively strong spatial structure (dispersal distance between 1 and 4 units of distance and mean population density 5 individuals per unit area). Our code is available at \url{https://github.com/gbradburd/spgr}. This new ability to not only simulate large spatial populations, but also to record entire chromosome-scale genealogies as well as spatial pedigrees, has great promise for the field moving forward. \subsection{Estimating ``effective'' parameters from the spatial pedigree} \begin{quote} \textit{ On one hand, every single one of my ancestors going back billions of years has managed to figure it out. On the other hand, that's the mother of all sampling biases.} \hfill \textit{-- Randall Munroe, xkcd:674} \end{quote} Inferences about the past based on those artifacts that have survived to the present are fraught with difficulties and caveats in any field, and population genetics is no exception. The ancestors of modern-day genomes are \emph{not} an unbiased sample from the past population -- they are biased towards individuals with more descendants today. It is obvious that we cannot learn anything from modern-day genomes about populations that died out entirely, but there are more subtle biases. For example, if we trace back the path along which a random individual today has inherited a random bit of genome, the chance that a particular individual living at some point in the past is an ancestor is proportional to the amount of genetic material that individual has contributed to the modern population. If we are looking one generation back, this is proportional how many offspring they had, i.e., their fitness. If we are looking a long time in the past (in practice, more than 10 or 20 generations \citep{BartonEtheridge2011fitness}), this is their \emph{long-term fitness}. Individuals from some point in the past who have many descendants today may or may not look like random samples from the population at the time. Different methods query different time periods of the pedigree, and are thus subject to these effects to different degrees. A familiar example of the limits of inference is the difference between ``census'' and ``effective'' population size \citep{Wright_1931,Charlesworth2009}. More subtle is the difference between dispersal distance ($\sigma$) and ``effective dispersal distance'' ($\sigma_e$) \citep[reviewed in][]{Cayuela2018demographic}. Both are mean distances between parent and offspring: $\sigma$ is the average observed from, say, the modern population, but $\sigma_e$ is the mean distance between parent and offspring along a lineage back through the spatial pedigree. The difference arises because lineages along which genetic material is passed do not give an unbiased sample of all dispersal events; they are weighted by their contribution to the population. For instance, if there is strong local intra-specific competition, individuals that dispersed farther from their parents (and their siblings) may have been more likely to reproduce and be ancestors of today's samples, which would make $\sigma_e > \sigma$. On the other hand, if there is local adaptation, individuals may be dispersing to habitats dissimilar to that of their parents and are unlikely to transmit genetic material to the next generation because they are maladapted to the local environment, and so $\sigma_e < \sigma$ \citep[for a review, see][]{wangbradburd2014}. \section{Things we want to know} \subsection{Where are they?} Perhaps the first things we might use to describe a geographically distributed population are an estimate of the total population size and a map of population density across space. Quantifying abundance and how it varies can be crucial, e.g., for understanding what habitat to prioritize for conservation \citep{zipkin2018synthesizing}, which regions have higher population carrying capacities than others \citep{roughgarden1974}, or whether a particular habitat is a demographic source or sink \citep{pulliam1988sources}. The best measure of population density would be a count of the number of individuals occurring in various geographic regions, and the best measure of total population size would be the sum of the counts across all regions. How close can population genetics get us to estimating these quantities by indirect means? Some fundamental limitations are clear: for instance, if we only sample adults, we cannot hope to estimate the proportion of juveniles that die before adulthood. None of our sampled genetic material inherits from these unlucky individuals, so they are invisible as we move back through the pedigree. In addition, it is tricky to separate the inference of population density from that of dispersal, as the rate of dispersal to or from a region of interest governs whether it makes sense to consider the pedigree in that region on its own. Partly because of this issue, it is also difficult to estimate total size from a sample of a non-panmictic population, and so it is more intuitive to discuss local density first, then scale up to the problem of total population size. The spatial pedigree contains a record of both total and regional population sizes, and we can use the genomes transmitted through it to learn about these quantities. \begin{figure} \centering \begin{subfigure}{0.95\textwidth} \centering \includegraphics[width=\linewidth]{valley_density} \caption{map of simulation scenario} \label{valley_map} \end{subfigure} \begin{subfigure}{0.95\textwidth} \centering \includegraphics[width=\linewidth]{valley_heterozygosity} \caption{individual heterozygosity} \label{valley_het} \end{subfigure} \caption{ \textbf{(a)} Map of population density of the simulated population scenario we use for examples throughout. Populations have local density-dependent regulation within two valleys with high local carrying capacity (indicated by contours), separated and surrounded by areas with lower carrying capacity. The western valley has a carrying capacity about twice as large as that of the eastern valley. \textbf{(b)} Heterozygosity of a sample of 100 individuals across the range. Circle sizes are proportional to heterozygosity, and circle color indicates relative values (green: above the mean; white: mean; purple: below the mean). Low heterozygosities occur on the edges of the range, and, because there is a strong barrier between the two valleys, mean heterozygosity is decreased by about 40\% in the lower-density eastern valley. } \label{pop_density} \end{figure} \subsubsection{Population density} Genetic information about population sizes or densities most clearly comes from numbers and recency of shared ancestors, i.e., the rate at which \emph{coalescences} between distinct lineages occur as one moves back through the pedigree. The relationship between population density and coalescence is, in principle, straightforward: with fewer possible ancestors, individuals' common ancestors tend to be more recent. Some calculations may be helpful to further build intuition (although the details of the calculations are not essential to what follows). Consider the problem of inferring the total size of the previous generation in a randomly-mating population from the number of siblings found in a random sample of size $n$. There are $x (x-1) / 2$ sibling pairs in a family with $x$ offspring, so the probability that, in a population of size $N$, a given pair of individuals are siblings in that family is $x(x-1)/N(N-1)$. Averaging across families, the probability that a given pair of individuals are siblings (in any family) is therefore $\mathbb{E}[X (X-1)] / (N-1)$, where $X$ is the number of offspring in a randomly chosen family. This implies that in a sample of size $n$, $n(n-1)/2$ divided by the number of observed sibling pairs provides an estimate of \emph{effective population size}, $N_e = N/\mathbb{E}[X(X-1)]$. A similar argument appears in \citet{mohle2003cpd}; also note this is \emph{inbreeding} effective population size (see \citet{wang2016prediction} for a review of different types of ``effective population size''). In other words, we should be able to use relatedness to estimate population size up to the factor $\mathbb{E}[X(X-1)]$, which depends on demographic details. This same logic can be applied locally: the (inbreeding) effective population density near a location $x$, denoted $\rho_e(x)$, can be defined as the inverse of the rate of appearance of sibling pairs near $x$, per unit of geographic area and per generation \citep{barton-depaulis-etheridge}. \details{ Let $P$ denote the probability that two diploids sampled from the population are siblings, and let $Q$be the probability that randomly sampled chromosomes from two randomly sampled diploids inherit from the same parental chromosome at a randomly chosen locus. Claim: Assuming monogamy (no half-sibs), $1/P$ is ``diploid inbreeding $N_e$'', defined (in \citet{ewens2004mpg}) to be $1/(2Q)$. (Note the caveats about diploidy do not appear in Ewens.) Proof: Under monogamy, the chance a random locus on random chromosomes from the two diploids are IBD from a common parent is $1/2$, so $Q = P/2$. } We can extend this line of reasoning to see that the local density of close relatives should reflect local population size. The chance that two geographic neighbors actually \emph{are} siblings decreases with the number of ``possible nearby parents'': \citet{wright1946isolation} quantified this with the \emph{neighborhood size}, $N_\text{loc} = 4 \pi \rho_e \sigma_e^2$, where $\pi$ is the mathematical constant, $\rho_e$ is the effective population density, and $\sigma_e$ is the effective dispersal distance. Each pair of siblings gives a small amount of information about population density within distance $\sigma_e$ of the pair. The more distant the coalescent event relating a pair of individuals, the vaguer the information they provide about population density, because there is greater uncertainty both in the inference of their precise degree of relatedness from genetic data, and in the location of their shared ancestors. Because genetic estimates of population size derive from rates of coalescence, they generally can only be used to estimate population sizes in the locations and times where those coalescences occur. Relatives up to recent cousins can be identified in a large sample to varying degrees of certainty from genomic data \citep[reviewed in][]{wang2016prediction}, using multilocus genotypes \citep{nomura2008estimation,WaplesWaples2011,Wang_2014}, shared rare alleles \citep{NovembreSlatkin2009}, or long shared haplotypes \citep[e.g.,][]{li2014relationship}. An alternative approach to estimating local density is to measure the rate of genetic drift in an area. To do this, one compares allele frequencies in at least two samples collected in a region in different generations, either at different points in time, or, in a species with overlapping generations, between contemporaneous individuals of different life stages, e.g., saplings and mature trees \citep{WilliamsonSlatkin1999}. The rate of drift is governed by, and therefore provides an estimate of, local population size; this is analogous to the \emph{variance effective size} of a population \citep{ewens2004mpg,Charlesworth2009,wang2016prediction}. Because these approaches are pinned to the recent past, either by the generations sampled or by the degree of closeness of relatives, they should offer a more accurate estimate of recent population density than heterozygosity does, especially when density has changed over time. \subsubsection{Total population size} Estimates of the largest geographic scale -- total population size -- turn out to be sensitive to changes over the longest time scales. Total effective population size is often estimated using measures of genetic diversity such as $\pi$ \citep{NeiLi1979,Tajima89}, the mean density of nucleotide differences between two randomly sampled chromosomes. Because each such difference is the result of a mutation sometime since the chromosomes' most recent common ancestor at that location on the genome, $\pi$ is equal to twice the mean time to most recent common ancestor within the sample, multiplied by the mutation rate. In other words, if the per-nucleotide mutation rate is $\mu$, and $2T$ is the mean length of a path through the pedigree along which two samples have inherited a random bit of genome from their most recent common ancestor, then $\pi \approx 2 T \mu$. The quantity $T$ itself is an interesting summary of the pedigree, and depends on geography, sampling, and dispersal in complex ways. What does it have to do with population size? In a randomly mating, diploid population of constant effective size $N_e$, the discussion above implies that $T = 2N_e$. In practice, populations are rarely constant, and so this is viewed as an average over the last few $N_e$ generations. \subsubsection{Heterozygosity and population density} We have seen that local population size is reflected in the pedigree through rates of shared ancestry: all else being equal, smaller populations should have more shared ancestry and therefore less overall genetic diversity. To gain intuition, we can look at how genetic diversity on the smallest scale -- heterozygosity -- behaves in a simulated example. Consider two adjacent valleys, one densely populated, the other sparsely populated, but both equal in geographic area and separated by a barrier to dispersal (Figure \ref{pop_density}\subref{valley_map}). In general, we expect pairs of individuals in the low density valley to have shared ancestors in the more recent past than pairs of individuals in the densely populated valley. This happens simply because each group of siblings makes up a larger proportion of the more sparsely populated valley. Indeed, individuals in the sparsely populated valley have more shared ancestors in the more recent past, so the two chromosomes sampled in each individual from that valley are more closely related, i.e., have lower heterozygosity, as shown in Figure \ref{pop_density}\subref{valley_het}. Heterozygosity correlates with population density in this example with a strong barrier, but does it predict relative density more generally? Differences in heterozygosity can be shaped by other forces. For example, we might also expect a similar difference in heterozygosity if the two valleys had the \emph{same} population density per unit area, but one valley was larger than the other, because heterozygosity reflects population size. Or, if dispersal distances tend to be shorter in the more densely populated valley -- e.g., because resources are more plentiful, so that individuals do not have to disperse as far to find food -- there may be more inbreeding over short distances, despite higher genetic diversity within the valley as a whole. And, of course, modern population densities may not be well-predicted by historical densities. Migration into and out of a region presents another complication. Roughly speaking, geographic patterns of relatedness are determined by a tension between population size and migration. As discussed above, genealogical relationships form on a time scale determined by population density, because in a geographic region containing $N$ individuals, the chance that two individuals are siblings is of order $1/N$. Shared ancestry -- and thus, genetic variation -- is spatially autocorrelated to the extent that this process of coalescence brings lineages together more quickly than migration moves them apart, as one traces individuals' ancestry back through the pedigree. If the migration rate into a geographic region is much greater than $1/N$ -- i.e., if more than a few individuals in each generation had parents living outside of the region -- then the pedigree in a region cannot be considered autonomously. In other words, regions cannot be analyzed independently unless a region of interest sees less than one migrant per generation (i.e., outside the parameter regime of the structured coalescent \citep{nagylaki1998}). \subsection{How do they move?} Dispersal is fundamental to many questions in ecology and evolution, such as predicting the spread of pathogens \citep{BiekReal2010}, responses to climate change \citep{parmesan2006}, or population demography and dynamics \citep{schreiber2010interactive}. We use the term ``dispersal'' to refer to the process that governs the displacement between geographic locations of parent and offspring. For some species, it may be feasible to directly measure dispersal using, e.g., telemetry or banding \citep{Cayuela2018demographic}, but this is often prohibitively expensive or difficult. Although we usually do not know the spatial locations of ancestors in the pedigree, the spatial locations of modern individuals can give strong clues about this. \subsubsection{Dispersal (individual, diffusive movement; $\sigma$)} We call the absolute value of the spatial displacement between parent and offspring locations the \emph{dispersal distance}, and refer to it as $\sigma$. The dispersal distance describes the quantity one could calculate by, e.g., collecting a large number of germinating seeds and averaging the distance from those seeds to their two parents. It determines how quickly spatial populations mix: larger dispersal spreads relatedness, and thus genetic variation, throughout the species' range faster. Dispersal distance could be trivially estimated by taking the average of these displacements across history if we knew the spatial pedigree through time without error. In practice, we often are only able to directly observe the location of individuals in the present day. However, spatial distances between individuals of different levels of relatedness give us information about dispersal distance, even without parental locations. For example, the distance between siblings is the result of two dispersals, so an average of this distance over many pairs of siblings gives an estimate of $2 \sigma$. The mean squared displacement along a path of total length $n$ through the pedigree is $\sigma^2 n$: first cousins would give four times the dispersal distance, and so forth. This spatial clustering of close relatives is shown in Figure \ref{fig:dispersal}\subref{cousin_map}. Unfortunately, basing an estimator of $\sigma$ on this observation is is usually infeasible in practice, unless a large, unbiased fraction of the population has been genotyped \citep[e.g.,][]{Aguillon2017deconstructing}. Empirical datasets do not usually contain many close relatives, but using phylogenetic methods on non-recombining loci (e.g., the mitochondria), we can obtain good estimates of times since common ancestor between much more distantly related individuals. This general idea was put into practice by \citet{neigel1993application}, who used the spatial locations of samples and their mitochondrial tree to infer $\sigma$ using phylogenetic comparative methods. However, the relationship between age of common ancestor and distance apart clearly can only apply if the geographic distance it predicts is much less than the width of the species range. In many species this is not true, because the typical time to common ancestor between two sampled individuals is long enough for their lineages to have crossed the species range several times \citep{barton1995genealogies}. Instead of identifying close relatives, we might use the decay of mean genetic relatedness with distance (shown in Figure \ref{fig:dispersal}\subref{ibd}) to learn about dispersal. Empirical studies usually find that the mean time since most recent common ancestor of two individuals at a random point on the genome is larger for more distant individuals \citep{epperson2003geographical,charlesworth2003effects,sexton2013genetic}, and this relationship of ``isolation by distance'' clearly should contain some information about $\sigma$. An approximate formula for this relationship in homogeneous space (Malec\'ot's formula) can be derived in various ways \citep{malecot, sawyer1976branching, barton1995genealogies, rousset_1997, barton-depaulis-etheridge, robledoarnuncio2010isolation, ringbauer2017inferring, alasadi2018estimating}, but is composed of two parts: (a) how long has it been since the two individuals last had ancestors that lived near to each other, and (b) how long before that did they actually share an ancestor. The second part is not well understood, but \citet{malecot} assumed that the second stage acts as in a randomly mating population with some local effective size, $N_\text{loc}$. \citet{rousset_1997} used this formula to show that the slope of $F_{ST}$ against the logarithm of distance is under these assumptions an estimator for Wright's neighborhood size ($4 \pi \rho_e \sigma_e^2$). See \citet{barton1995genealogies} for more discussion of these methods. \begin{figure} \centering \begin{subfigure}{0.8\textwidth} \centering \includegraphics[width=\linewidth]{valley_cousins.pdf} \caption{map of relatives} \label{cousin_map} \end{subfigure} \begin{subfigure}{0.7\textwidth} \centering \includegraphics[width=\linewidth]{valley_ibd.pdf} \caption{isolation by distance} \label{ibd} \end{subfigure} \begin{subfigure}{0.8\textwidth} \centering \includegraphics[width=\linewidth]{valley_line_flux.pdf} \caption{dispersal flux} \label{valleyflux} \end{subfigure} \caption{ \textbf{(a)} Map of close genealogical relatives of four focal individuals. Geographic locations of genealogical relatives are shown as larger triangles, with one color for each focal individual, with triangle size proportional to the expected proportion of genome shared (i.e., $2^{-k}$, where $k$ is the number of steps in the shortest path through the pedigree to the focal individual). \textbf{(b)} Genetic against geographic distance between each of four focal individuals and 100 other individuals, from the same map, and using the same colors, as in \textbf{(a)}. Genetic distance (calculated as expected sequence divergence) increases with geographic distance within and between each valley at similar rates, but levels off within each valley at different values due to different population sizes. \textbf{(c)} Flux across two boundaries on the same continuous map as \textbf{(a)}. All individuals across about 8 generations are shown as small dots, and every parent-child relationship that crosses each of the dotted lines is illustrated by an arrow, colored either red (if it crosses west-to-east) or blue (east-to-west). } \label{fig:dispersal} \end{figure} \subsubsection{Dispersal on heterogeneous landscapes} Of course, organisms do not live on featureless toroids, and individuals in one part of a species' range may disperse more than those in another due to heterogeneity in their nearby landscape. In spatial population genetics, one common way to describe this heterogeneity is with a spatial map of ``resistance''. The resistance value of a portion of the map is inversely proportional to the speed that organisms tend to disperse at, or (equivalently) the distance they tend to travel, when in that area. These models were introduced to spatial population genetics by Brad McRae \citep{McRae2006,McRae_Beier_2007,McRae2008}, and represented an important step forward in modeling dispersal (over, e.g., least-cost path analysis). However, resistance models do not allow spatial differences in dispersal variance or asymmetry in gene flow, as would be seen up a fecundity gradient or following a bias in offspring dispersal downwind. Note furthermore that we are distinguishing the ``resistance model'' of organism movement from the (current) methods used to fit such models; as implemented, ``resistance'' methods make use of an approximation that can result in estimates that diverge widely from the truth, especially if gene flow is asymmetric \citep{lundgren2018populations}. One of the most promising current spatial methods is MAPS \citep{alasadi2018estimating}, which uses information about long shared haplotype tracts (recent ancestry) to build a map of both local population size and dispersal ability. MAPS builds on EEMS \citep{petkova2016visualizing}, an analogous method based on resistance distances. Both methods produce spatial maps by averaging over discrete-population models embedded in geography, and thus share properties of both discrete and continuous population models. In particular, the underlying dispersal model is still based on a migration rate (proportion of individuals replaced) between randomly mating demes. Next we discuss a spatial analogue of this quantity. \subsubsection{Dispersal flux} We would often like to measure the ``amount of gene flow'' across some barrier or between two geographic regions. To do this, we can ask for the number of dispersal events in a given year that cross a given line drawn on a map (e.g., the boundary between two adjacent regions) -- that is, how many individuals are born each year whose parents were born on the other side of the line? This quantity, which we call the \emph{dispersal flux} across the boundary, is useful for investigating connectivity between different areas and the role of the landscape in shaping patterns of dispersal. Dispersal flux is a geographical analogue of the ``migration rate'' between discrete, isolated populations. Note that dispersal flux is not constrained to be equal in both directions across a boundary: it may be easier to disperse down-current than up-current. For instance, Figure \ref{fig:dispersal}\subref{valleyflux} shows the number of dispersal events crossing two lines on our simulated valley landscape over a few generations. The line on the left goes through the denser valley, and so has a large flux in each direction. The line on the right goes along the edge of the sparser valley, and so has lower flux overall, and more east-to-west flux (more red than blue arrows crossing it) due to the higher population density to the east of the line. As before, if we had complete knowledge of the spatial pedigree, we could calculate the flux across any line simply by counting the number of parent-offspring pairs that span it. However, it is rare to find any one individual that is a direct genetic ancestor of another in a dataset (apart from perhaps some parent-child relationships). As a result, we almost never infer a direct chain of dispersal events, only dispersal since coalescence events. The likely locations of these coalescent events depends on the maps of population density and fecundity, thus entangling the problems of inferring dispersal flux and population density. For instance, across a barrier with low flux, the average time to coalescence for pairs of individuals on opposite sides of the line is longer than that between individuals on the same side \citep{bedassle,Duforet-Frebourg_Blum_2014,ringbauer2018estimating}. Flux across a line is also related to mean dispersal distance, $\sigma$, discussed above. The expected flux across a straight boundary in a homogeneous area, per unit time and per unit of boundary length, is equal to the birth rate per unit area multiplied by $2 \sigma / \pi$ \citep[where $\pi$ is the mathematical constant,][]{buffon1777}, so estimates of flux can be converted to estimates of dispersal distance. \subsection{Where were their ancestors?} Above, we have discussed how population dynamics of movement and reproduction are reflected in the spatial pedigree. A complementary view is to start with individuals sampled in the present day, then, looking backwards in time, to ask where in space they have inherited their genomes from, i.e., where their ancestors lived. Because the signal in genetic data comes from shared ancestry and coalescence in the pedigree, thinking from this reverse-time perspective is useful in interpreting genetic data. However, summaries of how ancestry spreads across space through the pedigree can be important in their own right. For example, many humans are interested in the locations of their own ancestors back in time. More generally, we are often also interested in the partitioning of genetic diversity across space, e.g., quantifying the strength of inbreeding locally, or assessing the capacity of a population to become locally adapted. Spatial distributions of ancestry compared across sections of the genome could also be informative about other processes, such as the origins and mechanisms of selective sweeps. \subsubsection{Geographic distribution of ancestry} As one looks further back in time, the geographic distribution of an individual's ancestors is determined by the history of population size changes and movements. At any point in the past, each portion of each individual's genome can be associated with the ancestor from whom they inherited it. Their genetic ancestry can therefore be apportioned across space according to the locations of the ancestors from whom they inherited their genome. There are a number of natural questions that arise from a description of this process. How much of an average individual's ancestry is still within a given region, at some point in the past? How long in the past was it since a typical individual in one location had an ancestor in another geographic region (say, the next valley over)? How far back in time do you have to go before the average proportion of ancestry that an individual inherits from the local region they live in drops below (say) 90\%? This spatial distribution of \emph{all} genetic ancestors is depicted at several points back in time for four individuals in a simulation in Figure \ref{ancestry_spread}. As we look further back in time, we can see the ``cloud of ancestry'' spread out across space. The spread is diffusive, i.e., the mean displacement of a given $n^\text{th}$-generation ancestor is of order $\sigma_e \sqrt{n}$, as long as this is small relative to the width of the region. Not shown on the map are the many genealogical ancestors from which the focal individuals have not inherited genome -- these spread at constant speed rather than diffusively \citep{kelleher2016spread}, so that even by 15 generations in the past, each focal individual is genealogically descended from nearly everyone alive, even those living in the other valley \citep{chang1999}. \begin{figure} \begin{subfigure}{0.85\textwidth} \centering \includegraphics[width=\linewidth]{valley_ancestry_01.pdf} \caption{one generation ago} \label{1gen} \end{subfigure}\\ \begin{subfigure}{0.85\textwidth} \centering \includegraphics[width=\linewidth]{valley_ancestry_60.pdf} \caption{sixty generations ago} \label{60gen} \end{subfigure}\\ \begin{subfigure}{0.85\textwidth} \centering \includegraphics[width=\linewidth]{valley_ancestry_300.pdf} \caption{three hundred generations ago} \label{300gen} \end{subfigure} \caption{ Spatial locations of the ancestors of four individuals: at \textbf{(a)} one, \textbf{(b)} sixty, and \textbf{(c)} three hundred generations in the past. All individuals from whom the four individuals have inherited genome are denoted by a circle, with one color for each individual, and with circle area proportional to the amount of genome inherited. The landscape is the same as in Figure \ref{fig:dispersal}. Since the simulation uses overlapping generations, ancestors of different degrees are present at the same time. } \label{ancestry_spread} \end{figure} Although Figure \ref{ancestry_spread} does not highlight ancestors \emph{shared} by any pair of the focal individuals, it is clear that these occur in the points of overlap between their two clouds of ancestry. These shared ancestors may be informative about relative population densities in the two valleys. \subsubsection{Relative genetic differentiation} In the ``two valley'' simulation of Figure \ref{ancestry_spread}, ancestors are shared within valleys over the time period shown, but not between valleys. The difference in the geographic distribution of shared ancestors results in higher relatedness between the pairs of individuals from the same valley, and it underlies all measurements of relative genetic differentiation. The most common measure of how much more closely related neighbors are to each other relative to the population as a whole is $F_{ST}$ \citep{Wright1951}, which can be thought of as estimating one minus the ratio of mean coalescence time within subpopulations to that within the entire population \citep{slatkin_1991inbreeding}. The normalization by mean overall coalescence time makes this measure relative, and therefore comparable across populations of different sizes. In stable populations, relative genetic differentiation is determined by the tension between geographic mixing (due to dispersal flux between areas) and local coalescence (determined by population density). In the more remote past, each individual's ancestors are distributed across all of geography, so that the long-ago portion of the pedigree looks like that of a randomly mating population. Tracing the pedigree backward in time, remote ancestors have ``forgotten" the geographic position of their modern-day descendants. The transition between these two phases -- recent spatial autocorrelation (``scattering") and distant random mating (``collecting") \citep{Wakeley1999,wilkins2004separationoftimescales} happens on the time scale over which a lineage crosses the species range \citep{Wakeley1999}. Since lineage motion is diffusive, in a continuous range of width $L \sigma_e$, coalescences between lineages of distant individuals happen on a time scale of $L^2$ generations. Relative genetic differentiation is determined by the likelihood that coalescence between two nearby individuals occurs during the scattering phase -- i.e., by the length of time that two spatial clouds of ancestry of Figure \ref{ancestry_spread} are correlated with each other, relative to the local effective population size. So, in a species with limited dispersal (i.e., small $\sigma_e$), $F_{ST}$ may not be best measure of this quantity -- others are possible that depend less on the deep history of the population. For instance, one could ask for the proportion of the genomes of two neighbors inherited in common from ancestors in the last $T$ generations relative to the same quantity for distant individuals, where $T$ is chosen to reflect the time scale of interest. The appropriate measure will depend on the application at hand. \subsection{Clustering, grouping, and ``admixture''} Many tools for modern analysis of genetic data partition existing genetic variation into clusters labeled as (discrete) populations \citep[e.g.,][]{STRUCTURE, ADMIXTURE} The ubiquity of gene flow means that any conceptual model of discrete populations must also include \emph{admixture} between them. Models of discrete population structure and admixture provide visualizations that can be helpful for describing and making sense of patterns of relatedness and genetic variation. Coupled with a quantification of relative genetic differentiation, they can be used in conservation to delineate discrete management units. However, in practice, these discrete groups may in fact be determined by clustering of sampling effort rather than any intrinsic divisions within the population. Explicitly incorporating the geographic proximity of samples can help alleviate these concerns \citep{spacemix,conStruct}, but it would still be desirable to delineate groups in a way explicitly linked to the actual history of relatedness, i.e., the spatial pedigree. The real-world situation in which admixture between discrete populations is perhaps most clearly defined is when populations that have been completely separated for a long period of time come back into contact. In this case, the discrete populations are defined by partitioning \emph{ancestral} individuals, and admixture of subsequent generations is determined by inheritance from them. For instance, suppose that the two valleys of our running example were isolated during a long period of glaciation, followed by glacial retreat and expansion into secondary contact. The valleys clearly act as discrete populations during glaciation, during which there are are few if any pedigree connections between the valleys. Pedigrees only start to overlap more recently between individuals in each valley. To obtain an admixture proportion, we can fix some ``reference'' time in the past, and label the genomes of each individual in subsequent generations according to which of the two valleys it inherited from at the reference time. This is shown in Figure \ref{postglacial_expansion}\subref{8gen}: eight generations after contact, this quantity clearly reflects the history of isolation; individuals in or near each valley have inherited most of their genomes from ancestors in the closest valley. However, if we return 75 generations later, we see a more complicated story (Figure \ref{postglacial_expansion}\subref{75gen}). The continued spatial mixing has resulted in a significant portion of ancestry in the west valley inherited from glacial-era ancestors in the east valley, and vice versa. Further complicating the issue, the west-to-east flux across the ridge between the valleys is higher than that in the opposite direction because the western valley has a higher population density. As a result, a much higher proportion of the genomes in the eastern valley are now inherited from individuals that, during glaciation, were found in the western valley. \begin{figure} \centering \begin{subfigure}{0.85\textwidth} \centering \includegraphics[width=\linewidth]{valley_admixture_new} \caption{eight generations post-contact} \label{8gen} \end{subfigure} \begin{subfigure}{0.85\textwidth} \centering \includegraphics[width=\linewidth]{valley_admixture_old} \caption{seventy-five generations post-contact} \label{75gen} \end{subfigure} \caption{ Admixture proportions after a recent secondary contact. Each pie shows the proportion of a diploid individual's genomes that inherit from the western (red) and eastern (blue) valleys, respectively. The plots show the geographic distribution of that ancestry \textbf{(a)} Eight generations, and \textbf{(b)} seventy-five generations after a barrier along the top of the ridge is removed. } \label{postglacial_expansion} \end{figure} This simulation highlights both the relevance of a model of discrete population structure and admixture to spatially continuous data, and also its limitations. Outside the time during and immediately following glaciation, describing genotyped individuals on this landscape using a model of discrete populations with admixture becomes less helpful. Without a concrete interpretation based in the population pedigree, partitioning genetic variation into discrete groups, and labeling of samples as admixed between those groups can encourage the incorrect interpretation that discrete populations are Platonic ideals, real and unchanging. \subsection{How have things changed over time?} As we have discussed above, different methods are sensitive to signal from different time slices of the pedigree. Of course, the geographic distributions and dispersal patterns of most species, not to mention the landscape itself, have changed over the time scale spanned by the pedigree of modern individuals. For example, high-latitude tree populations may only have been established following the retreat of the glaciers some tens of generations ago \citep{WhitlockMcCauley1999}, and invasive species may have entered their current environment even more recently than that. In addition to organisms moving themselves across landscapes, landscapes are often changing out from under organisms' feet. Anthropogenic land use and global climate change are radically altering both where organisms can live and where they disperse \citep{parmesan1999}. The result is that many empirical systems are not in equilibrium, so that the dynamics we estimate from measurements of extant individuals may not be representative of those in the past. Exacerbating this problem, it can take a long time to reach equilibrium in areas of high population density or across regions of low flux \citep{CrowAoki1984group, whitlock1992temporal, slatkin1993isolation, WhitlockMcCauley1999}. Theory and methods that can address change across both time and space are still lacking, and present an exciting set of challenges for the field. \subsubsection{Difficult discontinuous demographies} The specter of spatial discontinuity in the pedigree -- those situations in which none of the individuals living in a particular region at a particular point in time are descended from any of the individuals who had inhabited that region at some point in the past -- haunts the inference of historical processes from modern genetic data. Spatial discontinuities in the pedigree occur when when regions become unoccupied (e.g., due to ecological disturbance or agonistic interactions) and are recolonized by immigrants from elsewhere. Discontinuity is expected over long enough time scales that ranges have shifted, and vicariance--secondary-contact events have occurred. There is abundant evidence of large-scale population movements or changes in human datasets that include ancient or historical samples \citep{skoglund2014investigating, PickrellReich2014, lazaridis_ancient_2014, haak2015massive, joseph2018inference}, as well as in other species over recent time scales using museum specimens \citep{bi2013unlocking,bi2019chipmunks}. Spatial discontinuity can pose a problem if the models we use for inference are predicated on the assumption that the observed geographic distribution of genetic variation was generated in the sampled geographic context. In principle, we can include large-scale population movement in our inference methods, but only if we have some clue that it has occurred. Identifying lack of fit due to such historical events remains an open problem. As we develop more datasets that include genotype data from historical individuals, we will better be able to evaluate the prevalence of spatial discontinuity and its effects on our inferences across natural systems. \subsubsection{Genealogical strata} The field of population genetics has many heuristics for genetic data; different types of genetic information are informative about events that occurred at different times in a population's history. For example, patterns of sharing of rare alleles can be informative about events in the recent past, and long shared haplotypes even more so. In contrast, pairwise statistics like $\pi$ or $F_{ST}$ mostly inform us about events long ago, on a scale of $N_e$ generations. Different statistics thus provide us with windows into different strata of the pedigree. Rates of sibling- and cousin-ship would shed light on the last few generations of history, but carries the (in many cases unreasonable) requirement of a sample that is a sizable fraction of the entire population. Methods for inferring the distant history of populations using a few samples are the most well-developed \citep[e.g.,][]{dadi,Li_Durbin2011,momi}, but these can incorporate very little in terms of geographic realism, and indeed much of the signal of geography may have washed out on this coalescent time scale \citep{wilkins2004separationoftimescales}. The length spectrum of long, shared haplotypes -- also known as ``identical-by-descent" (or IBD) segments -- can be used to peer into the strata of the pedigree between these two time scales. The lengths of segments of genome inherited in common by two individuals from $t$ generations ago scales roughly with $1/t$, these can carry substantial information about ancestors from only tens of generations ago. This fact has been used by \citet{alasadi2018estimating} to create estimated maps of population density and migration rate for different, recent periods of time. However, the different strata cannot be so cleanly disentangled -- e.g., although 1cM--long shared haplotypes are older on average than 2cM-long ones, the distributions of ages of these shared haplotypes overlap considerably. Moreover, the correspondence between shared haplotype length and age of common ancestor depends strongly on population size history \citep{ralph2013geography}. \section{Next steps for spatial population genetics} In this review we have focused on \emph{demographic inference} -- seeking to learn about past or present demographic processes from population genetic data. As demography -- birth, reproduction, death -- is the mechanism by which natural selection occurs, it is fundamental not only to history and ecology but also evolutionary biology. Describing the geographic distribution of genetic variation -- its patterns, the processes that have generated and maintained it, and its consequences -- is a fundamental goal of the field. We have already sketched out plenty of work for the field -- quantitative inference with continuous geography is for the most part an unsolved problem. Nonetheless, we describe below a few more areas in which we hope or expect further progress in the field to be made. \subsection{Selection} Some of the most important aspects of geographical population genetics we have not reviewed are related to natural selection. A significant avenue for future work is to develop methods that jointly estimate selection and demography for spatially continuous populations. We have mostly ignored this above, but clearly local adaptation and natural selection impact the structure of the pedigree, including its spatial patterns. For example, after a hard selective sweep, everyone in the population has inherited a single beneficial allele, and so the lineages of all extant individuals at that locus will pass through the lucky individual in whom that mutation occurred. There is a great deal known about the expected geographical action of selection, e.g., how beneficial alleles spread across space \citep{fisher1937wave,RalphCoop2010parallel,HallatschekFisher2014}, how locally adaptive alleles can be maintained in the face of gene flow \citep{slatkin1973geneflow,kruuk1999comparison,RalphCoop2015patchy}, or how hybrid zones are structured \citep{barton1985analysis,sedghifar_2015}. In all these situations, selection can produce dramatically different patterns in the genealogies of different regions of the genome. Incorporating selection into spatially continuous models will facilitate a greater union of population genetic processes and ecological models of population dynamics, and help shed light on important evolutionary questions. \subsection{Simulation and inference} Spatial population genetics suffers from a lack of concrete mathematical results that can be used for inference. Although we have a good understanding of the decay of expected pairwise relatedness with distance (e.g., the Wright--Malec\'{o}t formula), a deeper understanding of the coalescent process is required to make quantitative predictions of more complex population genetic statistics. How can we fill this gap? A recent advance in the field, which may help improve inference models with and without selection, has been the advent of powerful and flexible simulation methods, such as SLiM \citep{haller2018forward,haller2019treesequence} and msprime \citep{kelleher2016msprime}. These methods allow researchers to produce genome-scale datasets from simulations of arbitrary complexity. This capability offers an excellent pedagogical tool and opportunity to build intuition for patterns of genetic variation in complex scenarios for which theory may be lacking. In addition, these simulation methods can be used in statistical inference. For example, simulated datasets can be used in the training of machine learning methods \citep[e.g.,][]{SchriderKern2018}, or to compare between different generative models using approximate Bayesian computation \citep{MarjoramTavare2006modern}. Simulation-based inference presents an exciting way forward for problems that may be analytically intractable, although for large problems, the required computational effort is daunting. As an intermediate solution, a promising class of spatial coalescent models allows rapid simulation with geographically explicit models \citep{barton2010newmodel,guindon2016demographic}, although the precise relation to forwards-time demographic models is not well understood. \subsection{Identifiability and ill-posedness} Another important gap in current methods for spatial population genetics inference is a quantitative understanding of the limits of our ability to learn about quantities of interest. Demographic inference with population genetics data is an example of an \emph{inverse problem} -- the mapping from parameters to data is relatively well-understood, but the inverse map is not. Many inverse problems are \emph{ill-posed}, meaning that many distinct models give rise to statistically indistinguishable datasets, i.e., there is some degree of statistical nonidentifiability \citep{petrov2005well,stuart2010inverse}. For example, as with estimating effective population size using the site frequency spectrum \citep{Myers2008}, we may never be able to infer rapid changes in effective population density \citep[although see also][]{BhaskarSong2014descartes}. Likewise, the timing of heterogeneity in flux across a particular part of the landscape may be difficult to disentangle from the magnitude of its change, as is the case with migration/isolation models of dynamics in discrete demes \citep{sousa2011nonidentifiability}. More generally, it may be difficult to learn about local biases in the direction of flux, or large-scale flow in the average direction of dispersal, without genetic data from historical individuals. Mathematical theory and simulation-based tests of inference methods should allow us to further determine the spatial and temporal resolutions with which we can view history. \subsection{The past} The growing availability of genomic data from historical or ancient samples, collected from archaeological sites or museums, is one of the most exciting developments in population genetics, and has the potential to revolutionize the field of spatial population genetics. These historical data can provide a kind of ``fossil calibration,'' helping anchor spatial pedigrees in space and time. Although it may be unlikely that any particular genotyped historical individual is the direct genetic ancestor of any sampled extant individual, the geographic position of the historical sample and its relatedness to modern individuals is nonetheless informative about the geography of any modern individual's ancestors. These historical data can also illuminate temporal heterogeneity in some of the processes described in Section 3.4, which might otherwise be invisible in datasets comprised of only modern individuals. \section*{Conclusion} There is a long history of empirical research describing spatial patterns in genetic variation \citep{dobzhansky1947,human_blood_types,landscape_genomics_review}. Most population genetics inference methods assume a small number of randomly mating populations, and it is still unknown what effect realistic geographies have on these inferences. This is starting to change, however, as larger datasets with vastly more genomic data become available, giving us power to bring much more of a population's pedigrees into focus. In turn, the ability to study pedigrees and their geography over the recent past is bringing about a union between the fields of population genetics and population ecology. Measures of dispersal and density based on the pedigree can also inform the study of the factors governing the distribution and abundance of organisms over short timescales that might have previously been out of reach for population genetics. As datasets, theory, and methods in spatial population genetics continue to progress, it will be exciting to explore further integration of the two disciplines. \section*{Disclosure statement} The authors are not aware of any affiliations, memberships, funding, or financial holdings that might be perceived as affecting the objectivity of this review. \section*{Acknowledgments} The authors gratefully acknowledge Yaniv Brandvain, Graham Coop, John Novembre, Doug Schemske, and Marjorie Weber for helpful discussions about spatial population genetics, as well as Nick Barton, Graham Coop (again), Andy Kern, and Brad Shaffer for invaluable comments on the manuscript. \bibliographystyle{ar-style1}
{'timestamp': '2019-05-13T02:12:48', 'yymm': '1904', 'arxiv_id': '1904.09847', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.09847'}
arxiv
\section{Introduction} \label{sec:intro} In recent years, the world has witnessed an exponential increase in gun violence, morphing from isolated street crimes to incidences of mass shootings \cite{Howmanys35:online,Massshoo28:online,SantaFeS56:online}. Governments and private security agencies have been expanding the use of surveillance systems to monitor and secure public and private spaces. Mostly these surveillance systems are based on massive installations of camera-based surveillance systems which are mostly passive and where monitoring is delegated to the human operators. Usually, video from multiple CCTV cameras is streamed into a central station, where trained operators monitor these live footage, proactively watching for unusual activities and prohibited objects such as weapons. The operator’s ability to detect abnormality while monitoring a video feed is influenced by many variables including both technical (quality of images) and human factors such as age, experience, training and shift duration \cite{howard2013suspiciousness}. \begin{figure}[t] \begin{center} \captionsetup{justification=justified} \includegraphics[width=0.90\linewidth]{latex/images/teaser_1n_final_.pdf} \caption{\small{Automatic firearms detection: Oriented bounding boxes (\textcolor{magenta}{Magenta}) detected by the proposed OAOD algorithm exhibit better accuracy and localization compared to the RoI Trans \cite{Ding_2019_CVPR}(\textcolor{cyan}{Cyan}) and FRCNN \cite{ren2015faster}(\textcolor{blue}{Blue}) which suffer from miss-detections and poor localization. }} \label{teaser} \end{center} \vspace{-0.5cm} \end{figure} Studies have shown that the human ability to detect abnormalities from live feeds reduces as the number of simultaneous feeds increases \cite{van2005cctv, sulman2008effective}. The firearm based incidents are more difficult to detect since mostly they don't involve physical altercation but just the presence of the firearm changes the dynamics of the situation. A visual firearm detection system would not only be helpful in active security monitoring but also it would be vital in monitoring harmful content on social media. Such a novel scientific solution can be embedded in surveillance systems for significant improvement in identifying potential gun violence incidence. Despite an immense need to develop a firearms detection system, due to a number of challenges, no significant research work has yet been done in this direction. Visual firearm detection is inherently challenging due to intentional or unintentional occlusions, the close proximity of the object to the human body and design inspired for the camouflage. Existing visual object detectors (\cite{ren2015faster,redmon2016you,liu2016ssd}) despite being successful in detecting in a wide variety of common objects, do not perform well when dealing with firearms (Fig. \ref{teaser}). One of the reasons being that most of the existing object detectors predict object locations by looking at features in axis-aligned bounding boxes \cite{zhang2016faster, li2018scale, li2017perceptual, liu2019towards, ren2015faster,redmon2016you,liu2016ssd}. A physically thin and elongated structure of the rifles and small size of most guns, make these axis-aligned detectors inefficient due to low signal to noise ratio where the signal is the firearm signature and noise is everything else in the bounding box. This problem is evident in the case of firearms being carried by a person, the axis-aligned bounding box will tend to contain substantial information belonging to the background or non-firearm objects, like the person himself (Fig.~\ref{fig:aalign}). The inherent size \& shape variations of long and thin firearms, unfavorable viewing angles, and clutter make the detection more challenging than other objects such as human faces and vehicles. \begin{figure}[t] \begin{center} \captionsetup{justification=justified} \includegraphics[width=0.90\linewidth]{latex/images/axis_issue_newn.pdf} \caption{\small{Axis-Aligned Bounding Boxes (AABB) shown in \textcolor{green}{Green} are often wider than the actual object, hence features extracted from AABB are heavily affected by the background clutter. Oriented Bounding Boxes (OBB) shown in (\textcolor{magenta}{Magenta}), being aligned with the object, are relatively tighter and features pooled from OBB contain less noise from background clutter. }} \label{fig:aalign} \vspace{-0.5cm} \end{center} \end{figure} Recently some oriented object detection methods have also been proposed that try to detect Oriented Bounding Boxes (OBB) aligned with the objects. These algorithms target applications such as ships and aeroplanes in satellite images, and text in documents, by predicting oriented region proposals \cite{ma2018arbitrary,azimi2018towards}. However, this requires to have oriented boxes as a part of anchors at each location of the feature map, resulting in computational inefficiency due to a significant increase in the number of anchors. Also, for the training of region proposal network (RPN) and the detector itself, oriented boxes are needed as ground-truth. Annotating such boxes is quite a time consuming and erroneous, which is the reason that most datasets provide only axis-aligned boxes. To address these challenges, we propose an Orientation Aware multi-stage object detection system (OAOD), which is trained in a weakly supervised fashion, only on the axis-aligned bounding boxes (AABB) and orientation of the firearms. In our proposed system, RPN and orientation prediction are kept separate, allowing us to use a smaller number of anchors than oriented object detectors. In the first stage of our proposed system AABB and object orientation are jointly estimated, and in the second stage, a novel Oriented Proposal Generation (OPG) module is introduced to generate Oriented Region Proposal ($ORP$) by incorporating the predicted orientation information. The OPG is followed by Object Aligned Region of Interest pooling (OARoI-Pooling) to pool the features without background noise. Our proposed system predicts both axis-aligned as well as object aligned bounding boxes, while only being trained on the axis-aligned bounding boxes and orientation information in a weakly-supervised fashion. Main contributions of the current work include: \begin{itemize}[noitemsep,topsep=0pt] \item We propose a \textbf{weakly supervised} deep learning architecture to predict Oriented Bounding Boxes (OBB) without using OBB annotations while training. \item Orientation classification and regression module are proposed to predict orientation from the axis-aligned region proposals. \item An Oriented Proposal Generation (OPG) module is proposed to generate Oriented Region Proposals ($ORP$) followed by Object Aligned RoI-pooling (OARoI-Pooling) to pool target object features while discarding the background noise. Such a setup results in the features that are independent of the object's orientation simplifying the task of classification and bounding box regression. Thus improving the accuracy of classifier and bounding box regressor in the last stage. \item An extensive firearm dataset, ITU-Firearm (ITUF), is also proposed consisting of around 13647 annotated firearm instances in 10973 images. \item Our method achieves state-of-the-art performance compared to existing methods on the proposed ITUF dataset. \end{itemize} For a comprehensive analysis, the proposed OAOD algorithm is compared with five existing state-of-art axis-aligned object detection methods \cite{ren2015faster, redmon2017yolo9000, redmon2018yolov3, liu2016ssd, fu2017dssd} and three oriented object detection methods \cite{Ding_2019_CVPR, yang2018r2cnn, Xia_2018_CVPR}. The proposed OAOD has produced an excellent performance in terms of accuracy and stability compared to these existing methods. \section{Related Work} \label{sec:relatedwork} \textbf{Generic Object Detectors:} Significant progress has been made in developing deep-CNN based axis-aligned generic object detectors, which could be divided into two categories, including, multi-stage and single-stage detectors. Multi-stage detectors, generally contain the first stage of RPN that selects one of the predefined anchor boxes as the proposal at each location \cite{ren2015faster, he2017mask, lin2017feature, cai2018cascade, singh2018analysis}. The next stage is to regress the final bounding boxes and classify them to the object classes. The single-stage object detectors, like YOLO family \cite{redmon2016you,redmon2018yolov3,redmon2017yolo9000} and SSD \cite{liu2016ssd}, are well known for high detection speed but have been found to have lower performance \cite{huang2017speed}. Attributing to the class imbalance, Lin et al. \cite{lin2018focal} proposed focal loss, however, they still suffer from performance degradation while detecting small objects. The research community is putting efforts to make object detection proposal or anchor free \cite{duan2019centernet, law2018cornernet, Tian_2019_ICCV} though two-stage detectors \cite{singh2018analysis, singh2018sniper, liu2018path} still have better accuracy due to better region sampling. Axis-aligned object detectors do not handle thin and elongated objects detection challenge, where orientation makes object-size vs the AABB size disproportionate. \begin{table}[t] \centering \footnotesize \renewcommand{\arraystretch}{1.0} \tabcolsep=3.0pt\relax \caption{\footnotesize{An overview of different oriented object detection methods with respect to application domain, ground truth used during training and output bounding boxes (AABB or OBB).}} \begin{tabular}{ccccc} \hline \multirow{2}{*}{\textbf{Methods}} & \multirow{2}{*}{\textbf{Domain}} & \multirow{2}{*}{\textbf{\begin{tabular}[c]{@{}c@{}}Ground Truth\\ for Training\end{tabular}}} & \multicolumn{2}{c}{\textbf{Output}} \\ \cline{4-5} & & & \multicolumn{1}{c}{\textbf{OBB}} & \multicolumn{1}{c}{\textbf{AABB}} \\ \hline RRPN \cite{ma2018arbitrary} & Text Images & Oriented Boxes & $\checkmark$ & \\ \hline R2CNN++ \cite{yang2018r2cnn} & Aerial Images & Oriented Boxes & $\checkmark$ & $\checkmark$ \\ \hline DMP-Net \cite{liu2017deep} & Text Images & Oriented Boxes & $\checkmark$ & \\ \hline FOTS \cite{liu2018fots} & Text Images & Oriented Boxes & $\checkmark$ & \\ \hline ICN+FPN \cite{ azimi2018towards} & Aerial Images & Oriented Boxes & $\checkmark$ & $\checkmark$ \\ \hline RBox-CNN \cite{koo2018rbox} & Aerial Images & Oriented Boxes & $\checkmark$ & \\ \hline \begin{tabular}[c]{@{}c@{}}RoI-Trans \cite{Ding_2019_CVPR} \end{tabular} & Aerial Images & Oriented Boxes & $\checkmark$ & \\ \hline OAOD (Ours) & RGB Images & \begin{tabular}[c]{@{}c@{}}Axis-Aligned\\+Angle\end{tabular} & $\checkmark$ & $\checkmark$ \\ \hline \end{tabular} \label{papers:obb} \end{table} \textcolor{black}{ \textbf{Weakly Supervised Object Detectors:} Weakly supervised object detection has been broadly studied in last few years. Early approaches \cite{bilen2016weakly} exploited representation learned by deep convolutional neural network pre-trained on image classification task. In general features were pooled from the regions, indicated by region proposal generation process, image classification and object detection were jointly trained on these by back-propagating the image classification loss. \cite{tang2017multiple}, on the other hand proposed a Multiple Instance Learning to iteratively refine the object detector by back-propagating image-level labels through multiple object detection streams. Based on \cite{tang2017multiple}, another work proposed is proposal cluster learning using image level annotations for object detection \cite{tang2018pcl}. This is an iterative process and assign labels on the basis of proposal clusters for refinement of instance classifier. TS2C \cite{wei_2018_ECCV} exploits the weakly supervised object segmentation task to help the MIL based weakly supervised object detectors to concentrate on the whole object rather than just the discriminative parts. We present novel method using weakly supervised orientation information and axis-aligned bounding boxes for object detection with applications to firearms. } \textbf{Small Object Detectors:} In some small objects such as human faces contextual information may have significance for learning deep model \cite{hu2017finding}. Similarly, features from RPN have been used for small-sized pedestrian detection \cite{zhang2016faster}. Singh et al. proposed scale normalized training to address the problem of extreme-scale variations \cite{singh2018analysis}. Liu et al \cite{liu2018structure} also emphasized the significance of context and instance relationship for accurate object detection. However, in the case of firearms, most of the contextual objects may remain irrelevant and behave as noise by suppressing the required object information. \begin{figure*}[t] \begin{center} \captionsetup{justification=justified} \includegraphics[width=1.0\linewidth]{latex/images/flow_diagram_new_n.pdf} \vspace{-0.0cm} \caption{\small{ \textbf{The architecture of proposed OAOD Algorithm:} (a) computes deep features (b) outputs object and orientation classification along with respective AABB and orientation offsets (c) In Stage-2, the OPG module generates Oriented Region Proposals $ORP$ using predictions from Stage-1. (d) OARoI-Pooling is applied to pool orientation independent features followed by bounding box regression (e) The final regression output are then used to generate OBB using inverse transformation (Sec. \ref{sec:method-phase-2}). }} \label{fig:main-model} \end{center} \vspace{-0.5cm} \end{figure*} \textbf{Oriented Object Detectors:} Most of the recent oriented object detectors \cite{ma2018arbitrary, yang2018r2cnn, he2017deep, liu2018fots, azimi2018towards, Ding_2019_CVPR, koo2018rbox} are in the domains of document processing or remote sensing where objects are detected in aerial imagery (Table \ref{papers:obb}) and use OBB to train in a fully supervised way. OBB predicting methods try to handle challenges like dense objects, arbitrary orientation, and background noise. Ma et al \cite{ma2018arbitrary} used the rotational formation of anchors at RPN level for text detection. Yang et al \cite{yang2018r2cnn} used attention to improve dense objects detection in arbitrary orientations. Ding et al \cite{Ding_2019_CVPR} proposed a rotated RoI transformer in a fully supervised way to reduce the number of anchors at RPN level. Nevertheless, \textcolor{black} {as indicated in Table \ref{papers:obb}}, existing oriented object detection methods use OBB information as ground truth during training. In contrast, we propose a cascaded approach to detect oriented objects in a weakly-supervised way, using orientation and axis-aligned bounding boxes during training. \textbf{Firearms Detectors:} Research on visual firearm detection in images or videos is quite sparse and currently, there is no dedicated firearm detector or benchmark dataset for evaluation and comparison. Olmos et al. used FRCNN for only handgun detection \cite{olmos2018automatic}, while no results are reported on the rifle. Akcay et al. used FRCNN, RFCN, Yolo v2 and RCNN for gun detection in x-ray baggage security imagery \cite{akcay2018using}. In contrast to these existing approaches, in the current work, we propose a generic firearm detection and classification framework. The proposed framework is more comprehensive and does not require the OBB ground truth information during training. To the best of our knowledge, the proposed firearm detection framework is novel and has not been proposed before us. \section{Proposed Orientation Aware Object Detector} Most of the current object detectors predict axis-aligned bounding boxes (AABB) and for that, they analyze the features pooled from the axis-aligned window. Uniform pooling from an axis-aligned window may incur features containing noise due to uncorrelated background objects in the window, as shown in \ref{fig:aalign}, adversely effecting object detection performance. To overcome this issue, we propose an Orientation Aware Object Detector (OAOD), consisting of a cascade of two stages (\ref{fig:main-model}). The proposed network takes an entire image as input, localizes the firearms and simultaneously classifies them into rifles and guns. For localization, it predicts both Oriented Bounding Boxes (OBB) and axis-aligned bounding for firearms. Unlike other oriented object detectors \cite{ma2018arbitrary, yang2018r2cnn, liu2018fots, azimi2018towards, Ding_2019_CVPR, liu2017deep}, OAOD does not use OBB ground truth for training. It instead relies on only the orientation information, which is much easy to annotate than OBB in the ground-truth, and learn to predict the OBB in a weakly supervised way. In the following, both the stage-1 and the stage-2 are explained in more detail. \subsection{OAOD Stage-1} \label{sec:method-phase-1} The stage-1 of OAOD consists of a Region Proposal Network (RPN) followed by a firearm localization, classification and orientation estimation network. \subsubsection{Region Proposal Network (RPN)} \label{sec:method-phase-1-0} The RPN is retrained on the firearms training dataset similar to \cite{ren2015faster}. The RPN is applied to the deep features computed by VGG16 \cite{simonyan2014very} backbone model to generate initial axis-aligned region proposals, $RP_1$ which are then input to the next step. \subsubsection{Object and Orientation Classification Network} \label{sec:method-phase-1-1} During training, each region proposal $\in RP_{1}$ is associated with a unique ground-truth bounding box, based on maximum IoU between that proposal and the ground truth if maximum IoU is $\ge$ 0.50. On the basis of this association, class label, orientation label, orientation offset, and bounding box offsets are assigned to that proposal. If maximum IoU is $<0.5$ but $\ge 0.1$, that particular proposal is labeled as background, while the others are rejected. Thus the region proposals may have classification labels as background, gun or rifle. RoI pooling similar to FRCNN is used to pool the features to a fixed size for further processing. These features are input to a network consisting of two fully connected layers with four separate output heads, one for each of the four tasks: object classification, orientation classification, bounding box and orientation offsets regression. The cross entropy loss function for firearm classification as gun, rifle, and background in stage-1 ($L^f_{1}$) is defined as: \vspace{-0.2cm} \begingroup \small \begin{align} L^f_{1}(p^f_{1}, u^f_{1}, n_{b}) = \sum_{i=1}^{n_{b}}\sum_{j=1}^{n_f} u^f_{1}(i,j) \text{log}(p^f_{1}(i,j)), \label{eq4} \end{align} \endgroup where $p^f_{1} \in \mathcal{R}^{n_f}$ is the predicted firearm class probability and $u^f_{1}=\{\{1,0,0\},\{0,1,0\},\{0,0,1\}\} \in \mathcal{R}^{n_f}$ is the actual firearm class label, $n_f=3$ is the number of object classes including background, gun, and rifle, and $n_{b}$ is the number of object proposals in a mini batch. To predict the orientation of a region proposal effectively, the objects are divided into $n_o=8$ orientation classes in the range of 0$^o$- 180$^o$ as shown in Fig. \ref{circle}. The other half-circle contains objects pointing in the exact opposite direction, which are also considered in the same classes as the corresponding class in the upper half-circle. For each region proposal the orientation classification head predicts a label within the specified $n_o$ classes by using the orientation loss function, $ L^{o}_{1}$ : \vspace{-0.2cm} \begingroup \small \begin{align} L^{o}_{1}(p^{o}_{1}, u^{o}_{1}, n_{b}) = \sum_{i=1}^{n_{b}} \sum_{j=0}^{n_o} \delta_i u^o_1(i,j) log(p^o_1(i,j)), \label{eq3} \end{align} \endgroup where $p^{o}_{1} \in \mathcal{R}^{n_o}$ is the predicted orientation class probability and $u^{o}_{1} \in \mathcal{R}^{n_o}$ is the actual orientation class label, $n_o=8$ is the number of orientation classes, and $n_{b}$ are the number of object proposals in a mini batch corresponding to the firearms in the ground truth. Similarly, $\delta_i$ is an indicator variable for $i^{th}$ object proposal ensuring to ignore orientation loss during training for the background class, $\delta _{i}= 1$ if the label is gun/rifle and $0$ otherwise. \subsubsection{Bounding Box Regression} \label{sec:bbox1-reg} Alongside object classification, accurate localization is also very importance in object detection. We train a bounding box regression head to regress offsets. The objective function for the bounding box regression is given by: \vspace{-0.2cm} \begingroup \small \begin{align} \footnotesize{ L^b_{1}(p^b_{1}, u^b_{1}, n_{b}) = \sum_{i=1}^{n_{b}} \sum_{j=1}^4 \delta_i \text{S}_{\ell_1} (p^b_{1}(i,j) -u^b_1(i,j))} \label{eq1} \end{align} \endgroup where $p^b_{1} = (p_x, p_y, p_w, p_h)$ are predicted bounding box offsets and $u^b_{1} = (u_x, u_y, u_w, u_h)$ are actual ground truth offsets for the respective proposal. Also, $n_{b}$ and $\delta_i$ are the same as defined above. The \text{S}$_{\ell_1}(\cdot)$ is smooth $\ell_1$ function \begingroup \small \begin{align} \text{S}_{\ell_1} (x) = \left\{\begin{matrix} 0.5x^2 & \text{if~~~} |x|<1 \\ |x|-0.5 & \text{Otherwise} \end{matrix}\right. \label{eq2} \end{align} \endgroup During training, $L_1^{b}$ is back-propagated for only those object proposals which correspond to firearms in the ground truth while the others corresponding to the background are ignored by using the indicator variable $\delta_i$. \subsubsection{Orientation Offsets Regression} \label{sec:orient-reg} In addition to considering orientation as a classification task, we also rectify the predicted class mean angle (center of the bin as described in Sec. 4) based on the continuous-valued orientation ground truth ($r_{gt}$). \textcolor{black}{For our work, one orientation class represents degree-range : $u^{o}_{1}-r_m$ to $u^{o}_{1}+r_m$, as described in Sec. \ref{sec:dataset}, where $r_m$ is equal to half of the bin size. In our experiments $r_m= 11.25^o$ since we have set number of classes to 8.} The orientation offset is measured as the deviation of $u^{o}_{1}$ from the ground truth $r_{gt}$. The offset is then normalized using $r_m$ in the range of $[-1,1]$ as follows \vspace{-0.1cm} \begingroup \small \begin{flalign} \begin{split} \mathcal \textit{u}_{1}^{r} = \frac{u^{o}_{1} - r_{gt}}{r_m}, \label{eq:rorient} \end{split} \end{flalign} \endgroup \textcolor{black}{where $r_{gt}$ is subtracted from the mean angle $u^{o}_{1}$ associated with classification task and normalized with an absolute value $r_m$ to obtain ground truth offsets for rectification of predicted mean angle class $p_{1}^o$.} At inference, offsets predicted are scaled back to the original values followed by addition to the mean angle obtained by classification. This helps in better localizing the oriented area to pool features, removing background noise and clutter more effectively than procedure followed in Sec \ref{sec:method-phase-1-1}. The loss function for orientation offsets regression is as follows \begingroup \small \begin{align} \footnotesize{ L^r_{1}(p^r_{1}, u^r_{1}, n_{b}) = \sum_{i=1}^{n_{b}} \sum_{j=1}^{n_o} \delta_i \text{S}_{\ell_1} (p^r_{1}(i,j) -u^r_{1}(i,j))}, \label{eq:rorient-loss} \end{align} \endgroup where $p^r_{1}$ represents the regressed orientation offsets and $u^r_{1}$ shows orientation ground truth offsets, $n_{b}$ and $\delta_i$ are the same as defined above. The \text{S}$_{\ell_1}(\cdot)$ is smooth $\ell_1$ as defined in \eqref{eq2}. The overall training objective function for OAOD stage-1 is a weighted combination of the individual losses of object and orientation classification along with bounding box and orientation offsets regression \begingroup \small \begin{flalign} \begin{split} {L}_{1} = \alpha L^f_{1}(p^f_{1}, u^f_{1}, n_{b}) + \beta L^{o}_{1} (p^{o}_{1}, u^{o}_{1}, n_{b})\\ + \gamma L^b_{1}(p^b_{1}, u^b_{1}, n_{b}) + \eta L^r_{1}(p^r_{1}, u^r_{1}, n_{b}) \label{eq5} \end{split} \end{flalign} \endgroup where $\alpha$, $\beta$, $\gamma$, and $\eta$ are normalization weights to assign relative importance to each term in the objective function. The bounding box offset regression targets $u^b_{1}$ are also normalized within the same range of [-1,+1]. \subsection{OAOD Stage-2} \label{sec:method-phase-2} Output of the stage-1 is offsets for the Axes Aligned Bounding Boxes (AABB), their orientation class, orientation offset, and firearm classification result. In order to remove the noisy features belonging to the background, we use the output of the stage-1 to generate Oriented Region Proposals ($ORP$) by Oriented Proposal Generation (OPG) module, perform OARoI-Pooling for these proposals before presenting to the stage-2 classifier and regressor that generates Oriented Bounding Boxes (OBB). These steps are discussed in more detail in the following sections. \subsubsection{Updating Region Proposals for Stage-2} The bounding box offsets $p^b_{1}$, output by stage-1, are used to translate and scale region-proposals $RP_1$ to get $RP_2$, $RP_2=RP_1+p^b_1$. Therefore, $RP_2$ IoU with the corresponding ground truth bounding box $u^b_1$ may get changed requiring a revision of labels and training offsets for this stage. New ground-truth labels (${u^f_{2}, u^b_{2}}$) for each updated region proposal are recomputed by considering its IoU with the ground-truth bounding boxes. \subsubsection{Oriented Proposal Generation} \textcolor{black}{ For $i_{th}$ region proposal, adding the predicted offset $p_1^r(i)$ to the predicted mean angle $p_1^{o}(i)$ of the orientation class, we compute the updated orientation $\theta_{i}$, where $\theta_i=p^{o}_{1} (i)+r_m \times p_1^r(i)$, and $r_m=11.25^{o}$ in our case (Sec. \ref{sec:orient-reg}).} This updated angle is then used to generate Oriented Region Proposals ($ORP$), aligned with the firearm object. If $RP_2$ is directly rotated using $\theta_i$, it gets aligned with the firearm but it is not compact and may encapsulate even more background information than the original $RP_2$. To address this issue a maximum area oriented rectangle is computed inside $RP_{2}$ such that the longitudinal axis of this rectangle is aligned with $\theta_i$ as shown in Fig. \ref{figcomp:maxarea}. This oriented rectangle removes the extra background information, however, in many cases, it does not cover the full length of the object. Therefore, to obtain $ORP$, the maximum area rectangle is extended along the longitudinal axis till the corners of $RP_2$. As shown in Fig. \ref{figcomp:maxarea}(c), the $ORP$ is aligned with the axis of the object and is relatively tighter than both $RP_2$ and its rotated version (green rotated box in Fig. \ref{figcomp:maxarea} (a)). \begin{figure}[t] \begin{center} \captionsetup{justification=justified} \includegraphics[width=0.9\linewidth]{latex/images/max-area-rect_red.pdf} \caption{\small{Oriented Proposal Generation process (OPG): (a) AABB and its rotated version using angle information, (b) Maximum area oriented rectangle inscribed in the actual box and (c) $ORP$, used in second stage for OARoI-Pooling. }} \label{figcomp:maxarea} \end{center} \vspace{-0.5cm} \end{figure} \subsubsection{Object Aligned RoI-Pooling} Since $ORP$ consists of rectangles that are not axis-aligned, the pooling algorithm is modified. \textcolor{black}{We define an Object Aligned RoI-Pooling (OARoI-Pooling) process to pool values from the ORP. Unlike RoI pooling in stage-1, the OARoI-Pooling pools values from an oriented grid instead of an axis-aligned grid where the oriented grid is generated over the ORP. } The oriented feature map resulted from OARoI-Pooling is used for the final classification of the object and the bounding box regression \textcolor{black}{(see Fig. 3 (d))}. It should be noted that after OARoI-Pooling, the pooled values become invariant to the orientation of the object in $RP_1$ thus making easier for the classifier to perform prediction. \iffalse \begin{figure*}[ht] \begin{center} \captionsetup{justification=justified} \includegraphics[width=1.0\linewidth]{latex/images/features_v2.pdf} \caption{Features across the channels, warping and cropping. Before warping and cropping, it can be seen that there are very noisy and cluttered features for pooling to classify. After warping and cropping, the maximum area rectangle has been chosen for pooling of oriented region proposals to classify. It increases the classification score.} \label{figmax} \end{center} \end{figure*} \fi \subsubsection{Oriented Object Detection} An oriented object detection sub-network is trained to predict the classification score and bounding box offsets over OARoI-pooled features. These offsets are then applied to the $ORP$ before further processing. The design of oriented object detection sub-network layers is similar to the stage-1 object classification and bounding box regression layers. The objective function for this sub-network consists of two losses including oriented object classification loss and bounding box regression loss . The cross entropy loss $L^f_{2}$ is given by: \begingroup \small \begin{align} L^f_{2}(p^f_{2}, u^b_{2}, n_{b}) = \sum_{i=1}^{n_{b}}\sum_{j=1}^{n_f} u^f_{2}(i,j) \text{log}(p^f_{2}(i,j)) \label{eq400} \end{align} \endgroup where $p^f_{2} \in \mathcal{R}^{n_f}$ is the predicted firearm class probability and $u^f_{2} \in \mathcal{R}^{n_f}$ is the updated firearm class label, while the rest of parameters are similar to \eqref{eq4}. The bounding box regression loss $L^b_{2}$ is as follows: \begingroup \small \begin{align} L^b_{2}(p^b_{2}, u^b_{2}, n_{b}) = \sum_{i=1}^{n_{b}} \sum_{j=1}^4 {\Theta_i} \text{S}_{\ell_1} (p^b_{2}(i,j) -u^b_{2}(i,j)) \label{eq100} \end{align} \endgroup \begin{algorithm}[t] \textbf{Input:} \small{$\theta=\{\theta_i\}_{i=1}^{n_p}$, $\textbf{x}=\{x_\min^i,y_\min^i,x_\max^i,y_\max^i\}_{i=1}^{n_p}$ where $\textbf{x}=RP_{2}$ and, \textbf{u}=\{$u_\min^i,v_\min^i, u_\max^i,v_\max^i\}_{i=1}^{n_p}$ are the corresponding input \& output boxes from stage-2 respectively, $n_p$: total number of object proposals} \\ \textbf{Output:} Oriented Bounding Boxes $B_o=\{B^i_o\}_{i=1}^{n_p}$ \caption{Inverse Transformation} \begin{algorithmic}[1] \vspace{0.1cm} \For{\textit{$i \leftarrow 1:n_p$}} \vspace{0.2cm} \State $C_x^i \leftarrow (x_\min^i + x_\max^i) / 2$ , $C_y^i \leftarrow (y_\min^i + y_\max^i) / 2$ \vspace{0.2cm} \small{\State $T^i=\begin{bmatrix} \cos{\theta}_i & \sin{\theta}_i & C_x^i\cos{\theta}_i+C_y^i\sin{\theta}_i-C_x^i \\ -\sin{\theta}_i & \cos{\theta}_i & -C_x^i\sin{\theta}_i+C_y^i\cos{\theta}_i-C_y^i \\ 0 & 0 & 1 \end{bmatrix}$} \vspace{0.2cm} \State $M_{c}^i=\begin{bmatrix} u_\min^i & u_\max^i & u_\min^i & u_\max^i \\ v_\min^i & v_\min^i & v_\max^i & v_\max^i \\ 1 & 1 & 1 & 1 \end{bmatrix}$ \vspace{0.2cm} \State $B^i_o \leftarrow T^i M_{c}^i$ \EndFor \end{algorithmic} \end{algorithm} where $\Theta_i$ is an indicator variable such that, $\Theta_i=1$ if orientation is $0^o$ or $90^o$ and $\Theta_i=0$ otherwise. Hence, loss is backpropagated only if the firearm is vertically or horizontally axis-aligned. For these two angles, the $RP_{2}$ and the $ORP$ remain the same; hence ground truth boxes could be used to train the stage-2 bounding box regression. The combined objective function for this oriented object detection sub-network is given below: \begingroup \small \begin{flalign} \begin{split} L_{2} = L^f_{2}(p^f_{2}, u^f_{2}, n_{b}) + L^b_{2}(p^b_{2}, u^b_{2}, n_{b}) \label{eq6} \end{split} \end{flalign} \endgroup \subsubsection{Oriented Bounding Boxes Output} The bounding box offsets, $p_2^b$, predicted in stage-2 are used to update $ORP$. An inverse transformation is constructed to map this adjusted $ORP$ back to the original image, using the orientation $\theta_i$ and the $RP_{2}$ center positions from stage-2. The output of this final step gives us OBB. The step-wise details are provided in Algorithm-1. Note that: during the inference time, we use bounding box output by stage-1 as the AABB, and OBB generated by stage-2. However, in both cases, we use the classification probability from stage-2. \vspace{-0.1cm} \section{ITU Firearms Dataset (ITUF)} \label{sec:dataset} We have collected a large dataset of images containing firearms, named as ITUF. Axis-aligned bounding box (AABB) of each firearm in each image has been hand-annotated. Dataset has been divided into training and testing splits, for the testing split OBB were also manually annotated to enable comparison with existing OBB predicting algorithms. As per our knowledge, ITUF is the first large firearm dataset in the public domain. ITUF captures varied scenes (indoor, outdoor, lighting conditions) \& scenarios (firearms pointed, carried, lying on tables/ground/racks) and contains various makes and models of firearms (from pistols to AK-47). This diversity makes ITUF a challenging and realistic dataset for the firearm detection task. \begin{figure}[ht] \begin{center} \captionsetup{justification=justified} \includegraphics[width=0.8\linewidth]{latex/images/image_orient_half_.pdf} \caption{\small{ Orientation is divided in 8 classes considering firearms oriented $\theta+180^o$ in the same class as the firearms with $\theta$ class. Values in \textcolor{blue}{blue} show the Firearms distribution over different $\theta$ classes.}} \label{circle} \end{center} \vspace{-0.4cm} \end{figure} \textbf{Data Collection and Annotation: } ITUF was collected from the web by incorporating keywords, such as weapons, wars, pistol, movie names, firearms, types of firearms, sniper, shooter, corps, guns and rifles, in the web search. Results were cleaned to remove images not containing firearms, duplicates and synthetic ones. The final dataset consists of $10,973$ fully annotated images with 13647 firearm instances. We have divided firearms into two classes; `Gun' class includes different variations of pistols and revolvers; whereas `Rifle' class contains hunting-rifles to AK-47 (including small machine guns). AABB for each firearm in every image is tagged by an annotator, along with a class label and an angle representing the orientation of the firearm. Orientation is annotated as the angle made by line joining muzzle and the back tip (hammer or butt) of the firearm. Orientations are quantized into 8 bins as shown in Fig. \ref{circle}, and each bin is treated as a class with the value equal to the center of the bin. Each class also includes orientations which are 180$^o$ flipped versions of the angles shown in Fig. \ref{circle}. For example, class 0 spans 348.75$^o$ to +11.25$^o$ as well as 168.75$^o$ to 191.25$^o$. \textcolor{black}{The orientation class associated to each firearm represent the center of the associated quantization bin, and is named as \textbf{mean angle}.} We believe that this dataset will help the researchers to develop algorithms for firearm detection not just for security but also for the multi-media content analysis, including AR and VR environments as well. It will also help media and content distribution companies to categorize what content is feasible for age-appropriate consumption. More dataset details may be found in the supplementary material and at the project homepage\footnote{http://im.itu.edu.pk/orientation-aware-firearms-detection/}. \section{Experiments and Results} The proposed OAOD algorithm is trained and evaluated on the ITUF dataset and is compared with current state-of-the-art axis-aligned and oriented object detection algorithms. A thorough ablation study is performed to validate different parameters and aspects of the proposed OAOD algorithm. \subsection{Experimental Setup} \label{sec:exp-setup} In firearm detection experiments, we localize each firearm in an input image and classify it as a rifle or a gun. For the comparison with the axis-aligned object detection methods, AABB from stage-1 and classification score from stage-2 are used, whereas the output of stage-2 is used for comparisons with OBB detection methods. OAOD is only trained on AABB and orientation ground-truth information, while OBB are not used for training. \noindent \textbf{Implementation Details:} High-resolution images in ITUF are resized to a shorter side of 480 or larger side of 800 pixels preserving the aspect ratio. Due to limited GPU memory, a single image per batch is processed. The initial learning rate and momentum are set to 0.001 and 0.90 respectively. A weight decay of 0.0005 with SGD optimizer is used. VGG16 pre-trained on Imagenet \cite{simonyan2014very}, is used as a backbone network. Caffe is used as an implementation framework and training is performed on a single core-i5 machine with 32GB RAM and a GTX 1080 GPU with 8GB memory. The hyper parameters in \eqref{eq5}, $\alpha$, $\gamma$ \& $\eta$ are set to 1.0. The parameter $\beta$ is set to 0.1, by validating over a wide range in search of optimal value (Sec. \ref{sec:ablation}). \begin{table}[h] \footnotesize \centering \renewcommand{\arraystretch}{1.3} \tabcolsep=1.9pt\relax \caption{\footnotesize{OAOD-AA (no orientation offsets) \& OAOD-AA+ (with orientation offsets) vs state-of-the-art AABB object detectors at multiple IoU levels. $AP_g$ \& $AP_r$ : Average Precision of gun \& rifle respectively. Highest values shown in \textcolor{red}{Red}, $2^{nd}$ highest shown in \textcolor{blue}{Blue}.}} \begin{tabular}{c|ccc|ccc|ccc} \hline \multirow{2}{*}{\begin{tabular}[c]{@{}c@{}} Methods \end{tabular}} & \multicolumn{3}{c|}{\text{$AP_{40}$}} & \multicolumn{3}{c|}{\text{$AP_{50}$}} & \multicolumn{3}{c}{\text{$AP_{60}$}} \\ \cline{2-10} & \text{$AP_g$} & \text{$AP_r$} & \text{$mAP$} & \text{$AP_g$} & \text{$AP_r$} & \text{$mAP$} & \text{$AP_g$} & \text{$AP_r$} & \text{$mAP$} \\ \hline \begin{tabular}[c]{@{}c@{}}YOLOv2 \end{tabular} & 70.7 & 83.3 & 77.0 & 62.3 & 77.0 & 69.6 & 41.9 & 62.9 & 52.4 \\ YOLOv3 & 80.8 & 78.6 & 79.8 & 76.0 & 70.7 & 73.4 & 64.3 & 59.0 & 61.7 \\ SSD & 70.6 & 79.0 & 74.8 & 65.6 & 73.0 & 69.3 & 55.2 & 58.2 & 56.7 \\ DSSD & 77.4 & 78.9 & 78.1 & 73.0 & 72.3 & 72.7 & 63.2 & 58.9 & 61.1 \\ \begin{tabular}[c]{@{}c@{}}FRCNN\end{tabular} & \textcolor{black}{88.7} & \textcolor{black}{89.0} & \textcolor{black}{88.9} & \textcolor{black}{80.2} & \textcolor{black}{79.4} & \textcolor{black}{79.8} & \textcolor{blue}{67.8} & \textcolor{black}{68.3} & \textcolor{black}{68.1}\\ \hline \textbf{OAOD-AA} & \textcolor{blue}{88.8} & \textcolor{blue}{89.6} & \text{\textcolor{blue}{89.2}} & \textcolor{blue}{84.4} & \textcolor{blue}{86.4} & \text{\textcolor{blue}{85.4}} & \textcolor{black}{67.0} & \textcolor{blue}{74.0} & \text{\textcolor{blue}{70.3}} \\ \textbf{OAOD-AA+} & \textcolor{red}{89.6} & \textcolor{red}{90.2} & \text{\textcolor{red}{89.9}} & \textcolor{red}{87.6} & \textcolor{red}{88.9} & \text{\textcolor{red}{88.3}} & \textcolor{red}{73.2} & \textcolor{red}{78.1} & \text{\textcolor{red}{75.7}} \\ \hline \end{tabular} \label{tab:ioumap-axis} \end{table} \begin{figure*}[!htb] \begin{center} \captionsetup{justification=justified} \includegraphics[width=\linewidth]{latex/images/final_results_images_new_red_r.pdf} \caption{\small{Qualitative comparison of OAOD with current state-of-the-art object detectors, including YOLOv3, DSSD and FRCNN at IoU=0.50. \textcolor{green}{Green}: ground truth, \textcolor{red}{Red}: AABB detections of respective algorithms. Our proposed approach results in reduced miss-detections, accurate localization and lower false detections. The \textcolor{magenta}{Magenta} boxes in the last two rows are OBB detections of OAOD algorithm, one with only orientation classification (OAOD), and last one (OAOD$+$) with orientation offset regression. OAOD$+$ results in boxes tightly bounding the object. }} \label{compresults} \end{center} \vspace{-0.5cm} \end{figure*} \noindent \textbf{Training Scheme: } We train the two OAOD stages one by one. Initially stage-1 (Fig. \ref{fig:main-model}) is trained to predict the AABB, classification score and orientation information with loss function ${L}_{1}$ (\ref{eq5}). After a sufficient number of epochs, we train stage-2 along with fully connected layers of stage-1. The bounding boxes and the orientation information predicted by stage-1 are passed as input to stage-2 as described in Sec. \ref{sec:method-phase-2}. $L_b^{s2}$ in stage-2 is incorporated only if the orientation for the region proposal is 0$^o$ or 90$^o$, while the classification loss is used for every instance as given by \eqref{eq6}. To avoid over-fitting, a dropout of 0.5 is used between the fully connected layers during training. \subsection{Comparison with Existing State-of-the-art Techniques} The trained OAOD and other state of the art algorithms are evaluated over the ITUF test set for both AABB and OBB predictions. To understand the effect of orientation prediction we present results on the both sub-tasks, orientation classification (see Sec. \ref{sec:method-phase-1-1}) and orientation regression (see Sec. \ref{sec:orient-reg}). OAOD pipelines only with orientation classification are named OAOD-AA \& OAOD-OB (as the AABB and OBB predictions respectively), whereas OAOD-AA+ \& OAOD-OB+ are used for regression, that is with orientation offsets added in the pipeline (see Fig. \ref{fig:main-model}). Our model (with orientation regression) produces mAP of 88.3\% and 77.5\% (at IoU=0.50) for AABB and OBB respectively. Due to $ORP$ offsets regression and stage-2 classification, the proposed OAOD avoids miss-detection and multiple detections while performing more accurate localization. Employing a deeper backbone network such as ResNet-101 \cite{he2016deep} may result in further improved accuracy at the cost of increased space complexity. \subsubsection{Comparison with Axis-Aligned Bounding Box Methods} We compare OAOD against current state-of-the-art one-stage and two-stage AABB object detection algorithms such as SSD, DSSD, YOLOv2, YOLOv3 and FRCNN. These methods were trained on the same ITUF training dataset. All parameters in these algorithms were set as recommended by the original authors. \vspace{-0.0cm} The proposed OAOD has outperformed the compared methods by achieving better mAP compared to both single-stage and multi-stage detectors as shown in Table \ref{tab:ioumap-axis}. This is attributed to $ORP$ generated by the OPG module with OARoI-Pooling which removes much of the noisy features related to the background, making the stage-2 more accurate. Secondly, OAOD remains stable (Table \ref{tab:ioumap-axis}) as IoU levels are varied, despite the fact that the model is trained for IoU=0.50 only. Specifically compared to the baseline FRCNN, our proposed OAOD-AA and OAOD-AA+ have achieved increased mAP by 6.6\% and 9.6\% respectively, at IoU=0.50. Compared to the single-stage axis-aligned object detectors, the OAOD-AA and OAOD-AA+ improve the performance by a minimum of 14.0\% and 16.9\% respectively. The qualitative results are presented in Fig. \ref{compresults}. The proposed OAOD performs excellently by avoiding miss detections and produces better localization. \begin{table}[t] \footnotesize \centering \renewcommand{\arraystretch}{1.5} \tabcolsep=2.9pt\relax \caption{\footnotesize{Comparison of the proposed OAOD-OB (no orientation offsets) \& OAOD-OB+ (with orientation offsets) with state-of-the-art OBB detectors at different IoU levels. $OBB_{rot}$ are rotated version of AABB whereas $OBB_{ann}$ are manually annotated oriented boxes. Highest values shown in \textcolor{red}{Red}, $2^{nd}$ highest shown in \textcolor{blue}{Blue} }} \begin{tabular}{c|c|cc|cc} \hline \multirow{2}{*}{Methods} & \multirow{2}{*}{Baseline} & \multicolumn{2}{c|}{$OBB_{rot}$} & \multicolumn{2}{c}{$OBB_{ann}$} \\ \cline{3-6} & & \text{$AP_{50}$} & \text{$AP_{60}$} & \text{$AP_{50}$} & \text{$AP_{60}$} \\ \hline R2CNN$++$ & ResNet-50 & 54.5 & 44.8 & 43.0 & 27.9 \\ DOTA-FRCNN & ResNet-101 & 58.7 & \textcolor{black}{46.9} & 57.1 & 46.3 \\ RoI-Trans & ResNet-101 & \textcolor{black}{77.5} & 45.9 & \textcolor{black}{68.5} & \textcolor{black}{48.5} \\ \hline OAOD-OB & VGG16 & \textcolor{blue}{77.9} & \textcolor{blue}{62.2} & \textcolor{blue}{69.7} & \textcolor{red}{50.2} \\ OAOD-OB+ & VGG16 & \textcolor{red}{82.3} & \textcolor{red}{63.8} & \textcolor{red}{77.5} & \textcolor{blue}{49.6} \\ \hline \end{tabular} \label{tab:oriented-comparison} \end{table} \begin{figure*}[!htb] \begin{center} \includegraphics[width=0.9\linewidth]{latex/images/extra_results_orient_obb_s.pdf} \captionsetup{justification=justified} \caption{\small{Qualitative comparison of proposed OAOD-OB \& OAOD-OB+ (\textcolor{magenta}{Magenta}) with existing oriented object detectors (R2CNN++: \textcolor{yellow}{Yellow}, DOTA-FRCNN: \textcolor{orange}{Orange} and RoI-Trans: \textcolor{cyan}{Cyan}). OAOD-OB+ avoids miss-detection, multiple detections and achieves more accurate localization. }} \label{orientbbox} \end{center} \end{figure*} \subsubsection{Comparison with Oriented Object Detection Methods} Most of these methods are trained using OBB ground truth annotations, while such information is not available in the case of the ITUF dataset. In order to train the existing oriented bounding box detection methods (R2CNN++ \cite{ yang2018r2cnn}, DOTA FRCNN \cite{Xia_2018_CVPR}, RoI-Trans \cite{Ding_2019_CVPR}), we rotate the given AABB ground-truth with respective ground-truth orientation and create OBB. OAOD overcomes the limitation of the unavailability of OBB ground-truth by leveraging the orientation information (stage-1), ORP with OARoI-Pooling and inverse transformation (stage-2). Table. \ref{tab:oriented-comparison} shows the comparison of OAOD-OB \& OAOD-OB+ with the existing state-of-the-art oriented object detection algorithms. OAOD gives more stable results for different IoU values compared to other methods. For a comprehensive evaluation, we have tested the proposed OAOD algorithm and the existing OBB detection methods with rotated OBB ($OBB_{rot}$) and annotated OBB ($OBB_{ann}$). The $OBB_{rot}$ are the rotated version of AABB and $OBB_{ann}$ are the manually tagged boxes (available for test set only). More specifically, in the case of $OBB_{rot}$ and $OBB_{ann}$ at IoU=0.5, the proposed OAOD outperformed the existing state-of-the-art methods by a minimum of 5.8\% and 11.6\% mAP, respectively. Fig \ref{orientbbox} shows the qualitative results of OAOD-OB \& OAOD-OB+ with the existing state-of-the-art oriented object detection methods. More Qualitative results of OAOD are provided in the supplementary material. To compare the robustness and stability of the OAOD vs existing methods, we evaluate results at different confidence levels. As indicated in Fig. \ref{fig:OAODOBgraphs_r} (right), proposed OAOD-OB \& OAOD-OB+ algorithms remain stable and even at high confidence threshold, OAOD results less deteriorate compared to the other methods \cite{Ding_2019_CVPR, Xia_2018_CVPR, yang2018r2cnn}. This could be attributed to the cascaded nature of OAOD and removal of the noisy background features by generating Oriented Proposals and performing Object Alighted RoI-Pooling. \begin{figure}[t] \begin{center} \captionsetup{justification=justified} \includegraphics[width=0.9\linewidth]{latex/images/graphs_OAOD-OB_trans.pdf} \caption{\small{OAOD's behavior across varying confidence levels. \textbf{Left} figure shows AABB detection performance with ablation experiments. \textbf {Right} figure shows OBB detection performance using $OBB_{ann}$ over test set.}} \label{fig:OAODOBgraphs_r} \end{center} \end{figure} \subsection{Ablation Study} \label{sec:ablation} Thorough ablation study is performed in order to evaluate different design choices including hyper-parameters and OAOD precursor models (Fig. \ref{fig:OAODOBgraphs_r} (left)). \noindent \textbf{Orientation Loss:} With other hyper-parameters in stage-1 loss (\ref{eq5}) fixed to 1 (following original FRCNN paper), we searched a wide range for the optimal value of $\beta$, by training and validating on the ITUF validation-set chosen as 20\% of the training dataset. $\beta=0.10$ has resulted in increased orientation accuracy as well as mean average precision (Table \ref{betaval}), therefore $\beta=0.1$ is used for the rest of the experiments. \begin{table}[b] \footnotesize \centering \renewcommand{\arraystretch}{1.2} \tabcolsep=3.9pt\relax \caption{\footnotesize{Orientation accuracy and mean average precision (stage 1) with varying values of $\beta$ in \eqref{eq5} over the validation dataset. The \textcolor{red}{Red} represent high values and used in our experiments.}} \begin{tabular}{cccccccc} \hline $\beta$ & 1 & 0.5 & 0.325 & 0.25 & 0.125 & 0.1 & 0.0625 \\ \hline $\text{mAP}_{validation}$ & 51.5 & 62.9 & 66.6 & 72.5 & 71.9 &\textcolor{red}{74.8} & 72.5 \\ \hline Accuracy & 84.4 & 83.5 & 84.3 & 84.2 & 83.9 & \textcolor{red}{84.7} & 82.9 \\ \hline \end{tabular} \label{betaval} \end{table} \noindent \textcolor{black}{ \textbf{Orientation Regression Loss:} Similar to orientation loss in (\ref{eq5}), we search for the optimal value of of orientation regression loss scaling parameter $\eta$. With other hyper-parameters in stage-1 loss (\ref{eq5}) fixed, $\alpha =1$, and $\gamma=1$ (following original values used in FRCNN \cite{ren2015faster}) and $\beta=0.1$, the optimal value of $\eta$ is searched by training on the training set (chosen as 80\% of the training dataset) and validating on the ITUF validation-set (chosen as 20\% of the training dataset). $\eta=1.0~ \text{and}~ 0.5$ has shown comparative mAP (Table \ref{etaval}), however, $\eta=1.0$ have minimum absolute orientation error. Based on this observation, $\eta=1.0$ is used for the rest of the experiments.} \begin{table}[t] \footnotesize \centering \renewcommand{\arraystretch}{1.2} \tabcolsep=3.9pt\relax \caption{\footnotesize{Orientation absolute error and mean average precision (stage 1) with varying values of $\eta$ in \eqref{eq5} over the validation dataset. The \textcolor{red}{Red} represent high mAP while the \textcolor{blue}{Blue} shows the values used in our experiments as absolute error is less in this case with comparable mAP.}} \begin{tabular}{c|cccccc} \hline $\eta$ & 1.5 & 1.25 & 1.0 & 0.75 & 0.50 & 0.25 \\ \hline $\text{mAP}_{validation}$ & 77.9 & 71.1 &\textcolor{blue}{78.2} & 77.7 &\textcolor{red}{78.3} & 77.6 \\ \hline Absolute Error & 4.9 & 4.8 & \textcolor{blue}{4.4} & 4.8 & 4.6 & 4.9 \\ \hline \end{tabular} \label{etaval} \end{table} \noindent \textcolor{black}{\textbf{Orientation Classes Distribution:} To find the effective orientation classes $n_o$, We have validated orientation classes distribution, while having all the hyper-parameters ($\alpha=1,~ \beta=0.1,~ \text{and}~ \gamma=1$) in stage-1 fixed. The orientation classes distribution, respective mAP, orientation accuracies and orientation absolute errors (mean of the absolute differences between the predicted orientations and groud truth orientation) the are shown in Table. \ref{theta_dist}. For $n_o = 4$, the orientation accuracies are higher but the respective mAP values are dropped significantly along with high orientation absolute error. This is due to the fact, that the model have to classify the orientation in less number of classes which is an easy task compared to more classes with the cost of decrease in mAP and increase in absolute orientation error. Similarly, for more orientation classes, e.g., $n_o = 12$, the orientation performance decreases due to very close mean angle values causing an increase in absolute orientation error, however a slight increase in mAP is reported. The similarly, we repeated the experiment for $n_o = 8$, resulting low absolute error with comparative mAP. Since orientation being the main component of the proposed OAOD algorithm, we choose $n_o = 8$ orientation classes with high mAP compared to $n_o = 4$ classes and with less orientation absolute error compared to $n_o = 12$ orientation classes as shown in blue color in Table \ref{theta_dist}. } \begin{table}[t] \footnotesize \centering \renewcommand{\arraystretch}{1.2} \tabcolsep=3.9pt\relax \caption{\footnotesize{Orientation accuracy, orientation absolute error and mean average precision (stage 1) with varying number of orientation classes in \eqref{eq5} over the validation set. The \textcolor{red}{Red} represent high mAP while the \textcolor{blue}{Blue} shows the values used in our experiments with smaller absolute error and comparable mAP.}} \begin{tabular}{c|cccccc} \hline $\theta_n$ & 4 & 8 & 12 \\ \hline $\text{mAP}_{validation}$ & 67.5 & \textcolor{blue}{74.8} & \textcolor{red}{76.6} \\ \hline Accuracy & 91.1 & \textcolor{blue}{84.7} & 69.7 \\ \hline Absolute Error & 10.6 & \textcolor{blue}{3.8} & 4.6 \\ \hline \end{tabular} \label{theta_dist} \end{table} \noindent \textbf{Stage-1 Net:} The stage-1 (\ref{fig:main-model}) of the proposed OAOD described in Sec. \ref{sec:method-phase-1} is also evaluated for axis-aligned firearm detection. It is noted that, incorporating the orientation information using multi-task learning has improved the performance over the baseline FRCNN by 3.1\% mAP (Table. \ref{tab:ioumap-ablation}). \begin{table}[t!] \footnotesize \centering \renewcommand{\arraystretch}{1.3} \tabcolsep=4.5pt\relax \caption{\footnotesize{Comparison of OAOD with baseline (FRCNN), Stage-1 and 2-Loss Net for AABB task. Highest values shown in \textcolor{red}{Red}, $2^{nd}$ highest shown in \textcolor{blue}{Blue} }} \begin{tabular}{c|ccccccc} \hline $IoU$ & FRCNN & Stage-1 Net & 2-Loss Net & \begin{tabular}[c]{@{}c@{}}\textbf{OAOD-}\textbf{AA}\end{tabular} & \begin{tabular}[c]{@{}c@{}}\textbf{OAOD-}\textbf{AA+}\end{tabular} \\ \hline 0.4 & 88.9 & \textcolor{black}{88.9} & 88.8 & \text{\textcolor{blue}{89.2}} & \text{\textcolor{red}{89.9}} \\ \hline 0.5 & 79.8 & 82.3 & \textcolor{black}{82.9} & \text{\textcolor{blue}{85.4}} & \text{\textcolor{red}{88.3}} \\ \hline 0.6 & \textcolor{black}{68.1} & 66.1 & 65.9 & \text{\textcolor{blue}{70.3}} & \text{\textcolor{red}{75.7}} \\ \hline \end{tabular} \label{tab:ioumap-ablation} \end{table} \noindent \textbf{2-Loss Net:} In this experiment, the proposed cascaded model (Fig. \ref{fig:main-model}) is trained by using only AABB regression loss from stage-1 and classification loss from stage-2 as $L_{2L} = L^f_{2} + L^b_{1}$. The other losses are not used in this experiment. The $RP_{1}$ are used for generating $ORP$ along with OARoI-Pooling, unlike the $RP_{2}$ used in OAOD. Compared to FRCNN the 2-Loss Net improves the mAP by 3.8\% (IoU=0.50) that shows the significance of our basic framework. 2-Loss net's mAP remains 6.1\% less than OAOD mAP that highlights the importance of the remaining losses. \begin{figure}[h!] \begin{center} \captionsetup{justification=justified} \includegraphics[width=0.6\linewidth]{latex/images/failureCases_trans.pdf} \caption{\small{Example OAOD failure instances: Left: extremely outward pointing object are hard to localize, Right: occlusion may cause localization errors. }} \vspace{-0.5cm} \label{fig:fail} \end{center} \end{figure} \noindent \textbf{Failure Cases:} Fig. \ref{fig:fail} shows two failure cases by proposed OAOD. The left image characterizes the case where the firearm is itself not detectable (due to viewing angle, pose, color, etc.). Only information is in the pose of the holder, we intend to explore connection between human pose and firearm localization in future work. In the right one, failure is only a partial one, as the main component has been localized with the correct orientation, while the barrel has been missed due to the occluded portion. One of the possible reasons could be the lack of such occluded objects in the training data. \section{Conclusion} Rising gun violence, and the use of firearms in both electronic media and social media, poses a challenge for the security, surveillance and multi-media content curation domains. However, there has been no concrete effort in the direction of the firearm detection problem. We counter it by, first, introducing a large challenging dataset of images containing firearms, named ITUF dataset which consists of $10973$ images, where all the firearm instances have been hand-annotated. Secondly, we propose a novel firearm detector using the oriented object detection technique for the firearm detection problem. Firearms, being thin (and many being elongated), and mostly held in oriented poses are perfect fit for the oriented object detection problem. For this purpose, an Orientation Aware Object Detector (OAOD) architecture is designed that can detect tight oriented bounding boxes (OBB) while being trained in weakly supervised fashion using only axis-aligned bounding boxes (AABB) and orientation information. OAOD, is designed to be a multistage detector such that at the last stage features become independent of the object's orientation. Such a setup simplifies the task of classification and bounding box regression improving its accuracy. To keep the number of anchor boxes small at RPN level, orientation is not associated with the region proposals. Instead, an orientation prediction module is introduced, that predicts the orientation from every axis-aligned proposal classified as a firearm. Predicted orientation is used in an oriented region proposal generation step that allows sampling of features around the region aligned with the orientation of the object inside the AABB predicted in the last stage. We train OAOD, to detect OBB around the firearms, and classify them into two broad classes, guns and rifles. The experimental results (mAP: \textit{88.3} on $\text{AABB}$ \& mAP: \textit{77.5} for $\text{OBB}$) demonstrate the effectiveness and stability of the proposed method compared with the existing state-of-art methods. \noindent \textbf{Acknowledgment:} We greatly appreciate the assistance from Muhammad Faisal and Anza Shakeel in collecting and annotating the dataset, and Jason Chi for discussions and providing useful comments. \section{Introduction} \file{elsarticle.cls} is a thoroughly re-written document class for formatting \LaTeX{} submissions to Elsevier journals. The class uses the environments and commands defined in \LaTeX{} kernel without any change in the signature so that clashes with other contributed \LaTeX{} packages such as \file{hyperref.sty}, \file{preview-latex.sty}, etc., will be minimal. \file{elsarticle.cls} is primarily built upon the default \file{article.cls}. This class depends on the following packages for its proper functioning: \begin{enumerate} \item \file{natbib.sty} for citation processing; \item \file{geometry.sty} for margin settings; \item \file{fleqn.clo} for left aligned equations; \item \file{graphicx.sty} for graphics inclusion; \item \file{txfonts.sty} optional font package, if the document is to be formatted with Times and compatible math fonts; \item \file{hyperref.sty} optional packages if hyperlinking is required in the document; \item \file{endfloat.sty} optional packages if floats to be placed at end of the PDF. \end{enumerate} All the above packages (except some optional packages) are part of any standard \LaTeX{} installation. Therefore, the users need not be bothered about downloading any extra packages. Furthermore, users are free to make use of \textsc{ams} math packages such as \file{amsmath.sty}, \file{amsthm.sty}, \file{amssymb.sty}, \file{amsfonts.sty}, etc., if they want to. All these packages work in tandem with \file{elsarticle.cls} without any problems. \section{Major Differences} Following are the major differences between \file{elsarticle.cls} and its predecessor package, \file{elsart.cls}: \begin{enumerate}[\textbullet] \item \file{elsarticle.cls} is built upon \file{article.cls} while \file{elsart.cls} is not. \file{elsart.cls} redefines many of the commands in the \LaTeX{} classes/kernel, which can possibly cause surprising clashes with other contributed \LaTeX{} packages; \item provides preprint document formatting by default, and optionally formats the document as per the final style of models $1+$, $3+$ and $5+$ of Elsevier journals; \item some easier ways for formatting \verb+list+ and \verb+theorem+ environments are provided while people can still use \file{amsthm.sty} package; \item \file{natbib.sty} is the main citation processing package which can comprehensively handle all kinds of citations and works perfectly with \file{hyperref.sty} in combination with \file{hypernat.sty}; \item long title pages are processed correctly in preprint and final formats. \end{enumerate} \section{Installation} The package is available at author resources page at Elsevier (\url{http://www.elsevier.com/locate/latex}). It can also be found in any of the nodes of the Comprehensive \TeX{} Archive Network (\textsc{ctan}), one of the primary nodes being \url{http://tug.ctan.org/tex-archive/macros/latex/contrib/elsarticle/}. Please download the \file{elsarticle.dtx} which is a composite class with documentation and \file{elsarticle.ins} which is the \LaTeX{} installer file. When we compile the \file{elsarticle.ins} with \LaTeX{} it provides the class file, \file{elsarticle.cls} by stripping off all the documentation from the \verb+*.dtx+ file. The class may be moved or copied to a place, usually, \verb+$TEXMF/tex/latex/elsevier/+, or a folder which will be read by \LaTeX{} during document compilation. The \TeX{} file database needs updation after moving/copying class file. Usually, we use commands like \verb+mktexlsr+ or \verb+texhash+ depending upon the distribution and operating system. \section{Usage}\label{sec:usage} The class should be loaded with the command: \begin{vquote} \documentclass[<options>]{elsarticle} \end{vquote} \noindent where the \verb+options+ can be the following: \begin{description} \item [{\tt\color{verbcolor} preprint}] default option which format the document for submission to Elsevier journals. \item [{\tt\color{verbcolor} review}] similar to the \verb+preprint+ option, but increases the baselineskip to facilitate easier review process. \item [{\tt\color{verbcolor} 1p}] formats the article to the look and feel of the final format of model 1+ journals. This is always single column style. \item [{\tt\color{verbcolor} 3p}] formats the article to the look and feel of the final format of model 3+ journals. If the journal is a two column model, use \verb+twocolumn+ option in combination. \item [{\tt\color{verbcolor} 5p}] formats for model 5+ journals. This is always of two column style. \item [{\tt\color{verbcolor} authoryear}] author-year citation style of \file{natbib.sty}. If you want to add extra options of \file{natbib.sty}, you may use the options as comma delimited strings as arguments to \verb+\biboptions+ command. An example would be: \end{description} \begin{vquote} \biboptions{longnamesfirst,angle,semicolon} \end{vquote} \begin{description} \item [{\tt\color{verbcolor} number}] numbered citation style. Extra options can be loaded with\linebreak \verb+\biboptions+ command. \item [{\tt\color{verbcolor} sort\&compress}] sorts and compresses the numbered citations. For example, citation [1,2,3] will become [1--3]. \item [{\tt\color{verbcolor} longtitle}] if front matter is unusually long, use this option to split the title page across pages with the correct placement of title and author footnotes in the first page. \item [{\tt\color{verbcolor} times}] loads \file{txfonts.sty}, if available in the system to use Times and compatible math fonts. \item [{\tt\color{verbcolor} reversenotenum}] Use alphabets as author--affiliation linking labels and use numbers for author footnotes. By default, numbers will be used as author--affiliation linking labels and alphabets for author footnotes. \item [{\tt\color{verbcolor} lefttitle}] To move title and author/affiliation block to flushleft. \verb+centertitle+ is the default option which produces center alignment. \item [{\tt\color{verbcolor} endfloat}] To place all floats at the end of the document. \item [{\tt\color{verbcolor} nonatbib}] To unload natbib.sty. \item [{\tt\color{verbcolor} doubleblind}] To hide author name, affiliation, email address etc. for double blind refereeing purpose. \item[] All options of \file{article.cls} can be used with this document class. \item[] The default options loaded are \verb+a4paper+, \verb+10pt+, \verb+oneside+, \verb+onecolumn+ and \verb+preprint+. \end{description} \section{Frontmatter} There are two types of frontmatter coding: \begin{enumerate}[(1)] \item each author is connected to an affiliation with a footnote marker; hence all authors are grouped together and affiliations follow; \pagebreak \item authors of same affiliations are grouped together and the relevant affiliation follows this group. \end{enumerate} An example of coding the first type is provided below. \begin{vquote} \title{This is a specimen title\tnoteref{t1,t2}} \tnotetext[t1]{This document is the results of the research project funded by the National Science Foundation.} \tnotetext[t2]{The second title footnote which is a longer text matter to fill through the whole text width and overflow into another line in the footnotes area of the first page.} \end{vquote} \begin{vquote} \author[1]{Jos Migchielsen\corref{cor1}% \fnref{fn1}} \ead{[email protected]} \author[2]{CV Radhakrishnan\fnref{fn2}} \ead{[email protected]} \author[3]{CV Rajagopal\fnref{fn1,fn3}} \ead[url]{www.stmdocs.in} \end{vquote} \begin{vquote} \cortext[cor1]{Corresponding author} \fntext[fn1]{This is the first author footnote.} \fntext[fn2]{Another author footnote, this is a very long footnote and it should be a really long footnote. But this footnote is not yet sufficiently long enough to make two lines of footnote text.} \fntext[fn3]{Yet another author footnote.} \address[1]{Elsevier B.V., Radarweg 29, 1043 NX Amsterdam, The Netherlands} \address[2]{Sayahna Foundations, JWRA 34, Jagathy, Trivandrum 695014, India} \address[3]{STM Document Engineering Pvt Ltd., Mepukada, Malayinkil, Trivandrum 695571, India} \end{vquote} The output of the above \TeX{} source is given in Clips~\ref{clip1} and \ref{clip2}. The header portion or title area is given in Clip~\ref{clip1} and the footer area is given in Clip~\ref{clip2}. \deforange{blue!70} \src{Header of the title page.} \includeclip{1}{130 612 477 707}{1psingleauthorgroup.pdf \deforange{orange} \deforange{blue!70} \src{Footer of the title page.} \includeclip{1}{93 135 499 255}{1pseperateaug.pdf \deforange{orange} Most of the commands such as \verb+\title+, \verb+\author+, \verb+\address+ are self explanatory. Various components are linked to each other by a label--reference mechanism; for instance, title footnote is linked to the title with a footnote mark generated by referring to the \verb+\label+ string of the \verb=\tnotetext=. We have used similar commands such as \verb=\tnoteref= (to link title note to title); \verb=\corref= (to link corresponding author text to corresponding author); \verb=\fnref= (to link footnote text to the relevant author names). \TeX{} needs two compilations to resolve the footnote marks in the preamble part. Given below are the syntax of various note marks and note texts. \begin{vquote} \tnoteref{<label(s)>} \corref{<label(s)>} \fnref{<label(s)>} \tnotetext[<label>]{<title note text>} \cortext[<label>]{<corresponding author note text>} \fntext[<label>]{<author footnote text>} \end{vquote} \noindent where \verb=<label(s)>= can be either one or more comma delimited label strings. The optional arguments to the \verb=\author= command holds the ref label(s) of the address(es) to which the author is affiliated while each \verb=\address= command can have an optional argument of a label. In the same manner, \verb=\tnotetext=, \verb=\fntext=, \verb=\cortext= will have optional arguments as their respective labels and note text as their mandatory argument. The following example code provides the markup of the second type of author-affiliation. \begin{vquote} \author{Jos Migchielsen\corref{cor1}% \fnref{fn1}} \ead{[email protected]} \address{Elsevier B.V., Radarweg 29, 1043 NX Amsterdam, The Netherlands} \author{CV Radhakrishnan\fnref{fn2}} \ead{[email protected]} \address{Sayahna Foundations, JWRA 34, Jagathy, Trivandrum 695014, India} \author{CV Rajagopal\fnref{fn1,fn3}} \ead[url]{www.stmdocs.in} \address{STM Document Engineering Pvt Ltd., Mepukada, Malayinkil, Trivandrum 695571, India} \end{vquote} \vspace*{-.5pc} \begin{vquote} \cortext[cor1]{Corresponding author} \fntext[fn1]{This is the first author footnote.} \fntext[fn2]{Another author footnote, this is a very long footnote and it should be a really long footnote. But this footnote is not yet sufficiently long enough to make two lines of footnote text.} \end{vquote} The output of the above \TeX{} source is given in Clip~\ref{clip3}. \deforange{blue!70} \src{Header of the title page..} \includeclip{1}{119 563 468 709}{1pseperateaug.pdf \deforange{orange} \pagebreak Clip~\ref{clip4} shows the output after giving \verb+doubleblind+ class option. \deforange{blue!70} \src{Double blind article} \includeclip{1}{124 567 477 670}{elstest-1pdoubleblind.pdf \deforange{orange} \vspace*{-.5pc} The frontmatter part has further environments such as abstracts and keywords. These can be marked up in the following manner: \begin{vquote} \begin{abstract} In this work we demonstrate the formation of a new type of polariton on the interface between a .... \end{abstract} \end{vquote} \vspace*{-.5pc} \begin{vquote} \begin{keyword} quadruple exiton \sep polariton \sep WGM \end{keyword} \end{vquote} \noindent Each keyword shall be separated by a \verb+\sep+ command. \textsc{msc} classifications shall be provided in the keyword environment with the commands \verb+\MSC+. \verb+\MSC+ accepts an optional argument to accommodate future revisions. eg., \verb=\MSC[2008]=. The default is 2000.\looseness=-1 \subsection{New page} Sometimes you may need to give a page-break and start a new page after title, author or abstract. Following commands can be used for this purpose. \begin{vquote} \newpageafter{title} \newpageafter{author} \newpageafter{abstract} \end{vquote} \begin{itemize} \leftskip-2pc \item [] {\tt\color{verbcolor} \verb+\newpageafter{title}+} typeset the title alone on one page. \item [] {\tt\color{verbcolor} \verb+\newpageafter{author}+} typeset the title and author details on one page. \item [] {\tt\color{verbcolor} \verb+\newpageafter{abstract}+} typeset the title, author details and abstract \& keywords one one page. \end{itemize} \section{Floats} {Figures} may be included using the command, \verb+\includegraphics+ in combination with or without its several options to further control graphic. \verb+\includegraphics+ is provided by \file{graphic[s,x].sty} which is part of any standard \LaTeX{} distribution. \file{graphicx.sty} is loaded by default. \LaTeX{} accepts figures in the postscript format while pdf\LaTeX{} accepts \file{*.pdf}, \file{*.mps} (metapost), \file{*.jpg} and \file{*.png} formats. pdf\LaTeX{} does not accept graphic files in the postscript format. The \verb+table+ environment is handy for marking up tabular material. If users want to use \file{multirow.sty}, \file{array.sty}, etc., to fine control/enhance the tables, they are welcome to load any package of their choice and \file{elsarticle.cls} will work in combination with all loaded packages. \section[Theorem and ...]{Theorem and theorem like environments} \file{elsarticle.cls} provides a few shortcuts to format theorems and theorem-like environments with ease. In all commands the options that are used with the \verb+\newtheorem+ command will work exactly in the same manner. \file{elsarticle.cls} provides three commands to format theorem or theorem-like environments: \begin{vquote} \newtheorem{thm}{Theorem} \newtheorem{lem}[thm]{Lemma} \newdefinition{rmk}{Remark} \newproof{pf}{Proof} \newproof{pot}{Proof of Theorem \ref{thm2}} \end{vquote} The \verb+\newtheorem+ command formats a theorem in \LaTeX's default style with italicized font, bold font for theorem heading and theorem number at the right hand side of the theorem heading. It also optionally accepts an argument which will be printed as an extra heading in parentheses. \begin{vquote} \begin{thm} For system (8), consensus can be achieved with $\|T_{\omega z}$ ... \begin{eqnarray}\label{10} .... \end{eqnarray} \end{thm} \end{vquote} Clip~\ref{clip5} will show you how some text enclosed between the above code\goodbreak \noindent looks like: \vspace*{6pt} \deforange{blue!70} \src{{\ttfamily\color{verbcolor}\expandafter\@gobble\string\\ newtheorem}} \includeclip{2}{1 1 453 120}{jfigs.pdf} \deforange{orange} The \verb+\newdefinition+ command is the same in all respects as its\linebreak \verb+\newtheorem+ counterpart except that the font shape is roman instead of italic. Both \verb+\newdefinition+ and \verb+\newtheorem+ commands automatically define counters for the environments defined. \vspace*{6pt} \deforange{blue!70} \src{{\ttfamily\color{verbcolor}\expandafter\@gobble\string\\ newdefinition}} \includeclip{1}{1 1 453 105}{jfigs.pdf} \deforange{orange} The \verb+\newproof+ command defines proof environments with upright font shape. No counters are defined. \vspace*{6pt} \deforange{blue!70} \src{{\ttfamily\color{verbcolor}\expandafter\@gobble\string\\ newproof}} \includeclip{3}{1 1 453 65}{jfigs.pdf} \deforange{orange} Users can also make use of \verb+amsthm.sty+ which will override all the default definitions described above. \section[Enumerated ...]{Enumerated and Itemized Lists} \file{elsarticle.cls} provides an extended list processing macros which makes the usage a bit more user friendly than the default \LaTeX{} list macros. With an optional argument to the \verb+\begin{enumerate}+ command, you can change the list counter type and its attributes. \begin{vquote} \begin{enumerate}[1.] \item The enumerate environment starts with an optional argument `1.', so that the item counter will be suffixed by a period. \item You can use `a)' for alphabetical counter and '(i)' for roman counter. \begin{enumerate}[a)] \item Another level of list with alphabetical counter. \item One more item before we start another. \end{vquote} \deforange{blue!70} \src{List -- Enumerate} \includeclip{4}{1 1 453 185}{jfigs.pdf} \deforange{orange} Further, the enhanced list environment allows one to prefix a string like `step' to all the item numbers. \begin{vquote} \begin{enumerate}[Step 1.] \item This is the first step of the example list. \item Obviously this is the second step. \item The final step to wind up this example. \end{enumerate} \end{vquote} \deforange{blue!70} \src{List -- enhanced} \includeclip{5}{1 1 313 83}{jfigs.pdf} \deforange{orange} \section{Cross-references} In electronic publications, articles may be internally hyperlinked. Hyperlinks are generated from proper cross-references in the article. For example, the words \textcolor{black!80}{Fig.~1} will never be more than simple text, whereas the proper cross-reference \verb+\ref{tiger}+ may be turned into a hyperlink to the figure itself: \textcolor{blue}{Fig.~1}. In the same way, the words \textcolor{blue}{Ref.~[1]} will fail to turn into a hyperlink; the proper cross-reference is \verb+\cite{Knuth96}+. Cross-referencing is possible in \LaTeX{} for sections, subsections, formulae, figures, tables, and literature references. \section[Mathematical ...]{Mathematical symbols and formulae} Many physical/mathematical sciences authors require more mathematical symbols than the few that are provided in standard \LaTeX. A useful package for additional symbols is the \file{amssymb} package, developed by the American Mathematical Society. This package includes such oft-used symbols as $\lesssim$ (\verb+\lesssim+), $\gtrsim$ (\verb+\gtrsim+) or $\hbar$ (\verb+\hbar+). Note that your \TeX{} system should have the \file{msam} and \file{msbm} fonts installed. If you need only a few symbols, such as $\Box$ (\verb+\Box+), you might try the package \file{latexsym}. Another point which would require authors' attention is the breaking up of long equations. When you use \file{elsarticle.cls} for formatting your submissions in the \verb+preprint+ mode, the document is formatted in single column style with a text width of 384pt or 5.3in. When this document is formatted for final print and if the journal happens to be a double column journal, the text width will be reduced to 224pt at for 3+ double column and 5+ journals respectively. All the nifty fine-tuning in equation breaking done by the author goes to waste in such cases. Therefore, authors are requested to check this problem by typesetting their submissions in final format as well just to see if their equations are broken at appropriate places, by changing appropriate options in the document class loading command, which is explained in section~\ref{sec:usage}, \nameref{sec:usage}. This allows authors to fix any equation breaking problem before submission for publication. \file{elsarticle.cls} supports formatting the author submission in different types of final format. This is further discussed in section \ref{sec:final}, \nameref{sec:final}. \subsection*{Displayed equations and double column journals} Many Elsevier journals print their text in two columns. Since the preprint layout uses a larger line width than such columns, the formulae are too wide for the line width in print. Here is an example of an equation (see equation 6) which is perfect in a single column preprint format: \bigskip \setlength\Sep{6pt} \src{See equation (6)} \deforange{blue!70} \includeclip{4}{105 500 500 700}{1psingleauthorgroup.pdf} \deforange{orange} \noindent When this document is typeset for publication in a model 3+ journal with double columns, the equation will overlap the second column text matter if the equation is not broken at the appropriate location. \vspace*{6pt} \deforange{blue!70} \src{See equation (6) overprints into second column} \includeclip{3}{59 421 532 635}{elstest-3pd.pdf} \deforange{orange} \vspace*{6pt} \noindent The typesetter will try to break the equation which need not necessarily be to the liking of the author or as it happens, typesetter's break point may be semantically incorrect. Therefore, authors may check their submissions for the incidence of such long equations and break the equations at the correct places so that the final typeset copy will be as they wish. \section{Bibliography} Three bibliographic style files (\verb+*.bst+) are provided --- \file{elsarticle-num.bst}, \file{elsarticle-num-names.bst} and \file{elsarticle-harv.bst} --- the first one can be used for the numbered scheme, second one for numbered with new options of \file{natbib.sty}. The third one is for the author year scheme. In \LaTeX{} literature, references are listed in the \verb+thebibliography+ environment. Each reference is a \verb+\bibitem+ and each \verb+\bibitem+ is identified by a label, by which it can be cited in the text: \verb+\bibitem[Elson et al.(1996)]{ESG96}+ is cited as \verb+\citet{ESG96}+. \noindent In connection with cross-referencing and possible future hyperlinking it is not a good idea to collect more that one literature item in one \verb+\bibitem+. The so-called Harvard or author-year style of referencing is enabled by the \LaTeX{} package \file{natbib}. With this package the literature can be cited as follows: \begin{enumerate}[\textbullet] \item Parenthetical: \verb+\citep{WB96}+ produces (Wettig \& Brown, 1996). \item Textual: \verb+\citet{ESG96}+ produces Elson et al. (1996). \item An affix and part of a reference: \verb+\citep[e.g.][Ch. 2]{Gea97}+ produces (e.g. Governato et al., 1997, Ch. 2). \end{enumerate} In the numbered scheme of citation, \verb+\cite{<label>}+ is used, since \verb+\citep+ or \verb+\citet+ has no relevance in the numbered scheme. \file{natbib} package is loaded by \file{elsarticle} with \verb+numbers+ as default option. You can change this to author-year or harvard scheme by adding option \verb+authoryear+ in the class loading command. If you want to use more options of the \file{natbib} package, you can do so with the \verb+\biboptions+ command, which is described in the section \ref{sec:usage}, \nameref{sec:usage}. For details of various options of the \file{natbib} package, please take a look at the \file{natbib} documentation, which is part of any standard \LaTeX{} installation. In addition to the above standard \verb+.bst+ files, there are 10 journal-specific \verb+.bst+ files also available. Instruction for using these \verb+.bst+ files can be found at \href{http://support.stmdocs.in/wiki/index.php?title=Model-wise_bibliographic_style_files} {http://support.stmdocs.in} \section{Graphical abstract and highlights} A template for adding graphical abstract and highlights are available now. This will appear as the first two pages of the PDF before the article content begins. \pagebreak Please refer below to see how to code them. \begin{vquote} .... .... \end{abstract} \begin{graphicalabstract} \end{graphicalabstract} \begin{highlights} \item Research highlight 1 \item Research highlight 2 \end{highlights} \begin{keyword} .... .... \end{vquote} \section{Final print}\label{sec:final} The authors can format their submission to the page size and margins of their preferred journal. \file{elsarticle} provides four class options for the same. But it does not mean that using these options you can emulate the exact page layout of the final print copy. \lmrgn=3em \begin{description} \item [\texttt{1p}:] $1+$ journals with a text area of 384pt $\times$ 562pt or 13.5cm $\times$ 19.75cm or 5.3in $\times$ 7.78in, single column style only. \item [\texttt{3p}:] $3+$ journals with a text area of 468pt $\times$ 622pt or 16.45cm $\times$ 21.9cm or 6.5in $\times$ 8.6in, single column style. \item [\texttt{twocolumn}:] should be used along with 3p option if the journal is $3+$ with the same text area as above, but double column style. \item [\texttt{5p}:] $5+$ with text area of 522pt $\times$ 682pt or 18.35cm $\times$ 24cm or 7.22in $\times$ 9.45in, double column style only. \end{description} Following pages have the clippings of different parts of the title page of different journal models typeset in final format. Model $1+$ and $3+$ will have the same look and feel in the typeset copy when presented in this document. That is also the case with the double column $3+$ and $5+$ journal article pages. The only difference will be wider text width of higher models. Therefore we will look at the different portions of a typical single column journal page and that of a double column article in the final format. \begin{center} \hypertarget{bsc}{} \hyperlink{sc}{ {\bf [Specimen single column article -- Click here]} } \hypertarget{bsc}{} \hyperlink{dc}{ {\bf [Specimen double column article -- Click here]} } \end{center} \src{}\hypertarget{sc}{} \deforange{blue!70} \hyperlink{bsc}{\includeclip{1}{88 120 514 724}{elstest-1p.pdf}} \deforange{orange} \src{}\hypertarget{dc}{} \deforange{blue!70} \hyperlink{bsc}{\includeclip{1}{27 61 562 758}{elstest-5p.pdf}} \deforange{orange} \end{document}
{'timestamp': '2021-02-02T02:00:57', 'yymm': '1904', 'arxiv_id': '1904.10032', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.10032'}
arxiv
\section{Introduction} \label{intro} Diffusion-Limited Aggregation (DLA) is a kinetic model for cluster growth, first described by Witten and Sander \cite{PhysRevLett.47.1400}, which consists of an idealization of the way dendrites or dust particles form, where the rate-limiting step is the diffusion of matter to the cluster. The original DLA model consists of a series of particles that are thrown one by one from the top edge of a d-dimensional grid, where $d\geq 2$. The sites in the grid can either be occupied or empty. Initially all the sites in the grid are empty, except for the bottom line which begins and remains occupied. Each particle follows a random walk in the grid, starting from a random position in the top edge, until it neighbors an occupied site, or the particle escapes from the top edge or one of the lateral edges. In case the particle finds itself neighboring an occupied site, the current position of the particle becomes occupied and the next particle is thrown. The set of occupied sites is called a \emph{cluster}. \\ \begin{figure}[h] \begin{center} \includegraphics[width=0.6\textwidth]{4DLAFIN.png} \label{fig:1} \caption{A realization of the dynamics for a $200 \times 200$ grid.} \end{center} \end{figure} Clusters generated by the dynamics are highly intricate and fractal-like (see Figure \ref{fig:1}); they have been shown to exhibit the properties of scale invariance and multifractality \cite{meakin1983diffusion, halsey1986scaling}. DLA clusters have been observed to appear in electrodeposition, dielectrics and ion beam microscopy \cite{brady1984fractal, nittmann1985fractal, niemeyer1984fractal}. Nevertheless, perhaps the fundamental aspect of DLA is its profound connection to Hele-Shaw flow: it has been shown that DLA is its stochastic counterpart \cite{chan1988simulating, koza1991equivalence}. \newpage In this article we study \emph{restricted versions of DLA}, which consist in the limitation of the directions a particle is allowed to move within the grid. We ask what would be the consequences of restricting the particles movement in terms of computational complexity. More precisely, we consider four models, parameterized by their number of allowed movement directions, $k\in \{1,2,3,4\}$. The $4$-DLA model is simply the two-dimensional DLA model, i.e. when the particles can move in the $4$ cardinal directions. The $3$-DLA model is the DLA model when the particles can only move into the South, East or West direction. In the $2$-DLA model, the directions are restricted to the South and East. Finally, in the $1$-DLA model, the particles can only move downwards. \\ Even though the particles have restricted movements, it is possible to notice that the fractal-like structures are still present in the clusters obtained by the restricted DLA (see Figure \ref{fig:dynex}).\\ It is interesting to note that, in fact, the $1$-DLA model is a particular case of another computational model created to described processes in statistical physics, that of the Ballistic Deposition Model. In this model, there is a graph and a set of particles that are thrown into the vertices at some fixed initial height $h$. The particle's height decreases one unit at a time, until it reaches the bottom (height $0$ or meets another particle, i.e. there is a particle in an adjacent vertex at the same height, or in the same vertex just behind. The $1$-DLA model corresponds to the Ballistic Deposition model when the graph is an undirected path. \\ \begin{figure}[H] \begin{center} \includegraphics[width = 5cm ]{ejemploDLA.png}\hspace{0.5cm} \includegraphics[width = 5cm ]{ejemplo3D.png}\vspace{0.5cm} \includegraphics[width = 5cm]{ejemplo2D.png}\hspace{0.5cm} \includegraphics[width = 5cm]{ejemplo1D.png} \caption{DLA simulation for four (top left), three (top right), two (bottom left) and one (bottom right) directions, when $N=100$. } \label{fig:dynex} \end{center} \end{figure} Due to the generated cluster's properties, theoretical approaches to the DLA model are usually in the realm of fractal analysis, renormalization techniques and conformal representations \cite{barra2002iterated}. In this article we consider a perhaps unusual approach to study the DLA model (and its restricted versions), related with its computational capabilities, the difficulty of simulating their dynamics, and the possibility of characterizing the patterns they produce. Machta and Greenlaw studied, within the framework of computational complexity theory, the difficulty of computing whether a given site on the grid becomes occupied after the dynamics have taken place, i.e. all the particles have stuck to the cluster or have been discarded \cite{machta1996computational}. Inspired by their work, we consider two decision problems:\\ \begin{itemize} \item {\textsc{DLA-Prediction}}, which receives a sequence of trajectories for $n$ particles (i.e. the trajectories are deterministic and explicit) and the coordinates of a site in the lattice as input. The question is whether the given coordinate is occupied by a particle after the $n$ particles are thrown. \\ \item {\textsc{DLA-Realization}}, which receives an $n\times n$ sized pattern within the two-dimensional grid as input, and whose question is whether that pattern can be produced by the DLA model. \\ \end{itemize} For each $k\in \{1, 2, 3\}$ we call {$k$-\textsc{DLA-Prediction}} and $k$-\textsc{DLA-Realization}, respectively, the problems {\textsc{DLA-Prediction}} and {\textsc{DLA-Realization}} restricted to the $k$-DLA model. The computational complexity of a problem can be defined as the amount of resources, like time or space, needed to computationally solve it. Intuitively, the complexity of {\textsc{DLA-Prediction}} represent \emph{how efficiently} (in terms of computational resources) we are able to simulate the dynamics of DLA. On the other hand, the complexity of {\textsc{DLA-Realization}} represent \emph{how complex} are the patterns produced by DLA model. \\ We consider four fundamental complexity classes: {{\bf L}}, {{\bf P}}, {{\bf NL}} and {{\bf NP}}. Classes {{\bf L}} and {{\bf P}} contain the problems that can be solved in a \emph{deterministic} Turing machine that use \emph{logarithmic space} and take \emph{polynomial time}, respectively. On the other hand {{\bf NL}} and {{\bf NP}} are the classes of problems that can be solved in a \emph{non-deterministic} Turing machine that use \emph{logarithmic space} and take \emph{polynomial time}, respectively. For detailed definitions and characterizations of these classes we recommend the book of Arora and Barak \cite{arora2009computational}. A convention between computer theorists states that {{\bf P}} is the class of problems that can be solved \emph{efficiently} with respect to computation time. In that context, {{\bf NP}} can be characterized as the classes of problems that can be \emph{efficiently verified} with respect to computation time. Similarly, the same conventions hold for {{\bf L}} and {{\bf NL}} changing computation time for space. \\ It is easy to see that ${\bf L} \subseteq {\bf NL} \subseteq {\bf P} \subseteq {\bf NP}$, though it is unknown if any of these inclusions is proper. Perhaps the most famous conjecture in Computational Complexity theory is \textbf{P} $\neq$ \textbf{NP}. Put simply, this conjecture states that there are some problems whose solution can be efficiently verified but cannot be efficiently found. As mentioned in last paragraph, in this context \emph{efficiently} means polynomial time. Similarly, it is conjectured that ${\bf L} \neq {\bf NL}$, where in this case efficiently refers to logarithmic space. It is also conjectured that ${\bf NL} \neq {\bf P}$, meaning that some problems can be computed efficiently with respect to computation time, but cannot be verified (or computed) efficiently with respect to space \cite{arora2009computational}. \\ The problems in ${\bf P}$ that are the most likely to not belong to ${\bf NL}$ (hence not in ${\bf L}$) are the {{\bf P}-Complete} problems \cite{Greenlaw:1995}. A problem is {{\bf P}-Complete} if any other problem in ${\bf P}$ can be reduced to it via a \emph{log-space reduction}, i.e. a function calculable in logarithmic space that takes \emph{yes}-instances of one problem into the other. In a nutshell, it is unlikely that some {{\bf P}-Complete} problem belongs to {{\bf NL}}, because in that case we would have that ${\bf NL} = {\bf P}$. Similarly a problem is {{\bf NL}-Complete} if any problem in {{\bf NL}} can be reduced to it via a {{\bf L}} reduction. {{\bf NL}-Complete} problems are problems in {{\bf NL}} that are the most likely to not belong to {{\bf L}}, because if some {{\bf NL}-Complete} problem were to belong in {{\bf L}}, it would imply that {{\bf NL} = {\bf L}} \cite{arora2009computational}. \\ One {{\bf P}-Complete} problem is the \textsc{Circuit Value Problem (CVP)}, which consists in, given a Boolean circuit and an truth-assignment of its input gates, compute the output value of a given gate. Roughly, this problem is unlikely to be solvable (or verifiable) in logarithmic space because there is no better algorithm than simply sequentially computes truth values of each gate of the Boolean circuit, keeping in memory the values of all gates already evaluated. One {{\bf NL}-Complete} problem is {\sc Reachability}, which consists in, given a directed graph $G$ and two vertices $s$ and $t$, decide if there is a directed path between $s$ and $t$. Roughly, this problem is unlikely to be solvable in logarithmic space because there is no way to remember all paths starting from $s$ that do not reach $t$. \\ Within this context, it was shown by Machta and Greenlaw \cite{machta1996computational}, that {\textsc{DLA-Prediction}} is {\bf P}-Complete. The proof of this fact consists of reducing to it a version of the Circuit Value Problem, which is known to be {{\bf P}-Complete}\cite{Greenlaw:1995}. Within this proof, we noticed that the gadgets used to simulate the circuits rely heavily on the fact that in the DLA model, particles are free to move in any of the four cardinal directions. On the other hand, in the context of the study of the Ballistic deposition model it was proven by Matcha and Greenlaw \cite{machta1994parallel} that $1$-{\textsc{DLA-Prediction}} is in ${\bf NC}$. The class ${\bf NC}$ is a complexity class that contains ${\bf NL}$ and is contained in ${\bf P}$. \subsection{Our results} We begin our study of the complexity of biased DLA analyzing the complexity of the {\textsc{DLA-Prediction}} problem. By extending the results of Machta and Greenlaw to the $2$-DLA model, we show that $2$-{\textsc{DLA-Prediction}} is {{\bf P}-Complete}. This result is obtained following essentially the same gadgets used for the non-restricted case, but carefully constructing them using only two directions. More precisely, the construction of Machta and Greenlaw consists in a representation of an instance of {\sc Circuit Value Problem} as a sequence of particle throws, which final positions represent the input Boolean circuit with its gates evaluated on the given input. A gate evaluated \emph{true} is represented by a path of particles, while the \emph{false} signals are represented by the lack of such path. Since the construction of the circuit must be done in logarithmic space, the sequence of particles must be defined without knowing the actual output of the gates. Therefore, the trajectory of the particles considers that, if they are do not stick on a given position, they escape through the top edge of the grid. Since this escape movement is not possible in the $2$-DLA (nor $3$-DLA) model (because particles can not move upwards), we modify the circuit construction to build the gates in a specific way, in order to give the particles enough space to escape through the rightmost edge or deposit at the bottom of the grid without disrupting the ongoing evaluation of the circuit. The fact that $2$-{\textsc{DLA-Prediction}} is {{\bf P}-Complete} directly implies that $3$-{\textsc{DLA-Prediction}} is also {\bf P}-Complete, settling the prediction problem for these two biased versions of the model. We then study the $1$-DLA model. Despite of what one might guess, the dynamics of the DLA model restricted to one direction are far from trivial (see Section \ref{sec:restrictdir} for examples of the patterns produced by this model). Indeed, we begin our study showing that this dynamics can simulate simple sorting algorithms like \emph{Bead-Sort}. Then, we improve the result of Matcha and Greenlaw by showing that $1$-{\textsc{DLA-Prediction}} is in ${\bf NL}$. This is in fact an improvement, because they showed that $1$-{\textsc{DLA-Prediction}} is in ${\bf NC}^2$ \cite{machta1994parallel}, and ${\bf NL}$ is a sub-class of ${\bf NC}^2$ \cite{Greenlaw:1995}. Our result holds for the Ballistic Deposition model, i.e., when the graph is not restricted to a path but is an arbitrary graph given in the input (we call that problem {\textsc{BD-Prediction}}). We finish our study of the prediction problem showing that the complexity of {\textsc{BD-Prediction}} \emph{cannot be improved}. Indeed, we show that {\textsc{BD-Prediction}} is {{\bf NL}-Complete}. After this, we study the {\textsc{DLA-Realization}} problem. We observe that $k$-{\textsc{DLA-Realization}} is in {{\bf NP}} for all $k\in \{1,2, 3, 4\}$. Moreover, the non-deterministic aspect of the ${\bf NP}$ algorithm solving {\textsc{DLA-Realization}} only needs to obtain the order of the sequence on which the particles are placed on the grid, rather than obtaining both the order and the trajectory that each particle follows. In fact, the trajectories can be computed in polynomial time, given the order in which the particles are placed in the grid. We then show $1$-{\textsc{DLA-Realization}} can be solved much more efficiently. In fact, we give a characterization of the patterns that the $1$-DLA model can produce. Our characterization is based on a planar directed acyclic graph (PDAG) that represents the possible ways in which the particles are able to stick. Each occupied cell of the grid is represented by a node of the PDAG, plus a unique sink vertex that represents the \emph{ground}. We show that a pattern can be constructed by $1$-DLA if and only if there is a directed path from every vertex to the ground. We use our characterization to show that $1$-{\textsc{DLA-Realization}} is in ${\bf L}$, using a result of Allender \emph{et al.} \cite{allender2006grid} solving \textsc{Reachability} in log-space, when the input graph is a single sink PDAG. Finally, we give an efficient algorithm to solve the realization problem in the $2$-DLA model, showing that $2$-{\textsc{DLA-Realization}} is in {\bf P}. Our algorithm uses the fact that in the $2$-DLA model, the particles are placed into the grid in a very specific way. By establishing which particles force the order in which they are placed. We use this fact to efficiently compute the order in which the particles are thrown, obtaining a polynomial-time algorithm. \subsection{Related work} For dynamical properties of the restricted versions of DLA, including Ballistic Deposition, we refer the reader to \cite{asselah2016diffusion, mansour2019ballistic, penrose2008growth, meakin1986ballistic}. Some problems of similar characteristics have been studied in this context, such as the Ising Model, Eden Growth, Internal DLA and Mandelbrot Percolation, to name a few \cite{machta1996computational, moore2000internal}. On the other hand, the problem of Sandpile Prediction is an example where increasing the degrees of freedom increases the computational complexity of the prediction problem. In particular, when the dimension is greater than 3, the prediction problem is {\bf P}-Complete; but when the dimension is 1, the problem is in ${\bf NC}$ \cite{moore1999computational}. Another example of a complexity dichotomy that depends on the topology of the system is the Bootstrap Percolation model \cite{chalupa}. In this model, a set of cells in a $d$-dimensional grid are initially infected, in consecutive rounds, healthy sites that have more than the half of their neighbors infected become infected. In this model, the prediction problem consists in determining wether a given site becomes infected at some point in the evolution of the system. In \cite{GMT} it is shown that this prediction problem is {{\bf P}-Complete} in three or more dimensions, while in two dimensions it is in {{\bf NC}}. Other problems related to Bootstrap percolation involve the maximum time that the dynamics takes before converging to a fixed point \cite{Benevides2015}. \subsection{Structure of the article} The first section formally introduces the different computational complexity classes, along side problems of known complexity used throughout the article. Next, the dynamics for the general case of DLA are presented, in addition to the formal definition of the two associated prediction problems that are discussed: Prediction and Realization. The third section focuses on the proof that DLA restricted to 2 or 3 directions is {{\bf P}-Complete} and with the presentation of the non-deterministic log-space algorithm for the generalized version of the one direction DLA problem, Ballistic Deposition. The last section talks about the results concerning the Realization problem, where the one-directional case is shown to be solvable in {{\bf L}}, and the two-directional case has a polynomial algorithm characterizing figures obtained from the dynamics. \section{Preliminaries} \subsection{Complexity Classes and Circuit Value Problem} In this subsection we will define the main background concepts in computational complexity required in this article. For a more complete and formal presentation we refer to the books of Arora and Barak \cite{arora2009computational} and Greenlaw et al. \cite{Greenlaw:1995}. We assume that the reader is familiar with the basic concepts dealing with computational complexity. As we mentioned in the introduction, in this paper we will only consider complexity classes into which we classify the prediction problems. {{\bf P}} is the class of problems solvable in a Turing machine that runs in polynomial time in the size of the input. More formally, if $n$ is the size of the input, then a problem is polynomial time solvable if it can be solved in time $n^{\mathcal{O}(1)}$ in a deterministic Turing machine. A logarithmic-space Turing machine consists in a Turing machine with three tapes: a read-only \emph{input tape}, a write-only \emph{output-tape} and a read-write \emph{work-tape}. The Turing machine is allowed to move as much as it likes on the input tape, but can only use $\mathcal{O}(\log n)$ cells of the work-tape (where $n$ is the size of the input). Moreover, once the machine writes something in the output-tape, it moves to the next cell and can not return. {{\bf L}} is the class of problems solvable in a logarithmic-space Turing machine. A non-deterministic Turing machine is a Turing machine whose transition function does not necessarily output a single state but one over a set of possible states. A computation of the non-deterministic Turing machine considers all possible outcomes of the transition function. The machine is required to stop in every possible computation thread, and we say that the machine \emph{accepts} if at least one thread finishes on an accepting state. A non-deterministic Turing machine is said to run in \emph{polynomial-time} if every computation thread stops in a number of steps that is polynomial in the size of the input. {{\bf NP}} is the class of problems solvable in polynomial time in a non-deterministic Turing machine. A non-deterministic Turing machine is said to run in \emph{logarithmic-space} if every thread of the machine uses only logarithmic space in the work-tape. {{\bf NL}} is the class solvable in logarithmic space in a non-deterministic Turing machine. A problem $\mathcal{L}$ is ${\bf P}$-Complete if it belongs to ${\bf P}$ and any other problem in ${\bf P}$ can be reduced to $\mathcal{L}$ via a logarithmic-space (many-to-one or Turing) reduction. A {{\bf P}-Complete} problem belongs to {{\bf NL}} implies that ${{\bf P}} ={{\bf NL}}$. One well-known {{\bf P}-Complete} problem is the \textsc{NOR-Circuit-Value-Problem}. A \emph{NOR} \emph{Boolean Circuit} is a directed acyclic graph $C$, where each vertex of $C$ has two incoming and two outgoing edges, except for some vertices that have no incoming edges (called \emph{inputs} of $C$) and others that have no outgoing edges (called \emph{outputs} of $C$). We consider that $C$ is \emph{ordered by layers} meaning that for each non-input vertex of $C$, the two incoming neighbors of $v$ are at the same distance from an input. In other words, the input gates are in the first layer, the outgoing neighbors of the input gates are in the second layer, the third layer are outgoing neighbors of the vertices in the second layer, and so on. Each vertex of $C$ has a Boolean value (\emph{true} or \emph{false}). A truth assignment of the inputs of $C$, called $I$, is an assignment of values of the input gates of $C$. The value of a non-input gate $v$ is the NOR function (the negation of the conjunction) of the value of the two incoming neighbors of $v$. A truth assignment $I$ of $C$ defines a dynamic over $C$. First the vertices of the second layer compute their value according to the values of the input gates given in $I$. Then the vertices of the third layer compute their values according to the values of the second layer, and so on until we compute the value of all the vertices of the circuit. We call $C(I)$ the truth values of the output vertices of $C$ when the input gates are assigned $I$. The \textsc{NOR-Circuit-Value-Problem} is defined as follows. \vspace{2 mm} \defproblemu{\textsc{NOR-Circuit-Value-Problem}} {A NOR Boolean Circuit $C$ of size $n$, a truth-assignment $I$ of $C$ and $g$ an output gate of $C$.}{Is $g$ true in $C(I)$?} \vspace{2 mm} In \cite{Greenlaw:1995} it is shown that this problem is {\bf P}-Complete. \begin{proposition}[\cite{Greenlaw:1995}]\label{prop: NORCVPisPC} NOR-Circuit-Value-Problem is {\bf P}-Complete. \end{proposition} A problem $\mathcal{L}$ is {{\bf NL}-Complete} if $\mathcal{L}$ belongs to ${\bf NL}$ and any other problem in ${\bf NL}$ can be reduced to $\mathcal{L}$ via a (many-to-one or Turing) reduction computable in logarithmic space. A {{\bf NL}-Complete} problem belongs to {{\bf L}} implies that ${{\bf NL}} ={{\bf L}}$. One {{\bf NL}} problem is \textsc{Reachability} \cite{arora2009computational}. An instance of \textsc{Reachability} is a directed graph $G$ and two vertices $s$ and $t$. The instance is accepted if there is a directed path from $s$ to $t$ in $G$. \textsc{Reachability} is {{\bf NL}-Complete} because the computation of a non-deterministic log-space Turing machine (which is the set of possible states of the machine plus contents of the working tape) can be represented by a directed graph of polynomial size, and the difficulty of finding a directed path in that graph is the difficulty of finding a sequence of transitions from the initial state to an accepting state. For our reductions we will need specific variant of \textsc{Reachability}, that we call \textsc{Layered DAG Exact Reachability} (\LDEReach). In this problem, the input graph $G$ is a directed acyclic graph (DAG), which is \emph{layered}, meaning that vertices of a layer only receive inputs of a previous layer and only output to a next layer (but vertices with in-degree zero are not necessarily in the first layer). Also, besides $G$ and $s$ and $t$, the input considers a positive integer $k\leq |G|$, where $|G|$ is the number of vertices of the input graph. The question is whether there exists a path of length exactly $k$ connecting vertices $s$ and $t$. We show that this restricted version is also {{\bf NL}}-Complete. \begin{proposition}\label{prop:LDEReach} {\LDEReach} is {{\bf NL}-Complete}. \end{proposition} \begin{proof} Let us first consider the problem \textsc{Exact-Reachability}. This problem receives as input a directed graph $G$, two vertices $s$ and $t$ and a positive integer $k\leq |G|$, and the question is whether there exists a directed path of length exactly $k$ connecting vertices $s$ and $t$. Is easy to see that \textsc{Exact-Reachability} is {{\bf NL}}-Complete. Indeed, it belongs to {{\bf NL}} because an algorithm can simply nondeterministically choose the right vertices to follow in a directed path of length exactly $k$ from $s$ to $t$. The verification of such path can be performed using $\mathcal{O}(\log n)$ simply verifying the adjacency of the vertices in the sequence, and keeping a counter of the length of the path, that uses $\mathcal{O}(\log n)$ space because $k\leq |G|$). Observe also that \textsc{Exact-Reachability} is {{\bf NL}-Complete} because, if we have an algorithm $\mathcal{A}$ solving \textsc{Exact-Reachability}, we can solve \textsc{Reachability} running $\mathcal{A}$ for $k\in \{0, \dots, |G|\}$. Observe now that {\LDEReach} is in {{\bf NL}} for the same reasons than \textsc{Exact-Reachability}. We now show that, {\LDEReach} is {{\bf NL}-Complete} reducing \textsc{Exact-Reachability} to it. Let $(G,s,t,k)$ be an instance of \textsc{Exact-Reachability}. Consider the instance $(G',s',t',k)$ in {\LDEReach} defined as follows. The set of vertices of $G'$ is a set of $k$ copies of $V(G)$, the set of vertices of $G$. We enumerate the copies from $1$ to $k$, and call them $V_1, \dots, V_k$. Then the set of vertices of $G'$ is $V(G') = V_1\cup \dots \cup V_k$. If $v$ is a vertex of $G$, we call $v_i$ the copy of $v$ that belongs to $V_i$. There are no edges in $G'$ between vertices in the same copy of $V$. Moreover, if $u, v$ are two adjacent vertices in $G$, we add, for each $i\in \{1, \dots, k-1\}$, a directed edge from the $i$-th copy of $u$ to the $(i+1)$-th copy $v$ in $G'$, formally: $$(u,v) \in E(G) \iff (u_i, v_{i+1}) \in E(G'), \forall i \in \{1, \dots, k\}.$$ Finally, $s'=s_1$ and $t' = t_k$. By construction we obtain that $G'$ is layered, and moreover $(G,s,t,k)$ is a \emph{yes}-instance of \textsc{Exact-Reachability} if and only if $(G',s',t',k)$ is a \emph{yes}-instance of {\LDEReach}. Finally, we remark that we can build the instance $(G', s', t', k)$ in log-space from $(G, s, t, k)$. Indeed, the algorithm has to simply make a counter $j$ from $1$ to $k$, and sequentially connect the vertices of the $j$-th copy of $V(G)$ with the vertices of the $j+1$ copy of $V(G)$. We deduce that {\LDEReach} is {{\bf NL}-Complete}. \end{proof} \subsection{The DLA Model and its Restricted Counterpart}\label{sec:restrictdir} The dynamics of the computational model of DLA are the following: We begin with a sequence of particles which will undergo a random walk starting from a position at the top edge of a $N\times N$ lattice. The sequence specifies the order in which the particles are released. Each particle moves until it neighbors an occupied site at which point it sticks to its position, growing the cluster. We begin with an occupied bottom edge of the lattice. If the particles does not stick to the cluster and leaves the lattice (exiting through the top or lateral edges), it is discarded. A new particle begins its random walk as soon as the previous particle sticks to the cluster or is discarded. This process goes on until we run out of particles in our sequence. To study this model from a computational perspective, it is convenient to consider a \emph{determinisitic} version, where the sequence of sites visited by each released particle is predefined. The prediction problem presented by Machta and Greenlaw \cite{machta1996computational} for a $d$-dimensional DLA is: \vspace{2 mm} \defproblemu{\textsc{DLA-Prediction}} {Three positive integers: $N$, $M$, $L$, a site $p$ in the two-dimensional lattice of size $N^2$, a list of random bits specifying $M$ particle trajectories of length $L$ defined by a site on the top edge of the lattice together with a list of directions of motion.}{Is site $p$ occupied after the particles have been thrown into the lattice?} \vspace{2 mm} For this prediction problem, it is shown in \cite{machta1996computational} that $\textsc{DLA-Prediction}$ is {\bf P}-Complete. The proof consists of reducing a {\bf P}-Complete \ variant of the Circuit Value Problem to the prediction problem. Their construction relies heavily on the fact that the particles can move in four directions (Up, Down, Left or Right). The question we would like to answer is: what happens to the computational complexity of the prediction problem as we restrict the number of directions the particles are allowed to move along. Instead of the four permitted directions, we restrict the particle to move in three (left, right and downwards), two (right and downwards) and one (only downwards) directions. We call the different directions by $d_1 =$ Down, $d_2 =$ Right, $d_3 =$ Left and $d_4 =$ Up. From this, we define the following class of prediction problems for $k\in \{1,2,3,4\}$:\\ \vspace{2 mm} \defproblemu{\textsc{$k$-\textsc{DLA-Prediction}}} {Three positive integers: $N$, $M$, $L$, a site $p$ in the $N\times N$ lattice, a list of random bits specifying $M$ particle trajectories of length $L$ defined by a site on the top edge of the lattice together with a list of directions of motion, where the allowed directions of motions are $\{d_1, ... , d_k\}$.}{ Is site $p$ occupied after the particles have been thrown into the lattice?} \vspace{2 mm} Where $\textsc{DLA-Prediction}$ is the same as \textsc{4-\textsc{DLA-Prediction}}.\\ In addition, we ask for the computational complexity of determining whether a given pattern or figure is obtainable through the different biased dynamics. To do this, we codify a pattern on the two-dimensional grid as a binary matrix, where 0 represents an unoccupied site, and 1 represents an occupied one (an example of this can be found in Section 4.2). We define the computational problem as follows: \vspace{2 mm} \defproblemu{\textsc{$k$-\textsc{DLA-Realization}}} {A 0-1 matrix $M$ codifying a pattern on the two-dimensional grid.}{ Does there exist a sequence of particle throws that can move only on the allowed directions of motions, $\{d_1, ... , d_k\}$, whose end figure is represented by $M$?} \vspace{2 mm} Intuitively, this problem is concerned with understanding the complexity of the figures that can be obtained through the different versions of the DLA dynamics, by looking at the computational resources that are required to understand their structure. To our knowledge, this problem has not been studied from this angle before. \section{{\textsc{DLA-Prediction}}} \subsection{Two and three directions} In this section we show that the {2-\textsc{DLA-Prediction}} problem is {\bf P}-Complete. This result directly implies that the $3$-\textsc{DLA-Prediction} \ problem is also {\bf P}-Complete. \begin{theorem} \textsc{2-\textsc{DLA-Prediction}} is {\bf P}-Complete. \end{theorem} \begin{proof} We assume without loss of generality that the two directions in which the particles move are Down and Right. The proof consists on using these directions of motion to simulate the evaluation of an instance of the NOR Circuit Value Problem, that is, we must simulate NOR gates and single input OR gates. For this purpose, we adapt the gadgets used in \cite{machta1996computational} for the 4-directional case to work on our restricted version. What we must first tackle is the way in which the outputs of one layer of the circuit are relayed into the next. For this purpose, we create wires that transmit the respective truth values. A coordinate occupied by a particle will represent True, and an empty one will represent False. Through this representation, a wire carries the value True if a stack of particles grows along it, while wires that carry the value False remain unoccupied. The wire is realized by having a pre-assigned particle for each site that makes it up. The path of each particle begins at the top of the lattice, and moves straight-down to its assigned location in the wire. If the value the wire is transmitting is True, the particle will stick at the site. If the value is False, the particle will not stick. The particle is then instructed to move two positions to the right, and then to move indefinitely downwards to be discarded by means of getting stuck to the bottom, effectively transmitting the wire's value. We note that the particle only realizes this trajectory in the case that it has not stuck, that is, the value transmitted by the wire is False. We must discard the particles transmitting the value False this way because we can't make use of the upwards direction to do so (through the top of the lattice, as was the case for the original 4-directional construction). This means, that when we finally put the circuit together, each wire must be isolated by a distance of at least four columns from the next, to permit discarding particles. This separation will later guarantee that the discarded particles do not interfere with the evaluation of the circuit: by transmitting a \textit{False} value of length $n$, by discarding on two columns, this stack of discarded particles will only reach a height of $n/2$. \begin{figure}[h] \begin{center} \includegraphics[scale=0.5]{NOR_gate.png} \label{fig:nor} \caption{Gadget for the simulation of a NOR gate. Both inputs are grown until they reach the sites directly below sites $a$ and $b$ respectively. Two successive particles then follow the path $a\rightarrow b\rightarrow c$ following the dotted line, stopping according to the inputs. The output is then grown from site $c$.} \end{center} \end{figure} Next, we must simulate the NOR gate. It receives two inputs from the preceding layer. Each of these inputs are grown as mentioned before to the sites $a$ and $b$, as shown in Fig. \ref{fig:nor}. It is important to remember that both input cables are separated by a distance of four columns, to allow for the discarding of particles. In addition, we grow a power cable to function the gate (it is a wire that always carries the \textit{True} value). Same as before, site $c$ must be at least four columns away from site $b$. Once everything is in place, the gate is evaluated as follows: A particle makes the journey $a\rightarrow b\rightarrow c$. If input 1 is \textit{True}, then the particle will stick at $a$. The same goes for input 2 and site $b$. If both inputs are \textit{False}, the particle will then stick at site $c$. In any of the 3 cases, a new wire is grown starting from site $d$. This results in the simulation of a NOR gate. \begin{figure}[h] \begin{center} \includegraphics[scale=0.6]{OR_gate.png} \label{fig:or} \caption{Gadget for the simulation of a OR gate. The input is grown up to site $1$. A first particle then follows the trajectory $a\rightarrow b$, stopping according to the truth value of the gadget's input. Then, a second particle makes the trajectory $c\rightarrow d$, also stopping according to the truth value of the input. To finalize, the power wire is grown starting from site $d$, and the output is grown from site $1$. This OR gate with a single input, in fact, simulates the crossing of the input wire with the power wire. } \end{center} \end{figure} For the single input OR gate, we proceed in a similar fashion. The input wire is grown up to site 1. There, two particles make specific trajectories: the first visits $a\rightarrow b$, while the second one $c\rightarrow d$. After these particles have completed their trajectories, the power cable is grown starting at the site left of $d$. If the input is true, then the first of the walks will stop at $a$, and the second at $c$. The wire is grown from 1, and the power cable as mentioned before, crossing the two of them. If the input is negative, then the walks will end at $b$ and $d$ respectively. As before, the wire and the power cable are grown, crossing them. We re-state the importance of the distance between the cables germinated at $1$, $c$ and $a$, for the discarding of particles. The planar NOR Circuit Value Problem instance is constructed from Right to Left and from the bottom up in the topological order provided, as it is shown in Figure \ref{fig:circuit}. There are two important commentaries we must make to ensure the functioning of the evaluation. First off, due to the fact that the power cable is akin to a wire constantly transmitting \textit{True}, the direction in which it is grown is not important, the particles will always stick at the assigned location. If the circuit is constructed with the before mentioned space between wires, the residual particles being deposited at the bottom of the lattice will not interfere with the evaluation of the circuit. Lastly, if the circuit is $k$ layers deep and consists of $I$ inputs, the dimensions of our lattice must be at least $10k\times 5I$ (the height of $10k$ amounts for the height of the gates, and the wires from one layer to the next). \begin{figure}[H] \centering \begin{tikzpicture}[x=0.75pt,y=0.75pt,yscale=-1,xscale=1] \draw (154.72,209.36) -- (192.09,209.36) -- (192.09,247.12) -- (154.72,247.12) -- cycle ; \draw (257.64,228.56) .. controls (257.64,218.05) and (266.16,209.52) .. (276.68,209.52) .. controls (287.2,209.52) and (295.72,218.05) .. (295.72,228.56) .. controls (295.72,239.08) and (287.2,247.61) .. (276.68,247.61) .. controls (266.16,247.61) and (257.64,239.08) .. (257.64,228.56) -- cycle ; \draw [line width=2.25] (173.41,246.61) -- (173.41,299.2) ; \draw [line width=2.25] (270.33,246.61) -- (270.33,299.2) ; \draw [line width=2.25] (283.22,245.51) -- (283.22,299.71) ; \draw [line width=2.25] (173.41,157.61) -- (173.41,210.2) ; \draw [line width=2.25] (276.68,157.93) -- (276.68,210.52) ; \draw (206.08,113.21) .. controls (206.08,102.69) and (214.61,94.16) .. (225.12,94.16) .. controls (235.64,94.16) and (244.17,102.69) .. (244.17,113.21) .. controls (244.17,123.72) and (235.64,132.25) .. (225.12,132.25) .. controls (214.61,132.25) and (206.08,123.72) .. (206.08,113.21) -- cycle ; \draw [line width=2.25] (276.68,157.93) -- (232.82,157.93) ; \draw [line width=2.25] (219.08,157.61) -- (173.41,157.61) ; \draw [line width=2.25] (219.08,131.32) -- (219.08,157.61) ; \draw [line width=2.25] (232.82,131.64) -- (232.82,157.93) ; \draw (373.83,94.22) -- (411.21,94.22) -- (411.21,131.98) -- (373.83,131.98) -- cycle ; \draw [line width=2.25] (392.65,131.34) -- (392.65,210.71) ; \draw (296.3,23.84) .. controls (296.3,13.32) and (304.83,4.8) .. (315.35,4.8) .. controls (325.86,4.8) and (334.39,13.32) .. (334.39,23.84) .. controls (334.39,34.36) and (325.86,42.89) .. (315.35,42.89) .. controls (304.83,42.89) and (296.3,34.36) .. (296.3,23.84) -- cycle ; \draw [line width=2.25] (309.3,41.95) -- (309.3,68.25) ; \draw [line width=2.25] (323.05,42.27) -- (323.05,68.57) ; \draw [line width=2.25] (392.52,67.32) -- (392.52,93.96) ; \draw [line width=2.25] (225.12,67.32) -- (225.12,94.16) ; \draw [line width=2.25] (392.52,67.32) -- (323.05,67.32) ; \draw [line width=2.25] (309.3,67.32) -- (225.12,67.32) ; \draw [line width=0.75] (463.54,228.76) -- (463.54,302.33) ; \draw (374.48,210.22) -- (411.85,210.22) -- (411.85,247.98) -- (374.48,247.98) -- cycle ; \draw [line width=2.25] (392.78,247.25) -- (392.78,299.84) ; \draw (412.31,228.76) -- (463.54,228.76) ; \draw (295.72,229.1) -- (374.93,229.1) ; \draw (192.55,228.56) -- (257.64,228.56) ; \draw (116.5,228.24) -- (155.17,228.24) ; \draw [line width=0.75] (116.5,113.4) -- (116.5,228.24) ; \draw (116.5,113.4) -- (206.08,113.4) ; \draw (244.17,113.21) -- (374.93,113.21) ; \draw (411.66,113.1) -- (463.86,113.1) ; \draw [line width=0.75] (463.86,22.53) -- (463.86,113.1) ; \draw (334.39,23.84) -- (463.86,23.84) ; \draw (270,303) .. controls (270,304.85) and (270.93,305.78) .. (272.78,305.78) -- (272.78,305.78) .. controls (275.43,305.78) and (276.75,306.71) .. (276.75,308.56) .. controls (276.75,306.71) and (278.07,305.78) .. (280.72,305.78)(279.53,305.78) -- (280.72,305.78) .. controls (282.57,305.78) and (283.5,304.85) .. (283.5,303) ; \draw (278,318) node {$\geq 4$}; \end{tikzpicture} \caption{A circuit consists of single-input OR gates, shown as squares, and NOR gates, shown as circles. Truth-value carrying wires are shown in bold, where as the power cable is thinner. For this particular instance $k = 3$, and $I = 4$.} \label{fig:circuit} \end{figure} \end{proof} \begin{corollary} \textsc{3-\textsc{DLA-Prediction}} is {\bf P}-Complete. \end{corollary} \begin{proof} The particles in this case are allowed to move downwards, to the left and to the right. Thus, the proof of the $\bf{P}$-Completeness is straightforward. Because we already showed that given two directions, the prediction problem is {\bf P}-Complete \ we can just ignore one of the lateral directions, and execute the same constructions shown in the previous theorem. \end{proof} Because the aforementioned proofs rely only on the use of two dimensions, both results are directly extended to the dynamics in an arbitrary number of dimensions: \begin{corollary} \textsc{2-\textsc{DLA-Prediction}} and \textsc{3-\textsc{DLA-Prediction}} in $\mathbb{Z}^{d}$, are {\bf P}-Complete. \end{corollary} \subsection{One Direction} \label{sec:pred} By restricting the directions in which we allow particles to move, our problem statement simplifies. Because particles are only permitted to fall, there is no need to specify the whole trajectory of the particles, just the column of the $N\times N$ lattice we are throwing it down. Therefore, as a first method for representing the given behavior, we describe our input as a sequence of particle drops: $S= a_{1}a_{2} \ ...\ a_{n-1}a_{n}$ where each $a_{i}\in[N]$ represents the column where the $i$-th particle is dropped, and $[n]$ denotes the set $\{1, \dots, n\}$ for each integer $n$. This one-dimensional case is actually a particular instance of a more general model called \textit{Ballistic Deposition} (BD), first introducced by Vold and Sutherland to model colloidal aggregation \cite{vold1963computer, sutherland1966comments}. The growth model takes the substrate to be an undirected graph $G = (V,E)$, where each vertex defines a column through a ''height" function $h:V\rightarrow\mathbb{N}$, which represents the highest particle at the vertex. In addition, a sequence of particle throws is given by a list of vertices $S = v_1 v_2 \ ... \ v_{n-1} v_{n}$, where a particle gets stuck at a height determined by its vertex, and all vertices neighboring it. It is easy to see that the one-dimensional DLA problem on a $N\times N$ square lattice is the special case when $G = ([N], \{(i,i+1): i\in[N]\})$. Our prediction problem is as follows: \vspace{2 mm} \defproblemu{\textsc{BD Prediction}} { A graph $G = (V,E)$, a sequence $S$ of particle throws and a site $t = (h,v)\in \mathbb{N}\times V$, where $v$ is a vertex and $h$ a specified height for it.}{Is site $t$ occupied after the particles have been thrown into the graph?} \vspace{2 mm} This problem was shown to be in ${\bf NC}^2$ by Matcha and Greenlaw using a Minimum-Weight Path parallel algorithm \cite{machta1994parallel}. We improve this result to show that the problem is in fact \textbf{\textsc{NL}}-Complete. \begin{figure}[h] \begin{center} \includegraphics[width=0.75\textwidth]{ejemplo1D.png} \caption{A realization of the one-directional dynamics of the system on a one-dimensional strip. } \end{center} \end{figure} \subsubsection{Computational Capabilities of the Dynamics} As a first look at the computational capabilities of the model, and sticking to the 1-DLA version of Ballistic Deposition, we show that we can sort natural numbers, simulating The Bead-Sort model described by Arulanandham et al. \cite{arulanandham2002bead}. This model consists of sorting natural numbers through gravity: numbers are represented by beads on rods, like an abacus, and are let loose to be subjected to gravity. As shown in \cite{arulanandham2002bead}, this process effectively sorts any given set of natural numbers. It is reasonable to think that because of the dynamics and constraints of our model (one direction of movement for the particles), the same sorting method can be applied within our model, which is in fact the case. \begin{lemma} Bead-Sort can be simulated. \end{lemma} \begin{proof} Let $A$ be a set of $n$ positive natural numbers, with $m$ being the biggest number in the set. We create a $2m\times 2m$ lattice where we will be throwing the particles. Here the $k$-th rod from the Bead-Sort model is represented by row $2k-2$ on our lattice. Now, for each number $a\in A$ we create the sequence $S_a =$ 2 4 6 $\dotsc 2a$. The total sequence of launches $S$ is created by concatenating all $S_a$ for $a\in A$. We note that because of the commutativity of our model, the order in which the concatenation is made is not relevant. Thus, throwing sequence $S$ into our lattice, effectively simulates the Bead-Sort algorithm. \end{proof} Let us give an example using the set $A = \{7, 4, 1, 10\}$. Following the proof, we must simulate 1-DLA on a $20\times 20$ square lattice, and create the sequences $S_1 =$ 2, $S_4 = $2 4 6 8, $S_7 =$ 2 4 6 8 10 12 14, and $S_{10} =$ 2 4 6 8 10 12 14 16 18 20. By releasing the sequence $S = S_1 \circ S_4 \circ S_7 \circ S_{10}$ into the lattice we obtain Figure \ref{fig:sort}, which is ordered increasingly, effectively sorting set $A$. \begin{figure}[H] \centering \begin{tikzpicture}[x=0.75pt,y=0.75pt,yscale=-1,xscale=1] \draw [draw opacity=0] (527.5,298) -- (126.5,298) -- (126.5,158) -- (527.5,158) -- cycle ; \draw [color={rgb, 255:red, 128; green, 128; blue, 128 } ,draw opacity=1 ] (527.5,298) -- (527.5,158)(507.5,298) -- (507.5,158)(487.5,298) -- (487.5,158)(467.5,298) -- (467.5,158)(447.5,298) -- (447.5,158)(427.5,298) -- (427.5,158)(407.5,298) -- (407.5,158)(387.5,298) -- (387.5,158)(367.5,298) -- (367.5,158)(347.5,298) -- (347.5,158)(327.5,298) -- (327.5,158)(307.5,298) -- (307.5,158)(287.5,298) -- (287.5,158)(267.5,298) -- (267.5,158)(247.5,298) -- (247.5,158)(227.5,298) -- (227.5,158)(207.5,298) -- (207.5,158)(187.5,298) -- (187.5,158)(167.5,298) -- (167.5,158)(147.5,298) -- (147.5,158)(127.5,298) -- (127.5,158) ; \draw [color={rgb, 255:red, 128; green, 128; blue, 128 } ,draw opacity=1 ] (527.5,298) -- (126.5,298)(527.5,278) -- (126.5,278)(527.5,258) -- (126.5,258)(527.5,238) -- (126.5,238)(527.5,218) -- (126.5,218)(527.5,198) -- (126.5,198)(527.5,178) -- (126.5,178)(527.5,158) -- (126.5,158) ; \draw [color={rgb, 255:red, 128; green, 128; blue, 128 } ,draw opacity=1 ] ; \draw [fill={rgb, 255:red, 0; green, 0; blue, 0 } ,fill opacity=1 ] (147.5,278) -- (167.5,278) -- (167.5,298) -- (147.5,298) -- cycle ; \draw [fill={rgb, 255:red, 0; green, 0; blue, 0 } ,fill opacity=1 ] (147.5,258) -- (167.5,258) -- (167.5,278) -- (147.5,278) -- cycle ; \draw [fill={rgb, 255:red, 0; green, 0; blue, 0 } ,fill opacity=1 ] (187.5,278) -- (207.5,278) -- (207.5,298) -- (187.5,298) -- cycle ; \draw [fill={rgb, 255:red, 0; green, 0; blue, 0 } ,fill opacity=1 ] (187.5,258) -- (207.5,258) -- (207.5,278) -- (187.5,278) -- cycle ; \draw [fill={rgb, 255:red, 0; green, 0; blue, 0 } ,fill opacity=1 ] (187.5,238) -- (207.5,238) -- (207.5,258) -- (187.5,258) -- cycle ; \draw [fill={rgb, 255:red, 0; green, 0; blue, 0 } ,fill opacity=1 ] (147.5,238) -- (167.5,238) -- (167.5,258) -- (147.5,258) -- cycle ; \draw [fill={rgb, 255:red, 0; green, 0; blue, 0 } ,fill opacity=1 ] (147.5,218) -- (167.5,218) -- (167.5,238) -- (147.5,238) -- cycle ; \draw [fill={rgb, 255:red, 0; green, 0; blue, 0 } ,fill opacity=1 ] (227.5,278) -- (247.5,278) -- (247.5,298) -- (227.5,298) -- cycle ; \draw [fill={rgb, 255:red, 0; green, 0; blue, 0 } ,fill opacity=1 ] (267.5,278) -- (287.5,278) -- (287.5,298) -- (267.5,298) -- cycle ; \draw [fill={rgb, 255:red, 0; green, 0; blue, 0 } ,fill opacity=1 ] (227.5,258) -- (247.5,258) -- (247.5,278) -- (227.5,278) -- cycle ; \draw [fill={rgb, 255:red, 0; green, 0; blue, 0 } ,fill opacity=1 ] (267.5,258) -- (287.5,258) -- (287.5,278) -- (267.5,278) -- cycle ; \draw [fill={rgb, 255:red, 0; green, 0; blue, 0 } ,fill opacity=1 ] (307.5,278) -- (327.5,278) -- (327.5,298) -- (307.5,298) -- cycle ; \draw [fill={rgb, 255:red, 0; green, 0; blue, 0 } ,fill opacity=1 ] (387.5,278) -- (407.5,278) -- (407.5,298) -- (387.5,298) -- cycle ; \draw [fill={rgb, 255:red, 0; green, 0; blue, 0 } ,fill opacity=1 ] (347.5,278) -- (367.5,278) -- (367.5,298) -- (347.5,298) -- cycle ; \draw [fill={rgb, 255:red, 0; green, 0; blue, 0 } ,fill opacity=1 ] (307.5,258) -- (327.5,258) -- (327.5,278) -- (307.5,278) -- cycle ; \draw [fill={rgb, 255:red, 0; green, 0; blue, 0 } ,fill opacity=1 ] (347.5,258) -- (367.5,258) -- (367.5,278) -- (347.5,278) -- cycle ; \draw [fill={rgb, 255:red, 0; green, 0; blue, 0 } ,fill opacity=1 ] (387.5,258) -- (407.5,258) -- (407.5,278) -- (387.5,278) -- cycle ; \draw [fill={rgb, 255:red, 0; green, 0; blue, 0 } ,fill opacity=1 ] (427.5,278) -- (447.5,278) -- (447.5,298) -- (427.5,298) -- cycle ; \draw [fill={rgb, 255:red, 0; green, 0; blue, 0 } ,fill opacity=1 ] (467.5,278) -- (487.5,278) -- (487.5,298) -- (467.5,298) -- cycle ; \draw [fill={rgb, 255:red, 0; green, 0; blue, 0 } ,fill opacity=1 ] (507.5,278) -- (527.5,278) -- (527.5,298) -- (507.5,298) -- cycle ; \draw [fill={rgb, 255:red, 0; green, 0; blue, 0 } ,fill opacity=1 ] (227.5,238) -- (247.5,238) -- (247.5,258) -- (227.5,258) -- cycle ; \draw [fill={rgb, 255:red, 0; green, 0; blue, 0 } ,fill opacity=1 ] (267.5,238) -- (287.5,238) -- (287.5,258) -- (267.5,258) -- cycle ; \draw (102,288) node {$10\ \rightarrow $}; \draw (103,268) node {$7\ \rightarrow $}; \draw (103,248) node {$4\ \rightarrow $}; \draw (102,229) node {$1\ \rightarrow $}; \end{tikzpicture} \caption{Figure obtained by trowing sequence $S$ into the lattice. Set $A$ is ordered decreasingly from the first row onwards.} \label{fig:sort} \end{figure} A key aspect of the present model is the commutativity of throws through non-consecutive vertices of the graph. Given a figure, $\mathcal{F}$, we define $\varphi_v(\mathcal{F})$ as the figure that results after throwing a particle through vertex $v$. We notice, that because of the dynamics of our model, the point at which a given particle freezes is determined uniquely by the state of the vertex it has been dropped in, and the state of its neighbors. Therefore, given $v\in V$: $$(\varphi_v\circ\varphi_u)(\mathcal{F}) = (\varphi_u\circ\varphi_v)(\mathcal{F}) \ \ \forall u\notin N_G(v).$$ We will later use this fact to create a better algorithm for the prediction problem.\\ \subsubsection{Non-deterministic Log-space Algorithm} There is a critical aspect of the dynamics that is exploitable to create an algorithm: if two particles are thrown on non-adjacent vertices, their relative order in the input sequence is reversible. By using this, our aim is to shuffle the sequence into another sequence with the same final configuration, but ordered in a way that allows us to quickly solve the prediction problem. Specifically, if we are able to reorganize the input sequence into one that releases particles according to the height they will ultimately end at, the remaining step to solve the problem is checking amongst the particles for the target height, if the target vertex appears.\\ Let $S$ be the input sequence of \textsc{BD Prediction}. Formally, a sequence $S = s_1 \dots s_n$ is composed of the vertices onto which each particle will be released. From $S$, we are able define a sequence of particles $p_1, \dots, p_n$ that represents the same realization as the input sequence. We define a \emph{particle} $p$, as a triple $(V(p), \textnormal{num}(p), \textnormal{pos}(p)) \in V\times [n]\times[n]$, where the first coordinate, $V(p)$, denotes the vertex onto which the particle is thrown, the second coordinate, $\textnormal{num}(p)$, is an integer representing the number of particles thrown onto vertex $V(p)$ before $p$, and the third, $\textnormal{pos}(p)$ is the position of the particle within sequence $S$. The particle description of $S$ is easily obtained by setting $V(p_i) = s_i$, $\textnormal{num}(p_i) = |\{ j \in [n]: s_j = s_i \wedge j\leq i \}|$, and $\textnormal{pos}(p_i) = i$. Let us call $\mathbb{P} = \{ p_1, \dots, p_n\}$ the \emph{set of particles} of $S$. To further break down the problem, we define the following sets: $$A(p) := \{q \in \mathbb{P}: \textnormal{pos}(q)<\textnormal{pos}(p)\},$$ $$N(p) := \{q \in A(p): V(q)\in N_{G}(V(p))\cup\{V(p)\}\},$$ $$N^=(p) := \{q \in N(p): V(q) = V(p)\}.$$ In words, $A(p)$ denotes the set of particles thrown before $p$, $N(p)$ denotes the set of particles that are thrown before $p$ on vertices adjacent to $p$, and $N^=(p)$ denotes the subset of particles that belong to $N(p)$ and are in the same vertex as $p$. For a particle $p\in \mathbb{P}$, the \emph{row of $p$}, denoted $\textnormal{row}(p)$ is the height at which the particle ends up at after the dynamics have taken place. In other words, $\textnormal{row}(p) = h(V(p))$ after releasing the sequence $S' = s_{1} \dots s_{\textnormal{pos}(p)}$ . Relative to this definition, we call $N^r$ the set of particles thrown before $p$ in vertices adjacent than $p$ that stick at row $r$, formally: $$N^r(p) = \{q \in N(p): \textnormal{row}(q) = r\}.$$ We translate the dynamics into this new notation in the following lemma: \begin{lemma}\label{lem:rows} Let $p \in \mathbb{P}$ be a particle and let $$r =\left\{ \begin{array}{ccc} 1 & \textrm{ if } & N(p) = \emptyset, \\ \max \{\textnormal{row}(q): q \in N(p)\} & \textrm{ if } & N(p) \neq \emptyset. \end{array} \right.$$ Then, $$\textnormal{row}(p) =\left\{ \begin{array}{ccc} r+1 & \textrm{ if } & N^r(p) \cap N^=(p) \neq \emptyset,\\ r & \textrm{ if } & N^r(p) \cap N^=(p) = \emptyset. \end{array} \right.$$ \end{lemma} Explicitly, if the particle is the first of its neighbors to be thrown ($N(p) = \emptyset$), its row is 1. If not, that is, if its neighbors are higher than the vertex it is thrown in ($N^r(p) \cap N^=(p) = \emptyset$), the particle sticks at their height. Lastly, if the vertex that the particle is thrown in is higher that its neighbors ($N^r(p) \cap N^=(p) \neq \emptyset$), the particle sticks one row higher than the last particle in the vertex. \begin{proof} Let $p$ be a particle such that $N(p) = \emptyset$. This implies that $p$ is the first particle thrown through vertex $V(p)$ and its adjacent vertices. From the commutativity property, we deduce that $\textnormal{row}(p) = 1$. On the other hand, $r = 1$ and $N^r(p) \cap N^=(p) = \emptyset$, so $\textnormal{row}(p) = r$. Suppose now that $N(p) \neq \emptyset$, and let $q$ be a particle in $N^r(p)$. Observe that $\textnormal{row}(q) = r$, and $\textnormal{row}(u) \leq r$ for all $u \in N(p)$. Then, when $p$ is thrown, the first particle that it encounters is $q$. Suppose that we can pick $q$ such that $V(q) = V(p)$ (i.e. $N^r(p) \cap N^=(p) \neq \emptyset$). Since $V(q) = V(p)$, we deduce that $\textnormal{row}(p) = \textnormal{row}(q) + 1 = r+1$. On the other hand, if $N^r(p) \cap N^=(p) = \emptyset$ then the coordinate $(V(p), r)$ is empty when $p$ is thrown, but some of $(u, r)$, for $u\in N_{G}(V(p))$, are occupied. We deduce that $\textnormal{row}(p) = \textnormal{row}(q) = r$. \end{proof} We create a weighted graph that codifies the dependence of the particles to each other. Let $G_S$ be a weighted directed graph defined from $S$ as follows: the vertex set of $G_S$ is the set of particles $\mathbb{P}$ plus one more vertex $g$, called the \emph{ground} vertex. The edges of $G_S$ have weights, given by the weight function $W$ defined as: $$W(p,q) = \left\{ \begin{array}{cl} 1 &\textrm{ if }~ (p=g) \wedge (N(q) = \emptyset), \\ 1 &\textrm{ if }~ p\in N^=(q), \\ 0 & \textrm{ if }~ p\in N(q) \setminus N^=(q),\\ -\infty & \textrm{ otherwise.}\end{array} \right.$$ Observe that if we keep only the edges with weight different than $-\infty$, the obtained graph has no directed cycle, i.e. it is a directed acyclic graph. Moreover, the set of incoming edges of vertex $p$ is $N(p)$ if $N(p)\neq \emptyset$, and $\{g\}$ otherwise. For $p\in \mathbb{P}$, we call $\tilde{\omega}_{gp}$ the longest (maximum weight) path from $g$ to $p$ in $G_S$. \begin{theorem}\label{theo:grafodla} For every $p\in \mathbb{P}$, $\textnormal{row}(p) = \tilde{\omega}_{gp}$. \end{theorem} \begin{proof} We reason by induction on $\textnormal{pos}(p)$. Let $p\in \mathbb{P}$ be the particle such that $\textnormal{pos}(p)=1$. Observe that $p$ has only one incoming edge, which comes from $g$, and $W(g,p)=1$. Then $\tilde{\omega}_{gp} = 1 = \textnormal{row}(p)$. Suppose now that $\textnormal{row} (p) = \tilde\omega_{gp}$ for every particle $q$ such that $\textnormal{pos}(q) \leq k$ and let $p$ be a particle with $\textnormal{pos}(p) = k+1$. If $N(p) = \emptyset$, then, like in the base case, the only incoming edge of $p$ is $g$, and from Lemma \ref{lem:rows} we deduce that $\textnormal{row}(p) = 1 = \tilde{\omega}_{gp}$. Suppose now that $N(p)$ is different than $\emptyset$. Let $q$ be a particle in $N(p)$ such that $\textnormal{row}(q)$ is maximum, i.e. $\textnormal{row}(q) = \max\{ \textnormal{row}(u): u\in N(p)\} $. Observe that, from induction hypothesis and the choice of $q$, $\tilde\omega_{gq} \geq \tilde\omega_{gu}$ for all $u\in N(p) \setminus \{q\}$. Moreover, $\tilde\omega_{gp} \leq \tilde\omega_{gq} + 1$. Suppose that $q$ can be chosen to be such that $V(q) = V(p)$. Lemma \ref{lem:rows} then implies that $\textnormal{row}(p) = \textnormal{row}(q) + 1$. On the other hand, the path from $g$ to $p$ that passes through $q$ is of weight $\tilde\omega_{gq} + 1$. We deduce that $\tilde\omega_{gp} = \tilde\omega_{gq}+1 = \textnormal{row}(q)+1 = \textnormal{row}(p)$. Suppose now that for all $u \in N^=(p)$, $\textnormal{row}(u)$ is strictly smaller than $\textnormal{row}(q)$. In this case, Lemma \ref{lem:rows} implies that $\textnormal{row}(p) = \textnormal{row}(q)$. On the other hand, the path from $g$ to $p$ that passes through $q$ is of weight $\tilde\omega_{gq}$, which is greater or equal than $\tilde\omega_{gu}$, for all $u\in N(p) \setminus N^=(p)$ and strictly greater than $\tilde\omega_{gu}$, for all $u \in N^=(p)$. We deduce that $\tilde\omega_{gp} = \tilde\omega_{gq} = \textnormal{row}(q)=\textnormal{row}(q)$. \end{proof} \vspace{1mm} We now present an \textbf{NL}-algorithm for the prediction problem. Given a site $(h, v)$, we want to non-deterministically obtain a path through graph $G_{S}$ that will guarantee the site will be occupied by a particle. Each step of our algorithm we will non-deterministically guess a pair consisting of the next particle, and the corresponding weight of the transition between the last particle and the new one, such that the sum of the weights is the maximum weight to the final particle.\\ We say a particle $p$ is valid for an input sequence $S$, if $p\in\mathbb{P}$. The following log-space algorithm verifies if a particle is valid. \begin{algorithm}[H] \KwIn{A sequence $S$ and a particle $p \in V\times[n]\times[n]$} \KwOut{Accept if particle $p$ is valid.} Check if $V(p) = s_{\textnormal{pos}(p)}$\; Sum $\leftarrow 0$ \For{$i\in\{1, ..., \textnormal{pos}(p)\}$}{ \If{$s_{i} = V(p)$}{ Sum $\leftarrow $ Sum $+ \ 1$\; } } \eIf{$\textnormal{Sum} = \textnormal{num}(p)$}{ Accept\; }{Reject.\;} \caption{} \end{algorithm} At each step of the for loop of the algorithm, we must remember the value of Sum, the particles vertex, $V(p)$, and the current index of the iteration. This amounts to using $\mathcal{O}(\log(n))$ space. We also present a log-space algorithm to determine wether the obtained transition weight corresponds to the value of the weight function \begin{algorithm}[H] \KwIn{A sequence $S$, two valid particles $p,q \in V\times[n]\times[n]$, and $w\in\{0,1\}$} \KwOut{Accept if $W(p,q) = w$.} \If{$p = g$}{ \For{$i<\textnormal{pos}(q)$}{ Check that $s_i$ is not adjacent to $V(q)$\; } Accept\; } \If{$w = 1$}{ Check that $\textnormal{pos}(p) < \textnormal{pos}(q)$ and $V(p) = V(q)$\; Accept\; } \If{$w = 0$}{ Check that $\textnormal{pos}(p) < \textnormal{pos}(q)$\; Check that $V(p)\neq V(q)$\; Check that $V(p)$ is adjacent to $V(q)$ Accept\; } Reject\; \caption{} \end{algorithm} For this algorithm, the only case where information needs to be stored is when $p = g$. For this instance, each iteration of the for loop must remember the index of the iteration, and the vertex $V(q)$. Therefore, this algorithm uses $\mathcal{O}(\log(n))$ space. Combining these two subroutines, we are now ready to present the main algorithm. \begin{algorithm}[H] \label{algo:main} \KwIn{A graph $G = (V, E)$, a sequence $S$ and a site $t=(x,v) \in \mathbb{N}\times V$} \KwOut{Accept if a particle occupies site $t$ and reject otherwise.} Non-deterministically obtain $m$, the number of particles, and $p_1$. Write them down.\; Check if $p_{1}$ is valid and that $W(g, p_1) = 1$\; Sum $\leftarrow 1$\; Write down Sum. \For{$j\in\{2, ..., m\}$}{ Non-deterministically obtain particle $p_{j}$ and the transition weight $w_{j-1, j}$, and write them down. Check if $p_{j}$ is valid.\; Check if $W(p_{j-1},p_{j}) = w_{j-1, j}$\; Sum $\leftarrow $ Sum $ + \ w_{j-1, j}$\; Erase $p_{j-1}$ and $w_{j-1, j}$\; } \eIf{$\textnormal{Sum} = x$ and $V(p_m) = v$}{ Accept\; }{Reject\;} \caption{\textbf{NL} algorithm for \textsc{BD Prediction}} \end{algorithm} At the $j$-th step of this algorithm, we must retain the following information: the sum of the weights so far, particles $p_{j-1}$ and $p_j$, the current weight $w_{j-1,j}$. This means that around $4\log(n) = \mathcal{O}(\log(n))$ space is used on the tape. \begin{proposition} {\textsc{BD-Prediction}} is in \textsc{\textbf{NL}}. \end{proposition} \begin{proof} Let us show that Algorithm \ref{algo:main} decides \textsc{BD Prediction}. Let $S$ be an input sequence and $P = (h,v)$ an input site. \\ If the release of $S$ on to the underlying graph results on site $P$ being occupied, by Theorem \ref{theo:grafodla} we know that there exists a particle $q\in\mathbb{P}$ such that $h = \textnormal{row}(q) = \tilde{\omega}_{gq}$ and $V(q) = v$. Let $C = g \ p_1 \ p_2 \ ... \ p_{m-1} \ p_{m}$ be the maximum weight path of weight $\tilde{\omega}_{gq}$, where $p_{m} = q$. Then, for the $j$-th non-deterministic choice the algorithm makes, it obtains the pair: $p_{j}$ and $W(p_{j-1}, p_{j})$.\\ If the algorithm accepts for $S$ and $P$, we will obtain a sequence of particles such that the sum of the transition weights is exactly $h$ and that $V(p_{m}) = v$. This means that the weight from the ground to the last particle will indeed be $h = \tilde{\omega}_{g p_{m}}$. Due to Theorem \ref{theo:grafodla}, this means that $\textnormal{row}(p_{m}) = \tilde{\omega}_{g p_{m}} = h$. Therefore, particle $p_m$ indeed occupies site $P$. \end{proof} \begin{theorem} {\textsc{BD-Prediction}} is \textsc{\textbf{NL}}-Complete. \end{theorem} \begin{proof} Given proposition \ref{prop:LDEReach}, in order to show that the problem is \textbf{\textsc{{NL}}}-Hard, we will reduce an instance of {\LDEReach} to the Ballistic Deposition problem. \\ Let $(G, s, t, k)$ be an instance of {\LDEReach}, where $m$ is the number of layers of $G$, and let $i\in [m]$ be the index such that $s\in V_{i}$. The idea is to throw two particles for each vertex in all layers from $i$ to $i+k$. This way, the height at which the particles freeze will increase with each layer. Formally, for every $i < j\leq i+k$ and every $u\in V_{j}$ we create the sequence $S_{u} = u u$ (two particles are thrown in vertex $u$). Concatenating these sequences, we obtain a sequence of throws on the whole layer $S_j = \bigcirc_{u\in V_{j}} S_{u}$. We note that due to the structure of the graph and the commutativity of the dynamics, the order in which these sequences are concatenated does not matter because no two vertices in the same layer are adjacent. Finally, our input sequence will be the concatenation of the sequences associated to every layer from the $i$-th layer to the $i+k$-th one, $S = S_{s} \circ \bigcirc_{j=i+1}^{i+k} S_j$. The order in which these sequences are concatenated is important, and must be done in increasing order according to their index. At any point in this process the only information retained is the vertex for which we are currently creating the sequence $S_{u}$. This only requires $\log(n)$ space to store, making this process a log-space reduction. By defining the site $P = (k+1, t)$, we create an instance of \textsc{BD-Prediction}: $(G, S, P)$. Let us prove that this is indeed a reduction.\\ If $(G, s, t, k)\in \LDEReach$, then there exists a directed path $C = v_{0} \ ... \ v_{k}$ in $G$, where $s = v_0$ and $t = v_{k}$. Because of the layered structure of the graph, if $s\in V_{i}$ then $v_{j}\in V_{i+j}$. Then, because by construction, for every vertex on $C$ two particles will be dropped, the height of the last particle dropped in $v_j$ will be $j+1$, meaning that the last particle dropped on $v_k = t$ will have a height of $k+1$. This means that site $P$ will in fact be occupied, and therefore $(G, S, P)\in\textsc{BD-Prediction}$.\\ If $(G, S, P)\in\textsc{BD-Prediction}$, site $P = (k+1, t)$ is occupied after the sequence of particles, $S$, has been released onto $G$. Due to our construction, if site $P$ is occupied, site $(k, t)$ must also be occupied by a particle. Let $l\in [m]$ be such that $t\in V_{l}$. Because only two particles are thrown at each vertex, for the latter site to be occupied there must exist a vertex $v_{1}\in V_{l-1}$ adjacent to $t$ such that sites $(k, v_{1})$ and $(k-1, v_{1})$ are occupied. Iterating this process, we obtain a sequence $v_1 \ ... \ v_{k-1}$ such that $v_{i}$ is adjacent to $v_{i-1}$ and sites $(k - i + 1, v_{i})$ and $(k-i, v_{i})$ are occupied, for every $i\in\{2, ..., k-1\}$. By virtue of the construction of $S$, the only posible way in which site $(1, v_{k-1})$ is occupied is that $s = v_{k-1}$. This proves that $(G, s, t, k)\in \LDEReach$, concluding our proof. \end{proof} \section{Shape Characterizations and Realization} Although the figures obtained by simulating the dynamics are complex and fractal-like, not every shape is obtainable as an end product. This naturally leads to the problem of characterizing the figures which are obtainable through the dynamics, for the different restrictions of the DLA model. A crucial observation is the fact that not all connected shapes are realizable. Figure \ref{infact} shows shapes that are not achievable for each of the restricted versions. \begin{figure}[H] \label{infact} \begin{center} \includegraphics[scale=0.5]{infactibles.png} \label{fig:inf} \caption{Four non-constructible figures with the respective maximum number of directions where it is not constructible. The last figure is not constructible even with four directions.} \end{center} \end{figure} Given a fixed number of allowed directions, determining whether a given figure is realizable is an \textsc{\textbf{NP}} problem, where the non-deterministic choices of the algorithm are the order in which the particles are released. Having the order, it is possible to compute the trajectories that each particle takes in polynomial time, by finding a path that does not neighbor the already constructed cluster, from the place at which it is released to its final destination. \\%This certificate can be checked in polynomial time by simply executing the dynamics. \marginpar{Agregar que basta conocer el orden}. We give better algorithms for the shape characterization problems for both 1-DLA and 2-DLA, showing that the former belongs to the class of log-space solvable problems, ${\bf L}$, and the latter to ${\bf P}$. \subsection{One Direction} To characterize shapes created by the one-directional dynamics, given a sequence of drops $S$, and its corresponding shape $\mathcal{F}(S)\in\{0,1\}^{m\times n}$, we construct a planar directed acyclic graph (DAG), $G = (V,E)$, that takes into account the ways in which a shape can be constructed with the dynamics. We construct $G$ in two steps.\\ We begin by constructing $G_a = (V_a, E_a)$, where: \begin{equation*} \begin{aligned} V_a &=\{ij : \mathcal{F}(S)_{ij} = 1\} \cup \{g\} ,\\ E_1 &= \{(ij, i j +1) : \mathcal{F}(S)_{ij} = \mathcal{F}(S)_{i j + 1} = 1\}, \\ E_2 &=\{(ij, i j-1) : \mathcal{F}(S)_{ij} = \mathcal{F}(S)_{i j - 1} = 1\},\\ E_3 &= \{(ij, i+1 j) : \mathcal{F}(S)_{ij} = \mathcal{F}(S)_{i+1 j} = 1\},\\ E_4 &= \{(nj, g) : \mathcal{F}(S)_{nj} = 1\}, \end{aligned} \end{equation*} and $E_a = E_1 \cup E_2 \cup E_3 \cup E_4$. The intuition is the following: we create a vertex for each block in the shape and one representing the ground where the initial particles stick. $E_1$ and $E_2$ account for the particles that stick through their sides, $E_3$ accounts for particles falling on top of each other and finally $E_4$ connects the first level to the ground. For example, given the sequence $S =$ 2 7 7 2 6 3 4 4 4 5 6 3 2 6 2, we depict the obtained shape and corresponding graph in Figure \ref{fig:example}. \begin{figure}[H] \begin{center} \includegraphics[scale = 0.9]{ejemplo.png} \label{fig:3} \begin{tikzpicture}[scale=0.1][H] \tikzstyle{every node}+=[inner sep=0pt] \draw [black] (44.5,-51.9) circle (3); \draw (44.5,-51.9) node {$g$}; \draw [black] (18.7,-46.9) circle (3); \draw (18.7,-46.9) node {$5, 2$}; \draw [black] (66.2,-45.1) circle (3); \draw (66.2,-45.1) node {$5, 7$}; \draw [black] (18.7,-34.6) circle (3); \draw (18.7,-34.6) node {$4, 2$}; \draw [black] (29,-34.6) circle (3); \draw (29,-34.6) node {$4, 3$}; \draw [black] (39.2,-34.6) circle (3); \draw (39.2,-34.6) node {$4, 4$}; \draw [black] (38.4,-26.6) circle (3); \draw (38.4,-26.6) node {$3, 4$}; \draw [black] (38.4,-18.1) circle (3); \draw (38.4,-18.1) node {$2, 4$}; \draw [black] (47.7,-19.1) circle (3); \draw (47.7,-19.1) node {$2, 5$}; \draw [black] (57.5,-18.9) circle (3); \draw (57.5,-18.9) node {$2, 6$}; \draw [black] (28.3,-18.9) circle (3); \draw (28.3,-18.9) node {$2, 3$}; \draw [black] (18.7,-18.9) circle (3); \draw (18.7,-18.9) node {$2, 2$}; \draw [black] (69.8,-33.3) circle (3); \draw (69.8,-33.3) node {$4, 7$}; \draw [black] (57.5,-33.3) circle (3); \draw (57.5,-33.3) node {$4, 6$}; \draw [black] (57.5,-9) circle (3); \draw (57.5,-9) node {$1, 6$}; \draw [black] (18.7,-9) circle (3); \draw (18.7,-9) node {$1, 2$}; \draw [black] (63.34,-46) -- (47.36,-51); \fill [black] (47.36,-51) -- (48.28,-51.24) -- (47.98,-50.29); \draw [black] (21.65,-47.47) -- (41.55,-51.33); \fill [black] (41.55,-51.33) -- (40.86,-50.69) -- (40.67,-51.67); \draw [black] (68.92,-36.17) -- (67.08,-42.23); \fill [black] (67.08,-42.23) -- (67.79,-41.61) -- (66.83,-41.32); \draw [black] (60.5,-33.3) -- (66.8,-33.3); \fill [black] (66.8,-33.3) -- (66,-32.8) -- (66,-33.8); \draw [black] (66.8,-33.3) -- (60.5,-33.3); \fill [black] (60.5,-33.3) -- (61.3,-33.8) -- (61.3,-32.8); \draw [black] (18.7,-37.6) -- (18.7,-43.9); \fill [black] (18.7,-43.9) -- (19.2,-43.1) -- (18.2,-43.1); \draw [black] (26,-34.6) -- (21.7,-34.6); \fill [black] (21.7,-34.6) -- (22.5,-35.1) -- (22.5,-34.1); \draw [black] (21.7,-34.6) -- (26,-34.6); \fill [black] (26,-34.6) -- (25.2,-34.1) -- (25.2,-35.1); \draw [black] (36.2,-34.6) -- (32,-34.6); \fill [black] (32,-34.6) -- (32.8,-35.1) -- (32.8,-34.1); \draw [black] (32,-34.6) -- (36.2,-34.6); \fill [black] (36.2,-34.6) -- (35.4,-34.1) -- (35.4,-35.1); \draw [black] (38.7,-29.59) -- (38.9,-31.61); \fill [black] (38.9,-31.61) -- (39.32,-30.77) -- (38.32,-30.87); \draw [black] (38.4,-21.1) -- (38.4,-23.6); \fill [black] (38.4,-23.6) -- (38.9,-22.8) -- (37.9,-22.8); \draw [black] (35.41,-18.34) -- (31.29,-18.66); \fill [black] (31.29,-18.66) -- (32.13,-19.1) -- (32.05,-18.1); \draw [black] (31.29,-18.66) -- (35.41,-18.34); \fill [black] (35.41,-18.34) -- (34.57,-17.9) -- (34.65,-18.9); \draw [black] (41.38,-18.42) -- (44.72,-18.78); \fill [black] (44.72,-18.78) -- (43.98,-18.2) -- (43.87,-19.19); \draw [black] (44.72,-18.78) -- (41.38,-18.42); \fill [black] (41.38,-18.42) -- (42.12,-19) -- (42.23,-18.01); \draw [black] (50.7,-19.04) -- (54.5,-18.96); \fill [black] (54.5,-18.96) -- (53.69,-18.48) -- (53.71,-19.48); \draw [black] (54.5,-18.96) -- (50.7,-19.04); \fill [black] (50.7,-19.04) -- (51.51,-19.52) -- (51.49,-18.52); \draw [black] (21.7,-18.9) -- (25.3,-18.9); \fill [black] (25.3,-18.9) -- (24.5,-18.4) -- (24.5,-19.4); \draw [black] (25.3,-18.9) -- (21.7,-18.9); \fill [black] (21.7,-18.9) -- (22.5,-19.4) -- (22.5,-18.4); \draw [black] (18.7,-12) -- (18.7,-15.9); \fill [black] (18.7,-15.9) -- (19.2,-15.1) -- (18.2,-15.1); \draw [black] (57.5,-12) -- (57.5,-15.9); \fill [black] (57.5,-15.9) -- (58,-15.1) -- (57,-15.1); \end{tikzpicture} \end{center} \label{fig:example} \caption{Shape and graph obtained from sequence $S =$ 2 7 7 2 6 3 4 4 4 5 6 3 2 6 2.} \end{figure} \begin{lemma} \label{constr} A configuration is constructible iff $\forall ij \in V_a\setminus\{g\}$ there exists a directed path between $ij$ and $g$. \end{lemma} \begin{proof} Given a constructible configuration, by virtue of the definition, there is a sequence $S$ of particle drops that generates the configuration. Therefore, by the dynamics of our system and the construction of the graph, for each node in our graph, there exists a directed path to the \emph{ground}, represented by node $g$. Now, let $G = (V,E)$ be the graph corresponding to a given configuration on the grid. If we have that $\forall ij \in V\setminus\{g\}$ there exists a directed path between $ij$ and $g$, we start by reversing the direction of the arcs in our graph, and running a Breadth-first search-like algorithm starting from node $g$, to determine the minimum distance from $g$ to each of the other nodes. For all nodes with distance $1$ from $g$, $\{i_k j_k\}_{k=1}^{n}$, we create the sequence $S_1 = j_1 ... j_n$. Then for all non-visited nodes, with distance $d$ from $g$, $\{a_k b_k\}_{k=1}^{m}$, we create the sequence $S_d = b_1 \ ...\ b_m$. Let us show that the sequence $S = S_1 \circ S_2 \circ ... \circ S_M$, with $M = \max\{\text{dist}(ij, p): ij \in V\setminus\{g\}\}$ corresponds to the configuration. We do this by induction over $|S| = n$. For $n=1$, we have only one occupied state on our configuration, which is the only particle present in $S$. It is straightforward to see that $\mathcal{F}(S)$ actually corresponds to the configuration. Assuming the sequence is correct for $n$, let us prove that it is also correct for $n+1$. Because of the way $S$ was constructed, the only possibility for the configuration not to be achieved is that $S_{n+1}$ ends up higher or lower in $\mathcal{F}(S)$ on its column that in the given configuration. Due to the dynamics, the only way for a particle to become inmobile is to stick to another particle, this means that either it sticks to a particle in its own column, or to a particle in one of the neighboring ones. By the induction hypothesis, $S\setminus S_{n+1}$ actually corresponds to the configuration of the first $n$ particles. Therefore, if, without loss of generality, $S_{n+1}$ ends up lower, this means that when generating the sequence $S$ a node that was at a smaller distance from $g$ than the particle with which it sticks, was added after all other nodes that at the same distance, which is a contradiction. \end{proof} Next, we obtain $G$ from $G_a$ through the following procedure: \begin{enumerate} \item For every $v\in V_{a}\setminus\{g\}$, we create two vertices $v_{1}$ and $v_{2}$, connected by an arc from the former to the latter. \item For every $e = (v,u)\in E_1$, we create an edge $(v_1, u_1)$. \item For every $e = (v,u)\in E_2$, we create an edge $(v_2, u_2)$. \item For every $e = (v,u)\in E_3$, we create an edge $(v_2, u_1)$. \item For every $e = (v,g)\in E_4$, we create an edge $(v_2, g)$. \end{enumerate} \vspace{4mm} \begin{center} \begin{tikzpicture}[x=0.75pt,y=0.75pt,yscale=-1,xscale=1] \draw (110.17,207.67) .. controls (110.17,202.33) and (114.49,198) .. (119.83,198) .. controls (125.17,198) and (129.5,202.33) .. (129.5,207.67) .. controls (129.5,213.01) and (125.17,217.33) .. (119.83,217.33) .. controls (114.49,217.33) and (110.17,213.01) .. (110.17,207.67) -- cycle ; \draw (169.83,208.33) .. controls (169.83,202.63) and (174.46,198) .. (180.17,198) .. controls (185.87,198) and (190.5,202.63) .. (190.5,208.33) .. controls (190.5,214.04) and (185.87,218.67) .. (180.17,218.67) .. controls (174.46,218.67) and (169.83,214.04) .. (169.83,208.33) -- cycle ; \draw (110.5,168.33) .. controls (110.5,162.63) and (115.13,158) .. (120.83,158) .. controls (126.54,158) and (131.17,162.63) .. (131.17,168.33) .. controls (131.17,174.04) and (126.54,178.67) .. (120.83,178.67) .. controls (115.13,178.67) and (110.5,174.04) .. (110.5,168.33) -- cycle ; \draw (139.83,259) .. controls (139.83,253.29) and (144.46,248.67) .. (150.17,248.67) .. controls (155.87,248.67) and (160.5,253.29) .. (160.5,259) .. controls (160.5,264.71) and (155.87,269.33) .. (150.17,269.33) .. controls (144.46,269.33) and (139.83,264.71) .. (139.83,259) -- cycle ; \draw (120.83,178.67) -- (119.94,196) ; \draw [shift={(119.83,198)}, rotate = 272.96] [fill={rgb, 255:red, 0; green, 0; blue, 0 } ][line width=0.75] [draw opacity=0] (8.93,-4.29) -- (0,0) -- (8.93,4.29) -- cycle ; \draw (119.83,217.33) -- (148.78,247.23) ; \draw [shift={(150.17,248.67)}, rotate = 225.93] [fill={rgb, 255:red, 0; green, 0; blue, 0 } ][line width=0.75] [draw opacity=0] (8.93,-4.29) -- (0,0) -- (8.93,4.29) -- cycle ; \draw (180.17,218.67) -- (151.58,247.25) ; \draw [shift={(150.17,248.67)}, rotate = 315] [fill={rgb, 255:red, 0; green, 0; blue, 0 } ][line width=0.75] [draw opacity=0] (8.93,-4.29) -- (0,0) -- (8.93,4.29) -- cycle ; \draw (131.5,207.7) -- (167.83,208.3) ; \draw [shift={(169.83,208.33)}, rotate = 180.95] [fill={rgb, 255:red, 0; green, 0; blue, 0 } ][line width=0.75] [draw opacity=0] (8.93,-4.29) -- (0,0) -- (8.93,4.29) -- cycle ; \draw [shift={(129.5,207.67)}, rotate = 0.95] [fill={rgb, 255:red, 0; green, 0; blue, 0 } ][line width=0.75] [draw opacity=0] (8.93,-4.29) -- (0,0) -- (8.93,4.29) -- cycle ; \draw (337.67,113.25) .. controls (337.67,106.48) and (343.15,101) .. (349.92,101) .. controls (356.68,101) and (362.17,106.48) .. (362.17,113.25) .. controls (362.17,120.02) and (356.68,125.5) .. (349.92,125.5) .. controls (343.15,125.5) and (337.67,120.02) .. (337.67,113.25) -- cycle ; \draw (337.67,153.25) .. controls (337.67,146.48) and (343.15,141) .. (349.92,141) .. controls (356.68,141) and (362.17,146.48) .. (362.17,153.25) .. controls (362.17,160.02) and (356.68,165.5) .. (349.92,165.5) .. controls (343.15,165.5) and (337.67,160.02) .. (337.67,153.25) -- cycle ; \draw (349.92,125.5) -- (349.92,139) ; \draw [shift={(349.92,141)}, rotate = 270] [fill={rgb, 255:red, 0; green, 0; blue, 0 } ][line width=0.75] [draw opacity=0] (8.93,-4.29) -- (0,0) -- (8.93,4.29) -- cycle ; \draw (356.17,192.25) .. controls (356.17,185.48) and (361.65,180) .. (368.42,180) .. controls (375.18,180) and (380.67,185.48) .. (380.67,192.25) .. controls (380.67,199.02) and (375.18,204.5) .. (368.42,204.5) .. controls (361.65,204.5) and (356.17,199.02) .. (356.17,192.25) -- cycle ; \draw (356.17,230.25) .. controls (356.17,223.48) and (361.65,218) .. (368.42,218) .. controls (375.18,218) and (380.67,223.48) .. (380.67,230.25) .. controls (380.67,237.02) and (375.18,242.5) .. (368.42,242.5) .. controls (361.65,242.5) and (356.17,237.02) .. (356.17,230.25) -- cycle ; \draw (368.42,204.5) -- (368.42,216) ; \draw [shift={(368.42,218)}, rotate = 270] [fill={rgb, 255:red, 0; green, 0; blue, 0 } ][line width=0.75] [draw opacity=0] (8.93,-4.29) -- (0,0) -- (8.93,4.29) -- cycle ; \draw (418.67,192.25) .. controls (418.67,185.48) and (424.15,180) .. (430.92,180) .. controls (437.68,180) and (443.17,185.48) .. (443.17,192.25) .. controls (443.17,199.02) and (437.68,204.5) .. (430.92,204.5) .. controls (424.15,204.5) and (418.67,199.02) .. (418.67,192.25) -- cycle ; \draw (418.67,230.25) .. controls (418.67,223.48) and (424.15,218) .. (430.92,218) .. controls (437.68,218) and (443.17,223.48) .. (443.17,230.25) .. controls (443.17,237.02) and (437.68,242.5) .. (430.92,242.5) .. controls (424.15,242.5) and (418.67,237.02) .. (418.67,230.25) -- cycle ; \draw (430.92,204.5) -- (430.92,216) ; \draw [shift={(430.92,218)}, rotate = 270] [fill={rgb, 255:red, 0; green, 0; blue, 0 } ][line width=0.75] [draw opacity=0] (8.93,-4.29) -- (0,0) -- (8.93,4.29) -- cycle ; \draw (380.67,192.25) -- (416.67,192.25) ; \draw [shift={(418.67,192.25)}, rotate = 180] [fill={rgb, 255:red, 0; green, 0; blue, 0 } ][line width=0.75] [draw opacity=0] (8.93,-4.29) -- (0,0) -- (8.93,4.29) -- cycle ; \draw (418.67,230.25) -- (382.67,230.25) ; \draw [shift={(380.67,230.25)}, rotate = 360] [fill={rgb, 255:red, 0; green, 0; blue, 0 } ][line width=0.75] [draw opacity=0] (8.93,-4.29) -- (0,0) -- (8.93,4.29) -- cycle ; \draw (349.92,165.5) -- (361.33,181.38) ; \draw [shift={(362.5,183)}, rotate = 234.28] [fill={rgb, 255:red, 0; green, 0; blue, 0 } ][line width=0.75] [draw opacity=0] (8.93,-4.29) -- (0,0) -- (8.93,4.29) -- cycle ; \draw (389.33,279.5) .. controls (389.33,273.79) and (393.96,269.17) .. (399.67,269.17) .. controls (405.37,269.17) and (410,273.79) .. (410,279.5) .. controls (410,285.21) and (405.37,289.83) .. (399.67,289.83) .. controls (393.96,289.83) and (389.33,285.21) .. (389.33,279.5) -- cycle ; \draw (368.42,242.5) -- (398.15,267.87) ; \draw [shift={(399.67,269.17)}, rotate = 220.48] [fill={rgb, 255:red, 0; green, 0; blue, 0 } ][line width=0.75] [draw opacity=0] (8.93,-4.29) -- (0,0) -- (8.93,4.29) -- cycle ; \draw (430.92,242.5) -- (401.19,267.87) ; \draw [shift={(399.67,269.17)}, rotate = 319.52] [fill={rgb, 255:red, 0; green, 0; blue, 0 } ][line width=0.75] [draw opacity=0] (8.93,-4.29) -- (0,0) -- (8.93,4.29) -- cycle ; \draw (220.5,213) .. controls (222.17,211.33) and (223.83,211.33) .. (225.5,213) .. controls (227.17,214.67) and (228.83,214.67) .. (230.5,213) .. controls (232.17,211.33) and (233.83,211.33) .. (235.5,213) .. controls (237.17,214.67) and (238.83,214.67) .. (240.5,213) .. controls (242.17,211.33) and (243.83,211.33) .. (245.5,213) .. controls (247.17,214.67) and (248.83,214.67) .. (250.5,213) .. controls (252.17,211.33) and (253.83,211.33) .. (255.5,213) .. controls (257.17,214.67) and (258.83,214.67) .. (260.5,213) .. controls (262.17,211.33) and (263.83,211.33) .. (265.5,213) .. controls (267.17,214.67) and (268.83,214.67) .. (270.5,213) .. controls (272.17,211.33) and (273.83,211.33) .. (275.5,213) .. controls (277.17,214.67) and (278.83,214.67) .. (280.5,213) .. controls (282.17,211.33) and (283.83,211.33) .. (285.5,213) .. controls (287.17,214.67) and (288.83,214.67) .. (290.5,213) .. controls (292.17,211.33) and (293.83,211.33) .. (295.5,213) -- (299.5,213) -- (307.5,213) ; \draw [shift={(309.5,213)}, rotate = 180] [fill={rgb, 255:red, 0; green, 0; blue, 0 } ][line width=0.75] [draw opacity=0] (8.93,-4.29) -- (0,0) -- (8.93,4.29) -- cycle ; \draw (121.33,166) node {$v$}; \draw (119.83,204.67) node {$u$}; \draw (180.5,205.67) node {$w$}; \draw (151.17,258) node {$g$}; \draw (350.42,110.75) node {$v_{1}$}; \draw (351.33,150.83) node {$v_{2}$}; \draw (368.92,189.75) node {$u_{1}$}; \draw (369.83,227.83) node {$u_{2}$}; \draw (431.42,189.75) node {$w_{1}$}; \draw (430.33,228.33) node {$w_{2}$}; \draw (400.67,278) node {$g$}; \end{tikzpicture} \end{center} This procedure turns $G_a$ into a planar DAG.\\ It is straightforward to see that there is a directed path from a vertex $v\in V_{a}$ to $g$ on graph $G_a$ if and only if there is a path from vertex $v_1$ to $g$ on graph $G$.\\ Due to our construction, graph $G$ is what is known as a Multiple Source Single Sink Planar DAG (MSPD): there are multiple vertices with in-degree zero, and one vertex with out-degree zero. Allender et al. showed that the reachability problem on MSPD is in fact log-space solvable \cite{allender2006grid}. \begin{theorem}[\cite{allender2006grid}, Theorem 5.7] MSPD reachability is in {\bf L}. \end{theorem} \begin{proposition} Determining whether a given figure is a valid configuration for 1-DLA, is in ${\bf L}$. \end{proposition} The proof of this proposition consists on creating a log-space reduction from our realization problem to MSPD reachability. This stems from the fact that if a problem is log-space reducible to a log-space solvable problem, it is itself log-space solvable (the proof of this fact can be found in \cite{arora2009computational}). \begin{proof} Let $M$ be a matrix representing the configuration, using the same convention as the definition shape. We can see that the directed graph is constructible from a shape in ${\bf NC}^{1}$. By assigning a processor for each pair of coordinates in the matrix, that is $\mathcal{O}(n^2)$ processors, to construct the nodes and arcs of our graph. Because ${\bf NC}^{1}\subseteq{\bf L}$, this procedure is realizable in log-space. This procedure creates the MSPD $G$. For each vertex $v\in V$, we can solve the MSPD reachability problem for the instance $(G, v, g)$ in log-space. Due to Lemma \ref{constr}, this solves the one-directional realization problem. \end{proof} \subsection{Two directions} To characterize shapes generated by the two-directional dynamics, we follow a similar approach than we did for one-directional dynamics. We define for each figure a directed graph called the \emph{dependency graph}, which has as vertex set the set of all particles in the input figure $F$. The dependency graph satisfies that, if a particle $u$ is an in-neighbor of a particle $v$, then $u$ must be fixed before $v$ on every realization of the figure. Moreover, we show that the dependency graph characterizes the realizable figures. More precisely, we show that a figure is realizable if and only if its is acyclic. Let $M$ be the input matrix of an instance of \textsc{$2$-\textsc{DLA-Realization}}. For simplicity, in this section we assume that $M$ is a matrix of dimensions $[N+1]\times[N]$ where all the coordinates in row $N+1$ have value $1$ (representing the \emph{ground}). Moreover, we assume that $N$ is large enough so $M$ has a border of zeroes. More precisely, every coordinate of $M$ that equals $1$ and that is not in row $N+1$, is in a row and column of $M$ that is greater than $3$, and in a column fewer than $N-3$. More formally, we assume that $M = (m_{ij})$ satisfies: $$ i \leq 3 \vee j \leq 3 \vee j\geq N-3 \Rightarrow m_{ij} = 0.$$ We will say a coordinate $(i,j)\in [N]\times [N]$ is a \emph{particle} if $M_{ij} = 1$. The set of all particles is called a \emph{figure} $F$. We denote the row and column of a particle $p\in F$ by row$(p)$ and col$(p)$ respectively. Two particles $p$ and $q$ are said to be \emph{adjacent} if $|\textnormal{col}(p)-\textnormal{col}(q)| + |\textnormal{row}(p)-\textnormal{row}(q)| = 1$. We call $n$ the total number of particles, i.e. $n = |F|$. \begin{definition} Let $F\subseteq\{0,1\}^{N\times N}$ be a figure. A 2DLA-realization of $F$ is a bijective function $\varphi: F \to [n]$ such that, for every $t\in [n]$: \begin{itemize} \item Each particle is fixed to an adjacent particle already fixed, i.e., $\varphi^{-1}(t)$ has an adjacent particle in $\varphi^{-1}(\{1, \dots, t-1\})$ or $\textnormal{row}(\varphi^{-1}(t)) =N$. \item There exists an \emph{available path} for $\varphi^{-1}(t)$, that is to say, a path $P = p_0, \dots p_k$ such that \begin{itemize} \item The path starts in $(0,0)$ and reaches $p_k$, i.e. , $p_0 = (0,0)$ and $p_k = \varphi^{-1}(t)$, \item The particle is not fixed before its final destination, i.e., $0 < \ell < k$, cell $p_\ell$ is not adjacent to any cell in $\varphi^{-1}(\{1, \dots, t-1\})$ and $\textnormal{row}(p_\ell)<N$. \item The path reaches the cell using only two directions, i.e, for each $0\leq \ell < k$ cell $p_{\ell+1} = (\textnormal{row}(p_\ell)+1, \textnormal{col}(p_\ell)) $ or $p_{\ell+1} = (\textnormal{row}(p_\ell), \textnormal{col}(p_\ell)+1) $ \end{itemize} \end{itemize} \end{definition} Let us better understand how the relative position of particles affect the order in which they must be placed. For a particle $u\in F$, we define the \emph{shadow} of the particle as: $$S(u) = \{(i,j): \textnormal{row}(u) > i \ \wedge \ \textnormal{col}(u) > j\}$$ \begin{figure}[H] \begin{center} \begin{tikzpicture}[x=0.75pt,y=0.75pt,yscale=-1,xscale=1] \draw [color={rgb, 255:red, 0; green, 0; blue, 0 } ,draw opacity=1 ][fill={rgb, 255:red, 255; green, 255; blue, 255 } ,fill opacity=1 ] (69.57,40.87) -- (89.47,40.87) -- (89.47,59.67) -- (69.57,59.67) -- cycle ; \draw [color={rgb, 255:red, 0; green, 0; blue, 0 } ,draw opacity=1 ][fill={rgb, 255:red, 186; green, 186; blue, 186 } ,fill opacity=1 ] (89.47,59.67) -- (179.67,59.67) -- (179.67,149) -- (89.47,149) -- cycle ; \draw [dash pattern={on 4.5pt off 4.5pt}] (89.47,40.87) -- (181,40.33) ; \draw [dash pattern={on 4.5pt off 4.5pt}] (69.57,59.67) -- (70.33,149.67) ; \draw (75,46) node [anchor=north west][inner sep=0.75pt]{$u$}; \draw (116.67,90.57) node [anchor=north west][inner sep=0.75pt]{$S(u)$}; \end{tikzpicture} \end{center} \caption{} \end{figure} \begin{definition} Let $F$ be a 2-DLA constructible figure. A realization $\varphi$ of $F$ is said to be canonical if $$\forall u,v\in F: \ \ u\in S(v) \implies \varphi(u) < \varphi(v).$$ \end{definition} The following lemma states that every figure that is realizable admits a canonical realization. \begin{lemma} \label{canon} $F$ admits a 2-DLA realization if and only if $F$ has a canonical realization. \end{lemma} \begin{proof} If $F$ has a canonical realization it is trivially 2-DLA constructible. Let us suppose that $F$ is 2-DLA constructible but has no canonical realization. We will say a pair of particles $u,v$ is a \emph{bad pair} of a realization $\varphi$ if $\varphi(u) > \varphi(v)$ and $u\in S(v)$. Let $\varphi$ be the realization with the least amount of bad pairs. We will show that it is possible to define a realization with a lower amount of bad pairs, giving us a contradiction. From all possible bad pairs $(v,u)$, let us take one that minimizes $\textnormal{col}(v)$. Fixing such $v$, let us take $u$ as the first cell to be placed in $S(v)$ after $v$. In order to reach a contradiction, we consider two cases. \textbf{Case 1:} Let us suppose that $u$ is strictly in the interior of $S(v)$, that is, col$(u)>$ col$(v) +1$ and row$(u) >$ row$(v) + 1$ as see on Figure \ref{interior}. \begin{figure}[H] \label{interior} \begin{center} \begin{tikzpicture}[x=0.75pt,y=0.75pt,yscale=-1,xscale=1] \draw [color={rgb, 255:red, 0; green, 0; blue, 0 } ,draw opacity=1 ][fill={rgb, 255:red, 255; green, 255; blue, 255 } ,fill opacity=1 ] (69.57,40.87) -- (89.47,40.87) -- (89.47,59.67) -- (69.57,59.67) -- cycle ; \draw [color={rgb, 255:red, 0; green, 0; blue, 0 } ,draw opacity=1 ][fill={rgb, 255:red, 186; green, 186; blue, 186 } ,fill opacity=0.71 ] (89.47,59.67) -- (179.67,59.67) -- (179.67,149) -- (89.47,149) -- cycle ; \draw [dash pattern={on 4.5pt off 4.5pt}] (89.97,80.37) -- (181.5,79.83) ; \draw [dash pattern={on 4.5pt off 4.5pt}] (69.57,59.67) -- (70.33,149.67) ; \draw [dash pattern={on 4.5pt off 4.5pt}] (89.47,40.87) -- (181,40.33) ; \draw [dash pattern={on 4.5pt off 4.5pt}] (109.57,60.17) -- (110.33,150.17) ; \draw [color={rgb, 255:red, 0; green, 0; blue, 0 } ,draw opacity=1 ][fill={rgb, 255:red, 255; green, 255; blue, 255 } ,fill opacity=1 ] (140.57,100.37) -- (160.47,100.37) -- (160.47,119.17) -- (140.57,119.17) -- cycle ; \draw (75,46) node [anchor=north west][inner sep=0.75pt] {$v$}; \draw (145,105) node [anchor=north west][inner sep=0.75pt] {$u$}; \end{tikzpicture} \end{center} \caption{Case 1: $u$ is in the interior of $S(v)$.} \end{figure} For $w\in F$ let us call $F_w(\varphi)$ the set of particles such that $$F_w(\varphi) = \{z\in F: \varphi(z)\leq\varphi(w)\}$$ It is clear that in this case, we must have that $u$ must be adjacent to a particle in $F_v(\varphi)$. If not, we would have a contradiction with the fact that $u$ is the fist element to be placed after $v$ and that means it would be placed without a contact point. We now define $\tilde{\varphi}$ as the realization that equals $\varphi$, except that we place $u$ right before $v$, more formally: $$\tilde{\varphi}(p) = \begin{cases}\varphi(p) \ \text{ if } \ \varphi(p) < \varphi(v) \\ \varphi(v) \ \text{ if } \ p = u \\ \varphi(p) + 1 \ \text{ if } \ \varphi(v) \leq \varphi(p) < \varphi(u) \\ \varphi(p) \ \text{ if } \ \varphi(p) > \varphi(u) \end{cases}$$ Let us see that $\tilde{\varphi}$ is a realization. Let $w$ be any particle of $F$. Let $p_w$ denote the trajectory the particle takes to reach cell $w$ in the realization given by $\varphi$. Clearly if $\varphi(w)<\varphi(v)$ or $\varphi(w)>\varphi(u)$ then $F_w(\varphi) = F_w(\tilde{\varphi})$ and then $p_w$ is still available as a trajectory for the new realization $\tilde{\varphi}$. If $w = u$ then $F_w(\tilde{\varphi}) \subseteq F_w(\varphi) $ and then $P_w$ is also available as a trajectory for the new realization $\tilde{\varphi}$. Suppose then that $\varphi(v) \leq \varphi(w) < \varphi(u)$. If $u$ is not adjacent to any of the coordinates on $p_w$ (for example when $w=v$), this path is also valid as a trajectory for the new realization $\tilde{\varphi}$. We can observe that this is always the case: if $w\not\in S(v)$, $p_w$ can never be adjacent to $u$. If $w\in S(v)$, because this means that $\varphi(u)>\varphi(w)$, $u$ cannot be adjacent to $p_w$. Therefore, $\tilde{\varphi}$ is a realization of $F$. Moreover, $\tilde{\varphi}$ has a lower number of bad pairs. Indeed, on one hand $(v,u)$ is no longer a bad pair of $\tilde{\varphi}$. On the other, suppose that $(w_1,w_2)$ is a bad pair of $\tilde{\varphi}$ that is not a bad pair of $\varphi$. Then necessarily $w_1 = u$ and $w_2 \in S(u)$ is such that $\varphi(v) < \varphi(w_2) < \varphi(u)$. We obtain a contradiction with the fact that $S(u)\subset S(v)$ and $u$ was the first particle in $S(v)$ to be placed after $v$. We deduce that $\tilde{\varphi}$ is a realization of $F$ with a lower number of bad pairs than $\varphi$, which is a contradiction with the choice of $\varphi$. \textbf{Case 2:} Let us now suppose that $u$ is in the border of $S(v)$, that is, $\textnormal{col}(u) =\textnormal{col}(v) +1$ or $\textnormal{row}(u) =\textnormal{row}(v) +1$. Without loss of generality let us assume that $\textnormal{col}(u) =\textnormal{col}(v) +1$. \begin{figure}[H] \begin{center} \begin{tikzpicture}[x=0.75pt,y=0.75pt,yscale=-1,xscale=1] \draw [color={rgb, 255:red, 0; green, 0; blue, 0 } ,draw opacity=1 ][fill={rgb, 255:red, 255; green, 255; blue, 255 } ,fill opacity=1 ] (69.57,40.87) -- (89.47,40.87) -- (89.47,59.67) -- (69.57,59.67) -- cycle ; \draw [color={rgb, 255:red, 0; green, 0; blue, 0 } ,draw opacity=1 ][fill={rgb, 255:red, 186; green, 186; blue, 186 } ,fill opacity=0.71 ] (89.47,59.67) -- (179.67,59.67) -- (179.67,149) -- (89.47,149) -- cycle ; \draw [dash pattern={on 4.5pt off 4.5pt}] (89.97,80.37) -- (181.5,79.83) ; \draw [dash pattern={on 4.5pt off 4.5pt}] (69.57,59.67) -- (70.33,149.67) ; \draw [dash pattern={on 4.5pt off 4.5pt}] (89.47,40.87) -- (181,40.33) ; \draw [dash pattern={on 4.5pt off 4.5pt}] (109.57,60.17) -- (110.33,149) ; \draw [color={rgb, 255:red, 0; green, 0; blue, 0 } ,draw opacity=1 ][fill={rgb, 255:red, 255; green, 255; blue, 255 } ,fill opacity=1 ] (89.67,105.17) -- (109.95,105.17) -- (109.95,123.67) -- (89.67,123.67) -- cycle ; \draw (75,46) node [anchor=north west][inner sep=0.75pt] {$v$}; \draw (94,110) node [anchor=north west][inner sep=0.75pt] {$u$}; \end{tikzpicture} \end{center} \caption{Case 2: when $u$ is in the border of $v$ ($\textnormal{col}(u) = \textnormal{col}(v)+1$)} \end{figure} Let $p_u$ denote the trajectory the particle takes to reach cell $u$ in the realization given by $\varphi$. We have that $p_u$ must necessarily contain a coordinate $(i,j)$ such that $j = \textnormal{col}(v)$ and $i < \textnormal{row}(v)$. Let $C(\varphi; u)$ the connected component of $[N]\times[N]\setminus(S(v)\cup p_u)$ that contains $z = (\text{col}(v), N)$. \begin{figure}[H] \begin{center} \begin{tikzpicture}[x=0.75pt,y=0.75pt,yscale=-1,xscale=1] \draw [color={rgb, 255:red, 0; green, 0; blue, 0 } ,draw opacity=0.1 ][fill={rgb, 255:red, 0; green, 0; blue, 0 } ,fill opacity=0.16 ] (251,171) -- (250.8,209) -- (100.33,210.33) -- (101,91) -- (160.33,90.33) -- (160.33,150.33) -- (200.33,150.33) -- (200.33,171) -- cycle ; \draw [color={rgb, 255:red, 0; green, 0; blue, 0 } ,draw opacity=1 ][fill={rgb, 255:red, 255; green, 255; blue, 255 } ,fill opacity=1 ] (230.9,100.87) -- (250.8,100.87) -- (250.8,119.67) -- (230.9,119.67) -- cycle ; \draw [color={rgb, 255:red, 0; green, 0; blue, 0 } ,draw opacity=1 ][fill={rgb, 255:red, 230; green, 230; blue, 230 } ,fill opacity=0.71 ] (250.8,119.67) -- (341,119.67) -- (341,209) -- (250.8,209) -- cycle ; \draw [color={rgb, 255:red, 0; green, 0; blue, 0 } ,draw opacity=1 ][fill={rgb, 255:red, 255; green, 255; blue, 255 } ,fill opacity=1 ] (251,160.5) -- (271.28,160.5) -- (271.28,179) -- (251,179) -- cycle ; \draw [color={rgb, 255:red, 0; green, 0; blue, 0 } ,draw opacity=1 ][fill={rgb, 255:red, 255; green, 255; blue, 255 } ,fill opacity=1 ] (230.9,190.2) -- (250.8,190.2) -- (250.8,209) -- (230.9,209) -- cycle ; \draw (200.33,171) -- (248,171) ; \draw [shift={(251,171)}, rotate = 180] [fill={rgb, 255:red, 0; green, 0; blue, 0 } ][line width=0.08] [draw opacity=0] (8.93,-4.29) -- (0,0) -- (8.93,4.29) -- cycle ; \draw (200.33,150.33) -- (200.33,171) ; \draw (160.33,150.33) -- (200.33,150.33) ; \draw (160.33,90.33) -- (160.33,150.33) ; \draw (235.5,106.5) node [anchor=north west][inner sep=0.75pt] {$v$}; \draw (256,165.5) node [anchor=north west][inner sep=0.75pt] {$u$}; \draw (236,195) node [anchor=north west][inner sep=0.75pt] {$z$}; \draw (165.33,107.73) node [anchor=north west][inner sep=0.75pt] {$p_{u}( \varphi )$}; \draw (121.33,166.4) node [anchor=north west][inner sep=0.75pt] {$C( \varphi ;u)$}; \end{tikzpicture} \end{center} \caption{Construction of $C(\varphi;u)$} \end{figure} Now let us define the set $C(u,v)$ as the set of particles that are placed in $C(\varphi;u)$ after $v$ and before $u$ according to $\varphi$. More precisely: $$C(u, v) = \{w\in P(C(\varphi; u)): \varphi(v) < \varphi(w) < \varphi(u) \},$$ Finally, let us define the realization $\tilde{\varphi}$ as follows: \begin{itemize} \item First set all elements in $F_v\setminus\{v\}$preserving the order given by $\varphi$. \item Then, set all the elements of $C(u,v)$ preserving the order given by $\varphi$. \item Then, set $u$ followed by $v$. \item Finally set the rest of the elements of $F$ preserving the order given by $\varphi$. \end{itemize} Once again let us prove that $\tilde{\varphi}$ is in fact a realization of $F$. Let $w\in F$ be a particle. If $\tilde{\varphi}(w) < \varphi(v)$ or $\tilde{\varphi}(w) > \varphi(u)$, then it is clear that $p_w$ is still available in $\tilde{\varphi}$, because $F_w(\tilde{\varphi}) = F_w(\varphi)$. For the particles $w\in C(u,v)$ we have that $F_w(\tilde{\varphi})\subseteq F_w(\varphi)$ and then the path $p_w$ is also available in $\tilde{\varphi}$. The same argument goes for $w = u$. For the remaining options, let us define $$X = \{w\in F: \varphi(v)\leq\varphi(w)<\varphi(u)\} \setminus C(u,v).$$ This set is not empty because it contains $v$. Let us take $w\in X$, and suppose that no coordinate in $p_w$ is adjacent to $C(u,v)$. In this case $p_w$ is also available in $\tilde{\varphi}$. Suppose then that $p_w$ intersects $C(u,v)$. Since $w$ is not contained in $C(u,v)$, necessarily $p_w$ intersects $p_u$ (because $p_u$ is the frontier of the component $C(\varphi;u)$). Let $y\in p_u\cap p_{w}$ be the coordinate of the last time $p_u$ intersects $p_{w}$. Then define the trajectory $\tilde{p}_w$ of $w$ in $\tilde{\varphi}$ as $p_1$ and $p_2$, where $p_1$ equals to $p_u$ from the top of the grid up until reaching $y$ and $p_2$ is equal to $p_w$ from $y$ until reaching $w$. We obtain that $\tilde{p}_w$ is an available trajectory for $w$ in the realization $\tilde{\varphi}$. We deduce that $\tilde{\varphi}$ is a realization of $F$. To reach a contradiction, now we show that $\tilde{\varphi}$ has a lower number of bad pairs than $\varphi$. Obviously $(v,u)$ is not a bad pair of $\tilde{\varphi}$. Let us suppose that there is a bad pair $(p,q)$ for $\tilde{\varphi}$, that is not a bad pair for $\varphi$. The only possibility for this to happen is that $$q\in C(u,v)\cup\{u\} \quad \textrm{and} \quad p\in\{z\in F: z\not\in C(u,v) \ \wedge \ \varphi(v)\leq\varphi(z)<\varphi(v)\}.$$ In this case we would obtain a bad pair for $\varphi$ where $\textnormal{col}(q) < \textnormal{col}(v)$, which is not possible due to the choice of $v$. We conclude that in this case, $\tilde{\varphi}$ is a realization that has strictly less number of bad pairs than $\varphi$, which is a contradiction with the existence of $\varphi$. \end{proof} This Lemma allows us to better structure the proof that 2-DLA constructible figures can be characterized through canonical realizations. Given a particle $p\in F$, we define the particles scope as $$L(p) = \{(i,j): \textnormal{row}(p)< i \ \wedge \ \textnormal{col}(p) < j\} = \{q\in F: p\in S(q)\}.$$ \begin{figure}[H] \begin{center} \begin{tikzpicture}[x=0.75pt,y=0.75pt,yscale=-1,xscale=1] \draw [color={rgb, 255:red, 0; green, 0; blue, 0 } ,draw opacity=1 ][fill={rgb, 255:red, 255; green, 255; blue, 255 } ,fill opacity=1 ] (240.57,120.37) -- (260.47,120.37) -- (260.47,139.17) -- (240.57,139.17) -- cycle ; \draw [color={rgb, 255:red, 0; green, 0; blue, 0 } ,draw opacity=1 ][fill={rgb, 255:red, 155; green, 155; blue, 155 } ,fill opacity=0.67 ] (260.47,139.17) -- (350.67,139.17) -- (350.67,228.5) -- (260.47,228.5) -- cycle ; \draw [dash pattern={on 4.5pt off 4.5pt}] (260.47,120.37) -- (352,119.83) ; \draw [dash pattern={on 4.5pt off 4.5pt}] (240.57,139.17) -- (241.33,229.17) ; \draw [color={rgb, 255:red, 0; green, 0; blue, 0 } ,draw opacity=1 ][fill={rgb, 255:red, 155; green, 155; blue, 155 } ,fill opacity=0.67 ] (150.37,31.03) -- (240.57,31.03) -- (240.57,120.37) -- (150.37,120.37) -- cycle ; \draw [dash pattern={on 4.5pt off 4.5pt}] (259.7,30.37) -- (260.47,120.37) ; \draw [dash pattern={on 4.5pt off 4.5pt}] (149.03,139.7) -- (240.57,139.17) ; \draw (245,125) node [anchor=north west][inner sep=0.75pt] {$u$}; \draw (287.17,170.57) node [anchor=north west][inner sep=0.75pt] {$S( u)$}; \draw (176.17,63.57) node [anchor=north west][inner sep=0.75pt] {$L( u)$}; \end{tikzpicture} \end{center} \caption{The shadow $S(v)$ and scope $L(v)$ of a particle $v$} \end{figure} With this at hand, we reinterpret Lemma \ref{canon} as follows: a figure $F$ is 2DLA-Realizable if and only if there exists a canonical realization $\varphi$, that is a realization such that, for every $u\in F$: $$\varphi(z) < \varphi(u) < \varphi(x), \ \forall z\in S(u), \ \forall x\in L(u).$$ In the following we only focus on canonical realizations. Because of previous result, when constructing a figure and want to add a particle $x = (i,j)$ we can guarantee that there will be an interrupted path from the top of the grid to the coordinate $(i-2,j-2)\in L(x)$. \begin{figure}[H] \begin{center} \begin{tikzpicture}[x=0.75pt,y=0.75pt,yscale=-1,xscale=1] \draw [color={rgb, 255:red, 0; green, 0; blue, 0 } ,draw opacity=1 ][fill={rgb, 255:red, 255; green, 255; blue, 255 } ,fill opacity=1 ] (240.57,178.37) -- (260.47,178.37) -- (260.47,197.17) -- (240.57,197.17) -- cycle ; \draw [color={rgb, 255:red, 255; green, 255; blue, 255 } ,draw opacity=0 ][fill={rgb, 255:red, 155; green, 155; blue, 155 } ,fill opacity=0.67 ] (260.47,197.17) -- (300,197.17) -- (300,239.75) -- (260.47,239.75) -- cycle ; \draw [dash pattern={on 4.5pt off 4.5pt}] (260.47,178.37) -- (299,178.25) ; \draw [dash pattern={on 4.5pt off 4.5pt}] (240.57,197.17) -- (240.5,241.75) ; \draw [color={rgb, 255:red, 0; green, 0; blue, 0 } ,draw opacity=0 ][fill={rgb, 255:red, 155; green, 155; blue, 155 } ,fill opacity=0.67 ] (150.37,89.03) -- (240.57,89.03) -- (240.57,178.37) -- (150.37,178.37) -- cycle ; \draw [dash pattern={on 4.5pt off 4.5pt}] (259.7,88.37) -- (260.47,178.37) ; \draw [dash pattern={on 4.5pt off 4.5pt}] (149.03,197.7) -- (240.57,197.17) ; \draw [dash pattern={on 4.5pt off 4.5pt}] (260.47,197.17) -- (299,197.05) ; \draw [dash pattern={on 4.5pt off 4.5pt}] (260.47,197.17) -- (260.4,241.75) ; \draw [dash pattern={on 4.5pt off 4.5pt}] (239.8,88.37) -- (240.57,178.37) ; \draw [dash pattern={on 4.5pt off 4.5pt}] (149.03,178.9) -- (240.57,178.37) ; \draw [color={rgb, 255:red, 0; green, 0; blue, 0 } ,draw opacity=1 ][fill={rgb, 255:red, 255; green, 255; blue, 255 } ,fill opacity=0.87 ] (200.77,140.77) -- (220.67,140.77) -- (220.67,159.57) -- (200.77,159.57) -- cycle ; \draw (150.37,89.03) .. controls (152.72,89.04) and (153.89,90.23) .. (153.88,92.59) .. controls (153.86,94.95) and (155.03,96.14) .. (157.39,96.15) .. controls (159.75,96.16) and (160.92,97.35) .. (160.9,99.71) .. controls (160.89,102.07) and (162.06,103.26) .. (164.42,103.27) .. controls (166.77,103.28) and (167.94,104.47) .. (167.93,106.82) .. controls (167.91,109.18) and (169.08,110.37) .. (171.44,110.38) .. controls (173.8,110.39) and (174.97,111.58) .. (174.96,113.94) .. controls (174.94,116.3) and (176.11,117.49) .. (178.47,117.5) .. controls (180.83,117.51) and (182,118.7) .. (181.98,121.06) .. controls (181.96,123.42) and (183.13,124.61) .. (185.49,124.62) .. controls (187.85,124.63) and (189.02,125.81) .. (189.01,128.17) .. controls (188.99,130.53) and (190.16,131.72) .. (192.52,131.73) .. controls (194.88,131.74) and (196.05,132.93) .. (196.03,135.29) .. controls (196.01,137.65) and (197.18,138.84) .. (199.54,138.85) -- (202.99,142.34) -- (208.61,148.03) ; \draw [shift={(210.72,150.17)}, rotate = 225.37] [fill={rgb, 255:red, 0; green, 0; blue, 0 } ][line width=0.08] [draw opacity=0] (6.25,-3) -- (0,0) -- (6.25,3) -- cycle ; \draw (245,183) node [anchor=north west][inner sep=0.75pt] {$x$}; \end{tikzpicture} \end{center} \caption{We assume that for every occupied site $x=(i,j)$, when a particle is placed in $x$ there is an available path that starts in $(1,1)$ and reaches $(i-2,j-2)$.} \end{figure} This means that, to build a realization of a figure, it is sufficient to select one that satisfies that, for each particle $(i,j)$, there is a path from $(i-2, j-2)$ to $(i,j)$ that avoids the collision with other particles already fixed. For a particle $x \in F$, we define $V(x)$ the vicinity of $x$ as the set of sites depicted on Figure~\ref{vecindad}. More formally, if $x=(i,j)$ then $V(x) = V_1(x) \cup V_2(x) \cup V_3(x) \cup V_4(x)$ where $$V_1((i,j)) = \{(i-3,j), (i-2,j), (i-1,j), (i-2,j+1), (i-1,j+1)\},$$ $$V_2((i,j)) = \{(i,j-3), (i,j-2), (i, j-1), (i+1,j-2), (i+1, j-1)\},$$ \begin{figure}[H] \label{vecindad} \begin{center} \tikzset{every picture/.style={line width=0.75pt}} \begin{tikzpicture}[x=0.75pt,y=0.75pt,yscale=-1,xscale=1] \draw (270,150) -- (350,150) -- (350,170) -- (270,170) -- cycle ; \draw (290,150) -- (330,150) -- (330,190) -- (290,190) -- cycle ; \draw (310,150) -- (310,190) ; \draw [fill={rgb, 255:red, 155; green, 155; blue, 155 } ,fill opacity=1 ] (330,150) -- (350,150) -- (350,170) -- (330,170) -- cycle ; \draw (330,90) -- (350,90) -- (350,170) -- (330,170) -- cycle ; \draw (330,110) -- (370,110) -- (370,150) -- (330,150) -- cycle ; \draw (330,130) -- (370,130) ; \draw (80,150) -- (160,150) -- (160,170) -- (80,170) -- cycle ; \draw (100,150) -- (140,150) -- (140,190) -- (100,190) -- cycle ; \draw (120,150) -- (120,190) ; \draw [fill={rgb, 255:red, 155; green, 155; blue, 155 } ,fill opacity=1 ] (140,150) -- (160,150) -- (160,170) -- (140,170) -- cycle ; \draw (140,90) -- (160,90) -- (160,170) -- (140,170) -- cycle ; \draw (140,110) -- (180,110) -- (180,150) -- (140,150) -- cycle ; \draw (140,130) -- (180,130) ; \draw [fill={rgb, 255:red, 208; green, 2; blue, 27 } ,fill opacity=0.33 ] (270,150) -- (290,150) -- (290,170) -- (270,170) -- cycle ; \draw [fill={rgb, 255:red, 208; green, 2; blue, 27 } ,fill opacity=0.33 ] (290,150) -- (330,150) -- (330,190) -- (290,190) -- cycle ; \draw [fill={rgb, 255:red, 208; green, 2; blue, 27 } ,fill opacity=0.33 ] (140,90) -- (160,90) -- (160,110) -- (140,110) -- cycle ; \draw [fill={rgb, 255:red, 208; green, 2; blue, 27 } ,fill opacity=0.33 ] (140,110) -- (180,110) -- (180,150) -- (140,150) -- cycle ; \draw (335,155) node [anchor=north west][inner sep=0.75pt] [color={rgb, 255:red, 255; green, 255; blue, 255 } ,opacity=1 ] {$x$}; \draw (145,155) node [anchor=north west][inner sep=0.75pt] [color={rgb, 255:red, 255; green, 255; blue, 255 } ,opacity=1 ] {$x$}; \draw (311,202.4) node [anchor=north west][inner sep=0.75pt] {$V_{2}( x)$}; \draw (127,202.4) node [anchor=north west][inner sep=0.75pt] {$V_{1}( x)$}; \end{tikzpicture} \end{center} \caption{Visual representation of $V(x)$ and sets $V_1(x)$ and $V_2(x)$ highlighted in red} \end{figure} Due to the nature of the dynamics, we have to consider only four different possible paths a particle can take to reach $x$ from $y = (\textnormal{row}(x) -2, \textnormal{col}(x) - 2)$. We denote these paths as $Q_1, Q_2, Q_3$ and $Q_4$, which are shown in the following figure. \begin{figure}[H] \begin{center} \tikzset{every picture/.style={line width=0.75pt}} \begin{tikzpicture}[x=0.75pt,y=0.75pt,yscale=-1,xscale=1] \draw (90,150) -- (170,150) -- (170,170) -- (90,170) -- cycle ; \draw (110,110) -- (150,110) -- (150,190) -- (110,190) -- cycle ; \draw (130,110) -- (130,190) ; \draw [fill={rgb, 255:red, 155; green, 155; blue, 155 } ,fill opacity=1 ] (150,150) -- (170,150) -- (170,170) -- (150,170) -- cycle ; \draw [fill={rgb, 255:red, 208; green, 2; blue, 27 } ,fill opacity=0.33 ] (150,90) -- (170,90) -- (170,110) -- (150,110) -- cycle ; \draw [fill={rgb, 255:red, 208; green, 2; blue, 27 } ,fill opacity=0.33 ] (150,110) -- (190,110) -- (190,150) -- (150,150) -- cycle ; \draw (110,130) -- (190,130) ; \draw [fill={rgb, 255:red, 155; green, 155; blue, 155 } ,fill opacity=1 ] (110,110) -- (130,110) -- (130,130) -- (110,130) -- cycle ; \draw (310,150) -- (390,150) -- (390,170) -- (310,170) -- cycle ; \draw (330,110) -- (370,110) -- (370,190) -- (330,190) -- cycle ; \draw (350,110) -- (350,190) ; \draw [fill={rgb, 255:red, 155; green, 155; blue, 155 } ,fill opacity=1 ] (370,150) -- (390,150) -- (390,170) -- (370,170) -- cycle ; \draw (370,90) -- (390,90) -- (390,170) -- (370,170) -- cycle ; \draw (370,110) -- (410,110) -- (410,150) -- (370,150) -- cycle ; \draw (330,130) -- (410,130) ; \draw [fill={rgb, 255:red, 155; green, 155; blue, 155 } ,fill opacity=1 ] (330,110) -- (350,110) -- (350,130) -- (330,130) -- cycle ; \draw (170,110) -- (170,150) ; \draw [fill={rgb, 255:red, 208; green, 2; blue, 27 } ,fill opacity=0.33 ] (370,110) -- (390,110) -- (390,150) -- (370,150) -- cycle ; \draw [fill={rgb, 255:red, 208; green, 2; blue, 27 } ,fill opacity=0.33 ] (390,130) -- (410,130) -- (410,150) -- (390,150) -- cycle ; \draw [fill={rgb, 255:red, 208; green, 2; blue, 27 } ,fill opacity=0.33 ] (350,150) -- (370,150) -- (370,170) -- (350,170) -- cycle ; \draw (90,300) -- (170,300) -- (170,320) -- (90,320) -- cycle ; \draw (110,260) -- (150,260) -- (150,340) -- (110,340) -- cycle ; \draw (130,260) -- (130,340) ; \draw [fill={rgb, 255:red, 155; green, 155; blue, 155 } ,fill opacity=1 ] (150,300) -- (170,300) -- (170,320) -- (150,320) -- cycle ; \draw [fill={rgb, 255:red, 255; green, 255; blue, 255 } ,fill opacity=1 ] (150,240) -- (170,240) -- (170,260) -- (150,260) -- cycle ; \draw [fill={rgb, 255:red, 255; green, 255; blue, 255 } ,fill opacity=1 ] (150,260) -- (190,260) -- (190,300) -- (150,300) -- cycle ; \draw (110,280) -- (190,280) ; \draw [fill={rgb, 255:red, 155; green, 155; blue, 155 } ,fill opacity=1 ] (110,260) -- (130,260) -- (130,280) -- (110,280) -- cycle ; \draw (310,300) -- (390,300) -- (390,320) -- (310,320) -- cycle ; \draw (330,260) -- (370,260) -- (370,340) -- (330,340) -- cycle ; \draw (350,260) -- (350,340) ; \draw [fill={rgb, 255:red, 155; green, 155; blue, 155 } ,fill opacity=1 ] (370,300) -- (390,300) -- (390,320) -- (370,320) -- cycle ; \draw (370,240) -- (390,240) -- (390,320) -- (370,320) -- cycle ; \draw (370,260) -- (410,260) -- (410,300) -- (370,300) -- cycle ; \draw (330,280) -- (410,280) ; \draw [fill={rgb, 255:red, 155; green, 155; blue, 155 } ,fill opacity=1 ] (330,260) -- (350,260) -- (350,280) -- (330,280) -- cycle ; \draw (170,260) -- (170,300) ; \draw [fill={rgb, 255:red, 208; green, 2; blue, 27 } ,fill opacity=0.33 ] (330,300) -- (370,300) -- (370,320) -- (330,320) -- cycle ; \draw [fill={rgb, 255:red, 208; green, 2; blue, 27 } ,fill opacity=0.33 ] (370,280) -- (390,280) -- (390,300) -- (370,300) -- cycle ; \draw [fill={rgb, 255:red, 208; green, 2; blue, 27 } ,fill opacity=0.33 ] (90,300) -- (110,300) -- (110,320) -- (90,320) -- cycle ; \draw [fill={rgb, 255:red, 208; green, 2; blue, 27 } ,fill opacity=0.33 ] (110,300) -- (150,300) -- (150,340) -- (110,340) -- cycle ; \draw [color={rgb, 255:red, 208; green, 2; blue, 27 } ,draw opacity=1 ] (120,280) -- (120,310) -- (147,310) ; \draw [shift={(150,310)}, rotate = 180] [fill={rgb, 255:red, 208; green, 2; blue, 27 } ,fill opacity=1 ][line width=0.08] [draw opacity=0] (6.25,-3) -- (0,0) -- (6.25,3) -- cycle ; \draw [color={rgb, 255:red, 208; green, 2; blue, 27 } ,draw opacity=1 ] (350,120) -- (360,120) -- (360,140) -- (380,140) -- (380,147) ; \draw [shift={(380,150)}, rotate = 270] [fill={rgb, 255:red, 208; green, 2; blue, 27 } ,fill opacity=1 ][line width=0.08] [draw opacity=0] (6.25,-3) -- (0,0) -- (6.25,3) -- cycle ; \draw [color={rgb, 255:red, 208; green, 2; blue, 27 } ,draw opacity=1 ] (130,120) -- (160,120) -- (160,147) ; \draw [shift={(160,150)}, rotate = 270] [fill={rgb, 255:red, 208; green, 2; blue, 27 } ,fill opacity=1 ][line width=0.08] [draw opacity=0] (6.25,-3) -- (0,0) -- (6.25,3) -- cycle ; \draw [fill={rgb, 255:red, 208; green, 2; blue, 27 } ,fill opacity=0.33 ] (350,320) -- (370,320) -- (370,340) -- (350,340) -- cycle ; \draw [color={rgb, 255:red, 208; green, 2; blue, 27 } ,draw opacity=1 ] (340,280) -- (340,290) -- (360,290) -- (360,310) -- (367,310) ; \draw [shift={(370,310)}, rotate = 180] [fill={rgb, 255:red, 208; green, 2; blue, 27 } ,fill opacity=1 ][line width=0.08] [draw opacity=0] (6.25,-3) -- (0,0) -- (6.25,3) -- cycle ; \draw (155,155) node [anchor=north west][inner sep=0.75pt] [color={rgb, 255:red, 255; green, 255; blue, 255 } ,opacity=1 ] {$x$}; \draw (115,115) node [anchor=north west][inner sep=0.75pt] [color={rgb, 255:red, 255; green, 255; blue, 255 } ,opacity=1 ] {$y$}; \draw (375,155) node [anchor=north west][inner sep=0.75pt] [color={rgb, 255:red, 255; green, 255; blue, 255 } ,opacity=1 ] {$x$}; \draw (335,115) node [anchor=north west][inner sep=0.75pt] [color={rgb, 255:red, 255; green, 255; blue, 255 } ,opacity=1 ] {$y$}; \draw (155,305) node [anchor=north west][inner sep=0.75pt] [color={rgb, 255:red, 255; green, 255; blue, 255 } ,opacity=1 ] {$x$}; \draw (115,265) node [anchor=north west][inner sep=0.75pt] [color={rgb, 255:red, 255; green, 255; blue, 255 } ,opacity=1 ] {$y$}; \draw (375,305) node [anchor=north west][inner sep=0.75pt] [color={rgb, 255:red, 255; green, 255; blue, 255 } ,opacity=1 ] {$x$}; \draw (335,265) node [anchor=north west][inner sep=0.75pt] [color={rgb, 255:red, 255; green, 255; blue, 255 } ,opacity=1 ] {$y$}; \draw (130,200) node [anchor=north west][inner sep=0.75pt] {$Q_{1}$}; \draw (350,200) node [anchor=north west][inner sep=0.75pt] {$Q_{2}$}; \draw (130,350) node [anchor=north west][inner sep=0.75pt] {$Q_{3}$}; \draw (350,350) node [anchor=north west][inner sep=0.75pt] {$Q_{4}$}; \end{tikzpicture} \end{center} \caption{ A representation of the four choices of paths starting from $y = (i-2,j-2)$ and reaching coordinate $x = (i,j)$.} \end{figure} More formally, in Table \ref{table:defcaminos} are given the four possible choices of paths starting from $(i-2, j-2)$ and reaching coordinate $(i,j)$, with the list of visited cells and the cells adjacent to each path. For $k\in \{1,2,3,4\}$ we call $Q_k((i,j))$ the union of the set of visited and adjacent cells of path $Q_k((i,j))$. Given a realization $\varphi$ of $F$, we say that a path $Q_k$ is \emph{available} if all cells $c$ in the second of and third columns of the $k$-th row of the table are satisfy that $\varphi(c) > \varphi((i,j))$. Otherwise, we say that $Q_k$ is \emph{unavailable}. \renewcommand{\arraystretch}{2} \begin{table}[H] \label{table:defcaminos} \begin{center} \begin{tabular}{c|c|c|} Path & Sequence of visited cells & Adjacent cells in $V(x)$\\ \hline $Q_1((i,j))$ & \parbox[c]{4.5cm}{\centering $(i-2, j-2), (i-2, j-1), $ \\ $(i-2, j), (i-1, j) $} & \parbox[c]{4.5cm}{\centering $(i-3,j),(i-2,j+1),$ \\$(i-1,j+1) $} \\ \hline $Q_2((i,j))$ & \parbox[c]{4.5cm}{\centering $(i-2, j-2), (i-2, j-1), $ \\ $(i-1, j-1), (i-1, j)$} & \parbox[c]{4.5cm}{\centering $(i-2,j),(i-1,j+1),$\\$(i,j-1)$} \\ \hline $Q_3((i,j))$ & \parbox[c]{4.5cm}{\centering $(i-2, j-2), (i-1, j-2), $ \\ $(i, j-2), (i, j-1) $} & \parbox[c]{4.5cm}{\centering $(i,j-3),(i+1,j-1),$\\$(i+1,j-1)$} \\ \hline $Q_4((i,j))$ & \parbox[c]{4.5cm}{\centering $(i-2, j-2), (i-1, j-2), $ \\ $(i-1, j-1), (i, j-1)$} & \parbox[c]{4.5cm}{\centering $(i,j-2),(i+1,j-1),$\\$(i-1,j)$} \\ \hline \end{tabular} \end{center} \caption{Definition of possible choices of paths starting from $(i-2, j-2)$ and reaching coordinate $(i,j)$, with the list of visited cells and the cells adjacent to each path. In a realization, we say that a path $Q_i$ is \emph{available} if all cells in the second of and third columns of the $i$-th row are empty.} \end{table} \renewcommand{\arraystretch}{1} \begin{remark} There exist two other possible choices for paths reaching cell $(i,j)$ from cell $(i-2,j-2)$, however, namely the paths $(i-2, j-2), (i-2, j-1), (i-1, j-1), (i, j-1), (i, j)$ and $(i-2, j-2), (i-1, j-2), (i-1, j-1), (i-1, j), (i, j)$. However, these paths require have more available cells than $Q_2$ and $Q_3$, respectively. Therefore, any trajectory that uses any of such paths have $Q_2$ or $Q_4$ available. \end{remark} \subsubsection{The dependency graph} We are now ready to define the \emph{dependency graph} of a figure. The dependency graph $H$ of a figure $F$ is a directed graph satisfying that, if $u,v \in F$ and $(u,v)\in E(H)$, then $u$ must be fixed before $v$ on every canonical realization of $v$. To precisely define the set of edges, we apply a number of applications of a set of \emph{rules}, described below. First, let us denote $\textsf{Ground}$ as the set $\{N+1\}\times [N]$, that is to say, the set of particles in the bottom of the figure. The vertex set of the dependency graph $H$ is $F\cup \textsf{Ground}$. The construction starts with the set of edges $$E_0= (\textsf{Ground} \times F\setminus \textsf{Ground})\cup \{(u,v) \in F\times F : u \in S(v)\} .$$ We start this way because all the edges in the bottom must be fixed (are fixed from the beginning) before all particles in $F$. Moreover, as we are considering only canonical realizations, and all the particles in $S(v)$ are fixed before $v$. Then, we iteratively add edges to $E_0$ according to two rules defined below, obtaining this way sets $E_1, E_2, \dots$. The process stops when no new edges can be with any of the two rules. The resulting set is the set of edges of $H$. For $\ell \geq 0$ and a node $v\in V(H)$, let us consider the sets $$N(v) = \{(\textnormal{row}(v),\textnormal{col}(v)\pm 1), (\textnormal{row}(v) \pm 1,\textnormal{col}(v)) \} \cap V(H)$$ $$D^-_\ell(v) = \{w\in V(H): (w,v)\in E_\ell \},$$ $$D^+_\ell(v) = \{w\in V(H): (v,w)\in E_\ell \},$$ which are called, respectively, the sets of \emph{adjacent nodes} and the sets of \emph{predecessors} and \emph{successors} of $v$ with respect to edge set $E_\ell$. Given $E_\ell$, we construct $E_{\ell+1}$ adding edges to $E_\ell$ according to the following two rules.\\ The first rule is used to force that a particle that is not adjacent to the ground must have at least one adjacent particle that is potentially fixed before it. This rule is applied over vertices $v\in F$ such that $D^-_\ell(v) = \emptyset$. First, let us call $R_\ell(v)$ the set of neighbors of $v$ defined by: $$R_\ell(v) = N(v) \setminus \left( \bigcup_{w\in D_\ell^+(v)} D_\ell^+(w) \cup D^+_\ell(v) \right) $$ In words, $R_\ell(v)$ is the set of particles adjacent to $v$ that are not successors of $v$, neither successors of its successors. If $R_\ell(v) =\emptyset$, then all neighbors of $v$ must be fixed after $v$, and therefore the figure is not realizable. To represent that, we add edge $(v,v)$ to $E_{\ell +1}$. Now suppose that $R_\ell(v)$ is nonempty and suppose that there exists $u \in R_\ell(v)$ such that $R_\ell(v) \setminus (D^+_\ell(u) \cap \{u\}) = \emptyset$. Then, necessarily $u$ must be a predecessor of $v$. We conclude the following definition of {\bf Rule 1}. \begin{definition}[{\bf Rule 1}] For each $v\in F$ such that $D_\ell^-(v)=\emptyset$: \begin{itemize} \item If $R_\ell(v) = \emptyset$, then add edge $(v,v)$ to $E_{\ell +1}$. \item If $R_\ell(v) \neq \emptyset$ and there exists $u \in R_\ell(v)$ satisfying that $R_\ell(v) \setminus (D_{\ell}^+(u) \cup \{u\}) = \emptyset$ then we add $(u,v)$ to $E_{\ell +1}$. \end{itemize} \end{definition} \medskip The second rule states that, when a particle is fixed there must exist an available path reaching $v$ from $(\textnormal{row}(v)-2, \textnormal{col}(v)-2)$. This implies that we must fix $v$ before the cells that block all the available paths of $v$. More precisely, for a particle $v\in F$, we call $B_\ell(v)$ the set of currently unavailable paths of $v$, formally: $$ B_\ell(v) = \{ k \in \{1,2,3,4\}: Q_k(v) \cap D^-_\ell(v) \neq \emptyset \},$$ The set of available paths of $v$ is $A_\ell(v) =\{1,2,3,4\}\setminus B_\ell(v)$. Now let us define $\mathcal{I}_\ell(v)$ as the set of particles in the intersection of all available paths, formally $$\mathcal{I}_\ell(v) = \bigcap_{k \in A_\ell(v)} Q_k(v).$$ Then, {\bf Rule 2} states that all particles in $\mathcal{I}_{v}$ must be fixed after $v$. We deduce the following definition. \begin{definition}[{\bf Rule 2}] For each $v\in F$: \begin{itemize} \item If $A_\ell(v) = \emptyset$, then add edge $(v,v)$ to $E_{\ell +1}$. \item If $u \in \mathcal{I}_{v}$, then we add $(v,u)$ to $E_{\ell +1}$. \end{itemize} \end{definition} \medskip Therefore, the construction of the dependency graph consists in the applications of {\bf Rule 1} and {\bf Rule 2} until no new edges are created. Since a figure contains $n$ particles, there are at most $n^2$ possible edges between them. Therefore, the construction finalizes in at most $n^2$ applications of the rules. Observe also that each rule can be applied in polynomial time. We formalize previous construction in Algorithm \ref{algo:dependency}. \begin{algorithm}[H] \KwIn{A figure $F$ represented by a set of coordinates in $[N]\times [N]$ \KwOut{A set of edges $E$} $ \textsf{Ground} \leftarrow (\{N+1\}\times [N])$ \tcp{the cells in the bottom}\; $E_0 = \leftarrow\{(u,v): u \in S(v)\}\cup (\textsf{Ground} \times (F\setminus \textsf{Ground})) $\: \For {$ u = (i,j) \in F$}{ $N(u) \leftarrow \{(i+1,j),(i-1,j),(i,j+1),(i,j-1)\} \cap (F\cup \textsf{Ground})$\; $Q_1(u) = \{(i-3, j), (i-2,j), (i-1,j), (i-2,j+1), (i-1, j+1)\}\cap (F\cup \textsf{Ground})$\; $Q_2(u) =\{(i-2, j), (i-1, j), (i-1, j+1), (i, j-1)\}\cap (F\cup \textsf{Ground}) $\; $Q_3(u) = \{(i, j-3), (i,j-2), (i,j-1), (i+1,j-2), (i+1, j-1) \}\cap (F\cup \textsf{Ground})$\; $Q_4(u) = \{(i, j-2), (i, j-1), (i+1, j-1), (i-1, j) \}\cap (F\cup \textsf{Ground})$\; } \For{ $\ell \in \{1, \dots n^2\}$}{ $E_{\ell +1} \leftarrow E_{\ell}$\; \For{$x \in F$}{ $D^+(x) \leftarrow \{w \in F: (x,w)\in E_{\ell}\}$\; $D^-(x) \leftarrow \{w \in F: (w,x)\in E_{\ell}\} $\; $R_\ell(x) \leftarrow N(x) \setminus \left( \bigcup_{w\in D_\ell^+(x)} D_\ell^+(w) \cup D^+_\ell(x) \right) $\; $ B_\ell(x) \leftarrow \{ k \in \{1,2,3,4\}: D^-(x)\cap Q_k(x) \neq \emptyset\}$\; $A_\ell(x) \leftarrow \{1,2,3,4\} \setminus B_\ell(x)$. \; $ \mathcal{I}_\ell(x) \leftarrow \displaystyle{\bigcap_{k\in A_\ell(x)} Q_k(x)}$ \; } \For{$v \in F$}{ \tcp{Rule 1} \If{$D_\ell^{-}(v) =\emptyset$ and $R_\ell(v) = \emptyset$}{ $E_{\ell+1} \leftarrow E_{\ell+1}\cup \{(v,v)\}$\; } \If{$D_\ell^{-}(v) =\emptyset$ and $R_\ell(v) \neq \emptyset$}{ \For{$u \in R_\ell(v)$}{ \If {$R_\ell(v) \setminus (D^+(u) \cup \{u\}) = \emptyset$}{ $E_{\ell+1} \leftarrow E_{\ell+1}\cup \{(u,v)\}$\; } } } \tcp{Rule 2} \eIf{$A_\ell(v) = \emptyset$}{ $E_{\ell+1} \leftarrow E_{\ell+1}\cup \{(v,v)\}$\; }{ \For{$u \in F \cup \textsf{Ground}$}{ \If{$u \in \mathcal{I}_v$}{ $E_{\ell+1} \leftarrow E_{\ell+1}\cup \{(v,u)\}$\; } } } } } \Return $E_{n^2}\setminus (\textsf{Ground} \times F\setminus \textsf{Ground})) $\; \caption{Constructing the edges of the dependency graph of figure $F$} \label{algo:dependency} \end{algorithm} \begin{definition} The \emph{dependency graph} of a figure $F$ is the graph with vertex set $F$ and set of edges obtained as the output of Algorithm \ref{algo:dependency} on input $F$. \end{definition} In Figure \ref{fig:dependecy_example1} is depicted an example of a figure $F$ and its corresponding dependency graph. \begin{figure} \begin{center} \includegraphics[width=0.4\textwidth]{dpendency_example1_1} \includegraphics[width=0.5\textwidth]{dpendency_example1_2} \includegraphics[width=0.4\textwidth]{dpendency_example1_3} \includegraphics[width=0.5\textwidth]{dpendency_example1_4} \includegraphics[width=0.4\textwidth]{dpendency_example1_5} \includegraphics[width=0.5\textwidth]{dpendency_example1_6} \end{center} \caption{Three examples of figures and their corresponding dependency graphs. Observe that the middle and bottom figures are not 2DLA-realizable, and their dependency graphs are not acyclic.} \label{fig:dependecy_example1} \end{figure} \begin{lemma} \label{lem:dependency} Let $H = (F,E)$ be the dependency graph of a 2DLA-realizable figure $F$. For every pair of particles $u,v \in F$, if $(u,v)\in E$ then $u$ is fixed before $v$ on every canonical realization of $F$. \end{lemma} \begin{proof} We prove the result by induction on $\ell$, showing that every edge in $E_{\ell}$ have the above property. The base case $\ell = 0$ is trivial because $E_0$ contains only the edges $(u,v)$ such that $u \in S(v)$. Now suppose that for a given $\ell\geq 0$ all the edges in $(u,v)$ satisfy that $u$ is fixed before $v$ on every canonical realization of $F$. If $E_{\ell +1} = E_{\ell}$ then $E(H) = E_{\ell}$ and we are done. Therefore, suppose that $E_{\ell + 1}$ contains an edge $(u,v)$ not in $E_{\ell}$ and assume that there exists a canonical realization $\varphi$ that fixes $v$ before $u$. We will reach a contradiction by showing that $(u,v)$ can not created with {\bf Rule 1} or {\bf Rule 2}. First, as $v$ can fixed before $u$ in $\varphi$, there must exist a neighbor $w \in N(v)$ that is fixed before $v$ and $u$. From the induction hypothesis, this $w$ must be contained in $R_\ell(v)$ and moreover, $w \notin D_\ell^+(u)\cup \{u\}\cup D_\ell^+(v)$. Then $(u,v)$ was not created according to {\bf Rule 1}. Second, since $u$ can be fixed after $v$ in $\varphi$, there must exist an available path $k\in A_\ell(u)$ such that $v \notin Q_k(u)$. We deduce that $(u,v)$ can not be created according to {\bf Rule 2}. We deduce that, if $(u,v)$ is an edge of $E_{\ell+1}$ then $u$ must be fixed before $v$ on every canonical realization of $F$. \end{proof} Our approach consists in constructing a canonical realization of $F$ by removing one by one the particles of $F$, applying the following recursive algorithm. First, if $|F|= 1$, i.e., the input figure consists in a single particle, the algorithm returns a realization consisting in this single particle. If $|F|>1$, we compute the set of edges $E$ of the dependency graph of $F$. Then, we look for a \emph{removable particle} $u$, defined as follows. \begin{definition}\label{def:dependency} A removable particle is a particle satisfying the following conditions. \begin{itemize} \item $C(u) = \{ k \in \{1,2,3,4\}: (F \cup \textsf{Ground}) \cap Q_k(u) = \emptyset\} \neq \emptyset$, meaning that there is at least one available path $u$ not touching any particle in $F \cup \textsf{Ground}$. \item $D^+(u) = \{w \in F: (t,w)\in E\} = \emptyset$, meaning that no other particle needs to be fixed after $u$. \item The dependency graph of $F\setminus\{u\}$ is acyclic. \end{itemize} \end{definition} If no such particle $u$ is found, the algorithm rejects. Otherwise, we recursively run the algorithm in $F\setminus \{u\}$. Finally, if the recursive call of the algorithm does not reject, the output is a realization $\tilde{\varphi}$ of $F\setminus \{u\}$. The realization of $F$ is obtained by fixing $u$ after all the particles in $F\setminus\{u\}$ according to $\tilde{\varphi}$, obtaining this way a canonical realization $\varphi$. The pseudocode of algorithm is written in Algorithm \ref{algo:construction}. \begin{algorithm}[h] \KwIn{A figure $F \subseteq [N]\times[N] $ of size $n$ with an acyclic dependency graph.} \KwOut{A realization of $F$.} \eIf{$|F| = \{u\}$}{ \Return a list $\varphi$ containing $u$ as a single element.\; }{ Compute $E$ as the output of Algorithm \ref{algo:dependency} on input $F$\; \For{$x\in F$}{ $D^+(x) \leftarrow \{w \in F: (x,w)\in E\}$\; $ C_x \leftarrow \{ k \in \{1,2,3,4\}: F\cap Q_k(x) \neq \emptyset\}$\; } $\alpha \leftarrow \{u \in F: C_x \neq \emptyset\}$\; $\beta \leftarrow \{u \in F: D^+(u) = \emptyset\}$\; $\gamma \leftarrow \alpha\cap \beta$\; \For{$u \in \gamma$}{ Compute $E'$ as the output of Algorithm \ref{algo:dependency} on input $F\setminus \{u\}$\; \If{ $H=(F\setminus\{u\}, E')$ contains a cycle}{ $\gamma \leftarrow \gamma \setminus \{u\}$} } Pick any $u\in \gamma$\; $\tilde{\varphi} \leftarrow$ output of Algorithm \ref{algo:construction} on input $F\setminus \{u\}$\; $\varphi \leftarrow $ list $ \tilde{\varphi}$ adding $u$ in the end. \; \Return $\varphi$ \; } \caption{Constructing the realization of $F$} \label{algo:construction} \end{algorithm} \begin{lemma}\label{lem:tech1} Let $F$ be a figure with an acyclic dependency graph $H$, then $H$ contains a removable particle. \end{lemma} \begin{proof} Let $F$ be a figure such that its corresponding dependency graph $H$ is acyclic. Let $W$ be the set of particles with out-degree zero in $H$, formally $W = \{v \in F: D^+(v) = \emptyset\}$. This set is non-empty as $H$ is acyclic. Now let us pick the particle in $u \in W$ such that $\textnormal{col}(u)$ is minimum, and over all possible choices, we pick the one such that $\textnormal{row}(u)$ is maximum. In other words, $u$ is the bottom-left most particle in $W$. We are going to show that $u$ is a removable particle, by showing a series of claims. We define before the following four sets relatively to $u$: $$S_{NE}(u) = \{w \in F: \textnormal{row}(w)\leq \textnormal{row}(u) \textrm{ and } \textnormal{col}(w) \geq \textnormal{col}(u)\}\setminus \{u\}$$ $$S_{NW}(u) = \{w \in F: \textnormal{row}(w)< \textnormal{row}(u) \textrm{ and } \textnormal{col}(w) < \textnormal{col}(u)\}$$ $$S_{SE}(u) = \{w \in F: \textnormal{row}(w)> \textnormal{row}(u) \textrm{ and } \textnormal{col}(w) > \textnormal{col}(u)\}$$ $$S_{SW}(u) = \{w \in F: \textnormal{row}(w)\geq \textnormal{row}(u) \textrm{ and } \textnormal{col}(w) \leq \textnormal{col}(u)\} \setminus \{u\}$$ Observe that $S_{NW}(u)$ is the scope of $u$ and $S_{SE}(u)$ is the shadow of $u$. Observe that the scope of $u$ is empty, because $u$ has out degree zero in $H$. \medskip \noindent {\bf Claim 1:} All nodes in $S_{SW}(u)$ are ancestors of $u$ in $H$. Formally, for every $w\in S_{SW}(u)$ there is a $w,u$-directed path in $H$. \\ \textit{Proof of Claim 1}. Let $w_0$ an arbitrary particle in $S_{SW}(u)$. From the choice of $u$, we know that $w_0$ has at least one out-neighbor in $H$. Let $P = w_0, w_1, \dots, w_k$ be a longest directed path in $H$ starting from $w_0$. Then $w_k$ has out degree zero, implying that it is not contained in $S_{SW}(u)$. Let $w_\ell$, with $0<\ell\leq k$ be the first node in $P$ not contained in $S_{SW}(u)$. If $w_\ell = u$ we are done. If $w_\ell$ belongs to $S_{SE}(u)$ then $(w_ell,u)\in E(H)$ and $P' = w_0, \dots, w_\ell, u$ is a directed path in $H$. Finally, suppose that $w_\ell$ belongs to $S_{NE}$. Then necessarily $(w_{\ell-1}, w_\ell)$ is created by {\bf Rule 2} and $w_{\ell}$ belongs to $V_1(w_{\ell-1})$. Observe that $u$ is also contained in $V_1(w_{\ell-1})$ and then $(w_{\ell-1}, u)$ is also an edge created by {\bf Rule 2}. We conclude that $P'' = w_0, \dots, w_{\ell-1}, u$ is a directed path of $H$. \medskip \noindent {\bf Claim 2:} $u$ has an available path in $F$, i.e. $C(u) \neq \emptyset$. \\ \textit{Proof of Claim 2}. Suppose that $Q_3(u)$ intersects $F$ and pick $w \in Q_3(u) \cap F$. Observe that $w\in S_{SW}(u)$. Therefore, by {\bf Claim 1} there is a directed path from $w$ to $u$, and moreover, $(w,u)$ is an edge in $E(H)$. Then, by {\bf Rule 2} there is an edge connecting $u$ with all the particles in $V_1(u)$. Since $u$ has out-degree zero, necessarily $V_1(u) \cap F$ is empty. We deduce that $Q_1(u)$ is an available path for $u$ and then $1 \in C(u)$. We conclude that $\{1, 3\}\cap C(u) \neq \emptyset$. \medskip Claims {\bf 1} and {\bf 2} imply that $u$ satisfies the first two conditions of the definition of removable particle. It remains to show that the dependency graph of $F\setminus \{u\}$ is acyclic. In the following we call $E(H-u)$ the dependency graph of $F\setminus \{u\}$. \\ \noindent {\bf Claim 3:} $E(H)\setminus (F \times \{u\})$ is a subset of $E(H-u)$. \\ \textit{Proof of Claim 3}. Suppose that $E(H)\setminus (F \times \{u\})$ contains an edge $e = (w_1, w_2)$ not in $E(H-u)$. From all possible choices, let us pick the one that is created in the earliest iteration of Algorithm \ref{algo:dependency}. Observe that $e$ can not be created by {\bf Rule 1}. Indeed, if $R_\ell(w_2)$ does not contains $u$ then necessarily $e$ is also an edge of $E(H-u)$, and if $R_\ell(w_2)$ contains $u$ then necessarily $u$ also belongs to $D^+(w_1)$ ($u$ must be different than $w_1$ because $u$ has out-degree zero). In both cases we have that if $e$ is created by {\bf Rule 1}, then $e$ must be an edge of $E(H-u)$. Then necessarily $e$ is created with {\bf Rule 2}. However, as $u$ has out-degree zero, it cannot block any path of another node. We deduce that $e$ can not exist and then $E(H)\setminus (F \times \{u\}) \subseteq E(H-u)$. \\ \noindent {\bf Claim 4:} Let $e = (w_1, w_2)$ be an edge of $E(H-u)\setminus E(H)$. Then $w_1\neq w_2$ (i.e. $e$ is not a self-loop), and $w_1$ belongs to $S_{NE}(u)$. Moreover, if $w_2$ also belongs to $S_{NE}(u)$, then $w_2$ is closer to $u$ than $w_1$ in Manhattan distance, i.e. $|\textnormal{row}(w_2) - \textnormal{row}(u)|+ |\textnormal{col}(w_2)-\textnormal{col}(u)|< |\textnormal{row}(w_1) - \textnormal{row}(u)|+ |\textnormal{col}(w_1)-\textnormal{col}(u)|$. \\ \textit{Proof of Claim 4}. Let $\ell_1< \dots < \ell_t$ be the iterations of Algorithm \ref{algo:dependency} in which an edge of $E(H-u)\setminus E(H)$ is created. If $e = (w_1, w_2)$ is created in iteration $\ell_1$, then necessarily $e$ is created by {\bf Rule 1} (as $u$ has out-degree $0$ it can not block any path of another node). Then necessarily $w_2$ is a neighbor of $u$ such that $D^+(w_2) = \emptyset$. Observe that $R_{\ell_1}(w_2) \setminus \{u\} \neq \emptyset$ because otherwise $(w_2, u)$ is an edge of $E(H)$. Then $w_1\neq w_2$ and $w_2$ is closer to $u$ than $w_1$ in Manhattan distance. Now suppose that the claim is true for all edges created in steps up to $\ell_i$, with $i\in \{1,\dots, t-1\}$, and suppose that $e=(w_1, w_2)$ is created in iteration $\ell_{i+1}$. If $(w_1, w_2)$ is created by {\bf Rule 1}, then necessarily $w_2$ has an out-neighbor $w_3$ not present in $E(H)$, that was created in iterations $\ell_1, \dots, \ell_{i}$. Then $w_2$ belongs to $S_{NE}(u)$ by induction hypothesis. Observe that $R_{\ell_{i+1}}(w_2) \setminus w_3 \neq \emptyset$, otherwise $(w_2,w_3)$ is an edge of $E(H)$. Then $w_1 \neq w_2$. Suppose by contradiction that $w_1$ is not contained in $S_{NE}(u)$. Then necessarily $w_1$ belongs to $S_{SE}(u)$, with $w_1 = (\textnormal{row}(w_2)+1, \textnormal{col}(w_2))$. Moreover, $w_3$ belongs to $S_{NE}(u)$. Then, by induction hypothesis, $w_3$ is closer to $u$ than $w_2$, meaning that $w_3 = (\textnormal{row}(w_2), \textnormal{col}(w_2)-1)$. This implies that $(w_1, w_3)$ is an edge of $E(H)$ and then $(w_1, w_2)$ must be also an edge of $E(H)$. We deduce that $w_1$ is contained in $S_{NE}(u)$. As the distance from $w_2$ to $w_3$ is fewer than the distance of $w_1$ to $w_3$ we deduce by the induction hypothesis that the distance from $w_2$ to $u$ is fewer than the distance from $w_1$ to $u$. If $(w_1, w_2)$ is created by {\bf Rule 2}. Then necessarily $w_1$ has an incoming edge from a node $w_0 \in V(w_1)$ such that $(w_0, w_1)$ is not in $E(H)$ and was created in iterations $\ell_1, \dots, \ell_{i}$. From the induction hypothesis we know that $w_0$ belongs to $S_{NE}(u)$ and is closer to $u$ than $w_1$. Then $w_0$ belongs to $V_1(w_1)$. If $(w_0, w_1)$ is created with {\bf Rule 1}, then there is a path $P$ from $w_1$ to one of the adjacent particles of $u$ where all the edges in that path are edges in $E(H-u)\setminus E(H)$ created by {\bf Rule 1} (this is proven in the previous paragraph). Then $P$ either contains $w_2$ or contains a node $w' $ such that. $\textnormal{row}(w') = \textnormal{row}(w_2)$ and $\textnormal{col}(w') > \textnormal{col}(w_2)$. Indeed, in the other possibility is that $(v_0, v_1)$ and $(v_1, v_2)$ are edges of $P$, with $v_0 = (\textnormal{row}(w_2)-1, \textnormal{col}(w_2)+1)$, $v_1 = (\textnormal{row}(w_2)-1, \textnormal{col}(w_2))$ and $v_2= (\textnormal{row}(w_2)-1, \textnormal{col}(w_2)-1)$. However, this is impossible because in that case $(w_2, v_1)$ must be an edge of $E(H)$ and then $(v_0, v_1)$ is also an edge of $E(H)$. Then, there is a directed path of \emph{rule 1 edges} connecting $w_1$ and a neighbor of $u$. This implies that $w_2$ is ether in $S_{NE}(u)$ or in $S_{SW}(u)$. In any case we have that $(w_1, w_2)$ satisfies the conditions of the claim. It remains the case when $(w_0, w_1)$ is created with {\bf Rule 2} in some iteration $\ell_1, \dots, \ell_{i}$. Let $P' = v_0, \dots, v_k$ be the longest directed path of edges in $E(H-u)\setminus E(H)$ that are created with {\bf Rule 2} in iterations $\ell_1, \dots, \ell_{i}$, such that $v_k = w_0$. Then $v_0$ must have an incoming neighbor $z_0$ such that $(z_0, w_0)$ is an edge of $E(H-u)\setminus E(H)$ created by {\bf Rule 1}, and such that $z_0 = (\textnormal{row}(v_0)-1, \textnormal{col}(v_0))$. Following the same argument than in the previous case (i.e. taking the path of edges of $E(H-u)\setminus E(H)$ created by {\bf Rule 1} connecting $w_0$ with a particle adjacent to $u$) we deduce that $(w_1, w_2)$ satisfies the conditions of the claim. This finishes the proof of {\bf Claim 4}. Observe that {\bf Claim 4} implies that the edges of $E(H-u)\setminus E(H)$ form a directed acyclic graph. On the other hand, we know that $H$ is acyclic. Finally, it is impossible to have a cycle containing a combination of edges in $E(H-u)\setminus E(H)$ and $E(H)$, because all the out-going neighbors of nodes in $E(H-u)\setminus E(H)$ also belong to $E(H-u)\setminus E(H)$. We deduce that the dependency graph of $F\setminus \{u\}$ is acyclic. We conclude that $u$ is a removable particle of $F$. \end{proof} We remark that the third condition of Definition \ref{def:dependency} is not necessarily deduced from the first two conditions, in the sense that there are figures with particles $u$ satisfying that $C(u)\neq \emptyset$ and $D^+(u) = \emptyset$, but that are not removable. For instance, the realizable figure depicted in Figure \ref{fig:dependecy_example2} contains a particle $u$ such that $C(u)\neq \emptyset$, $D^+(u) = \emptyset$ and $F\setminus\{u\}$ is not realizable. \begin{figure} \begin{center} \includegraphics[width=0.4\textwidth]{dpendency_example2_1} \includegraphics[width=0.5\textwidth]{dpendency_example2_2} \includegraphics[width=0.4\textwidth]{dpendency_example2_3} \includegraphics[width=0.5\textwidth]{dpendency_example2_4} \includegraphics[width=0.4\textwidth]{dpendency_example2_5} \includegraphics[width=0.5\textwidth]{dpendency_example2_6} \end{center} \caption{An example of a figure containing a node of coordinates $u = (5,4)$ such that $C(u)\neq \emptyset$ (as $Q_1(u)$ is available), $D^+(u) = \emptyset$ but $F \setminus \{u\} $ contains a cycle. In the first row is depicted the figure $F$ and its dependency graph. And in the second row is depicted $F\setminus \{u\}$ and its corresponding dependency graph. Nodes $(5,5), (4,6), (5,6)$ form a cycle in this graph. Observe that $F$ does contain a removable particle, for instance $v = (3,6)$. In the third row is depicted $F \setminus \{ v\}$ and its corresponding (acyclic) dependency graph. } \label{fig:dependecy_example2} \end{figure} We are now ready to give the main result of this section. \begin{theorem} A figure $F$ is 2DLA-realizable if and only its dependency graph $H$ is acyclic. \end{theorem} \begin{proof} Let us assume that $H$ contains a cycle, and let $u$ be a node in a cycle of $H$. Lemma \ref{lem:dependency} implies that $u$ must be placed before himself on any canonical realization. Therefore, $F$ does not admit a canonical realization. From Lemma \ref{canon} we deduce that $F$ is not realizable. Conversely, suppose that $H = (F,E)$ is acyclic. Then, Lemma \ref{lem:tech1} imply that we can successively decompose $F$ finding removable nodes. The obtained canonical realization of $F$ is the output of Algorithm \ref{algo:construction}. \end{proof} \begin{corollary} 2-\textsc{DLA-Realization}~is solvable in polynomial time. \end{corollary} \begin{remark} An implementation of the algorithm solving $2$-\textsc{DLA-Realization}\ can be found in \url{https://github.com/pedromontealegre/2DLA-Realization}. \end{remark} \section{Conclusion} The introduction of restrictions to discrete dynamical systems, coming from statistical physics, has been shown to change the computational complexity of its associated decision problem. We have once again observed this phenomenon with the changes in computational complexity when restricting the directions a particle can move in the DLA model. By adapting the {\bf P}-Complete \ proof of the 4-{\textsc{DLA-Prediction}} \ we showed that both 3-{\textsc{DLA-Prediction}} and 2-{\textsc{DLA-Prediction}} are {\bf P}-Complete. For 1-{\textsc{DLA-Prediction}}, \ we tackled the generalized problem, \textsc{Ballistic Deposition} and showed that by exploiting the commutativity exhibited by the dynamics of the system, we created a non-deterministic log-space algorithm to solve the problem, and show that \textsc{1-Prediction} \ is \textbf{\textsc{NL}}-Complete. What is interesting to note is that the algorithm does not depend on the topological properties of the model, it exclusively works on the input word (the sequence of particle throws in this case). We finally showed that characterizing the shapes that are obtainable through the dynamics is an interesting problem, and exhibited that the computational problem associated is in ${\bf L}$ for the one-directional dynamics, and in ${\bf P}$ for the two-directional one. This is interesting due to the fact that the figures produced when executing the probabilistic versions of the dynamics, as shown in Figure \ref{fig:dynex}, the computational complexity of examining these shapes is efficient. \subsection{Future Work} An interesting extension to the presented problem is the one of determining, given a figure, what is the minimum amount of directions necessary to produce it, if it is achievable at all. We have shown that figures generated by the \textsc{1-Prediction} \ model are characterizable in ${\bf L}$, and those of the two-directional model in ${\bf P}$. It remains to see if the latter can be improved into an ${\bf NC}$ algorithm, or the problem is in fact {\bf P}-Complete. The definition of the dependency graph seems intrinsically sequential, and we believe that is unlikely that the problem could be solved by a fast-parallel algorithm In addition, the complexity classification of realization problem for three and four directions remains open. We believe that the definition of a dependency graph for these cases is plausible, but several several assumptions (such as the existence of canonical realizations) must be redefined. A related problem, not treated in this article, consists in the \emph{reachability}, i.e. given a figure $F$ and a subfigure $F'$, decide if it is possible to construct $F$ given that $F'$ is already fixed. This problem can be also studied restricting the number of directions the particles are allowed to move in. Our belief is that there is room to create more complex gadgets, indicating that these problems are possibly \textbf{\textsc{NP}}-Complete at least for three or more movement directions. \section*{Acknowledgments} We would like to thank the anonymous reviewers for letting us know about the Ballistic Deposition model, which we had no previous knowledge~of. This work has been partially supported by ANID, via PAI + Convocatoria Nacional Subvenci\'on a la Incorporaci\'on en la Academia A\~no 2017 + PAI77170068 (P.M.), FONDECYT 11190482 (P.M.) FONDECYT 1200006 (E.G. and P.M.) and via CONICYT-PFCHA/Mag\'isterNacional/2019 - 22190497 (N.B.). \bibliographystyle{siamplain}
{'timestamp': '2020-11-23T02:13:43', 'yymm': '1904', 'arxiv_id': '1904.10011', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.10011'}
arxiv
\section{Introduction}\label{sec:intro} When using Stochastic Gradient Descent (SGD), it is important that samples are drawn at random. In contrast, cycling over a specific permutation of data points (e.g.~sorting data by label, or even alphabetically or by time of collection) can be detrimental to the performance of SGD. But in some applications, such as in Federated Learning \citep{FL3, FL4} or when running SGD in ``real time'', some cyclic patterns in the data samples are hard to avoid. In this paper we investigate how such cyclic structure hurts the effectiveness of SGD, and how this can be corrected. We model this semi-cyclicity through a ``block-cyclic'' structure, where during the course of training, we cycle over blocks in a fixed order and samples for each block are drawn from a block-specific distribution. Our primary motivation is Federated Learning. In this setting, mobile devices collaborate in the training of a shared model while keeping the training data decentralized. Devices communicate updates (e.g. gradients) to a coordinating server, which aggregates the updates and applies them to the global model. In each iteration (or round) of Federated SGD, typically a few hundred devices are chosen randomly by the server to participate; critically, however, only devices that are idle, charging, and on a free wireless connection are selected~\cite{FL_BLOG,bonawitz19sysml}. This ensures Federated Learning does not impact the user's experience when using their phone, but also can produce significant diurnal variation in the devices available, since devices are more likely to meet the training eligibility requirements at night local time. For example, for a language model \citep{gboard}, devices from English speakers in India and America are likely available at different times of day. When the number of blocks in each cycle is high and the number of samples per block is low, the setting approaches fully-cyclic SGD, which is known to be problematic. But what happens when the number of blocks is fairly small and each blocks consists of a large number of samples? E.g., if there are only two blocks corresponding to ``day'' and ``night'', with possibly millions of samples per block. % An optimist would hope that this ``slightly cyclic'' case is much easier than the fully cyclic case, and the performance of SGD degrades gracefully as the number of blocks increases. Unfortunately, in Section \ref{sec:lower} we show that even with only two blocks, the block-cyclic sampling can cause an arbitrarily bad slowdown. One might ask whether alternative forms of updates, instead of standard stochastic gradient updates, can alleviate this degradation in performance. We show that such a slowdown is unavoidable for any iterative method based on semi-cyclic samples. Instead, the solution we suggest is to embrace the heterogeneity in the data and resort to a {\em pluralistic} solution, allowing a potentially different model for each block in the cycle (e.g.~a ``daytime'' model and a ``nighttime'' model). A naive pluralistic approach would still suffer a significant slowdown as it would not integrate information between blocks (Section \ref{sec:plur}). In Section~\ref{sec:pluravg} we show a remarkably simple and practical pluralistic approach that allows us to obtain exactly the same guarantees as with i.i.d.~non-cyclic sampling, thus entirely alleviating the problem introduced by such data heterogeneity---as we also demonstrate empirically in Section \ref{sec:experiments}. In Section \ref{sec:hedge} we go even further and show how we can maintain the same guarantee without any deterioration while also being competitive with separately learned predictors, hedging our bets in case the differences between components are high. \section{Setup} We consider a stochastic convex optimization problem \begin{equation} \label{eq:F} F(w) = \Ee{z \sim \mathcal{D}}{f(w,z)} \quad\text{where}\quad \mathcal{D} = \frac{1}{m} \sum_{i=1}^m \mathcal{D}_i, \end{equation} where each component $\mathcal{D}_i$ represents the data distribution associated with one of $m$ blocks $i=1,\ldots,m$. For simplicity, we assume a uniform mixture; our results can be easily extended to non-uniform mixing weights and corresponding non-uniform block lengths. In a learning setting, $z=(x,y)$ represents a labeled example and the instantaneous objective $f(w,(x,y))=\textit{loss}(h_w(x),y)$ is the loss incurred if using the model $w$. % We assume $f(w,z)$ is convex and 1-Lipschitz with respect to $w$, which lives in some high-, possibly infinite-dimensional, Euclidean or Hilbert space. Our goal is to compete with the best possible predictor of some bounded norm $B$, that is to learn a predictor $\hat{w}$ such that $F(\hat{w})\leq F(w_{\star}) + \epsilon$ where % $F(w_{\star}) = \inf_{\norm{w}\leq B} F(w)$. We consider Stochastic Gradient Descent (SGD) iterates on the above objective: \begin{equation} \label{eq:SGD} w_{t+1} \leftarrow w_{t} - \eta_{t} \nabla f(w_t,z_t). \end{equation} If the samples $z_t$ are chosen independently from the data distribution $\mathcal{D}$, then with an appropriately chosen stepsizes $\eta_t$, SGD attains the mini-max optimal error guarantee \citep[e.g.][]{shalev2009stochastic}: \begin{equation} \label{eq:SGDbound} \EE{F(\overline{w})} \leq F(w_{\star}) + O\left(\sqrt\frac{B^2}{T}\right) \end{equation} where $\overline{w} = \frac{1}{T} \sum_{i=1}^T w_i$ and $T$ is the total number of iterations, and thus also the total number of samples used. But here we study {\em Block-Cyclic SGD}, which consists of $K$ {\em cycles} (e.g., days) of $mn$ iterations each, for a total of $T=Kmn$ iterations of the update \eqref{eq:SGD}. In each cycle, the first $n$ samples are drawn from $\mathcal{D}_1$, the second $n$ from $\mathcal{D}_2$ and so forth. That is, samples are drawn according to \begin{equation}\label{eq:seqkmn} z_{t(k,i,j)} \sim\mathcal{D}_i \quad\textrm{where } t(k,i,j)\!=(k\!-\!1)nm+(i\!-\!1)n+j \end{equation} where $k=1..K$ indexes the cycles, $i=1..m$ indexes blocks and $j=1..n$ indexes iterations within a block and thus $t(k,i,j)\in\{1,\ldots,T\}$ indexes the overall sequence of samples and corresponding updates. The samples are therefor no longer identically distributed and the standard SGD analysis no longer valid. We study the effect of such block-cyclic sampling on the SGD updates \eqref{eq:SGD}. One can think of $\mathcal{D}$ as the population distribution, with each step of SGD being based on a fresh sample; or of $\mathcal{D}$ as an empirical distribution over a finite training set that is partitioned to $m$ groups. It is important however not to confuse a {\em cycle} over the different components with an {\em epoch} over all samples---the notion of an {\em epoch} or the size of the support of $F$ (i.e.~the number of training points if $F(w)$ is viewed as an empirical objective) do not enter our analysis. Either view is consistent with our development, though our discussion will mostly refer to the population view of SGD based on fresh samples. \section{Lower Bounds for Block-Cyclic Sampling}\label{sec:lower} How badly can the block-cyclic sampling \eqref{eq:seqkmn} hurt the SGD updates \eqref{eq:SGD}? Unfortunately, we will see that the effect can be quite detrimental, especially when the number of samples $n$ in each block is very large compared to the overall number of cycles $K$, and even if the number of components $m$ is small. This is a typical regime in Federated Learning if we consider daily cycles, as we would hope training would take a small number of days, but the number of SGD iterations per block can be very high. For example, recent models for Gboard were trained for \num{1.2e6} sequential steps over 4-5 days ($K = 4$ or $5$, $nm = \num{3e5}$, and e.g. $m=6$ and $n=\num{5e4}$ if the day is divided into six 4-hour blocks) \cite{gboard}.\footnote{The cited work uses the Federated Averaging algorithm with communication every 400 sequential steps, as opposed to averaging gradients every step, so while not exactly matching our setting, it provides a rough estimate for realistic scenarios.} To see how even $K=2$ can be very bad, consider an extreme setting where the objective $f(w,z)$ depends only on the component of $z$, but is the same for all samples from each $\mathcal{D}_i$. Formally, let $z=\{1,2\}$ with $P(z=i)=1$. That is there are only two possible examples which we call ``1'', which is the only example in the support of the first component $\mathcal{D}_1$ and ``2'', which is the only example in the support of $\mathcal{D}_2$. The problem then reduces to a deterministic optimization problem of minimizing $F(w)=\frac{1}{2}f(w,1)+\frac{1}{2}f(w,2)$, but in each block we see gradients only of one of the two terms. With a large number of iterations per block $n$, we might be able to optimize each term separately very well. But we also know that in order to optimize such a composite objective to within $\epsilon$, even if we could optimize each component separately, requires alternating between the two components at least $\Omega(B/\epsilon)$ times \cite{woodworth2016tight}, establishing a lower bound on the number of required cycles, independent of the number of iterations per cycle. This extreme deterministic situation establishes the limits of what can be done with a limited number of cycles, and captures the essence of the difficulty with block-cyclic sampling. In fact, the lower bound we shall see applies not only to the precise SGD updates \eqref{eq:SGD} but to {\em any} method that uses block-cyclic samples as in \eqref{eq:seqkmn}, and at each iteration access $f(\cdot,z_t)$, i.e.~the objective on example $z_t$. More precisely, consider any method that at iteration $t$ chooses a ``query point'' $w_t$ and evaluates $f(w_t,z_t)$ and the gradient (or a sub-gradient) $\nabla f(w_t,z_t)$, where $w_t$ may be chosen in {\em any} way based on all previous function and gradient evaluations (the SGD iterates \eqref{eq:SGD} is just one examples of such a method). The output $\hat{w}$ of the algorithm can then be chosen as any function of the query points $w_t$, the evaluated function values and the gradients. \begin{theorem} \label{thm:LowerLip} Consider any (possibly randomized) optimization method of the form described in the previous paragraph, i.e.~where access to the objective is by evaluating $f(w_t,z_t)$ and $\nabla f(w_t,z_t)$ on semi-cyclic samples \eqref{eq:seqkmn} and where $w_t$ is chosen based on $\left\{(f(w_s,z_s),\nabla f(w_s,z_s)),s<t\right\}$ and the output $\hat{w}$ based on all iterates\footnote{This theorem, as well as Theorem \ref{thm:Lowersmooth}, holds even if the method is allowed ``prox queries''\removed{, that is to solve an optimization problem over $f(w,z_t)$} of the form $\arg\min_w f(w,z_t)+\lambda_t \norm{w-w_t}^2$.\removed{where $w_t$ and $\lambda_t$ are chosen by the method}}. For any $B,n,K$ and $m>1$ there exists a 1-Lipschitz convex problem over high enough dimension such that $\EE{F(\hat{w})}\geq F(w_{\star})+\Omega(B/K)$, where the expectation is over $z_t$ and any randomization in the method. \end{theorem} \begin{proof} Let $P(z=1|i<m/2)=1$ and $P(z=2|i\geq m/2)=1$, with the following functions taken from \citet{woodworth2018graph}, which in turn is based on the constructions in \citet{arjevani2015communication,woodworth2017lower,carmon2017lower,woodworth2017lower}: \begin{equation} \begin{aligned} f(w,1)&=\frac{\eta}{8}\Big(-2a \langle v_1,w \rangle + \phi(\langle v_{4K},w\rangle) \\ &\quad +\sum_{k=1}^{2K-1}\phi(\langle v_{2k}-v_{2k+1},w \rangle)\Big) \\ f(w,2)&=\frac{\eta}{8}\left(\sum_{k=1}^{2K}\phi(\langle v_{2k-1}-v_{2k},w \rangle)\right) \end{aligned} \end{equation} where $v_r$ are orthogonal vectors, $\eta=4BK,\gamma=2B/(\eta\sqrt{K}),a=1/\sqrt{64K^3}$, and for now consider $\phi(x)=2 \gamma \abs{x}$. The main observation is that each vector $v_{2k+i}$ is only revealed after $w$ includes a component in direction $v_{2k+i-1}$ (more formally: it is not revealed if $w\in\spn\{v_1,\ldots,v_{2k+i-2}\}$), and only when $f(w,i)$ is queried \citep[Lemma 9]{woodworth2018graph}. That is, each cycle will reveal at most two vectors, $v_{2k+1}$ for queries on the first half of the blocks, and $v_{2k+2}$ for queries on the second half. After $K$ cycles, the method would only encounter vectors in the span of the first $2K$ vectors $v_1,\ldots,v_{2K}$. But for $\hat{w}\in\spn\{v_1,\ldots,v_{2K}\}$, we have $F(\hat{w})\geq F(w_{\star}) + \frac{B}{96K}$ \citep[Lemma 8]{woodworth2018graph}. These arguments apply if the method does not leave the span of gradients returned so far. Intuitively, in high enough dimensions, it is futile to investigate new directions aimlessly. More formally, to ensure that trying out new directions over $T=Kmn$ queries wouldn't help, following appendix C of \citep{woodworth2018graph}, we can choose $v_r$ randomly in $R^{\tilde{O}(K^5n^2m^2)}$ and use a piecewise quadratic $\phi(x)$ that is 0 for $\abs{z}\leq a/2$ and is equal to $\phi(x)=2\gamma \abs{x}-\gamma^2 - a^2/2$ for $\abs{x}\geq\gamma$. \end{proof} Theorem \ref{thm:LowerLip} establishes that once we have a block-cyclic structure with multiple blocks per cycle, we cannot ensure excess error better then: \begin{equation} \label{eq:lower1} F(\hat{w})-F(w_{\star})=\Omega\left(\frac{B}{K}\right)=\Omega\left(\sqrt\frac{B^2}{T}\sqrt{\frac{mn}{K}}\right). \end{equation} Compared to using i.i.d.~sampling as in Eq.~\eqref{eq:SGDbound}, this is worse by a factor of $\sqrt{mn/K}$, which is very large when the number of samples per block $n$ is much larger then the number of cycles $K$, as we would expect in many applications. \removed{Said differently, reaching excess error $\epsilon$ might take $K = B/\epsilon = \sqrt{nm K_{\textrm{iid}}}$ cycles, where $K_{\textrm{iid}}$ is the number of cycles required with i.i.d.~sampling and $nm$ iterations per cycle.} For smooth objectives (i.e., with Lipschitz gradients) the situation is quantitatively a bit better, but we again can be arbitrarily worse then i.i.d.~sampling as the number $n$ of iterations per block increases: \begin{theorem}\label{thm:Lowersmooth} Under the same setup as in Theorem \ref{thm:LowerLip}, for any $B,n,K$ and $m>1$ there exists a 1-Lipschitz convex problem where the gradient $\nabla_w f(w,z)$ is also 1-Lipschitz, such that $\EE{F(\hat{w})}\geq F(w_{\star})+\Omega(B^2/K^2)$. \end{theorem} \begin{proof} Use the same construction as in Theorem \ref{thm:LowerLip}, but with $\eta=B^2$ and \begin{minipage}[c]{0.35\textwidth} \vspace{-5mm} $$ \phi(z) = \begin{cases} 0 & \abs{z} \leq a/2 \\ 2(\abs{z} - a/2)^2 & a/2 < \abs{z} \leq a \\ z^2 - a^2/2 & a < \abs{z} \leq \gamma \\ 2\gamma\!\abs{z} -\! \gamma^2\! - a^2/2 & \abs{z} > \gamma \end{cases} $$ \end{minipage} \begin{minipage}[c]{0.12\textwidth} \includegraphics[height=20mm,width=24mm]{phi.png} \end{minipage} % The objective is smooth \citep[Lemma 7]{woodworth2018graph}, and the same arguments as in the proof of Theorem \ref{thm:LowerLip} hold except that now $\hat{w}$ spanned by $v_1,\ldots,v_{2K}$ has $F(\hat{w})\geq F(w_{\star}) + \frac{B^2}{256K}$ \citep[Lemma 8]{woodworth2018graph}. \end{proof} That is, the best we can ensure with block-cyclic sampling, even if the objective is smooth, is an excess error of: \begin{equation}\label{eq:lowerboundsmooth} \epsilon = \Omega\left( \frac{B^2}{K^2} \right) = \Omega\left( \sqrt\frac{B^2}{T} \sqrt\frac{B^2 mn}{K^3} \right), \end{equation} i.e., worse by a $\sqrt{\frac{B^2 mn}{K^3}}$ factor compared to i.i.d.~sampling. \section{A Pluralistic Approach}\label{sec:plur} The slowdown discussed in the previous section is due to the difficulty of finding a {\em consensus} solution $w$ that is good for all components $\mathcal{D}_i$. But thinking of the problem as a learning problem, this should be avoidable. Why should we insist on a single consensus predictor? In a learning setting, our goal is to be able to perform well on future samples $z\sim \mathcal{D}$. If the data arrives cyclically in blocks, we should be able to associate each sample $z$ with the mixture component $\mathcal{D}_i$ it was generated from. Formally, one can consider a joint distribution $(i,z)\sim\mathcal{\tilde{D}}$ over samples and components, where $i$ is uniform over $1..m$ and $z\,|\,i\sim\mathcal{D}_i$. In settings where the data follows a block-cyclic structure, it is reasonable to consider the component index $i$ as observed and leverage this at prediction (test) time. For example, in Federated Learning, this could be done by associating each client with the hours it is available for training. If it is available during multiple blocks, we can associate with it a distribution over $i$ reflecting its availability. Instead of learning a single consensus model for all components, we can therefore take a pluralistic approach and learn a separate model $w^i$ for each one of the components $i=1..m$ with the goal of minimizing: \begin{equation} \label{eq:plurGoal} \mathbf{F}(\mathbf{w})=\Ee{(i,z)\sim\mathcal{\tilde{D}}}{f(w^i,z)} = \frac{1}{m}\sum_{i=1}^m F_i(w^i) , \end{equation} where $\mathbf{w}=(w^1,\ldots,w^m)$ and $F_i(w^i)=\Ee{z\sim\mathcal{D}_i}{f(w^i,z)}$. How can this be done? A simplistic approach would be to learn a predictor $w^i$ for each component $D_i$ separately, based only on samples from block $i$. This could be done by maintaining $m$ separate SGD chains, and updating chain $i$ only using samples from block $i$: \begin{multline} w^{i}_{t(k,i,j+1)} \leftarrow w^{i}_{t(k,i,j)}-\eta_{t(k,i,j)} \nabla f(w^i_{t(k,i,j)},z_{t(k,i,j)}) \\* \textrm{where } w^{i}_{t(k+1,i,1)}=w^{i}_{t(k,i,n+1)} . \label{eq:separatew} \end{multline} We will therefore only have $Kn=T/m$ samples per model, but for each model, the samples are now i.i.d., and we can learn $\hat{w}^i$ such that: \begin{equation}\label{eq:eachFi} F_i(\hat{w}^i) \leq F_i(w_{\star}^i) + O\left(\sqrt\frac{B^2}{T/m}\right) \end{equation} where $w_{\star}^i = \arg\min_{\norm{w}\leq B} F_i(w)$, and so: \begin{align} \mathbf{F}(\hat{\mathbf{w}}) &= \frac{1}{m}\sum_{i=1}^m F_i(\hat{w}^i) \notag \\ &\leq \frac{1}{m}\sum_{i=1}^m F_i(w_{\star}^i) + \label{eq:sepFi} O\left(\sqrt\frac{B^2}{T/m}\right) \\ &\leq F(w_{\star}) + O\left(\sqrt\frac{B^2}{T/m}\right). \label{eq:sepFstar} \end{align} That is, ensuring excess error $\epsilon$ requires $T=O(m B^2/\epsilon^2)$ iterations, which represents a slow-down by a factor of $m$ relative to overall i.i.d.~sampling. The pluralistic approach can have other gains, owing to its multi-task nature, if the $m$ sub-problems $\min F_i(w)$ are very different from each other. An extreme case is when the different subproblems are in direct conflict, in a sense ``competing'' with each other, and the optimal $w_{\star}^i$ for the different sub-populations are not compatible with each other. For example, this could happen if a very informative feature has different effects in different subgroups. In this case we might have $F_i(w_{\star}^i) \ll F_i(w_{\star})$, and there is a strong benefit to the pluralistic approach regardless of the semi-cyclic sampling. The lower bounds of Section \ref{sec:lower} involve a subtly different conflicting situation, where there is a decent consensus predictor, but finding it requires, in a sense, ``negotiations'' between the different blocks, and this requires going back-and-forth between them many times, as is possible with i.i.d.~non-cyclic data, but not in a block-cyclic situation. Learning separate predictors would bypass this required conflict resolution. An intermediate situation is when the sub-problems are ``orthogonal'' to each other, e.g.~different features are used in different problems. In this case we have that $w_{\star}^i$ are orthogonal to each other, and we might have that $w_{\star} = \sum_i w_{\star}^i$ and $F_i(w_{\star}^i)=F_i(w_{\star})$. However, in this case, we would have that on average (over $i$), $\norm{w_{\star}^i}=\frac{\norm{w_{\star}}}{\sqrt{m}}$, and so with the pluralistic approach we can learn relative to a norm-bound $B'=B/\sqrt{m}$ that is $\sqrt{m}$ times smaller than would be required when using a single consensus model. This precisely negates the slow-down in terms of $m$ of the pluralistic learn-separate-predictors approach \eqref{eq:separatew}, and we recover the same performance as when learning a consensus predictor based on i.i.d.~non-cyclic data. The regime where we {\em would} see a significant slow-down is when the distributions $\mathcal{D}_i$ are fairly similar. By separating the problem into $m$ distinct problems, and not sharing information between components, we are effectively cutting the amount of data, and updates, by a factor of $m$, causing the slow-down. But if the distributions are indeed similar, then at least intuitively, the semi-cyclisity shouldn't be too much of a problem, and a simple single-SGD approach might be OK. At an extreme, if all components are identical ($\mathcal{D}_i=\mathcal{D}$), the block-cyclic sampling is actually i.i.d.~sampling and we do not have a problem in the first place. We see, then, that in extreme situations, semi-cyclicity is not a real problem: if the components are extremely ``competing'', we would be better off with separate predictors, while if they are identical we can just use a single SGD chain and lose nothing. But how do we know which situation we are in? Furthermore, what we actually expect is a combination of the above scenarios, with some aspects being in direct competition between the components, some being orthogonal while others being aligned and similar. Is there a simple approach that would always allow us to compete with training a single model based on i.i.d.~data? That is, a procedure for learning $\mathbf{w}=(w^1,\ldots,w^m)$ such that: \begin{equation} \label{eq:plur_goal} \mathbf{F}(\mathbf{w}) \leq F(w_{\star}) + O\left(\!\sqrt{\frac{B^2}{T}}\,\right). \end{equation} We would like to make a distinction between our objective here and that of multi-task learning. In multi-task learning \citep[and many others]{caruana1997multitask}, one considers several different but possibly related tasks (e.g.~the tasks specified by our component distributions $\mathcal{D}_i$) and the goal is to learn different ``specialized'' predictors for each task so as to {\em improve} over the consensus error $F(w_{\star})$ while leveraging the relatedness between them so as to reduce sample complexity. In order to do so, it is necessary to target a particular way in which tasks are related \citep{baxter2000model,ben2003exploiting}. For example, one can consider shared sparsity \citep[e.g.][]{turlach2005simultaneous}, shared linear features or low-rank structure \citep{ando2005framework}, shared deep features \citep[e.g.][]{caruana1997multitask}, shared kernel or low nuclear-norm structure \citep[e.g.][]{argyriou2008convex,amit2007uncovering}, low-norm additive structure \citep[e.g.][]{evgeniou2004regularized}, or graph-based relatedness \citep[e.g.][]{evgeniou2005learning,maurer2006bounds}. The success of multi-task learning then rests on whether the choosen relatedness assumptions hold, and the sample complexity depends on the specificity of this inductive bias. But we do {\em not} want to make any assumptions about relatedness. We would like a pluralistic method that {\em always} achieve the guarantee \eqref{eq:plur_goal}, without any additional or even low-order terms that depend on the relatedness. We hope we can achieve this since in \eqref{eq:plur_goal}, we are trying to compete with the {\em fixed} solution $F(w_{\star})$, and are resorting to pluralism only in order to overcome data heterogeneity, not in order to leverage it. \section{Pluralistic Averaging}\label{sec:pluravg} We give a surprisingly simple solution to the above problem. It {\em is} possible to compete with $F(w_{\star})$ in a semi-cyclic setting, without any additional performance deterioration (at least on average) and with no assumptions about the specific relatedness structure between different components. In fact, this can be done by running a single semi-cyclic SGD chain \eqref{eq:SGD}, which previously we discussed was problematic. The only modification is that instead of averaging all iterates to obtain a single final predictor (or using a single iterate), we create $m$ different pluralistic models by averaging, for each component $i$, only the iterates corresponding to that block: \begin{equation} \label{eq:wtilde} \tilde{w}^i = \frac{1}{Kn} \sum_{k=1}^K\sum_{j=1}^n w_{t(k,i,j)} . \end{equation} \begin{theorem}\label{thm:pluravg} Consider semi-cyclic samples as in \eqref{eq:seqkmn}. The pluralistic averaged solution $\tilde{\mathbf{w}}$ given in \eqref{eq:wtilde} in terms of the iterates of \eqref{eq:SGD} with step size $\eta_t=B/\sqrt{2T}$ and starting at $w_1=0$, satisfies \begin{equation} \label{eq:mainE} \EE{\mathbf{F}(\tilde{\mathbf{w}})} \leq F(w_{\star}) + O\left(\!\sqrt{\frac{B^2}{T}}\,\right), \end{equation} where the expectation is w.r.t.~the samples. \removed{In addition, for a bounded objective $0\leq f(w,z)\leq a$, and any $\delta>0$, with probability at least $1-\delta$ over the samples: \begin{equation} \label{eq:mainP} \mathbf{F}(\tilde{\mathbf{w}}) \leq F(w_{\star}) + O\left(\sqrt{\frac{B^2+a \log 1/\delta}{T}}\right). \end{equation}} \end{theorem} The main insight is that the SGD guarantee can be obtained through an online-to-batch conversion, and that the online guarantee itself does {\em not} require any distributional assumption and so is valid also for semi-cyclic data. Going from Online Gradient Descent to Stochastic Gradient Descent, the i.i.d.~sampling {\em is} vital for the online-to-batch conversion. But by averaging only over iterates corresponding to samples from the same component, we are in a sense doing an online-to-batch conversion for each component separately, and thus over i.i.d.~samples. \begin{proof} Viewing the updates \eqref{eq:SGD} as implementing online gradient descent \cite{zinkevich2003online}\footnote{The development in \citet{zinkevich2003online} is for updates that also involve a projection: $w_{t+1} \leftarrow \Pi_B(w_t - \eta_t \nabla f(w_t,z_t))$ where $\Pi_B(w)=w/\!\max(\norm{w}\!/B,1)$. See, e.g., \citet{shalev2012online}, for a development of SGD without the projection as in \eqref{eq:SGD}, and proof of the regret guarantee \eqref{eq:OGDreg} for these updates. Although we present the analysis without a projection, our entire development is also valid with a projection as in \citet{zinkevich2003online}, which results in all the same guarantees}, we have the following online regret guarantee for {\em any} sequence $z_t$ (and in particular any sequence obtained from any sort of sampling) and any $w$ with $\norm{w}\leq B$: \begin{equation}\label{eq:OGDreg} \sum_{t=1}^T f(w_t,z_t) \leq \sum_{t=1}^T f(w,z_t) + \sqrt{2B^2 T}. \end{equation} choosing $w=w_{\star}$ on the right hand side, dividing by $T$ and rearranging the summation we have: \begin{multline} \label{eq:OGDbyT} \frac{1}{m} \sum_{i=1}^m \frac{1}{Kn} \sum_{k,j} f(w_{t(k,i,j)},z_{t(k,i,j)})\\* \leq \frac{1}{m} \sum_{i=1}^m \frac{1}{Kn} \sum_{k,j} f(w_{\star},z_{t(k,i,j)}) + \sqrt{\frac{2B^2}{T}}. \end{multline} The above is valid for any sequence $z_t$. Taking $z_t$ to be random, regardless of their distribution, we can take expectations on both sides. For the semi-cyclic sampling \eqref{eq:seqkmn}, and since $w_t$ is independent of $z_t$ we have: \begin{multline}\label{eq:OGDbyTex} \EE{\frac{1}{m} \sum_{i=1}^m \frac{1}{Kn} \sum_{k,j} \Ee{z\sim\mathcal{D}_i}{f(w_{t(k,i,j)},z)}} \\* \leq \frac{1}{m} \sum_{i=1}^m \frac{1}{Kn} \sum_{k,j} \Ee{z\sim\mathcal{D}_i}{f(w_{\star},z)} + \sqrt{\frac{2B^2}{T}}, \end{multline} where the outer expectation on the left-hand-side is w.r.t.~$w_t$. On the right hand side we have that $\Ee{z\sim\mathcal{D}_i}{f(w_{\star},z)}=F_i(w_{\star})$. On the left hand side, we can use the convexity of $f$ and apply Jensen's inequality: \begin{multline} \label{eq:Jensen} \frac{1}{Kn} \sum_{k,j} \Ee{z\sim\mathcal{D}_i}{f(w_{t(k,i,j)},z)} \\ \geq \Ee{z\sim\mathcal{D}_i}{\,f\Big(\frac{1}{Kn} \sum_{k,j} w_{t(k,i,j)},z\Big)\!} = F_i(\tilde{w}_i) . \end{multline} Substituting \eqref{eq:Jensen} back into \eqref{eq:OGDbyTex} we have: \begin{equation} \label{eq:FiFiBound} \EE{\frac{1}{m}\sum_{i=1}^mF_i(\tilde{w}_i)} \leq \frac{1}{m}\sum_{i=1}^mF_i(w_{\star}) + \sqrt{\frac{2B^2}{T}}. \end{equation} recalling the definition \eqref{eq:plurGoal} of $\mathbf{F}(\tilde{\mathbf{w}})$ and that $F(w)=\frac{1}{m}\sum_i F_i(w)$, we obtain the expectation bound \eqref{eq:mainE}. \end{proof} An important, and perhaps surprising, feature of the guarantee of Theorem \ref{thm:pluravg} is that it does {\em not} depend on the number of blocks $m$, and does not deteriorate as $m$ increases. That is, in terms of learning, we could partition our cycle to as many blocks as we would like, ensuring homogeneity inside each block and without any accuracy cost. E.g.~we could learn a separate model for each hour, or minute, or second of the day. The cost here is only a memory and engineering cost of storing, distributing and handling the plenitude of models, not an accuracy nor direct computational cost. This is in sharp contrast to separate training for each component, as well as to most multi-task approaches. \section{Pluralistic Hedging} \label{sec:hedge} \newcommand{u}{u} \newcommand{\mathbf{u}}{\mathbf{u}} \newcommand{\nu}{\nu} The pluralistic averaging approach shows that we can always compete with the best single possible solution $w_{\star}$, even when faced with semi-cyclic data. But as discussed in Section \ref{sec:plur}, perhaps in some extreme cases learning separate predictors $w^i$, each based only on data from the $i$th component as in \eqref{eq:separatew}, might be better. That is, depending on the similarity and conflict between components, the guarantees \eqref{eq:eachFi} might be better than that of Theorem \ref{thm:pluravg}, at least for some of the predictors. But if we do not know in advance which regime we are at, nor for which components we are better off with a separately-learned model (because they are very different from the others) and which are better off leveraging also the other components, can we still ensure the $m$ individual guarantees \eqref{eq:eachFi} and the guarantee of Theorem \ref{thm:pluravg} simultaneously? Here we give a method for doing so, based on running both the single SGD chain \eqref{eq:SGD} and the separate SGD chains \eqref{eq:separatew} and carefully combining them using learned weights for each chain. Let $q>0$ be the weight for the full SGD chain $w_t$~\eqref{eq:SGD}, which will be kept fixed throughout, and let $q^i_t>0$ be the weights assigned to the block-specific SGD chains $w_t^i$~\eqref{eq:separatew} on step $t$. We learn the weights using a multiplicative update rule. At step $t=t(k,i,j)$, in which block $i$ is active, this update takes the form: \begin{align*} q^{i}_{t+1} &\gets q^{i}_t \cdot \big( 1+\nu\big(f(w_t,z_t)-f(w_t^{i},z_t)\big) \big) ; \\ \forall ~ i' \neq i , \qquad q^{i'}_{t+1} &\gets q^{i'}_t ~, \end{align*} where $\nu>0$ is a learning rate (separate from those of the SGD chains). Then, we let $ p_t = q_t^{i} \big/ (q_t^{i} + q) \in [0,1] $ and choose between the full and block-specific SGD chains by: \begin{align*} u_t \gets \begin{cases} w^{i}_t & \text{with probability $p_t$;}\\ w_t & \text{otherwise.} \end{cases} \end{align*} Finally, we obtain the final predictors via pluralistic averaging; namely, for each component $i$, we average only the iterate within the corresponding blocks: \begin{align} \label{eq:wtilde-hedge} \tilde{u}^i = \frac{1}{Kn} \sum_{k=1}^K \sum_{j=1}^n u_{t(k,i,j)} ~. \end{align} For the averaged solution $\tilde{\mathbf{u}} = (\tilde{u}^1,\ldots,\tilde{u}^m)$, we have the following. \begin{theorem} \label{thm:hedging} Set $\nu = \frac{1}{2B} \sqrt{(m/T)\log(BT/m)}$, $q = 1-\eta$, and initialize $q^i_1 = \eta$ for each $i$. Then, for all $i$ we have \begin{align*} \EE{F_i(\tilde{u}^i)} &\leq F_i(w_{\star}^i) + 4\sqrt{\frac{B^2 \log(BT/m)}{T/m}} , \intertext{and further, provided that $m \leq B^2Kn$,} \EE{\mathbf{F}(\tilde{\mathbf{u}})} &\leq F(w_{\star}) + 4\sqrt{\frac{B^2}{T}} . \end{align*} \end{theorem} The requirement that $m\leq B^2Kn$ is extremely mild, as we would generally expect a large number of iterations per block $n$, and only a mild number of blocks $m$, i.e.~$n\ll m$. The proofs in this section use the following notation. For all $i \in [m]$, let $S_i \subseteq [T]$ be the set of time steps where we got a sample from distribution $\mathcal{D}_i$ (so that $\abs{S_i} = T/m$). We first prove the following. \begin{lemma} \label{lem:regret} For each $i \in [m]$ we have \begin{align*} \EE{ \sum_{t \in S_i} f(u_t, z_t) - \sum_{t \in S_i} f(w_t, z_t) } &\leq 2 ~, \intertext{and} \EE{ \sum_{t \in S_i} f(u_t, z_t) - \sum_{t \in S_i} f(w^i_t, z_t) } &\leq 2B \sqrt{\frac{T}{m} \log\frac{BT}{m}} ~. \end{align*} Here, the expectation is taken w.r.t.~the $z_t$ as well as the internal randomization of the algorithm. \end{lemma} The proof (in \cref{sec:hedge-proofs}) is based on classic analysis of the {\sc Prod} algorithm (\citealp{Cesa-Bianchi2007}; see also~\citealp{Even-Dar2008,sani2014exploiting}). We can now prove the main theorem of this section. \begin{proof}[Proof of \cref{thm:hedging}] The proof follows from a combination of \cref{lem:regret} with regret bounds for the SGD chains \eqref{eq:SGD} and \eqref{eq:separatew}, viewed as trajectories of the Online Gradient Descent algorithm. Standard regret bounds for the latter (\citealp{zinkevich2003online}; see also \citealp{shalev2012online,hazan2016introduction}) imply that for any sequence $z_1,\ldots,z_T$ and for any $\norm{w_{\star}} \leq B$, it holds that \begin{align} \sum_{t=1}^T f(w_t, z_t) - \sum_{t=1}^T f(w_{\star}, z_t) &\leq 2B \sqrt{T} ~, \label{eq:ogd-all} \intertext{and, for each $i \in [m]$ and for any $w_{\star}^i$ such that $\norm{w_{\star}^i} \leq B$,} \sum_{t \in S_i} f(w^i_t, z_t) - \sum_{t=1}^T f(w_{\star}^i, z_t) &\leq 2B \sqrt{\frac{T}{m}} ~. \label{eq:ogd-separate} \end{align} Now, fix $i \in [m]$; \cref{lem:regret} together with \cref{eq:ogd-separate} imply \begin{align*} \frac{1}{T/m} \sum_{t \in S_i} \EE{ f(u_t, z_t) - f(w_{\star}^i, z_t) } &\leq 4\sqrt{\frac{B^2 \log(BT/m)}{T/m}} ~. \end{align*} Using the facts that $\Ee{t}{f(u_t,z_t)} = F_i(u_t)$ and $\Ee{t}{f(w_{\star}^i,z_t)} = F_i(w_{\star}^i)$ for any $t \in S_i$, we have \begin{align*} \frac{1}{T/m} \sum_{t \in S_i} \big( \EE{ F_i(u_t) } - F_i(w_{\star}^i) \big) \leq 4\sqrt{\frac{B^2 \log(BT/m)}{T/m}} ~. \end{align*} Appealing to the convexity of $F_i$ and applying Jensen's inequality on the left-hand side to lower bound $\frac{1}{T/m} \sum_{t \in S_i} F_i(u_t) \geq F_i(\tilde{u}^i)$, we obtain \begin{align*} \EE{ F_i(\tilde{u}^i) } - F_i(w_{\star}^i) \leq 4\sqrt{\frac{B^2 \log(BT/m)}{T/m}} ~, \end{align*} which implies the first guarantee of the theorem. For the second claim, the first bound of \cref{lem:regret} implies \begin{align*} \sum_{i=1}^m \EE{ \sum_{t \in S_i} f(u_t, z_t) } - \EE{ \sum_{t=1}^T f(w_t, z_t) } \leq 2m . \end{align*} Summing this with \cref{eq:ogd-all} and dividing through by $T$ gives \begin{align*} \frac{1}{m} \sum_{i=1}^m \frac{1}{T/m} \sum_{t \in S_i} \EE{ f(u_t, z_t) - f(w_{\star}, z_t) } \leq \frac{2m}{T} + 2\sqrt{\frac{B^2}{T}} . \end{align*} Next, as before, substitute the conditional expectations and use Jensen's to lower bound the left-hand side; this yields \begin{align*} \frac{1}{m} \sum_{i=1}^m \big( \EE{F_i(\tilde{u}^i)} - F_i(w_{\star}) \big) \leq \frac{2m}{T} + 2\sqrt{\frac{B^2}{T}} . \end{align*} Recalling now the definitions $\mathbf{F}(\tilde{\mathbf{u}}) = \frac{1}{m} \sum_{i=1}^m F_i(\tilde{u}^i)$ and $F(w_{\star}) = \frac{1}{m} \sum_{i=1}^m F_i(w_{\star})$, we have shown that \begin{align*} \EE{ \mathbf{F}(\tilde{\mathbf{u}}) } - F(w_{\star}) \leq \frac{2m}{T} + 2\sqrt{\frac{B^2}{T}} ~. \end{align*} Noting $m \leq B\sqrt{T} = B\sqrt{Kmn}$ implies $m \leq B^2Kn$ conludes the proof. \end{proof} \section{Experiments}\label{sec:experiments} To illustrate the challenges of optimizing on block-cyclic data, we train and evaluate a small logistic regression model on the Sentiment140 Twitter dataset \cite{go09}, a binary classification task over \num{1.6e6} examples. We split the data into training (90\%) and test (10\%) sets, partition it into $m=6$ components based on the timestamps (but not dates) of the Tweets: 12am - 4am, 4am - 8am, etc, then divide each component across $K=10$ cycles (days). For more details, see Appendix~\ref{sec:exp_details}. For simplicity, we keep the model architecture (linear bag of words classifier over top 1024 words) and minibatch size (128) fixed; we used a learning rate of $\eta = 0.464$ (determined through log-space grid search) except for the per-component SGD approach % \eqref{eq:separatew} where $\eta = 1.0$ was optimal due to fewer iterations. To illustrate the differences between the proposed methods, as well as to capture the diurnal variation expected in practical Federated Learning settings, we vary the label balance as a function of the time of day, ensuring the $\mathcal{D}_i$ are somewhat different. In particular, we randomly drop negative posts from the midnight group so the overall rate is 2/3 positive sentiment, we randomly drop positive posts from the noon group so the overall rate is 1/3 positive sentiment, and we linearly interpolate for the other 4 components. For discussion, and a figure giving positive and negative label counts over components, see Appendix~\ref{sec:exp_labels}. We write $\hat{F}_i$ for the empirical accuracy on component $i$ of the test set, with $\hat{F}$ measuring the overall test accuracy. We consider the following approaches: \vspace{-0.15in} \begin{enumerate} \itemsep -2pt \item A non-pluralistic \textbf{block-cyclic consensus} model, subject to the lower bounds of Section~\ref{sec:lower}. The accuracy of this procedure for day $k$ is given by the expected test-set accuracy of randomly picking $i \in \{1, \dots, m=6\}$, and evaluating $F(w_{t(k,i,n)})$, i.e. evaluating the model after completing a random block $i$ on each day $k$. \item The \textbf{per-component SGD} approach \eqref{eq:separatew}, where we run $m=6$ SGD chains, with each model training on only one block per day. For each day $k$, we evaluate $\frac{1}{m}\sum_i \hat{F}_i(w^i_{kn})$, where $w^i_{kn}$ is the model for component $i$ trained on the first $k$ blocks for component $i$. \item The \textbf{pluralistic single SGD chain} approach of Section~\ref{sec:pluravg}. The SGD chain is the same as for the consensus model, but evaluation is pluralistic as above: for each day $k$ we evaluate $\frac{1}{m}\sum_i \hat{F}_i(w_{t(k,i,n)})$, i.e.~for each test component we use the model at the end of the corresponding training block. \item An (impractical in real settings) \textbf{idealized i.i.d. model}, trained on the complete shuffled training set. For purposes of evaluation, we treat the data as if it had cyclic block structure and evaluate identically to the block-cyclic consensus model. \end{enumerate} See Appendix~\ref{sec:exp_eval} for more details on evaluation. Note that we do not use a model average, but rather take the most recent relevant iterate, matching how such models are typically deployed in practice. \begin{figure}[t] \centering \includegraphics[width=8cm]{experiment_results_cycles.pdf} \vspace{-0.4cm} \caption{Accuracy of a model trained on block-cyclic data tested on two blocks of data - posts from the midnight component (12am-4am), and posts from the noon component (12pm-4pm). Mean and standard deviations are computed from ten training repetitions.} \label{fig:experiment_results_cycles} \end{figure} Figure \ref{fig:experiment_results_cycles} illustrates how the block-cyclic structure of data can hurt accuracy of a consensus model. We plot how the accuracy on two test data components --- the midnight, and the noon component --- changes as a function of time of day when evaluated on the iterates of the SGD chain \eqref{eq:SGD}. Training is quick to leverage the label bias and gravitate towards a model too specific for the block being processed, instead of finding a better predictive solution based on other features that would help predictions across all groups. In Figure \ref{fig:experiment_results} we compare results from the four different training and test methods introduced above. First, pluralistic models with separate SGD chains take longer to converge because they are trained on less data. Depending on how long training proceeds, the size of the data set, and the number of components, these models may or may not surpass the idealized i.i.d. SGD and pluralistic single SGD chain models in accuracy. Second, the pluralistic models from a single SGD chain consistently perform better than a single consensus model from the same chain. Third, the performance of pluralistic models is en par with or better than the idealized i.i.d. SGD model, reflecting the fact that these models better match the target data distribution than a single model (i.i.d. or block cyclic consensus) can. \section{Summary} We considered training in the presence of block-cyclic data, showed that ignoring this source of data heterogeneity can be detrimental, but that a remarkably simple pluralistic approach can entirely resolve the problem and ensure, even in the worst case, the same guarantee as with homogeneous i.i.d.~data, and without any degradation based on the number of blocks. When the component distributions are actually different, pluralism can outperform the ``ideal'' i.i.d.~baseline, as our experiments illustrate. An important lesson we want to stress is that pluralism can be a critical tool for dealing with heterogeneous data, by embracing this heterogeneity instead of wastefully insisting on a consensus solution. Dealing with heterogeneous data, users or clients can be difficult in many machine learning settings, and especially in Federated Learning where learning happens on varied devices with different characteristics, each handling its own distinct data. Other heterogeneous aspects we can expect are variabilities in processing time and latency, amount of data per client, and client availability and reliability, which can all be correlated in different ways with different data components. All these pose significant challenges when training. We expect pluralistic solutions might be relevant in many of these situations. \begin{figure}[t] \centering \vspace{-0.25cm} \includegraphics[width=8cm]{experiment_results.pdf} \vspace{-0.4cm} \caption{Comparison of various training and testing methodologies for a simple model on a sentiment classification task, using i.i.d. and block-cyclic data. Means and standard deviations shown are computed from ten training repetitions.} \vspace{-0.5cm} \label{fig:experiment_results} \end{figure} In this paper we considered only optimizing {\em convex} objectives using sequential SGD. In many cases we are faced with non-convex objectives, as in when training deep neural networks. As with many other training techniques, we expect this study of convex semi-cyclic training to be indicative also of non-convex scenarios (except that a random predictor would need to be used instead of an averaged predictor in the online-to-batch conversion) and also serve as a basis for further analysis of the non-convex case. We are also interesting in analyzing the effect of block-cyclic data on methods beyond sequential SGD, and most prominently parallel SGD (aka Federated Averaging). Unfortunately, there is currently no satisfying and tight analysis of parallel SGD even for i.i.d.~data, making a detailed analysis of semi-cyclicity for this method beyond our current reach. Nevertheless, we again hope our analysis will be both indicative and serve as a basis for future exploration of parallel SGD and other distributed optimization approaches. \section*{Acknowledgements} NS was supported by NSF-BSF award 1718970 and a Google Faculty Research Award. \setlength{\bibsep}{0.75ex plus 0.3ex} \section{Introduction}\label{sec:intro} When using Stochastic Gradient Descent (SGD), it is important that samples are drawn at random. In contrast, cycling over a specific permutation of data points (e.g.~sorting data by label, or even alphabetically or by time of collection) can be detrimental to the performance of SGD. But in some applications, such as in Federated Learning \citep{FL3, FL4} or when running SGD in ``real time'', some cyclic patterns in the data samples are hard to avoid. In this paper we investigate how such cyclic structure hurts the effectiveness of SGD, and how this can be corrected. We model this semi-cyclicity through a ``block-cyclic'' structure, where during the course of training, we cycle over blocks in a fixed order and samples for each block are drawn from a block-specific distribution. Our primary motivation is Federated Learning. In this setting, mobile devices collaborate in the training of a shared model while keeping the training data decentralized. Devices communicate updates (e.g. gradients) to a coordinating server, which aggregates the updates and applies them to the global model. In each iteration (or round) of Federated SGD, typically a few hundred devices are chosen randomly by the server to participate; critically, however, only devices that are idle, charging, and on a free wireless connection are selected~\cite{FL_BLOG,bonawitz19sysml}. This ensures Federated Learning does not impact the user's experience when using their phone, but also can produce significant diurnal variation in the devices available, since devices are more likely to meet the training eligibility requirements at night local time. For example, for a language model \citep{gboard}, devices from English speakers in India and America are likely available at different times of day. When the number of blocks in each cycle is high and the number of samples per block is low, the setting approaches fully-cyclic SGD, which is known to be problematic. But what happens when the number of blocks is fairly small and each blocks consists of a large number of samples? E.g., if there are only two blocks corresponding to ``day'' and ``night'', with possibly millions of samples per block. % An optimist would hope that this ``slightly cyclic'' case is much easier than the fully cyclic case, and the performance of SGD degrades gracefully as the number of blocks increases. Unfortunately, in Section \ref{sec:lower} we show that even with only two blocks, the block-cyclic sampling can cause an arbitrarily bad slowdown. One might ask whether alternative forms of updates, instead of standard stochastic gradient updates, can alleviate this degradation in performance. We show that such a slowdown is unavoidable for any iterative method based on semi-cyclic samples. Instead, the solution we suggest is to embrace the heterogeneity in the data and resort to a {\em pluralistic} solution, allowing a potentially different model for each block in the cycle (e.g.~a ``daytime'' model and a ``nighttime'' model). A naive pluralistic approach would still suffer a significant slowdown as it would not integrate information between blocks (Section \ref{sec:plur}). In Section~\ref{sec:pluravg} we show a remarkably simple and practical pluralistic approach that allows us to obtain exactly the same guarantees as with i.i.d.~non-cyclic sampling, thus entirely alleviating the problem introduced by such data heterogeneity---as we also demonstrate empirically in Section \ref{sec:experiments}. In Section \ref{sec:hedge} we go even further and show how we can maintain the same guarantee without any deterioration while also being competitive with separately learned predictors, hedging our bets in case the differences between components are high. \section{Setup} We consider a stochastic convex optimization problem \begin{equation} \label{eq:F} F(w) = \Ee{z \sim \mathcal{D}}{f(w,z)} \quad\text{where}\quad \mathcal{D} = \frac{1}{m} \sum_{i=1}^m \mathcal{D}_i, \end{equation} where each component $\mathcal{D}_i$ represents the data distribution associated with one of $m$ blocks $i=1,\ldots,m$. For simplicity, we assume a uniform mixture; our results can be easily extended to non-uniform mixing weights and corresponding non-uniform block lengths. In a learning setting, $z=(x,y)$ represents a labeled example and the instantaneous objective $f(w,(x,y))=\textit{loss}(h_w(x),y)$ is the loss incurred if using the model $w$. % We assume $f(w,z)$ is convex and 1-Lipschitz with respect to $w$, which lives in some high-, possibly infinite-dimensional, Euclidean or Hilbert space. Our goal is to compete with the best possible predictor of some bounded norm $B$, that is to learn a predictor $\hat{w}$ such that $F(\hat{w})\leq F(w_{\star}) + \epsilon$ where % $F(w_{\star}) = \inf_{\norm{w}\leq B} F(w)$. We consider Stochastic Gradient Descent (SGD) iterates on the above objective: \begin{equation} \label{eq:SGD} w_{t+1} \leftarrow w_{t} - \eta_{t} \nabla f(w_t,z_t). \end{equation} If the samples $z_t$ are chosen independently from the data distribution $\mathcal{D}$, then with an appropriately chosen stepsizes $\eta_t$, SGD attains the mini-max optimal error guarantee \citep[e.g.][]{shalev2009stochastic}: \begin{equation} \label{eq:SGDbound} \EE{F(\overline{w})} \leq F(w_{\star}) + O\left(\sqrt\frac{B^2}{T}\right) \end{equation} where $\overline{w} = \frac{1}{T} \sum_{i=1}^T w_i$ and $T$ is the total number of iterations, and thus also the total number of samples used. But here we study {\em Block-Cyclic SGD}, which consists of $K$ {\em cycles} (e.g., days) of $mn$ iterations each, for a total of $T=Kmn$ iterations of the update \eqref{eq:SGD}. In each cycle, the first $n$ samples are drawn from $\mathcal{D}_1$, the second $n$ from $\mathcal{D}_2$ and so forth. That is, samples are drawn according to \begin{equation}\label{eq:seqkmn} z_{t(k,i,j)} \sim\mathcal{D}_i \quad\textrm{where } t(k,i,j)\!=(k\!-\!1)nm+(i\!-\!1)n+j \end{equation} where $k=1..K$ indexes the cycles, $i=1..m$ indexes blocks and $j=1..n$ indexes iterations within a block and thus $t(k,i,j)\in\{1,\ldots,T\}$ indexes the overall sequence of samples and corresponding updates. The samples are therefor no longer identically distributed and the standard SGD analysis no longer valid. We study the effect of such block-cyclic sampling on the SGD updates \eqref{eq:SGD}. One can think of $\mathcal{D}$ as the population distribution, with each step of SGD being based on a fresh sample; or of $\mathcal{D}$ as an empirical distribution over a finite training set that is partitioned to $m$ groups. It is important however not to confuse a {\em cycle} over the different components with an {\em epoch} over all samples---the notion of an {\em epoch} or the size of the support of $F$ (i.e.~the number of training points if $F(w)$ is viewed as an empirical objective) do not enter our analysis. Either view is consistent with our development, though our discussion will mostly refer to the population view of SGD based on fresh samples. \section{Lower Bounds for Block-Cyclic Sampling}\label{sec:lower} How badly can the block-cyclic sampling \eqref{eq:seqkmn} hurt the SGD updates \eqref{eq:SGD}? Unfortunately, we will see that the effect can be quite detrimental, especially when the number of samples $n$ in each block is very large compared to the overall number of cycles $K$, and even if the number of components $m$ is small. This is a typical regime in Federated Learning if we consider daily cycles, as we would hope training would take a small number of days, but the number of SGD iterations per block can be very high. For example, recent models for Gboard were trained for \num{1.2e6} sequential steps over 4-5 days ($K = 4$ or $5$, $nm = \num{3e5}$, and e.g. $m=6$ and $n=\num{5e4}$ if the day is divided into six 4-hour blocks) \cite{gboard}.\footnote{The cited work uses the Federated Averaging algorithm with communication every 400 sequential steps, as opposed to averaging gradients every step, so while not exactly matching our setting, it provides a rough estimate for realistic scenarios.} To see how even $K=2$ can be very bad, consider an extreme setting where the objective $f(w,z)$ depends only on the component of $z$, but is the same for all samples from each $\mathcal{D}_i$. Formally, let $z=\{1,2\}$ with $P(z=i)=1$. That is there are only two possible examples which we call ``1'', which is the only example in the support of the first component $\mathcal{D}_1$ and ``2'', which is the only example in the support of $\mathcal{D}_2$. The problem then reduces to a deterministic optimization problem of minimizing $F(w)=\frac{1}{2}f(w,1)+\frac{1}{2}f(w,2)$, but in each block we see gradients only of one of the two terms. With a large number of iterations per block $n$, we might be able to optimize each term separately very well. But we also know that in order to optimize such a composite objective to within $\epsilon$, even if we could optimize each component separately, requires alternating between the two components at least $\Omega(B/\epsilon)$ times \cite{woodworth2016tight}, establishing a lower bound on the number of required cycles, independent of the number of iterations per cycle. This extreme deterministic situation establishes the limits of what can be done with a limited number of cycles, and captures the essence of the difficulty with block-cyclic sampling. In fact, the lower bound we shall see applies not only to the precise SGD updates \eqref{eq:SGD} but to {\em any} method that uses block-cyclic samples as in \eqref{eq:seqkmn}, and at each iteration access $f(\cdot,z_t)$, i.e.~the objective on example $z_t$. More precisely, consider any method that at iteration $t$ chooses a ``query point'' $w_t$ and evaluates $f(w_t,z_t)$ and the gradient (or a sub-gradient) $\nabla f(w_t,z_t)$, where $w_t$ may be chosen in {\em any} way based on all previous function and gradient evaluations (the SGD iterates \eqref{eq:SGD} is just one examples of such a method). The output $\hat{w}$ of the algorithm can then be chosen as any function of the query points $w_t$, the evaluated function values and the gradients. \begin{theorem} \label{thm:LowerLip} Consider any (possibly randomized) optimization method of the form described in the previous paragraph, i.e.~where access to the objective is by evaluating $f(w_t,z_t)$ and $\nabla f(w_t,z_t)$ on semi-cyclic samples \eqref{eq:seqkmn} and where $w_t$ is chosen based on $\left\{(f(w_s,z_s),\nabla f(w_s,z_s)),s<t\right\}$ and the output $\hat{w}$ based on all iterates\footnote{This theorem, as well as Theorem \ref{thm:Lowersmooth}, holds even if the method is allowed ``prox queries''\removed{, that is to solve an optimization problem over $f(w,z_t)$} of the form $\arg\min_w f(w,z_t)+\lambda_t \norm{w-w_t}^2$.\removed{where $w_t$ and $\lambda_t$ are chosen by the method}}. For any $B,n,K$ and $m>1$ there exists a 1-Lipschitz convex problem over high enough dimension such that $\EE{F(\hat{w})}\geq F(w_{\star})+\Omega(B/K)$, where the expectation is over $z_t$ and any randomization in the method. \end{theorem} \begin{proof} Let $P(z=1|i<m/2)=1$ and $P(z=2|i\geq m/2)=1$, with the following functions taken from \citet{woodworth2018graph}, which in turn is based on the constructions in \citet{arjevani2015communication,woodworth2017lower,carmon2017lower,woodworth2017lower}: \begin{equation} \begin{aligned} f(w,1)&=\frac{\eta}{8}\Big(-2a \langle v_1,w \rangle + \phi(\langle v_{4K},w\rangle) \\ &\quad +\sum_{k=1}^{2K-1}\phi(\langle v_{2k}-v_{2k+1},w \rangle)\Big) \\ f(w,2)&=\frac{\eta}{8}\left(\sum_{k=1}^{2K}\phi(\langle v_{2k-1}-v_{2k},w \rangle)\right) \end{aligned} \end{equation} where $v_r$ are orthogonal vectors, $\eta=4BK,\gamma=2B/(\eta\sqrt{K}),a=1/\sqrt{64K^3}$, and for now consider $\phi(x)=2 \gamma \abs{x}$. The main observation is that each vector $v_{2k+i}$ is only revealed after $w$ includes a component in direction $v_{2k+i-1}$ (more formally: it is not revealed if $w\in\spn\{v_1,\ldots,v_{2k+i-2}\}$), and only when $f(w,i)$ is queried \citep[Lemma 9]{woodworth2018graph}. That is, each cycle will reveal at most two vectors, $v_{2k+1}$ for queries on the first half of the blocks, and $v_{2k+2}$ for queries on the second half. After $K$ cycles, the method would only encounter vectors in the span of the first $2K$ vectors $v_1,\ldots,v_{2K}$. But for $\hat{w}\in\spn\{v_1,\ldots,v_{2K}\}$, we have $F(\hat{w})\geq F(w_{\star}) + \frac{B}{96K}$ \citep[Lemma 8]{woodworth2018graph}. These arguments apply if the method does not leave the span of gradients returned so far. Intuitively, in high enough dimensions, it is futile to investigate new directions aimlessly. More formally, to ensure that trying out new directions over $T=Kmn$ queries wouldn't help, following appendix C of \citep{woodworth2018graph}, we can choose $v_r$ randomly in $R^{\tilde{O}(K^5n^2m^2)}$ and use a piecewise quadratic $\phi(x)$ that is 0 for $\abs{z}\leq a/2$ and is equal to $\phi(x)=2\gamma \abs{x}-\gamma^2 - a^2/2$ for $\abs{x}\geq\gamma$. \end{proof} Theorem \ref{thm:LowerLip} establishes that once we have a block-cyclic structure with multiple blocks per cycle, we cannot ensure excess error better then: \begin{equation} \label{eq:lower1} F(\hat{w})-F(w_{\star})=\Omega\left(\frac{B}{K}\right)=\Omega\left(\sqrt\frac{B^2}{T}\sqrt{\frac{mn}{K}}\right). \end{equation} Compared to using i.i.d.~sampling as in Eq.~\eqref{eq:SGDbound}, this is worse by a factor of $\sqrt{mn/K}$, which is very large when the number of samples per block $n$ is much larger then the number of cycles $K$, as we would expect in many applications. \removed{Said differently, reaching excess error $\epsilon$ might take $K = B/\epsilon = \sqrt{nm K_{\textrm{iid}}}$ cycles, where $K_{\textrm{iid}}$ is the number of cycles required with i.i.d.~sampling and $nm$ iterations per cycle.} For smooth objectives (i.e., with Lipschitz gradients) the situation is quantitatively a bit better, but we again can be arbitrarily worse then i.i.d.~sampling as the number $n$ of iterations per block increases: \begin{theorem}\label{thm:Lowersmooth} Under the same setup as in Theorem \ref{thm:LowerLip}, for any $B,n,K$ and $m>1$ there exists a 1-Lipschitz convex problem where the gradient $\nabla_w f(w,z)$ is also 1-Lipschitz, such that $\EE{F(\hat{w})}\geq F(w_{\star})+\Omega(B^2/K^2)$. \end{theorem} \begin{proof} Use the same construction as in Theorem \ref{thm:LowerLip}, but with $\eta=B^2$ and \begin{minipage}[c]{0.35\textwidth} \vspace{-5mm} $$ \phi(z) = \begin{cases} 0 & \abs{z} \leq a/2 \\ 2(\abs{z} - a/2)^2 & a/2 < \abs{z} \leq a \\ z^2 - a^2/2 & a < \abs{z} \leq \gamma \\ 2\gamma\!\abs{z} -\! \gamma^2\! - a^2/2 & \abs{z} > \gamma \end{cases} $$ \end{minipage} \begin{minipage}[c]{0.12\textwidth} \includegraphics[height=20mm,width=24mm]{phi.png} \end{minipage} % The objective is smooth \citep[Lemma 7]{woodworth2018graph}, and the same arguments as in the proof of Theorem \ref{thm:LowerLip} hold except that now $\hat{w}$ spanned by $v_1,\ldots,v_{2K}$ has $F(\hat{w})\geq F(w_{\star}) + \frac{B^2}{256K}$ \citep[Lemma 8]{woodworth2018graph}. \end{proof} That is, the best we can ensure with block-cyclic sampling, even if the objective is smooth, is an excess error of: \begin{equation}\label{eq:lowerboundsmooth} \epsilon = \Omega\left( \frac{B^2}{K^2} \right) = \Omega\left( \sqrt\frac{B^2}{T} \sqrt\frac{B^2 mn}{K^3} \right), \end{equation} i.e., worse by a $\sqrt{\frac{B^2 mn}{K^3}}$ factor compared to i.i.d.~sampling. \section{A Pluralistic Approach}\label{sec:plur} The slowdown discussed in the previous section is due to the difficulty of finding a {\em consensus} solution $w$ that is good for all components $\mathcal{D}_i$. But thinking of the problem as a learning problem, this should be avoidable. Why should we insist on a single consensus predictor? In a learning setting, our goal is to be able to perform well on future samples $z\sim \mathcal{D}$. If the data arrives cyclically in blocks, we should be able to associate each sample $z$ with the mixture component $\mathcal{D}_i$ it was generated from. Formally, one can consider a joint distribution $(i,z)\sim\mathcal{\tilde{D}}$ over samples and components, where $i$ is uniform over $1..m$ and $z\,|\,i\sim\mathcal{D}_i$. In settings where the data follows a block-cyclic structure, it is reasonable to consider the component index $i$ as observed and leverage this at prediction (test) time. For example, in Federated Learning, this could be done by associating each client with the hours it is available for training. If it is available during multiple blocks, we can associate with it a distribution over $i$ reflecting its availability. Instead of learning a single consensus model for all components, we can therefore take a pluralistic approach and learn a separate model $w^i$ for each one of the components $i=1..m$ with the goal of minimizing: \begin{equation} \label{eq:plurGoal} \mathbf{F}(\mathbf{w})=\Ee{(i,z)\sim\mathcal{\tilde{D}}}{f(w^i,z)} = \frac{1}{m}\sum_{i=1}^m F_i(w^i) , \end{equation} where $\mathbf{w}=(w^1,\ldots,w^m)$ and $F_i(w^i)=\Ee{z\sim\mathcal{D}_i}{f(w^i,z)}$. How can this be done? A simplistic approach would be to learn a predictor $w^i$ for each component $D_i$ separately, based only on samples from block $i$. This could be done by maintaining $m$ separate SGD chains, and updating chain $i$ only using samples from block $i$: \begin{multline} w^{i}_{t(k,i,j+1)} \leftarrow w^{i}_{t(k,i,j)}-\eta_{t(k,i,j)} \nabla f(w^i_{t(k,i,j)},z_{t(k,i,j)}) \\* \textrm{where } w^{i}_{t(k+1,i,1)}=w^{i}_{t(k,i,n+1)} . \label{eq:separatew} \end{multline} We will therefore only have $Kn=T/m$ samples per model, but for each model, the samples are now i.i.d., and we can learn $\hat{w}^i$ such that: \begin{equation}\label{eq:eachFi} F_i(\hat{w}^i) \leq F_i(w_{\star}^i) + O\left(\sqrt\frac{B^2}{T/m}\right) \end{equation} where $w_{\star}^i = \arg\min_{\norm{w}\leq B} F_i(w)$, and so: \begin{align} \mathbf{F}(\hat{\mathbf{w}}) &= \frac{1}{m}\sum_{i=1}^m F_i(\hat{w}^i) \notag \\ &\leq \frac{1}{m}\sum_{i=1}^m F_i(w_{\star}^i) + \label{eq:sepFi} O\left(\sqrt\frac{B^2}{T/m}\right) \\ &\leq F(w_{\star}) + O\left(\sqrt\frac{B^2}{T/m}\right). \label{eq:sepFstar} \end{align} That is, ensuring excess error $\epsilon$ requires $T=O(m B^2/\epsilon^2)$ iterations, which represents a slow-down by a factor of $m$ relative to overall i.i.d.~sampling. The pluralistic approach can have other gains, owing to its multi-task nature, if the $m$ sub-problems $\min F_i(w)$ are very different from each other. An extreme case is when the different subproblems are in direct conflict, in a sense ``competing'' with each other, and the optimal $w_{\star}^i$ for the different sub-populations are not compatible with each other. For example, this could happen if a very informative feature has different effects in different subgroups. In this case we might have $F_i(w_{\star}^i) \ll F_i(w_{\star})$, and there is a strong benefit to the pluralistic approach regardless of the semi-cyclic sampling. The lower bounds of Section \ref{sec:lower} involve a subtly different conflicting situation, where there is a decent consensus predictor, but finding it requires, in a sense, ``negotiations'' between the different blocks, and this requires going back-and-forth between them many times, as is possible with i.i.d.~non-cyclic data, but not in a block-cyclic situation. Learning separate predictors would bypass this required conflict resolution. An intermediate situation is when the sub-problems are ``orthogonal'' to each other, e.g.~different features are used in different problems. In this case we have that $w_{\star}^i$ are orthogonal to each other, and we might have that $w_{\star} = \sum_i w_{\star}^i$ and $F_i(w_{\star}^i)=F_i(w_{\star})$. However, in this case, we would have that on average (over $i$), $\norm{w_{\star}^i}=\frac{\norm{w_{\star}}}{\sqrt{m}}$, and so with the pluralistic approach we can learn relative to a norm-bound $B'=B/\sqrt{m}$ that is $\sqrt{m}$ times smaller than would be required when using a single consensus model. This precisely negates the slow-down in terms of $m$ of the pluralistic learn-separate-predictors approach \eqref{eq:separatew}, and we recover the same performance as when learning a consensus predictor based on i.i.d.~non-cyclic data. The regime where we {\em would} see a significant slow-down is when the distributions $\mathcal{D}_i$ are fairly similar. By separating the problem into $m$ distinct problems, and not sharing information between components, we are effectively cutting the amount of data, and updates, by a factor of $m$, causing the slow-down. But if the distributions are indeed similar, then at least intuitively, the semi-cyclisity shouldn't be too much of a problem, and a simple single-SGD approach might be OK. At an extreme, if all components are identical ($\mathcal{D}_i=\mathcal{D}$), the block-cyclic sampling is actually i.i.d.~sampling and we do not have a problem in the first place. We see, then, that in extreme situations, semi-cyclicity is not a real problem: if the components are extremely ``competing'', we would be better off with separate predictors, while if they are identical we can just use a single SGD chain and lose nothing. But how do we know which situation we are in? Furthermore, what we actually expect is a combination of the above scenarios, with some aspects being in direct competition between the components, some being orthogonal while others being aligned and similar. Is there a simple approach that would always allow us to compete with training a single model based on i.i.d.~data? That is, a procedure for learning $\mathbf{w}=(w^1,\ldots,w^m)$ such that: \begin{equation} \label{eq:plur_goal} \mathbf{F}(\mathbf{w}) \leq F(w_{\star}) + O\left(\!\sqrt{\frac{B^2}{T}}\,\right). \end{equation} We would like to make a distinction between our objective here and that of multi-task learning. In multi-task learning \citep[and many others]{caruana1997multitask}, one considers several different but possibly related tasks (e.g.~the tasks specified by our component distributions $\mathcal{D}_i$) and the goal is to learn different ``specialized'' predictors for each task so as to {\em improve} over the consensus error $F(w_{\star})$ while leveraging the relatedness between them so as to reduce sample complexity. In order to do so, it is necessary to target a particular way in which tasks are related \citep{baxter2000model,ben2003exploiting}. For example, one can consider shared sparsity \citep[e.g.][]{turlach2005simultaneous}, shared linear features or low-rank structure \citep{ando2005framework}, shared deep features \citep[e.g.][]{caruana1997multitask}, shared kernel or low nuclear-norm structure \citep[e.g.][]{argyriou2008convex,amit2007uncovering}, low-norm additive structure \citep[e.g.][]{evgeniou2004regularized}, or graph-based relatedness \citep[e.g.][]{evgeniou2005learning,maurer2006bounds}. The success of multi-task learning then rests on whether the choosen relatedness assumptions hold, and the sample complexity depends on the specificity of this inductive bias. But we do {\em not} want to make any assumptions about relatedness. We would like a pluralistic method that {\em always} achieve the guarantee \eqref{eq:plur_goal}, without any additional or even low-order terms that depend on the relatedness. We hope we can achieve this since in \eqref{eq:plur_goal}, we are trying to compete with the {\em fixed} solution $F(w_{\star})$, and are resorting to pluralism only in order to overcome data heterogeneity, not in order to leverage it. \section{Pluralistic Averaging}\label{sec:pluravg} We give a surprisingly simple solution to the above problem. It {\em is} possible to compete with $F(w_{\star})$ in a semi-cyclic setting, without any additional performance deterioration (at least on average) and with no assumptions about the specific relatedness structure between different components. In fact, this can be done by running a single semi-cyclic SGD chain \eqref{eq:SGD}, which previously we discussed was problematic. The only modification is that instead of averaging all iterates to obtain a single final predictor (or using a single iterate), we create $m$ different pluralistic models by averaging, for each component $i$, only the iterates corresponding to that block: \begin{equation} \label{eq:wtilde} \tilde{w}^i = \frac{1}{Kn} \sum_{k=1}^K\sum_{j=1}^n w_{t(k,i,j)} . \end{equation} \begin{theorem}\label{thm:pluravg} Consider semi-cyclic samples as in \eqref{eq:seqkmn}. The pluralistic averaged solution $\tilde{\mathbf{w}}$ given in \eqref{eq:wtilde} in terms of the iterates of \eqref{eq:SGD} with step size $\eta_t=B/\sqrt{2T}$ and starting at $w_1=0$, satisfies \begin{equation} \label{eq:mainE} \EE{\mathbf{F}(\tilde{\mathbf{w}})} \leq F(w_{\star}) + O\left(\!\sqrt{\frac{B^2}{T}}\,\right), \end{equation} where the expectation is w.r.t.~the samples. \removed{In addition, for a bounded objective $0\leq f(w,z)\leq a$, and any $\delta>0$, with probability at least $1-\delta$ over the samples: \begin{equation} \label{eq:mainP} \mathbf{F}(\tilde{\mathbf{w}}) \leq F(w_{\star}) + O\left(\sqrt{\frac{B^2+a \log 1/\delta}{T}}\right). \end{equation}} \end{theorem} The main insight is that the SGD guarantee can be obtained through an online-to-batch conversion, and that the online guarantee itself does {\em not} require any distributional assumption and so is valid also for semi-cyclic data. Going from Online Gradient Descent to Stochastic Gradient Descent, the i.i.d.~sampling {\em is} vital for the online-to-batch conversion. But by averaging only over iterates corresponding to samples from the same component, we are in a sense doing an online-to-batch conversion for each component separately, and thus over i.i.d.~samples. \begin{proof} Viewing the updates \eqref{eq:SGD} as implementing online gradient descent \cite{zinkevich2003online}\footnote{The development in \citet{zinkevich2003online} is for updates that also involve a projection: $w_{t+1} \leftarrow \Pi_B(w_t - \eta_t \nabla f(w_t,z_t))$ where $\Pi_B(w)=w/\!\max(\norm{w}\!/B,1)$. See, e.g., \citet{shalev2012online}, for a development of SGD without the projection as in \eqref{eq:SGD}, and proof of the regret guarantee \eqref{eq:OGDreg} for these updates. Although we present the analysis without a projection, our entire development is also valid with a projection as in \citet{zinkevich2003online}, which results in all the same guarantees}, we have the following online regret guarantee for {\em any} sequence $z_t$ (and in particular any sequence obtained from any sort of sampling) and any $w$ with $\norm{w}\leq B$: \begin{equation}\label{eq:OGDreg} \sum_{t=1}^T f(w_t,z_t) \leq \sum_{t=1}^T f(w,z_t) + \sqrt{2B^2 T}. \end{equation} choosing $w=w_{\star}$ on the right hand side, dividing by $T$ and rearranging the summation we have: \begin{multline} \label{eq:OGDbyT} \frac{1}{m} \sum_{i=1}^m \frac{1}{Kn} \sum_{k,j} f(w_{t(k,i,j)},z_{t(k,i,j)})\\* \leq \frac{1}{m} \sum_{i=1}^m \frac{1}{Kn} \sum_{k,j} f(w_{\star},z_{t(k,i,j)}) + \sqrt{\frac{2B^2}{T}}. \end{multline} The above is valid for any sequence $z_t$. Taking $z_t$ to be random, regardless of their distribution, we can take expectations on both sides. For the semi-cyclic sampling \eqref{eq:seqkmn}, and since $w_t$ is independent of $z_t$ we have: \begin{multline}\label{eq:OGDbyTex} \EE{\frac{1}{m} \sum_{i=1}^m \frac{1}{Kn} \sum_{k,j} \Ee{z\sim\mathcal{D}_i}{f(w_{t(k,i,j)},z)}} \\* \leq \frac{1}{m} \sum_{i=1}^m \frac{1}{Kn} \sum_{k,j} \Ee{z\sim\mathcal{D}_i}{f(w_{\star},z)} + \sqrt{\frac{2B^2}{T}}, \end{multline} where the outer expectation on the left-hand-side is w.r.t.~$w_t$. On the right hand side we have that $\Ee{z\sim\mathcal{D}_i}{f(w_{\star},z)}=F_i(w_{\star})$. On the left hand side, we can use the convexity of $f$ and apply Jensen's inequality: \begin{multline} \label{eq:Jensen} \frac{1}{Kn} \sum_{k,j} \Ee{z\sim\mathcal{D}_i}{f(w_{t(k,i,j)},z)} \\ \geq \Ee{z\sim\mathcal{D}_i}{\,f\Big(\frac{1}{Kn} \sum_{k,j} w_{t(k,i,j)},z\Big)\!} = F_i(\tilde{w}_i) . \end{multline} Substituting \eqref{eq:Jensen} back into \eqref{eq:OGDbyTex} we have: \begin{equation} \label{eq:FiFiBound} \EE{\frac{1}{m}\sum_{i=1}^mF_i(\tilde{w}_i)} \leq \frac{1}{m}\sum_{i=1}^mF_i(w_{\star}) + \sqrt{\frac{2B^2}{T}}. \end{equation} recalling the definition \eqref{eq:plurGoal} of $\mathbf{F}(\tilde{\mathbf{w}})$ and that $F(w)=\frac{1}{m}\sum_i F_i(w)$, we obtain the expectation bound \eqref{eq:mainE}. \end{proof} An important, and perhaps surprising, feature of the guarantee of Theorem \ref{thm:pluravg} is that it does {\em not} depend on the number of blocks $m$, and does not deteriorate as $m$ increases. That is, in terms of learning, we could partition our cycle to as many blocks as we would like, ensuring homogeneity inside each block and without any accuracy cost. E.g.~we could learn a separate model for each hour, or minute, or second of the day. The cost here is only a memory and engineering cost of storing, distributing and handling the plenitude of models, not an accuracy nor direct computational cost. This is in sharp contrast to separate training for each component, as well as to most multi-task approaches. \section{Pluralistic Hedging} \label{sec:hedge} \newcommand{u}{u} \newcommand{\mathbf{u}}{\mathbf{u}} \newcommand{\nu}{\nu} The pluralistic averaging approach shows that we can always compete with the best single possible solution $w_{\star}$, even when faced with semi-cyclic data. But as discussed in Section \ref{sec:plur}, perhaps in some extreme cases learning separate predictors $w^i$, each based only on data from the $i$th component as in \eqref{eq:separatew}, might be better. That is, depending on the similarity and conflict between components, the guarantees \eqref{eq:eachFi} might be better than that of Theorem \ref{thm:pluravg}, at least for some of the predictors. But if we do not know in advance which regime we are at, nor for which components we are better off with a separately-learned model (because they are very different from the others) and which are better off leveraging also the other components, can we still ensure the $m$ individual guarantees \eqref{eq:eachFi} and the guarantee of Theorem \ref{thm:pluravg} simultaneously? Here we give a method for doing so, based on running both the single SGD chain \eqref{eq:SGD} and the separate SGD chains \eqref{eq:separatew} and carefully combining them using learned weights for each chain. Let $q>0$ be the weight for the full SGD chain $w_t$~\eqref{eq:SGD}, which will be kept fixed throughout, and let $q^i_t>0$ be the weights assigned to the block-specific SGD chains $w_t^i$~\eqref{eq:separatew} on step $t$. We learn the weights using a multiplicative update rule. At step $t=t(k,i,j)$, in which block $i$ is active, this update takes the form: \begin{align*} q^{i}_{t+1} &\gets q^{i}_t \cdot \big( 1+\nu\big(f(w_t,z_t)-f(w_t^{i},z_t)\big) \big) ; \\ \forall ~ i' \neq i , \qquad q^{i'}_{t+1} &\gets q^{i'}_t ~, \end{align*} where $\nu>0$ is a learning rate (separate from those of the SGD chains). Then, we let $ p_t = q_t^{i} \big/ (q_t^{i} + q) \in [0,1] $ and choose between the full and block-specific SGD chains by: \begin{align*} u_t \gets \begin{cases} w^{i}_t & \text{with probability $p_t$;}\\ w_t & \text{otherwise.} \end{cases} \end{align*} Finally, we obtain the final predictors via pluralistic averaging; namely, for each component $i$, we average only the iterate within the corresponding blocks: \begin{align} \label{eq:wtilde-hedge} \tilde{u}^i = \frac{1}{Kn} \sum_{k=1}^K \sum_{j=1}^n u_{t(k,i,j)} ~. \end{align} For the averaged solution $\tilde{\mathbf{u}} = (\tilde{u}^1,\ldots,\tilde{u}^m)$, we have the following. \begin{theorem} \label{thm:hedging} Set $\nu = \frac{1}{2B} \sqrt{(m/T)\log(BT/m)}$, $q = 1-\eta$, and initialize $q^i_1 = \eta$ for each $i$. Then, for all $i$ we have \begin{align*} \EE{F_i(\tilde{u}^i)} &\leq F_i(w_{\star}^i) + 4\sqrt{\frac{B^2 \log(BT/m)}{T/m}} , \intertext{and further, provided that $m \leq B^2Kn$,} \EE{\mathbf{F}(\tilde{\mathbf{u}})} &\leq F(w_{\star}) + 4\sqrt{\frac{B^2}{T}} . \end{align*} \end{theorem} The requirement that $m\leq B^2Kn$ is extremely mild, as we would generally expect a large number of iterations per block $n$, and only a mild number of blocks $m$, i.e.~$n\ll m$. The proofs in this section use the following notation. For all $i \in [m]$, let $S_i \subseteq [T]$ be the set of time steps where we got a sample from distribution $\mathcal{D}_i$ (so that $\abs{S_i} = T/m$). We first prove the following. \begin{lemma} \label{lem:regret} For each $i \in [m]$ we have \begin{align*} \EE{ \sum_{t \in S_i} f(u_t, z_t) - \sum_{t \in S_i} f(w_t, z_t) } &\leq 2 ~, \intertext{and} \EE{ \sum_{t \in S_i} f(u_t, z_t) - \sum_{t \in S_i} f(w^i_t, z_t) } &\leq 2B \sqrt{\frac{T}{m} \log\frac{BT}{m}} ~. \end{align*} Here, the expectation is taken w.r.t.~the $z_t$ as well as the internal randomization of the algorithm. \end{lemma} The proof (in \cref{sec:hedge-proofs}) is based on classic analysis of the {\sc Prod} algorithm (\citealp{Cesa-Bianchi2007}; see also~\citealp{Even-Dar2008,sani2014exploiting}). We can now prove the main theorem of this section. \begin{proof}[Proof of \cref{thm:hedging}] The proof follows from a combination of \cref{lem:regret} with regret bounds for the SGD chains \eqref{eq:SGD} and \eqref{eq:separatew}, viewed as trajectories of the Online Gradient Descent algorithm. Standard regret bounds for the latter (\citealp{zinkevich2003online}; see also \citealp{shalev2012online,hazan2016introduction}) imply that for any sequence $z_1,\ldots,z_T$ and for any $\norm{w_{\star}} \leq B$, it holds that \begin{align} \sum_{t=1}^T f(w_t, z_t) - \sum_{t=1}^T f(w_{\star}, z_t) &\leq 2B \sqrt{T} ~, \label{eq:ogd-all} \intertext{and, for each $i \in [m]$ and for any $w_{\star}^i$ such that $\norm{w_{\star}^i} \leq B$,} \sum_{t \in S_i} f(w^i_t, z_t) - \sum_{t=1}^T f(w_{\star}^i, z_t) &\leq 2B \sqrt{\frac{T}{m}} ~. \label{eq:ogd-separate} \end{align} Now, fix $i \in [m]$; \cref{lem:regret} together with \cref{eq:ogd-separate} imply \begin{align*} \frac{1}{T/m} \sum_{t \in S_i} \EE{ f(u_t, z_t) - f(w_{\star}^i, z_t) } &\leq 4\sqrt{\frac{B^2 \log(BT/m)}{T/m}} ~. \end{align*} Using the facts that $\Ee{t}{f(u_t,z_t)} = F_i(u_t)$ and $\Ee{t}{f(w_{\star}^i,z_t)} = F_i(w_{\star}^i)$ for any $t \in S_i$, we have \begin{align*} \frac{1}{T/m} \sum_{t \in S_i} \big( \EE{ F_i(u_t) } - F_i(w_{\star}^i) \big) \leq 4\sqrt{\frac{B^2 \log(BT/m)}{T/m}} ~. \end{align*} Appealing to the convexity of $F_i$ and applying Jensen's inequality on the left-hand side to lower bound $\frac{1}{T/m} \sum_{t \in S_i} F_i(u_t) \geq F_i(\tilde{u}^i)$, we obtain \begin{align*} \EE{ F_i(\tilde{u}^i) } - F_i(w_{\star}^i) \leq 4\sqrt{\frac{B^2 \log(BT/m)}{T/m}} ~, \end{align*} which implies the first guarantee of the theorem. For the second claim, the first bound of \cref{lem:regret} implies \begin{align*} \sum_{i=1}^m \EE{ \sum_{t \in S_i} f(u_t, z_t) } - \EE{ \sum_{t=1}^T f(w_t, z_t) } \leq 2m . \end{align*} Summing this with \cref{eq:ogd-all} and dividing through by $T$ gives \begin{align*} \frac{1}{m} \sum_{i=1}^m \frac{1}{T/m} \sum_{t \in S_i} \EE{ f(u_t, z_t) - f(w_{\star}, z_t) } \leq \frac{2m}{T} + 2\sqrt{\frac{B^2}{T}} . \end{align*} Next, as before, substitute the conditional expectations and use Jensen's to lower bound the left-hand side; this yields \begin{align*} \frac{1}{m} \sum_{i=1}^m \big( \EE{F_i(\tilde{u}^i)} - F_i(w_{\star}) \big) \leq \frac{2m}{T} + 2\sqrt{\frac{B^2}{T}} . \end{align*} Recalling now the definitions $\mathbf{F}(\tilde{\mathbf{u}}) = \frac{1}{m} \sum_{i=1}^m F_i(\tilde{u}^i)$ and $F(w_{\star}) = \frac{1}{m} \sum_{i=1}^m F_i(w_{\star})$, we have shown that \begin{align*} \EE{ \mathbf{F}(\tilde{\mathbf{u}}) } - F(w_{\star}) \leq \frac{2m}{T} + 2\sqrt{\frac{B^2}{T}} ~. \end{align*} Noting $m \leq B\sqrt{T} = B\sqrt{Kmn}$ implies $m \leq B^2Kn$ conludes the proof. \end{proof} \section{Experiments}\label{sec:experiments} To illustrate the challenges of optimizing on block-cyclic data, we train and evaluate a small logistic regression model on the Sentiment140 Twitter dataset \cite{go09}, a binary classification task over \num{1.6e6} examples. We split the data into training (90\%) and test (10\%) sets, partition it into $m=6$ components based on the timestamps (but not dates) of the Tweets: 12am - 4am, 4am - 8am, etc, then divide each component across $K=10$ cycles (days). For more details, see Appendix~\ref{sec:exp_details}. For simplicity, we keep the model architecture (linear bag of words classifier over top 1024 words) and minibatch size (128) fixed; we used a learning rate of $\eta = 0.464$ (determined through log-space grid search) except for the per-component SGD approach % \eqref{eq:separatew} where $\eta = 1.0$ was optimal due to fewer iterations. To illustrate the differences between the proposed methods, as well as to capture the diurnal variation expected in practical Federated Learning settings, we vary the label balance as a function of the time of day, ensuring the $\mathcal{D}_i$ are somewhat different. In particular, we randomly drop negative posts from the midnight group so the overall rate is 2/3 positive sentiment, we randomly drop positive posts from the noon group so the overall rate is 1/3 positive sentiment, and we linearly interpolate for the other 4 components. For discussion, and a figure giving positive and negative label counts over components, see Appendix~\ref{sec:exp_labels}. We write $\hat{F}_i$ for the empirical accuracy on component $i$ of the test set, with $\hat{F}$ measuring the overall test accuracy. We consider the following approaches: \vspace{-0.15in} \begin{enumerate} \itemsep -2pt \item A non-pluralistic \textbf{block-cyclic consensus} model, subject to the lower bounds of Section~\ref{sec:lower}. The accuracy of this procedure for day $k$ is given by the expected test-set accuracy of randomly picking $i \in \{1, \dots, m=6\}$, and evaluating $F(w_{t(k,i,n)})$, i.e. evaluating the model after completing a random block $i$ on each day $k$. \item The \textbf{per-component SGD} approach \eqref{eq:separatew}, where we run $m=6$ SGD chains, with each model training on only one block per day. For each day $k$, we evaluate $\frac{1}{m}\sum_i \hat{F}_i(w^i_{kn})$, where $w^i_{kn}$ is the model for component $i$ trained on the first $k$ blocks for component $i$. \item The \textbf{pluralistic single SGD chain} approach of Section~\ref{sec:pluravg}. The SGD chain is the same as for the consensus model, but evaluation is pluralistic as above: for each day $k$ we evaluate $\frac{1}{m}\sum_i \hat{F}_i(w_{t(k,i,n)})$, i.e.~for each test component we use the model at the end of the corresponding training block. \item An (impractical in real settings) \textbf{idealized i.i.d. model}, trained on the complete shuffled training set. For purposes of evaluation, we treat the data as if it had cyclic block structure and evaluate identically to the block-cyclic consensus model. \end{enumerate} See Appendix~\ref{sec:exp_eval} for more details on evaluation. Note that we do not use a model average, but rather take the most recent relevant iterate, matching how such models are typically deployed in practice. \begin{figure}[t] \centering \includegraphics[width=8cm]{experiment_results_cycles.pdf} \vspace{-0.4cm} \caption{Accuracy of a model trained on block-cyclic data tested on two blocks of data - posts from the midnight component (12am-4am), and posts from the noon component (12pm-4pm). Mean and standard deviations are computed from ten training repetitions.} \label{fig:experiment_results_cycles} \end{figure} Figure \ref{fig:experiment_results_cycles} illustrates how the block-cyclic structure of data can hurt accuracy of a consensus model. We plot how the accuracy on two test data components --- the midnight, and the noon component --- changes as a function of time of day when evaluated on the iterates of the SGD chain \eqref{eq:SGD}. Training is quick to leverage the label bias and gravitate towards a model too specific for the block being processed, instead of finding a better predictive solution based on other features that would help predictions across all groups. In Figure \ref{fig:experiment_results} we compare results from the four different training and test methods introduced above. First, pluralistic models with separate SGD chains take longer to converge because they are trained on less data. Depending on how long training proceeds, the size of the data set, and the number of components, these models may or may not surpass the idealized i.i.d. SGD and pluralistic single SGD chain models in accuracy. Second, the pluralistic models from a single SGD chain consistently perform better than a single consensus model from the same chain. Third, the performance of pluralistic models is en par with or better than the idealized i.i.d. SGD model, reflecting the fact that these models better match the target data distribution than a single model (i.i.d. or block cyclic consensus) can. \section{Summary} We considered training in the presence of block-cyclic data, showed that ignoring this source of data heterogeneity can be detrimental, but that a remarkably simple pluralistic approach can entirely resolve the problem and ensure, even in the worst case, the same guarantee as with homogeneous i.i.d.~data, and without any degradation based on the number of blocks. When the component distributions are actually different, pluralism can outperform the ``ideal'' i.i.d.~baseline, as our experiments illustrate. An important lesson we want to stress is that pluralism can be a critical tool for dealing with heterogeneous data, by embracing this heterogeneity instead of wastefully insisting on a consensus solution. Dealing with heterogeneous data, users or clients can be difficult in many machine learning settings, and especially in Federated Learning where learning happens on varied devices with different characteristics, each handling its own distinct data. Other heterogeneous aspects we can expect are variabilities in processing time and latency, amount of data per client, and client availability and reliability, which can all be correlated in different ways with different data components. All these pose significant challenges when training. We expect pluralistic solutions might be relevant in many of these situations. \begin{figure}[t] \centering \vspace{-0.25cm} \includegraphics[width=8cm]{experiment_results.pdf} \vspace{-0.4cm} \caption{Comparison of various training and testing methodologies for a simple model on a sentiment classification task, using i.i.d. and block-cyclic data. Means and standard deviations shown are computed from ten training repetitions.} \vspace{-0.5cm} \label{fig:experiment_results} \end{figure} In this paper we considered only optimizing {\em convex} objectives using sequential SGD. In many cases we are faced with non-convex objectives, as in when training deep neural networks. As with many other training techniques, we expect this study of convex semi-cyclic training to be indicative also of non-convex scenarios (except that a random predictor would need to be used instead of an averaged predictor in the online-to-batch conversion) and also serve as a basis for further analysis of the non-convex case. We are also interesting in analyzing the effect of block-cyclic data on methods beyond sequential SGD, and most prominently parallel SGD (aka Federated Averaging). Unfortunately, there is currently no satisfying and tight analysis of parallel SGD even for i.i.d.~data, making a detailed analysis of semi-cyclicity for this method beyond our current reach. Nevertheless, we again hope our analysis will be both indicative and serve as a basis for future exploration of parallel SGD and other distributed optimization approaches. \section*{Acknowledgements} NS was supported by NSF-BSF award 1718970 and a Google Faculty Research Award. \setlength{\bibsep}{0.75ex plus 0.3ex}
{'timestamp': '2019-04-24T02:05:27', 'yymm': '1904', 'arxiv_id': '1904.10120', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.10120'}
arxiv
\section{Introduction} With the popularity of the disciplines related to 3D vision (eg: robotics, augmented and mixed reality, autonomous driving), how to get more accurate depth information using cheap devices in a 3D environment is important. Currently, there are many methods to obtain depth information, such as active illumination devices (eg: structured light cameras, Time of Flight (ToF) sensors), passive methods (monocular vision~\cite{Monodepth}, stereo vision~\cite{PSMNet,Dispnet,FPGA_stereo,SGM}) and so on. However, none of these methods is perfect in all scenes. For example: ToF is sensitive to sunshine outdoors and reflectivity of the materials; Vision-based methods are sensitive to scene content (repetitive or textureless regions); Lidar-based devices are expensive and data is sparse and lacks color information. Thus, depth fusion from multiple sources is urgently needed, where different data sources can compensate for the weaknesses of each other. In recent years, different kinds of depth fusion methods have emerged in different sub-tasks, such as stereo-ToF fusion~(\cite{Probablistic_Fusion,Reliable_Fusion,DL_Fusion}), stereo-stereo fusion~(\cite{Deep_stere_fusion}), Lidar-stereo fusion~(\cite{Probabilistic-Lidar-stereo,HP-Lidar-stereo-fusion}) and general depth fusion~(\cite{Sdf-GAN}). Additionally, deep-learning based methods perform much better than the rest. However, all of these algorithms are supervised and require much ground truth depth data to train. They suffer from two big problems: (1) Ground truth depth data is hard to get and expensive. (2) It is hard to generalize well with a limited amount of labeled data. As far as I know, the proposed algorithm in this paper is the first to develop a fully unsupervised depth fusion method, which solves the problems above and can fuse the depth inputs of different quality effectively without using ground truth depth data. Unsupervised disparity fusion is hard because the algorithm requires to be able to produce an extremely accurate disparity map without any ground truth disparity data. The existing unsupervised strategy based on the left and right intensity consistency cannot guarantee a highly accurate disparity map. For example, Monodepth~\cite{Monodepth} treated the left-right intensity consistency error as a global metric in their cost function to obtain the disparity value but slight intensity changes in the images will influence the global estimation strongly. However, the left-right intensity consistency is just one of our local refinement metrics, which increases the global robustness and accuracy in turn. Previous work, such as our Sdf-MAN~\cite{Sdf-GAN}, achieved top disparity fusion performance but these algorithms need the ground truth disparity data to train. By combining the global disparity initialization with local disparity refinement, we show that our network can be trained without any ground truth depth data. In this paper, a fully unsupervised disparity fusion framework is proposed without the requirement of ground truth depth data. The initial disparity maps from the left view along with the auxiliary information (gradient, left \& right intensity image) are input into the refiner (a network similar to the generator in GAN~\cite{Standard_GAN} but without noise input) and the refiner is made to output the refined disparity map registered to the left view. The refined left disparity map and left intensity image are used to reconstruct the fake right intensity image. Finally, the fake and real right intensity images (from the right stereo vision camera) are fed into the discriminator (See Fig.~\ref{fig:Whole_diagram_UDFNet}). In the model, the refiner is trained to output a refined disparity value close to the weighted sum of the disparity inputs for global initialization (Equation~\ref{eq3_UDFNet}). Then, three refinement principles are adopted to refine the depth further. (1) The reconstructed intensity error between the fake and real right intensity image is minimized (Equation~\ref{eq1_UDFNet}). (2) The similarities between the fake and real right image in different receptive fields are maximized (Equation~\ref{eq4_UDFNet}). (3) The refined disparity map is smoothed based on the corresponding intensity image space (Equation~\ref{eq2_UDFNet}). A novel and efficient network structure has been designed as well (See Figure~\ref{fig:Network_refiner_UDFNet} for refiner, Figure~\ref{fig:Network_discriminator_UDFNet} for discriminator). In the refiner, from the input layer to the bottleneck, the dense blocks and transition layers~\cite{Densenet} are used to increase local non-linearity to obtain more local detailed information. Long skip connections from previous layers to later layers are added to preserve the lost detail information after the bottleneck. The discriminator outputs the probability of the input image (real right image or reconstructed right image) being from the real distribution at different receptive field sizes (or different scales). Also, the dense blocks and transition layers have been adapted to increase the ability of the discriminator. Section~\ref{Methodology_UDFNet} presents the pipeline of the proposed work, the mathematical model used in the design of the objective function for the network and the architecture for the refiner and discriminator. Section~\ref{Experiments_UDFNet} presents the experimental results. \textbf{Contributions:} \begin{enumerate} \item An efficient unsupervised strategy by combining global disparity initialization and local refinement \item An indirect method using an adversarial network to force the disparity Markov Random Field of the refined disparity map to be close to the real \item An unsupervised end-to-end uncertainty-based pipeline to fuse any disparity input \end{enumerate} \section{Methodology \label{Methodology_UDFNet}} First a pipeline using a refiner network (similar to the generator in GAN~\cite{Standard_GAN} without noise input) is proposed to realize disparity fusion and then a mathematical model is built to design the cost function for the fully unsupervised network. Finally, the refiner and discriminator architectures are introduced. \\ \subsection{Fusion Pipeline} Similar to \cite{Sdf-GAN}, a refiner network has been used to map coarse disparity inputs to a real disparity distribution deterministically using multi-modal information (disparity, intensity, intensity gradient). Unlike ~\cite{Deep_stere_fusion, Sdf-GAN, DL_Fusion}, a fully unsupervised method is used to train the neural network without ground truth. Inspired by \cite{Monodepth}, the disparity output from the left view is treated as a hidden layer and used to reconstruct the intensity image of the right view. The whole process is shown in Figure~\ref{fig:Whole_diagram_UDFNet}. \begin{figure}[h!] \subfloat[Refiner]{\includegraphics[width = 7cm]{"figure//UDFNet//Theory//refiner"}} \hspace{0.5cm} \subfloat[Reconstruct right intensity image]{\includegraphics[width = 7cm]{"figure//UDFNet//Theory//converter"}} \\ \subfloat[Negative examples]{\includegraphics[width = 7cm]{"figure//UDFNet//Theory//negative_example"}} \hspace{0.5cm} \subfloat[Positive examples]{\includegraphics[width = 7cm]{"figure//UDFNet//Theory//positive_example"}} \\ \caption{\textcolor{black}{ (a): The inputs to the refiner (R) are the initial disparity maps (`disparity map 1', `disparity map 2') in the left view and auxiliary information (left intensity image, right intensity image, right gradient image). The gradient of the left view is calculated from the left intensity image directly. The refiner produces a refined disparity map in the left view. (b): The refined left disparity map and left intensity image are used to reconstruct the right intensity image. (c)(d): The input to discriminator (D) is the combination of the left intensity image, right gradient image, the initial disparity inputs and the reconstructed/real right image. The discriminator tries to discriminate whether the input is fake (reconstructed right image) in (c) or true (real right image) in (d). The images in each block come from the training process on a synthetic garden dataset.}} \label{fig:Whole_diagram_UDFNet} \end{figure} \subsection{Objective Function} Using the reconstructed intensity error as a metric usually cannot guarantee a highly precise disparity output (eg:~\cite{Monodepth}), especially in environments with similar color and repetitive patterns (eg: garden). Additionally, the fusion accuracy may decrease compared with highly accurate disparity inputs if only the reconstructed intensity error is used as the decision metric. Thus, a more complex mathematical model is proposed as the cost function for disparity fusion. The main ideas for the mathematical model: $\bullet$ The target is disparity fusion, whose accuracy should depend on the input disparity accuracy. The initial disparity maps should be used to provide the global initial value for the refined disparity map first. That is, the output of the refiner is encouraged to be similar to the input disparities (Equation~\ref{eq3_UDFNet}). $\bullet$ The initialization based on Equation~\ref{eq3_UDFNet} can provide a coarse disparity map. The refinement will be realized by three local decision strategies discussed below together. The fake right intensity image is reconstructed from the left intensity image and disparity map. Thus, the accuracy of the refined disparity map can be assessed indirectly by comparing the reconstructed right image and real right image. The $L_1$ intensity error is designed based on the gradient in Equation~\ref{eq1_UDFNet} and the distance between the Markov Random Field of the refined disparity map and real disparity distribution is described in Equation~\ref{eq4_UDFNet} indirectly. A disparity smoothness term is also designed to reduce the outliers and strong noise in Equation~\ref{eq2_UDFNet} using the gradient. More specifically, the cost function has been designed as the following: (1) Different from classical stereo vision algorithms without initial disparity inputs, disparity fusion is aimed at refinement of initial disparity inputs. Thus, a constraint is added that the output should be close to the weighted sum of the initial disparity inputs at each pixel. The output accuracy will increase with the accuracy enhancement of the initial disparity inputs. \begin{equation} \label{eq3_UDFNet} \mathcal{L}_{c}(G) = \mathop{{}\mathbb{E}}_{u \in \tilde{x}, u_s \in \bar{x}_s, \tilde{x} \sim P_G, s=1..Z}[w_{u_s} || \tilde{x}_u-\bar{x}_{u_s}||_1] \end{equation} In Equation~\ref{eq3_UDFNet}, $\bar{x}_{u_s}$ is the disparity value of a pixel $u_s$ of the $s^{th}$ initial disparity input (In Fig.~\ref{fig:Whole_diagram_UDFNet}, it is `disparity map 1' or `disparity map 2') corresponding to $u$ in the refined disparity output $\tilde{x}$ (In Fig.~\ref{fig:Whole_diagram_UDFNet}, it is `refined disparity map'). $P_G$ represents the distribution of the samples $\tilde{x}$ from the refiner. $w_{u_s}$ is the confidence of the pixel $u_s$ from the $s^{th}$ initial disparity input. If no prior knowledge is available, $w_{u_s}=1/Z$ for all pixels. $Z$ is the number of initial disparity inputs. (2) To encourage disparity estimates at edges to be more accurate, gradient information is integrated as a weight into the $L_1$ distance to make the disparity edges clearer. \begin{equation} \label{eq1_UDFNet} \mathcal{L}_{L_1}(G) = \mathop{{}\mathbb{E}}_{I_r \sim P_R, \tilde{I_r} \sim P_G' }[\exp(\alpha |\nabla (I_r)|) || I_r-\tilde{I_r}||_1] \end{equation} In Equation~\ref{eq1_UDFNet}, $I_r$ is the real right intensity image from the right camera (In Fig.~\ref{fig:Whole_diagram_UDFNet}, it is `right intensity image'.) and $\tilde{I_r}$ is the reconstructed right intensity image from the refiner (In Fig.~\ref{fig:Whole_diagram_UDFNet}, it is `reconstructed right intensity image'). $\nabla (I_r)$ is the gradient of the gray image in the right view (In Fig.~\ref{fig:Whole_diagram_UDFNet}, it is `right gradient image' calculated from Sobel operator). $\alpha \geq 0$ weights the gradient value. $||\bullet ||_1$ is $L_1$ distance. $P_G'$ represents the distribution of the samples $\tilde{I_r}$ reconstructed from the left intensity image and corresponding refined disparity map. $P_R$ represents the distribution of the samples $I_r$ from the right camera in the stereo vision setting. The goal is to encourage disparity estimates at edges (larger gradients) to be more accurate with less reconstructed intensity error. (3) The right intensity image is reconstructed from the left intensity image using the refined disparity output. Unlike \cite{Sdf-GAN}, the reconstructed right intensity image and real right intensity image are input into the discriminator in this paper, which also gives indirect feedback about whether the refined disparity distribution is close to the ground truth. By making the discriminator output the probabilities at different receptive fields or scales (In Fig.~\ref{fig:Network_discriminator_UDFNet}, please refer to D1, D2,..,D5), the refiner will be forced to make the disparity distribution in the refined disparity map close to the real. To alleviate training difficulties and avoid GAN mode collapse, the Improved WGAN loss function ~\cite{Improved-WGAN} is adopted. In Equation~\ref{eq4_UDFNet}, $D_i$ is the probability at the $i^{th}$ scale that the input image patch to the discriminator is from the real distribution at the $i^{th}$ scale. $\lambda$ is the penalty coefficient. $\hat{I_r}$ is the random sample and $P_{\hat{I_r}}$ is its corresponding distribution. (For more details, please read \cite{Improved-WGAN}). \begin{equation} \label{eq4_UDFNet} \begin{split} \mathcal{L}_{wgan}(G,D_{i}) = \mathop{{}\mathbb{E}}_{\tilde{I_r} \sim P_G' }[D_{i}(\tilde{I_r})]-\mathop{{}\mathbb{E}}_{I_r \sim P_R}[D_{i}(I_r)] \\ + \lambda \mathop{{}\mathbb{E}}_{\hat{I_r} \sim P_{\hat{I_r}} }[(||\nabla _{\hat{I_r}} D_{i}(\hat{I_r}) ||_2 - 1)^2] \end{split} \end{equation} (4) After the strategies above, the neural network may produce outliers (black holes) in the texture-less areas. In order to suppress the outliers and noise in the refined disparity map, a gradient-based smoothness term is used to propagate more accurate disparity values to the areas with similar color by the assumption that the disparity in the neighborhood should be similar if the intensity is similar. However, this term tends to produce blurry edge in the refined disparity map. \begin{equation} \label{eq2_UDFNet} \mathcal{L}_{sm}(G) = \mathop{{}\mathbb{E}}_{u \in \tilde{x}, v \in N(u), \tilde{x} \sim P_G }[\exp(\gamma-\beta | \nabla (I_l)_{uv}|) || \tilde{x}_u-\tilde{x}_v||_1] \end{equation} In Equation~\ref{eq2_UDFNet}, $\tilde{x}_u$ is the disparity of a pixel $u$ in the refined disparity map $\tilde{x}$ from the refiner. $\tilde{x}_v$ is the disparity value of a pixel $v$ in the neighborhood $N(u)$ of pixel $u$. $\nabla (I_l)_{uv}$ is the gradient in the left intensity image (the refined disparity map is produced on the left view) from pixel $u$ to pixel $v$. It is calculated from the left intensity image considering the diagonal, left and right directions. $\beta \geq 0$ and $\gamma \geq 0$ are responsible for how close the disparities are if the intensities in the neighborhood are similar. (5) Finally, our object function for the fully unsupervised approach is: \begin{equation} \label{eq5_UDFNet} \begin{split} G^{*} = \arg \mathop{\min}\limits_{G} \mathop{\max}\limits_{D_{i}} [& \theta _{1}\mathcal{L}_{L_1}(G) + \theta _{2}\mathcal{L}_{sm}(G) + \theta _{3} \mathcal{L}_{c}(G) \\ &- \theta _{4}\sum_{i=1}^{M}\mathcal{L}_{wgan}(G,D_{i})] \end{split} \end{equation} In Equation~\ref{eq5_UDFNet}, $M$ is the number of the scales (In Fig.~\ref{fig:Network_discriminator_UDFNet}, M=5, please refer to D1, D2, .., D5). $\theta _{1}$, $\theta _{2}$, $\theta _{3}$, $\theta _{4}$ are the weights for the different loss terms. \subsection{Network architectures} A fully convolutional neural network~\cite{FCN} is adopted and also the partial architectures from~\cite{DCGAN,Densenet,Sdf-GAN} are adapted here for the refiner and discriminator. The refiner and discriminator use dense blocks~\cite{Densenet} to increase local non-linearity. Transition layers~\cite{Densenet} change the size of the feature maps to reduce the time and space complexity. In each dense block and transition layer, modules of the form ReLu-BatchNorm-convolution are used. Two modules in the refiner and four modules in the discriminator in each dense block are used, where the filter size is 3$\times$3 and stride is 1. In each transition layer, only one module is used, where the filter size is 4$\times$4 and the stride is 2 (except that in Tran.3 of the discriminator the stride is 1). Figure~\ref{fig:Network_refiner_UDFNet} shows the main architecture of the refiner. c1 initial disparity inputs (the experiments below use $c1=2$ for 2 disparity maps) and c2 pieces of information (the experiments below use $c2=3$ for the left intensity image, the right intensity image and a gradient of the right intensity image) are concatenated as input into the refiner. The batch size is b and resolution is 32m*32n. $lg$ is the number of the feature map channels after the first convolution. The refined disparity map is treated as a hidden layer in the network and used to reconstruct the intensity image in the right view. To reduce the computational complexity and increase the extraction ability of local details, each dense block contains only 2 internal layers. Additionally, the skip connections~\cite{Unet} from the previous layers to the latter layers preserve the local details in order not to lose information after the network bottleneck. During training, a dropout strategy has been added into the layers in the refiner after the bottleneck to avoid overfitting and the dropout part is cancelled during testing to produce a deterministic result. \begin{figure*}[h!] \includegraphics[width = 15cm]{figure/UDFNet/Architecture/refiner} \caption{ This figure shows some important hyperparameters and the refiner architecture configuration. Please refer to Table~\ref{Network_setting_UDFNet} for the specific values in each experiment. } \label{fig:Network_refiner_UDFNet} \end{figure*} Figure~\ref{fig:Network_discriminator_UDFNet} is for the discriminator. The discriminator will only be used during training and abandoned during testing. Thus, the architecture of the discriminator will only influence the computational complexity during training. The initial disparity maps, information and real or reconstructed right images are concatenated and fed into the discriminator. Each dense block contains 4 internal layers. The sigmoid function (function tf.sigmoid in Tensorflow platform) outputs the probability map ($D_i, i=1,2..5$) that the input is real or fake at different scales to force the Markov Random Field of the refined disparity map to get closer to the real distribution at different receptive field sizes. \begin{figure*}[h!] \includegraphics[width = 13cm]{figure/UDFNet/Architecture/discriminator} \caption{ This figure shows some important hyperparameters and the discriminator architecture configuration. Please refer to Table~\ref{Network_setting_UDFNet} for the specific values in each experiment. } \label{fig:Network_discriminator_UDFNet} \end{figure*} \section{Experiments \label{Experiments_UDFNet}} The network is implemented using TensorFlow\cite{TensorFlow} and trained \& tested using an Intel Core i7-7820HK processor (quad-core, 8MB cache, up to 4.4GHZ) and Nvidia Geforce GTX 1080Ti. First, an ablation study with initial disparity inputs (~\cite{Dispnet, FPGA_stereo}) is conducted using a synthetic garden dataset to analyze the influence of each factor in the energy function. Secondly, a real test on the Kitti2015 dataset~\cite{Kitti2015} is done with two initial inputs (~\cite{PSMNet,SGM}). All the results show the proposed algorithm's superiority compared with the state-of-art or classical stereo vision algorithms (~\cite{PSMNet,FPGA_stereo,Dispnet,SGM}), and the state-of-the-art stereo-stereo fusion algorithms (~\cite{Sdf-GAN,Deep_stere_fusion}). In the following experiments, the inputs to the neural network were first padded to 32M * 32N (M, N are integers) using 0 and normalized to [-1, 1]. After that, the input was flipped vertically with a 50\% chance to double the number of training samples. Weights of all the neurons were initialized from a Gaussian distribution (standard deviation 0.02, mean 0). Each model is trained for 100 epochs on a synthetic garden dataset\footnote{It is not available to the public now.} and 500 epochs on Kitti2015, with a batch size 4 using Adam~\cite{Adam} with a momentum of 0.5. The learning rate is changed from 0.005 to 0.0001 gradually. The method in~\cite{Standard_GAN} is used to optimize the refiner and discriminator by alternating between one step on the discriminator and then one step on the refiner. The parameters $\theta_{1}$, $\theta_{2}$, $\theta_{3}$, $\theta_{4}$ in Equation~\ref{eq5_UDFNet} were set to make those four terms contribute differently to the energy function in the training process. If the difference of two initial disparity values on the same pixel is small (\textless 0.3 pixels), a large value (0.99) is assigned to their confidence weight in Equation~\ref{eq3_UDFNet}. If not, they were set to a medium value (0.5). Besides the confidence estimation above, some other special empirical confidence estimation for some disparity inputs were adopted in the following experiments (For more details, see the corresponding experiments). Additionally, I didn't do any post-processing on the occlusion area and the other areas. The $L_1$ distance between the estimated value and ground truth is used as the error. The unit is pixel. For more details about the network settings and computational complexity, please see Table~\ref{Network_setting_UDFNet}. To highlight the real test, the network can do the disparity fusion (up to 384*1248 pixels) directly at 90 HZ without any cropping or downsampling. \begin{table*}[h!] \centering \caption{Computation Time and Initial Parameter Setting } \scalebox{.63}[.65]{\begin{tabular}{|p{0.8cm} | p{1.7cm}| p{1.8cm}| *{13}{p{0.9 cm}|}} \hline & \multicolumn{15}{c|}{\textbf{Ablation Study} with Synthetic Garden Dataset } \\ \hline \bf Para. & Train time & Test time & b & 32m & 32n & $c_1, c_2$, $c_3$ & lg & ld & $\theta_{1}$ & $\theta_{2}$ & $\theta_{3}$ & $\theta_{4}$ & $\alpha$ & $\beta$ & $\gamma$ \\ \hline \bf Value & 0.22 (h/epoch) & 0.010 (s/frame) & 4 & 384 & 480 & 2, 3, 2 & 32 & 32 & 10 & 0.1 & 0.001 & 1 & 3 & 650 & 5 \\ \hline & \multicolumn{15}{c|}{\textbf{Real Test } with Kitti2015 Dataset } \\ \hline \bf Para. & Train time & Test time & b & 32m & 32n & $c_1, c_2$, $c_3$ & lg & ld & $\theta_{1}$ & $\theta_{2}$ & $\theta_{3}$ & $\theta_{4}$ & $\alpha$ & $\beta$ & $\gamma$ \\ \hline \bf Value & 0.03 (h/epoch) & 0.011 (s/frame) & 4 & 384 & 1248 & 2, 3, 2 & 10 & 10 & 1 & 20 to 1 & 0.0001 to~1K & 1 & 3 & 1 to 3000 & 5 \\ \hline \end{tabular} } \label{Network_setting_UDFNet} \end{table*} \begin{table*}[h!] \centering \caption{Ablation Study on Each Cue (Unit: Pixel) } \scalebox{.61}[.63]{\begin{tabular}{|p{2cm}| *{10}{p{1.7 cm}|}} \hline \bf Experiment & Input1~\cite{Dispnet} & Input2~\cite{FPGA_stereo} & $\theta_{1}=0$ & $\theta_{2}=0$ & $\theta_{3}=0$ & $\theta_{4}=0$ & $\alpha=0$ & $\beta=65$ & $\gamma=1$ & Baseline \\ \hline \bf Error (pixel) & 4.67 & 8.52 & 3.53 & 3.94 & \bf 228.31 & 3.70 & 3.55 & 5.86 & 3.67 & \bf 3.45 \\ \hline \bf Tuning experience & overall accuracy & overall accuracy & contrast influence & smooth influence & \bf initialized disparity & disparity MRF & accuracy at edge & smooth effect & smooth effect & \\ \hline \end{tabular} } \label{Ablation_study_UDFNet} \end{table*} \subsection{Ablation Study} \begin{figure*}[h!] \centering \subfloat[Scene]{\includegraphics[width = 7cm,height=5cm]{figure//UDFNet//example_synthetic//left_image-eps-converted-to.pdf}} \vspace{0.001cm} \subfloat[Ground Truth]{\includegraphics[width = 7cm,height=5cm]{figure//UDFNet//example_synthetic//gt-eps-converted-to.pdf}} \vspace{0.001cm} \subfloat[FPGA Stereo~\cite{FPGA_stereo}]{\includegraphics[width = 7cm,height=5cm]{figure//UDFNet//example_synthetic//disp1-eps-converted-to.pdf}} \vspace{0.001cm} \subfloat[Dispnet~\cite{Dispnet}]{\includegraphics[width = 7cm,height=5cm]{figure//UDFNet//example_synthetic//disp2-eps-converted-to.pdf}} \vspace{0.001cm} \subfloat[Fused Disparity]{\includegraphics[width = 7cm,height=5cm]{figure//UDFNet//example_synthetic//ours-eps-converted-to.pdf}} \vspace{0.001cm} \caption{Two initial disparity inputs (c)(d) were fused to get a refined disparity map (e) using our baseline method on the synthetic garden dataset. (b) is the ground truth and (a) is the corresponding scene. Many, but not all, pixels from the fused result are closer to the ground truth than the original inputs. Tip: Zooming in the electronic version gives a better view.} \label{fig:Ablation_study_UDFNet} \end{figure*} The synthetic garden dataset contains 4600 training samples and 421 test samples under outdoor environments. Each sample has one pair of rectified stereo images and dense ground truth with resolution 480*640 (height * width) pixels. The reason using a synthetic dataset is that the real dataset (eg: Kitti2015) does not have dense ground truth, which will influence the evaluation of the network. Dispnet~\cite{Dispnet} and FPGA-stereo~\cite{FPGA_stereo} were used as inputs. The authors of ~\cite{Dispnet,FPGA_stereo} helped us get the best performance on the dataset as the input to the network. Besides the confidence estimation strategy above, another special rule to Dispnet was added because the disparity map from Dispnet is very inaccurate in remote areas. That is, the pixels whose disparity is less than 4 (pixels) have a small confidence (0.1) and, otherwise, have a big confidence (0.9) because it is more accurate for close scenes. The default settings for the baseline network is shown in Table~\ref{Network_setting_UDFNet}. In the ablation study, one of the following factors ($\theta_{1}$, $\theta_{2}$, $\theta_{3}$, $\theta_{4}$, $\alpha$, $\beta$, $\gamma$) in our energy function is changed to see the influence of each cue. The performance results are listed in Table~\ref{Ablation_study_UDFNet}. One example is Figure~\ref{fig:Ablation_study_UDFNet}. As said in the introduction, the disparity constraint term $\theta_{3}$ (Equation \ref{eq3_UDFNet}) encourages the network to produce disparities close to the initial disparity inputs. It is the most important factor (228.31 pixels errors) because the other factors do not provide an accurate global initialization but mainly refine the disparity value in the local area using pixel-pixel intensity ($\theta_{1}$,$\alpha$), smoothness ($\theta_{2}$, $\gamma$, $\beta$) and Markov Random Field ($\theta_{4}$) . When tuning the network, the experience also followed the theory in the methodology section (Table~\ref{Ablation_study_UDFNet}). To explore the influence of the input accuracy and the number of initial inputs, one or two initial disparity maps with different noise levels were input into the networks. The disparity inputs were got by adding different levels of Gaussian noise $N(0,\sigma^2)$ to the normalized ground truth (ground truth divided by 480). The confidence for each pixel in the experiments is proportional to the noise value under the assumption that accurate confidence estimation in the future can be obtained. The fusion accuracy (Table~\ref{Ablation_Study_2_UDFNet}) increases with the number and accuracy of the disparity inputs. When there is only one input with $\sigma=0.002$, the proposed method still can refine the input disparity (0.77 \textless 1 pixel ) because there are accurate confidence estimates. The proposed method sometimes fails to refine only one input disparity map when there are no confidence estimates (all confidences are 100\%) and the mean error (\textless 1 pixel) is too small. Otherwise, it works robustly and effectively. \begin{table}[h!] \centering \caption{Average error (pixel) on Synthetic Garden } \label{Ablation_Study_2_UDFNet} \begin{tabular}{|p{1.8cm}|*{5}{p{1 cm}|}} \hline & \multicolumn{2}{c|}{\bf Fuse one input } & \multicolumn{3}{c|}{\bf Fuse two inputs } \\ \hline \bf Noise std. & \bf input1 & \bf fused & \bf input1 & \bf input2 & \bf fused \\ \hline $\sigma=0.002$ & 0.77 & 0.69 & 0.77 & 0.77 & 0.64 \\ \hline $\sigma=0.004$ & 1.53 & 1.13 & 1.53 & 1.53 & 0.71 \\ \hline $\sigma=0.008$ & 3.06 & 1.58 & 3.06 & 3.06 & 0.80 \\ \hline $\sigma=0.016$ & 6.12 & 3.05 & 6.12 & 6.12 & 1.33 \\ \hline \end{tabular} \end{table} \subsection{Real Data} \subsubsection{Stereo-stereo Fusion} The network was tested on the real Kitti2015 dataset, which used a Velodyne HDL-64E Lidar scanner to get the sparse ground truth and a 1242*375 resolution stereo camera to get stereo image pairs. The training dataset contains 400 unlabeled and labeled samples in all. There are another 400 samples in the test dataset. 50 samples from `000000\_10.png' to `000049\_10.png' in the Kitti2015 training dataset were used as our test dataset. 50 samples from `000050\_50.png' to `000099\_10.png' in the Kitti2015 training dataset were used as our validation dataset. The rest 700 samples were used as our training set. By flipping the training samples vertically, it doubled the number of training samples. The state-of-art stereo vision algorithm PSMNet~\cite{PSMNet} was used as one of our inputs. Their released pre-trained model\footnote{PSMNet~\cite{PSMNet}: \url{https://github.com/JiaRenChang/PSMNet}} on the Kitti2015 dataset was used to get the disparity maps. A traditional stereo vision algorithm SGM~\cite{SGM} was used as the second input to the network. Because the sparsity of SGM is not so important, its parameters were set to produce more reliable disparity maps. Thus, big confidence values (0.8) were assigned to its valid pixels and 0 to its invalid pixels' confidences. More specifically, the implementation (`disparity' function) from Matlab2016b was used. The relevant parameters are: 'DisparityRange' [0, 160], `BlockSize' 5, `ContrastThreshold' 0.99, `UniquenessThreshold' 70, `DistanceThreshold' 2. The settings of the neural network are shown in Table~\ref{Network_setting_UDFNet}. The proposed algorithm was compared with the state-of-the-art technique~\cite{Sdf-GAN,Deep_stere_fusion} in stereo-stereo fusion and also stereo vision inputs~\cite{PSMNet,SGM}. The proposed method was compared with the supervised method in Sdf-MAN~\cite{Sdf-GAN}. The supervised method in Sdf-MAN was trained on our synthetic garden dataset first and then fine-tuned on the Kitti2015. 150 labeled samples from `00050\_10.png' to `000199\_10.png' in the initial training dataset were used for Sdf-MAN fine-tuning. Compared~with SGM~\cite{SGM} (0.78 pixels)~({This is a more accurate disparity but is calculated only using more reliable pixels. On~average only 40\% of the ground truth pixels are used. If all the valid ground truth are used to calculate its error, it~is 22.13 pixels}), the~fused results are much more dense and accurate. The performance of the proposed algorithm (0.83 pixels) (See Table~\ref{Real Test_UDFNet}) is better than Sdf-MAN (1.17 pixels). The reason is because Sdf-MAN can't generalize in the real environment well. However, the proposed algorithm is not affected by such problems because the unsupervised method can use the unlabeled data directly. \begin{table}[h!] \centering \caption{Average error (pixel) on Kitti2015 } \label{Real Test_UDFNet} \begin{tabular}{|p{1.9cm}| p{1.9cm}| *{3}{p{2.7 cm}|}} \hline \multicolumn{2}{|c|}{\bf Source Error } & \multicolumn{3}{c|}{\bf Fused Algorithm Error } \\ \hline SGM \cite{SGM} & PSMNet~\cite{PSMNet} & DSF~\cite{Deep_stere_fusion} & Sdf-MAN~\cite{Sdf-GAN} & Ours \\ \hline 0.78 & 1.22 & 1.20 & 1.17 & 0.83 \\ \hline \end{tabular} \end{table} \begin{figure*}[h!] \centering \subfloat[Ground Truth]{\includegraphics[height=3.5cm]{figure//UDFNet//example//gt_new-eps-converted-to.pdf}} \subfloat[Scene]{\includegraphics[height=3.5cm]{figure//UDFNet//example//left_image-eps-converted-to.pdf}}\\ \subfloat[Input Disparity 1: SGM~\cite{SGM}]{\includegraphics[height=3.5cm]{figure//UDFNet//example//disp1_new-eps-converted-to.pdf}} \subfloat[Input Disparity 1 Error: SGM~\cite{SGM}]{\includegraphics[height=3.5cm]{figure//UDFNet//example//disp1_error-eps-converted-to.pdf}} \\ \subfloat[Input Disparity 2: PSMNet~\cite{PSMNet}]{\includegraphics[height=3.5cm]{figure//UDFNet//example//disp2_new-eps-converted-to.pdf}} \subfloat[Input Disparity 2 Error: PSMNet~\cite{PSMNet}]{\includegraphics[height=3.5cm]{figure//UDFNet//example//disp2_error-eps-converted-to.pdf}} \\ \subfloat[Refined Disparity]{\includegraphics[height=3.5cm]{figure//UDFNet//example//ours_new-eps-converted-to.pdf}} \subfloat[Refined Disparity Error]{\includegraphics[height=3.5cm]{figure//UDFNet//example//ours_error-eps-converted-to.pdf}} \\ \caption{The unsupervised adversarial network was trained to fuse the initial disparity maps (c), (e) into a refined disparity map (g) for the same scene (b) from the Kitti2015 dataset~\cite{Kitti2015}. (a) is the corresponding ground truth. (d), (f), (h) are the errors of (c), (e), (g). The colorbars (from blue to white) corresponds to 0 - 1.6 pixels and the lighter pixel have bigger error in (d), (f), (h).} \label{fig:example_demo_UDFNet} \end{figure*} For qualitative results, see Figure~\ref{fig:example_demo_UDFNet}. The proposed method compensates for the weaknesses of the inputs and refines the initial disparity maps effectively. Compared with SGM~\cite{SGM}, the fused results are much more dense and accurate. Compared with PSMNet, the proposed method preserves the details better (eg: mountain). But the proposed method fully fails in the sky. The reason is that the pixels (disparity = 0) are treated as invalid (confidence = 0) in SGM. However, the disparity values of the pixels in the sky area from PSMNet are all larger than 0 (confidence \textgreater 0). So, the PSMNet misleads the network to adopt their disparity value as the initialization. Thus, the wrong confidence measurement can bring big error to the refined disparity map. The problem can be solved by adding more cues, such as semantic meaning, to make the confidence measurement more accurate. The efficiency and effectiveness of the proposed network's structure on the Kitti2015 dataset have been explored. The same settings from Table~\ref{Network_setting_UDFNet} except the channel ($l_g$, $l_d$) of the features in each layer were used. The results are shown in Table~\ref{Network_structure_efficiency_UDFNet}. When $l_g=l_d=10$, our network achieves the best accuracy (0.83 pixels) compared with the rest. Additionally, the four groups of experiments with different $l_g, l_d$ achieve similar performance, which shows the robustness of the proposed method. \begin{table}[h!] \centering \caption{Average error (pixel) on Kitti2015 } \label{Network_structure_efficiency_UDFNet} \begin{tabular}{|p{3cm}|*{2}{p{2.6 cm}|}} \hline Structure & Error (pixel) & Time (s/frame) \\ \hline $l_g=l_d=5$ & 1.00 & \bf 0.009 \\ \hline $l_g=l_d=10$ & \bf 0.83 & 0.011 \\ \hline $l_g=l_d=15$ & 0.92 & 0.014 \\ \hline $l_g=l_d=20$ & 0.87 & 0.017 \\ \hline \end{tabular} \end{table} \subsubsection{Stereo-Lidar Fusion} Our network can generalize to any sub-fusion task based on left-right consistency. A stereo-lidar fusion demo on Kitti2015 has also been done. The valid points in the initial ground truth were removed by half randomly to get the Lidar input to our network. The confidence of each valid Lidar data point was set as extremely large (100\%). PSMNet was used as the stereo input again and set the confidence of each pixel as 50\%. One hundred labeled images in the initial Kitti2015 training dataset were used to train (from `000100\_10.png' to `000199\_10.png' ) and the other 100 to test (from `000000\_10.png' to `000099\_10.png'). The error of PSMNet~\cite{PSMNet} is 1.22 pixels and our error is 0.86 pixels after fusion. \section{Conclusion} We proposed an unsupervised method to fuse the disparity estimates of multiple state-of-art disparity/depth algorithms. The experiments have shown the effectiveness of the energy function design based on multiple cues and the efficiency of the network structure. The proposed network can be generalized to other fusion tasks based on left-right image consistency (In this paper, we only did stereo-stereo and stereo-lidar fusion). The work in this paper reduces the cost of acquiring labelled data necessary for use in a supervised method. Given the algorithm's low computation cost, the combination of the proposed method and existing depth-acquisition algorithms is a good solution to obtaining high accuracy depth maps. Future work will investigate improved methods for setting the confidence values based on the initial disparity values and type of sensor. \bibliographystyle{unsrt}
{'timestamp': '2019-04-24T02:02:04', 'yymm': '1904', 'arxiv_id': '1904.10044', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.10044'}
arxiv
\section{INTRODUCTION} \label{sec:intro} \vspace{-0.1in} Fluorescence microscopy is a modality that allows imaging of subcellular structures from live specimens \cite{bib:Piston1999, bib:Vonesch2006}. During this image acquisition process, large datasets of 3D microscopy image volumes are generated. The quantitative analysis of the fluorescence microscopy volume is hampered by light diffraction, distortion created by lens aberrations in different directions, complex variation of biological structures \cite{bib:Murphy2012}. The image acquisition process can be typically modeled as the convolution of the observed objects with a 3D point spread function (PSF) followed by degradation from noise such as Poisson noise and Gaussian noise \cite{bib:Yang2015}. These limitations result in anisotropic, inhomogeneous background, blurry (out-of-focus), and noisy image volume with poor edge details which aggravate the image quality poorer in depth \cite{bib:SLee2018a}. There has been various approaches to improve 3D fluorescence microscopy images quality. One popular approach is known as image deconvolution which ``inverts'' the convolution process to restore the original microscopy image volume \cite{bib:Sarder2006}. Richard-Lucy (RL) deconvolution \cite{bib:Richard1972, bib:Lucy1974} which maximizes the likelihood distribution based on a Poisson noise assumption for confocal microscopy was proposed. This RL deconvolution was further extended in \cite{bib:Dey2006} that incorporated the total variation as a regularization term in the cost function. Since the PSF is usually not known, blind deconvolution which estimates the PSF and the original image simultaneously is favorable \cite{bib:Shajkofci2018}. Blind deconvolution using RL deconvolution was described in \cite{bib:Fish1995}. A pupil model for the PSF was presented in \cite{bib:Soulez2012} and the PSF was estimated using machine learning approaches in \cite{bib:Kenig2010}. Sparse coding to learn 2D features for coarse resolution along the depth axis to mitigate anisotropic issues was presented in \cite{bib:Soulez2014}. Another approach to achieve better image quality stems from image denoising research. One example is Poisson noise removal using a combination of the Haar wavelet and the linear expansion of thresholds (PURE-LET) proposed in \cite{bib:PureDenoise}. This PURE-LET approach was extended further to 3D widefield microscopy in \cite{bib:JLi2017}. Additionally, a denoising and deblurring method for Poisson noise corrupted data using variance stabilizing transforms (VST) was described in \cite{bib:Azzari2017}. Meanwhile, a 3D inhomogeneity correction method that combines 3D active contours segmentation was presented in \cite{bib:SLee2017}. Convolutional neural network (CNN) has been popular to address various problems in medical image analysis and computer vision such as image denoising, image segmentation, and image registration \cite{bib:Litjens2017}. There are few papers that focus on image deconvolution in fluorescence microscopy using CNNs. One example is an anisotropic fluorescence microscopy restoration method using a CNN \cite{bib:Weigert2017}. Later, semi-blind spatially-variant deconvolution in optical microscopy with a local PSF using a CNN was described in \cite{bib:Shajkofci2018}. More recently, generative adversarial networks has gradually gained interest in medical imaging especially for medical image analysis \cite{bib:Yi2018}. One of the useful architectures for medical image is a cycle-consistent adversarial networks (CycleGAN) \cite{bib:CycleGAN} which learns image-to-image translation without having paired images (actual groundtruth images). This CycleGAN was utilized for CT denoising by an analogy of mapping low dose phase images to high dose phase images to improve image quality \cite{bib:Kang2018}. Additionally, this CycleGAN was further extended by \cite{bib:CFu2018} incorporating a spatial constrained term to minimize misalignment between synthetically generated binary volume and corresponding synthetic microscopy volume to achieve better segmentation results. In this paper, we present a new approach to restore various biological structures in 3D microscopy images in deeper tissue without knowing the 3D PSF using a spatially constrained CycleGAN (SpCycleGAN) \cite{bib:CFu2018}. We train and inference the SpCycleGAN in three directions along with $xy$, $yz$, and $xz$ sections ($3$-Way SpCycleGAN) to incorporate 3D information inspired by \cite{bib:Roth2014, bib:SLee2018b}. These restored $3$-way microscopy images are then averaged and evaluated with three different image quality metrics. Our datasets consist of Hoechst $33342$ labeled nuclei and a phalloidin labeled filamentous actin collected from a rat kidney using two-photon microscopy. The goal is to restore blurred and noisy 3D microscopy images to the level of well-defined images so that the deeper depth tissues can be used for biological study. \vspace{-0.2in} \section{PROPOSED METHOD} \label{sec:method} \vspace{-0.15in} \begin{figure}[htbp!] \centering \includegraphics[width=0.5\textwidth]{blockdiagram} \vspace{-0.3in} \caption{Block diagram of the proposed deconvolution method using a $3$-Way SpCycleGAN} \label{fig:blockdiagram} \end{figure} \vspace{-0.15in} Figure \ref{fig:blockdiagram} shows a block diagram of the proposed 3D images deconvolution method. We denote $I$ as a 3D image volume of size $X \times Y \times Z$. Note that $I_{z_p}$ is a $xy$ section with $p^\text{th}$ focal plane along the $z$-direction in a volume, where $p \in \{1, \dots, Z\}$. Similarly, $I_{y_q}$ is a $xz$ section with $q^\text{th}$ focal plane along $y$-direction, where $q \in \{1, \dots, Y\}$, and $I_{x_r}$ is a $yz$ section with $r^\text{th}$ focal plane along $x$-direction, where $r \in \{1, \dots, X\}$. In addition, let $I_{\left(r_i:r_f,q_i:q_f,p_i:p_f\right)}$ be a subvolume of $I$, whose $x$-coordinate is $r_i \leq x \leq r_f$, $y$-coordinate is $q_i \leq y \leq q_f$, and $z$-coordinate is $p_i \leq z \leq p_f$. For example, $I_{\left(241:272,241:272,131:162\right)}$ is a subvolume of $I$ where the subvolume is cropped between $241^\text{st}$ slice and $272^\text{nd}$ slice in $x$-direction, between $241^\text{st}$ slice and $272^\text{nd}$ slice in $y$-direction, and between $131^\text{st}$ slice and $162^\text{nd}$ slice in $z$-direction. As shown in Figure \ref{fig:blockdiagram}, we divide an original florescence microscopy volume denoted as $I^{O}$ into two subvolumes such as an out-of-focus and noisy subvolume and a well-defined subvolume denoted as $I^{OA}$ and $I^{OB}$, respectively. In particular, we choose $I^{OA}$ from deep sections and $I^{OB}$ from shallow sections since shallow sections of fluorescence microscopy volumes typically have a better image quality than deep sections. These two volumes are sliced in the $z$-, $y$-, and $x$-direction to form the $xy$, $xz$, and $yz$ sections of the images. Then, the $xy$ sections from $I^{OA}$ and $I^{OB}$ are used for the training of the SpCycleGAN \cite{bib:CFu2018} to obtain the trained generative network denoted as $G_{AB}^{xy}$. Similarly doing this with the $xz$ sections and the $yz$ sections, trained generative networks $G_{AB}^{xz}$ and $G_{AB}^{yz}$ are obtained. These generative networks are used for inference with a test volume denoted as $I^{OT}$ in the $xy$, $xz$, and $yz$ sections. Next, these synthetically generated results by the SpCycleGAN inference are stacked with $z$-, $y$-, and $x$-direction to form 3D volumes denoted as $I^{STxy}$, $I^{STxz}$, and $I^{STyz}$, respectively. Finally, we obtain the final volume $I^F$ by voxelwise weighted averaging of these volumes. \vspace{-0.05in} \subsection{Spatially Constrained CycleGAN (SpCycleGAN)} \vspace{-0.05in} This SpCycleGAN was introduced in our previous work \cite{bib:CFu2018} which extended the CycleGAN \cite{bib:CycleGAN} by adding one more term to the loss function and introducing an additional generative network. The SpCycleGAN was used for generating synthetic microscopy volumes from a synthetic binary volume. One problem with the CycleGAN is that the generated images sometimes are misaligned with the input images. We added a spatial constrained term ($\mathcal{L}_{spatial}$) to the loss function and minimize the loss function together with the two original GAN losses ($\mathcal{L}_{\text{GAN}}$) and the cycle consistent loss ($\mathcal{L}_{cyc}$) as: \vspace{-0.2in} \begin{align}\label{eq:LSpCycleGAN} \mathcal{L}(G_{AB}, G_{BA}, H, D_A, D_B) &= \mathcal{L}_{\text{GAN}}(G_{AB},D_B,I^{OA}, I^{OB}) \nonumber \\ &+ \mathcal{L}_{\text{GAN}}(G_{BA},D_A,I^{OB},I^{OA}) \nonumber \\ &+ \lambda_1 \mathcal{L}_{cyc}(G_{AB},G_{BA}, I^{OA},I^{OB}) \nonumber \\ &+ \lambda_2 \mathcal{L}_{spatial}(G_{AB},H,I^{OA},I^{OB}) \end{align} \vspace{-0.1in} where \\ \resizebox{1.00\hsize}{!} { \begin{minipage}{\linewidth} \begin{align} \mathcal{L}_{\text{GAN}}(G_{AB},D_B,I^{OA}, I^{OB}) &= \mathbb{E}_{I^{OB}}[\text{log}({D_B (I^{OB})})] \nonumber \\ &+ \mathbb{E}_{I^{OA}}[\text{log}(1 - {D_B (G_{AB} (I^{OA})))}] \nonumber \end{align} \end{minipage} } \\ \resizebox{1.00\hsize}{!} { \begin{minipage}{\linewidth} \begin{align} \mathcal{L}_{\text{GAN}}(G_{BA},D_A,I^{OB},I^{OA}) &= \mathbb{E}_{I^{OA}}[\text{log}({D_A (I^{OA})})] \nonumber \\ &+ \mathbb{E}_{I^{OB}}[\text{log}(1 - {D_A (G_{BA} (I^{OB})))}] \nonumber \end{align} \end{minipage} } \\ \resizebox{1.00\hsize}{!} { \begin{minipage}{\linewidth} \begin{align} \mathcal{L}_{cyc}(G_{AB},G_{BA},I^{OA},I^{OB}) &= \mathbb{E}_{I^{OA}}[|| G_{BA}(G_{AB}(I^{OA})) - I^{OA} ||_1] \nonumber \\ &+ \mathbb{E}_{I^{OB}}[|| G_{AB}(G_{BA}(I^{OB})) - I^{OB} ||_1] \nonumber \end{align} \end{minipage} } \\ \resizebox{1.00\hsize}{!} { \begin{minipage}{\linewidth} \begin{align} \mathcal{L}_{spatial}(G_{AB}, H, I^{OA},I^{OB}) &= \mathbb{E}_{I^{OA}}[|| H(G_{AB}(I^{OA})) - I^{OA} ||_2] \nonumber. \end{align} \end{minipage} } \vspace{0.01in} \\ \noindent Note that $\lambda_1$ and $\lambda_2$ are the controllable coefficients for $\mathcal{L}_{cyc}$ and $\mathcal{L}_{spatial}$. Also, $|| \cdot ||_1$ and $|| \cdot ||_2$ represent $L_1$ and $L_2$ norms, respectively. The generative model $G_{AB}$ transfers $I^{OA}$ to $I^{OB}$ and the generative model $G_{BA}$ transfers $I^{OB}$ to $I^{OA}$. Similarly, the discriminative model $D_A$ and $D_B$ distinguish between $I^{OA}$ and $G_{BA}(I^{OB})$ and between $I^{OB}$ and $G_{AB}(I^{OA})$. In particular, $G_{AB}(\cdot)$ is a transfer function using model $G_{AB}$ and $G_{BA}(\cdot)$ is another transfer function using model $G_{BA}$. For example, $G_{AB}(I^{OA})$ is a synthetically restored volume generated by model $G_{AB}$ using a blurred and noisy volume. Also, $G_{BA}(I^{OB})$ is a synthetically generating blurred and noisy volume by model $G_{BA}$ using a well-defined volume. Additionally, another generative model $H$ takes $G_{AB}(I^{OA})$ as an input to generate a synthetically blurred and noisy volume $H(G_{AB}(I^{OA}))$ using synthetically restored volume. This generative model $H$ minimizes $\mathcal{L}_2$ loss between $I_{OA}$ and $H(G_{AB}(I^{OA}))$. \begin{figure*}[htb!] \centering \subfloat[] {\label{fig:WSM_B_testA}\includegraphics[width=0.14\textwidth]{WSM_B_testA_z126y256_box}} \ \subfloat[] {\label{fig:WSM_B_PSFSynRL}\includegraphics[width=0.14\textwidth]{WSM_B_PSFsynRL_z126y256_box}} \ \subfloat[] {\label{fig:WSM_B_EpiDEMIC}\includegraphics[width=0.14\textwidth]{WSM_B_EpiDEMIC_z126y256_box}} \ \subfloat[] {\label{fig:WSM_B_PureDenoise}\includegraphics[width=0.14\textwidth]{WSM_B_PureDenoise_z126y256_box}} \ \subfloat[] {\label{fig:WSM_B_iterVSTpoissonDeb}\includegraphics[width=0.14\textwidth]{WSM_B_iterVSTpoissonDeb_z126y256_box}} \ \subfloat[] {\label{fig:WSM_B_3DacIC}\includegraphics[width=0.14\textwidth]{WSM_B_3DacIC_z126y256_box}} \ \subfloat[] {\label{fig:WSM_B_SpCycleGAN3ways}\includegraphics[width=0.14\textwidth]{WSM_B_SpCycleGAN3ways_z126y256_box}} \\ \vspace{-0.1in} \subfloat[] {\label{fig:WSM_R_testA}\includegraphics[width=0.14\textwidth]{WSM_R_testA_z126y256_box}} \ \subfloat[] {\label{fig:WSM_R_PSFSynRL}\includegraphics[width=0.14\textwidth]{WSM_R_PSFsynRL_z126y256_box}} \ \subfloat[] {\label{fig:WSM_R_EpiDEMIC}\includegraphics[width=0.14\textwidth]{WSM_R_EpiDEMIC_z126y256_box}} \ \subfloat[] {\label{fig:WSM_R_PureDenoise}\includegraphics[width=0.14\textwidth]{WSM_R_PureDenoise_z126y256_box}} \ \subfloat[] {\label{fig:WSM_R_iterVSTpoissonDeb}\includegraphics[width=0.14\textwidth]{WSM_R_iterVSTpoissonDeb_z126y256_box}} \ \subfloat[] {\label{fig:WSM_R_3DacIC}\includegraphics[width=0.14\textwidth]{WSM_R_3DacIC_z126y256_box}} \ \subfloat[] {\label{fig:WSM_R_SpCycleGAN3ways}\includegraphics[width=0.14\textwidth]{WSM_R_SpCycleGAN3ways_z126y256_box}} \\ \vspace{-0.1in} \caption{Comparison of the original volume and 3D restored volume results with the $xy$ and $xz$ sections of \textit{Dataset-I} (up) and \textit{Dataset-II} (down) using various methods. First column: Test volume $xy$ section ($I^{OT}_{z126}$) and $yz$ section ($I^{OT}_{y256}$), Second column: RL \cite{bib:Richard1972, bib:Lucy1974}, Third column: EpiDEMIC \cite{bib:Soulez2014}, Fourth column: PureDenoise \cite{bib:PureDenoise}, Fifth column: iterVSTpoissonDeb \cite{bib:Azzari2017}, Sixth column: 3DacIC \cite{bib:SLee2017}, Seventh column: 3-Way SpCycleGAN (Proposed)} \label{fig:visual_comparison1} \vspace{-0.25in} \end{figure*} \vspace{-0.05in} \subsection{3-Way SpCycleGAN and Volumes Averaging} \vspace{-0.05in} One drawback of the SpCycleGAN is that it works only in 2D. Since our fluorescence microscopy data is a 3D volume, we form the 3D volume by stacking 2D images obtained from different focal planes during data acquisition \cite{bib:DeconvolutionLab2}. Therefore, we employ $3$-Way SpCycleGAN training which uses the SpCycleGAN in the $xy$, $xz$, and $yz$ sections independently and obtain the generative models per each sections. We use three generative models ($G_{AB}^{xy}$, $G_{AB}^{xz}$, and $G_{AB}^{yz}$) for the inference using $I^{OT}$ which transfer noisy and out-of-focus images to well-defined and focused images in the $xy$, $xz$, and $yz$ sections. More specifically, the test volume is sliced into three sets of sectional images and each image is used as an input of inference to generate synthetic well-defined and focused image. Then, these synthetically generated images are stacked in the $z$-, $y$-, and $x$-direction to form $I^{STxy}$, $I^{STxz}$, and $I^{STyz}$, respectively. In general, the number of the $xy$, $xz$, and $yz$ sections are different from each other, we use zero padding to make the dimension of three volumes identical. Lastly, the final volume ($I^F$) is obtained as \begin{equation} I^F = w_1 I^{STxy} + w_2 I^{STxz} + w_3 I^{STyz} \end{equation} where $w_1$, $w_2$, and $w_3$ are weight coefficients of $I^{STxy}$, $I^{STxz}$, and $I^{STyz}$, respectively. \section{EXPERIMENTAL RESULTS} \label{sec:experimental_results} \vspace{-0.05in} The performance of our proposed deconvolution method was tested on two different datasets:\footnote{\textit{Dataset-I} and \textit{II} were provided by Malgorzata Kamocka of the Indiana Center for Biological Microscopy.} \textit{Dataset-I} and \textit{II}. \textit{Dataset-I} and \textit{II} are originally obtained at the same time with different fluorophores to delineate different biological structures. \textit{Dataset-I} and \textit{II} are both comprised of $Z = 512$ grayscale images, each of size $X \times Y = 512 \times 512$ pixels. We selected a blurred and noisy subvolume ($I^{OA}$) from last $200$ images of given fluorescence microscopy volume as $I^{O}_{(1:512,1:512,313:512)}$ with a size of $512 \times 512 \times 200$ for \textit{Dataset-I} and \textit{II}. Also, a good quality subvolume ($I^{OB}$) was selected based on a biologist's opinion as $I^{O}_{(1:512,1:512,15:214)}$ with size of $512 \times 512 \times 200$ for \textit{Dataset-I} and \textit{II}. The test volume ($I^{OT}$) for each dataset was selected at deeper tissue depth than $I^{OB}$ as $I_{(1:512,1:512,215:512)}^{O}$ with size of $512 \times 512 \times 298$. Our $3$-Way SpCycleGAN is implemented in PyTorch using the Adam optimizer \cite{bib:Kingma2014} with constant learning rate $0.0002$ for the first $100$ epochs and gradually decreased to $0$ for the next $100$ epochs. Also, we use the ResNet $9$ blocks \cite{bib:ResNet} for all generative models ($G_{AB}$, $G_{BA}$, and $H$) with $64$ feature maps at the first layer. For the corresponding discriminative models ($D_A$ and $D_B$), same discriminative models are used in the CycleGAN \cite{bib:CycleGAN}. We randomly select patches size of $256 \times 256$ from $512 \times 512$ for the $xy$ sections and $200 \times 200$ from $512 \times 200$ for the $xz$ and $yz$ sections for the SpCycleGAN training, respectively. We choose larger resolution for the $xy$ sections since $xy$ sections is a finer resolution than those $xz$ and $yz$ sections. Also, we set the coefficients $\lambda_1 = \lambda_2 = 10$ for all $3$-Way SpCycleGAN training for both \textit{Dataset-I} and \textit{II}. Lastly, the weights for $3$-way volume averaging is set as $w_1 = w_2 = w_3 = 1/3$ so that each sectional results equally contribute the final volume. \begin{table*}[htb!] \centering \renewcommand{\tabcolsep}{3pt} {\begin{tabular}{|c||c|c|c||c|c|c|} \hline & \multicolumn{3}{c||}{$I^{OT}_{(1:512,1:512,149:298)}$ of the \textit{Dataset-I}} & \multicolumn{3}{c|}{$I^{OT}_{(1:512,1:512,149:298)}$ of the \textit{Dataset-II}} \\ \hline \multirow{2}{*}{Method} & 3-Way & 3-Way & 3-Way & 3-Way & 3-Way & 3-Way \\ & BRISQUE \cite{bib:BRISQUE} & OG-IQA \cite{bib:OGIQA} & Microscopy IFQ \cite{bib:Yang2018} & BRISQUE \cite{bib:BRISQUE} & OG-IQA \cite{bib:OGIQA} & Microscopy IFQ \cite{bib:Yang2018} \\ \hline \textit{$I^{OT}_{(1:512,1:512,149:298)}$} & $35.50$ & $-0.34$ & $1.95$ & $\mathbf{15.68}$ & $-0.64$ & $3.07$ \\ \hline RL \cite{bib:Richard1972, bib:Lucy1974} & $41.19$ & $-0.80$ & $0.67$ & $23.97$ & $-0.49$ & $3.98$ \\ \hline EpiDEMIC \cite{bib:Soulez2014} & $58.96$ & $-0.75$ & $0.62$ & $50.97$ & $-0.29$ & $0.96$ \\ \hline PureDenoise \cite{bib:PureDenoise} & $39.90$ & $-0.67$ & $2.04$ & $24.40$ & $-0.47$ & $3.34$ \\ \hline iterVSTpoissonDeb \cite{bib:Azzari2017} & $35.01$ & $-0.44$ & $2.84$ & $32.38$ & $-0.36$ & $4.05$ \\ \hline 3DacIC \cite{bib:SLee2017} & $37.96$ & $-0.26$ & $0.66$ & $19.68$ & $-0.61$ & $1.64$ \\ \hline 3-Way SpCycleGAN & \multirow{2}{*}{$\mathbf{34.05}$} & \multirow{2}{*}{$\mathbf{-0.88}$} & \multirow{2}{*}{$\mathbf{0.52}$} & \multirow{2}{*}{$31.14$} & \multirow{2}{*}{$\mathbf{-0.82}$} & \multirow{2}{*}{$\mathbf{0.94}$} \\ (Proposed) & & & & & & \\ \hline \end{tabular} } \vspace{-0.1in} \caption{Comparison of the performance of proposed and other restoration methods with three image quality metrics using \textit{Dataset-I} and \textit{II}} \label{tab:results_comp_number} \vspace{-0.25in} \end{table*} Our proposed deconvolution results were visually compared with five different techniques including RL \cite{bib:Richard1972, bib:Lucy1974}, EpiDEMIC \cite{bib:Soulez2014}, PureDenoise \cite{bib:PureDenoise}, iterVSTPoissonDeb \cite{bib:Azzari2017}, and 3DacIC \cite{bib:SLee2017} shown in Figure \ref{fig:visual_comparison1}. Note that we used default settings for the methods RL and PureDenoise in ImageJ plugins, EpiDEMIC in Icy plugin, and iterVSTpoissonDeb. As shown in Figure \ref{fig:visual_comparison1}, first column displays a sample $xy$ section ($I^{OT}_{z126}$) and $xz$ section ($I^{OT}_{y256}$) of original test volumes in \textit{Dataset-I} and \textit{II}, respectively. The original test volumes suffer from significant intensity inhomogeneity, blur, and noise. Also, this degradation gets worse at deeper depth as shown in the $xz$ section. As observed, our proposed method showed the best performance among presented methods in terms of inhomogeneity correction, clarity of the shape of nuclei and tubules/glomeruli structure, and noise level. More specifically, two deconvolution methods (RL and EpiDEMIC) successfully reduced blur but the original shapes of the biological structures were lost. Also, EpiDEMIC's $xz$ section deconvolution results were all connected each other since EpiDEMIC learned 2D features as a prior to enhance 3D. Similarly, two denoising methods (PureDenoise and iterVSTpoissonDeb) successfully suppressed Poisson noise but these denoising results were still suffered from intensity inhomogeneity and blur. In fact, the denoising results added more blur than original test volume. Meanwhile, 3DacIC method successfully corrected inhomogeneity but this method amplified background noise level and aggravated image quality. Moreover, 3DacIC exacerbated line shape noise shown in the $xz$ sections. In addition to the visual comparison, three image quality metrics were utilized for evaluating volume quality of restored volumes of proposed and other presented methods. Since our microscopy volumes do not have reference volumes to compare, we need to use no reference image quality assessment (NR-IQA) \cite{bib:BRISQUE} instead of traditional PSNR, SSIM, and FSIM. One problem is that there is no gold standard image quality metric for 3D fluorescence microscopy. We employed the blind/referenceless image spatial quality evaluator (BRISQUE) \cite{bib:BRISQUE}, the oriented-gradient image quality assessment (OG-IQA) \cite{bib:OGIQA}, and the microscopy image focus quality assessment (Microscopy IFQ) \cite{bib:Yang2018} for evaluating quality of restored microscopy volumes. In particular, BRISQUE model is a regression model learned from local statistics of natural scenes in the spatial domain to measure image quality where the quality value range is from $0$ to $100$. OG-IQA model is a gradient feature based model that maps from image features to image quality via an adaboosting back propagation neural network where the quality value is from $-1$ to $1$. Lastly, Microscopy IFQ measures discrete defocus level from $0$ to $10$ using $84 \times 84$ local patches using a CNN. Instead of using discrete defocus level, we got a probability ($p(l)$) for each corresponding defocus level ($l$) before the softmax layer and used these probabilities and corresponding defocus levels to obtain expected value which defined as \vspace{-0.1in} \begin{equation} \text{Microscopy IFQ} = \sum_{l=0}^{10} l \cdot p(l). \vspace{-0.05in} \end{equation} Since this Microscopy IFQ value was obtained for each individual $84 \times 84$ local patches, we resized our images to be nearest integer multiple of local patch size and took an average through entire image. Note that the smaller values of all three image quality assessments indicate the better image quality. In addition, since these three image quality assessments can only measure the quality of 2D images, we again utilized $3$-way idea to obtain the image quality of the $xy$, $xz$, and $yz$ sections and took an average of them. The end result was a single representative value for volume quality per each volume. We used these three image quality metrics to test seven different volumes including the original test volume. This is provided in Table \ref{tab:results_comp_number}. Note that we selected the $150$ most blurred and noisy image volumes from test volume as $I^{OT}_{(1:512,1:512,149:298)}$ for the evaluation purpose. As mentioned above the smaller values are considered to be indicators of the better image volume quality. As observed in Table \ref{tab:results_comp_number}, our proposed method outperformed the other methods and original volume except from $3$-Way BRISQUE in \textit{Dataset-II}. This is because BRISQUE measures the quality from natural image statistics and this model is a favor of blurred volume. Therefore, RL and EpiDEMIC had higher values in BRISQUE image quality metric. Similarly, OG-IQA is a gradient based measurement so edge preserved restoration volume can get smaller image quality values. Also, Microscopy IFQ is a defocus level measurement. Hence, PureDenoise and iterVSTpoissonDeb had sometimes higher OG-IQA and Microscopy IFQ. 3DacIC produced reasonably lower values for the $xy$ sections but the quality of the $xz$ and $yz$ sections were poor so that the entire volume quality was inferior than proposed method's volume quality. \begin{figure}[htb!] \centering \subfloat[] {\label{fig:WSM_B_testA}\includegraphics[width=0.15\textwidth]{WSM_B_testA_z126y256_box2}} \,\ \subfloat[] {\label{fig:WSM_B_SpCycleGAN3ways}\includegraphics[width=0.15\textwidth]{WSM_B_SpCycleGAN3ways_z126y256_box2}} \,\ \subfloat[] {\label{fig:WSM_B_SpCycleGANxy}\includegraphics[width=0.15\textwidth]{WSM_B_SpCycleGANxy_z126y256_box2}} \vspace{-0.15in} \caption{Comparison of original test volume $xy$ section ($I^{OT}_{z126}$) and $yz$ section ($I^{OT}_{y256}$), restored volume using proposed $3$-Way SpCycleGAN, and restored volume using the $xy$ sections of SpCycleGAN using \textit{Dataset-I}} \label{fig:visual_comparison2} \vspace{-0.2in} \end{figure} Lastly, Figure \ref{fig:visual_comparison2} portrays the visual comparison between proposed $3$-Way SpCycleGAN and SpCycleGAN using the $xy$ sections only ($w_1 = 1$, $w_2 = w_3 = 0$). Without having $z$-direction information, SpCycleGAN using the $xy$ sections cannot correctly restore the glomerulus displayed in the red box. Also, the $z$-direction images are frequently discontinued as shown in the $xz$ section in the green box. Compared to that, proposed $3$-Way SpCycleGAN can successfully restore glomerulus and connect smoothly in $z$-direction. \vspace{-0.05in} \section{CONCLUSION AND FUTURE WORK} \label{sec:conclusion} \vspace{-0.1in} This paper has presented a blind image deconvolution method for fluorescence microscopy volumes using the $3$-Way SpCycleGAN. Using the $3$-Way SpCycleGAN, we can successfully restore the blurred and noisy volume to good quality volume so that deeper volume can be used for the biological research. Future work will include developing a 3D segmentation technique using our proposed deconvolution method as a preprocessing step. \vspace{-0.05in} \bibliographystyle{IEEEbib}
{'timestamp': '2019-04-24T02:00:12', 'yymm': '1904', 'arxiv_id': '1904.09974', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.09974'}
arxiv
\section*{Abstract} Age of Information (AoI) is studied in two-user broadcast networks with feedback, and lower and upper bounds are derived on the expected weighted sum AoI of the users. In particular, a class of simple coding actions is considered and within this class, randomized and deterministic policies are devised. Explicit conditions are found for symmetric dependent channels under which coded randomized policies strictly outperform the corresponding uncoded policies. Similar behavior is numerically shown for deterministic policies. \begin{IEEEkeywords} Age of Information, Network Coding, Randomized Policy, Max-Weight Policy, Feedback, Broadcast Packet Erasure Channels \end{IEEEkeywords} \section{Introduction}\label{sec: Introduction} Sending status updates in a timely manner has significant importance in the Internet of Things (IoT) applications. In practice, it is not always effective to update the information as fast as possible for it may cause further delay in the network queues. To measure the timeliness of information at a remote system, the concept of Age of Information (AoI) was introduced in \cite{Tutorial-Kaul, 2011-S.Kaul, 2012-S.Kaul}. AoI measures, at the receiving side, how much time has passed since the generation time of the latest received packet. In \cite{2012-S.Kaul}, a single source and server setup were considered under First-Come First-Serve (FCFS) queue management and it was shown that there is an optimal update rate that minimizes time-average AoI. Further extensions to networks of multiple sources and servers with and without packet management were studied in \cite{2012-S.K.Kaul, 2014-C.Kam, 2016-C.Kam, 2016-M.Costa, 2019-R.D.Yates}. More recently, AoI has been studied as a performance metric in various contexts such as source and channel coding \cite{2018-J.Zhong, 2018-P.Mayekar, 2018-R.Devassy}, caching \cite{ 2017-C.Kam, 2017-R.D.Yates, 2018-S.Zhang}, energy harvesting \cite{2018-A.Arafa, 2018-A.Arafa1, 2018-S.Feng}, sampling \cite{2018-J.Yun, 2018-1806.03487, 2019-TasmeenZaman} and scheduling \cite{2018-Q.He, 2018-C.Joo, 2015-B.Li, 2016-B.Li, 2018-I.Kadota, 2018-IgorKadota, 2018-R.Talak, 2018-R.Talak1, 2018-R.Talak2}. In coding theory, previous work has mainly studied point to point channels. For example, \cite{2016-K.Chen,2017-R.D.Yates1,2017-P.Parag} consider erasure channels, propose coding schemes, and analyze the resulting average or peak AoI in various setups. More recently, \cite{2019-E.Najm} proves that when the source alphabet and channel input alphabet have the same size, a Last-Come First-Serve (LCFS) with no buffer policy is optimal. Considering erasure channels with FCFS M/G/1 queues, \cite{2018-H.Sac} finds an optimal block length for channel coding to minimize the average age and average peak age of information. AoI has also been investigated in network management and scheduling. In particular, \cite{2018-Q.He} proposes scheduling policies to optimize the overall age in a wireless network. Maintaining equally up-to-date and synchronized information from multiple sources is studied in \cite{2018-C.Joo}. In \cite{2018-IgorKadota}, scheduling algorithms are designed to minimize AoI in wireless broadcast channels. \cite{2018-I.Kadota} devises scheduling policies to minimize average AoI under throughput constraints in wireless multi-access networks. The minimum age of time-varying wireless channels with interference constraints is obtained in \cite{2018-R.Talak,2018-R.Talak1,2018-R.Talak2} with and without channel state information. In this work, we aim to shed light on the interplay between AoI and (channel/network) coding in the context of broadcast packet erasure channels (BPECs) with feedback. BPECs and their variants have been investigated in previous work such as \cite{2009-L.Georgiadis,2010-C.Wang, 2012-M.Gatzianas, 2013-M.Gatzianas, 2018-M.Heindlmaier} and rate-optimal coding algorithms are designed using (network) coding ideas. The key idea is due to \cite{2009-L.Georgiadis} where it is shown that the entire capacity region of two-user BPECs with feedback can be attained by XOR-ing overheard packets. More precisely, suppose a packet $p$, intended for user~$1$, is broadcasted and only received at user~$2$. Scheduling algorithms re-transmit this packet because it is not received at its intended receiver. However, one may be able to exploit coding opportunities by tracking such packets (and this is possible through the available feedback). For example, in a similar manner, a packet $q$, intended for user $2$, may get transmitted and received only at receiver $1$. Now instead of re-transmitting $p$ and $q$ in two uses of the network, one can transmit the XOR packet $p\oplus q$ which is simultaneously useful for both users. As opposed to the aforementioned literature, in this work, we seek {\it efficiency in terms of age as opposed to rate}. The underlying challenge is as follows. On the one hand, the highest rate of communication in BPECs can be attained when coding is employed across packets of different users \cite{2009-L.Georgiadis}. A higher rate effectively corresponds to a smaller delay (both in the sense that the queues get emptied faster and in the sense that fewer uses of the network are needed in total to transmit a fixed number of information bits). On the other hand, to achieve high rates with coding, we have to incur delay by waiting for the arrival of other packets for the purpose of coding as well as prioritizing their transmission. So it is not clear apriori when coding is beneficial. We will devise scheduling policies that {\it schedule different coding actions}, as opposed to traditional schemes that schedule different users, and show the benefit of coding in terms of average age over uncoded schemes such as those proposed in \cite{2018-IgorKadota}. Motivated by the capacity achieving coding scheme of \cite{2009-L.Georgiadis}, in this work we restrict attention to a class of coding algorithms consisting of three actions: uncoded transmission for user $1$, uncoded transmission for user $2$, and coded (XOR-ed) transmission for both users. We consider a discrete time model as in \cite{2018-IgorKadota} and study the expected weighted sum of AoI (EWSAoI) at the users. The first contribution of the paper is a general lower bound on the achievable EWSAoI. As opposed to previous lower bounds (e.g. \cite{2018-IgorKadota}) that hold only in the class of traditional scheduling algorithms, the new lower bound is valid for any coding scheme. The second contribution of the paper is the devise and analysis of EWSAoI or an upper bound on it for (i) stationary randomized policies and (ii) deterministic Max-Weight (MW) policies. In the class of randomized policies, for symmetric channels, we find conditions under which coded policies perform strictly better than their corresponding uncoded policies. For MW policies, we numerically compare the performance of coded and uncoded MW policies and show gains of coding. The remainder of this paper is organized as follows. The problem setup and notation are introduced in Section~\ref{sec: Basic model}. Section~\ref{sec: lower bound} presents a general lower bound on EWSAoI. In Section~\ref{sec: stationary randomized policy}, we devise a randomized policy based on three coding actions and find a closed-form expression for the resulting EWSAoI. We further study the special case of symmetric BPECs and find conditions under which coded randomized policies strictly outperform uncoded randomized policies in terms of age. In Section~\ref{sec: Standard Max-Weight Policies}, we propose a Max-Weight policy and derive an upper bound on the resulting EWSAoI. Simulation results and the comparison of uncoded vs. coded schemes are presented in Section~\ref{sec: Numerical results and discussions}. \section{System Model}\label{sec: Basic model} We consider a model where time is slotted. At the beginning of every time slot, new packets are generated for the users and they replace any undelivered packets from previous time slots. Our model is similar to \cite{2018-I.Kadota, 2018-IgorKadota}, where users are scheduled with the goal of minimizing age. Transmission occurs on a noisy network which we model by a broadcast packet erasure channel with two users. In each time slot $k$, the input $X(k)$ to the channel is a packet. The packet is successfully delivered to user $i$ with probability $1-\epsilon_{i}$, $0\leq\epsilon_{i}<1$, and lost with probability $\epsilon_i$. Let $Z_i(k)$ be a random variable modeling erasure at user $i\in\{1,2\}$ in time slot $k\in\{1,2,\ldots\}$. We assume that the channel is memoryless and hence $\{Z_i(k)\}_{k=1}^\infty$ is an iid Bernoulli process with probability $1-\epsilon_i$. The output of the channel at user $i$ in slot $k$ is: \begin{align*} Y_i(k)=\left\{\begin{array}{cc}X(k) &\text{if }Z_i(k)=1\\\Delta&\text{otherwise}\end{array}\right. \end{align*} where $\Delta$ is a symbol denoting erasure. Note that the pairs $\{(Z_1(k),Z_2(k))\}_k$ are independent across time (over $k=1,2,\ldots$) but potentially correlated across $(Z_1, Z_2)$. In addition, the feedback is available at the encoder after each transmission. Define $\epsilon_1,\epsilon_2,\epsilon_{12}$ as \begin{align*} \epsilon_{1}:=&\Pr(Z_1=0)\\ \epsilon_2:=&\Pr(Z_2=0)\\ \epsilon_{12}:=&\Pr(Z_1=0,Z_2=0), \end{align*} and hence we have \begin{align*} \Pr(Z_1=1,Z_2=0)=&\epsilon_{2}-\epsilon_{12}\\ \Pr(Z_1=0,Z_2=1)=&\epsilon_{1}-\epsilon_{12}. \end{align*} The statistics of $(Z_1,Z_2)$ that describes the channel is assumed fixed and given and can be characterized by $(\epsilon_1,\epsilon_2,\epsilon_{12})$. We consider a simple class of coding algorithms that consists of three actions, including a network coding action. The encoder is modeled by a network of virtual queues. Let $Q_{1}^{(i)}$ denote the queue of incoming packets for user $i$ and $Q_2^{(i)}$ denote the queue of packets that are intended for user $i$ but are received only by the other user. The encoder can track such packets using the available feedback. For $i=\{1,2\}$, we use the notation $\backslash i$ as short for $\{1,2\}\backslash i$. The packets in $Q_2^{(i)}$ are not received at their intended receivers, but are received at the other receiver and act as side information for it -- this can be exploited in the code design at the encoder. In particular, the encoder can XOR packets in $Q_2^{(1)}$ with $Q_2^{(2)}$ and form more efficient coded packets for transmission. In each time slot $k$, the encoder decides between the following three actions, denoted by $A(k)\in\{1,2,3\}$ and defined below:\vspace{-.15cm} \begin{itemize} \item $A(k)\!=\!1$: a packet is transmitted from $Q_{1}^{(1)}$; \item $A(k)\!=\!2$: a packet is transmitted from $Q_{1}^{(2)}$; \item $A(k)\!=\!3$: a coded packet is transmitted from $Q_{2}^{(1)}$, $Q_{2}^{(2)}$. \end{itemize} \begin{figure}[t!] \centering \includegraphics[width=2.5in]{channels} \caption{the virtual network of queues at the encoder} \label{fig_channels1} \end{figure} \begin{definition}[Age of Information \cite{Tutorial-Kaul}]\label{def: AoI} Consider a source-destination pair. Let $\{t_k\}_k$ be the times at which packets are generated and $\{t_{k}'\}_k$ be the times at which packets are received at the destination. At any time $\xi$, denote $N(\xi)=\max\{k|t_{k}'\leq\xi\}$, and $u(\xi)=t_{N(\xi)}$. The Age of Information (AoI) at the destination is $\Delta(t)=t-u(t)$. \end{definition} Using Definition \ref{def: AoI}, let $h_{i}$ be the positive real number that represents the age at user $i$. The age $h_{i}$ increases linearly in time when there is no delivery of packets to user $i$ and drops with every delivery to a value that represents how old the received packet is. \begin{lemma}\label{lem: buffer size 1} To attain the optimal age in the above class of $3-$action coding algorithms, we can assume, without loss of generality, that all queues are of buffer size $1$. \end{lemma} \begin{proof} The proof is presented in Appendix~\ref{App: Lemma buffer size 1}. \end{proof} To capture the evolution of $h_i$ in the class of $3-$action algorithms described, we proceed as follows. First, define $w_{i}(k)$ as the (current) age of information at $Q_{2}^{(i)}$ in slot $k$. If the packet in $Q_{2}^{(i)}$ is successfully delivered at user $i$ by time $k$, then it is removed from $Q_{2}^{(i)}$ and $w_{i}(k)$ is defined to be zero; if a packet in $Q^{(i)}_{2}$ is replaced by a new packet $p$ in slot $k$, then $w_{i}(t)$ is the age of the new packet when $t>k$. More precisely, suppose packet $p$ is generated at time $t_p$. At time $t$, while $p$ is in the queue $Q_{2}^{(i)}$, the age $w(t)$ is $t-t_p$. Finally, once a packet is delivered successfully at user $i$ from $Q_1^{(i)}$, then the existing packet in $Q_2^{(i)}$ (which is necessarily older) becomes obsolete and hence we remove it from $Q_{2}^{(i)}$ and define $w_i(k+1)$ to be $0$. Thus, the recursion of $w_{i}(k)$ is \begin{align}\label{equ: BM-w} \footnotesize w_{i}(k+1)=\left\{\begin{aligned} &0\,\,\text{if}\, A(k)\in\{i,3\},\, Z_i(k)=1\\ &1\,\,\text{if}\, A(k)=i,\, (Z_i(k),Z_{\backslash{i}}(k))=(0,1)\\ &(w_{i}(k)+1)\cdot1_{\{w_{i}(k)>0\}}\,\,\text{otherwise} \end{aligned}\right.. \end{align} Based on $w_{i}(k)$, the age function $h_{i}(k)$ evolves as follows: \begin{align}\label{equ: BM-age} \footnotesize h_{i}(k+1)=\left\{\begin{aligned} &1\quad\text{if}\,\, A(k)=i,\, Z_i(k)=1\\ &w_{i}(k)+1\quad\text{if}\,\, A(k)=3,\, Z_{i}(k)=1\\ &h_{i}(k)+1\quad\text{otherwise} \end{aligned}\right.. \end{align} \begin{remark}\label{w<=h-1} Using the mathematical recursions in \eqref{equ: BM-w} and \eqref{equ: BM-age}, we conclude that $w_{i}(k)\leq h_{i}(k)-1$. \end{remark} \begin{figure}[t!] \centering \includegraphics[width=3.5in]{samplepath} \caption{a sample path of the channel state $(h_{1}, h_{2}, w_{1}, w_{2})$ which initial state $(h_{1},h_{2},w_{1},w_{2})=(3,4,1,2)$} \label{fig_channels2} \end{figure} \subsection{A Sample Path} \label{sec:samplepath} A sample path for the evolution of $w_1,h_1$ and $w_2,h_2$ is shown in Fig. \ref{fig_channels2}. The initial state is $(h_{1},h_{2},w_{1},w_{2})=(3,4,1,2)$, and the actions and the channels are as follows: \begin{center} \begin{tabular}{r|ccccc} $k$&1&2&3&4&5\\ $A(k)$&2&1&1&2&3\\ $(Z_1(k),Z_2(k))$&(1,1)&(1,0)&(0,1)&(1,0)&(1,1)\\ \end{tabular} \end{center} Now consider a general sample path associated with a transmission policy and a finite time-horizon $T$. For this sample path, let $N_{i}(T)$ be the total number of packets delivered to user $i$ up to and including time slot $T$, and $I_{i}(m)$ be the number of time slots between the $(m-1)$th and $m$th deliveries to user $i$, i.e., the inter delivery times of user $i$. Denote the age of user $i$ after delivery of the $m$th packet by $D_{i}(m)$ and let $L_{i}$ be the number of remaining time slots after the last packet delivery to the same user. With this notation, the time-horizon can be written as $T=\sum_{m=1}^{N_{i}(T)}I_{i}(m)+L_{i}$ with $i\in\left\{1,2\right\}$. Next, consider the sum of the instantaneous ages in the interval corresponding to $I_{i}(m)$, $m\geq2$, denoted by $\Delta_{i}[m]$. As shown in Figure \ref{fig_channels2}, $\Delta_{i}[m]$ is equal to the area underneath the age curve in the corresponding interval minus $I_{i}(m)$ small triangle areas; i.e., \begin{align} \footnotesize &\Delta_i[m]=\sum_{k\text{ in between delivery of ${m-1}^{\text{}th}$ and $m^{\text{th}}$ packets}} h_i[k]\\ =&\frac{(D_i(m-1)+I_{i}(m))^{2}}{2}-\frac{(D_i(m-1))^{2}}{2} -\frac{I_i(m)}{2}\\ =&\frac{I_{i}^{2}(m)}{2}+D_i(m-1)I_{i}(m)-\frac{I_i(m)}{2}\label{equ: delta_i[m]}. \end{align} \subsection{The Expected Weighted Sum AoI} Both $w_i(k)$ and $h_i(k)$ and their evolution depend on the policy that we choose and, hence, we sometimes write them as $w_{i}^{\pi}(k)$ and $h_{i}^\pi(k)$. Moreover, we denote the vector $(h_1(1),h_2(1),w_1(1),w_2(1))$ by $\vec{s}(1)$. We aim to find policies $\pi$ that minimize the following EWSAoI at the users: \begin{align}\label{equ: BM-expected weighted sum aoi} \mathbb{E}\left[\frac{1}{2T}\sum_{k=1}^{T}\sum_{i=1}^{2}\alpha_{i}h^{\pi}_{i}(k)\Big|\vec{s}(1) \right] \end{align} where $\alpha_{1}$ and $\alpha_{2}$ are weights associated to users $1$ and $2$, respectively. We assume $\alpha_{i}\geq0$ and $\alpha_{1}+\alpha_{2}=1$. For notational simplicity, we omit $\vec{s}(1)$ hereafter, and hence the minimum age is given by the following optimization problem. \begin{align}\label{equ: BM-optimization} \min_{\pi\in\Pi}\mathbb{E}[J_{T}^{\pi}],\quad\text{where}\quad J_{T}^{\pi}=\frac{1}{2T}\sum_{k=1}^{T}\sum_{i=1}^{2}\alpha_{i}h_{i}^{\pi}(k). \end{align} Since we aim to minimize the EWSAoI in the long run, we define \begin{align*} J^{\pi}=\lim_{T\rightarrow\infty}J_{T}^{\pi}. \end{align*} \section{A Lower Bound}\label{sec: lower bound} We prove a lower bound on EWSAoI as stated below. \begin{theorem}\label{thm: lowerbound} For any communication policy $\pi$, we have: \begin{align} \mathbb{E}[J^{\pi}]\geq\frac{1}{4}\left(\frac{(\sum_{i=1}^{2}\sqrt{\alpha_{i}(2-\epsilon_{12}-\epsilon_{\backslash{i}})})^{2}}{(1-\epsilon_{12})(2-\epsilon_{1}-\epsilon_{2})}+1\right).\end{align} \end{theorem} \begin{remark} The lower bound of Theorem \ref{thm: lowerbound} holds in general and is not restricted to the class of $3-$action coded algorithms that we introduced in Section \ref{sec: Basic model}. \end{remark} \begin{proof} Consider a sample path associated with a transmission policy and a finite time-horizon $T$ (see Section \ref{sec:samplepath}). The EWSAoI as defined in \eqref{equ: BM-expected weighted sum aoi} can be re-written in terms of $\Delta_i(m)$'s: \begin{align}\label{equ: LB-age1} J_{T}^{\pi}=&\frac{1}{2T}\sum_{k=1}^{T}\sum_{i=1}^{2}\alpha_{i}h_{i}(k)\nonumber\\ =&\frac{1}{2}\!\sum_{i=1}^{2}\!\frac{\alpha_{i}}{T}\!\!\left(\!\sum_{m=1}^{N_{i}(T)}\!\!\!\!\Delta_i(m)\!+\!\frac{1}{2}L_i^2\!+\!D_{i}(\hspace{-.05cm}N_{i}(\hspace{-.05cm}T\hspace{-.05cm})\hspace{-.05cm})L_i\!-\!\frac{1}{2}L_i\!\!\right)\!\!. \end{align} Since $D_i(m)\geq 1$ for all $1\leq m\leq N_{i}(T)$, we can lower bound \eqref{equ: delta_i[m]} and hence \eqref{equ: LB-age1} by substituting $D_i(m)=1$. Using similar steps as \cite[Eqns. (9) - (14)]{2018-IgorKadota}, we find \begin{equation}\label{equ: age-4} \begin{aligned} J^{\pi}_{T} \geq\frac{1}{4}\sum_{i=1}^{2}\alpha_{i}\frac{T}{N_{i}(T)}+\frac{1}{4}. \end{aligned} \end{equation} We remark that so far, the lower bound on $J_{T}^{\pi}$ is the same as \cite[Eqn. (7)]{2018-IgorKadota}. We now depart from \cite{2018-IgorKadota} by allowing for the general class of coding and scheduling schemes. Recall that $N_i(T)$ is the total number of packets received by user $i$, $i=1,2$. In the limit of $T\to\infty$, $\frac{N_i(T)}{T}$ is the throughput of user~$i$. We further know the capacity of two-user broadcast packet erasure channels from \cite{2009-L.Georgiadis}. In particular, any non-negative rate pair $(R_1,R_2)$ is achievable if and only if it satisfies the following conditions. \begin{align} &\frac{R_1}{1-\epsilon_1}+\frac{R_2}{1-\epsilon_{12}}\leq 1\label{equ: LB1-throughput1}\\ &\frac{R_1}{1-\epsilon_{12}}+\frac{R_2}{1-\epsilon_{2}}\leq 1\label{equ: LB1-throughput2}. \end{align} Hence, from \eqref{equ: LB1-throughput1} and \eqref{equ: LB1-throughput2}, we have \begin{align} &\lim_{T\rightarrow\infty}\frac{\frac{N_{1}(T)}{T}}{1-\epsilon_1}+\frac{\frac{N_{2}(T)}{T}}{1-\epsilon_{12}}\leq 1\label{equ: LB-throughput1}\\ &\lim_{T\rightarrow\infty}\frac{\frac{N_{1}(T)}{T}}{1-\epsilon_{12}}+\frac{\frac{N_{2}(T)}{T}}{1-\epsilon_{2}}\leq 1\label{equ: LB-throughput2}. \end{align} For notational simplicity, denote $x=\lim_{T\rightarrow\infty}\frac{N_{1}(T)}{T}$ and $y=\lim_{T\rightarrow\infty}\frac{N_{2}(T)}{T}$. Substituting $x$ and $y$ into (\ref{equ: LB-throughput1}) and (\ref{equ: LB-throughput2}), we obtain \begin{align*} &\frac{x}{1-\epsilon_{1}}+\frac{y}{1-\epsilon_{12}}\leq1\\ &\frac{x}{1-\epsilon_{12}}+\frac{y}{1-\epsilon_{2}}\leq1. \end{align*} Re-arranging terms, we obtain \begin{align*} &(1-\epsilon_{12})x+(1-\epsilon_{1})y\leq(1-\epsilon_{12})(1-\epsilon_{1})\\ &(1-\epsilon_{2})x+(1-\epsilon_{12})y\leq(1-\epsilon_{12})(1-\epsilon_{2})\\ \end{align*} and summing the above two inequalities, we get \begin{align} &k_1x+k_2y\leq k_3\label{eq:ineq3} \end{align} where \begin{align*} k_1=&2-\epsilon_{2}-\epsilon_{12}\\ k_2=&2-\epsilon_{1}-\epsilon_{12}\\ k_3=&(1-\epsilon_{12})(2-\epsilon_{1}-\epsilon_{2}). \end{align*} We can now use \eqref{eq:ineq3} along with the Cauchy-Schwarz inequality and write \begin{align*} \Big(\frac{\alpha_{1}}{x}+\frac{\alpha_{2}}{y}\Big)k_3&\geq \Big(\frac{\alpha_{1}}{x}+\frac{\alpha_{2}}{y}\Big)(k_{1}x+k_{2}y)\\ &\geq\left(\sqrt{\alpha_{1}k_1}+\sqrt{\alpha_{2}k_2}\right)^{2}. \end{align*} Re-arranging terms and replacing for $k_1,k_2,k_3$, we find \begin{align*} \Big(\frac{\alpha_{1}}{x}+\frac{\alpha_{2}}{y}\Big)\geq \frac{(\sum_{i=1}^{2}\sqrt{\alpha_{i}(2-\epsilon_{\backslash{i}}-\epsilon_{12})})^{2}}{(1-\epsilon_{12})(2-\epsilon_{1}-\epsilon_{2})} \end{align*} and hence, from \eqref{equ: age-4}, we obtain \begin{align*} J^{\pi}\geq&\lim_{T\rightarrow\infty}\frac{1}{4}\sum_{i=1}^{2}\alpha_{i}\frac{T}{N_{i}(T)}+\frac{1}{4}\\ \geq&\frac{1}{4}\Big(\frac{(\sum_{i=1}^{2}\sqrt{\alpha_{i}(2-\epsilon_{12}-\epsilon_{\backslash{i}})})^{2}}{(1-\epsilon_{12})(2-\epsilon_{1}-\epsilon_{2})}+1\Big). \end{align*} \end{proof} \section{Coded Randomized Policies}\label{sec: stationary randomized policy} Consider a stationary randomized policy where each action is chosen with a fixed probability in each time slot, independent of the system's status. Denote by $\mu_i$ the probability of action $A(k)=i$, $i\in\{1,2,3\}$, $k\in\{1,\ldots\}$, where $\mu_{1}+\mu_{2}+\mu_{3}=1$. Denote the EWSAoI for randomized policies (in the long run) as $\mathbb{E}[J^{R}]$. \subsection{Age Analysis} We will first find the exact EWSAoI of the coded randomized policy. We start with $\Delta_i(m)$ derived in \eqref{equ: delta_i[m]}. Consider $i=1$. The expectation of $\Delta_1(m)$ is \begin{align} &\mathbb{E}[\Delta_1(m)|\vec{s}(1)]\!\\ =&\!\mathbb{E}\left[\frac{I_{1}^{2}(m)}{2}+D_1(m-1)I_{1}(m)-\frac{I_1(m)}{2}\Big|\vec{s}(1)\right]\!\\ =&\frac{\mathbb{E}\left[{I_{1}^{2}}\right]}{2}+\mathbb{E}[D_1]\mathbb{E}[I_{1}]-\frac{\mathbb{E}[I_1]}{2}\label{equ: Randomized policy-(a)}. \end{align} Equality \eqref{equ: Randomized policy-(a)} holds because of the following observations: (i) the processes $\{I_1(m)\}_m$ and $\{D_1(m)\}_m$ are each iid and not dependent on $\vec{s}(1)$ (so we use $I_1$ and $D_1$ to denote the underlying random variables, respectively), and (ii) $I_{1}(m)$ and $D_1(m-1)$ are independent (while $I_1(m)$ and $D_1(m)$ may be dependent). Thus, the EWSAoI of user $1$ is \begin{align} &\lim_{T\to\infty}\frac{1}{T}\sum_{k=1}^T \mathbb{E}[h_1(k)|\vec{s}(1)]\\ =&\lim_{T\to\infty}\frac{1}{T}\sum_{m=1}^{N_1(T)} \mathbb{E}[\Delta_1(m)|\vec{s}(1)]\\ =&\lim_{T\to\infty}\frac{{N_1(T)}}{T}\left(\frac{\mathbb{E}\left[{I_{1}^{2}}\right]}{2}+\mathbb{E}[D_1]\mathbb{E}[I_{1}]-\frac{\mathbb{E}[I_1]}{2}\right)\\ =&\frac{\mathbb{E}\left[I_{1}^{2}\right]}{2\mathbb{E}[I_1]}+\mathbb{E}[D_1]-\frac{1}{2}\label{eq:ageformularandom} \end{align} where \eqref{eq:ageformularandom} holds because the arrival process is a renewal process \cite[Section 3.3, Theorem 3.3.1]{2008-SheldonM.Ross} and hence $\lim_{T\rightarrow\infty}\frac{T}{N_1(T)}=\mathbb{E}[I_1]$. Then, we consider the statistics of $D_{1}$, and find the probability of $\Pr(D_1=d)$ for $d=1,2,\ldots$. For each slot~$k$, \begin{equation}\label{equ: Randomized p(h_1=d)} \begin{aligned} P(h_{1}(k)=1)&=\mu_{1}(1-\epsilon_{1})\\ P(h_{1}(k)=d)&=\mu_{1}\mu_{3}(1-\epsilon_{1})(\epsilon_{1}-\epsilon_{12})\\ &\times (\mu_{1}\epsilon_{12}+\mu_{2}+\mu_{3}\epsilon_{1})^{d-2}\quad d\geq 2. \end{aligned} \end{equation} To find the probability distribution of $D_1$, condition the above probabilities on the event that a packet is delivered to user $1$ at time slot $k$. The probability of this event can be found by summing \eqref{equ: Randomized p(h_1=d)} over all $d\geq 1$: $$P_{\text{delivery}}^{1}=\frac{\mu_1(1-\epsilon_1)(\mu_1+\mu_3)(1-\epsilon_{12})}{1-\mu_{1}\epsilon_{12}-\mu_{2}-\mu_{3}\epsilon_{1}}.$$ We thus find \begin{equation*} \footnotesize \begin{aligned} P(D_{1}=d)=\left\{\begin{array}{ll} \mu_{1}(1-\epsilon_{i})/P_{\text{delivery}}^{1}&d=1\\ \frac{\mu_{1}\mu_{3}(\epsilon_{1}-\epsilon_{12})(1-\epsilon_{1})(\mu_{1}\epsilon_{12}+\mu_{2}+\mu_{3}\epsilon_{1})^{d-2}}{P_{\text{delivery}}^{1}}& d\geq2 \end{array}\right. \end{aligned} \end{equation*} and the expectation of $D_1$ is equal to \begin{equation}\label{equ: R-ED} \footnotesize \begin{aligned} E(D_1)=1+\frac{\mu_3(\epsilon_{1}-\epsilon_{12})}{(\mu_1+\mu_3)(1-\epsilon_{12})(1-\mu_{1}\epsilon_{12}-\mu_{2}-\mu_{3}\epsilon_{1})}. \end{aligned} \end{equation} The distribution of $I_1$ can be found by treating $I_1$ and $D_1$ jointly. First of all, we have $$P(I_{1}=1)=P(I_{1}=1,D_1=1)=\mu_{1}(1-\epsilon_{1}).$$ Then we look at the event of $I_1=\ell$ and $D_1=d$ for $\ell\geq 2, d\leq\ell$ (otherwise, if $d>\ell$, then $\Pr(I_1=\ell, D_1=d)=0$ because the packet in the queue $Q_2^{(1)}$ becomes obsolete once a new packet is delivered to user $1$). So we assume $d\leq\ell$ and consider the following cases: (\romannumeral1) If $d=1$, then a packet was delivered by action $i$ at slot $\ell$. (\romannumeral2) For $d\geq2$, the delivered packet was moved to $Q_2^{(1)}$ at slot $\ell-d+1$, stayed there, and got received at user $1$ at slot $\ell$. Now consider slots $1$ to $\ell-d+1$. Denote by $t$ the first slot in which a packet is received in $Q_{2}^{(1)}$, $1\leq t\leq \ell-d+1$. Then we have the two sub-cases: (\romannumeral2-1) If $t$ exists, then $Q_2^{(1)}$ is empty before $t$, and the delivered packet (another packet different from the delivered packet) moves to $Q_2^{(1)}$ at $t$ when $t=\ell-d+1$ (when $t<\ell-d+1$) and from that point $Q_2^{(1)}$ is non-empty. (\romannumeral2-2) If there is no such slot $t$, which may happen for $d=1$, then $Q_2^{(1)}$ is empty for the entire duration of $\ell$ slots. Considering the above cases, for $\ell=1,2,\ldots$, we can show the following lemma. \begin{lemma}\label{lem: distribution of I_i} The probability distribution of the inter delivery random variable $I_{1}$ is given by \begin{equation}\label{equ: dirstibution of I_i} P(I_{1}=\ell)=\delta_{1} x_{1}^{\ell-1}+\beta_{1} y_{1}^{\ell-1} \end{equation} where $$x_{1}=\mu_1\epsilon_{12}+\mu_{2}+\mu_3$$ $$y_{1}=\mu_1\epsilon_{1}+\mu_{2}+\mu_3\epsilon_1$$ $$\delta_{1}=\mu_1(1-\epsilon_{12})+\frac{\mu_{1}^{2}(\epsilon_{1}-\epsilon_{12})(1-\epsilon_{12})}{-\mu_{1}(\epsilon_{1}-\epsilon_{12})+\mu_{3}(1-\epsilon_{1})}$$ $$\beta_{1}=-\frac{\mu_{1}(\epsilon_{1}-\epsilon_{12})(1-\epsilon_1)}{-\mu_{1}(\epsilon_{1}-\epsilon_{12})+\mu_{3}(1-\epsilon_{1})}\Big({\mu_{1}}+{\mu_3}\Big).$$ \end{lemma} The proof of Lemma~\ref{lem: distribution of I_i} is in Appendix~\ref{App: Lemma 1}. Using Lemma~\ref{lem: distribution of I_i}, we find $\mathbb{E}[I_{1}]$ and $\mathbb{E}[I_{1}^2]$: \begin{align} \mathbb{E}[I_{1}]=&\frac{\delta_{1}}{(1-x_{1})^2}+\frac{\beta_{1}}{(1-y_{1})^2}\label{eq:exp}\\ \mathbb{E}[I_{1}^2]=&\frac{\delta_{1}(1+x_{1})}{(1-x_{1})^3}+\frac{\beta_{1}(1+y_{1})}{(1-y_{1})^3}.\label{eq:second} \end{align} Finally, substituting \eqref{equ: R-ED}, \eqref{eq:exp}, \eqref{eq:second} into \eqref{eq:ageformularandom}, and replacing for the values of $x_i,y_i,z_i$ and $\delta_i, \beta_i$, we find the EWSAoI as given by the following theorem. \begin{theorem}\label{thm: R-age} The $EWSAoI$ of Randomized policy is characterized by \begin{equation}\label{equ: R-randomizedpolicyage} \footnotesize \begin{aligned} &\mathbb{E}[J^{R}]\!=\!\frac{1}{2}\!\sum_{i=1}^{2}\!\alpha_{i}\!\!\left(\!\!\frac{\frac{\mu_3(1-\epsilon_i)}{\left(\mu_i(1-\epsilon_{12})\right)^2}+\frac{-\mu_i(\epsilon_{i}-\epsilon_{12})}{\left((\mu_i+\mu_3)(1-\epsilon_i)\right)^2}}{\frac{\mu_3(1-\epsilon_i)}{\mu_i(1-\epsilon_{12})}+\frac{-\mu_i(\epsilon_{i}-\epsilon_{12})}{(\mu_i+\mu_3)(1-\epsilon_i)}}\right.\\ &\left.\qquad\qquad\qquad\ \ \ +\frac{\mu_3(\epsilon_{i}-\epsilon_{12})}{(\mu_i\!+\!\mu_3)\!(1\!-\!\epsilon_{12})\!(\mu_i(1\!-\!\epsilon_{12})\!\hspace{-.05cm}+\hspace{-.05cm}\!\mu_3(1\!-\!\epsilon_i)\!)}\!\!\right)\!\hspace{-.05cm}. \end{aligned} \end{equation} \end{theorem} \begin{remark} To find an \emph{optimal coded randomized policy} with respect to age, we have to choose the probability vector $(\mu_{1}^{*}, \mu_{2}^{*}, \mu_{3}^{*})$ such that $\mathbb{E}[J^{R}]$ is minimized. \end{remark} \begin{remark} Setting $\mu_3=0$, we recover the EWSAoI of \cite{2018-IgorKadota} which corresponds to uncoded randomized policies. \end{remark} \subsection{Symmetric BPECs} Consider the class of symmetric BPECs. Let the erasure probabilities of channels to users $1$ and $2$ be equal to $\epsilon$ and $\epsilon_{12}$ be the probability of simultaneous erasure at both users. So $\epsilon>\epsilon_{12}$. Note that $\epsilon_{12}$ is either a function of $\epsilon$ or a constant, thus we rewrite $\epsilon_{12}$ as $\epsilon_{12}(\epsilon)$. Denote the probabilities of choosing action $1$ and $2$ by $\mu$, hence the probability of choosing action $3$ is $1-2\mu$ with $0\leq\mu\leq1/2$. For simplicity, let $\alpha_1=\alpha_2=\alpha$. We find regimes of operation where optimal coded randomized policies strictly improve the EWSAoI over uncoded randomized policies such as \cite{2018-IgorKadota}. From Theorem \ref{thm: R-age}, we find the EWSAoI as follows \begin{equation}\label{equ: R-symmetric AoI} \footnotesize \begin{aligned} \mathbb{E}[J^{R}]=&\frac{\alpha}{(1-\epsilon_{12}(\epsilon))(1-\mu)}\\ \times&\Bigg(\frac{(1-\epsilon)^{3}(1-2\mu)(1-\mu)^{2}-(1-\epsilon_{12}(\epsilon))^{2}(\epsilon-\epsilon_{12}(\epsilon))\mu^{3}}{\Big((1-2\mu)(1-\epsilon)^{2}(1-\mu)-\mu^{2}(1-\epsilon_{12}(\epsilon))(\epsilon-\epsilon_{12}(\epsilon))\Big)\mu}\\ +&\frac{(1-2\mu)(\epsilon-\epsilon_{12}(\epsilon))}{(2\epsilon-1-\epsilon_{12}(\epsilon))\mu+1-\epsilon}\Bigg). \end{aligned} \end{equation} First, we get optimal randomized policies (i.e., optimal probabilities) of the symmetric case by the following lemma. \begin{lemma}\label{lem: symmetric case} For any given $\epsilon$, \begin{equation}\label{equ: symmetric case} \footnotesize \mu^{*}=\left\{\begin{aligned} &\frac{\sqrt{1-\epsilon}}{\sqrt{1-\epsilon}+\sqrt{\epsilon-\epsilon_{12}(\epsilon)}}&\quad& \epsilon_{12}(\epsilon)-2\epsilon+1<0\\ &1/2&\quad&\epsilon_{12}(\epsilon)-2\epsilon+1\geq0. \end{aligned}\right. \end{equation} \end{lemma} The proof of Lemma~\ref{lem: symmetric case} is in Appendix~\ref{App: Lemma 3}. From Lemma~\ref{lem: symmetric case}, if $\epsilon_{12}(\epsilon)-2\epsilon+1\geq0$, then the optimal probability of action $1$ (action $2$) is $\mu^{*}=1/2$. In this case, no packets reach the XOR, i.e., action $3$ is never chosen. So coded randomized policies degenerate to uncoded randomized algorithms. Thus coded and uncoded randomized policies reach the same age. If $\epsilon_{12}(\epsilon)-2\epsilon+1<0$, since $\mu^{*}$ is the {\it unique} minimum point of \eqref{equ: R-symmetric AoI} as shown in Appendix~\ref{App: Lemma 3}, then \begin{align*} \mathbb{E}[J^{R}]\big|_{\{\mu^{*}\}}< \mathbb{E}[J^{R}]\big|_{\{\mu=1/2\}} \end{align*} which implies that the age of optimal coded randomized policies is strictly lower than that of optimal uncoded randomized policies. So we arrive at the following result. \begin{theorem}\label{thm: symmetric case} Optimal coded and uncoded randomized policies achieve the same EWSAoI if and only if $\epsilon_{12}(\epsilon)-2\epsilon+1\geq 0$. Otherwise, optimal coded randomized policies strictly outperform uncoded randomized policies. \end{theorem} \begin{remark} When the channels are independent, i.e., $\epsilon_{12}(\epsilon)=\epsilon^{2}$, coded and uncoded randomized policies have the same performance with respect to age. \end{remark} \section{Max-Weight Policies}\label{sec: Standard Max-Weight Policies} \subsection{The Algorithm} In this section, we devise deterministic policies using techniques from Lyapunov Optimization. Denote the EWSAoI for Max-Weight policies (in the long run) as $\mathbb{E}[J^{MW}]$. Denote $\vec{h}(k)=(h_{1}(k),h_{2}(k))$ and $\vec{s}(k)=(h_{1}(k),h_{2}(k),w_{1}(k),w_{2}(k))$. Define the Lyapunov function \begin{align} L(\vec{h}(k))=\frac{1}{2}\sum_{i=1}^{2}\alpha_{i}h_{i}^{2}(k), \end{align} and the one-slot Lyapunov Drift \begin{align} \Theta(\vec{h}(k))=\mathbb{E}[L(\vec{h}(k+1))-L(\vec{h}(k))|\vec{s}(k)]. \end{align} We devise the Max-Weight (MW) policy such that it minimizes the one-slot Lyapunov drift: \begin{definition}\label{def: MW-policy} In each slot $k$, the MW policy chooses the action that has the maximum weight as shown in following Table: \begin{figure}[h!] \begin{tabular}{|c|c|} \hline $\!\!\!A(k)\!\!\!$& Weights\\ \hline $1$&$\frac{\alpha_{1}(1-\epsilon_{1})}{2}h_{1}(k)(h_{1}(k)+2)$ \\ \hline $2$&$\frac{\alpha_{2}(1-\epsilon_{2})}{2}h_{2}(k)(h_{2}(k)+2)$ \\ \hline $3$&$\!\!\frac{1}{2}\sum_i\!\alpha_{i}(\hspace{-.05cm}1\!\hspace{-.05cm}-\hspace{-.05cm}\!\epsilon_{i}\hspace{-.05cm})1_{\!\{w_{i}(k)\!>\!0\}}\hspace{-.05cm}(h_{i}^{2}(k)\!+\!2h_{i}(k)\!\hspace{-.05cm}-\hspace{-.05cm}\!w_{i}^{2}(k)\!\hspace{-.05cm}-\hspace{-.05cm}\!2w_{i}(k)\hspace{-.05cm})\!\!$\\ \hline \end{tabular} \end{figure} \end{definition} \begin{theorem}\label{thm: MW-policy} The MW policy defined in Definition \ref{def: MW-policy} minimizes the one-slot Lyapunov Drift in each slot. \end{theorem} \begin{proof} The proof of Theorem \ref{thm: MW-policy} can be found in Appendix~\ref{App: Theorem 4}. \end{proof} \subsection{The Upper Bound of EWSAoI} While the exact analysis of the resulting EWSAoI is difficult for the above MW policy, we derive an upper bound on it in Theorem \ref{thm: MW-the upper bound}. The proof is deferred to Appendix~\ref{App: Theorem 5}. \begin{theorem}\label{thm: MW-the upper bound} The EWSAoI achieved by the proposed Max-Weight policy is upper bounded by \begin{align*} \mathbb{E}[J^{MW}]\leq\sqrt{\frac{1}{2}\sum_{i=1}^{2}\frac{\alpha_{i}}{\mu_{i}(1-\epsilon_{i})}\sum_{i=1}^{2}\alpha_{i}\Psi_{i}}+\frac{1}{2}\sum_{i=1}^{2}\alpha_{i}\Phi_{i} \end{align*} where $$\Phi_{i}=\frac{1-\mu_{3}P_{ne}^{i}(1-\epsilon_{i})-\mu_{i}(1-\epsilon_{i})}{\mu_{i}(1-\epsilon_{i})}$$ $$\Psi_{i}=1-\mu_{3}P_{ne}^{i}(1-\epsilon_{i})+\frac{\big(1-\mu_{i}(1-\epsilon_{i})-\mu_{3}P_{ne}^{i}(1-\epsilon_{i})\big)^{2}}{\mu_{i}(1-\epsilon_{i})}$$ $$P_{ne}^{i}=\frac{\mu_{i}(\epsilon_{i}-\epsilon_{12})}{\mu_{3}(1-\epsilon_{i})+\mu_{i}(\epsilon_{i}-\epsilon_{12})-\mu_{3}\mu_{i}(1-\epsilon_{i})(\epsilon_{i}-\epsilon_{12})}.$$ \end{theorem} \begin{remark} Setting $\mu_3=0$, we recover the upper bound of \cite{2018-IgorKadota} which corresponds to uncoded randomized policies. \end{remark} \section{Numerical Results and Discussion}\label{sec: Numerical results and discussions} \begin{figure}[ht!] \begin{tikzpicture} \begin{axis} [axis lines=left, width=2.8in, height=2.5in, scale only axis, xlabel=$\epsilon$, ylabel=EWSAoI, xmin=0.5,xmax=.9, ymin=0,ymax=8, xtick={0.1,0.3,0.5,0.7,0.9}, ytick={0,4,8,12,16,20}, legend pos=north west, ymajorgrids=true, grid style=dashed, scatter/classes={ a={mark=+, draw=black}, b={mark=star, draw=black} } ] \addplot[smooth,color=black] coordinates{(0.1,0.7563)(0.15,0.7727)(0.2,0.7914)(0.25,0.8130)(0.3,0.8380)(0.35,0.8672)(0.4,0.9016)(0.45,0.9428)(0.5,0.9926)(0.55,1.0541)(0.6, 1.1316)(0.65,1.2319)(0.7, 1.3664)(0.75,1.5556)(0.8,1.8407)(0.85,2.3174)(0.9,3.2733)(0.95,5.2809) }; \addplot[ color=red, mark=star,] coordinates{(0.1,1.0647)(0.15,1.1274)(0.2,1.1978)(0.25,1.2777)(0.3,1.3689)(0.35,1.4742)(0.4,1.5971)(0.45,1.7423)(0.5,1.9165)(0.55,2.1286)(0.6,2.3847)(0.65,2.7011)(0.7,3.1060)(0.75,3.6491)(0.8,4.4266)(0.85,5.6567)(0.9,7.9711)(0.95,13.9950) }; \addplot[ color=green, mark=square,] coordinates{(0.1,1.0647)(0.15,1.1274)(0.2,1.1978)(0.25,1.2777)(0.3,1.3689)(0.35,1.4742)(0.4,1.5971)(0.45,1.7423)(0.5,1.9165)(0.55,2.1295)(0.6,2.3956)(0.65,2.7379)(0.7,3.1942)(0.75,3.8330)(0.8,4.7913)(0.85,6.3884)(0.9,9.5826)(0.95,19.1652) }; \addplot[ color=blue,dashed, mark=triangle] coordinates{(0.1,0.8275)(0.15,0.8749)(0.2,0.9285)(0.25,0.9892)(0.3,1.0590)(0.35,1.1390)(0.4,1.2306)(0.45,1.3398)(0.5,1.4692)(0.55,1.6252)(0.6,1.8204)(0.65,2.0697)(0.7,2.3985)(0.75,2.8586)(0.8,3.5473)(0.85,4.6932)(0.9,6.9798)(0.95,13.9734) }; \addplot[color=purple, mark=o] coordinates{(0.1,0.8265)(0.15,0.8722)(0.2,0.9241)(0.25,0.9834)(0.3,1.0518)(0.35,1.1304)(0.4,1.2213)(0.45,1.3312)(0.5,1.4619)(0.55,1.6210)(0.6,1.8203)(0.65,2.0778)(0.7,2.4195)(0.75,2.8972)(0.8,3.6165)(0.85,4.8137)(0.9,7.2164)(0.95,14.5141) }; \legend{Lower Bound, Coded Randomized, Uncoded Randomized, Coded Max-Weight, Uncoded Max-Weight} \end{axis} \end{tikzpicture} \caption{EWSAoI as a function of erasure probability for a class of dependent channels with $\epsilon_{12}=\epsilon^{2}/5$.} \label{fig-age1} \end{figure} In this section, we compare the performance of the proposed coded algorithms with the uncoded algorithms in \cite{2018-IgorKadota}. In Figure \ref{fig-age1}, we plot the EWSAoI of optimal coded and uncoded randomized policies, coded and uncoded Max-Weight policies, as well as the lower bound of Theorem \ref{thm: lowerbound}. We have chosen $\alpha_{1}=0.3$, $\alpha_{2}=0.7$, and $\epsilon_{1}=\epsilon_{2}=\epsilon$, where $\epsilon$ varies from $0.5$ to $0.9$. We consider a dependent channel of $\epsilon_{12}=\epsilon^{2}/5$. We see that for the proposed policies, coding is beneficial when the channel erasure is larger than a threshold. Although the gain is small for MW policies, we believe the gain will be more significant over networks with many users. In addition, we also consider Dynamic Programming (DP) policies in the class of 3-action coding schemes, the EWSAoI performance of DP policies is very close to that of MW policies for all $\epsilon$. \appendices \section{Proof of Lemma~\ref{lem: buffer size 1}}\label{App: Lemma buffer size 1} \begin{proof} We consider two types of policies: policies with buffer size $1$, denote by $\pi_{1}$, and policies with buffer size larger than $1$, denote by $\pi_{2}$. $\pi_1$ works on buffers of size $1$ while $\pi_{2}$ works on buffers of infinite size. To differentiate the two policies and their corresponding queues, we label the packets inside the queues by \emph{new} and \emph{old}. A new packet in a queue means that this packet has not been previously received at its intended user. A packet in a queue is labeled old if there is a newer packet in the same queue or if the packet (or a fresher packet) is already received at its intended user. We refer to the freshest old packet as the old packet. At a given time slot, denote the new packet and the old packet for user $1$ (resp. user $2$) as $p_{new}$ and $p_{old}$ (resp. $q_{new}$ and $q_{old}$) in $Q_{1}^{(i)}$ (resp. $Q_{2}^{(i)}$), $i=1,2$, respectively. Consider a fixed erasure pattern for the channels to the users and an arbitrary time slot $k$. Denote the generation time of the new packet and the old packet for user $1$ (resp. user $2$) in $Q_{1}^{(i)}$ (resp. $Q_{2}^{(i)}$) as $k_{pn}$ and $k_{po}$ (resp. $k_{qn}$ and $k_{qo}$), $i=1,2$. We measure the efficiency of the policies at each slot $k$ by their resulting age at both users. To this end, we show that no matter what policy $\pi_2$ chooses, there is a policy of type $\pi_1$ that is at least as efficient as $\pi_2$ in terms of age at both users. \begin{enumerate} \item $\pi_{2}$ chooses action $i$, $i=1,2$, at slot $k$. In this case, $\pi_{2}$ transmits a packet from $Q_{1}^{(i)}$. By sending the new packet from $Q_{1}^{(i)}$, policy $\pi_1$ attains a smaller age for user $i$ at slot $k+1$ and the age remains the same for the other user. See also \cite[Theorem 2]{2019-E.Najm} for a similar argument. \item $\pi_{2}$ chooses action $3$ at slot $k$. First of all, note that it is always strictly better to choose action $i$ over action $3$ if queue $Q_2^{(\backslash i)}$ is empty, and then a similar analysis with the previous case can be done. Therefore, we consider the case that both queues $Q_2^{(1)}$ and $Q_2^{(2)}$ are non-empty and a coded packet of the form $p_{old}\oplus q_{old}$ is sent by $\pi_2$. To compare with policies of type $\pi_1$, we need to consider four possible cases depending on if there are any new packets in $Q_2^{(1)}$ and $Q_2^{(2)}$. Note that type $\pi_1$ policies are effectively oblivious to old packets. \begin{itemize} \item There are packets of type $p_{old}$ as well as $p_{new}$ in $Q_{1}^{(2)}$ and similarly $q_{old},q_{new}$ in $Q_{2}^{(2)}$. In this case, $\pi_1$ can choose action $3$ and send the coded packet $p_{new}\oplus q_{new}$. This way, if there is a delivery at user~$1$ (resp. user~$2$), the age of user~$1$ (resp. user~$2$) will drop to $k+1-k_{po}$ (resp. $k+1-k_{qo}$) under $\pi_2$ and to $k+1-k_{pn}$ (resp. $k+1-k_{qn}$) under $\pi_1$ at time $k+1$. Since $k_{pn}>k_{po}$ and $k_{qn}>k_{qo}$, $\pi_1$ is strictly more efficient than $\pi_2$ at slot $k+1$. \item There are no packets of type $p_{new}$ in $Q_{1}^{(2)}$ but there are packets of type $q_{old}$ as well as $q_{new}$ in $Q_{2}^{(2)}$. Since there is no packets of type new in $Q_1^{(2)}$, the existing old packet (or a fresher packet) must have been previously received at user $1$. So the current age at user~$1$ is at most $k-k_{po}$ and will increase at most up to $k+1-k_{po}$ at slot $k+1$. The best that a policy of type $\pi_2$ can do by action $3$ is to drop the age at user~$1$ to $k+1-k_{po}$ and drop the age at user~$2$ to $k+1-k_{qo}$ at slot $k+1$. $\pi_1$ can choose action $2$ and perform strictly better than $\pi_2$ at slot $k+1$ because the newest packet in $Q_1^{(2)}$ is fresher than any new packet in $Q_2^{(2)}$. \item There are no packets of type $q_{new}$ in $Q_{2}^{(2)}$ but there are packets of type $p_{old}$ as well as $p_{new}$ in $Q_{2}^{(1)}$. This case is similar to the previous case. \item There are only packets of type $p_{old}$ in $Q_{1}^{(2)}$ and $q_{old}$ in $Q_{2}^{(2)}$. Since there is no packet of type new in the queues, it means that the old packets (or fresher ones) are previously received at the users under $\pi_{1}$. So under $\pi_1$, the current age at user $1$ (resp. user $2$) is at most $k-k_{po}$ (resp. $k-k_{qo}$) at this time and will increase at most by $1$ at time $k+1$. The age under $\pi_2$, however, can only become $k+1-k_{po}$ (resp. $k+1-k_{qo}$) if there is a delivery. Hence $\pi_1$ is at least as efficient as $\pi_2$. \end{itemize} \end{enumerate} So at each time, the average age of policy $\pi_{1}$ is smaller than or equal to that of policy $\pi_{2}$. \end{proof} \section{Proof of Lemma~\ref{lem: distribution of I_i}}\label{App: Lemma 1} \begin{proof} From the analysis above, the probability of Case (\romannumeral1) is $$P_{1}=(\mu_{1}\epsilon_{12}+\mu_{2}+\mu_{3})^{\ell-1}\mu_1(1-\epsilon_1).$$ The probability of Case (\romannumeral2-1) is \begin{equation*} \footnotesize \begin{aligned} P_{2}=&\sum_{t=1}^{\ell-1}(\mu_{1}\epsilon_{12}+\mu_{2}+\mu_{3})^{t-1}(\mu_{1}\epsilon_{1}+\mu_{2}+\mu_{3}\epsilon_{1})^{\ell-1-t}\\ \times&\mu_{1}(\epsilon_{1}-\epsilon_{12})\mu_1(1-\epsilon_1)\\ +&\sum_{2\leq d\leq\ell}\sum_{t=1}^{\ell-d}\Big((\mu_{1}\epsilon_{12}+\mu_{2}+\mu_{3})^{t-1}(\mu_{1}\epsilon_{1}+\mu_{2}+\mu_{3}\epsilon_{1})^{\ell-d-t}\\ \times&(\mu_{1}(\epsilon_{1}-\epsilon_{12}))^2(\mu_{2}+\mu_1\epsilon_{12}+\mu_3\epsilon_1)^{d-2}\mu_3(1-\epsilon_1)\Big). \end{aligned} \end{equation*} The probability of Case (\romannumeral2-2) is \begin{equation*} \begin{aligned} P_{3}=&\sum_{2\leq d\leq\ell}(\mu_{1}\epsilon_{12}+\mu_{2}+\mu_{3})^{\ell-d}\\ \times&\mu_{1}(\epsilon_{1}-\epsilon_{12})(\mu_{2}+\mu_1\epsilon_{12}+\mu_3\epsilon_1)^{d-2}\mu_3(1-\epsilon_1). \end{aligned} \end{equation*} Denote \begin{align*} x_{1}=&\mu_1\epsilon_{12}+\mu_{2}+\mu_3\\ y_{1}=&\mu_1\epsilon_{1}+\mu_{2}+\mu_3\epsilon_1\\ z_{1}=&\mu_1\epsilon_{12}+\mu_{2}+\mu_3\epsilon_1, \end{align*} thus \begin{align*} &\Pr(I_1=\ell)\nonumber=\sum_{d\leq\ell}\Pr(I_{1}=\ell, D_1=d)\nonumber \\=&P_{1}+P_{2}+P_{3}=eq_{1}+eq_{2}+eq_{3}+eq_{4}. \end{align*} where \begin{equation*} \begin{aligned} eq_{1}=&x_{1}^{\ell-1}\mu_1(1-\epsilon_1)\\ eq_{2}=&\mu_{1}^{2}(\epsilon_{1}-\epsilon_{12})(1-\epsilon_1)\frac{x_{1}^{l-1}-y_{1}^{l-1}}{x_{1}-y_{1}}\\ eq_{3}=&\frac{(\mu_{1}(\epsilon_{1}-\epsilon_{12}))^2\mu_3(1-\epsilon_1)}{x_{1}-y_{1}}\\ \times&\Big(\frac{x_{1}^{l-1}-z_{1}^{l-1}}{x_{1}-z_{1}}-\frac{y_{1}^{l-1}-z_{1}^{l-1}}{y_{1}-z_{1}}\Big)\\ eq_{4}=&\mu_{1}(\epsilon_{1}-\epsilon_{12})\mu_3(1-\epsilon_1)\frac{x_{1}^{l-1}-z_{1}^{l-1}}{x_{1}-z_{1}}. \end{aligned} \end{equation*} By calculation, for $\ell\geq2$, \begin{align}\label{equ: probability of I} \Pr(I_1=\ell)=\delta_{1} x_{1}^{\ell-1}+\beta_{1} y_{1}^{\ell-1} \end{align} where $$\delta_{1}=\mu_1(1-\epsilon_{12})+\frac{\mu_{1}^{2}(\epsilon_{1}-\epsilon_{12})(1-\epsilon_{12})}{-\mu_{1}(\epsilon_{1}-\epsilon_{12})+\mu_{3}(1-\epsilon_{1})}$$ $$\beta_{1}=-\frac{\mu_{1}(\epsilon_{1}-\epsilon_{12})(1-\epsilon_1)}{-\mu_{1}(\epsilon_{1}-\epsilon_{12})+\mu_{3}(1-\epsilon_{1})}\Big({\mu_{1}}+{\mu_3}\Big).$$ Now we check $\Pr(\ell=1)$. Substituting $\ell=1$ into \eqref{equ: probability of I}, we have $P(I_{1}=\ell)=\delta_{1}+\beta_{1}=\mu_{1}(1-\epsilon_{1})$, therefore \begin{equation*} P(I_{1}=\ell)=\delta_{1} x_{1}^{\ell-1}+\beta_{1} y_{1}^{\ell-1} \end{equation*} holds for all $\ell\geq1$. \end{proof} \section{Proof of Lemma \ref{lem: symmetric case}}\label{App: Lemma 3} \begin{proof} Taking the first derivative of \eqref{equ: R-symmetric AoI} with respect to $\mu$ and letting it equal to zero, we have \begin{align*} &\mu^{(1)}=\frac{1-\epsilon+\sqrt{(\epsilon-\epsilon_{12}(\epsilon))(1-\epsilon)}}{\epsilon_{12}(\epsilon)-2\epsilon+1}\\ &\mu^{(2)}=\frac{1-\epsilon-\sqrt{(\epsilon-\epsilon_{12}(\epsilon))(1-\epsilon)}}{\epsilon_{12}(\epsilon)-2\epsilon+1}. \end{align*} If $\epsilon_{12}(\epsilon)-2\epsilon+1=0$, then substituting $\epsilon_{12}(\epsilon)=2\epsilon-1$ into \eqref{equ: R-symmetric AoI}, taking the derivative and equating to zero, we obtain $\mu^{(1)}=\mu^{(2)}=1/2$. First, we simplify $\mu^{(2)}$. If $\epsilon_{12}(\epsilon)-2\epsilon+1\neq0$, then \begin{align} \mu^{(2)}=&\frac{1-\epsilon-\sqrt{(\epsilon-\epsilon_{12}(\epsilon))(1-\epsilon)}}{\epsilon_{12}(\epsilon)-2\epsilon+1}\\=&\frac{\sqrt{1-\epsilon}}{\epsilon_{12}(\epsilon)-2\epsilon+1}(\sqrt{1-\epsilon}-\sqrt{\epsilon-\epsilon_{12}(\epsilon)})\\ =&\frac{\sqrt{1-\epsilon}}{\epsilon_{12}(\epsilon)-2\epsilon+1}\cdot\frac{\epsilon_{12}(\epsilon)-2\epsilon+1}{\sqrt{1-\epsilon}+\sqrt{\epsilon-\epsilon_{12}(\epsilon)}}\\=&\frac{\sqrt{1-\epsilon}}{\sqrt{1-\epsilon}+\sqrt{\epsilon-\epsilon_{12}(\epsilon)}}\label{equ: simplify x_2}. \end{align} Note that \eqref{equ: simplify x_2} still holds when $\epsilon_{12}(\epsilon)-2\epsilon+1=0$. From \eqref{equ: simplify x_2}, we have $\mu^{(2)}>0$. Consider the following three cases: (1) If $\epsilon_{12}(\epsilon)-2\epsilon+1<0$, then $\mu^{(1)}<0$. Also, \begin{align*} \mu^{(2)}=&\frac{\sqrt{1-\epsilon}}{\sqrt{1-\epsilon}+\sqrt{\epsilon-\epsilon_{12}(\epsilon)}}\\<&\frac{\sqrt{1-\epsilon}}{\sqrt{1-\epsilon}+\sqrt{1-\epsilon}}<1/2. \end{align*} $\mathbb{E}[J^{R}]$ in \eqref{equ: R-symmetric AoI} decreases when $\mu\in[0,\mu^{(2)}]$ and increases when $\mu\in(\mu^{(2)},1/2]$, so the unique minimal point is obtained at $\mu^{*}=\mu^{(2)}$. (2) If $\epsilon_{12}(\epsilon)-2\epsilon+1=0$, then $\mu^{(1)}=\mu^{(2)}=1/2$, and $\mathbb{E}[J^{R}]$ in \eqref{equ: R-symmetric AoI} decreases when $\mu\in[0, 1/2]$. So the unique minimum point is obtained at $\mu^{*}=1/2$. (3) If $\epsilon_{12}(\epsilon)-2\epsilon+1>0$, then $$\mu^{(1)}>\mu^{(2)}>0.$$ Also, \begin{align*} \mu^{(2)}=&\frac{\sqrt{1-\epsilon}}{\sqrt{1-\epsilon}+\sqrt{\epsilon-\epsilon_{12}(\epsilon)}}\\>&\frac{\sqrt{1-\epsilon}}{\sqrt{1-\epsilon}+\sqrt{1-\epsilon}}>1/2. \end{align*} $\mathbb{E}[J^{R}]$ decreases when $\mu\in[0,1/2]$, so the unique minimum point is obtained at $\mu^{*}=1/2$. \end{proof} \section{Proof of Theorem \ref{thm: MW-policy}}\label{App: Theorem 4} \begin{proof} We first denote by $d_{i}(k)\in\left\{0,1\right\}$ and $t_{i}(k)\in\left\{0,1\right\}$, the number of packets delivered to user $i$ during slot $k$ from $Q_{1}^{(i)}$ and $Q_{2}^{(i)}$, respectively. We have \begin{align*} &d_{i}(k)\leq1\\ &t_{i}(k)\leq1\\ &d_{i}(k)+t_{i}(k)\leq1. \end{align*} Thus from \eqref{equ: BM-w} and \eqref{equ: BM-age}, \begin{equation}\label{equ: MW-recursion of h} \begin{aligned} h_{i}(k+1)=&d_{i}(k)+t_{i}(k)(w_{i}(k)+1)\\ +&(1-d_{i}(k)-t_{i}(k))(h_{i}(k)+1). \end{aligned} \end{equation} Using \eqref{equ: MW-recursion of h}, we can re-write the Lyapunov Drift as follows: \begin{equation*} \footnotesize \begin{aligned} \Theta(\vec{h}(k))=&\mathbb{E}\big[L(\vec{h}(k+1))-L(\vec{h}(k))|\vec{s}(k)\big] \\=&\frac{1}{2}\sum_{i=1}^{2}\alpha_{i}\mathbb{E}\big[\big((1-d_{i}(k)-t_{i}(k))(h_{i}(k)+1)\\ +&d_{i}(k)+t_{i}(k)(w_{i}(k)+1)\big)^{2}-h_{i}^{2}(k)|\vec{s}(k)\big]\\ \stackrel{(a)}{=}&\frac{1}{2}\sum_{i=1}^{2}\alpha_{i}\mathbb{E}\big[\big((1-d_{i}(k)-t_{i}(k))^{2}(h_{i}(k)+1)^{2}\\ +&d_{i}^{2}(k)+t_{i}^{2}(k)(w_{i}(k)+1)^{2}-h_{i}^{2}(k)|\vec{s}(k)\big)\big]\\ \stackrel{(b)}{=}&\frac{1}{2}\sum_{i=1}^{2}\alpha_{i}\mathbb{E}\big[\big((1-d_{i}(k)-t_{i}(k))\cdot(h_{i}(k)+1)^{2}\\ +&d_{i}(k)+t_{i}(k)(w_{i}(k)+1)^2-h_{i}^{2}(k)|\vec{s}(k)\big)\big]\\ =&\frac{1}{2}\sum_{i=1}^{2}\alpha_{i}\Big(\mathbb{E}[t_{i}(k)|\vec{h}(k)]\big(w_{i}^{2}(k)+2w_{i}(k)-h_{i}^{2}(k)-2h_{i}(k)\big)\\ -&\mathbb{E}[d_{i}(k)|\vec{h}(k)](h_{i}^{2}(k)+2h_{i}(k))+2h_{i}(k)+1\Big). \end{aligned} \end{equation*} (a) holds because from the definition of $d_{i}(k)$ and $t_{i}(k)$, at each slot only one of $d_{i}(k), t_{i}(k), 1-d_{i}(k)-t_{i}(k)$ equals to $1$, and the rest are zero. (b) holds because $d_{i}^{2}(k)=d_{i}(k)$, $t_{i}^{2}(k)=t_{i}(k)$, and $(1-d_{i}(k)-t_{i}(k))^{2}=1-t_{i}(k)-d_{i}(k)$. Minimizing $\Theta(\vec{h}(k))$ is equivalent to minimize \begin{equation}\label{equ: MW-upper bound-tilde delta} \footnotesize \begin{aligned} \tilde{\Theta}(\vec{h}(k))=&\frac{1}{2}\sum_{i=1}^{2}\alpha_{i}\Big(-\mathbb{E}[d_{i}(k)|\vec{s}(k)]\big(h_{i}^{2}(k)+2h_{i}(k)\big)\\ +&\mathbb{E}[t_{i}(k)|\vec{s}(k)]\big(w_{i}^{2}(k)+2w_{i}(k)-h_{i}^{2}(k)-2h_{i}(k)\big)\Big) \end{aligned} \end{equation} since $h_{i}(k)$ is a constant once we know $\vec{s}(k)$. Moreover, from the definition of MW policies, in each slot, $P(A(k)=i)\in\left\{0,1\right\}$ and $\sum_{i=1}^{3}P(A(k)=i)=1$. Therefore, we have \begin{align} &\mathbb{E}[d_{i}(k)|\vec{s}(k)]=1_{\{A(k)=i\}}(1-\epsilon_{i})\label{equ: MW upper bound Ed}\\ &\mathbb{E}[t_{i}(k)|\vec{s}(k)]=1_{\{A(k)=3\}}1_{\{w_{i}(k)>0\}}(1-\epsilon_{i}).\label{equ: MW upper bound Et} \end{align} Substituting \eqref{equ: MW upper bound Ed} and \eqref{equ: MW upper bound Et} into \eqref{equ: MW-upper bound-tilde delta}, we obtain the desired results. \end{proof} \section{Proof of Theorem \ref{thm: MW-the upper bound}}\label{App: Theorem 5} Before obtaining the upper bound of Max-Weight policies, we consider any randomized policy with probability $\mu_{1}$, $\mu_{2}$, and $\mu_{3}$. Now we calculate the probability of $Q_{2}^{(i)}=\varnothing$. This can be found as a corollary of the following lemma: \begin{lemma}\label{lem: empty queue} Consider a queue $Q$ of size $1$. Suppose that packets arrive with a Bernoulli random process of rate $\lambda$ and leave with another (independent) Bernoulli random process of rate $\mu$. Then the probability of empty queue is $$P(Q=\varnothing)=\frac{\mu(1-\lambda)}{\mu+\lambda-\mu\lambda}.$$ \end{lemma} \begin{proof} Since the capacity of the system is $1$, then only two state exists, one is ``an empty queue'', and the other is ``a non-empty queue''. Denote ``an empty queue'' as state~$0$ and ``a non-empty queue'' as state~$1$, and consider a two-state Markov chain. Then, we find the transition probabilities \begin{equation*} \begin{aligned} P_{0\rightarrow1}=&P\{\text{a arrival occurs}\}=\lambda\\ P_{1\rightarrow0}=&P\text{\{a departure occurs but no arrivals occur\}}\\ =&\mu(1-\lambda). \end{aligned} \end{equation*} Thus the transition probability matrix is \begin{align*} P=\left[\begin{matrix} 1-\lambda&\lambda\\ \mu(1-\lambda)&1-\mu+\mu\lambda \end{matrix}\right]. \end{align*} Denote the stationary distribution as $\pi=(\pi_{0},\pi_{1})$, therefore \begin{align*} \pi=\pi P\Rightarrow \pi_{0}=\frac{\mu(1-\lambda)}{\mu+\lambda-\mu\lambda}. \end{align*} \end{proof} \begin{corollary}\label{cor: P_empty} The probability of empty queue in $Q_{2}^{(i)}$ is \begin{equation}\label{equ: empty queue} \footnotesize \begin{aligned} P_{empty}^{i}:=\frac{\mu_{3}(1-\epsilon_{i})(1-\mu_{i}(\epsilon_{i}-\epsilon_{12}))}{\mu_{3}(1-\epsilon_{i})+\mu_{i}(\epsilon_{i}-\epsilon_{12})-\mu_{3}\mu_{i}(1-\epsilon_{i})(\epsilon_{i}-\epsilon_{12})}. \end{aligned} \end{equation} \end{corollary} \begin{proof} Since $Q_{2}^{(i)}$ is the queue in which packets are erased by user $i$ but received user $\backslash{i}$, so the arrival rate is $$\lambda=\mu_{i}(\epsilon_{i}-\epsilon_{12}),$$ and the departure rate $$\mu=\mu_{3}(1-\epsilon_{i}).$$ From Lemma \ref{lem: empty queue}, \begin{equation*} \footnotesize \begin{aligned} P(Q_{2}^{(i)}=\varnothing)=&\frac{\mu_{3}(1-\epsilon_{i})(1-\mu_{i}(\epsilon_{i}-\epsilon_{12}))}{1-(1-\mu_{3}(1-\epsilon_{i}))(1-\mu_{i}(\epsilon_{i}-\epsilon_{12}))}\\ =&\frac{\mu_{3}(1-\epsilon_{i})(1-\mu_{i}(\epsilon_{i}-\epsilon_{12}))}{\mu_{3}(1-\epsilon_{i})+\mu_{i}(\epsilon_{i}-\epsilon_{12})-\mu_{3}\mu_{i}(1-\epsilon_{i})(\epsilon_{i}-\epsilon_{12})}. \end{aligned} \end{equation*} \end{proof} To obtain the upper bound of MW policies, we manipulate the expression of the one-slot Lyapunov Drift. From the proof of Theorem~\ref{thm: MW-policy}, we have \begin{equation*} \footnotesize \begin{aligned} \Theta\big(\vec{h}(k)\big)=&\frac{1}{2}\sum_{i=1}^{2}\alpha_{i}\Big(-\mathbb{E}[d_{i}(k)|\vec{s}(k)]\big(h_{i}^{2}(k)+2h_{i}(k)\big)+2h_{i}(k)+1\\ +&\mathbb{E}[t_{i}(k)|\vec{s}(k)]\big(w_{i}^{2}(k)+2w_{i}(k)-h_{i}^{2}(k)-2h_{i}(k)\big)\Big). \end{aligned} \end{equation*} Consider any randomized policy with probability $(\mu_{1},\mu_{2},\mu_{3})$ in Section \ref{sec: stationary randomized policy}, and denote the probability of the non-empty queue in $Q_{2}^{(i)}$ as $P_{ne}^{i}=1-P_{empty}^{i}$. From the definition of Max-Weight policies, and substituting $\mu_{1}$, $\mu_{2}$, $\mu_{3}$ and $P_{ne}^{i}$ into $\Theta(\vec{h}(k))$, we find \begin{equation*} \footnotesize \begin{aligned} \Theta(\vec{h}(k))\leq&\frac{1}{2}\sum_{i=1}^{2}\alpha_{i}\big(-\mu_{i}(1-\epsilon_{i})(h_{i}^{2}(k)+2h_{i}(k))+2h_{i}(k)+1\\ +&\mu_{3}P_{ne}^{i}(1-\epsilon_{i})(w_{i}^{2}(k)+2w_{i}(k)-h_{i}^{2}(k)-2h_{i}(k))\big). \end{aligned} \end{equation*} From Remark~\ref{w<=h-1}, since $w_{k}(k)\leq h_{i}(k)-1$, then \begin{equation*} \footnotesize \begin{aligned} \Theta(\vec{h}(k))\leq\frac{1}{2}\sum_{i=1}^{2}\alpha_{i}\big(-\mu_{i}(1-\epsilon_{i})(h_{i}(k)-\Phi_{i})^{2}+\Psi_{i}\big) \end{aligned} \end{equation*} where \begin{equation*} \footnotesize \begin{aligned} &\Phi_{i}=\frac{1-\mu_{3}P_{ne}^{i}(1-\epsilon_{i})-\mu_{i}(1-\epsilon_{i})}{\mu_{i}(1-\epsilon_{i})}\\ &\Psi_{i}=1-\mu_{3}P_{ne}^{i}(1-\epsilon_{i})+\frac{\big(1-\mu_{i}(1-\epsilon_{i})-\mu_{3}P_{ne}^{i}(1-\epsilon_{i})\big)^{2}}{\mu_{i}(1-\epsilon_{i})}. \end{aligned} \end{equation*} By Cauchy-Schwarz inequality, \begin{equation*} \footnotesize \begin{aligned} &\sum_{i=1}^{2}\alpha_{i}\mu_{i}(1-\epsilon_{i})(h_{i}(k)-\Phi_{i})^{2}(\sum_{i=1}^{2}\frac{\alpha_{i}}{\mu_{i}(1-\epsilon_{i})})\\ \geq&\bigg(\sum_{i=1}^{2}\alpha_{i}|h_{i}(k)-\Phi_{i}|\bigg)^{2}. \end{aligned} \end{equation*} Therefore \begin{equation*} \footnotesize \begin{aligned} \Theta(\vec{h}(k))\leq&-\frac{1}{2}(\sum_{i=1}^{2}\frac{\alpha_{i}}{\mu_{i}(1-\epsilon_{i})})^{-1}\big(\sum_{i=1}^{2}\alpha_{i}|h_{i}(k)-\Phi_{i}|\big)^{2}\\ +&\frac{1}{2}\sum_{i=1}^{2}\alpha_{i}\Psi_{i}, \end{aligned} \end{equation*} which implies \begin{equation*} \footnotesize \begin{aligned} &\frac{1}{2}\big(\sum_{i=1}^{2}\alpha_{i}|h_{i}(k)-\Phi_{i}|\big)^{2}\\ \leq&-(\sum_{i=1}^{2}\frac{\alpha_{i}}{\mu_{i}(1-\epsilon_{i})})\Theta(\vec{h}(k))+\frac{1}{2}\sum_{i=1}^{2}\frac{\alpha_{i}}{\mu_{i}(1-\epsilon_{i})}\sum_{i=1}^{2}\alpha_{i}\Psi_{i}. \end{aligned} \end{equation*} Summing over $k\in\left\{1,2,\cdots,T\right\}$, taking expectation and dividing by $T$ results in \begin{equation*} \footnotesize \begin{aligned} &\frac{1}{2T}\bigg(\sum_{k=1}^{T}\mathbb{E}\big(\sum_{i=1}^{2}\alpha_{i}|h_{i}(k)-\Phi_{i}|\big)^{2}\bigg)\\ \leq& -\big(\sum_{i=1}^{2}\frac{\alpha_{i}}{\mu_{i}(1-\epsilon_{i})}\big)\frac{1}{T}\sum_{k=1}^{T}\mathbb{E}[\Theta(\vec{h}(k))]+\frac{1}{2}(\sum_{i=1}^{2}\frac{\alpha_{i}}{\mu_{i}(1-\epsilon_{i})})\sum_{i=1}^{2}\alpha_{i}\Psi_{i}. \end{aligned} \end{equation*} By Jensen's inequality, \begin{equation*} \footnotesize \begin{aligned} &\frac{1}{2}\bigg(\frac{1}{T}\sum_{k=1}^{T}\mathbb{E}\big(\sum_{i=1}^{2}\alpha_{i}|h_{i}(k)-\Phi_{i}|\big)\bigg)^{2}\\ \leq& -(\sum_{i=1}^{2}\frac{\alpha_{i}}{\mu_{i}(1-\epsilon_{i})})\frac{1}{T}\sum_{k=1}^{T}\mathbb{E}[\Theta(\vec{h}(k))]+\frac{1}{2}\sum_{i=1}^{2}\frac{\alpha_{i}}{\mu_{i}(1-\epsilon_{i})}\sum_{i=1}^{2}\alpha_{i}\Psi_{i}. \end{aligned} \end{equation*} Since \begin{align*} -\frac{1}{T}\sum_{k=1}^{T}\mathbb{E}[\Theta(\vec{h}(k))]\leq\frac{\mathbb{E}[L(\vec{h}(1))]}{T} \end{align*} and $\mathbb{E}[L(\vec{h}(1))]$ is a constant, then \begin{align*} \lim_{T\rightarrow\infty}-\frac{1}{T}\sum_{k=1}^{T}\mathbb{E}[\Theta(\vec{h}(k))]=0. \end{align*} Thus, \begin{equation*} \footnotesize \begin{aligned} \mathbb{E}[J^{MW}]\leq \sqrt{\frac{1}{2}\sum_{i=1}^{2}\frac{\alpha_{i}}{\mu_{i}(1-\epsilon_{i})}\sum_{i=1}^{2}\alpha_{i}\Psi_{i}}+\frac{1}{2}\sum_{i=1}^{2}\alpha_{i}\Phi_{i} \end{aligned} \end{equation*} where \begin{equation*} \footnotesize \begin{aligned} &\Phi_{i}=\frac{1-\mu_{3}P_{ne}^{i}(1-\epsilon_{i})-\mu_{i}(1-\epsilon_{i})}{\mu_{i}(1-\epsilon_{i})}\\ &\Psi_{i}=1-\mu_{3}P_{ne}^{i}(1-\epsilon_{i})+\frac{\big(1-\mu_{i}(1-\epsilon_{i})-\mu_{3}P_{ne}^{i}(1-\epsilon_{i})\big)^{2}}{\mu_{i}(1-\epsilon_{i})}. \end{aligned} \end{equation*} \bibliographystyle{IEEEtran}
{'timestamp': '2019-04-24T02:03:30', 'yymm': '1904', 'arxiv_id': '1904.10077', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.10077'}
arxiv
\section{Introduction} Many space missions take place in environments with complex and time-varying dynamics that may be incompletely modeled during the mission design phase. For example, during an orbital refueling mission, the inertia tensor of each of the two spacecraft will change significantly as fuel is transferred from one spacecraft to the other, which can make the combined system difficult to control [\citenum{guang2018attitude}]. A significant fraction of an exoatmospheric kill vehicle's (EKV) wet mass consists of fuel, and as this is depleted with divert thrusts, the center of mass changes, which impacts performance. Future missions to asteroids might be undertaken before the asteroid's gravitational field, rotational velocity, and local solar radiation pressure are accurately modeled. Also consider that it is difficult to accurately model the aerodynamics of hypersonic re-entry. Moreover, there is the problem of navigation system errors biasing the state estimate given to the guidance system. Finally, there is the possibility of actuator failure, which significantly modifies the dynamic system of a spacecraft and its environment. These examples show a clear need for a guidance system that can adapt in real time to time-varying system dynamics that are likely to be imperfectly modeled prior to the mission. The integration of guidance and navigation bring further benefits, including the ability to adapt to sensor distortion, and co-optimization of the two systems. Recent work in the area of adaptive guidance algorithms include [\citenum{prabhakar2018trajectory}], which demonstrates an adaptive control law for a UAV tracking a reference trajectory, where the adaptive controller adapts to external disturbances. One limitation is the linear dynamics model, which may not be accurate, as well as the fact that the frequency of the disturbance must be known. In [\citenum{huang2019mars}], the authors develop a fault identification system for Mars entry phase control using a pre-trained neural network, with a fault controller implemented as a second Gaussian neural network, Importantly, the second network requires on-line parameter update during the entry phase, which may not be possible to implement in real time on a flight computer. Moreover, the adaptation is limited to known actuator faults as identified by the 1st network. In [\citenum{han2015adaptive}],the authors develop an adaptive controller for spacecraft attitude control using reaction wheels. This approach is also limited to actuator faults, and the architecture does not adapt to either state estimation bias or environmental dynamics. Several works have demonstrated improved performance with uncertain and complex dynamics using the reinforcement learning (RL) framework and training with randomized system parameters. In [\citenum{yu2017preparing}], the authors use a recurrent neural network to explicitly learn model parameters through real time interaction with an environment; these parameters are then used to augment the observation for a standard reinforcement learning algorithm. In [\citenum{peng2017sim}], the authors use a recurrent policy and value function in a modified deep deterministic policy gradient algorithm to learn a policy for a robotic manipulator arm that uses real camera images as observations. In both cases, the agents train over a wide range of randomized system parameters. In the deployed policy, the recurrent network's internal state quickly adapts to the actual system dynamics, providing good performance for the agent's respective tasks. In this work we use the principles of reinforcement meta-learning [\citenum{wang2016learning}] (meta-RL) to formulate two adaptive guidance laws, one suitable for controlling a lander in a Mars powered descent phase, the other suitable for landing on small bodies such as an asteroid. In the meta-RL framework, and agent "learns to learn" through exposure to a multitude of environments. The optimized policy can then quickly adapt to novel environments. The guidance laws take the form of a global policy over the region of state space defined by the deployment region and potential landing sites. This global policy maps the navigation system's estimate of the lander's state to a commanded thrust vector in the target centered reference frame. Optimizing the policy involves simulated interaction between an agent instantiating the policy and the environment over many episodes with randomly generated initial conditions that cover the theater of operations. Importantly, environmental parameters such as state estimation error, the lander's wet mass, and environmental forces are varied between episodes. The optimized policy will adapt in real time to these parameters. We will demonstrate through a series of experiments that the meta-RL adaptive guidance law outperforms a traditional energy-optimal closed-loop guidance algorithm independently developed by by Battin [\citenum{battin1999introduction}, page 558] and D'Souza [\citenum{d1997optimal}], referred to in the sequel as a "DR/DV policy". Moreover, we demonstrate that in a subset of experiments, the meta-RL adaptive guidance law (referred to in the sequel as the "meta-RL policy") outperforms a non-adaptive guidance law optimized using standard reinforcement learning (hereafter referred to as an "RL policy"). In the Mars landing experiments, the RL policy is identical to the 3-DOF Mars landing policy developed in [\citenum{gaudet2018deep}]. Finally, in two experiments, we integrate guidance and navigation by optimizing a guidance law that takes observations consisting of sensor outputs. The first experiment is in a Mars powered descent phase environment, where the observation consists of simulated Doppler radar altimeter readings. The second experiment is in an asteroid landing environment using simulated LIDAR altimeter readings. We compare the performance of the DR/DV policy, RL policy, and a meta-RL policy over a range of tasks with unknown but highly variable dynamics. We use the DR/DV policy as a performance baseline, and to improve its performance, we give it access to the ground truth lander mass at the start of an episode. In contrast, the RL and meta-RL policies only have access to observations that are a function of the lander's position and velocity, or in some cases, sensor readings. Since sensor output feedback is still an open problem in the optimal control framework, for the tasks using sensor output as observations, we did not compare performance to that obtainable using DR/DV. These tasks include: \begin{enumerate} \item \underline{Engine Failure (3-DOF Mars Landing):} At the start of each episode, with probability $p$ a the lander's thrust capability in a given direction is reduced. \item \underline{Large Mass Variation (3-DOF Mars Landing):} We use a small engine specific impulse and assume wet/dry masses of 2000kg/200kg respectively, which results in a large variation in lander mass during the landing. This creates a difficult control problem, as the agent does not have access to the ground truth mass. \item \underline{Landing with Integrated Guidance and Navigation:} The agent learns a guidance law with observation consisting of the readings from the four Doppler radar altimeters. This example uses a 3-DOF Mars Landing model. \item \underline{State Estimate Bias: (3-DOF Mars Landing):} The agent has access to a corrupted version of the ground truth state. \item \underline{Unknown Dynamics (3-DOF Asteroid Landing):} In each episode, the acceleration due to gravity, solar radiation pressure, and rotation are randomly chosen over a wide range, limited only by the lander's thrust capability. \item \underline{Landing with Integrated Guidance and Navigation:} The agent learns a guidance law with observation consisting of LIDAR altimeter readings. This example uses a 3-DOF Asteroid Landing model. \end{enumerate} \section{Meta-RL Problem Formulation} In the RL framework, an agent learns through repeated interaction with an environment how to complete a task. A Markov Decision Process (MDP) is an abstraction of this environment, which in a continuous state and action space, can be represented by a state space $\mathcal{S}$, an action space $\mathcal{A}$, a state transition distribution $\mathcal{P}(\mathbf{x}_{t+1}|\mathbf{x}_t,\mathbf{u}_t)$, and a reward function $r=\mathcal{R}(\mathbf{x}_t,\mathbf{u}_t))$, where $x \in \mathcal{S}$ and $u \in \mathcal{A}$, and $r$ is a scalar reward signal. We can also define a partially observable MDP (POMDP), where the state $\mathbf{x}$ becomes a hidden state, generating an observation $\mathbf{o}$ using an observation function $\mathcal{O}(\mathbf{x})$ that maps states to observations. The POMDP formulation is useful when the observation is a noisy version of the ground truth state (due to navigation system inaccuracies) and when the observation consists of raw sensor outputs such as LIDAR readings or sequential camera images. In the following, we will refer to both fully observable and partially observable environments as POMDPs, as an MDP can be considered a POMDP with an identify function mapping states to observations. The agent operates within an environment defined by the POMDP, generating some action $\mathbf{u}_t$ based off of the observation $\mathbf{o}_t$, and receiving reward $r_{t+1}$ and next observation $\mathbf{o}_{t+1}$. Optimization involves maximizing the sum of (potentially discounted) rewards over the trajectories induced by the interaction between the agent and environment. Constraints such as minimum and maximum thrust, glide slope, attitude compatible with sensor field of view, maximum rotational velocity, and terrain feature avoidance (such as targeting the bottom of a deep crater) can be included in the reward function, and will be accounted for when the policy is optimized. Note that there is no guarantee on the optimality of trajectories induced by the policy, although in practice it is possible to get close to optimal performance by tuning the reward function. Reinforcement meta-learning differs from generic reinforcement learning in that the agent learns to adapt to novel POMPDs by learning over a wide range of POMDPs. These POMDPs can include different environmental dynamics, actuator failure scenarios, and varying amounts of navigation system state estimation bias. Learning within the RL meta-learning framework results in an agent that can quickly adapt to novel POMDPs, often with just a few steps of interaction with the environment. There are multiple approaches to implementing meta-RL. In [\citenum{finn2017model}], the authors design the objective function to explicitly to make the model parameters transfer well to new tasks. In [\citenum{mishra2018simple}], the authors demonstrate state of the art performance using temporal convolutions with soft attention. And in [\citenum{frans2017meta}], the authors use a hierarchy of policies to achieve meta-RL. In this proposal, we use a different approach similar to that employed in [\citenum{wang2016learning}] using a recurrent policy and value function. Note that it is possible to train over a wide range of POMDPs using a non-meta RL algorithm, and we demonstrated in [\citenum{gaudet2018deep}] that this can provide a robust integrated guidance and control system for the 6-DOF Mars landing problem, and such an approach was applied in [\citenum{rajeswaran2016epopt}] to obtain robust results in a the openAI mujoco environment with robot parameters randomly varied across episodes. However, although such an approach typically results in a robust policy, the policy cannot adapt in real time to novel environments. In this work the meta-RL policy is optimized using proximal policy optimization (PPO) [\citenum{schulman2017proximal}] with both the policy and value function implementing recurrent layers in their networks. To understand how recurrent layers result in an adaptive agent, consider that given some ground truth agent position and velocity $\mathbf{x}\in\mathbb{R}^{6}$, and action vector $\mathbf{u}\in\mathbb{R}^{3}$ output by the agent's policy, the next observation depends not only on $\mathbf{x}$ and $\mathbf{u}$, but also on the ground truth agent mass and external forces acting on the agent. Consequently, during training, the hidden state of a policy's recurrent layers evolves differently depending on the observed sequence of observations from the environment and actions output by the policy. Specifically, the trained policy's hidden state captures unobserved information such as (potentially time-varying) external forces that are useful in minimizing the cost function. In contrast, a non-recurrent policy, which does not maintain a persistent state vector, can only optimize using a set of current observations, actions, and advantages, and will tend to under-perform a recurrent policy on tasks with randomized dynamics. After training, although the recurrent policy's network weights are frozen, the hidden state will continue to evolve in response to a sequence of observations and actions, thus making the policy adaptive. In contrast, an non-recurrent policy's behavior is fixed by the network parameters at test time. The policy and value functions are implemented using four layer neural networks with tanh activations on each hidden layer. Layer 2 for the policy and value function is a recurrent layer implemented as a gated recurrent unit [\citenum{chung2015gated}]. The network architectures are as shown in Table \ref{tab:NN}, where $n_{\mathrm{hi}}$ is the number of units in layer $i$, $\mathrm{obs\_dim}$ is the observation dimension, and $\mathrm{act\_dim}$ is the action dimension. During training, the hidden layer is unrolled for a number of steps in the forward pass in order to perform back-propagation through time, which allows the network to learn temporal dependencies in the rollout trajectories. \begin{table}[h] \fontsize{8}{8}\selectfont \caption{Policy and Value Function network architecture} \label{tab:NN} \centering \newcolumntype{R}{>{\raggedleft\arraybackslash}p{1.8cm}} \begin{tabular}{l | R | c | R | c } \hline & \multicolumn{2}{c}{Policy Network}\vline & \multicolumn{2}{c}{Value Network}\\ \hline Layer & \# units & activation & \# units & activation \\ \hline hidden 1 & $10 * \mathrm{obs\_dim}$ & tanh & $10 * \mathrm{obs\_dim}$ & tanh \\ hidden 2 & $\sqrt{n_{\mathrm{h1}} * n_{\mathrm{h3}}}$ & tanh & $\sqrt{n_{\mathrm{h1}} * n_{\mathrm{h3}}}$ & tanh\\ hidden 3 & $10 * \mathrm{act\_dim}$ & tanh & 5 & tanh \\ output & $\mathrm{act\_dim}$ & linear & 1 & linear \\ \hline \end{tabular} \end{table} We optimize the policy using proximal policy optimization (PPO) [\citenum{schulman2017proximal}]. Our implementation of the PPO algorithm uses an advantage function that is the difference between the empirical return and a state value function baseline, as shown in Eq. \eqref{eq:ppo_adv}, where $r(\mathbf{u},\mathbf{o})$ is the reward function, and $\gamma$ a discount rate used to facilitate temporal credit assignment: \begin{equation} \label{eq:ppo_adv} A^{\pi}_{\bf w}(\mathbf{o}_{k},\mathbf{u}_{k})=\left[\sum_{\ell=k}^{T}\gamma^{\ell-k}r(\bf o_{\ell},\bf u_{\ell})\right]-V_{\bf w}^{\pi}(\mathbf{o}_{k}) \end{equation} Here the value function $V_{\bf w}^{\pi}$ is learned using the cost function given in Eq. \eqref{eq:vf_ppo}. \begin{equation} \label{eq:vf_ppo} L(\mathbf{w})=\sum_{i=1}^{M}\left(V_{\mathbf{w}}^{\pi}({\bf o}_k^i)-\left[\sum_{\ell=k}^{T}\gamma^{\ell-k}r({\bf u}_{\ell}^i,{\bf o}_{\ell}^i)\right]\right)^2 \end{equation} PPO attempts to bound changes in the policy's distribution of actions conditioned on observations using a probability ratio heuristic $p_{k}({\bm \theta})$ given by, \begin{equation} \label{eq:clipr} p_{k}({\bm \theta})=\frac{\pi_{{\bm \theta}}({\bf u}_{k}|{\bf o}_{k})}{\pi_{{\bm \theta}_\text{old}}({\bf u}_{k}|{\bf o}_{k})} \end{equation} Our objective function is then shown in Eq. \ref{eq:ppoloss}: \begin{equation} \label{eq:ppoloss} L({\bm \theta})=\mathbb{E}_{p({\bm \tau})}\left[\mathrm{min}\left[p_{k}({\bm \theta}) \mathrm{clip}(p_{k}({\bm \theta}) , 1-\epsilon, 1+\epsilon)\right]A^{\pi}_{\bf w}({\bf o}_{k},{\bf u}_{k})\right] \end{equation} This clipped objective function has been shown to aid convergence by insuring that the policy does not change drastically between updates. The policy optimization algorithm updates the policy using a batch of trajectories (roll-outs) collected by interaction with the environment. Each trajectory is associated with a single episode, with a sample from a trajectory collected at step $k$ consisting of observation ${\bf o}_{k}$, action ${\bf u}_{k}$, and reward $r_k({\bf o}_k,{\bf u}_k)$. Finally, gradient accent is performed on ${\bm \theta}$ and gradient decent on ${\bf w}$ and update equations are given by \begin{align}\label{loss} {\bf w}^+&={\bf w}^--\beta_{{\bf w}}\nabla_{{\bf w}} \left. L({\bf w})\right|_{{\bf w}={\bf w}^-}\\ {\bm \theta}^+&={\bm \theta}^-+\beta_{{\bm \theta}} \left. \nabla_{\bm \theta}J\left({\bm \theta}\right)\right|_{{\bm \theta}={\bm \theta}^-} \end{align} where $\beta_{{\bf w}}$ and $\beta_{{\bm \theta}}$ are the learning rates for the value function, $V_{\bf w}^{\pi}$, and policy, $\pi_{\bm \theta}\left({\bf u}_k|{\bf o}_k\right)$, respectively. In our implementation, we dynamically adjust the clipping parameter $\epsilon$ to target a KL divergence between policy updates of 0.001. The policy and value function are learned concurrently, as the estimated value of a state is policy dependent. We use a Gaussian distribution with mean $\pi_{\bm \theta}({\bf o}_{k})$ and a diagonal covariance matrix for the action distribution in the policy. Because the log probabilities are calculated using the exploration variance, the degree of exploration automatically adapts during learning such that the objective function is maximized. \section{Mars Landing Environment} Each episode begins with the initial conditions shown in Table \ref{tab:IC}, where values are in the target centered reference frame. At the start of each episode, the environmental disturbance acceleration $\mathbf{a}_{\text{env}}$ in Eq. \ref{eq:EQOM1b} is randomly set over a uniform distribution ranging from $\text{-0.2m/s}^2\text{to 0.2m/s}^2$, and the lander's initial mass $m$ in Eq. \ref{eq:EQOM1b} is set over a random distribution +/-10\% of nominal. These are the types and amounts of parameter variation we would expect any guidance law to be able to easily compensate for. \begin{table}[h] \fontsize{10}{10}\selectfont \caption{Mars Lander Initial Conditions for Optimization} \label{tab:IC} \centering \newcolumntype{R}{>{\raggedleft\arraybackslash}p{1.8cm}} \begin{tabular}{l | R | R } Parameter & min & max \\ \hline Downrange Position (m) & 0 & 2000\\ Crossrange Position (m) & -1000 & 1000 \\ Elevation Position (m) & 2300 & 2400 \\ Downrange Velocity (m/s) & -70 & -10 \\ Crossrange Velocity (m/s) & -30 & 30 \\ Elevation Velocity (m/s) & -90 & -70 \\ Lander Mass (kg) & 1800 & 2200 \\ \end{tabular} \end{table} \subsection{Dynamics Model} We model the Mars landings in 3-DOF, where the translational motion is modeled as shown in Eqs. \ref{eq:EQOM1a} through \ref{eq:EQOM1c}: \begin{subequations} \begin{align} \Dot{\mathbf r} &= {{\mathbf v}}\label{eq:EQOM1a}\\ \Dot{\bf v} &= \frac{\bf T}{m} + \mathbf{a}_{\text{env}} + \mathbf{g} \label{eq:EQOM1b}\\ \Dot{m} &= -\frac{\lVert{{\bf T}}\rVert}{I_\text{sp}g_\text{ref}} \label{eq:EQOM1c} \end{align} \end{subequations} Here $\mathbf{r}$ is the lander's position in the target centered reference frame, ${{\bf T}}$ is the lander's thrust vector $g_\text{ref}=9.8$ $\text{m}/\text{s}^{2}$, ${\bf g}=\begin{bmatrix} 0 & 0 & -3.7114\end{bmatrix} \text{m}/\text{s}^2$, $I_\text{sp}=225$ s, and the lander's mass is $m$. ${\bf a}_\text{env}$ is a vector representing environmental disturbances such as wind and variations in atmospheric density. The minimum and maximum thrust is constrained to be in the range [2000N, 15000N], and the lander's nominal wet mass is 2000kg. The equations of motion are integrated using 4\textsuperscript{th} order Runge-Kutta integration with a 0.05s step size, and the navigation period is 0.2s. \subsection{Reward Function} We use an approach similar to that taken in [\citenum{gaudet2018deep}] for our reward function. This reward function is a combination of shaping rewards [\citenum{ng2003shaping}] and a terminal reward. The shaping rewards give the agent hints at every time step as to how well it is performing. These hints take the form of a target velocity aligned with the line of sight vector. Specifically, we define the piece wise velocity field given in Equations \eqref{eq:vtarg1a}, \eqref{eq:vtarg1b}, \eqref{eq:vtarg1c}, \eqref{eq:vtarg1d}, and \eqref{eq:vtarg1e}, where $\tau_{1}$ and $\tau_{2}$ are hyperparameters and $v_{o}$ is set to the magnitude of the lander's velocity at the start of the powered descent phase. We see that the shaping rewards take the form of a velocity field that maps the lander's position to a target velocity. In words, we target a location 15m above the desired landing site and target a z-component of landing velocity equal to -2m/s. Below 15m, the downrange and crossrange velocity components of the target velocity field are set to zero, which encourages a vertical descent. \begin{subequations} \begin{align} {\bf v}_{targ}&=-v_{o}\left(\frac{{\bf \hat{r}}}{\lVert{\bf \hat{r}}\rVert}\right)\left(1-\exp\left(-\frac{t_{go}}{\tau}\right)\right)\label{eq:vtarg1a}\\ t_{go}&=\frac{\lVert{\bf \hat{r}}\rVert}{\lVert{\bf \hat{v}}\rVert}\label{eq:vtarg1b} \\ {\bf \hat{r}}&=\begin{cases}{\bf r} - \begin{bmatrix}0 & 0 & 15\end{bmatrix}, & \text{if } r_{2} > 15 \\ \begin{bmatrix}0 & 0 & r_{2}\end{bmatrix}, &\text{otherwise}\end{cases}\label{eq:vtarg1c} \\ {\bf \hat{v}}&=\begin{cases}{\bf v} - \begin{bmatrix}0 & 0 & -2\end{bmatrix}, & \text{if } r_{2} > 15 \\ {\bf v}-\begin{bmatrix}0 & 0 & -1\end{bmatrix}, &\text{otherwise}\end{cases}\label{eq:vtarg1d} \\ \tau&=\begin{cases} \tau_{1}, & \text{if } r_{2} > 15 \\ \tau_{2}, &\text{otherwise}\end{cases}\label{eq:vtarg1e} \end{align} \end{subequations} Finally, we provide a terminal reward bonus when the lander reaches an altitude of zero, and the terminal position, velocity, and glideslope are within specified limits. The reward function is then given by Equation \eqref{eq:reward_func}, where the various terms are described in the following: \begin{enumerate} \item $\alpha$ weights a term penalizing the error in tracking the target velocity. \item $\beta$ weights a term penalizing control effort. \item $\gamma$ is a constant positive term that encourages the agent to keep making progress along the trajectory. \item $\eta$ is a bonus given for a successful landing, where terminal position, velocity, and glideslope are all within specified limits. The limits are $r_{lim}=5$ $\text{m}$, $v_{lim}=2$ $\text{m/s}$, and $\text{gs}_{lim}=79$ deg. The minimum glideslope at touchdown insures the lander's velocity is directed predominatly downward. \end{enumerate} \begin{equation} \begin{aligned} \label{eq:reward_func} r &= \alpha\|{\bf v}-{\bf v}_{targ}\|+ \beta\|{\bf T}\|+\gamma\\ &+\eta({\bf r}_{2}<0 \ \mathrm{and}\ \|{\bf r}\|<r_{lim} \ \\ &\mathrm{and}\ \|{\bf v}\|<v_{lim} \ \mathrm{and} \ gs > gs_{lim})\ \end{aligned} \end{equation} This reward function allows the agent to trade off between tracking the target velocity given in Eq.~\eqref{eq:vtarg1a}, conserving fuel, and maximizing the reward bonus given for a good landing. Note that the constraints are not hard constraints such as might be imposed in an optimal control problem solved using collocation methods. However, the consequences of violating the constraints (a large negative reward and termination of the episode) are sufficient to insure they are not violated once learning has converged. Hyperparameter settings and coefficients used in this work are given in Table~\ref{tab:HPS}, where $\|{\bf v}_{o}\|$ is the magnitude of the lander's velocity at the start of an episode. \begin{table}[h] \fontsize{10}{10}\selectfont \caption{Hyperparameter Settings} \label{tab:HPS} \centering \newcolumntype{R}{>{\raggedleft\arraybackslash}p{1.8cm}} \begin{tabular}{ c | c } \hline Hyperparameter & Value\\ $v_{o}$ (m/s) & $\|{\bf v}_{o}\|$\\ $\tau_{1}$ (s) & 20\\ $\tau_{2}$ (s) & 100\\ $\alpha$ & -0.01\\ $\beta$ & -0.05\\ $\gamma$ & 0.01\\ $\eta$ & 10 \\ \end{tabular} \end{table} As shown in Eq.~\eqref{eq:obs}, the observation given to the agent during learning and testing is ${\bf v}_\text{error}={\bf v}-{\bf v}_\text{targ}$, with ${\bf v}_\text{targ}$ given in Eq.~\eqref{eq:vtarg1a} , the lander's estimated altitude, and the time to go. Note that aside from the altitude, the lander translational coordinates do not appear in the observation. This results in a policy with good generalization in that the policy's behavior can extend to areas of the full state space that were not experienced during learning. \begin{equation} \label{eq:obs} {\text{obs}}=\begin{bmatrix}{\bf v}_\text{error} & r_{2} & t_\text{go}\end{bmatrix} \end{equation} \section{Asteroid Landing Environment} The lander's initial conditions in the asteroid environment are shown in Table \ref{tab:exp1_ic}, where the values are in the target centered reference frame. Each episode starts with a random heading error for the lander's velocity between -45 and 45 degrees defined with respect to the lander's line of sight at the start of the landing phase. The variation in initial conditions is typically much less than this for such a mission. Indeed, (Reference \citenum{udrea2012sensitivity}) assume position and velocity standard deviations at the start of the Osiris Rex TAG maneuver of 1cm and 0.1cm/s respectively. The large range of initial conditions demonstrates the ability to learn a policy over a large theater of operations, which has the potential to simplify mission planning. The lander targets a position on the asteroid's pole that is a distance of 250m from the asteroid center. Due to the range of environmental parameters tested, the effect would be identical if the target position was on the equator, or anywhere else 250m from the asteroid's center of rotation. For purposes of computing the Coriolis and centrifugal forces, we translate the lander's position from the target centered reference frame to the asteroid centered reference frame. We define a landing plane with a surface normal depending on the targeted landing site, which allows use of the Mars landing environment with minimal changes. At the start of each episode, the lander's mass is uniformly set to between 450 and 500kg. At the start of each episode, the asteroid's angular velocity ($\omega$), mass ($M$), and the local solar radiation pressure (SRP) are uniformly drawn from within the bounds given in Table \ref{tab:ast_forces}. \begin{table}[h] \fontsize{8}{8}\selectfont \caption{Asteroid Lander Initial Conditions} \label{tab:exp1_ic} \centering \newcolumntype{R}{>{\raggedleft\arraybackslash}p{1.8cm}} \begin{tabular}{l | R | R } Parameter & min & max \\ \hline Distance (m) & 900 & 1100\\ Position Polar Angle $\theta$ (deg) & 0 & 45 \\ Position Azimuth Angle $\phi$ (deg) & -180 & 180 \\ Velocity Heading Error (deg) & -45 & 45 \\ Magnitude Velocity (cm/s) & 5 & 10 \\ Lander wet mass (kg) & 450 & 500 \\ \end{tabular} \end{table} \begin{table}[h] \fontsize{10}{10}\selectfont \caption{Asteroid Environmental Parameters} \label{tab:ast_forces} \centering \newcolumntype{R}{>{\raggedleft\arraybackslash}p{1.5cm}} \begin{tabular}{l | R | R } Parameter & min & max \\ \hline Rotational Velocity $\omega_{x}$ (rad/s) & $-1\times10^{-3}$ & $1\times10^{-3}$ \\ Rotational Velocity $\omega_{y}$ (rad/s) & $-1\times10^{-3}$ & $1\times10^{-3}$ \\ Rotational Velocity $\omega_{z}$ (rad/s) & $-1\times10^{-3}$ & $1\times10^{-3}$ \\ SRP $x$ ($m/s^{2}$) & $-1\times10^{-6}$ & $1\times10^{-6}$ \\ SRP $y$ ($m/s^{2}$) & $-1\times10^{-6}$ & $1\times10^{-6}$ \\ SRP $z$ ($m/s^{2}$) & $-1\times10^{-6}$ & $1\times10^{-6}$ \\ Mass ($\times10^{10}$ kg) & 2 & 20 \end{tabular} \end{table} \subsection{Dynamics Model} We model the Asteroid landings in 3-DOF, where the translational motion is modeled as follows: \begin{subequations} \begin{align} \Dot{\mathbf r} &= {{\mathbf v}}\label{eq:EQOM2a}\\ \Dot{\bf v} &= \frac{{\bf T}}{m} + \mathbf{a}_\text{SRP} - \frac{MG\mathbf{r}_{a}}{\|\mathbf{r}_{a}\|^3}+2\mathbf{\dot{r}}_{a}\times\bm{\omega}_a + (\bm{\omega}_a\times\mathbf{r}_{a})\times\bm{\omega}_a\label{eq:EQOM2b}\\ \Dot{m} &= -\frac{\lVert{{\bf T}}\rVert}{I_\text{sp}g_\text{ref}} \label{eq:EQOM2c} \end{align} \end{subequations} Here $\mathbf{r}$ is the lander's position in the target centered reference frame, $\mathbf{r}_a$ is the lander's position in the asteroid centered reference frame, ${{\bf T}}$ is the lander's thrust vector, $g_\text{ref}=9.8$ $\text{m}/\text{s}^{2}$, $I_\text{sp}=225$ s, and the lander's mass is $m$. $M$ is the asteroid's mass, and $G$ is the gravitational constant. ${\bf a}_\text{SRP}$ is a vector representing acceleration due to solar radiation pressure (SRP). $\bm{\omega}$ is a vector of rotational velocities in the asteroid centered reference frame. The lander's nominal wet mass is 500kg. We assume pulsed thrusters with a thrust capability of 2N along each axis in the target centered reference frame. The equations of motion are integrated using 4\textsuperscript{th} order Runge-Kutta integration with a 2s step size, and the navigation period is 6s. \subsection{Reward Function} The reward function used for the 3-DOF asteroid landing is slightly modified from the Mars landing reward function. We do not use a glideslope reward component in the terminal reward, and the shaping rewards are not piecewise. Specifically, we use the velocity field equations given in \eqref{eq:ast_vtarg1a} through \eqref{eq:ast_vtarg1b}. The hyperparameters given in Table \ref{tab:HPS} are also modified, with $\tau_{1}=250\text{ s}$ , $\alpha=\text{1.0}$, and $v_{o}=\text{0.5 m/s}$. The landing bonus limits are also modified, with $r_{lim}=\text{1 m}$ and $v_{lim}=\text{0.2 m/s}$. \begin{subequations} \begin{align} {\bf v}_{targ}&=-v_{o}\left(\frac{{\bf \hat{r}}}{\lVert{\bf \hat{r}}\rVert}\right)\left(1-\exp\left(-\frac{t_{go}}{\tau_1}\right)\right)\label{eq:ast_vtarg1a}\\ t_{go}&=\frac{\lVert{\bf \hat{r}}\rVert}{\lVert{\bf \hat{v}}\rVert}\label{eq:ast_vtarg1b} \end{align} \end{subequations} The observation used in the 3-DOF asteroid environment is given in Equation \eqref{eq:aobs}, where ${\bf v}_\text{error}={\bf v}-{\bf v}_\text{targ}$: \begin{equation} \label{eq:aobs} {\text{obs}}=\begin{bmatrix}{\bf v}_\text{error} & t_\text{go} \end{bmatrix} \end{equation} \section{Experiments} In each experiment, we optimize the policy using PPO, and then test the trained policy for 10,000 episodes. We compare the test performance of a DR/DV policy, RL policy, and meta-RL policy where the recurrent layer is unrolled through 1, 20, and 60 timesteps during the forward pass through the policy and value function networks during training. As a shorthand, we will refer to a policy where the recurrent network is unrolled T steps during the forward pass as a T-step meta-RL policy, and a non-recurrent policy as an RL policy. Note that unrolling the recurrent network layer for more timesteps results in a policy that can capture longer temporal dependencies. The DR/DV policy instantiates a DR/DV controller, which is thrust limited in the same way as the RL-agents. For the experiments using the asteroid environment, we tuned the nominal gravity parameter used in the time to go calculation in the DR/DV guidance law for best performance; it turns out that the optimal setting for this parameter is quite a bit higher than the actual environmental gravity. Table \ref{tab:drdv_base} gives baseline performance for the DR/DV policy under ideal conditions in the asteroid landing environment for comparison in the experiments that follow, giving statistics for the terminal position and velocity. Note that even under ideal conditions, the DR/DV policy results in a terminal velocity that is on the high side. \begin{table}[h] \fontsize{10}{10}\selectfont \caption{DR/DV Baseline Performance, Asteroid Environment} \label{tab:drdv_base} \centering \newcolumntype{R}{>{\raggedleft\arraybackslash}p{1.5cm}} \begin{tabular}{l | R | R | R } \hline Value & $\mu$ & $\sigma$ & max \\ \hline Position (m) & 0.1 & 0.0 & 0.6 \\ Velocity (cm/s) & 10.8 & 7.1 & 37.8 \end{tabular} \end{table} \subsection{Experiment 1: Mars Landing with Engine Failure} To test the ability of the recurrent policy to deal with actuator failure, we increase the Mars lander's maximum thrust to 24000N. In a 6-DOF environment, each engine would be replaced by two engines with half the thrust, with reduced thrust occurring when one engine in a pair fails. At the start of each episode, we simulate an engine failure in 3-DOF by randomly choosing to limit the available downrange or crossrange thrust by a factor of 2, and limit the vertical (elevation) thrust by a factor of 1.5. Some episodes occur with no failure; we use a failure probability of 0.5. A real engine would hopefully be more reliable, but we want to optimize with each failure mode occurring often. The goal is to demonstrate a level of adaptability that would not be possible without an adaptive guidance system. Testing the optimized policies resulted in catastrophic failure for the DR/DV policy, but the performance was similar for the RL and meta-RL policies. Therefore, in order to differentiate the performance between these policies, we further decreased the available thrust during engine failure, limiting the available downrange or crossrange thrust by a factor of 2.5, with the vertical (elevation) thrust remaining reduced by a factor of 1.5. We see in Tables \ref{tab:exp1_pos} and Tables \ref{tab:exp1_vel} that the DR/DV policy fails catastrophically, whereas the RL policy comes close to a safe landing except for rare outliers that bring the touchdown velocity unacceptably high. The 1-step Meta-RL policy's performance is acceptable on average, but the outliers are worse than that of the RL policy. Both the 20-step and 60-step Meta-RL policies achieve a safe landing, with minimum terminal glideslope of 87 degrees and fuel consumption similar to that obtained without engine failure. \begin{table}[h] \fontsize{10}{10}\selectfont \caption{Experiment 1: Norm of Terminal Position (m)} \label{tab:exp1_pos} \centering \newcolumntype{R}{>{\raggedleft\arraybackslash}p{0.8cm}} \begin{tabular}{l | R | R | R} Statistic & $\mu$ & $\sigma$ & max \\ \hline DR/DV & 144.9 & 227.5 & 1322.9 \\ RL & 0.7 & 0.3 & 2.2 \\ Meta-RL 1 step & 0.9 & 6.4 & 511.2 \\ Meta-RL 20 step & 0.3 & 0.2 & 1.2 \\ Meta-RL 60 steps & 0.3 & 0.2 & 1.3 \\ \end{tabular} \end{table} \begin{table}[h] \fontsize{10}{10}\selectfont \caption{Experiment 1: Norm of Terminal Velocity (m/s)} \label{tab:exp1_vel} \centering \newcolumntype{R}{>{\raggedleft\arraybackslash}p{0.8cm}} \begin{tabular}{l | R | R | R } Statistic & $\mu$ & $\sigma$ & max \\ \hline DR/DV & 19.51 & 19.90 & 63.13 \\ RL & 1.00 & 0.62 &4.76 \\ Meta-RL 1 step & 0.96 & 0.74 & 42.88 \\ Meta-RL 20 step & 0.98 & 0.06 & 1.15 \\ Meta-RL 60 steps & 1.00 & 0.06 & 1.16 \\ \end{tabular} \end{table} \subsection{Experiment 2: Mars Landing with High Mass Variation} Here we divide the lander engine's specific impulse by a factor of 6, which increases fuel consumption to around 1200kg on average, with a peak of 1600kg. This complicates the guidance problem in that the mass varies by a significant fraction of the lander's initial mass during the descent, and we do not give the agent access to the actual mass during the descent. Although we are using a Mars landing environment for this task, the large variability in mass would be more similar to the problem encountered in an EKV interception of an ICBM warhead, where there is a high ratio of wet mass to dry mass. We see in Tables \ref{tab:exp2_pos} and \ref{tab:exp2_vel} that the DR/DV policy has a rather large maximum position error, and an unsafe terminal velocity. The RL policy and 1-step Meta-RL policy give improved performance, but still result in an unsafe landing. The 20-step meta-RL policy achieves a good landing, which is slightly improved on by the 60-step meta-RL policy. \begin{table}[h] \fontsize{10}{10}\selectfont \caption{Experiment 2: Norm of Terminal Position (m)} \label{tab:exp2_pos} \centering \newcolumntype{R}{>{\raggedleft\arraybackslash}p{0.8cm}} \begin{tabular}{l | R | R | R} Statistic & $\mu$ & $\sigma$ & max \\ \hline DR/DV & 0.4 & 1.5 & 19.6 \\ RL & 0.7 & 0.2 & 3.7 \\ Meta-RL 1 step & 0.4 & 0.1 & 0.8 \\ Meta-RL RNN 20 steps & 0.6 & 0.1 & 1.0 \\ Meta-RL 60 steps & 0.6 & 0.2 & 1.1 \\ \end{tabular} \end{table} \begin{table}[h] \fontsize{10}{10}\selectfont \caption{Experiment 2: Norm of Terminal Velocity (m/s)} \label{tab:exp2_vel} \centering \newcolumntype{R}{>{\raggedleft\arraybackslash}p{0.8cm}} \begin{tabular}{l | R | R | R } Statistic & $\mu$ & $\sigma$ & max \\ \hline DR/DV & 0.63 & 0.96 & 5.39 \\ RL & 0.92 & 0.26 & 5.25 \\ Meta-RL 1 steps & 0.98 & 0.42 & 6.48 \\ Meta-RL 20 step & 1.17 & 0.07 & 1.36 \\ Meta-RL 60 steps & 1.06 & 0.05 & 1.21 \\ \end{tabular} \end{table} \begin{figure}[h] \begin{center} \includegraphics[width=.9\linewidth]{Figures/landing_DTM_fixed} \caption{Experiment 3: Landing with Integrated Guidance and Navigation. Trajectories are samples from neural network policy in closed-loop.} \label{fig:exp3_trajectory} \end{center} \end{figure} \subsection{Experiment 3: Mars Landing using Radar Altimeter Observations} In this task, the observations are simulated Doppler altimeter readings from the lander using a digital terrain map (DTM) of the Mars surface in the vicinity of Uzbois Valis. Since the simulated beams can cover a wide area of terrain, we doubled the map size by reflecting the map and joining it with original map. Note that the agent does not have access to the DTM, but will learn how to successfully complete a maneuver using rewards received from the environment. Although these observations are a function of both lander position and lander velocity, the observations do not satisfy the Markov property as there are multiple ground truth positions and velocities that could correspond to a given observation, making the optimal action a function of the history of past altimeter readings. For the simulated altimeter readings, the agent's state in the target centered reference frame is transformed to the DTM frame, which has a target location of [4000, 4000, 400] meters. In order to simulate altimeter readings fast enough to allow optimization to complete in a reasonable time, we had to create a fast altimeter model. The model uses a stack of planes with surface normals in the $z$ (elevation direction) that spans the elevations in the DTM. Each of the four radar beams has an associated direction vector, which, in conjunction with the lander's position, can quickly be used to find the intersection of the beam and the planes. The intersection $x$,$y$ indices are used to index the DTM, and the plane intersection with a z value closest to that of the indexed DTM elevation is used to determine the distance between the lander and the terrain feature hit by the beam. This is extremely fast (about 1000X faster than the ray-casting approach we used in [\citenum{gaudet2014navigation}], but is error prone at lower elevations as sometimes the closest distance between DTM elevation and associated plane intersect $z$ component is the far side of a terrain feature. Rather than call this a bug, we use it to showcase the ability of a recurrent policy to get remarkably close to a good landing, given the large errors. The reduction in accuracy at lower elevations is apparent in Table \ref{tab:mm_acc}. The accuracy was estimated by choosing 10,000 random DTM locations and casting a ray to a random position at the designated elevation. The length of this ray is the ground truth altimeter reading. We then checked what the measurement model returned from that lander position, with the error being the difference. Note that the DTM elevations range from 0 to 380m. In this scenario, the lander target's a terminal position 50m above the top of a hill at 350m elevation. The altimeter beams are modeled as having equal offset angles ($\pi/8$ radians) from a direction vector that points along the lander's body frame negative $z$-axis. The lander's negative z-axis is then aligned at each simulation step in a direction that is averaged between the lander's velocity vector and straight down. We thought this a reasonable assumption as we are modeling the lander in 3-DOF. We see from Tables \ref{tab:exp3_pos} and \ref{tab:exp3_vel} that although you would not want to entrust an expensive lander to this integrated guidance and navigation algorithm, the performance is remarkably good given the altimeter inaccuracy at lower elevations. We also note a steady improvement in performance as the number of recurrent steps is increased. Learning curves for the 1-step and 20-step RNN's are shown in Figures \ref{fig:exp2_lc-1step} and \ref{fig:exp2_lc}, which plots statistics for terminal position ($r_f$) and terminal velocity ($v_f$) as a function of episode, with the statistics calculated over the 30 episodes used to generate rollouts for updating the policy and value function. We see from the learning curves that the amount of steps we unroll the recurrent network in the forward pass has a large impact on optimization performance, and that for the 120 step case, the optimization initially makes good progress, but then stalls, likely due to the highly inaccurate altimeter readings at lower altitudes. Figure \ref{fig:exp3_trajectory} shows sampled trajectories over a 4 km squared deployment area. \begin{table}[h] \fontsize{8}{8}\selectfont \caption{Experiment3: Altimeter Error as function of lander elevation (m)} \label{tab:mm_acc} \centering \newcolumntype{R}{>{\raggedleft\arraybackslash}p{1.8cm}} \begin{tabular}{l | l | l | l | l } Elevation (DTM Frame) & mean (m) & std (m) & max (m) & miss \% \\ \hline 500 & 122 & 528 & 4467 & 12 \\ 600 & 25 & 201 & 2545 & 6 \\ 700 & 8 & 92 & 1702 & 4 \\ 800 & 4 & 60 & 1300 & 2 \\ \hline \end{tabular} \end{table} \begin{table}[h] \fontsize{10}{10}\selectfont \caption{Experiment 3: Norm of Terminal Position (m)} \label{tab:exp3_pos} \centering \newcolumntype{R}{>{\raggedleft\arraybackslash}p{0.8cm}} \begin{tabular}{l | R | R | R} Statistic & $\mu$ & $\sigma$ & max \\ \hline RL & 131 & 101 & 796 \\ Meta-RL 1 step & 114 & 95 & 1359 \\ Meta-RL 20 step & 78 & 41 & 390 \\ Meta-RL 120 steps & 72 & 40 & 349 \\ Meta-RL 200 steps & 59 & 42 & 288 \end{tabular} \end{table} \begin{table}[h] \fontsize{10}{10}\selectfont \caption{Experiment 3: Norm of Terminal Velocity (m/s)} \label{tab:exp3_vel} \centering \newcolumntype{R}{>{\raggedleft\arraybackslash}p{0.8cm}} \begin{tabular}{l | R | R | R } Statistic & $\mu$ & $\sigma$ & max \\ \hline RL & 48 & 18 & 145 \\ Meta-RL 1 step & 37 & 4 & 67 \\ Meta-RL 20 step & 26 & 2 & 39 \\ Meta-RL 120 steps & 28 & 2 & 44 \\ Meta-RL 200 steps & 23 & 4 & 40 \\ \end{tabular} \end{table} \begin{figure}[h] \begin{center} \includegraphics[width=.9\linewidth]{Figures/Exp2_LC-1step} \caption{Experiment 3: Learning Curves for 1 step RNN} \label{fig:exp2_lc-1step} \end{center} \end{figure} \begin{figure}[h] \begin{center} \includegraphics[width=.9\linewidth]{Figures/Exp2_LC.png} \caption{Experiment 3: Learning Curves for 120 step RNN} \label{fig:exp2_lc} \end{center} \end{figure} In a variation on this experiment, we assume that the lander has the ability to point its radar altimeters such that the central direction vector remains fixed on the target location, and therefore the beams themselves bracket the target. This functionality could be achieved with phased array radar, but a separate pointing policy would need to be learned that keeps the beams pointed in the required direction. Here we see (Tables \ref{tab:exp3p_pos} and \ref{tab:exp3p_vel}) that performance markedly improves. We postulate one reason for the improved performance is that the altimeter beams remain in areas of high terrain diversity. Indeed, when we repeat the experiment for a landing site further to the south (bottom of DTM), we find that performance degrades. Another factor could be that since the policy is focused on a small portion of the map, it does not "forget" the relationship between observations, actions, and advantages. \begin{table}[h] \fontsize{10}{10}\selectfont \caption{Experiment 3 (Target Pointing): Norm of Terminal Position (m)} \label{tab:exp3p_pos} \centering \newcolumntype{R}{>{\raggedleft\arraybackslash}p{0.8cm}} \begin{tabular}{l | R | R | R} Statistic & $\mu$ & $\sigma$ & max \\ \hline RL & 3.3 & 1.9 & 108.6 \\ Meta-RL 1 step & 3.3 & 1.9 & 108.6 \\ Meta-RL 20 step & 0.3 & 1.2 & 116.0 \\ Meta-RL 60steps & 0.4 & 1.5 & 111.5 \\ Meta-RL 120 steps & 0.6 & 1.6 & 139.8 \\ \end{tabular} \end{table} \begin{table}[h!] \fontsize{10}{10}\selectfont \caption{Experiment 3 (Target Pointing): Norm of Terminal Velocity (m/s)} \label{tab:exp3p_vel} \centering \newcolumntype{R}{>{\raggedleft\arraybackslash}p{0.8cm}} \begin{tabular}{l | R | R | R } Statistic & $\mu$ & $\sigma$ & max \\ \hline RL & 4.92 & 2.29 & 84.16 \\ Meta-RL 1 step & 5.75 & 1.38 & 69.80 \\ Meta-RL 20 step & 1.61 & 0.60 & 64.84 \\ Meta-RL 60 steps & 2.00 & 0.92 & 53.73 \\ Meta-RL 120steps & 2.23 & 0.94 & 57.47 \\ \end{tabular} \end{table} Taking into account the number of large outliers, it is probably best to focus on the average performance when comparing the network architectures. The general trend is that performance increases as we increase the number of steps we unroll the recurrent layer for the forward pass. This implies that the temporal dependencies for this task probably span a significant fraction of a single episode. \subsection{Experiment 4: Mars Landing with State Estimation Bias} In this experiment, the agent has access to a corrupted version of the ground truth state $\mathbf{x}=[\bf r, \bf v]$, specifically the agent's position observation is $\mathbf{o}_r=\mathbf{r}+p_{r}|\mathbf{r}|$ and the agent's velocity observation is $\mathbf{o}_v=\mathbf{v}+p_{v}|\mathbf{v}|$, where $p_r$ and $p_v$ are uniformly drawn between -0.1 and 0.1 at the start of each episode. We expect that the meta-RL policy will be able to quickly adapt to the level of sensor bias in a given episode. The results are given in Tables \ref{tab:exp4_pos} and \ref{tab:exp4_vel}. Here we do not see any large performance difference between RL and 60-step meta-RL policies. Interestingly, the 1-step and 20-step meta-RL have poor performance. This could be due to the policy misinterpreting the sensor bias as a force acting on the lander. To illustrate, assume a sensor bias of +10\%. For the case of no sensor bias, a given thrust level might result in some change in velocity. But with the sensor bias, this change in velocity would be larger, which could be interpreted as a force acting on the spacecraft in addition to the thrust. By attempting to adapt to this fictitious force, performance might be impaired rather than improved. There may be information in the temporal dependencies that allow distinguishing between external forces and sensor noise that are only captured with more than 20 steps. Since the RL policy uses only the current observation and advantage to update the policy, it cannot attempt to adapt to the sensor noise, but merely learns a policy that is robust to the noise. This could explain why the RL policy performs much better than the 1 or 20 step meta-RL policies. \begin{table}[h] \fontsize{10}{10}\selectfont \caption{Experiment 4: Norm of Terminal Position (m)} \label{tab:exp4_pos} \centering \newcolumntype{R}{>{\raggedleft\arraybackslash}p{0.8cm}} \begin{tabular}{l | R | R | R} Statistic & $\mu$ & $\sigma$ & max \\ \hline DR/DV & 0.1 & 1.7 & 75.7 \\ MLP & 0.9 & 0.3 & 3.3 \\ Meta-RL 1 steps & 0.6 & 0.7 & 59.6 \\ Meta-RL 20 step & 0.6 & 1.9 & 183.8 \\ Meta-RL 60 steps & 0.5 & 0.4 & 5.5 \\ \end{tabular} \end{table} \begin{table}[h!] \fontsize{10}{10}\selectfont \caption{Experiment 4: Norm of Terminal Velocity (m/s)} \label{tab:exp4_vel} \centering \newcolumntype{R}{>{\raggedleft\arraybackslash}p{0.8cm}} \begin{tabular}{l | R | R | R } Statistic & $\mu$ & $\sigma$ & max \\ \hline DR/DV & 0.48 & 0.93 & 20.14 \\ MLP & 1.11 & 0.11 & 1.48 \\ Meta-RL 1 steps & 1.11 & 0.24 & 22.39 \\ Meta-RL 20 step & 1.40 & 0.25 & 22.26 \\ Meta-RL 60 steps & 1.31 & 0.12 & 1.69 \\ \end{tabular} \end{table} \subsection{Experiment 5: Asteroid Landing with Unknown Dynamics} This experiment is a simulated landing on an asteroid with unknown and highly variable environmental dynamics, where the goal is to land on the asteroid's pole, which is assumed to be 250m from the asteroid center for purposes of computing centrifugal and Coriolis forces. We chose an asteroid landing environment for this task because the asteroid's rotation can cause the forces acting on the lander to vary widely, creating in effect an environment with unknown dynamics. Tables \ref{tab:exp5_pos} and \ref{tab:exp5_vel} give the test results. Again, we see that the DR/DV policy gives unacceptable performance, with a large position error and a landing velocity close to 1m/s. Interestingly, there is no real difference between the RL policy and the meta-RL policies. For this scenario, it appears that optimizing using parameter uncertainty provides the same performance as an adaptive policy. It is worth mentioning that we did perform a variation of this experiment in the Mars landing environment where the acceleration due to gravity was randomly drawn between -4m/s and 4m/s at the start of each episode. In this highly unrealistic environment, only the adaptive policies where the recurrent layers were unrolled for at least 20 steps during optimization consistently achieved a safe landing. Figures \ref{fig:exp5_lowdist} and \ref{fig:exp5_highdist} illustrate a single trajectory from the 60-step Meta-RL policy with a low and high external disturbance, respectively. The X, Y, and Z curves are elevation, crossrange, and elevation in the target centered reference frame. The N curve is the L2 norm. Note that the disturbance approaches the lander's maximum thrust capability in the high disturbance case. \begin{table}[h] \fontsize{10}{10}\selectfont \caption{Experiment 5: Norm of Terminal Position (m)} \label{tab:exp5_pos} \centering \newcolumntype{R}{>{\raggedleft\arraybackslash}p{0.8cm}} \begin{tabular}{l | R | R | R} Statistic & $\mu$ & $\sigma$ & max \\ \hline DR/DV & 0.3 & 1.9 & 44.0 \\ RL & 0.1 & 0.0 & 0.3 \\ Meta-RL 1 steps & 0.1 & 0.1 & 0.5 \\ Meta-RL 20 step & 0.1 & 0.1 & 0.5 \\ Meta-RL 60 steps & 0.1 & 0.1 & 0.6 \\ \end{tabular} \end{table} \begin{table}[h] \fontsize{10}{10}\selectfont \caption{Experiment 5: Norm of Terminal Velocity (cm/s)} \label{tab:exp5_vel} \centering \newcolumntype{R}{>{\raggedleft\arraybackslash}p{0.8cm}} \begin{tabular}{l | R | R | R } Statistic & $\mu$ & $\sigma$ & max \\ \hline DR/DV & 7.5 & 7.6 & 85.7 \\ RL & 2.1 & 0.7 & 5.1 \\ Meta-RL 1 steps & 2.6 & 0.8 & 16.9 \\ Meta-RL 20 step & 2.5 & 0.9 & 7.2 \\ Meta-RL 60 steps & 2.5 & 0.9 & 7.9 \\ \end{tabular} \end{table} \begin{figure}[h] \begin{center} \includegraphics[width=.9\linewidth]{Figures/Exp5_lowdist.png} \caption{Experiment 5: 60-step Meta-RL Policy with low disturbance} \label{fig:exp5_lowdist} \end{center} \end{figure} \begin{figure}[h!] \begin{center} \includegraphics[width=.9\linewidth]{Figures/Exp5_highdist.png} \caption{Experiment 5: 60-step Meta-RL Policy with high disturbance} \label{fig:exp5_highdist} \end{center} \end{figure} \subsection{Experiment 6: Asteroid Landing using Doppler LIDAR altimeter readings} In our final experiment, we integrate navigation and guidance in the Asteroid 3-DOF environment, giving the agent access to only Doppler LIDAR altimeter readings during the landing. We simplify the problem by using a reduced set of initial conditions, with the polar angle in Table \ref{tab:exp1_ic} reduced to 22.5 degrees, and the range of rotational velocities is reduced to between $-1\times10^{-5} \text{ and } 1\times10^{-5}$ rad/s. We assume that in the body frame one altimeter beam is pointed straight down, and four more beams are equally spaced with an offset angle of 12 degrees from the first. Note that this could be implemented with a single scanning LIDAR system. At each simulation time step, we then rotate the body so that the -z body frame axis is aligned with the lander's velocity vector, i.e., the center beam is always aligned with the lander's velocity vector. A shape model of asteroid rq-36 with 1-m resolution is down sampled to 5m resolution to reduce the required amount of ray-casting operations, and we use the same ray casting approach as in [\citenum{gaudet2014real}] to determine where the altimeter beams intersect the asteroid and the Doppler closing velocity associated with each beam. The observation given to the agent is then the concatenation of the five range readings and five Doppler closing velocities $\mathbf{o} \in \mathbb{R}^{10}$. Tables \ref{tab:exp6_pos} and \ref{tab:exp6_vel} tabulate the test results. We see that the average miss distance approaches the shape model resolution, although the occasional outlier exceeds 3 times the resolution. Terminal velocity is also on the high side. We see a similar patter to that in the Mars landing using RADAR experiment, where the best results are for the 60-step meta-RL policy, and a steady decrease in performance as we unroll the recurrent layer fewer steps in the forward pass during optimization. \begin{table}[h] \fontsize{10}{10}\selectfont \caption{Experiment 6: Norm of Terminal Position (m)} \label{tab:exp6_pos} \centering \newcolumntype{R}{>{\raggedleft\arraybackslash}p{0.8cm}} \begin{tabular}{l | R | R | R} Statistic & $\mu$ & $\sigma$ & max \\ \hline RL & 8.4 & 22.5 & 1533.2\\ Meta-RL 1 steps & 44.6 & 167.4 & 1018.0 \\ Meta-RL 20 step & 9.8 & 5.9 & 36.8\\ Meta-RL 60 steps & 7.9 & 4.6 & 28.2 \\ \end{tabular} \end{table} \begin{table}[h] \fontsize{10}{10}\selectfont \caption{Experiment 6: Norm of Terminal Velocity (cm/s)} \label{tab:exp6_vel} \centering \newcolumntype{R}{>{\raggedleft\arraybackslash}p{0.8cm}} \begin{tabular}{l | R | R | R } Statistic & $\mu$ & $\sigma$ & max \\ \hline RL & 13.7 & 5.1 & 312.3\\ Meta-RL 1 steps & 30.7 & 77.4 & 42.2\\ Meta-RL 20 step & 22.8 & 8.2 & 54.9 \\ Meta-RL 60 steps & 14.6 & 3.0 & 35.7 \\ \end{tabular} \end{table} \section{Conclusion} We optimized an adaptive guidance system using reinforcement meta learning with recurrent policy and value function in four different environments, and demonstrated the ability of the optimized policy to adapt in real time. In all cases both the RL and 60-step Meta-RL policies outperformed the DR/DV policy, and in the engine failure and high mass variation experiments, the 60-step meta-RL policy outperformed the RL policy. In some cases the 1-step and 20-step Meta-RL policies performed relatively poorly. For a given task, there is likely an optimal number of steps to unroll the recurrent layer during the forward pass, with the optimal number of steps depending on the bandwidth of the temporal dependencies in the sequences of observations, actions, and advantages. If this number of steps is too low the policy may not learn dependencies that are critical to the mastering the task. Although not examined in this work, too many steps could also be a problem if it is much greater than the temporal dependency bandwidth, and when the number of steps gets very large, there are also issues with exploding and vanishing gradients. Therefore, we suggest that the number of steps to unroll the recurrent network in the forward pass should be treated as a hyperparameter during optimization. We then optimized an integrated guidance and navigation system for both the 3-DOF Mars and asteroid landing environments, with the agent only getting access to Doppler radar and LIDAR altimeter readings, respectively. In both of these cases, the recurrent layer of the Meta-RL policy provided superior performance to the RL policy. This was expected, as both of these tasks use non-Markov observations, with a given ground truth state potentially mapping to multiple observations. Only by looking at a history of observations is it possible to reduce this to a one to one mapping. Since sensor output feedback is an open problem with optimal control methods, we did not compare performance to that of the DR/DV guidance law. The results of the Mars landing experiment were rather poor, which could be at least partly attributed to the errors in the fast ray tracing algorithm that was used to model the sensor. The asteroid landing experiment produced better results, closer to that which would be obtainable with access to the ground truth lander state. We attribute the higher performance in the asteroid landing environment to two factors: an accurate ray tracing algorithm and the curvature of the asteroid, the latter resulting in a given ground truth state mapping to fewer observations. The take away from this work is that the ability to optimize using parameter uncertainty leads to robust policies, and the ability of a recurrent policy to adapt in real time to dynamic environments makes it the best performing option in environments with unknown or highly variable dynamics. This capability has the potential to dramatically simplify mission planning for asteroid close proximity missions. The results for integrating guidance and navigation were not as promising, as performance was poor compared to what is possible using a separate navigation system. To illustrate, in [\citenum{gaudet2014real}], we couple a navigation system using a Rao-Blackwellized particle filter and LIDAR measurements with the DR/DV policy (in an environment with known dynamics) and consistently achieve a simulated pinpoint soft landing. We repeat this for a Mars landing using RADAR altimeter measurements in [\citenum{gaudet2014navigation}]. Clearly, more work is needed to develop a fully integrated guidance, navigation, and control system using the RL framework that achieves higher performance than that possible with a separate navigation system. We only scratched the surface of applications that would benefit from adaptive guidance, and future work will use the RL meta-learning framework for problems in orbital refueling, exoatmospheric intercepts, and hypersonic reentry. We will also explore different sensor models when integrating navigation into the policy, where observations will consist of direct sensor output using simulated camera images, flash LIDAR, and electo-optical sensors. \section{References} \bibliographystyle{AAS_publication}
{'timestamp': '2019-04-23T02:26:09', 'yymm': '1904', 'arxiv_id': '1904.09865', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.09865'}
arxiv
\section{Introduction} The term Malware is derived from \textbf{Mal}icious Soft\textbf{ware}, and initially, malware was developed to show one’s technical skills, but now it has become a profit-driven industry. Over the last decade, android popularity has grown immensely, and its current mobile market share is more than 75\% \cite{marketshare}. The popularity of android Operating System (OS) is because of its open source platform and the availability of a large number of feature-rich applications for it. These applications should ideally be benign, but because of malicious intent of the adversaries, it can be made to perform some unwanted activities in the devices, e.g., stealing the personal information, sending short message service to a premium number, spying on the user, etc. According to G DATA Security, 3809 new malware samples were detected in 2011 \cite{gdata}. Since then there has been a rapid rise in the number of android malware, and in 2017 more than three million new malware samples have been identified. In this, nearly seven million applications (70\% higher as compared to 2016) were removed from Google Play which was either malware or had some unacceptable content \cite{androidblog}. A report published by McAfee in 2018 shows that there has been an increase of 36\% in AdClick Frauds, 23\% spyware and 12\% Banking Trojan from the previous year \cite{mcafee2018q1}. Another McAfee Threat Report suggests that by the end of 2017 there were more than twenty million malware samples on the android platform out of which around $\sim$2.5 millions new samples were detected in quarter-3 itself \cite{mcafeedec2017}. For detection of android malware, most of the anti-malware rely on the signature-based detection techniques. But generating and maintaining signature of such a huge number malware is a herculean task. Thus in the last couple of years, researchers have actively started to explore different ways to detect the malware effectively and efficiently. Therefore recently many authors \cite{you2015android} \cite{tam2015copperdroid} \cite{de2015using} \cite{lindorfer2014andrubis} \cite{enck2014taintdroid} have proposed machine learning as a useful technique to counter the malware, and in this field, the research can be broadly divided into two parts: the feature extraction/selection and methods for the classifications. \textbf{\textit{Feature extraction}} is an important component of machine learning, and for the effective and efficient classification, features can be extracted without executing the application (static) or during the execution (dynamic) for the detection of malware. Although static analysis gives a better code coverage, it has other limitations. However, with the static feature, several authors have proposed various malware detection models, e.g., Au et al. \cite{au2012pscout} in PScout extracted permissions used in 4 different android OS and found that there are over 75 unique permissions out of which 22\% of the non-system permissions are unnecessary. Lindorfer et al. proposed a fully automated ANDRUBIS system to analyze the android applications from which they found that malicious application on an average request for 13 permission while for good applications the number is just 4.5 \cite{lindorfer2014andrubis}. Ashu et al. used a combination of static opcode frequency and dangerous permissions for malware classification \cite{ashuandroidgroupwise}. Puerta et al. with the Genome dataset found that opcode frequency is better feature vector than the permissions \cite{de2015using}. Malware can also be analyzed while executing them in a controlled environment to find the features, e.g., network traffic, application programming interface, system calls, information flow for the classifications. In this, Enck et al. built TaintDroid to track the runtime information flow and found many instances of private data being misuse in different applications \cite{enck2014taintdroid}. Tam et al. developed CopperDroid to model well know process-OS interaction and also inter-process and intra-process communications for effective malware detection \cite{tam2015copperdroid}. You et al. in 2015 did a comprehensive analysis using Dalvik opcodes as features to find the potential threats \cite{you2015android}. Finally, the features obtained by the static or dynamic approach is an important ingredient for the \textbf{\textit{classification}}. In this, Puerta et al. proposed a single class classifier for malware detection based on opcode occurrence and achieved an accuracy of 85\% \cite{de2015using}. Ashu et al. used opcode occurrence on five different classifiers and obtained the highest accuracy of 79.27\% with the functional tree \cite{sharma2018investigation}. Feizollah et al. proposed AndroDialysis, which used intent and permission separately and then combine them to make an extensive feature vector \cite{feizollah2017androdialysis}. Their analysis shows that independently intent and permission achieved a detection rate of 91\% and 83\% respectively. However, combing both the features shows an increase in the detection rate (95.5\%). Wu et al. proposed DroidMat, which collects permission, intent, API Call and applied various machine learning algorithms like k-nearest neighbor and naive bayes for malware detection, and achieved the highest accuracy of 97.87\% \cite{wu2012droidmat}. Arp et al. used permission, intent, API call, network address in the Drebin dataset of more than 5000 malware samples and utilized support vector machine for the classification, and achieved an accuracy of 94\% \cite{arp2014drebin}. Recently Ashu et al. used opcode frequency as a feature and grouped them based on permission to achieve a detection accuracy of 97.15\% \cite{ashuandroidgroupwise}. Li et al. used permission as the feature vector and used three level pruning for identification of significant permission for effective detection of malware and benign \cite{li2018significant}. They have used 22-most significant permissions and achieved a detection rate of 93.62\%. Rana et al. use different tree based classifiers like a decision tree, random forest, gradient boosting and extremely randomized tree with n-gram approach and shown that with 3-gram and random forest classifier one can achieve an accuracy up to 97.24\% \cite{rana2018evaluation}. Chen et al. used n-gram opcode sequence with exemplar feature selection method and random forest classifier to detect the malware only with 95.6\% correctly with 4-gram approach \cite{chen2018tinydroid}. The above-proposed methods using different machine learning seem to be not sufficient to identify sophisticated advanced malware. However, it appears that detection accuracy can be improved by using the clustering method. Therefore in this paper, we propose a novel scalable and effective clustering method to improve the detection accuracy of the android malware. Hence, the rest of the paper is organized as follows: Section 2 introduces the dataset and feature extraction. Section 3 contains the experimental analysis and results. Finally, Section 4 concludes the paper. \section{Dataset and Feature Extraction} In the area of machine learning, it is very important that how good one can make/train a model to identify the target in new/test data, and in turn, the quality of the trained model depends on the dataset and how the features are extracted/selected from it. Understanding the fact we used Drebin dataset \cite{arp2014drebin} which is one of the largest benchmark malware samples, which consists of 5550 malware samples from more than 20 different families. It also includes all the malware samples from the Android Malware Genome Project \cite{jiang2012dissecting}. For the benign file, we have collected 8500 android applications between 2016-17 from various sources (Google Play \cite{googleplay}, Third-party app stores, alternate marketplaces, etc.). To test the downloaded files is benign or not, we verified them using VirusTotal \cite{virustotal} (it is a subsidy of Alphabet which is an aggregator of 40-60 antivirus including AVG, Bitdefender, F-Secure, Kaspersky Lab, McAfee, Norton, Panda Security, etc. and provide various API’s to check whether the application is malware/benign) services, and we declare an application as malicious if one or more antivirus from virustotal.com categories it as malware. Thus after verifying all the downloaded samples from VirusTotal, we were left with 5720 samples for the experimental analysis. For the analysis, we disassemble all the sample file by APKtool \cite{apktool} to extract all the opcodes for the clustering and classifications. For this purpose, we have taken the frequency of the opcode as a feature vector and generated the feature vector for the complete dataset as $11266 \times 256$ matrix, where rows represent different files, and a column represents the frequency of the opcode in that particular file. \section{Experimental Analysis and Result} A schematic of the experimental analysis of our novel proposed approach/method is depicted in figure \ref{Flowchart}. We first experimented by the regular method given by the various authors \cite{jiang2012dissecting} \cite{arp2014drebin} \cite{wu2012droidmat} \cite{feizollah2017androdialysis} \cite{de2015using}, i.e., without clustering/grouping the data for comparison of accuracy with our novel method (first we find the optimal number of cluster and then identify the malicious android applications), and we used the scikit-learn \cite{sklean} machine learning library for all the clustering and classifications. Also Numpy python library has been used to handle large multidimensional arrays and matrices \cite{numpy}. \subsection{Malware Detection without clustering} To understand the performance of the different type of classifiers by regular used method (i.e., taking the whole data altogether), we used Logistic Regression (LR), Naive Bayes (NB), Support Vector Machine (SVM), Decision Tree (DT), and Random Forest (RF). For the classification, we used all 256 opcodes as features and ten-fold cross-validation (it divides the data into ten equal parts out of which nine parts are used for training the model, and one part is used for testing. This exercise is completed ten times with different combinations of training and testing set and at last average result is taken into account) and the result obtained is shown in figure \ref{crossval}. From the analysis, we found that after three-fold cross-validation the accuracy of classifiers is more or less same. The detailed results of the experiment conducted by all the five classifiers in terms of Accuracy, Recall, and Specificity are given in the table \ref{table_without_cluster}, where $$ \text{Accuracy} = \frac{\text{Number of Malware and Benign correctly classified}}{\text{Total Number of files in the dataset}}$$ $$ \text{True Postive Rate (TPR)} = \frac{\text{Number of Malware correctly classified}}{\text{Number of Malware in the dataset}}$$ $$ \text{True Negative Rate (TNR)} = \frac{\text{Number of Benign correctly classified}}{\text{Number of Benign in the dataset}}$$ $$$$ The analysis also shows that the tree-based RF classifier outperformed the other classifiers with the best accuracy of 95.82\%. \begin{figure}[h] \centering \includegraphics[scale=.45]{flowchart} \caption{Flowchart of our novel method to improved malware detection. accuracy} \label{Flowchart} \end{figure} \begin{table}[h] \begin{center} \caption{Accruacy, TPR and TNR obtained without clustering the data.} \medskip \label{table_without_cluster} \begin{tabular}{|c|c|c|c|c|c|} \hline \textbf{} & \textbf{\begin{tabular}[c]{@{}c@{}}Logistic\\ Regression\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}Naive \\ Bayes\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}Support Vector\\ Machines\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}Decision \\ Trees\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}Random \\ Forest\end{tabular}} \\ \hline \textbf{Accuracy} & 87.96 & 76.66 & 84.68 & 93.70 & 95.82 \\ \hline \textbf{Recall/TPR} & 92.44 & 94.89 & 69.38 & 95.27 & 95.40 \\ \hline \textbf{Specificity/TNR} & 84.16 & 58.49 & 99.96 & 92.65 & 95.73 \\ \hline \end{tabular} \end{center} \end{table} \subsection{Clustering based Malware Detection} To improve the detection accuracy of malicious applications, we first studied the five different clustering algorithms (k-means, Agglomerative, BIRCH, DBSCAN, and GMM) to find the clusters in the dataset. The analysis shows (table \ref{ClusterAnalysis}) that the k-means algorithm forms the best cluster (Calinski-Harabasz \cite{calinski1974dendrite} and Silhouette score \cite{rousseeuw1987silhouettes} of the k-means is best among the selected five clustering algorithm). Further, we observed that the two clusters formed by the k-means would be best for the classification of malicious applications (fig \ref{elbow}) and in the obtained cluster, we find that cluster-1 contains total 8760 files and is dominated by malware files whereas the cluster-2 contains total 2780 files dominated by benign files. However, for the analysis, we have balanced the dataset using SMOTE \cite{chawla2002smote}. Now for the classification, we use the same set of classifiers that are used for the classification without clustering and found that the overall accuracy, TPR and TNR obtained by clustering the data is significantly more than without clustering the data and the results obtained are given in table \ref{table_with_clustering}. \begin{figure}[h] \begin{minipage}[b]{0.5\linewidth} \includegraphics[trim=0cm 0cm 3.20cm 3.0cm, clip, height=5.2cm, width=6cm]{crossval} \caption{Classifier accuracy with the k-fold Cross-Validation.} \label{crossval} \end{minipage} \begin{minipage}[b]{0.5\linewidth} \includegraphics[trim=0cm 0cm 3.50cm 2.30cm, clip, height=5.2cm, width=6cm]{optimalK_KMEANS} \caption{Number of clusters with SSE by k-means algorithm.} \label{elbow} \end{minipage} \end{figure} \begin{table} \begin{center} \caption{Number of clusters with different clustering algorithm and its Calinski Harabaz and Silhouette Score.} \bigskip \label{ClusterAnalysis} \begin{tabular}{|c|c|c|c|} \hline &&&\\ & No of Clusters & Calinski Harabaz Score & Silhouette Score \\ &&&\\\hline \multirow{4}{*}{\textbf{k-means Clustering}} & \textbf{2} & \textbf{28568.28} & \textbf{0.7377} \\ \cline{2-4} & 3 & 25493.58 & 0.7005 \\ \cline{2-4} & 4 & 22109.38 & 0.6167 \\ \cline{2-4} & 5 & 22971.34 & 0.6013 \\ \hline \multirow{4}{*}{\textbf{Agglomerative Clustering}} & 2 & 24706.58 & 0.7256 \\ \cline{2-4} & 3 & 21245.43 & 0.7069 \\ \cline{2-4} & 4 & 20046.19 & 0.6043 \\ \cline{2-4} & 5 & 20939.81 & 0.6052 \\ \hline \multirow{4}{*}{\textbf{BIRCH Clustering}} & 2 & 24735.95 & 0.7258 \\ \cline{2-4} & 3 & 20844.19 & 0.7080 \\ \cline{2-4} & 4 & 18494.73 & 0.6656 \\ \cline{2-4} & 5 & 21261.10 & 0.6056 \\ \hline \multirow{4}{*}{\begin{tabular}[c]{@{}c@{}}\textbf{Gaussian Mixture Model}\\ \textbf{Clustering}\end{tabular}} & 2 & 8398.36 & 0.4716 \\ \cline{2-4} & 3 & 2738.43 & 0.1967 \\ \cline{2-4} & 4 & 1640.20 & 0.1010 \\ \cline{2-4} & 5 & 4813.65 & 0.2519 \\ \hline \multirow{4}{*}{\textbf{DBSCAN Clustering}} & eps = 5000 & 1380.75 & 0.1539 \\ \cline{2-4} & eps = 10000 & 3469.39 & 0.5316 \\ \cline{2-4} & eps = 15000 & 3743.52 & 0.5349 \\ \cline{2-4} & eps = 20000 & 4858.33 & 0.6753 \\ \hline \end{tabular} \end{center} \vspace{1.0cm} \begin{center} {\footnotesize \caption{Accuracy, TPR and TNR after clustering the data.} \label{table_with_clustering} \begin{tabular}{|c|c|c|c|c|c|} \hline \textbf{} & \textbf{\begin{tabular}[c]{@{}c@{}}Logistic\\ Regression\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}Naive \\ Bayes\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}Support Vector\\ Machines\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}Decision \\ Trees\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}Random \\ Forest\end{tabular}} \\ \hline \textbf{Accuracy} & 92.23 & 81.01 & 92.29 & 97.92 & 98.34 \\ \hline \textbf{Recall/TPR} & 91.49 & 96.46 & 84.59 & 97.59 & 97.30 \\ \hline \textbf{Specificity/TNR} & 92.98 & 65.57 & 99.96 & 98.25 & 99.38 \\\hline \end{tabular} } \end{center} \end{table} \section{Conclusion} To detect the malware, generally signature-based anti-malware are used which is not good enough to detect the advanced obfuscated malware. Hence time-to-time to detect the advanced malware different machine learning solutions are proposed by various authors. In this, we proposed a novel scalable and effective clustering based android malware detection system. The analysis shows an overall improvement of accuracy with RF (98.34\%) by our proposed clustering method. The accuracy achieved by our approach outperformed the recent accuracy obtained by the authors viz. Ashu et al. (97.15\%), Li et al. (93.62\%) and Rana et al. (97.24\%). Also, the experimental analysis shows that despite the TNR of SVM and TPR of DT are marginally better than the RF, the overall accuracy of RF is best among the tested classifiers, this is because the TPR of SVM and TNR of DT is far below the RF classifier. As the results are significant, therefore we are developing an API for the identification of the android malicious apps, which we will be free to the research community. \bibliographystyle{plain}
{'timestamp': '2019-04-24T02:06:20', 'yymm': '1904', 'arxiv_id': '1904.10142', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.10142'}
arxiv
\section{\@ifstar{\starsection}{\nostarsection}} \newcommand\nostarsection[1] {\sectionprelude\origsection{#1}\sectionpostlude} \newcommand\starsection[1] {\sectionprelude\origsection*{#1}\sectionpostlude} \newcommand\sectionprelude{% \vspace{0.1em} } \newcommand\sectionpostlude{% \vspace{0.1em} } \makeatother \vspace{-10pt} \section{Introduction} \vspace{-4pt} Recently, security of cyber-physical systems has drawn much research interest within the discrete-event systems and formal methods community~\cite{CarvalhoEnablementAttacks},~\cite{Carvalho2018},~\cite{Su2018},~\cite{Goes2017},~\cite{Lanotte2017},~\cite{Jones2014},~\cite{WTH17},\\~\cite{LACM17},~\cite{Lima2018},~\cite{K2016},~\cite{R17},~\cite{Lin2018},~\cite{Zhu2018},~\cite{LZS19},~\cite{WBP19},~\cite{YL19},~\cite{HMR18}. For a recent survey on the discrete-event systems based approach for the security of cyber-physical systems, the reader is referred to~\cite{Aida19}. In this paper, we shall focus on discrete-event systems as our model of cyber-physical systems and consider the problem of attacker synthesis, as a major step towards solving the resilient supervisor synthesis problem~\cite{LZS19}. In particular, we consider the synthesis of a successful actuator attacker~\cite{Lin2018},~\cite{LZS19}. We assume the goal of the actuator attacker is to remain covert in the process of attacking the closed-loop systems until it causes damages, much in parallel to the framework of~\cite{Su2018}. An actuator attacker is said to be successful if it achieves its goal. Correspondingly, a supervisor is said to be resilient if a successful actuator attacker does not exist. We also consider the synthesis of (successful) covert actuator attackers that can eavesdrop the control commands issued by the supervisor, extending our recent work~\cite{Lin2018}. Some of the existing works consider the problem of deception attack~\cite{Su2018},~\cite{Goes2017},~\cite{WTH17}, where the attacker would accomplish the attack goal by altering the sensor readings. There are also works that deal with actuator attacks as well as sensor attacks~\cite{Carvalho2018},~\cite{LACM17},~\cite{Lima2018},\\~\cite{WBP19}. We provide some comparisons between the existing works and this work in the following. \begin{enumerate} \item The works of~\cite{Carvalho2018},~\cite{LACM17} and~\cite{Lima2018} do not require the attackers to possess any knowledge of the system's models\footnote{There is in fact an exception. In sensor insertion scenario,~\cite{Carvalho2018} assumes the attacker knows the model of the supervisor.} and, in particular, they only consider the reachability of damages as the attackers' goal; consequently, they only need to consider the ``worst case" attacker~\cite{Carvalho2018} that performs enablement attacks wherever it is possible, which makes the problem of attacker synthesis irrelevant in their problem setup. In contrast, we consider those attackers that know the models of the system, including the plant's and the supervisor's models. This allows the attacker to make informed attack decisions and also makes it possible to model different goals and constraints of the attackers. In particular, this does allow us to model the synthesis of covert attackers~\cite{Su2018},~\cite{Lin2018},~\cite{LZS19}. Indeed, in this paper, we consider the synthesis of covert attackers with both damage-nonblocking goal and damage-reachable goal. In addition, compared with~\cite{Carvalho2018},~\cite{LACM17} and~\cite{Lima2018}, we allow the attacker and the supervisor to have different observation capabilities. While disablement attack is considered to be not useful in~\cite{Carvalho2018},~\cite{LACM17} and~\cite{Lima2018}, it is often crucial for the success of covert attackers, when combined with enablement attacks. \item The only means of system protection in the setup of~\cite{Carvalho2018} and~\cite{LACM17} is by making use of an intrusion detection module for detecting the presence of an attacker, along with a fixed supervisor that may not have been properly designed against the attackers. Their setup does not consider the possibility of modifying the supervisor to render attack impossible or harder. In comparison, the resilient supervisor synthesis based approach in~\cite{Su2018},~\cite{LZS19} allows and explicitly considers the synthesis of a supervisor that can prevent the damages caused by attackers, by making attack impossible or by making attack futile\footnote{The supervisor could be designed in such a way that either every disabled event is non-attackable, which makes (enablement) attack impossible, or every disabled attackable event cannot bring the system to damage, which makes attack futile.}, even in the absence of a monitor, or by discouraging attack attempt that may cause the violation of covertness, by using a monitor~\cite{Lin2018}. The feature that the presence of a monitor can discourage attack attempt is not available in~\cite{Carvalho2018} and~\cite{LACM17}. The work of~\cite{WBP19} attempts to generalize~\cite{Su2018} and uses non-deterministic finite state transducers as the unifying models to address the security against combined actuator attacks and sensor attacks. However, it only considers resilient supervisor verification upon newly defined controllability condition. The problem of synthesis of resilient supervisor remains unsolved if the controllability condition is not satisfied. Similarly,~\cite{Carvalho2018} and~\cite{LACM17} only address the problem of verification, instead of synthesis, for security. We note that solving the problem of attacker synthesis in this work naturally solves the resilient supervisor verification problem and can be used for solving the resilient supervisor synthesis problem as well, as explained in~\cite{LZS19}. While~\cite{Lima2018} also studies undetectable attacks (in addition to detectable attacks), they consider the undetectability of the ``worst case" attacker and the UNA-security verification condition~\cite{Lima2018} under which security against undetectable ``worst case" attacker can be established. We start from covertness goal and synthesize covert attackers fulfilling damage-infliction goals. Again, \cite{Lima2018} only studies the problem of verification, instead of synthesis, for security. While resilience against risky attackers of~\cite{Carvalho2018},~\cite{LACM17} and~\cite{Lima2018} implies resilience against covert attackers, if the system designer has the additional information that any potential attacker intends to remain covert, this information can be used and often allows a larger design space of resilient supervisors for the system designer. \item In~\cite{Lin2018},~\cite{Zhu2018} and~\cite{LZS19}, we have considered partially-observing attackers that also eavesdrop the control commands issued by the supervisor. Given the same observation capability over the plant events, control command eavesdropping attackers are more powerful than the counterparts that do not eavesdrop the control commands. In~\cite{HMR18}, a notion of a powerful attacker is defined for passive attackers; a passive attacker is considered to be powerful in~\cite{HMR18} if it can directly query some information about the current state of the plant. A control command eavesdropping attacker in~\cite{Lin2018} can be considered as a powerful attacker in the sense of~\cite{HMR18}. In particular, the supervisor's control command does encode some knowledge of the partially-observing supervisor on the execution of the plant. We consider the synthesis of both types of covert actuator attackers and develop reduction based synthesis procedures. Compared with~\cite{Lin2018} that also addresses the covert actuator attacker synthesis problem, we do not require normality $\Sigma_c \subseteq \Sigma_o, \Sigma_{c, A} \subseteq \Sigma_{o, A}$ and the synthesis procedure is much simpler \end{enumerate} The paper is organized as follows: Section~\ref{sec: prel} is devoted to the preliminaries. Then, in Section~\ref{section:SS}, we shall provide a detailed explanation about the system setup, including a formalization of the supervisor, the non-eavesdropping actuator attacker, the damage automaton, the monitoring mechanism, the attacked closed-loop system and the attack goal. In Section~\ref{section: AS}, we then provide straightforward reductions from the actuator attacker synthesis problems to the supervisor synthesis problems. In Section~\ref{section: eavesdrop}, we then consider control command eavesdropping attackers. Finally, discussions and conclusions are presented in Section~\ref{section:DC}. \vspace{-12pt} \section{Preliminaries} \label{sec: prel} \vspace{-4pt} We assume the reader is familiar with the basics of supervisory control theory~\cite{WMW10},~\cite{CL99} and automata theory~\cite{HU79}. In this section, we shall recall the basic notions and terminology that are necessary to understand this work. For any two sets $A$ and $B$, we use $A \times B$ to denote their Cartesian product and use $A-B$ to denote their set difference. $|A|$ is used to denote the cardinality of set $A$. A (partial) finite state automaton $G$ over alphabet $\Sigma$ is a 5-tuple $(Q, \Sigma, \delta, q_0, Q_m)$, where $Q$ is the finite set of states, $\delta: Q \times \Sigma \longrightarrow Q$ the partial transition function\footnote{We write $\delta(q, \sigma)!$ to mean $\delta(q, \sigma)$ is defined and write $\neg \delta(q, \sigma)!$ to mean $\delta(q, \sigma)$ is undefined. As usual, $\delta$ is naturally extended to the partial transition function $\delta: Q \times \Sigma^* \rightarrow Q$ such that, for any $q \in Q$, any $s \in \Sigma^*$ and any $\sigma \in \Sigma$, $\delta(q, \epsilon)=q$ and $\delta(q, s\sigma)=\delta(\delta(q,s),\sigma)$. We define $\delta(Q' ,\sigma)=\{\delta(q, \sigma) \mid q \in Q'\}$ for any $Q'\subseteq Q$.}, $q_0 \in Q$ the initial state and $Q_m \subseteq Q$ the set of marked states. Let $L(G)$ and $L_m(G)$ denote the closed-behavior and the marked-behavior of $G$, respectively~\cite{WMW10}. When $Q_m=Q$, we also write $G=(Q, \Sigma, \delta, q_0)$ for simplicity. For any two finite state automata $G_1=(Q_1, \Sigma_1, \delta_1, q_{1,0}, Q_{1, m}), G_2=(Q_2, \Sigma_2, \delta_2, q_{2,0}, Q_{2, m})$, we write $G:=G_1 \lVert G_2$ to denote their synchronous product. Then, we have that $G = (Q := Q_1\times Q_2,\Sigma:=\Sigma_1\cup\Sigma_2,\delta := {\delta}_1 \lVert {\delta}_2,q_0:=(q_{1,0},q_{2,0}), Q_m:=Q_{1, m} \times Q_{2, m})$, where the (partial) transition function $\delta$ is defined as follows: for any $q = (q_1,q_2)\in Q$ and any $\sigma \in \Sigma$, \begin{center}$ \delta(q,\sigma):=\left\{ \begin{array}{rcl} ({\delta}_1(q_1,\sigma),q_2), && \text{if } {\sigma \in {\Sigma}_1}- {\Sigma}_2 \\ (q_1,{\delta}_2(q_2,\sigma)), && \text{if } {\sigma \in {\Sigma}_2}- {\Sigma}_1 \\ ({\delta}_1(q_1,\sigma),{\delta}_2(q_2,\sigma)), && \text{if } {\sigma \in {\Sigma}_1}\cap {\Sigma}_2 \\ \end{array} \right. $ \end{center} \noindent A control constraint over $\Sigma$ is a tuple $(\Sigma_c, \Sigma_o)$ of sub-alphabets of $\Sigma$, where $\Sigma_o \subseteq \Sigma$ denotes the subset of observable events (for the supervisor) and $\Sigma_c \subseteq \Sigma$ denotes the subset of controllable events (for the supervisor). Let $\Sigma_{uo}=\Sigma-\Sigma_o\subseteq \Sigma$ denote the subset of unobservable events (for the supervisor) and let $\Sigma_{uc}=\Sigma-\Sigma_c \subseteq \Sigma$ denote the subset of uncontrollable events (for the supervisor). For each sub-alphabet $\Sigma' \subseteq \Sigma$, the natural projection $P_{\Sigma'}: \Sigma^* \rightarrow \Sigma'^*$ is defined, which is extended to a map between languages as usual~\cite{WMW10}. Let $G=(Q, \Sigma, \delta, q_0)$. We shall abuse the notation and define $P_{\Sigma'}(G)$ to be the finite state automaton $(2^Q, \Sigma, \Delta, UR_{G, \Sigma-\Sigma'}(q_0))$ over $\Sigma$, where the unobservable reach $UR_{G, \Sigma-\Sigma'}(q_0):=\{q \in Q \mid \exists s \in (\Sigma-\Sigma')^*, q=\delta(q_0, s)\}$ of $q_0$ with respect to the sub-alphabet $\Sigma-\Sigma' \subseteq \Sigma$ is the initial state, and the partial transition function $\Delta: 2^Q \times \Sigma \longrightarrow 2^Q$ is defined as follows. \begin{enumerate} \item For any $\varnothing \neq Q' \subseteq Q$ and any $\sigma \in \Sigma'$, $\Delta(Q', \sigma)=UR_{G, \Sigma-\Sigma'}(\delta(Q', \sigma))$, where $UR_{G, \Sigma-\Sigma'}(Q'):=\bigcup_{q \in Q'}UR_{G, \Sigma-\Sigma'}(q)$ for any $Q' \subseteq Q$; \item for any $\varnothing \neq Q' \subseteq Q$ and any $\sigma \in \Sigma-\Sigma'$, $\Delta(Q', \sigma)=Q'$. \end{enumerate} In particular, we shall note that $P_{\Sigma'}(G)$ is over the alphabet $\Sigma$ and there is no transition defined at the state $\varnothing \in 2^Q$. A finite state automaton $G=(Q, \Sigma, \delta, q_0, Q_m)$ is said to be non-blocking if every reachable state in $G$ can reach a marked state in $Q_m$~\cite{WMW10}. \begin{comment} \begin{align} \begin{split} (\forall s,s'\in L(G))P_o(s)=P_o(s')\Rightarrow V(s)=V(s') \label{vcond1} \end{split}\\ \begin{split} \epsilon \in L(V/G) \label{vcond2} \end{split}\\ \begin{split} L(V/G) := \{ s\sigma \in L(G) | s \in L(V/G) \wedge \sigma \in V(s) \} \label{vcond3} \end{split}\\ \begin{split} L_m(V/G) := L_m(G) \cap L(V/G) \label{vcond4} \end{split} \end{align} There exists a controllable and normal FSA $S$ {\color{red} we need to assume that $\Sigma_{S, c} \subseteq \Sigma_{S, o}$} that finitely represents $V$ with $S = (Z,\Sigma,\delta,z_0,Z_m=Z)$ for which Conditions \ref{scond1} to \ref{scond3} hold: \MR{Do we provide definitions / references to controllable and normal?} \MR{Are we going to provide the construction of this FSA $S$?} \begin{align} \begin{split} L(S||G)=L(V/G) \text{ and } L_m(S||G) = L_m(V/G)\\ \text{where $'||'$ is the automaton product \cite{Wonham2014}} \label{scond1} \end{split}\\ \begin{split} (\forall s \in L(S))E_S(s) := \{\sigma \in \Sigma | s\sigma \in L(s)\} = V(s) \label{scond2} \end{split}\\ \begin{split} (\forall s,s' \in L(S))P_o(s) = P_o(s') \Rightarrow E_S(s) = E_S(s') \label{scond3} \end{split} \end{align} \MR{Apparently (6) is a definition of the notion $E_S$ and a condition at the same time. Please avoid this as it is confusing.} \end{comment} \vspace{-12pt} \section{System Setup } \label{section:SS} \vspace{-4pt} In this section, we shall introduce the system setup that involves non-eavesdropping actuator attacker. Intuitive explanations about the basic underlying ideas and assumptions are provided in Section~\ref{subs:BI}. After that, a formal setup is provided in Section~\ref{subs: FS} \vspace{-6pt} \subsection{Basic Ideas} \label{subs:BI} The plant $G$, which is a finite state automaton over $\Sigma$, is under the control of a partially observing supervisor $S$ over $(\Sigma_c, \Sigma_o)$, which is also given by a finite state automaton over $\Sigma$. In addition, we assume the existence of an actuator attacker $A$ that partially observes the execution of the closed-loop system and can modify the control command $\gamma$ (issued by the supervisor) on a specified attackable subset $\Sigma_{c, A} \subseteq \Sigma_c$ of controllable events. The plant $G$ follows the modified control command $\gamma'$ instead of $\gamma$. In this work, we assume that the supervisor issues the newly generated control command each time whenever it observes an event transition and when the system starts~\cite{LZS19}, and we assume the plant $G$ follows the (old) modified control command $\gamma'$ whenever an event $\sigma \in \Sigma_{uo}$ unobservable to the supervisor is executed in $G$. For simplification of analysis, we shall assume $\Sigma_{o, A} \subseteq \Sigma_o$. We impose this assumption as we do not want the attacker to observe $\sigma$ if $\sigma \in \Sigma_{uo}$ is executed in the plant, when the plant will reuse the old modified control command $\gamma'$\footnote{This assumption may be removed, by imposing the constraint that the attacker does not change its attack decision whenever $\sigma \in \Sigma_{uo}$ is executed in the plant, even when the execution of $\sigma$ may be observed by the attacker, if $\sigma \in \Sigma_{uo} \cap \Sigma_{o, A}$, and thus may lead to state change in the attacker. The analysis of this general case is left to the future work.}. We assume the supervisor $S$ is augmented with a monitoring mechanism that monitors the execution of the closed-loop system (possibly under attack). If $\sigma \in \Sigma_{c, A}$ is enabled by the supervisor in $\gamma$, then the attacker is not discovered\footnote{The supervisor is not sure whether $\sigma$ has been disabled by an attacker, even if disabling $\sigma$ may result in deadlock, as the supervisor is never sure whether: 1) deadlock has occurred due to actuator attack, or 2) $\sigma$ will possibly fire soon (according to the internal mechanism of the plant).} by the supervisor when it disables $\sigma$ in $\gamma'$. The supervisor is able to conclude the existence of an attacker the first moment when it observes an inconsistency between what it has observed and what shall be observed in the absence of attacker. We assume that the attacker has a complete knowledge about the models of the plant $G$ and the supervisor $S$, as well as the control constraint $(\Sigma_{c}, \Sigma_{o})$ and what constitutes damages. Intuitively, the goal of the attacker is to remain covert in the process of attacking the closed-loop system until it causes damages (by generating certain damaging strings). More precisely, the covertness property requires the attacker not to reach a situation where its existence is detected by the supervisor while no damage has been or can be caused. We assume that the supervisor has a mechanism for halting the execution of the closed-loop system after discovering an actuator attack. \vspace{-10pt} \subsection{Formal Setup} \label{subs: FS} In this section, we explain the formal setup. We first need to introduce and present a formalization of the system components {\bf Supervisor}: In the absence of attacker, a supervisor over control constraint $(\Sigma_c, \Sigma_o)$ is modeled by a finite state automaton $S=(X, \Sigma, \zeta, x_0)$ that satisfies the controllability and observability constraints~\cite{B1993}: \begin{enumerate} \item [$\bullet$] ({\em controllability}) for any state $x \in X$ and any uncontrollable event $\sigma \in \Sigma_{uc}$, $\zeta(x, \sigma)!$, \item [$\bullet$] ({\em observability}) for any state $x \in X$ and any unobservable event $\sigma \in \Sigma_{uo}$, $\zeta(x, \sigma)!$ implies $\zeta(x, \sigma)=x$, \end{enumerate} {\bf Plant}: The plant is modeled by a finite state automaton $G=(Q, \Sigma, \delta, q_0)$ as usual. Whenever the plant fires an observable transition $\delta(q, \sigma)=q'$, it sends the observable event $\sigma$ to the supervisor. {\bf Actuator Attacker}: We assume the attacker knows the model of the plant $G$ and the model of the supervisor $S$. We here impose some restrictions on the capability of the attacker. Let $\Sigma_{o, A} \subseteq \Sigma$ denote the subset of (plant) events that can be observed by the attacker. Let $\Sigma_{c, A} \subseteq \Sigma_c$ denote the set of attackable events. The attacker is able to modify the control command $\gamma$ issued by the supervisor on the subset $\Sigma_{c, A}$. We henceforth name $(\Sigma_{o, A}, \Sigma_{c, A})$ as an attack constraint. An actuator attacker over attack constraint $(\Sigma_{o, A}, \Sigma_{c, A})$ is modeled by a finite state automaton $A=(Y, \Sigma, \beta, y_0)$ that satisfies the following constraints. \begin{enumerate} \item [$\bullet$] ({\em A-controllability}) for any state $y \in Y$ and any unattackable event $\sigma \in \Sigma-\Sigma_{c, A}$, $\beta(y, \sigma)!$, \item [$\bullet$] ({\em A-observability}) for any state $y \in Y$ and any unobservable event $\sigma \in \Sigma-\Sigma_{o, A}$ to the attacker, $\beta(y, \sigma)!$ implies $\beta(y, \sigma)=y$, \end{enumerate} Compared with~\cite{Su2018},~\cite{Lin2018} and~\cite{LZS19}, in this work we have adopted a unifying model for the modeling of the plant, the supervisor and the attacker. In particular, it is straightforward to see that an attacker $A$ over attack constraint $(\Sigma_{o, A}, \Sigma_{c, A})$ can also be viewed as a supervisor over control constraint $(\Sigma_{c, A}, \Sigma_{o, A})$. We here shall remark that we do not impose any assumption on the control constraint $(\Sigma_c, \Sigma_o)$ and we do not restrict the attack constraint $(\Sigma_{o, A}, \Sigma_{c, A})$ either, except for the natural requirement\footnote{The requirement $\Sigma_{c, A} \subseteq \Sigma_c$ is not essential, as it is only used in Remark 2, i.e., used in the discussion of when the reduction can be carried out in polynomial time.} $\Sigma_{c, A} \subseteq \Sigma_c$ and the technical requirement\footnote{The relaxation of this requirement makes our synthesis approach incomplete in general.} that $\Sigma_{o, A} \subseteq \Sigma_o$. In particular, we do not require $\Sigma_{o, A} = \Sigma_o$, which is required by~\cite{Carvalho2018},~\cite{LACM17} and~\cite{Lima2018}, and we also do not require normality $\Sigma_c \subseteq \Sigma_o, \Sigma_{c, A} \subseteq \Sigma_{o, A}$, which is assumed in~\cite{Lin2018}. We allow both enablement and disablement attacks; in particular, disablement attacks can be essential for the success of covert attackers, which is quite different from~\cite{Carvalho2018},~\cite{LACM17} and~\cite{Lima2018}. {\bf Damage Automaton}: To specify in a general manner what strings can cause damages, we here shall adopt a complete finite state automaton $H=(W, \Sigma, \chi, w_0, W_m)$~\cite{Lin2018}, which is referred to as a damage automaton. In particular, each string $s \in L_m(H)$ is a damage-inflicting string that the attacker would like the attacked closed-loop system to generate. In the special case of enforcing or testing state avoidance property for the closed-loop system under attack, we can get rid of $H$ and introduce the set $Q_{bad} \subseteq Q$ of bad states to avoid in the plant $G$. In general, $H$ does not have to be the same as the specification that is used to synthesize the (possibly insecure) supervisor $S$. {\bf Monitoring Mechanism}: In the presence of an attacker, we assume the supervisor is augmented with a monitoring mechanism. We assume, without loss of generality, that the execution of the attacked closed-loop system is immediately halted\footnote{ In~\cite{LACM17}, when the supervisor detects the presence of an attacker, all controllable events will be disabled, while uncontrollable events can still occur (i.e., immediate halt by reset is impossible). This is not difficult to accommodate, by working on the damage automaton $H$ that defines the set of damage-inflicting strings $L_m(H)$. In particular, if uncontrollable events can still occur after the detection, then we only need to use the new damage automaton $H'$ with $L_m(H')=L_m(H) \cup L_m(H)/\Sigma_{uc}^*$, where $L_m(H)/\Sigma_{uc}^*:=\{s \in \Sigma^* \mid \exists s' \in \Sigma_{uc}^*, ss' \in L_m(H)\}$, as the renewed set of damage-inflicting strings. An alternative approach is to add self-loops of each uncontrollable event at the state $x_{halt}$ of $S^A$ and at the state $\varnothing$ of $P_{\Sigma_o}(S\lVert G)$ to allow execution of uncontrollable events after the detection; the definition of these two components will be explained soon.} once the supervisor discovers the presence of an attacker. The supervisor online records its observation $w \in \Sigma_o^*$ of the execution of the (attacked) closed-loop system. It concludes the existence of an attacker and then halts the execution of the (attacked) closed-loop system the first time when it observes some string $w \notin P_{\Sigma_o}(L(S \lVert G))$\footnote{The same monitoring mechanism indeed works for both covert attackers and risky attackers~\cite{LZS19}.}. {\bf Attacked Closed-loop System}: The attacked closed-loop system consists of the three main components $G$, $S$ and $A$. However, the synchronous product of $G$, $S$ and $A$ is not the attacked closed-loop system for the following two reasons: 1) The effect of attack on the supervisor is not reflected in $S$; 2) The monitoring mechanism has not been encoded in $S$. The first problem can be solved by computing the (totally) enablement-attacked supervisor $S^A$. Let $S=(X, \Sigma, \zeta, x_0)$. We shall let $S^A=(X \cup \{x_{halt}\}, \Sigma, \zeta^A, x_0)$ denote the enablement-attacked supervisor, where $x_{halt} \notin X$ denotes a distinguished halting state and $\zeta^A: (X \cup \{x_{halt}\}) \times \Sigma \longrightarrow (X \cup \{x_{halt}\})$ is obtained from $\zeta$ by adding the following transitions (in addition to a copy of the transitions of $\zeta$) \begin{enumerate} \item [a)] for any $x \in X$ and any $\sigma \in \Sigma_{uo} \cap \Sigma_{c, A}$, if $\neg \zeta(x, \sigma)!$, then $\zeta^A(x, \sigma)=x$ \item [b)] for any $x \in X$ and any $\sigma \in \Sigma_{o} \cap \Sigma_{c, A}$, if $\neg \zeta(x, \sigma)!$, then $\zeta^A(x, \sigma)=x_{halt}$ \end{enumerate} Intuitively, to obtain $S^A$, for each state $x \in X$ and each event $\sigma \in \Sigma_{uo} \cap \Sigma_{c, A}$, if $\sigma$ is not defined at state $x$, we then add a self-loop at state $x$ labeled by $\sigma$; for each state $x \in X$ and each event $\sigma \in \Sigma_o \cap \Sigma_{c, A}$, if $\sigma$ is not defined at state $x$, we then add a transition from $x$ to the halting state $x_{halt}$ labeled by $\sigma$. In particular, we note that there is no transition defined at state $x_{halt}$ and every state in $S^A$ is a marked state. With $S^A$, we have effectively implemented an ignorant attacker that performs enablement attacks wherever it is possible, that is, an attacker that enables each attackable event at each state. Then, the rest of the attack decisions for the actuator attacker is to disable attackable events properly, based on its own partial observation and its knowledge on the system's models, to ensure covertness and damage-infliction. This brings the covert actuator attacker synthesis problem closer to the supervisor synthesis problem The second problem has been partially solved in the solution to the first problem. In particular, if $S^A$ enters $x_{halt}$, then an attack has necessarily happened. This is insufficient, however. Recall that the supervisor concludes the existence of an attacker and then halts the execution of the (attacked) closed-loop system the first time when it observes some string $w \notin P_{\Sigma_o}(L(S \lVert G))$. We shall denote $S \lVert G=(X \times Q, \Sigma, \lambda, (x_0, q_0))$, where $\lambda=\zeta \lVert \delta$. Then, we have $P_{\Sigma_o}(S \lVert G)=(2^{X \times Q}, \Sigma, \Lambda, UR_{S\lVert G, \Sigma-\Sigma_{o}}(x_0, q_0))$, where $UR_{S\lVert G, \Sigma-\Sigma_{o}}(x_0, q_0)$ denotes the unobservable reach of $(x_0, q_0)$ with respect to the sub-alphabet $\Sigma-\Sigma_o$ in $S\lVert G$ and the partial transition function $\Lambda: 2^{X \times Q} \times \Sigma \longrightarrow 2^{X \times Q}$ is defined such that, \begin{enumerate} \item for any $\varnothing \neq D \subseteq X \times Q$ and any $\sigma \in \Sigma_o$, $\Lambda(D, \sigma)=UR_{S \lVert G, \Sigma-\Sigma_o}(\lambda(D, \sigma))$; \item for any $\varnothing \neq D \subseteq X \times Q$ and any $\sigma \in \Sigma-\Sigma_o$, $\Lambda(D, \sigma)=D$. \end{enumerate} Intuitively, we can use $P_{\Sigma_o}(S\lVert G)$ to track the belief $\varnothing \neq D \subseteq X \times Q$ of the supervisor on the current states of the unattacked closed-loop system $S \lVert G$, for monitoring purpose. When the current belief of the supervisor is $\varnothing \neq D \subseteq X \times Q$ and $\sigma \in \Sigma_o$ is executed with $\lambda(D, \sigma)=\varnothing$, the supervisor detects an inconsistency and determines that attack necessarily has happened and thus halts the execution of the attacked closed-loop system. In particular, we note that there is no transition defined at state $\varnothing \in 2^{X \times Q}$ and every state in $P_{\Sigma_o}(S \lVert G)$ is a marked state. Given the plant $G$, the supervisor $S$ and the attacker $A$, the attacked closed-loop system is the synchronous product $G \lVert S^A \lVert P_{\Sigma_o}(S \lVert G) \lVert A$, which is a finite state automaton over $\Sigma$. Since the set of states the supervisor believes itself to be residing in is a singleton (due to the observability constraint for a supervisor) and corresponds to the state that it actually resides in, whenever $P_{\Sigma_o}(S\lVert G)$ is not in the state $\varnothing$, the state space of $G \lVert S^A \lVert P_{\Sigma_o}(S \lVert G) \lVert A$, when restricted to the reachable state set, is isomorphic to $Q \times (X \cup \{x_{halt}\}) \times 2^Q \times Y$. In the rest, we consider $Q \times (X \cup \{x_{halt}\}) \times 2^Q \times Y$ as the state space whenever convenient. {\bf Successful Actuator Attackers}: In this work, we shall focus on covert attackers. Given the damage automaton $H=(W, \Sigma, \chi, w_0, W_m)$, the definition of covertness is given in the following. \begin{definition}[Covertness] Given any plant $G$, any supervisor $S$, any actuator attacker $A$ and any damage automaton $H$, $A$ is said to be covert on $(G, S)$ with respect to $H$ if each state in $\{(q, x, D_Q, y, w) \in Q \times (X \cup \{x_{halt}\}) \times 2^Q \times Y \times W \mid (x=x_{halt} \vee D_Q=\varnothing) \wedge w \notin W_m\}$ is not reachable\footnote{Alternatively, we can use the equivalent set $\{(q, x, D, y, w) \in Q \times (X \cup \{x_{halt}\}) \times 2^{X \times Q} \times Y \times W \mid D=\varnothing \wedge w \notin W_m\}$ for specifying the violation of covertness.} in $G \lVert S^A \lVert P_{\Sigma_o}(S \lVert G) \lVert A \lVert H$. \end{definition} We note that the set of marked states for $G \lVert S^A \lVert P_{\Sigma_o}(S \lVert G) \lVert A \lVert H$ is $\{(q, x, D_Q, y, w) \in Q \times (X \cup \{x_{halt}\}) \times 2^Q \times Y \times W \mid w \in W_m\}$. In this work, we shall consider two ``possibilistic" interpretation of damaging goals for covert actuator attackers. For us, the first interpretation of interest is the damage-nonblocking goal, which intuitively states that it is always possible to reach damages in the attacked closed-loop system, wherever the current state is for the attacked closed-loop system. That is, for any string $s \in L(G \lVert S^A \lVert P_{\Sigma_o}(S \lVert G) \lVert A)$ generated by the attacked closed-loop system, it is always possible to extend it in $G \lVert S^A \lVert P_{\Sigma_o}(S \lVert G) \lVert A$ to some string in $L_m(H)$. This is formally captured by the next definition. \begin{definition}[Damage-nonblocking] Given any plant $G$, any supervisor $S$, any damage automaton $H$ and any covert actuator attacker $A$ on $(G, S)$ with respect to $H$, $A$ is said to be damage-nonblocking on $(G, S)$ with respect to $H$ if $G \lVert S^A \lVert P_{\Sigma_o}(S \lVert G) \lVert A \lVert H$ is non-blocking. \end{definition} The damage-nonblocking goal ensures the ``necessity" of damage-infliction in the long run, much in parallel to a nonblocking supervisor. The second interpretation of interest for us is the damage-reachable goal~\cite{Lin2018},~\cite{Zhu2018},~\cite{LZS19}, which intuitively states that it is possible to reach damages in the attacked closed-loop system from the initial state. It is worth mentioning that, due to the existence of events beyond the control of attackers (that is, any event $\sigma \notin \Sigma_{c, A}$), this is arguably the weakest interpretation for damage-infliction goal. \begin{definition}[Damage-reachable] Given any plant $G$, any supervisor $S$, any damage automaton $H$ and any covert actuator attacker $A$ on $(G, S)$ with respect to $H$, $A$ is said to be damage-reachable on $(G, S)$ with respect to $H$ if some marked state in $G \lVert S^A \lVert P_{\Sigma_o}(S \lVert G) \lVert A \lVert H$ is reachable, that is, $L_m(G \lVert S^A \lVert P_{\Sigma_o}(S \lVert G) \lVert A \lVert H) \neq \varnothing$. \end{definition} It is clear that the damage-nonblocking goal is stronger than the damage-reachable goal, which is given by the proposition below. \begin{proposition} Given any plant $G$ over $\Sigma$, any supervisor $S$ over control constraint $(\Sigma_c, \Sigma_o)$, any attack constraint $(\Sigma_{o, A}, \Sigma_{c, A})$ and any damage automaton $H$ over $\Sigma$, if a covert actuator attacker $A$ over $(\Sigma_{o, A}, \Sigma_{c, A})$ is damage-nonblocking on $(G, S)$ with respect to $H$, then $A$ is damage-reachable on $(G, S)$ with respect to $H$. \end{proposition} \vspace{-4pt} \begin{proof} This follows straightforwardly from the definitions of the damage-nonblocking goal and the damage-reachable goal. Indeed, $G \lVert S^A \lVert P_{\Sigma_o}(S \lVert G) \lVert A \lVert H$ is non-blocking implies that some marked state in $G \lVert S^A \lVert P_{\Sigma_o}(S \lVert G) \lVert A \lVert H$ is reachable. \end{proof} However, in general, a damage-reachable attacker may not be damage-nonblocking. \vspace{-12pt} \section{Synthesis of Non-eavesdropping Actuator Attackers} \label{section: AS} \vspace{-4pt} In this section, we provide straightforward reductions from the actuator attacker synthesis problems, with the two different damaging goals, to the Ramadge-Wonham supervisor synthesis problems. It then follows that we can use the techniques and tools developed for solving the supervisor synthesis problems to solve the actuator attacker synthesis problems. We shall provide the reductions for the two different interpretations of damaging goals, separately. The details of the reductions are summarized in the next two theorems. \begin{theorem} Given any plant $G$ over $\Sigma$, any supervisor $S$ over control constraint $(\Sigma_c, \Sigma_o)$, any attack constraint $(\Sigma_{o, A}, \Sigma_{c, A})$ and any damage automaton $H$ over $\Sigma$, there is a damage-nonblocking covert actuator attacker $A$ over $(\Sigma_{o, A}, \Sigma_{c, A})$ on $(G, S)$ with respect to $H$ iff there is a supervisor $S'$ over $(\Sigma_{c, A}, \Sigma_{o, A})$ such that $S' \lVert P$ avoids reaching the set ${\bf BAD}$ of bad states in $P$ and $S' \lVert P$ is non-blocking, where $P=G \lVert S^A \lVert P_{\Sigma_o}(S\lVert G) \lVert H$ and ${\bf BAD}:=\{(q, x, D_Q, w) \in Q \times (X \cup \{x_{halt}\}) \times 2^Q \times W \mid (x=x_{halt} \vee D_Q=\varnothing) \wedge w \notin W_m\}$. \end{theorem} \begin{proof} This straightforwardly follows from the definition of a damage-nonblocking covert actuator attacker. In particular, $A$ is a damage-nonblocking covert actuator attacker over $(\Sigma_{o, A}, \Sigma_{c, A})$ on $(G, S)$ with respect to $H$ iff $A \lVert P$ avoids reaching the set ${\bf BAD}$ of bad states in $P$ and $A \lVert P$ is non-blocking, where $P=G \lVert S^A \lVert P_{\Sigma_o}(S \lVert G) \lVert H$ and ${\bf BAD}:=\{(q, x, D_Q, w) \in Q \times (X \cup \{x_{halt}\}) \times 2^Q \times W \mid (x=x_{halt} \vee D_Q=\varnothing) \wedge w \notin W_m\}$, by Definition 1 and Definition 2; in particular, $A$ can be viewed as a supervisor over $(\Sigma_{c, A}, \Sigma_{o, A})$ and $P$ can be viewed as the transformed plant. \end{proof} \begin{theorem} Given any plant $G$ over $\Sigma$, any supervisor $S$ over control constraint $(\Sigma_c, \Sigma_o)$, any attack constraint $(\Sigma_{o, A}, \Sigma_{c, A})$ and any damage automaton $H$ over $\Sigma$, there is a damage-reachable covert actuator attacker $A$ over $(\Sigma_{o, A}, \Sigma_{c, A})$ on $(G, S)$ with respect to $H$ iff there is a supervisor $S'$ over $(\Sigma_{c, A}, \Sigma_{o, A})$ such that $S' \lVert P$ avoids reaching the set ${\bf BAD}$ of bad states in $P$ and $L_m(S' \lVert P) \neq \varnothing$, where $P=G \lVert S^A \lVert P_{\Sigma_o}(S \lVert G) \lVert H$ and ${\bf BAD}:=\{(q, x, D_Q, w) \in Q \times (X \cup \{x_{halt}\}) \times 2^Q \times W \mid (x=x_{halt} \vee D_Q=\varnothing) \wedge w \notin W_m\}$. \end{theorem} \begin{proof} This straightforwardly follows from the definition of a damage-reachable covert actuator attacker. In particular, $A$ is a damage-reachable covert actuator attacker over the attack constraint $(\Sigma_{o, A}, \Sigma_{c, A})$ on $(G, S)$ with respect to $H$ iff $A \lVert P$ avoids reaching the set ${\bf BAD}$ of bad states in $P$ and $L_m(A \lVert P) \neq \varnothing$, where $P=G \lVert S^A \lVert P_{\Sigma_o}(S \lVert G) \lVert H$ and ${\bf BAD}:=\{(q, x, D_Q, w) \in Q \times (X \cup \{x_{halt}\}) \times 2^Q \times W \mid (x=x_{halt} \vee D_Q=\varnothing) \wedge w \notin W_m\}$, by Definition 1 and Definition 3; in particular, $A$ can be viewed as a supervisor over the control constraint $(\Sigma_{c, A}, \Sigma_{o, A})$ and $P$ can be viewed as the transformed plant. \end{proof} \vspace{-4pt} \begin{remark} By viewing $A$ as the supervisor and $G\lVert S^A \lVert P_{\Sigma_o}(S \lVert G) \lVert H$ as the transformed plant, Definition 2 and Definition 3 allow us to reduce the actuator attacker synthesis problems to the supervisor synthesis problems. We remark that the set {\bf BAD} of bad states in Theorem 1 and Theorem 2 is defined according to the definition of covertness in Definition 1, where breaking covertness, i.e., reaching states in {\bf BAD}, is bad for the attacker. \end{remark} The reductions provided above, combined with the maximally permissive supervisor synthesis algorithm\footnote{Theorem 1 requires the synthesis of a safe and nonblocking supervisor, while Theorem 2 only requires the synthesis of a safe and nonempty supervisor. The maximally permissive supervisor synthesis algorithm in~\cite{YL16} is of exponential time complexity and can be adapted for both scenarios.} in~\cite{YL16}, provides a doubly exponential time algorithm for the covert actuator attacker synthesis problem, for both the damage-nonblocking goal and the damage-reachable goal. This doubly exponential time complexity seems unavoidable in general, due to two independent sources of exponentiation constructions arising from partial observation. The inner level of the exponentiation is due to partial observation by the supervisor, in the construction of $P_{\Sigma_o}(S \lVert G)$ to determine when the attacked closed-loop system is halted. The outer level of the exponentiation is due to partial observation by the attacker, whose synthesis can be viewed as the synthesis of a partial observation supervisor on the transformed plant. In general, the reductions provided in the above two theorems cannot be carried out in polynomial time. Here, the main trouble is due to the need for tracking the state in $P_{\Sigma_o}(S \lVert G)$, whose state size is in general exponential in the state size of $G$ (modulo the state space of $S$). We now shall show that, under certain assumption on the set of attackable events, the above reductions are polynomial time computable, regardless of the models for $S$ and $G$. \begin{theorem} If $\Sigma_{uo} \cap \Sigma_{c, A} =\varnothing$, then the actuator attacker synthesis problem is polynomial time reducible to the (partial-observation) supervisor synthesis problem, for both the damage-nonblocking goal and the damage-reachable goal. \end{theorem} \begin{proof} Consider the transformed plant $G \lVert S^A \lVert P_{\Sigma_o}(S \lVert G) \lVert H$ in Theorem 1 and Theorem 2. We restore the component $2^{X \times Q}$ for analysis; then a state of $G \lVert S^A \lVert P_{\Sigma_o}(S \lVert G) \lVert H$ is of the form $(q, x, D, w) \in Q \times (X \cup \{x_{halt}\}) \times 2^{X \times Q} \times W$. Let $dom(D):=\{x \in X \mid \exists q \in Q, (x, q) \in D\}$. We know that $dom(D)$ is the singleton $\{x\}$, when restricted to the reachable state set of $G \lVert S^A \lVert P_{\Sigma_o}(S \lVert G) \lVert H$ and when $D \neq \varnothing$. Let $Img(D):=\{q \in D \mid \exists x \in X, (x, q) \in D\}$. When the belief of the supervisor is $\varnothing \neq D \subseteq X \times Q$ and event $\sigma \in \Sigma_o$ is executed with $\lambda(D, \sigma)=\varnothing$, the supervisor detects an inconsistency and determines that attack has necessarily happened. There are two possible reasons for $\lambda(D, \sigma)=\varnothing$. The first reason is when $\zeta(x, \sigma)$ is undefined for the unique state $x \in dom(D)$. This has already been taken care of by the component $S^A$. The second reason is when $\delta(Img(D), \sigma)=\varnothing$, which can be tracked with the component $P_{\Sigma_o}(S \lVert G)$. However, since $\sigma$ has been executed at the current plant state $q \in Q$, we conclude that $q \notin Img(D)$. That is, the current state the plant is in does not belong to the set of states the supervisor believes the plant to be residing in. This is only possible if some event $\sigma' \in \Sigma_{uo} \cap \Sigma_{c, A}$ has been enabled by the actuator attacker but disabled by the supervisor in the past execution. If $\Sigma_{uo} \cap \Sigma_{c, A}=\varnothing$, then the above possibility can be ruled out. Thus, we can effectively get rid of the component $2^Q$ (associated with the use of $P_{\Sigma_o}(S \lVert G)$) in the construction of the transformed plant, when $\Sigma_{uo} \cap \Sigma_{c, A}=\varnothing$, since the halting state $x_{halt}$ in the component $S^A$ is sufficient for detecting the presence of an actuator attacker in this case. It then follows that the reductions provided in Theorems 1 and 2 are polynomial time reductions when $\Sigma_{uo} \cap \Sigma_{c, A}=\varnothing$. \end{proof} Intuitively, if the actuator attacker cannot attack those unobservable events to the supervisor, then the reductions provided in Theorem 1 and Theorem 2, after removing the component $2^Q$, are polynomial time reductions. In the following remark, we shall explain one implication of Theorem 3. \begin{remark} \label{remark: poly} If $\Sigma_{uo} \cap \Sigma_c=\varnothing$, that is, when the given supervisor $S$ satisfies the normality property~\cite{WMW10}, then we also have $\Sigma_{uo} \cap \Sigma_{c, A}=\varnothing$, since $\Sigma_{c, A} \subseteq \Sigma_c$. We consider this to be not quite restrictive. A supervisor satisfying the normality property leaves much reduced attack surfaces for the actuator attacker~\cite{Lin2018}, since events that are disabled (by the supervisor) are observable to the supervisor and enabling those disabled (attackable) events (by the actuator attacker) may immediately break the covertness of the actuator attacker, if they are also enabled by the plant. Thus, being suspicious of the presence of an attacker, the designer may prefer to synthesize supervisors that satisfy the normality property. \end{remark} Based on Theorem 3 and the discussion after Remark 1, we immediately have the following result. \begin{corollary} If $\Sigma_{uo} \cap \Sigma_{c, A} =\varnothing$, then the actuator attacker synthesis problem is solvable in exponential time, for both the damage-nonblocking goal and the damage-reachable goal. \end{corollary} In general, there are two possible situations where the exponential blowup of state sizes can be avoided in the construction of the transformed plant $G \lVert S^A \lVert P_{\Sigma_o}(S \lVert G) \lVert H$. The first situation is when $P_{\Sigma_o}(S \lVert G)$ is of polynomial size. An example is when $P_{\Sigma_o}$ is an $L(S\lVert G)$-observer~\cite{LW10}; in this case, the size of $P_{\Sigma_o}(S \lVert G)$ is upper bounded by the state size of $S \lVert G$. The second situation is when for any reachable state $(q, x, D, w) \in Q \times (X \cup \{x_{halt}\}) \times 2^{X \times Q} \times W$ and any $\sigma \in \Sigma_o$ such that $\sigma$ is defined at $(q, x, D, w)$, we have $\delta(Img(D), \sigma) \neq \varnothing$; in this case, the component $P_{\Sigma_o}(S \lVert G)$ can be safely removed in the construction of the transformed plant, as analyzed in the proof of Theorem 3. An example is when $\Sigma_{uo} \cap \Sigma_{c, A}=\varnothing$, as shown in Theorem 3. For the second situation, in general we need to first construct $G \lVert S^A \lVert P_{\Sigma_o}(S \lVert G) \lVert H$ and then perform the corresponding (straightforward) verification. If the condition is indeed satisfied, then we can safely remove the component $P_{\Sigma_o}(S \lVert G)$ and perform supervisor synthesis based on $G \lVert S^A \lVert H$. In both situations, the actuator attacker synthesis problem is solvable in exponential time, for both the damage-nonblocking goal and the damage-reachable goal. We here remark that the above two situations are not exclusive. In general, it is possible that $P_{\Sigma_o}(S \lVert G)$ is of polynomial size and still can be removed in the construction of the transformed plant (according to the second situation). \section{ Synthesis of Eavesdropping Actuator Attackers} \label{section: eavesdrop} \vspace{-4pt} In this section, we consider the synthesis of successful covert actuator attackers that not only partially observes the execution of the closed-loop system but also can eavesdrop the control commands issued by the supervisor, following the setup of~\cite{Lin2018}. As we have explained before, control command eavesdropping attackers can be considered as powerful attackers in the sense of~\cite{HMR18}; in particular, eavesdropping attackers can decode the information encoded in the issued control commands to possibly gain part of the knowledge of the supervisors on the execution of the plant. Since the attackers can eavesdrop the control commands, it is important to discuss when the control commands are sent to the plant. The control command generated at each supervisor state $x \in X$ is $\Gamma(x):=\{\sigma \in \Sigma \mid \zeta(x, \sigma)!\}$. We assume that whenever the supervisor fires an observable transition $\zeta(x, \sigma)=x'$, it sends the newly generated control command $\Gamma(x')$ to the plant\footnote{In another setup~\cite{LZS19}, the supervisor sends a control command each time when it fires an observable transition $\zeta(x, \sigma)=x'$ satisfying $\Gamma(x) \neq \Gamma(x')$. To solve the (covert) actuator attacker synthesis problem for this setup requires the concept of dynamic observation~\cite{AVW03} that is beyond the scope of this work.}. When the system first initiates, the supervisor sends the initial control command $\Gamma(x_0)$ to the plant. This setup is a generalization of that of~\cite{Lin2018} and we do not impose any assumption on the control constraint $(\Sigma_c, \Sigma_o)$ or the attack constraint $(\Sigma_{o, A}, \Sigma_{c, A})$, except for the natural requirement that $\Sigma_{c, A} \subseteq \Sigma_c$ and the technical requirement that $\Sigma_{o, A} \subseteq \Sigma_o$. In particular, we do not require normality $\Sigma_c \subseteq \Sigma_o, \Sigma_{c, A} \subseteq \Sigma_{o, A}$ in~\cite{Lin2018}. We here shall employ a technique that we refer to as supervisor bipartization to solve the (covert) actuator attacker synthesis problem for this setup. Intuitively, we need to perform a (bipartization) transformation of the supervisor so that the issued control commands become a part of the alphabet that can be observed by the attacker, while the control function of the bipartite supervisor (on the plant) remains the same as the (ordinary) supervisor. Given any supervisor $S=(X, \Sigma, \zeta, x_0)$, its bipartization is given by the finite state automaton $BT(S)=(X \cup X_{com}, \Sigma \cup \Gamma, \zeta^{BT}, x_{0,com})$, where $X_{com}=\{x_{com} \mid x \in X\}$ is a (relabelled) copy of $X$ with $X \cap X_{com}=\varnothing$, $x_{0, com} \in X_{com}$ is a copy of $x_0 \in X$ and is the initial state of $BT(S)$, and the partial transition function $\zeta^{BT}: (X \cup X_{com}) \times (\Sigma \cup \Gamma) \longrightarrow (X \cup X_{com})$ is defined as follows: \begin{enumerate} \item for any $x_{com} \in X_{com}$, $\zeta^{BT}(x_{com},\Gamma(x))=x$ \item for any $x \in X$ and any $\sigma \in \Sigma_{uo}$, $\zeta^{BT}(x, \sigma)=\zeta(x,\sigma)$ \item for any $x \in X$ and any $\sigma \in \Sigma_{o}$, $\zeta^{BT}(x, \sigma)=\zeta(x,\sigma)_{com}$ \end{enumerate} Intuitively, each $x_{com}$ is the control state corresponding to $x$ that is ready to issue the control command $\Gamma(x)$; the transition $\zeta^{BT}(x_{com},\Gamma(x))=x$ represents the event of the supervisor sending the control command $\Gamma(x)$ to the plant. Each $x \in X$ is a reaction state that is ready to react to an event in the issued control command $\Gamma(x)$ executed by the plant $G$. For any $x \in X$ and $\sigma \in \Sigma$, the supervisor reacts to the corresponding transition fired in the plant. If $\sigma \in \Sigma_{uo}$ is defined at $x \in X$, then the supervisor observes nothing and remains in the same reaction state $\zeta(x,\sigma)=x \in X$; if $\sigma \in \Sigma_o$ is defined at $x \in X$, then the supervisor proceeds to the next control state $\zeta(x,\sigma)_{com}$. We remark that $\zeta^{BT}(x, \sigma)$ is defined iff $\zeta(x, \sigma)$ is defined, for any $x\in X$ and any $\sigma \in \Sigma$. If we abstract $BT(S)$ by merging the states $x_{com}$ and $x$, treated as equivalent states in the abstraction, then we can recover $S$. In this sense, $BT(S)$ is control equivalent to $S$. We shall refer to $BT(S)$ as a bipartite supervisor over $\Sigma \cup \Gamma$. A control command eavesdropping actuator attacker over attack constraint $(\Sigma_{o, A}, \Sigma_{c, A})$ is modeled by an (ordinary) actuator attacker $A=(Y, \Sigma \cup \Gamma, \beta, y_0)$ over attack constraint $(\Sigma_{o, A} \cup \Gamma, \Sigma_{c, A})$. Thus, it satisfies the following constraints. \begin{enumerate} \item [$\bullet$] ({\em A-controllability}) for any state $y \in Y$ and any unattackable event $\sigma \in \Sigma \cup \Gamma-\Sigma_{c, A}$, $\beta(y, \sigma)!$, \item [$\bullet$] ({\em A-observability}) for any state $y \in Y$ and any unobservable event $\sigma \in (\Sigma\cup \Gamma)-(\Sigma_{o, A} \cup \Gamma)=\Sigma-\Sigma_{o, A}$ to the attacker, $\beta(y, \sigma)!$ implies $\beta(y, \sigma)=y$, \end{enumerate} The monitoring mechanism is exactly the same as that in the non-eavesdropping case. For the bipartite supervisor $BT(S)$, we still need to compute the (totally) enablement-attacked bipartite supervisor $BT(S)^A=(X \cup X_{com} \cup \{x_{halt}\}, \Sigma \cup \Gamma, \zeta^{BT, A}, x_{0,com})$, where $x_{halt} \notin X \cup X_{com}$ is the distinguished halting state and the partial transition function $\zeta^{BT, A}: (X \cup X_{com} \cup \{x_{halt}\}) \times (\Sigma \cup \Gamma) \longrightarrow (X \cup X_{com} \cup \{x_{halt}\})$ is obtained from $\zeta^{BT}$ by adding the following transitions (in addition to a copy of the transitions of $\zeta^{BT}$). \begin{enumerate} \item [a)] for any $x \in X$ and any $\sigma \in \Sigma_{uo} \cap \Sigma_{c, A}$, if $\neg \zeta^{BT}(x, \sigma)!$, then $\zeta^{BT,A}(x, \sigma)=x$ \item [b)] for any $x \in X$ and any $\sigma \in \Sigma_{o} \cap \Sigma_{c, A}$, if $\neg \zeta^{BT}(x, \sigma)!$, then $\zeta^{BT,A}(x, \sigma)=x_{halt}$ \end{enumerate} We here shall remark that, for bipartite supervisors, no modification shall be made to the control states $x \in X_{com}$. The attacked closed-loop system is $G\lVert BT(S)^A \lVert P_{\Sigma_o}(S \lVert G) \lVert A$. Finally, given the damage automaton $H=(W, \Sigma, \chi, w_0, W_m)$, we need to compute the synchronous product $G\lVert BT(S)^A \lVert P_{\Sigma_o}(S \lVert G) \lVert A \lVert H$ to determine whether the attacker $A$ is successful, with respect to the damage-nonblocking goal or the damage-reachable goal. Intuitively, the attacker $A$ can be viewed as a supervisor over control constraint $(\Sigma_{c, A}, \Sigma_{o, A} \cup \Gamma)$ and $G\lVert BT(S)^A \lVert P_{\Sigma_o}(S \lVert G) \lVert H$ can be viewed as the transformed plant over $\Sigma \cup \Gamma$. By a similar reasoning as before, we have the following theorems. \begin{theorem} Given any plant $G$ over $\Sigma$, any supervisor $S$ over control constraint $(\Sigma_c, \Sigma_o)$, any attack constraint $(\Sigma_{o, A}, \Sigma_{c, A})$ and any damage automaton $H$ over $\Sigma$, there is a damage-nonblocking covert control command eavesdropping actuator attacker $A$ over $(\Sigma_{o, A}, \Sigma_{c, A})$ on $(G, S)$ with respect to $H$ iff there is a supervisor $S'$ over $(\Sigma_{c, A}, \Sigma_{o, A} \cup \Gamma)$ such that $S' \lVert P$ avoids reaching the set ${\bf BAD}$ of bad states in $P$ and $S' \lVert P$ is non-blocking, where $P=G \lVert BT(S)^A \lVert P_{\Sigma_o}(S\lVert G) \lVert H$ and ${\bf BAD}:=\{(q, x, D_Q, w) \in Q \times (X \cup X_{com} \cup \{x_{halt}\}) \times 2^Q \times W \mid (x=x_{halt} \vee D_Q=\varnothing) \wedge w \notin W_m\}$. \end{theorem} \begin{theorem} Given any plant $G$ over $\Sigma$, any supervisor $S$ over control constraint $(\Sigma_c, \Sigma_o)$, any attack constraint $(\Sigma_{o, A}, \Sigma_{c, A})$ and any damage automaton $H$ over $\Sigma$, there is a damage-reachable covert control command eavesdropping actuator attacker $A$ over attack constraint $(\Sigma_{o, A}, \Sigma_{c, A})$ on $(G, S)$ with respect to $H$ iff there is a supervisor $S'$ over $(\Sigma_{c, A}, \Sigma_{o, A} \cup \Gamma)$ such that $S' \lVert P$ avoids reaching the set ${\bf BAD}$ of bad states in $P$ and $L_m(S' \lVert P) \neq \varnothing$, where $P=G \lVert BT(S)^A \lVert P_{\Sigma_o}(S \lVert G) \lVert H$ and ${\bf BAD}:=\{(q, x, D_Q, w) \in Q \times (X \cup X_{com} \cup \{x_{halt}\}) \times 2^Q \times W \mid (x=x_{halt} \vee D_Q=\varnothing) \wedge w \notin W_m\}$. \end{theorem} The same conclusions on the complexity issues as in the non-eavesdropping case, which are presented in Section 4, apply to the control command eavesdropping case. Due to serious space restriction, we here shall omit the discussions. \begin{remark} The approach that uses bipartization of supervisors is rather versatile~\cite{ZLWS19}. Here, we shall explain how the supervisor bipartization approach can also be used for solving the actuator attacker synthesis problem in Section 4 (thus treating the analysis in Section 4 as a special case of the analysis carried out in Section 5). Indeed, for the non-eavesdropping case, we only need to treat $\Gamma$ as unobservable to the attacker. By merging the states $x$ and $x_{com}$ in $BT(S)^A$, as the only transition between them is both unobservable and uncontrollable to the attacker, we immediately recover $S^A$; thus, Theorem 4 and Theorem 5 are now immediately reduced to Theorem 1 and Theorem 2, respectively, for the non-eavesdropping case. The case when the supervisor sends a control command each time when it fires an observable transition $\zeta(x, \sigma)=x'$ satisfying $\Gamma(x) \neq \Gamma(x')$ can be dealt with using exactly the same construction, but requires the notion of dynamic observation~\cite{AVW03} that is beyond the scope of this work \end{remark} \vspace{-12pt} \section{Discussions and Conclusions} \label{section:DC} \vspace{-4pt} In this paper, we have presented a formalization of the covert actuator attacker synthesis problem, in the formalism of discrete-event systems, for cyber-physical systems. In particular, we have addressed the problems of synthesis of covert actuator attackers with the damage-nonblocking goal and with the damage-reachable goal, respectively. It is worth noting that the technique to solve the actuator attacker synthesis problem is by reduction to the well-studied supervisor synthesis problem, instead of developing new synthesis algorithms. In the rest of this section, we provide a discussion of some future works that can be carried out. {\bf Synthesis of (Powerful) Actuator and Sensor Attackers}: This work only considers the synthesis of actuator attackers. One of the immediate future works for us is to consider the problem of synthesis of (powerful) combined actuator and sensor attackers~\cite{LZS19}. The solution to the attacker synthesis problem has immediate applications to the resilient supervisor synthesis problem, as explained in~\cite{LZS19}. {\bf Resilient Supervisor Synthesis}: The problem of resilient supervisor synthesis can be better understood. In~\cite{LZS19}, a bounded resilient supervisor synthesis approach has been developed as a semi-decision procedure for the synthesis of resilient supervisors against powerful actuator and sensor attackers. It is also of interest for us to explore other (semi-)decision procedures for resilient supervisor synthesis. Finally, we shall remark that the problem of covertly attacking closed-loop systems in ``continuous" control theory is nothing new~\cite{S11},~\cite{TSSJ12},~\cite{ALSB10},~\cite{PDB13},~\cite{MKBDLPS12}. It is of interest to borrow the ideas from theses studies and enrich our discrete-event systems based theory; we hope that the discrete-event based approach can also inspire further research in ``continous" control theory based security of cyber-physical systems, e.g., \begin{samepage} the notion and synthesis of a supremal attacker~\cite{Lin2018}. An interesting research direction is to extend our framework to hybrid or probabilistic models~\cite{FKNP11}. \begin{comment} We intend to remove the assumption. one approach is to use the technique developed in~\cite{YL16} synthesis of all attackers, extension to eavesdropping attacker synthesis of resilient supervisor, combination of sensor and actuator attack how normality assumption can be removed how synthesis of supervisor can be carried out.. three person play game if using above construction synthesis of resilient supervisor We currently know of two ways to address the problem of resilient supervisor synthesis. 1. bounded synthesis 2. heuristic synthesis: treating each attackable event as uncontrollable, solve the resilient against risky problem, which is a heuristic for solving the synthesis against non-risky.. 3. represent the supervisor using all structure, A heuristic to solve the supervisor synthesis is to treat any event with attackable event as uncontrollable....This only works for risky attackers...whose goal is to reach any many states as possible. covertness requirement the non-reachability of certain states. Thus, treating with uncontrollable event is only a heuristic..We need to consider all structure.... generalize to eavesdropping attacker, risky or covert attacker , 2. observing control command each time when observable transition extend to deal with sensor and actuator attacks. \end{comment} \begin{acknowledgements} This work is financially supported by Singapore Ministry of Education Academic Research Grant RG91/18-(S)-SU RONG (VP), which is gratefully acknowledged. \end{acknowledgements} \vspace{-4pt} \begin{comment} ---------------------- \begin{lemma} \label{lemma: ROS} Let the plant $G$ and the normal supervisor $V$ be given. Suppose there exists an attacker $A$ on $(G, V)$ w.r.t. $(\Sigma_{c, A}, \Sigma_{o, A})$ that satisfies $\varnothing \neq L(V_A/G)-L(V/G) \subseteq L_{dmg}$. Suppose that for some $w_0 \in P_o(L(V/G))$, it holds that $(V(w_0) \cap \Sigma_{c, A}) \nsubseteq A(\hat{P}_{o, A}^{V}(w_0))$. Then, the attacker $A': \hat{P}_{o, A}^{V}(P_o(L(V/G))) \rightarrow \Delta \Gamma$ on $(G, V)$ w.r.t. $(\Sigma_{c, A}, \Sigma_{o, A})$ with \begin{enumerate} \item $A'(\hat{P}_{o, A}^{V}(w_0)):=(V(w_0) \cap \Sigma_{c, A}) \cup A(\hat{P}_{o, A}^{V}(w_0))$ \item for any other $\hat{w} \neq \hat{P}_{o, A}^{V}(w_0)$ in $\hat{P}_{o, A}^{V}(P_o(L(V/G)))$, $A'(\hat{w}):=A(\hat{w})$ \end{enumerate} also satisfies $\varnothing \neq L(V_{A'}/G)-L(V/G) \subseteq L_{dmg}$. \end{lemma} \begin{proof} We first show that the actuator attacker $A'$ is well-defined. Let $w_1 \in P_o(L(V/G))$ be another string such that $(V(w_1) \cap \Sigma_{c, A}) \nsubseteq A(\hat{P}_{o, A}^{V}(w_1))$ and $\hat{P}_{o, A}^{V}(w_0)=\hat{P}_{o, A}^{V}(w_1)$. We need to show that $A'(\hat{P}_{o, A}^{V}(w_0))=A'(\hat{P}_{o, A}^{V}(w_1))$ holds for $A'$. By the definition, we have that $last(\hat{P}_{o, A}^{V}(w_0))=(P_{o, A}(last(w_0)), V(w_0))$ and $last(\hat{P}_{o, A}^{V}(w_1))=(P_{o, A}(last(w_1)), V(w_1))$, where $last$ is used to denote the operation that computes the last element in a string. Since $\hat{P}_{o, A}^{V}(w_0)=\hat{P}_{o, A}^{V}(w_1)$, we conclude that $last(\hat{P}_{o, A}^{V}(w_0))=last(\hat{P}_{o, A}^{V}(w_1))$ and thus $V(w_0)=V(w_1)$. It then follows that $A'(\hat{P}_{o, A}^{V}(w_0))=(V(w_0) \cap \Sigma_{c, A}) \cup A(\hat{P}_{o, A}^{V}(w_0))=(V(w_1) \cap \Sigma_{c, A}) \cup A(\hat{P}_{o, A}^{V}(w_1))=A'(\hat{P}_{o, A}^{V}(w_1))$. In the following, we only need to show that $\varnothing \neq L(V_{A'}/G)-P_{o}^{-1}P_o(L(V/G)) \subseteq L_{dmg}$. By the definition of $A'$, it holds that, for any $\hat{w} \in \hat{P}_{o, A}^{V}(P_o(L(V/G)))$, $A(\hat{w}) \subseteq A'(\hat{w})$. Correspondingly, for any $w \in P_o(L(V/G))$, we have that $V_A(w) \subseteq V_{A'}(w)$. It follows that $L(V_A/G) \subseteq L(V_{A'}/G)$. Since $\varnothing \neq L(V_A/G)-P_{o}^{-1}P_o(L(V/G))$, we then have $\varnothing \neq L(V_{A'}/G)-P_{o}^{-1}P_o(L(V/G))$. In the rest, we show that $L(V_{A'}/G)-P_{o}^{-1}P_o(L(V/G)) \subseteq L_{dmg}$. \end{proof} By Lemma~\ref{lemma: ROS}, we can ensure that {\color{red} XXX}. Thus, we have the following corollary. \begin{corollary} Let the plant $G$ and the normal supervisor $V$ be given. Suppose there exists an attacker $A$ on $(G, V)$ w.r.t. $(\Sigma_{c, A}, \Sigma_{o, A})$ that satisfies $\varnothing \neq L(V_A/G)-P_{o}^{-1}P_o(L(V/G)) \subseteq L_{dmg}$. Then, there exists an attacker $A'$ on $(G, V)$ w.r.t. $(\Sigma_{c, A}, \Sigma_{o, A})$ such that \begin{enumerate} \item $A'(\hat{P}_{o, A}^{V}(w)) \supseteq (V(w) \cap \Sigma_{c, A})$, for any $w \in P_o(L(V/G))$ \item $\varnothing \neq L(V_{A'}/G)-P_{o}^{-1}P_o(L(V/G)) \subseteq L_{dmg}$. \end{enumerate} \end{corollary} \begin{lemma} The supremal element exists for the control map $A$ \end{lemma} ------------------------ \subsection{Verification of Attackability} \label{subsection: VA} In this subsection, we address the problem of verifying attackability. Recall that $G=(Q, \Sigma, \delta, q_0)$ is the plant. Let $V$ be a supervisor on $G$ w.r.t. $(\Sigma_c, \Sigma_o)$, which is given by a finite state automaton $S=(X, \Sigma, \Delta, x_0)$. , where $V(P_o(s))=\{\sigma \in \Sigma \mid \Delta(\Delta(x_0, s), \sigma)!\}$ for any $s \in L(V/G)=L(S \lVert G) \subseteq L(S)$. Let $s$ be any string in $L(V/G)$. $w=\hat{P}_{o, A}^{V}(P_{o}(s)) \in ((\Sigma_{o, A} \cup \{\epsilon\}) \times \Gamma)^*$ is the attacker's observation sequence when $s$ is generated. From the attacker's point of view, what is the set of strings $s \in L(V/G)$ that the system might have generated? This is captured by the following problem. \begin{problem} Given any string $w$ in $\hat{P}_{o, A}^{V}(P_{o}(L(V/G)))$, compute the set $\{s \in L(V/G) \mid w=\hat{P}_{o, A}^{V}(P_{o}(s))\}$ of all the possible strings that are generated. \end{problem} Given $s$, compute the set of all observationally equivalent strings. This is Inverse Projection, subset construction If both transitions to bad and no bad is defined at the subset construction for the transducer, then there is an attack. produce the counter example $(s, \sigma)$ {\color{red} continue on this} \subsection{Attack Synthesis} In this subsection, we address the problem of synthesis of successful attackers, which, if we do not care about the optimality, is a well solved problem based on the proof of Theorem~\ref{theorem:existence} and the discussions in Section~\ref{subsection: VA}. Indeed, if $(G, V)$ is not attackable w.r.t. $(\Sigma_{c, A}, \Sigma_{o, A})$ and $L_{dmg}$, then there is no successful attacker on $(G, V)$ w.r.t. $(\Sigma_{c, A}, \Sigma_{o, A})$ and $L_{dmg}$; otherwise, we can compute a witness $(s, \sigma)$ for the attackability, which can be used for synthesizing a successful attacker $A: \hat{P}_{o, A}^{V}(P_o(L(V/G))) \rightarrow \Delta \Gamma$ on $(G, V)$ w.r.t. $(\Sigma_{c, A}, \Sigma_{o, A})$ and $L_{dmg}$ by setting \begin{enumerate} \item $A(\hat{P}_{o, A}^{V}(P_o(s)))=(V(P_o(s)) \cap \Sigma_{c, A}) \cup \{\sigma\}$ \item for any $w \in P_o(L(V/G))$ such that $\hat{P}_{o, A}^{V}(w)\neq \hat{P}_{o, A}^{V}(P_o(s))$, $A(\hat{P}_{o, A}^{V}(w))=V(w) \cap \Sigma_{c, A}$. \end{enumerate} In the rest of this section, we show that there exists the supremal successful attacker $A^{\uparrow}$ on $(G, V)$ w.r.t. $(\Sigma_{c, A}, \Sigma_{o, A})$ and $L_{dmg}$, if $(G, V)$ is attackable w.r.t. $(\Sigma_{c, A}, \Sigma_{o, A})$ and $L_{dmg}$. We then present an algorithm to compute the supremal successful attacker. {\color{red} continue on this} \subsubsection{Existence of Supremal Successful Enabling Attacker} In the following, we show that the set of successful enabling attackers on $(G, V)$ w.r.t. $(\Sigma_{c, A}, \Sigma_{o, A})$ and $L_{dmg}$ is closed under the $\sqcup$ operation \begin{lemma} Let the plant $G$ and the normal supervisor $V$ be given. Let $A_1$ and $A_2$ be any two successful enabling attackers on $(G, V)$ w.r.t. $(\Sigma_{c, A}, \Sigma_{o, A})$ and $L_{dmg}$. Then, $L(V_{A_1 \sqcup A_2}/G)=L(V_{A_1}/G) \cup L(V_{A_2}/G)$ and $A_1 \sqcup A_2$ is also a successful enabling attacker on $(G, V)$ w.r.t. $(\Sigma_{c, A}, \Sigma_{o, A})$ and $L_{dmg}$. \end{lemma} \begin{proof} $\varnothing \neq L(V_{A_i}/G)-L(V/G) \subseteq L_{dmg}$ for $i=1, 2$, since both $A_1$ and $A_2$ are successful attackers on $(G, V)$ w.r.t. $(\Sigma_{c, A}, \Sigma_{o, A})$ and $L_{dmg}$. We now show that $L(V_{A_1 \sqcup A_2}/G)=L(V_{A_1}/G) \cup L(V_{A_2}/G)$. Then, it immediately follows that $\varnothing \neq L(V_{A_1 \sqcup A_2}/G)-L(V/G) \subseteq L_{dmg}$ and $A_1 \sqcup A_2$ is also a successful attacker on $(G, V)$ w.r.t. $(\Sigma_{c, A}, \Sigma_{o, A})$ and $L_{dmg}$. It is immediate that $A_1 \sqcup A_2$ is an enabling attacker. It is clear that $L(V_{A_i}/G) \subseteq L(V_{A_1 \sqcup A_2}/G)$, for $i=1, 2$, since $(A_1 \sqcup A_2)(\hat{P}_{o, A}^{V}(w)) \supseteq A_i(\hat{P}_{o, A}^{V}(w))$ for any $w \in P_o(L(V/G))$ and thus $V_{A_1 \sqcup A_2}(w) \supseteq V_{A_i}(w)$ for any $w \in P_o(L(V/G))$. Thus, we have $L(V_{A_1 \sqcup A_2}/G) \supseteq L(V_{A_1}/G) \cup L(V_{A_2}/G)$. In the rest, we show $L(V_{A_1 \sqcup A_2}/G) \subseteq L(V_{A_1}/G) \cup L(V_{A_2}/G)$. We have $L(V/G) \subseteq L(V_{A_i}/G)$ for $i=1, 2$ and $L(V/G) \subseteq L(V_{A_1 \sqcup A_2}/G)$, since $A_1$, $A_2$ and $A_1 \sqcup A_2$ are all enabling attackers. Thus, we only need to show $L(V_{A_1 \sqcup A_2}/G)-L(V/G) \subseteq L(V_{A_1}/G) \cup L(V_{A_2}/G)-L(V/G)$. Let $s$ be any string in $L(V_{A_1 \sqcup A_2}/G)-L(V/G)$. It is clear that $s=s'\sigma$ for some $s' \in L(V/G)$ and $\sigma \in (A_1\sqcup A_2)(\hat{P}_{o, A}^{V}(P_o(s')))=A_1(\hat{P}_{o, A}^{V}(P_o(s'))) \cup A_2(\hat{P}_{o, A}^{V}(P_o(s')))$. If $\sigma \in A_1(\hat{P}_{o, A}^{V}(P_o(s')))$, then we have $s'\sigma \in L(V_{A_1}/G)-L(V/G)$; otherwise, we have $s'\sigma \in L(V_{A_2}/G)-L(V/G)$. In any case, we have $s \in L(V_{A_1}/G) \cup L(V_{A_2}/G)-L(V/G)$. \end{proof} For any two enabling attackers $A_1, A_2$ on $(G, V)$ w.r.t. $(\Sigma_{c, A}, \Sigma_{o, A})$, we define $A_1 \sqsubseteq A_2$ if $A_1(\hat{w}) \subseteq A_2(\hat{w})$ for any $\hat{w} \in \hat{P}_{o, A}^{V}(P_o(L(V/G)))$. Then, it is immediate that $A_1 \sqsubseteq A_2$ iff $A_1 \sqcup A_2=A_2$. Now, let $\Phi$ denote the set of all the successful enabling attackers on $(G, V)$ w.r.t. $(\Sigma_{c, A}, \Sigma_{o, A})$ and $L_{dmg}$. If $\Phi$ is non-empty, then the supremal element $A^{\uparrow}=\bigsqcup_{A \in \Phi}A$ exists in $\Phi$ and $\forall A \in \Phi, A \sqsubseteq A^{\uparrow}$, which is defined such that $A^{\uparrow}(\hat{w})=\bigcup_{A \in \Phi}A(\hat{w})$ for any $\hat{w} \in \hat{P}_{o, A}^{V}(P_o(L(V/G)))$. It is clear that $A^{\uparrow}$ is an enabling attacker. We have the following characterization of $A^{\uparrow}$. \begin{theorem} Let the plant $G$ and the normal supervisor $V$ be given. If there exists a successful attacker on $(G, V)$ w.r.t. $(\Sigma_{c, A}, \Sigma_{o, A})$ and $L_{dmg}$, then $A^{\uparrow}$ exists in $\Phi$ and, for any $s \in L(V/G)$, $A^{\uparrow}(\hat{P}_{o, A}^{V}(P_o(s)))=(V(P_o(s)) \cap \Sigma_{c, A})\cup I(\hat{P}_{o, A}^{V}(P_o(s)))$, where Next, we shall show that $A^{\uparrow}(\hat{P}_{o, A}^{V}(P_o(s))) \supseteq (V(P_o(s)) \cap \Sigma_{c, A})\cup I(\hat{P}_{o, A}^{V}(P_o(s)))$. It is clear that $A^{\uparrow}(\hat{P}_{o, A}^{V}(P_o(s))) \supseteq V(P_o(s)) \cap \Sigma_{c, A}$ since $A^{\uparrow}(\hat{P}_{o, A}^{V}(w))=\bigcup_{A \in \Phi}A(\hat{P}_{o, A}^{V}(w))$ for any $w \in P_o(L(V/G))$ and each attacker $A$ in $\Phi$ is enabling. Let $\sigma$ be any event in $I(\hat{P}_{o, A}^{V}(P_o(s)))$. By definition, there exists some $s' \in L(V/G)$ such that $\hat{P}_{o, A}^{V}(P_o(s))=\hat{P}_{o, A}^{V}(P_o(s'))$ and $(s', \sigma) \in AP_{dmg}$. Now, let $A: \hat{P}_{o, A}^{V}(P_o(L(V/G))) \rightarrow \Delta \Gamma$ be an enabling attacker on $(G, V)$ w.r.t. $(\Sigma_{c, A}, \Sigma_{o, A})$ defined such that \begin{enumerate} \item $A(\hat{P}_{o, A}^{V}(P_o(s')))=(V(P_o(s')) \cap \Sigma_{c, A}) \cup \{\sigma\}$ \item for any $w \in P_o(L(V/G))$ such that $\hat{P}_{o, A}^{V}(w)\neq \hat{P}_{o, A}^{V}(P_o(s'))$, $A(\hat{P}_{o, A}^{V}(w))=V(w) \cap \Sigma_{c, A}$. \end{enumerate} Since $(s', \sigma) \in AP_{dmg}$, from the proof of Theorem~\ref{theorem:existence}, we conclude that $A$ is a successful enabling attacker on $(G, V)$ w.r.t. $(\Sigma_{c, A}, \Sigma_{o, A})$ and $L_{dmg}$, i.e., $A \in \Phi$. Then, we have $\sigma \in A(\hat{P}_{o, A}^{V}(P_o(s'))) \subseteq A^{\uparrow}(\hat{P}_{o, A}^{V}(P_o(s')))=A^{\uparrow}(\hat{P}_{o, A}^{V}(P_o(s)))$. Thus, we have shown that $I(\hat{P}_{o, A}^{V}(P_o(s))) \subseteq A^{\uparrow}(\hat{P}_{o, A}^{V}(P_o(s)))$ and thus $A^{\uparrow}(\hat{P}_{o, A}^{V}(P_o(s))) \supseteq (V(P_o(s)) \cap \Sigma_{c, A})\cup I(\hat{P}_{o, A}^{V}(P_o(s)))$. Then, we show that $A^{\uparrow}(\hat{P}_{o, A}^{V}(P_o(s))) \subseteq (V(P_o(s)) \cap \Sigma_{c, A})\cup I(\hat{P}_{o, A}^{V}(P_o(s)))$. We only need to show that, for any $A \in \Phi$, $A(\hat{P}_{o, A}^{V}(P_o(s))) \subseteq (V(P_o(s)) \cap \Sigma_{c, A})\cup I(\hat{P}_{o, A}^{V}(P_o(s)))$. Let $\sigma$ be any event in $A(\hat{P}_{o, A}^{V}(P_o(s)))$. It is clear that $\sigma \in \Sigma_{c, A}$. If $\sigma \in V(P_o(s))$, then $\sigma \in V(P_o(s)) \cap \Sigma_{c, A} \subseteq (V(P_o(s)) \cap \Sigma_{c, A})\cup I(\hat{P}_{o, A}^{V}(P_o(s)))$. We suppose $\sigma \notin V(P_o(s))$. show that the language is supremal among all attackers \begin{proposition} Let the plant $G$ and the normal supervisor $V$ be given. Suppose $\Phi$ is non-empty. For any successful attacker $A$ on $(G, V)$ w.r.t. $(\Sigma_{c, A}, \Sigma_{o, A})$ and $L_{dmg}$, we have $L(V_A/G) \subseteq L(V_{A^{\uparrow}}/G)$. \end{proposition} \subsubsection{Synthesis of Supremal Successful Enabling Attacker} Annotate the supervisor, is the attacker finite state representable \begin{problem} \end{problem} The idea is to perform variation of the subset construction on the supervisor. This is illustrated by the next example. \begin{example} \end{example} \begin{theorem} \end{theorem} This is illustrated by the next example. \begin{example} \end{example} \begin{proposition} \end{proposition} attackable.....strong attack \section{Synthesis of Normal Supervisors Against Actuator Attack} Iteratively remove attackable strings. edit the control map \section{Conclusions and Future Work} In this paper, we have proposed a discrete-event based attacker model and presented an algorithm for the synthesis of supremal actuator attacker. strong attack remove $\Sigma_{c, A} \subseteq \Sigma_{o, A}$ remove the constraint that normal supervisor remove constraint on the observation channel of the attacker. confusion map synthesis. interpretation of $L_{dmg}$ \end{comment} \begin{comment} \begin{figure}[h] \centering \hspace*{-1mm} \includegraphics[width=2.0in, height=1.0in]{archi2} \captionsetup{justification=centering} \caption{architecture for actuator attack \label{fig:ring} \end{figure} \end{comment} \begin{comment} \section{Attack Synthesis for Non-Normal Supervisor} In the following, we work on the case where the supervisor is allowed to be non-normal, that is, $\Sigma_c \cap \Sigma_{uo}$ is allowed to be non-empty. {\color{red} to change to string} The system $(G, S)$ is covertly attackable by a full-observation attacker $A$ over $\Sigma_{c, A}$ iff \begin{enumerate} \item there is a boundary state of $G$ outside $S$ that is reachable via a string $w \in L(G)$ such that \begin{enumerate} \item $P_{S,o}(w) \in L(S/G)$ (covertness of attack) \item for any $w' \in L(G), \sigma \in \Sigma_{S, c}$ such that $w'\sigma \leq w$, we have $\sigma \notin S(P_{S, o}(w')) \implies \sigma \in \Sigma_{c, A}$ (realizability of attack) \end{enumerate} \item there is a boundary state of $G$ inside $S$ \end{enumerate} Intuitively, the attack mechanism is as follows: if B), then wait the supervisor moves to the boundary state, establish attack!; if A), then, fool the supervisor to the boundary state, establish attack! Here, since every disabled event in the corresponding path is attackable, it is realizable under attack. The resulting string will be observationally equivalent to a string in normal supervised behavior, thus remain covert. If cannot observe the control command, then $S_1 \leq S_2$ (behaviour subset) implies that $S_1$ easier to attack than $S_2$ synthesis of secure relative observable supervisor. We will present a general schematic representation of the actuator attack model We need to distinguish between the case whether the supervisor controls outside the reachable state space. The model is very general. It includes the following usual architectures. To see this,... We first define the notion of attackability. After the definition, we see that a serious trouble here is that boundary transition that is unobservable could be disabled. A simple trick is to develop normal supervisor. However, there are two restrictions. Firstly, naturally, supervisor designed may not be normal. So the attack designed for normal supervisor may not be workable, while the supervisor is indeed attackable. Another rationale is that the normal supervisor necessarily restricts the solution behavior. It is possible that robust supervisor does exist, but normal robust supervisor does not exist. We are interested in the following problems \begin{enumerate} \item Given any string $s \in \overline{K}$, is it an attackable string? \item For any close behavior $K$, how to compute the set of attack strings? \item Is a given attack string enforceble and how to enforce it? \item Given any close behavior, is there a enforceble attackable string? \end{enumerate} Computation of the set of all attackable strings. 1) for any boundary state within $S$, union the languages 2) for any boundary state outside $S$, .. it is crucial whether the supervisor disables events outside $S$! Two cases here. The system $(G, S)$ is covertly attackable by a partial-observation attacker $A$ over $(\Sigma_{c, A}, \Sigma_{o, A})$ iff synthesize an partial-observation attacker synthesize an maximal permissive robust supervisor. use normal supervisor to preclude. synthesize normal supervisor that exclude boundary states \begin{enumerate} \item prune or enlarge \item Given any fixed supervisor, how shall the attacker attack (attack model) \item Under the attack model, how to design a supervisor that works against the attacker \item When supremality exists. In general, only maximal permissiveness exists \item How to property design observation alphabets so that it is minimal. \item Given a fixed observation for the supervisor, if robust supervisor does not exist, how to extend the observation capability \item How about in the distributed setup? Is the problem decidable? \item bad state attack; blocking attack \item we show that synthesizing of non-normal supervisor is a source of dangerous, since every disabled event (going out of the bad state zone) is observable. In the first work, we consider normal supervisor that is robust \item We assume $\Sigma_{uo} \cap \Sigma_{A, attackable} \neq \varnothing$, otherwise no solution \item sufficient and necessary condition for the existence of secure supervisor against attack. relationship between observable events of supervisor and attack \item double partial observation structure \item usually, supervisor has to be as restrictive as possible to be robust \item read modal mu calculus and better under partial observation (read xiang yin's paper) \item attackability; sat based solver---different synchronization method \item synthesis of confusing maps \end{enumerate} We motivate our results with the following example. Without attacker, the closed-loop system is $S \lVert G$, where bad states are not reachable. \subsection{Definitions} All events in $\Sigma$ in the plant are either controllable or uncontrollable $\Sigma _c \dot \cup \Sigma_{uc}$ and they are either observable or unobservable $\Sigma _o \dot \cup \Sigma _{uo}$.\par In normal operation, the plant $G$ relays event occurrences $\sigma \in \Sigma _o$ to the supervisor. Based on the observed events, the supervisor will send a set of allowed events $\gamma \in \Gamma$ with $\Gamma := \{\gamma \subseteq \Sigma | \Sigma _{uc} \subseteq \gamma \}$. \MR{This last formula seems strange. $\Sigma_{uc}$ is a set of events and $\gamma$ is an event, so this cannot be the intention.} uncontrollable events to happen. \par Now we introduce an \textit{Actuator Attacker A}. The attacker is assumed to have full knowledge of the Plant $G$ and the Supervisor $S$ and/or $V$. The goal of the attacker is to lead the system \MR{It should be made more clear what is the system: is it the plant $G$ or the controlled system $S || G$?}to a predefined set of \textit{Damaging States:} \MR{Are the damaging states those of the plant or also those of the supervisor?} $X_{da} \subseteq X \wedge X_{da} \nsubseteq Z$. {\color{red} $X_{da} \subseteq X \wedge X_{da} \cap Z=\varnothing$?} \MR{The states of $Z$ are unrelated to those of $X$ unless you assume a specific synthesis construction of the FSA for the supervisor. It looks strange to write $X_{da} \cap Z$} The attacker is assumed to be able to read out a set of observable event occurrences to the attacker of the plant $\Sigma _{o,A}$. Also, the attacker can intercept and read the event set $\gamma \in \Gamma$ issued by the supervisor. The attacker is able to remove and add new events to this control pattern as long as they are \textit{Attacker Controllable Events: }$\Sigma_{c,A} \subseteq \Sigma_c$. A new control signal $\gamma' \in \Gamma'$ follows. \par It is possible to model the supervisor under influence of the attacker by a new FSA \textit{Supervisor under Attack S'} which, respective to the case above, represents a control pattern mapping $V':L(G)\rightarrow \Gamma'$. \MR{ARe we going to construct such an FSA? WHere?} The control loop as described above is given in Figure \ref{control_loop_image}.\par \begin{figure}[htpb] \centering \includegraphics[width=0.75\columnwidth]{images/control_loop.eps} \caption{Control loop {\color{red} after observation channel, we may have $\epsilon$instead of event}} \label{control_loop_image} \end{figure} \MR{It would be nice if all sets used before are made visible in the figure. I would also present the figure a bit earlier, as it may help to understand the setting.} In short, the attacker will execute its attack in two phases. In the first phase it will \textit{Covertly} lead the system to a state from which it can launch an \textit{Attacker Controllable Event}, then, in the second phase, it will insert this event trying to lead the system to a \textit{Damaging State}. In order to properly define the types of these attacks and their influence, the definition of several notions is needed: \begin{itemize} \item \textit{Damaging State:} State in a predefined set of states outside the closed loop behaviour of this system, but within the plant behaviour. $X_{da} \subseteq X \wedge X_{da} \nsubseteq Z$. \item \textit{Covertness:} The attacker is \textit{covert} as long as all language observed by the supervisor is defined in the language of the closed loop system: $L(S'/G)\subseteq L(S/G)$. The attacker loses its \textit{covertness} property once an observable event takes place that is undefined in the closed loop behaviour $S/G$ but defined in the plant behaviour $G$.\\ In short, an action keeps the attacker covert \textit{covert} if this action is allowed by the supervisor or the action is undefined in the plant. \item \textit{Boundary State:} A state from which a \textit{Attacker Controllable Event} can be fired so that, possibly by taking uncontrollable events, a \textit{Damaging State} $X_{da}$ can be reached. The set of \textit{Boundary states} $X_b$ can be defined as given in Equation \ref{boundarystate1}. From some \textit{Boundary States} the attacker does not have to rely on the occurrence of these uncontrollable events in order to reach a damaging state, these states will be known as \textit{Strong Boundary States} $x_{b,strong} \in X_{b,strong}$ and are defined in Equation \ref{boundarystate2}. Boundary states that are not strong, will be known as \textit{Weak Boundary States}: $x_{b,weak} \in X_{b,weak}$ as defined in Equation \ref{boundarystate3}. \begin{align} \begin{split} X_b = \{ b|\xi (b,\sigma_1 \sigma_2) \in X_{da} \text{ with } \sigma_1 \in \Sigma_{c,A} \wedge \sigma_2 \in \Sigma^*_{uc}\} \label{boundarystate1} \end{split}\\ \begin{split} X_{b,strong} = \{ b|\xi (b,\sigma) \in X_{da} \text{ with } \sigma \in \Sigma_{c,A}\} \label{boundarystate2} \end{split}\\ \begin{split} X_{b,weak} = X_b \setminus X_{b,strong} \label{boundarystate3} \end{split} \end{align} \item \textit{Certain Actuator Attack:} Due to partial observability, the attacker will not always know the exact state that the closed loop system $S/G$ is in. Using the observed events and control signal from the supervisor, the attacker will have to make a state estimation. There will be a maximal set of states the system could be in, if all states in this estimation are \textit{Strong Boundary States} that have the same \textit{Attacker Controllable Event} that immediately, without using uncontrollable directions, reach a \textit{Damaging State}, the attacker can launch this event. The issuance of this event will be know as a \textit{Certain Actuator Attack.} {\color{red} incomplete definition} \item \textit{Uncertain Actuator Attack:} If the maximal set of states the system could be in contains at least one \textit{Weak} or \textit{Strong Boundary State}, but the attacker can not launch a \textit{Certain Actuator Attack}, then the Attacker could launch a \textit{Uncertain Actuator Attack}. For a part of the estimated states the attack might be successful, but the attack could also be unsuccessful and lead to the attacker losing covertness without the system reaching a \textit{Damaging State.} \item {\color{red}Risky / Non Risky Actuator Attacks} \item \textit{Strong Attackability:} {\color{red}strongly attackable} There exists an order of events in the closed loop system $S/G$ after which the Attacker can launch a \textit{Certain Actuator Attack} \item \textit{Weak Attackability:} There exists no order of events in the closed loop system $S/G$ after which the Attacker can launch a \textit{Certain Actuator Attack}. There exists an order of events in the closed loop system $S/G$ after which the Attacker can launch an \textit{Uncertain Actuator Attack}. \end{itemize} If the attacker loses covertness without the system being in a damaging state, it is assumed that the system can take defensive action and go to some lockdown mode where the attacker can not damage the system anymore. This could not purely be done by the supervisor, because there is no confidence that the supervisors actions will be performed. Thus, this subject is considered to be outside the scope of this paper.\par The attacker is defined to be a \textit{Smart Actuator Attacker} when: \begin{itemize} \item If $(S,G)$ is \textit{Strong Attackable}, the Attacker will not lose covertness before it has guaranteed the system reaches a bad state. Only if $(S,G)$ is \textit{Weak Attackable}, the Attacker will launch a \textit{Uncertain Actuator Attack}. \item The attacker changes the control map $V$ to $V' : L(G )\rightarrow \Gamma'$. This control map shall be modelled as a FSA $S'$ respective to the model $S$ of $V$. $S'$ is a controllable normal supervisor. \item If possible, the attacker will disallow events that would lead the system to a state from which a damaging state can not be reached anymore. \item {\color{red}do we wish to add more reqs?} \end{itemize} We introduce several notions of different types of Actuator Attacks with their respective synthesis algorithms to model a system that is under the influence of these Actuator Attacks. This will be followed by formulations of supervisor models that are robust against these type of attacks, along with their respective synthesis algorithms. \subsection{Inverse projection of Attacker} The projection of observable events to the attacker is given as $P_{o,A}:\Sigma^*_o \rightarrow \Sigma^*_{o,A}$. Next to these observations, the attacker also has the allowed event set of the supervisor as an input. For a successful attack, the attacker wishes to estimate the state the system is in using both of these inputs. Therefore it is useful to come up with an inverse projection $\hat{P}^{-1}_{o,A} : I^* \rightarrow \Sigma^*$, with $I^* = \Sigma^*_{o,A} \times \Gamma^*$. In order to properly narrow down what states the attacker might think the system could be in, this $I^*$ needs to be properly defined. We can not just give two separate lists in $\Sigma^*_{o,A}$ and $\Gamma^*$ and compute all the possible behavior of the plant that would result in these lists as the attacker has more information; it knows when these events and control commands are occurring. It is necessary to keep track of what events and control commands occur synchronously. To this aim, $I$ will be given as an \textit{n-tuple} of $\sigma,\gamma$ pairs: $I = \{(\sigma_1,\gamma_1),(\sigma_2,\gamma_2),...,(\sigma_n,\gamma_n)\} \in I^*$, the following rules are imposed on the construction of $I$: \begin{itemize} \item If $\sigma_i$ occurs and there is no new $\gamma$ input, then $\gamma_i = \gamma_{i-1}$. \item If $\gamma_i$ occurs and there is no sigma input, then $\sigma_i = \epsilon$. \item $\sigma_i$ is a string of length 1 in $\Sigma_{o,A}$, or contains the empty string $\epsilon$. \item $\gamma_i$ is a single set of allowed events in $\Gamma$. \end{itemize} With $I$ given in this form, the inverse projection $\hat{P}^{-1}_{o,A}$ can be computed as displayed in Equation \ref{invprojhatoa}. \begin{align} \begin{split} \hat{P}^{-1}_{o,A}(I) = &\{t=t_1 ... t_n \in \Sigma^* \Big{|} \text{ for all i from 1 to n } \Big{(}(\forall t_j \in \Bar{t_i})\\ &\big{(}V(P_{o,S}(t_0 ... t_{i-1} t_j))=\gamma_i \wedge t_0 ... t_{i-1} t_j \subseteq P^{-1}_{o,A} (\sigma_1 ... \sigma_i)\big{)}\Big{)}\} \text{ with } t_0 = \epsilon \label{invprojhatoa} \end{split} \end{align} \section{Synthesis of a Smart Actuator Attacker} {\color{orange}In this section, we present a framework to synthesize an actuator attacker. Before we provide the solution to this problem, we use the following example to illustrate the idea. \begin{example} Consider the plant $G$ and supervisor $S$ shown in Fig.XXX... \end{example} The following algorithm can be used to compute the set of attack strings $A(G, S)$. subset construction over $G$ and $S$.. \\} To cope with the Attacker having multiple input ports and a single output, it will be modelled by the means of a Deterministic \textit{Finite State Transducer (FST)}. An FST is a type of FSA that maps between two sets of symbols \cite{Jurafsky2008}. These can be viewed as an input and output set. The input set for the attacker is a tuple consisting out of the observable events to the attacker and the set of enabled events coming from the supervisor; Input alphabet $I=\{\sigma \in \Sigma \cup \epsilon, \gamma \in \Gamma \}$. The output of the attacker is a new set of allowed events which will be sent to the plant; Output alphabet $U = \{ \gamma' \in \Gamma'\}$. The Deterministic FST of the attacker is given by tuple $A = \{Q,I,U,\delta,\omega,q_0,F\}$ where: \begin{itemize} \item Q is the state space/set \item I is the input alphabet as defined above \item U is the output alphabet as defined above \item $\delta$ is the transition function $\delta : Q \times I \rightarrow Q$ \item $\omega$ is the output function $\omega : Q \times I \rightarrow U$ \item $q_0$ is the initial state \item $F$ is the set of marker states where $A$ will transduce a response. We wish to do this after every transition so $F=Q$ \end{itemize} Note that by the input alphabet the attacker can infer than an event in $\Sigma_{uo,A}$ has taken place by a change is $\gamma$. Note that this change in $\gamma$ can only occur if this particular event is defined in $\Sigma_{o,S}$.\par It is assumed that in the case where the supervisor switches from state and in the new state it wishes to issue the same control command as before, it will not send a new control signal. Thus, if the state changes from state \textit{A} to state \textit{B}, the attacker can only notice the state change if the event between these states in is $\Sigma_{o,A}$ or if the issued control command at state \textit{A} is different from the the control command at state \textit{B}.\par First, we focus on creating the state space of the attacker FST with for each state an assigned state estimation of what state the plant \textit{G} might be in using the available inputs. We define the following: \begin{itemize} \item $B(q)$ is the set of states $B(q) \subseteq X$ the attacker thinks the plant might be in at state $q\in Q$ of the attacker transducer. \item $En(x)$ is the set of allowed events by the supervisor when the plant is in state $x \in X$. \item $f_{S/G}(x_i,e)$ is the state that will be reached after firing event $e$ when the plant is in state $x_i$ as long as event $e$ is allowed by the supervisor when the plant is in state $x$ and $f(x_i,e)!$ in $G$. \end{itemize} The synthesis for the Attacker State Estimator is given in Procedure \ref{procstateest}: \begin{algorithm} \label{procstateest} \begin{algorithmic} \STATE Attacker State Estimator synthesis: \STATE $q_0 \in Q$ \STATE $B(q_0) = \{x|x=f_{S/G}(x_0,\sigma) \text{ with } \sigma \in \Sigma^*_{uo} \wedge (\forall \sigma \in \sigma^*)En(f(x_0,\sigma)) = En(x_0) \}$ \STATE $k = 0, k_{tot} = 0$ \WHILE{$k\leq k_{tot}$} \FOR {\textbf{\textit{all}} $x_i \in B(q_k)$} \STATE $T = \{\{e,\gamma\}|(f_{S/G}(x_i,e)!\vee e=\epsilon) \wedge e\in \Sigma_{o,A} \cup \epsilon \wedge \gamma = En(f_{S/G}(x_i,e))\}$ \STATE $I = I \cup T$ \FOR {\textbf{\textit{all}} $t = \{e,\gamma\} \in T$} \STATE $B(q_{k,t}) = \{x|x=f_{S/G}(x_i,\sigma) \text{ with } \sigma \in e\Sigma^*_{uo} \wedge (\forall \sigma \in \sigma^*)En(f(x_i,\sigma))=\gamma \}$ \IF{$\delta(q_k,t)!\text{ in A}$} \STATE $\text{add estimated states to destination: } B(\delta(q_k,t)) = B(\delta(q_k,t)) \cup B(q_{k,t})$ \ELSIF{$q_j \in Q \text{ exists, where: } B(q_j) = B(q_{k,t})$} \STATE $\delta(q_k,t) = q_j$ \ELSE \STATE $\text{Incr }k_{tot} \text{ and define }q_{k+1} \in Q \text{ with } B(q_{k+1})=B(q_{k,t}) \text{ and }q_{k+1} = \delta (q_k,t)$ \ENDIF \ENDFOR \ENDFOR \ENDWHILE \end{algorithmic} \end{algorithm} As for the Attacker tuple, $Q$, $I$, $\delta$, $q_0$ and $F (=Q)$ are now defined. It remains to introduce the output alphabet $U$ and the output functions $\omega$. As long as $\omega_i \subseteq \gamma_i \wedge \omega_i \neq \epsilon$ the attacker is covert. The attacker knows it can attack with certainty if there exists a unique event that leads the system to a bad state from all of the states the attacker estimated the closed loop system might be in. It will try to remove as much of the issued control commands as it can and insert the attack that will cause damage. So, Procedure \ref{procstateest} will be extended by Procedure \ref{procattack}. {\color{red}this algorithm is still incorrect because the change estimation will change with a new control issuance. It still shows the idea though} \begin{algorithm} \label{procattack} \begin{algorithmic} \STATE Attack synthesis:\\ \FOR{\textbf{\textit{all }} $q_i \in Q \text{ and respective } I_i = \{\sigma, \gamma_i\} \text{ for which } \delta (q_i,I_i)!$} \IF{$\exists e_i \in \Sigma_{c,A} \text{ where } \forall b \in B(q_i): \xi(b,e_i)! \text{ and } \neg \delta(b,e_i)!$} \STATE $\omega(q_i,I_i) = (\gamma_i \setminus \Sigma_{c,A} \cup e \text{ for } e_i \in \gamma_i \text{ and } I_i = \{\sigma,\gamma_i\} \text{{\color{red}new delta definition needed}}$ \ELSE \STATE $\omega(q_i,I_i) = \{e_i | e_i \in \gamma_i \text{ with } I_i = \{\sigma,\gamma_i\} \wedge \exists b = f(x_i,e_i\sigma) \text{ where } \xi(b,e_i)! \text { and }$ \STATE $\neg \delta(b,e_i)! \forall x_i \in B(q_i) \text{ with } f_{S/G}(x_i,e_i \sigma)!\} \cap \Sigma_{c,A}$ \STATE $\text{{\color{red} new delta definition needed, add what to do if gamma is empty now}}$ \ENDIF \ENDFOR \end{algorithmic} \end{algorithm} {\color{orange}The alphabet of the attacker observation automaton is $\Sigma \times \Gamma$. The control command in $\Gamma$ can used to refine the observation of the attacker the current state of the closed-loop systems. The attacker automaton is then straightfowardly modified from the attacker observation automaton using the following.... We need to use the attacker observation automaton to discover the set of attack strings. Based on sequences of execution and the control commands, .... We assume that before the plant executes, the attacker is already there... (to be moved to attacker model) The initial state is ...} \begin{theorem} The supervisor is resilient against actuator attack if and only if $A(G, S)=\varnothing$. \end{theorem} \begin{proof} proof \qedhere \end{proof} \section{Synthesis of Resilient Supervisors} In this section, we present an algorithm to synthesize a resilient supervisor against actuator attacker. {\color{orange}Given a non-resilient supervisor, based on algorithm XX, we can compute the set of all attack strings. A straightforward idea is to prune theses strings and synthesis another supervisor, check whether this supervisor is resilient. loop ,, Based on the above discussion, the next algorithm can be used to compute a resilient supervisor. The above algorithm is sound (not sure whether it is complete.) } technique 2: treat the set of attackable events as uncontrollable and synthesize a supremal normal and controllable sublauages. We show that the above two solutions are not comparable. The intuition is the following... \section{Case Study} {\color{red} Festo Line Example?} \end{comment} \addtolength{\textheight}{-10cm} \begin{comment} Intuitively, Assumption~\ref{assump: normalattack} states that the attacker cannot attack events that it cannot observe. The purpose for making Assumption~\ref{assump: normalattack} is to establish Lemma~\ref{lemma: NDS}, which states that we only need to focus on enabling actuator attackers for attacking normal supervisors (in order to achieve the attack goal). \begin{lemma} \label{lemma: NDS} Let the plant $G$ and the normal supervisor $V$ be given. Suppose that there exists a successful attacker $A$ on $(G, V)$ w.r.t. $(\Sigma_{c, A}, \Sigma_{o, A})$ and $L_{dmg}$. Then, there exists a successful enabling attacker $A'$ on $(G, V)$ w.r.t. $(\Sigma_{c, A}, \Sigma_{o, A})$ and $L_{dmg}$ \end{lemma} \begin{proof} Since $A$ is a successful attacker on $(G, V)$ w.r.t. $(\Sigma_{c, A}, \Sigma_{o, A})$ and $L_{dmg}$, we have $\varnothing \neq L(V_A/G)-L(V/G) \subseteq L_{dmg}$. Let $s$ be some fixed string in $L(V_A/G)-L(V/G)$, the existence of which is ensured since $L(V_A/G)-L(V/G) \neq \varnothing$. It is clear that $s=s'\sigma$ for some $s' \in L(V/G) \cap L(V_A/G)$ and $\sigma \in A(\hat{P}_{o, A}^{V}(P_o(s'))) \subseteq \Sigma_{c, A}$ and $\sigma \notin V(P_o(s'))$. We shall first show that, for any string $s'' \in L(V/G)$ such that $\hat{P}_{o, A}^{V}(P_o(s'))=\hat{P}_{o, A}^{V}(P_o(s''))$, it holds that $s'' \in L(V_A/G)$. It is not difficult to see that $\hat{P}_{o, A}^{V}(P_o(s'))=\hat{P}_{o, A}^{V}(P_o(s''))$ implies $V(P_o(s'))=V(P_o(s''))$. Indeed, $\hat{P}_{o, A}^{V}(P_o(s'))=\hat{P}_{o, A}^{V}(P_o(s''))$ implies $last(\hat{P}_{o, A}^{V}(P_o(s')))=last(\hat{P}_{o, A}^{V}(P_o(s'')))$, where $last$ denotes the operation that computes the last element in a string, and by the definition of $\hat{P}_{o, A}^{V}$ we have \begin{center} $last(\hat{P}_{o, A}^{V}(P_o(s')))=(P_{o, A}(last(P_o(s'))), V(P_o(s')))$ and $last(\hat{P}_{o, A}^{V}(P_o(s'')))=(P_{o, A}(last(P_o(s''))), V(P_o(s'')))$ \end{center} Then, it follows that, for any string $s'' \in L(V/G)$ such that $\hat{P}_{o, A}^{V}(P_o(s'))=\hat{P}_{o, A}^{V}(P_o(s''))$ and $s''\sigma \in L(G)$, we have that $s''\sigma \in L(V_A/G)-L(V/A) \subseteq L_{dmg}$, since $\sigma \in A(\hat{P}_{o, A}^{V}(P_o(s''))) \subseteq V_A(P_o(s''))$ and $\sigma \notin V(P_o(s'))=V(P_o(s''))$. Suppose, on the contrary, that $s'' \notin L(V_A/G)$, then it must be the case that $s''=s_1\sigma's_2$ for some $s_1, s_2 \in \Sigma^*$ and $\sigma' \in \Sigma$ such that $s_1 \in L(V/G) \cap L(V_A/G)$ and $s_1\sigma' \in L(V/G)-L(V_A/G)$. Thus, we have $\sigma' \in V(P_o(s_1))$ and $\sigma' \notin V_A(P_o(s_1))=(V(P_o(s_1))-\Sigma_{c, A}) \cup A(\hat{P}_{o, A}^{V}(P_o(s_1)))$. It follows that we have $\sigma' \in V(P_o(s_1)) \cap \Sigma_{c, A}-A(\hat{P}_{o, A}^{V}(P_o(s_1))) \subseteq \Sigma_{c, A}$. By Assumption~\ref{assump: normalattack}, we have $\sigma'\in \Sigma_{c, A} \subseteq \Sigma_{o, A}$. It is immediate that $\hat{P}_{o, A}^{V}(P_o(s_1))$ is a strict prefix of $\hat{P}_{o, A}^{V}(P_o(s''))=\hat{P}_{o, A}^{V}(P_o(s'))$, since we have $s_1\sigma' \leq s''$ and $\sigma' \in \Sigma_{o, A}$. We conclude that the set $D=\{s_1' \in \Sigma^* \mid s_1'\leq s', \hat{P}_{o, A}^{V}(P_o(s_1'))=\hat{P}_{o, A}^{V}(P_o(s_1))\}$ is non-empty. Let $s^0_{1}$ be the longest string in $D$. Then, $\hat{P}_{o, A}^{V}(P_o(s^0_1))=\hat{P}_{o, A}^{V}(P_o(s_1))$ is a strict prefix of $\hat{P}_{o, A}^{V}(P_o(s'))$ and thus we must have $s^0_{1}<s'$. Let $s'=s^0_{1}\sigma''s^0_2$ for some $\sigma'' \in \Sigma$ and $s^0_2 \in \Sigma^*$. We first observe that $\sigma'' \in \Sigma_o$, since otherwise $s^0_1\sigma''$ would be another string in $D$ that is longer than $s^0_1$, contradicting to the supposition that $s^0_1$ is the longest string in $D$. Next, we can conclude that $\sigma'' \in \Sigma_{o, A}$. Otherwise, we have $\hat{P}_{o, A}^{V}(P_o(s^0_1))=\hat{P}_{o, A}^{V}(P_o(s_1))$ and $\hat{P}_{o, A}^{V}(P_o(s^0_1\sigma''))=\hat{P}_{o, A}^{V}(P_o(s^0_1))(\epsilon, V(P_o(s^0_1\sigma''))) \neq \hat{P}_{o, A}^{V}(P_o(s_1))(\sigma', V(P_o(s_1\sigma')))=\hat{P}_{o, A}^{V}(P_o(s_1\sigma'))$. This leads to a contradiction with $\hat{P}_{o, A}^{V}(P_o(s''))=\hat{P}_{o, A}^{V}(P_o(s'))$. Thus, for any $s'' \in L(V/G)$ such that $\hat{P}_{o, A}^{V}(P_o(s'))=\hat{P}_{o, A}^{V}(P_o(s''))$ and $s''\sigma \in L(G)$, we have $s''\sigma \in L_{dmg}$. Let $A': \hat{P}_{o, A}^{V}(P_o(L(V/G))) \rightarrow \Delta \Gamma$ be another actuator attacker on $(G, V)$ w.r.t. $(\Sigma_{c, A}, \Sigma_{o, A})$ that is defined as follows: \begin{enumerate} \item $A'(\hat{P}_{o, A}^{V}(P_o(s')))=(V(P_o(s')) \cap \Sigma_{c, A}) \cup \{\sigma\}$ \item for any $w \in P_o(L(V/G))$ such that $\hat{P}_{o, A}^{V}(w)\neq \hat{P}_{o, A}^{V}(P_o(s'))$, $A'(\hat{P}_{o, A}^{V}(w))=V(w) \cap \Sigma_{c, A}$. \end{enumerate} Intuitively, the attacker $A'$ performs no actual attack until it observes $\hat{P}_{o, A}^{V}(P_o(s'))$, at which point the attacker enables the disabled attackable event $\sigma \notin V(P_o(s'))$. It is immediate that $A'$ is a well-defined actuator attacker, since for any $w \in P_o(L(V/G))$ we have that $V(w)$ is the second component of $last(\hat{P}_{o, A}^{V}(w))$. That is, for any $w_1, w_2 \in P_o(L(V/G))$ such that $\hat{P}_{o, A}^{V}(w_1)=\hat{P}_{o, A}^{V}(w_2)$, we have $A'(\hat{P}_{o, A}^{V}(w_1))=A'(\hat{P}_{o, A}^{V}(w_2))$, for both Cases 1) and 2), since $V(w_1)=V(w_2)$. It is clear that $A'$ is enabling. In the rest, we show that $\varnothing \neq L(V_{A'}/G)-L(V/G) \subseteq L_{dmg}$, that is, $A'$ is a successful attacker on $(G, V)$ w.r.t. $(\Sigma_{c, A}, \Sigma_{o, A})$ and $L_{dmg}$. Since $A'$ is enabling, we have $L(V/G) \subseteq L(V_{A'}/G)$. Thus, $s' \in L(V/G) \subseteq L(V_{A'}/G)$. Since $\sigma \in A'(\hat{P}_{o, A}^{V}(P_o(s'))) \subseteq V_{A'}(P_o(s'))$ and $s'\sigma=s \in L(G)-L(V/G)$, we immediately have $s'\sigma \in L(V_{A'}/G)-L(V/G)$ and thus $L(V_{A'}/G)-L(V/G) \neq \varnothing$. Let $s''$ be any string in $L(V_{A'}/G)-L(V/G)$. By the definition of $L(V_{A'}/G)$ and Lemma~\ref{lemma: DOL}, we conclude that $s''=s_0\sigma_0$ for some $s_0 \in L(V/G)$ and some $\sigma_0 \in \Sigma_{c, A}$, where we have $\sigma_0 \notin V(P_o(s_0))$ and $\sigma_0 \in A'(\hat{P}_{o, A}^{V}(P_o(s_0))) \subseteq V_{A'}(P_o(s_0))$. Then, it follows that $V(P_o(s_0)) \neq V_{A'}(P_o(s_0))$ and $\sigma_0 \in V_{A'}(P_o(s_0))-V(P_o(s_0))$. And, from the definition of $A'$, we observe that, for any $w \in P_o(L(V/G))$, $V_{A'}(w) \neq V(w)$ only if\footnote{$V_{A'}(w)=(V(w)-\Sigma_{c, A}) \cup A'(\hat{P}_{o, A}^{V}(w)) \neq V(w)$ only if $A'(\hat{P}_{o, A}^{V}(w)) \neq V(w) \cap \Sigma_{c, A}$.} $V_{A'}(w)=V(w) \cup \{\sigma\}$ and $\hat{P}_{o, A}^{V}(w)=\hat{P}_{o, A}^{V}(P_o(s'))$. Thus, we can conclude that $V_{A'}(P_o(s_0))=V(P_o(s_0)) \cup \{\sigma\}$ and $\hat{P}_{o, A}^{V}(P_o(s_0))=\hat{P}_{o, A}^{V}(P_o(s'))$; the only possibility is $\sigma_0=\sigma$. Thus, we have that $s_0 \in L(V/G)$, $\hat{P}_{o, A}^{V}(P_o(s'))=\hat{P}_{o, A}^{V}(P_o(s_0))$ and $s_0\sigma=s'' \in L(G)$, which implies $s''=s_0\sigma \in L(V_A/G)-L(V/G) \subseteq L_{dmg}$. That is, we have shown that $L(V_{A'}/G)-L(V/G) \subseteq L_{dmg}$. \end{proof} With Lemma~\ref{lemma: NDS}, we have the following characterization for the existence of successful attackers in the case of normal supervisors. \begin{theorem} Let the plant $G$ and the normal supervisor $V$ be given. Then, there exists a successful attacker $A$ on $(G, V)$ w.r.t. $(\Sigma_{c, A}, \Sigma_{o, A})$ and $L_{dmg}$ iff there exists a string $s \in L(V/G)$ and an attackable event $\sigma \in \Sigma_{c, A}$, such that \begin{enumerate} \item $s\sigma \in L_{dmg}$, \item for any string $s' \in L(V/G)$, $\hat{P}_{o, A}^{V}(P_o(s))=\hat{P}_{o, A}^{V}(P_o(s'))$ and $s'\sigma \in L(G)$ together implies $s'\sigma \in L_{dmg}$. \end{enumerate} \end{theorem} \begin{proof} Suppose there exists an attacker $A$ on $(G, V)$ w.r.t. $(\Sigma_{c, A}, \Sigma_{o, A})$ such that $\varnothing \neq L(V_A/G)-L(V/G) \subseteq L_{dmg}$, that is, $A$ is a successful attacker on $(G, V)$ w.r.t. $(\Sigma_{c, A}, \Sigma_{o, A})$ and $L_{dmg}$. By Lemma~\ref{lemma: NDS}, we assume, without loss of generality, that $A$ is enabling. Let $s'' \in L(V_A/G)-L(V/G) \subseteq L_{dmg}$. By the definition of $L(V_A/G)$ and Lemma~\ref{lemma: DOL}, we know that $s''=s\sigma$ for some $s \in L(V/G)$. Since $s'' \notin L(V/G)$ and $s'' \in L(V_A/G)$, we have $\sigma \notin V(P_o(s))$ and $\sigma \in V_A(P_o(s))$; the only possibility is $\sigma \in A(\hat{P}_{o, A}^{V}(P_o(s)))$ and $\sigma \in \Sigma_{c, A}$. Since $A$ is enabling, we have $V_A(w) \supseteq V(w)$ and thus $L(V_A/G) \supseteq L(V/G)$. Thus, by the definition of $L(V_A/G)$ and Lemma~\ref{lemma: DOL}, the following statement holds. \begin{center} (*): For any string $s' \in L(V/G)$, if $\sigma \in V_A(P_o(s'))$ and $s'\sigma \in L(G)-L(V/G)$, then $s'\sigma \in L(V_A/G)-L(V/G)$. \end{center} On the other hand, for any string $s' \in L(V/G)$, if $\hat{P}_{o, A}^{V}(P_o(s))=\hat{P}_{o, A}^{V}(P_o(s'))$, then it holds that $A(\hat{P}_{o, A}^{V}(P_o(s)))=A(\hat{P}_{o, A}^{V}(P_o(s')))$ and $last(\hat{P}_{o, A}^{V}(P_o(s)))=last(\hat{P}_{o, A}^{V}(P_o(s')))$, which implies $V(P_o(s))=V(P_o(s'))$. Thus, for any string $s' \in L(V/G)$, if $\hat{P}_{o, A}^{V}(P_o(s))=\hat{P}_{o, A}^{V}(P_o(s'))$ and $s'\sigma \in L(G)$, then we have $s'\sigma \in L(G)-L(V/G)$, since $\sigma \notin V(P_o(s))=V(P_o(s'))$, and $\sigma \in A(\hat{P}_{o, A}^{V}(P_o(s)))=A(\hat{P}_{o, A}^{V}(P_o(s'))) \subseteq V_A(P_o(s'))$; it then follows from (*) that $s'\sigma \in L(V_A/G)-L(V/G) \subseteq L_{dmg}$, that is, $s'\sigma \in L_{dmg}$. Thus, we have shown that the left hand side implies the right hand side. \end{proof} \end{comment} \vspace{-10pt}
{'timestamp': '2021-03-23T01:11:54', 'yymm': '1904', 'arxiv_id': '1904.10159', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.10159'}
arxiv
\section{Introduction} \label{sec_introduction} Three major questions arise when considering a finite element method for the problem of Fluid-Structure Interactions (FSI): (1) what kind of meshes are used (interface fitted or unfitted); (2) how to couple the fluid-structure interactions (monolithic/fully-coupled or partitioned/segregated); (3) what variables are solved (velocity and/or displacement). Combinations of the answers to these questions lead to different types of numerical method. For example, \cite{Degroote_2009, K_ttler_2008} solve for fluid velocity and solid displacement sequentially (partitioned/segregated) using an Arbitrary Lagrangian-Eulerian (ALE) fitted mesh, whereas \cite{Heil_2004, Heil_2008, Muddle_2012} use an ALE fitted mesh to solve for fluid velocity and solid displacement simultaneously (monolithic/fully-coupled) with a Lagrange Multiplier to enforce the continuity of velocity/displacement on the interface. The Immersed Finite Element Method (IFEM) \cite{peskin2002immersed, Wang_2011, Wang_2009,Wang_2013,Zhang_2007,zhang2004immersed} and the Fictitious Domain Method (FDM) \cite{baaijens2001fictitious,Boffi_2016,Glowinski_2001,Hesch_2014,Kadapa_2016,Yu_2005} use two meshes to represent the fluid and solid separately. Although IFEM could be monolithic \cite{Boffi_2015}, the classical IFEM only solves for velocity, while the solid information is arranged on the right-hand side of the fluid equation as a prescribed force term. Conversely, although the FDM may be partitioned \cite{Yu_2005}, usually the FDM approach solves for both velocity in the whole domain (fluid plus solid) and displacement of the solid simultaneously via a distributed Lagrange multiplier (DLM) to enforce the consistency of velocity/displacement in the overlapped solid domain. In the case of one-field and monolithic numerical methods for FSI problems, \cite{Auricchio_2014} introduces a 1D model using a one-field FDM formulation based on two meshes, and \cite{Hecht_2017,Pironneau_2016} introduces an energy stable monolithic method (in 2D) based on one Eulerian mesh and discrete remeshing. In a previous study \cite{Wang_2017}, we present a one-field monolithic fictitious domain method (subsequently referred to as the one-field FDM) which has the following main features: (1) only one velocity field is solved in the whole domain, based upon the use of an appropriate $L^2$ projection; (2) the fluid and solid equations are solved monolithically. The primary purpose of this paper is to highlight the relationship between the one-field FDM and the IFEM family of methods: demonstrating that the former is in fact a new variant of the latter which possesses a number of practical advantages. Before describing these in detail however we briefly provide further context for the one-field FDM based on comparing its features with those of existing monolithic schemes. FDM/DLM methods \cite{baaijens2001fictitious,Boffi_2016,Glowinski_2001,Hesch_2014,Kadapa_2016,Yu_2005} solve the solid equation, but for a displacement field, and couple this displacement with the velocity of the fictitious fluid via a Lagrange multiplier. This leads to a large discrete linear algebra system. The one-field FDM solves a smaller discrete system since it rewrites the solid equation in terms of a velocity variable and couples the fictitious fluid through a finite element interpolation. Monolithic Eulerian methods \cite{Hecht_2017, Pironneau_2016} also express the solid equation in terms of velocity, and the fluid and solid are coupled naturally on an interface-fitted mesh. The one-field FDM also uses two meshes to represent the fluid and solid respectively. Consequently, before discretization in space, these two methods have many similarities, the advantage of the one-field FDM being that interface fitting is not required. As discussed above, the primary purpose of this paper is to demonstrate that the proposed one-field FDM is a particular linearization of the fully implicit IFEM. It is more robust than the classical explicit IFEM, and presents almost the same accuracy as the implicit IFEM. We will show: \begin{itemize} \item [(1)] The one-field FDM is based upon the implicit expression of the FSI force. This FSI force term is linearized using the velocity at the current configuration (instead of displacement at the reference configuration), which is an approximation of the fully implicit IFEM \cite{wang2006immersed, wang2007iterative, wang2009computational} but without requiring a nonlinear iteration at each time step. \item [(2)] In the simple case of equal density and viscosity for both fluid and solid, the only difference between the one-field FDM and the explicit IFEM (explicitly expressing the FSI force term) \cite{Wang_2011, Wang_2009,Wang_2013,Zhang_2007,zhang2004immersed} is that there are some terms of order $O(\Delta t)$ and $O(\Delta t^2)$ retained in the former. However these terms have a helpful stabilizing effect, which can allow the one-field FDM to use a time step that is significantly larger than the explicit IFEM, with almost the same accuracy. \item [(3)] The one-field FDM can naturally deal with the case of different densities and different viscosities in the fluid and solid. \end{itemize} The paper is organized as follows. The control equations and a general finite element weak formulation are introduced in Section \ref{control_equations} and \ref{weak_formulation} respectively, followed by a dimensionless weak formulation in Section \ref{dimensionless_weak} and time discretization in Section \ref{time_discretization}. Different types of IFEM approaches are then discussed in Section \ref{diferent_ifem}, and their relationship with the weak form of Section \ref{dimensionless_weak} is highlighted. An operator splitting scheme is introduced in Section \ref{splitting_scheme} followed by a comparison between the IFEM and one-field FDM approaches in Section \ref{ifem} and \ref{one_field_fdm}. Numerical examples are given in Section \ref{sec_numerical_exs}, and conclusions are presented in Section \ref{sec_conclusions}. \section{Control equations} \label{control_equations} In the following context, $\Omega_t^f\subset\mathbb{R}^d$ and $\Omega_t^s\subset\mathbb{R}^d$ with $d=2,3$ denote the fluid and solid domain respectively which are time dependent regions as shown in Figure \ref{fig1:Schematic diagram of FSI}. $\Omega=\Omega_t^f \cup \Omega_t^s $ is a fixed domain (with outer boundary $\Gamma$) and $\Gamma_t=\partial\Omega_t^f\cap\partial\Omega_t^s$ is the moving interface between fluid and solid. We denote by ${\bf X}$ the reference (material) coordinates of the solid, by ${\bf x}={\bf x}(\cdot,t)$ the current coordinates of the solid, and by ${\bf x}_0$ the initial coordinates of the solid. \begin{figure}[h!] \centering \includegraphics[width=2.5in,angle=0]{fig1} \caption {\scriptsize Schematic diagram of FSI, $\Omega=\Omega_t^f\cup \Omega_t^s$ and $\Gamma=\Gamma_D\cup \Gamma_N$.} \label{fig1:Schematic diagram of FSI} \end{figure} Let $\rho, \mu, {\bf u}, {\bm{\sigma}}$ and ${\bf g}$ denote the density, viscosity, velocity, stress tensor and acceleration due to gravity respectively. We assume both an incompressible fluid in $\Omega_t^f$ and incompressible solid in $\Omega_t^s$. The conservation of momentum and conservation of mass take the same form in the fluid and solid (just differing in the specific expressions of ${\bm\sigma}$): Momentum equation: \begin{equation} \label{momentum_equation} \rho\frac{d{\bf u}}{dt} =\nabla \cdot {\bm\sigma}+\rho{\bf g}, \end{equation} and continuity equation: \begin{equation} \label{continuity_equation} \nabla \cdot {\bf u}=0. \end{equation} An incompressible Newtonian constitutive equation in $\Omega_t^f$ can be expressed as: \begin{equation} \label{constitutive_fluid} {\bm\sigma}={\bm\sigma}^f={\bm\tau}^f-p^f{\bf I}, \end{equation} where ${\rm D}{\bf u}=\nabla {\bf u}+\nabla^{\scriptsize T} {\bf u}$, and \begin{equation} \label{constitutive_fluid_deviatoric} {\bm\tau}^f=\mu^f {\rm D}{\bf u}^f \end{equation} is the deviatoric part of stress ${\bm\sigma}^f$. In $\Omega_t^s$ we use an incompressible neo-Hookean solid with viscosity $\mu^s$ \cite{Boffi_2016,Yu_2005,baaijens2001fictitious} (see appendices for a brief discussion of other solid material models). The constitutive equation may be expressed as: \begin{equation} \label{constitutive_solid} {\bm\sigma}={\bm\sigma}^s={\bm\tau}^s-p^s{\bf I}, \end{equation} with \begin{equation} \label{constitutive_solid_deviatoric} {\bm\tau}^s=c_1\left({\bf F}{\bf F}^T-{\bf I}\right)+\mu^s{\rm D}{\bf u}^s \end{equation} being the deviatoric part of stress ${\bm\sigma}^s$, where \begin{equation}\label{definition_f} {\bf F} =\frac{\partial {\bf x}}{\partial {\bf X}} =\frac{\partial {\bf x}}{\partial {\bf x}_0} \frac{\partial {\bf x}_0}{\partial {\bf X}} =\nabla_0{\bf x}\nabla_{\bf X}{\bf x}_0 \end{equation} is the deformation tensor of the solid, and $c_1$ a solid material parameter. Finally the system is completed with the following boundary and initial conditions. Interface continuity conditions: \begin{equation}\label{interfaceBC1} {\bf u}^f={\bf u}^s\quad on \quad \Gamma_t \end{equation} and \begin{equation}\label{interfaceBC2} {\bm \sigma}^f{\bf n}^s= {\bm \sigma}^s{\bf n}^s\quad on \quad \Gamma_t. \end{equation} Dirichlet and Neumann boundary conditions: \begin{equation}\label{homogeneous_boundary} {\bf u}^f=\bar{\bf u}\quad on \quad \Gamma_D \end{equation} and \begin{equation}\label{Neumann} {\bm \sigma}^f{\bf n}^s= \bar{\bf h}\quad on \quad \Gamma_N, \end{equation} where $\Gamma=\Gamma_D\cup\Gamma_N$. Initial conditions: \begin{equation} \label{initialcd_fluid} \left. {\bf u}^f\right|_{t=0}={\bf u}_0^f \end{equation} and \begin{equation} \label{initialcd_solid} \left. {\bf u}^s\right|_{t=0}={\bf u}_0^s. \end{equation} \section{Weak formulation} \label{weak_formulation} In the following context, let $L^2(\omega)$ be the square integrable functions in domain $\omega$, endowed with norm $\left\|u\right\|_{0,\omega}^2=\int_\omega \left|u\right|^2$ ($u\in L^2(\omega)$). Let $H^1(\omega)=\left\{u:u, \nabla u\in L^2(\omega)\right\}$ with the norm denoted by $\left\|u\right\|_{1,\omega}^2=\left\|u\right\|_{0,\omega}^2+\left\|\nabla u\right\|_{0,\omega}^2$. We also denote by $H_0^1(\omega)$ the subspace of $H^1(\omega)$ whose functions have zero values on the Dirichlet boundary of $\omega$. Let $ {p}=\left \{ \begin{matrix} {{p}^f \quad in \quad \Omega_t^f} \\ {{p}^s \quad in \quad \Omega_t^s} \\ \end{matrix}\right. $. Given ${\bf v}\in H_0^1(\Omega)^d$, we perform the following symbolic operations: \begin{equation*} \begin{split} \int_{\Omega}{\rm Eq.}(\ref{momentum_equation})\left({\bm\sigma}\right)\cdot{\bf v} &\equiv \int_{\Omega_t^f}{\rm Eq.}(\ref{momentum_equation})\left({\bm\sigma}^f\right)\cdot{\bf v} +\int_{\Omega_t^s}{\rm Eq.}(\ref{momentum_equation})\left({\bm\sigma}^s\right)\cdot{\bf v}\\ &\equiv \int_{\Omega}{\rm Eq.}(\ref{momentum_equation})\left({\bm\sigma}^f\right)\cdot{\bf v} +\int_{\Omega_t^s}\left({\rm Eq.}(\ref{momentum_equation})\left({\bm\sigma}^s\right)-{\rm Eq.}(\ref{momentum_equation})\left({\bm\sigma}^f\right)\right)\cdot{\bf v}. \end{split} \end{equation*} Integrating the stress terms by parts, the above operations, using constitutive equation (\ref{constitutive_fluid}) and (\ref{constitutive_solid}) and interface condition (\ref{interfaceBC2}), give: \begin{equation}\label{operation1} \begin{split} &\rho^f\int_{\Omega}\frac{d{\bf u}}{dt} \cdot{\bf v} +\int_{\Omega}{\bm{\tau}^f}:\nabla{\bf v} -\int_{\Omega}p\nabla \cdot {\bf v} \\ +&\left(\rho^s-\rho^f\right)\int_{\Omega_t^s}\frac{d{\bf u}}{dt}\cdot{\bf v} +\int_{\Omega_t^s}\left({\bm{\tau}^s}-{\bm{\tau}^f}\right):\nabla{\bf v} \\ =&\int_{\Omega}\rho^f{\bf g}\cdot{\bf v} +\int_{\Omega_t^s}\left(\rho^s-\rho^f\right){\bf g}\cdot{\bf v} +\int_{\Gamma_N}\bar{\bf h}\cdot{\bf v}. \end{split} \end{equation} Note that the integrals on the interface $\Gamma_t$ are cancelled out using boundary condition (\ref{interfaceBC2}), because they are internal forces for the whole FSI system. Combining with the following symbolic operations for $q\in L^2(\Omega)$, $$ -\int_{\Omega_t^f}{\rm Eq.}(\ref{continuity_equation})q -\int_{\Omega_t^s}{\rm Eq.}(\ref{continuity_equation})q \equiv -\int_{\Omega}{\rm Eq.}(\ref{continuity_equation})q, $$ leads to the weak form of the FSI system as follows. Given ${\bf u}_0$ and $\Omega_0^s$, for each $t>0$ find ${\bf u}(t)\in H^1(\Omega)^d$, $p(t) \in L^2(\Omega)$ and $\Omega_t^s$, such that $\forall {\bf v}\in H_0^1(\Omega)^d$, $\forall q \in L^2(\Omega)$, the following two equations hold: \begin{equation}\label{weak_form1} \begin{split} &\rho^f\int_{\Omega}\frac{\partial{\bf u}}{\partial t} \cdot{\bf v} +\rho^f \int_{\Omega}\left({\bf u}\cdot\nabla\right){\bf u}\cdot{\bf v} +\frac{\mu^f}{2}\int_{\Omega}{\rm D}{\bf u}:{\rm D}{\bf v} -\int_{\Omega}p\nabla \cdot {\bf v} \\ +&\rho^{\delta}\int_{\Omega_t^s} \frac{\mathfrak{d}{\bf u}}{\mathfrak{d} t} \cdot{\bf v} +\frac{\mu^\delta}{2}\int_{\Omega_t^s}{\rm D}{\bf u}:{\rm D}{\bf v} +c_1\int_{\Omega_t^s}\left({{\bf F}{\bf F}^T-{\bf I}}\right):\nabla{\bf v} \\ =&\int_{\Omega}\rho^f{\bf g}\cdot{\bf v} +\int_{\Omega_t^s}\rho^\delta{\bf g}\cdot{\bf v} +\int_{\Gamma_N}\bar{\bf h}\cdot{\bf v}, \end{split} \end{equation} (where $\rho^\delta=\rho^s-\rho^f$ and $\mu^\delta=\mu^s-\mu^f$) and \begin{equation}\label{weak_form2} -\int_{\Omega} q\nabla \cdot {\bf u}=0. \end{equation} In equation (\ref{weak_form1}), $\frac{\mathfrak{d}}{\mathfrak{d}t}$ is the time derivative with respect to a frame moving with the solid velocity ${\bf u}^s=\left. {\bf u}\right|_{\Omega_t^s}$. \section{Dimensionless weak formulation} \label{dimensionless_weak} We may rewrite the weak form (\ref{weak_form1}) and (\ref{weak_form2}) in a dimensionless form by introducing the following scales \cite{Yu_2005}: $\tilde{L}$ for length, $\tilde{U}$ for velocity, $\tilde{L}/\tilde{U}$ for time and $\rho^f\tilde{U}^2$ for pressure $p$ and parameter $c_1$. Dividing by $\rho^f\tilde{U}^3/\tilde{L}$ on both sides of equation (\ref{weak_form1}), we have: \begin{equation}\label{weak_form1_dimensionless} \begin{split} &\int_{\Omega}\frac{\partial\tilde{\bf u}}{\partial \tilde {t}} \cdot\tilde{\bf v} +\int_{\Omega}\left(\tilde{\bf u}\cdot\nabla\right)\tilde{\bf u}\cdot\tilde{\bf v} +\frac{1}{2Re}\int_{\Omega}{\rm D}\tilde{\bf u}:{\rm D}\tilde{\bf v} -\int_{\Omega}\tilde{p}\nabla \cdot \tilde{\bf v} \\ +&\left(\rho^{r}-1\right)\int_{\Omega_t^s} \frac{\mathfrak{d}\tilde{\bf u}}{\mathfrak{d} \tilde{t}} \cdot\tilde{\bf v} +\frac{\mu^r-1}{2Re}\int_{\Omega_t^s}{\rm D}\tilde{\bf u}:{\rm D}\tilde{\bf v} +\tilde{c}_1\int_{\Omega_t^s}\left({{\bf F}{\bf F}^T-{\bf I}}\right):\nabla{\bf v} \\ =& Fr\int_{\Omega}\frac{{\bf g}}{|{\bf g}|}\cdot\tilde{\bf v} +Fr\left(\rho^r-1\right)\int_{\Omega_t^s}\frac{{\bf g}}{|{\bf g}|}\cdot\tilde{\bf v} +\int_{\Gamma_N}\tilde{\bf h}\cdot\tilde{\bf v}, \end{split} \end{equation} where $\tilde{\bf u}={\bf u}/\tilde{U}$, $\tilde{\bf v}={\bf v}/\tilde{U}$, $\tilde{p}=p/\rho^f\tilde{U}^2$, $\tilde{t}=t\tilde{U}/\tilde{L}$, $\tilde{\bf h}=\bar{\bf h}\tilde{L}/\rho^f\tilde{U}^2$ and the following parameters. \begin{itemize} \item Reynolds number: \begin{equation} Re=\rho^f\tilde{U}\tilde{L}/\mu^f. \end{equation} \item density ratio: \begin{equation} \rho^r=\rho^s/\rho^f. \end{equation} \item viscosity ratio: \begin{equation} \mu^r=\mu^s/\mu^f. \end{equation} \item material parameter: \begin{equation} \tilde{c}_1=c_1/\rho^f\tilde{U}^2. \end{equation} \item Froude number: \begin{equation}\label{froude} Fr=|{\bf g}|\tilde{L}/\tilde{U}^2. \end{equation} \end{itemize} The dimensionless form of equation (\ref{weak_form2}) is straightforward by dividing by $\rho^f\tilde{U}^3/\tilde{L}$: \begin{equation}\label{weak_form2_dimensionless} -\int_{\Omega} \tilde{q}\nabla \cdot \tilde{\bf u}=0, \end{equation} with $\tilde{q}=q/\rho^f\tilde{U}^2$. For the sake of notation convenience, we shall still use ${\bf u}$, ${\bf v}$, $p$ and $q$ instead of $\tilde{\bf u}$, $\tilde{\bf v}$, $\tilde{p}$ and $\tilde{q}$ in equation (\ref{weak_form1_dimensionless}) and (\ref{weak_form2_dimensionless}) in the following context. \section{Discretization in time} \label{time_discretization} Using the backward Euler method to discretize in time, equations (\ref{weak_form1_dimensionless}) and (\ref{weak_form2_dimensionless}) may be discretized as follows: Given ${\bf u}_n$, $p_n$ and $\Omega_n^s$, find ${\bf u}_{n+1}\in H^1(\Omega)^d$, $p_{n+1} \in L^2(\Omega)$ and $\Omega_{n+1}^s$, such that $\forall{\bf v}\in H_0^1\left(\Omega\right)^d$, $\forall q\in L^2(\Omega)$, the following two equations hold: \begin{equation}\label{weak_form1_time} \begin{split} &\int_{\Omega}\frac{{\bf u}_{n+1}-{\bf u}_n}{\Delta t} \cdot{\bf v} +\int_{\Omega}\left({\bf u}_{n+1}\cdot\nabla\right){\bf u}_{n+1}\cdot{\bf v} \\ +&\frac{1}{2Re}\int_{\Omega}{\rm D}{\bf u}_{n+1}:{\rm D}{\bf v} -\int_{\Omega}p_{n+1}\nabla \cdot {\bf v}\\ +&\left(\rho^{r}-1\right)\int_{\Omega_{n+1}^s}\frac{{\bf u}_{n+1}-{\bf u}_n}{\Delta t} \cdot{\bf v} +\frac{\mu^r-1}{2Re}\int_{\Omega_{n+1}^s}{\rm D}{\bf u}_{n+1}:{\rm D}{\bf v} \\ +& \tilde{c}_1\int_{\Omega_{n+1}^s}\left({{\bf F}{\bf F}^T-{\bf I}}\right):\nabla{\bf v} \\ =& Fr\int_{\Omega}\frac{{\bf g}}{|{\bf g}|}\cdot{\bf v} +Fr\left(\rho^r-1\right)\int_{\Omega_{n+1}^s}\frac{{\bf g}}{|{\bf g}|}\cdot{\bf v} +\int_{\Gamma_N}\tilde{\bf h}\cdot{\bf v}, \end{split} \end{equation} and \begin{equation}\label{weak_form2_time} -\int_{\Omega} q\nabla \cdot {\bf u}_{n+1}=0. \end{equation} \begin{remark} $\Omega_{n+1}^s$ is updated from $\Omega_n^s$ by the following formula: \begin{equation}\label{update_of_solid_mesh} \Omega_{n+1}^s=\left\{{\bf x}:{\bf x}={\bf x}_n+\Delta t{\bf u}_{n+1}, {\bf x}_n\in\Omega_n^s \right\}. \end{equation} \end{remark} \section{Implementations of different IFEM approaches} \label{diferent_ifem} Having introduced the weak formulation and time discretization in the previous sections, we now consider implementation details, and demonstrate that different choices lead to methods that correspond to existing IFEM schemes, as well as the proposed one-field FDM \cite{Wang_2017}. We can see from (\ref{weak_form1_time}) that the integrals are carried out over two different domains: the whole domain $\Omega$ and the moving solid domain $\Omega_{n+1}^s$. The IFEM methods compute these two types of integrals based on two different meshes, and use projection/distribution functions to transfer information between the two meshes \cite{baaijens2001fictitious,Boffi_2016,Glowinski_2001,Hesch_2014,Kadapa_2016,Yu_2005,Wang_2011, Wang_2009,Wang_2013,Zhang_2007,zhang2004immersed}. The one-field FDM also adopts two meshes, and uses the FEM interpolation function (also used in \cite{Wang_2009}) to transfer information between the two meshes. In the remainder of this section we focus on how different IFEM approaches fit within the framework of this weak formulation. The classical IFEM is introduced in \cite{zhang2004immersed, Zhang_2007}, in which all the solid integrals (in $\Omega_{n+1}^s$) are moved to the right-hand side of equation (\ref{weak_form1_time}) as a force term and evaluated at the previous time step as follows: \begin{equation}\label{weak_form_classical_ifem} \begin{split} &\int_{\Omega}\frac{{\bf u}_{n+1}-{\bf u}_n}{\Delta t} \cdot{\bf v} +\int_{\Omega}\left({\bf u}_{n+1}\cdot\nabla\right){\bf u}_{n+1}\cdot{\bf v} \\ +&\frac{1}{2Re}\int_{\Omega}{\rm D}{\bf u}_{n+1}:{\rm D}{\bf v} -\int_{\Omega}p_{n+1}\nabla \cdot {\bf v}\\ =&\left(1-\rho^{r}\right)\int_{\Omega_n^s}\frac{{\bf u}_{n}-{\bf u}_{n-1}}{\Delta t} \cdot{\bf v} -\boxed{\frac{\mu^r-1}{2Re}\int_{\Omega_n^s}{\rm D}{\bf u}_n:{\rm D}{\bf v}} \\ -& \tilde{c}_1\int_{\Omega_n^s}\left({{\bf F}_n{\bf F}_n^T-{\bf I}}\right):\nabla{\bf v} \\ +& Fr\int_{\Omega}\frac{{\bf g}}{|{\bf g}|}\cdot{\bf v} +Fr\left(\rho^r-1\right)\int_{\Omega_n^s}\frac{{\bf g}}{|{\bf g}|}\cdot{\bf v} +\int_{\Gamma_N}\tilde{\bf h}\cdot{\bf v}. \end{split} \end{equation} The above formulation differs from \cite{zhang2004immersed, Zhang_2007} only in the following respects: \begin{enumerate} \item [(1)]The boxed term in (\ref{weak_form_classical_ifem}) vanishes in \cite{zhang2004immersed, Zhang_2007} because the fluid stress within the solid domain is neglected (which is equivalent to setting $\mu^r=1$). \item [(2)] \cite{zhang2004immersed, Zhang_2007} use the stabilized equal-order finite element method to treat convection and pressure after discretization in space, while we shall use a splitting scheme to deal with convection and a stable mixed-order finite element space for the velocity and pressure. \item [(3)] The above formulation is expressed in a dimensionless form. \end{enumerate} However these differences are not the distinguishing features of IFEM, and do not influence any comparisons (in Section \ref{sec_numerical_exs} we show that our implementation of IFEM produces the same results as in the literature). The distinguishing feature of IFEM is its development from the Immersed Boundary Method (IBM) \cite{peskin2002immersed}: the solid information is based on the previous time step and arranged on the right-hand side of the fluid equation as a force term, which is computed on the solid mesh, distributed to the fluid mesh and then added to the fluid equation as an extra term. The IFEM formulation (\ref{weak_form_classical_ifem}) represents an explicit forcing strategy, which approximates the time derivative in the solid using values from the previous two time steps. Errors may be accumulated as time evolves in this case, and this may be observed in numerical tests (see, for example, Figures \ref{cavity_solid_deformation_parameter3} and \ref{cavity_solid_deformation_parameter4}). There is a semi-implicit formulation which introduces an indicator function $I({\bf x})$ to smear out the densities across the fluid-solid interface \cite{Wang_2011}. Based on this indicator function $I({\bf x})$ (see \cite{Wang_2011} for the definition), the formulation (\ref{weak_form_classical_ifem}) may be modified as follows: \begin{equation}\label{weak_form_classical_semi_ifem} \begin{split} &\left(1+\left(\rho^{r}-1\right)I\left(\bf x\right)\right)\int_{\Omega}\frac{{\bf u}_{n+1}-{\bf u}_n}{\Delta t} \cdot{\bf v} +\int_{\Omega}\left({\bf u}_{n+1}\cdot\nabla\right){\bf u}_{n+1}\cdot{\bf v} \\ +&\frac{1}{2Re}\int_{\Omega}{\rm D}{\bf u}_{n+1}:{\rm D}{\bf v} -\int_{\Omega}p_{n+1}\nabla \cdot {\bf v}\\ =&\frac{1-\mu^r}{2Re}\int_{\Omega_n^s}{\rm D}{\bf u}_n:{\rm D}{\bf v} -\tilde{c}_1\int_{\Omega_n^s}\left({{\bf F}_n{\bf F}_n^T-{\bf I}}\right):\nabla{\bf v} \\ +& Fr\int_{\Omega}\frac{{\bf g}}{|{\bf g}|}\cdot{\bf v} +Fr\left(\rho^r-1\right)\int_{\Omega_n^s}\frac{{\bf g}}{|{\bf g}|}\cdot{\bf v} +\int_{\Gamma_N}\tilde{\bf h}\cdot{\bf v}. \end{split} \end{equation} Furthermore, a fully implicit forcing strategy may also be considered as follows: \begin{equation}\label{weak_form_classical_implicit_ifem} \begin{split} &\int_{\Omega}\frac{{\bf u}_{n+1}-{\bf u}_n}{\Delta t} \cdot{\bf v} +\int_{\Omega}\left({\bf u}_{n+1}\cdot\nabla\right){\bf u}_{n+1}\cdot{\bf v} \\ +&\frac{1}{2Re}\int_{\Omega}{\rm D}{\bf u}_{n+1}:{\rm D}{\bf v} -\int_{\Omega}p_{n+1}\nabla \cdot {\bf v}\\ =&\left(1-\rho^{r}\right)\int_{\Omega_n^s}\frac{{\bf u}_{n+1}-{\bf u}_n}{\Delta t} \cdot{\bf v} -\frac{\mu^r-1}{2Re}\int_{\Omega_n^s}{\rm D}{\bf u}_{n+1}:{\rm D}{\bf v} \\ -& \tilde{c}_1\int_{\Omega_n^s}\left({{\bf F}_{n+1}{\bf F}_{n+1}^T-{\bf I}}\right):\nabla{\bf v} \\ +& Fr\int_{\Omega}\frac{{\bf g}}{|{\bf g}|}\cdot{\bf v} +Fr\left(\rho^r-1\right)\int_{\Omega_n^s}\frac{{\bf g}}{|{\bf g}|}\cdot{\bf v} +\int_{\Gamma_N}\tilde{\bf h}\cdot{\bf v}. \end{split} \end{equation} It can be seen that the force term on the right-hand side of above equation is computed using the velocity at the current time step, which then needs to be iteratively constructed. This idea of implicit forcing was first utilized in the immersed boundary method (IBM) \cite{newren2007unconditionally,newren2008comparison}, and then also adopted within IFEM in \cite{wang2006immersed, wang2007iterative, wang2009computational}, where a Newton-Krylov iterative procedure is used to solve this nonlinear system. In our implementation, for simplicity, we use fixed point iteration to demonstrate the implicit IFEM. The fixed point iteration generally converges more slowly than the Newton-Krylov method, however it is not our purpose to compare the efficiency of these two implicit forcing strategies. Instead we shall demonstrate that both the implicit IFEM (iterating at each time step) and the one-field FDM (which needs no iteration inside the time step) produce almost identical results. Based upon the above discussion, we next introduce an operator splitting scheme in Section \ref{splitting_scheme}. In Section \ref{ifem} we then present an explicit and an implicit forcing strategy for IFEM (corresponding to (\ref{weak_form_classical_ifem}) and (\ref{weak_form_classical_implicit_ifem}) respectively), and in Section \ref{one_field_fdm} the one-field FDM formulation is illustrated in detail with the proposed operator splitting scheme. \section{An operator splitting scheme} \label{splitting_scheme} The operator splitting scheme is introduced here in order to treat the non-linear convection term in the Navier-Stokes equation, and simplify the saddle-point problem, which is widely adopted to solve pure fluid equations \cite{Glowinski_2003, laval1990fractional}. The fluid-structure coupling process can still be designed either explicitly or implicitly inside the diffusion step (as discussed in Section \ref{ifem} and \ref{one_field_fdm}). In this article, we focus on studying the FSI coupling strategies rather than different methods to deal with the convection or saddle-point problem. \begin{itemize} \item[(1)] Convection step: \begin{equation}\label{convection_step} \int_{\Omega}\frac{{\bf u}_{n+1/3}-{\bf u}_n}{\Delta t} \cdot{\bf v} +\int_{\Omega}\left({\bf u}_{n+1/3}\cdot\nabla\right){\bf u}_{n+1/3}\cdot{\bf v} =0. \end{equation} \item[(2)] Diffusion step: \begin{equation}\label{diffusion} \begin{split} &\int_{\Omega}\frac{{\bf u}_{n+2/3}-{\bf u}_{n+1/3}}{\Delta t} \cdot{\bf v} +\frac{1}{2Re}\int_{\Omega}{\rm D}{\bf u}_{n+2/3}:{\rm D}{\bf v} \\ +&\left(\rho^{r}-1\right)\int_{\Omega_n^s}\frac{{\bf u}_{n+2/3}-{\bf u}_n}{\Delta t} \cdot{\bf v} +\frac{\mu^r-1}{2Re}\int_{\Omega_n^s}{\rm D}_n{\bf u}_{n+2/3}:{\rm D}_n{\bf v} \\ +& \tilde{c}_1\int_{\Omega_n^s}\left({{\bf F}_{n+2/3}{\bf F}_{n+2/3}^T-{\bf I}}\right):\nabla_n{\bf v} \\ =& Fr\int_{\Omega}\frac{{\bf g}}{|{\bf g}|}\cdot{\bf v} +Fr\left(\rho^r-1\right)\int_{\Omega_n^s}\frac{{\bf g}}{|{\bf g}|}\cdot{\bf v} +\int_{\Gamma_N}\tilde{\bf h}\cdot{\bf v}. \end{split} \end{equation} In the above, $\nabla_n(\cdot)=\frac{\partial(\cdot)}{\partial{\bf x}_n}$ and ${\rm D}_n=\nabla_n+\nabla_n^T$. \item[(3)] Pressure step: \begin{equation}\label{pressure1} \int_{\Omega}\frac{{\bf u}_{n+1}-{\bf u}_{n+2/3}}{\Delta t} \cdot{\bf v} -\int_{\Omega}p_{n+1}\nabla \cdot {\bf v} =0. \end{equation} and \begin{equation}\label{pressure2} -\int_{\Omega} q\nabla \cdot {\bf u}_{n+1}=0. \end{equation} \end{itemize} \begin{remark}\label{fraction_f} Notice that the variables ${\bf u}_{n+1/3}$ or ${\bf u}_{n+2/3}$ are just intermediate values, not the velocity at time $t=t_n+\frac{\Delta t}{3}$ or $t=t_n+\frac{2\Delta t}{3}$. The notation ${\bf F}_{n+1/3}$ or ${\bf F}_{n+2/3}$ is interpreted as follows: \begin{equation}\label{fraction_f_eq} {\bf F}_t=\frac{\partial {\bf x}_t}{\partial {\bf X}} =\nabla_{\bf X}\left({\bf x}_n+{\bf u}_t\Delta t\right), \end{equation} with $t=n+1/3$ or $n+2/3$. \end{remark} \begin{remark} Compared with the 2-step splitting scheme in our original paper \cite{Wang_2017}, this 3-step splitting scheme decouples the FSI problem and Stokes/saddle-point problem into two separate steps. The fluid and solid are coupled in the diffusion step, which may be effectively solved by the preconditioned Conjugate Gradient algorithm. The pressure step becomes a ``degenerate'' Stokes problem \cite{Glowinski_2003}, which can also be efficiently solved (readers may refer to \cite [Section 34] {Glowinski_2003} for more discussion). There are a variety of numerical methods to treat the convection equation (\ref{convection_step}), such as wave-like methods \cite{Glowinski_2003}, characteristic based schemes \cite{Glowinski_2003, Zienkiewic2014, Hecht_2017}, upwind schemes (including the Streamline Upwind Petrov Galerkin (SUPG) method) \cite{Glowinski_2003, Zienkiewic2014} or the Least-squares method \cite{Zienkiewic2014}. In our implementations we primarily use this latter approach. \end{remark} It can be seen that the fluid-structure interaction only occurs in the diffusion step (\ref{diffusion}) based upon this operator splitting scheme. In order to solve equation (\ref{diffusion}) the one-field FDM and IFEM use different strategies. In the following two sections we focus on this diffusion step, and present the differences between the one-field FDM, and IFEM strategies. \section{Explicit and implicit forcing} \label{ifem} For notational convenience let us define the following force term: \begin{equation}\label{force_fsi} \begin{split} \mathcal{F}_t^{FSI}=&\left(\rho^{r}-1\right)\int_{\Omega_n^s}\frac{{\bf u}_t-{\bf u}_n}{\Delta t} \cdot{\bf v} +\frac{\mu^r-1}{2Re}\int_{\Omega_n^s}{\rm D}_n{\bf u}_t:{\rm D}_n{\bf v} \\ +& \tilde{c}_1\int_{\Omega_n^s}\left({{\bf F}_t{\bf F}_t^T-{\bf I}}\right):\nabla_n{\bf v}, \end{split} \end{equation} where $t=n+1/3$ or $n+2/3$ as in Remark \ref{fraction_f}. Based upon the splitting scheme adopted here, we use ${\bf u}_{n+1/3}$, obtained from the previous convection step, to evaluate $\mathcal{F}_t^{FSI}$, and solve equation (\ref{diffusion}) as follows. \begin{itemize} \item Explicit forcing: \begin{equation}\label{diffusion_explicit} \begin{split} &\int_{\Omega}\frac{{\bf u}_{n+2/3}-{\bf u}_{n+1/3}}{\Delta t} \cdot{\bf v} +\frac{1}{2Re}\int_{\Omega}{\rm D}_n{\bf u}_{n+2/3}:{\rm D}_n{\bf v} \\ =& Fr\int_{\Omega}\frac{{\bf g}}{|{\bf g}|}\cdot{\bf v} +Fr\left(\rho^r-1\right)\int_{\Omega_n^s}\frac{{\bf g}}{|{\bf g}|}\cdot{\bf v} +\int_{\Gamma_N}\tilde{\bf h}\cdot{\bf v} -\boxed{\mathcal{F}_{n+1/3}^{FSI}}. \end{split} \end{equation} \end{itemize} As noted above, expression (\ref{diffusion_explicit}) corresponds to a formulation of the classical explicit IFEM. The implicit IFEM may be expressed in a similar form, based upon the splitting scheme, but using the current value ${\bf u}_{n+2/3}$ to construct $\mathcal{F}_{n+2/3}^{FSI}$. \begin{itemize} \item Implicit forcing: \begin{equation}\label{diffusion_implicit} \begin{split} &\int_{\Omega}\frac{{\bf u}_{n+2/3}-{\bf u}_{n+1/3}}{\Delta t} \cdot{\bf v} +\frac{1}{2Re}\int_{\Omega}{\rm D}_n{\bf u}_{n+2/3}:{\rm D}_n{\bf v} \\ =& Fr\int_{\Omega}\frac{{\bf g}}{|{\bf g}|}\cdot{\bf v} +Fr\left(\rho^r-1\right)\int_{\Omega_n^s}\frac{{\bf g}}{|{\bf g}|}\cdot{\bf v} +\int_{\Gamma_N}\tilde{\bf h}\cdot{\bf v} -\boxed{\mathcal{F}_{n+2/3}^{FSI}}. \end{split} \end{equation} \end{itemize} \section{One-field FDM} \label{one_field_fdm} It can be seen that the solid velocity is hidden in the nonlinear term ${\bf F}{\bf F}^T-{\bf I}$ in equation (\ref{weak_form1_time}) or (\ref{diffusion}). The difference between the one-field FDM and the explicit IFEM is how to treat this nonlinear term: the former extracts this hidden velocity by linearizing ${\bf F}{\bf F}^T-{\bf I}$ in the current configuration, while the latter evaluates this term as a force term on the right-hand side of the equation. In this section, we shall demonstrate how the nonlinear term ${\bf F}{\bf F}^T-{\bf I}$ is linearized in the one-field FDM, and expressed in terms of velocity in the current configuration. Also notice that this idea is not limited to the operator splitting. The splitting is just a specific implementation that allows us to express the IFEM and the one-field FDM in a similar form so as to facilitate direct comparison with each other. Denoting ${\bf F}_t{\bf F}_t^T-{\bf I}$ by ${\bf s}_t$, and according to the definition of {\bf F} (\ref{definition_f}), ${{\bf s}_t}$ may be computed as follows: \begin{equation} {{\bf s}_t} ={\bf F}_t{\bf F}_t^T-{\bf I} =\left(\nabla_{\bf X}{\bf x}_t\nabla_{\bf X}^T{\bf x}_t-{\bf I}\right). \end{equation} Using the chain rule, this last equation can also be expressed as: \begin{equation} {{\bf s}_t} =\nabla_n{\bf x}_t \nabla_{\bf X}{\bf x}_n \nabla_{\bf X}^T{\bf x}_n \nabla_n^T{\bf x}_t -{\bf I} +\nabla_n{\bf x}_t \nabla_n^T{\bf x}_t -\nabla_n{\bf x}_t \nabla_n^T{\bf x}_t \end{equation} or \begin{equation} {{\bf s}_t} =\nabla_n{\bf x}_t \nabla_n^T{\bf x}_t - {\bf I} +\nabla_n{\bf x}_t\left(\nabla_{\bf X}{\bf x}_n \nabla_{\bf X}^T{\bf x}_n-{\bf I}\right)\nabla_n^T{\bf x}_t. \end{equation} Then ${{\bf s}_t}$ can be expressed based on the previous coordinate ${\bf x}_n$ as follows: \begin{equation} {{\bf s}_t} =\nabla_n{\bf x}_t \nabla_n^T{\bf x}_t - {\bf I} +\nabla_n{\bf x}_t {{\bf s}_{n}} \nabla_n^T{\bf x}_t. \end{equation} Using ${\bf x}_t={\bf x}_n+\Delta t{\bf u}_t$ (see Remark \ref{fraction_f} (\ref{fraction_f_eq})), the last equation can finally be expressed as: \begin{equation}\label{solidstress} \begin{split} {{\bf s}_{t}} &=\Delta t\left(\nabla_n{\bf u}_{t}+\nabla_n^T{\bf u}_{t}+\Delta t\nabla_n{\bf u}_{t}\nabla_n^T{\bf u}_{t}\right) +{{\bf s}_n} \\ &+\Delta t^2\nabla_n{\bf u}_{t} {{\bf s}_n} \nabla_n^T{\bf u}_{t} +\Delta t\nabla_n{\bf u}_{t} {{\bf s}_n} +\Delta t {{\bf s}_n} \nabla_n^T{\bf u}_{t}. \end{split} \end{equation} There are two nonlinear terms in the last equation, which may be linearized as \begin{equation}\label{linearization1} \nabla_n{\bf u}_{t}\nabla_n^T{\bf u}_{t} =\nabla_n{\bf u}_{t}\nabla_n^T{\bf u}_n +\nabla_n{\bf u}_n\nabla_n^T{\bf u}_{t} -\nabla_n{\bf u}_n\nabla_n^T{\bf u}_n, \end{equation} and \begin{equation}\label{linearization2} \nabla_n{\bf u}_{t} {{\bf s}_n} \nabla_n^T{\bf u}_{t} =\nabla_n{\bf u}_{t} {{\bf s}_n} \nabla_n^T{\bf u}_n +\nabla_n{\bf u}_n {{\bf s}_n} \nabla_n^T{\bf u}_{t} -\nabla_n{\bf u}_n {{\bf s}_n} \nabla_n^T{\bf u}_n. \end{equation} Substituting ${\bf s}_{n+2/3}={{\bf F}_{n+2/3}{\bf F}_{n+2/3}^T-{\bf I}}$, using expression (\ref{solidstress}), (\ref{linearization1}) and (\ref{linearization2}), into diffusion step (\ref{diffusion}), we finally get the one-field FDM formulation as follows: \begin{equation}\label{diffusion_fdm} \begin{split} &\int_{\Omega}\frac{{\bf u}_{n+2/3}-{\bf u}_{n+1/3}}{\Delta t} \cdot{\bf v} +\frac{1}{2Re}\int_{\Omega}{\rm D}{\bf u}_{n+2/3}:{\rm D}{\bf v} \\ +&\left(\rho^{r}-1\right)\int_{\Omega_n^s}\frac{{\bf u}_{n+2/3}-{\bf u}_n}{\Delta t} \cdot{\bf v} +\frac{\mu^r-1}{2Re}\int_{\Omega_n^s}{\rm D}_n{\bf u}_{n+2/3}:{\rm D}_n{\bf v} \\ +& \boxed{\frac{\Delta t\tilde{c}_1}{2}\int_{\Omega_n^s}{\rm D}_n{\bf u}_{n+2/3}:{\rm D}_n{\bf v}} + \boxed{\Delta t\tilde{c}_1\int_{\Omega_n^s}{\rm D}_n^1{\bf u}_{n+2/3}:\nabla_n{\bf v}} \\ +& \boxed{\Delta t^2\tilde{c}_1\int_{\Omega_n^s}\left({\rm D}_n^2+{\rm D}_n^3\right){\bf u}_{n+2/3}:\nabla_n{\bf v}} \\ =& Fr\int_{\Omega}\frac{{\bf g}}{|{\bf g}|}\cdot{\bf v} +Fr\left(\rho^r-1\right)\int_{\Omega_n^s}\frac{{\bf g}}{|{\bf g}|}\cdot{\bf v} +\int_{\Gamma_N}\tilde{\bf h}\cdot{\bf v}\\ -& \tilde{c}_1\int_{\Omega_n^s}{\bf s}_n:\nabla_n{\bf v} + \boxed{\Delta t^2\tilde{c}_1\int_{\Omega_n^s}\left(\nabla_n{\bf u}_n\nabla_n^T{\bf u}_n\right):\nabla_n{\bf v}} \\ + & \boxed{\Delta t^2\tilde{c}_1\int_{\Omega_n^s}\left(\nabla_n{\bf u}_n {\bf s}_n \nabla_n^T{\bf u}_n\right):\nabla_n{\bf v}}. \end{split} \end{equation} In the above, the linear operators ${\rm D}_n^1$, ${\rm D}_n^2$ and ${\rm D}_n^3$ are defined as: \begin{equation} {\rm D}_n^1{\bf u}=\nabla_n{\bf u}{\bf s}_n+{\bf s}_n\nabla_n^T{\bf u}, \end{equation} \begin{equation} {\rm D}_n^2{\bf u}=\nabla_n{\bf u}\nabla_n^T{\bf u}_n+\nabla_n{\bf u}_n\nabla_n^T{\bf u}, \end{equation} and \begin{equation} {\rm D}_n^3{\bf u}=\nabla_n{\bf u}{\bf s}_n\nabla_n^T{\bf u}_n+\nabla_n{\bf u}_n{\bf s}_n\nabla_n^T{\bf u}. \end{equation} \begin{remark}\label{not_trivial_terms} When $\rho^r=\mu^r=1$, comparing equations (\ref{diffusion_explicit}) and (\ref{diffusion_fdm}), we see that the only difference between the one-field FDM and explicit IFEM is the additional boxed terms in equation (\ref{diffusion_fdm}) of $O(\Delta t)$ or $O(\Delta t^2)$ respectively. We shall demonstrate, with numerical tests, that these terms are not trivial at all: in fact they have a very positive stabilizing effect, such that a significantly larger time step may be adopted. \end{remark} \section{Numerical experiments} \label{sec_numerical_exs} Having analyzed the proposed one-field FDM, and illustrated its close relationship with the IFEM family of methods, in this section we focus on validation of the three advantages, as claimed in Section \ref{sec_introduction}, of the one-field FDM compared with IFEM. We shall use the Least-squares method to approximate the convection step \cite{Wang_2017}. For the diffusion step in which FSI interaction happens, we use the finite element isoparametric interpolation functions to transfer information between the solid mesh and fluid mesh for both the one-field FDM and IFEM. The finite element interpolation function is suggested to be capable of producing sharper interfaces than the traditional discretized Dirac delta function or the reproducing kernel function in \cite{Wang_2009}. The pressure step is a ``degenerate'' Stokes equation, and we shall use the standard $Taylor$-$Hood$ element to discretize this step. Gravity will not be considered in this paper, so the Froude number (\ref{froude}) will be zero ($Fr=0$) in each of the following tests. \subsection{Lid-driven cavity flow with a solid disc} This example is taken from papers \cite{Zhao_2008,Wang_2009}, in which IFEM approaches are adopted. A sketch of the problem and boundary conditions are shown in Figure \ref{Sketch_cavity}. We consider the parameter sets displayed in Table \ref{Parameter_sets_cavity}, and all the simulations use a sufficiently small time step to ensure stability: parameter set 1 (very soft solid) uses $\Delta t=1.0\times 10^{-3}$ and all other tests have a time step of $\Delta t=5.0\times 10^{-3}$. To illustrate the meshes that we use, velocity norms on the fluid mesh ($40\times 40$ biquadratic quadrilaterals) and solid mesh (1373 linear triangles with 771 nodes) for Parameter set 1 are presented in Figure \ref{cavity_v_fluid_solid}. \begin{figure}[h!] \centering \includegraphics[width=2.5in,angle=0]{fig2} \captionsetup{justification=centering} \caption {\scriptsize Computational domain and boundary conditions for the test problem of a lid-driven cavity flow with a solid disc.} \label{Sketch_cavity} \end{figure} \begin{figure}[h!] \begin{minipage}[t]{0.5\linewidth} \centering \includegraphics[width=2.2in,angle=0]{fig3a} \captionsetup{justification=centering} \caption* {\scriptsize (a) Velocity on fluid mesh.} \end{minipage} \begin{minipage}[t]{0.5\linewidth} \centering \includegraphics[width=2.0in,angle=0]{fig3b} \captionsetup{justification=centering} \caption* {\scriptsize (b) Velocity on solid mesh.} \end{minipage} \captionsetup{justification=centering} \caption {\scriptsize Distribution of the velocity norm for Parameter set 1 at $t=10$. The position of the solid in the cavity can be seen from Figure \ref{cavity_solid_deformation_mu1} (d). } \label{cavity_v_fluid_solid} \end{figure} \begin{table}[h!] \centering \begin{tabular}{|c|c|c|c|c|c|} \hline Parameter sets & $Re$ & $\tilde{c}_1$ & $\rho^r$ & $\mu^r$ \\ \hline Parameter 1 & $100$ & $0.1$ & $1$ & $1$ \\ \hline Parameter 2 & $100$ & $1$ & $1$ & $1$ \\ \hline Parameter 3 & $100$ & $1$ & $2$ & $1$ \\ \hline Parameter 4 & $100$ & $1$ & $0.5$ & $1$ \\ \hline Parameter 5 & $100$ & $1$ & $1$ & $1.5$ \\ \hline Parameter 6 & $100$ & $1$ & $1$ & $2$ \\ \hline Parameter 7 & $500$ & $0.5$ & $2$ & $2$ \\ \hline \end{tabular} \\ \captionsetup{justification=centering} \caption{Parameter sets for lid-driven cavity flow with a solid disc (the first parameter set is used in \cite{Zhao_2008,Wang_2009}).} \label{Parameter_sets_cavity} \end{table} For all these tests, we aim to run to $t=10$. However for the Parameter sets 3 to 5 ($\rho^r\ne 1$), our implementation of the implicit IFEM scheme cannot reach $t=10$. Therefore, in these cases, we show a comparison shortly before the IFEM breaks down. The following criterion is used to check whether the implicit IFEM converges. \begin{equation}\label{stop_criterion} error=\frac{\|{\bf u}_{k+1}-{\bf u}_{k}\|_{\Omega_n^s}}{\|{\bf u}_{k}\|_{\Omega_n^s}} < tol, \end{equation} where ${\bf u}_k$ and ${\bf u}_{k+1}$ are the iterative values of the last and current step respectively, and $tol=10^{-6}$ is the convergence tolerance used in our tests. \begin{figure}[h!] \begin{minipage}[t]{0.5\linewidth} \centering \includegraphics[width=2.2in,angle=0]{cavity_mu1_1} \captionsetup{justification=centering} \caption* {\scriptsize (a) $t=2.4$,} \end{minipage} \begin{minipage}[t]{0.5\linewidth} \centering \includegraphics[width=2.2in,angle=0]{cavity_mu1_2} \captionsetup{justification=centering} \caption* {\scriptsize (b) $t=4.7$,} \end{minipage} \begin{minipage}[t]{0.5\linewidth} \centering \includegraphics[width=2.2in,angle=0]{cavity_mu1_3} \captionsetup{justification=centering} \caption* {\scriptsize (c) $t=7.0$,} \end{minipage} \begin{minipage}[t]{0.5\linewidth} \centering \includegraphics[width=2.2in,angle=0]{cavity_mu1_4} \captionsetup{justification=centering} \caption* {\scriptsize (d) $t=10$.} \end{minipage} \captionsetup{justification=centering} \caption {\scriptsize Solid deformation for Parameter set 1. These results are identical to Fig. 10 in \cite{Wang_2009}. The figures show that the one-field FDM and the explicit IFEM present the same results in the case of $\rho^r=\mu^r=1$. The $l^2$ norm of velocity vectors on the solid mesh at $t=10$: $\|{\bf u}_{\rm IFEM}\|=4.80955$, $\|{\bf u}_{\rm FDM}\|=4.80087$ and $\|{\bf u}_{\rm IFEM}-{\bf u}_{\rm FDM}\|=0.07399$.} \label{cavity_solid_deformation_mu1} \end{figure} \begin{figure}[h!] \centering \includegraphics[width=5.0 in,angle=0]{cavity_mu2} \captionsetup{justification=centering} \caption {\scriptsize Solid deformation for Parameter set 2 at $t=10$. The $l^2$ norm of displacement vectors on the solid mesh: $\|{\bf d}_{\rm exIFEM}-{\bf d}_{\rm FDM}\|=0.13423$ and $\|{\bf d}_{\rm imIFEM}-{\bf d}_{\rm FDM}\|=0.12248$}. \label{cavity_solid_deformation_mu2} \end{figure} The first two parameter sets are simple cases because $\rho^r=\mu^r=1$. We can see from Figure \ref{cavity_solid_deformation_mu1} that the one-field FDM and the explicit IFEM present almost identical results in the case of a very soft solid ($\tilde{c}_1=0.1$), both of which are themselves indistinguishable from the published results in the literature \cite{Wang_2009}. Figure \ref{cavity_solid_deformation_mu2} shows the solid deformation for a slightly harder disc ($\tilde{c}_1=1$). Although the explicit IFEM, implicit IFEM and the one-field FDM present very similar results, a close look at the interface shape shows that the solution of the one-field FDM is almost identical to that of the implicit IFEM, and different from the explicit IFEM. \begin{figure}[h!] \centering \includegraphics[width=2.5 in,angle=0]{cavity_parameter3} \captionsetup{justification=centering} \caption {\scriptsize Solid deformation for Parameter set 3 at $t=4.4$.} \label{cavity_solid_deformation_parameter3} \end{figure} \begin{figure}[h!] \centering \includegraphics[width=4.0 in,angle=0]{cavity_parameter4} \captionsetup{justification=centering} \caption {\scriptsize Solid deformation for Parameter set 4 at $t=5.0$. The result of the one-field FDM is identical to the result of the implicit IFEM.} \label{cavity_solid_deformation_parameter4} \end{figure} The case of a larger solid density ($\rho^r=2$) and a smaller solid density ($\rho^r=0.5$) are tested by Parameter sets 3 and 4 respectively. Both results (Figures \ref{cavity_solid_deformation_parameter3} and \ref{cavity_solid_deformation_parameter4}) show that the one-field FDM and the fully converged implicit IFEM have almost the same accuracy. Furthermore, in neither IFEM case do the results converge up to $t=10$ when using the same time step as the one-field FDM: $\Delta t=5.0\times 10^{-3}$. The explicit IFEM uses velocities from the previous two time steps to compute the effect of the solid: it can be seen from Figure \ref{cavity_solid_deformation_parameter3} that the disc moves more slowly using this explicit IFEM. We also note that reducing the time step cannot solve the problem in this case, because the temporal term in the FSI force $\mathcal{F}_t^{FSI}$ (\ref{force_fsi}) becomes huge and has a negative effect on the stability. Figure \ref{cavity_solid_deformation_parameter4} demonstrates similar problems for the explicit IFEM, but the disc using the explicit IFEM moves faster than the one-field FDM or the implicit IFEM. \begin{figure}[h!] \centering \includegraphics[width=2.0 in,angle=0]{cavity_parameter5} \captionsetup{justification=centering} \caption {\scriptsize Solid deformation for Parameter set 5 at $t=4.2$. The result of the one-field FDM is identical to the result of the implicit IFEM.} \label{cavity_solid_deformation_parameter5} \end{figure} \begin{figure}[h!] \begin{minipage}[t]{0.5\linewidth} \centering \includegraphics[width=2.4in,angle=0]{cavity_v_fluid_t=5} \captionsetup{justification=centering} \caption* {\scriptsize (a) Velocity in the background domain.} \end{minipage} \begin{minipage}[t]{0.5\linewidth} \centering \includegraphics[width=2.0in,angle=0]{cavity_v_solid_t=5} \captionsetup{justification=centering} \caption* {\scriptsize (b) Velocity on the solid mesh.} \end{minipage} \captionsetup{justification=centering} \caption {\scriptsize Distribution of the velocity norm for Parameter set 6 at $t=5$, using the one-field FDM. The disc arrives at top of the cavity.} \label{cavity_v_t_5} \end{figure} \begin{figure}[h!] \begin{minipage}[t]{0.5\linewidth} \centering \includegraphics[width=2.4in,angle=0]{cavity_v_fluid_t=10} \captionsetup{justification=centering} \caption* {\scriptsize (a) Velocity in the background domain.} \end{minipage} \begin{minipage}[t]{0.5\linewidth} \centering \includegraphics[width=2.0in,angle=0]{cavity_v_solid_t=10} \captionsetup{justification=centering} \caption* {\scriptsize (b) Velocity on the solid mesh.} \end{minipage} \captionsetup{justification=centering} \caption {\scriptsize Distribution of the velocity norm for Parameter set 6 at $t=10$, using the one-field FDM.} \label{cavity_v_t_10} \end{figure} Parameter sets 5 ($\mu^r=1.5$) and 6 ($\mu^r=2$) are included to show the case of different viscosities between fluid and solid. It can be seen from Figure \ref{cavity_solid_deformation_parameter5} that the results of the one-field FDM and the implicit IFEM match very well. Using the selected time step, our IFEM implementations break down after the first few time steps when testing Parameter set 6, therefore we only show the results of the one-field FDM in Figures \ref{cavity_v_t_5} and \ref{cavity_v_t_10} (as future test cases for others to validate against). \begin{figure}[h!] \begin{minipage}[t]{0.5\linewidth} \centering \includegraphics[width=2.4in,angle=0]{cavity_v_fluid_t=74} \captionsetup{justification=centering} \caption* {\scriptsize (a) Velocity in the background domain.} \end{minipage} \begin{minipage}[t]{0.5\linewidth} \centering \includegraphics[width=2.0in,angle=0]{cavity_v_solid_t=74} \captionsetup{justification=centering} \caption* {\scriptsize (b) Velocity on solid mesh.} \end{minipage} \captionsetup{justification=centering} \caption {\scriptsize Distribution of the velocity norm for Parameter set 7 at $t=7.4$, using the one-field FDM. The disc arrives at top of the cavity.} \label{cavity_v_t_74} \end{figure} We purposely choose Parameter set 7 to be difficult, with large Reynolds number and differences in viscosity and density between fluid and solid. The one-field FDM can stably run up to $t=10$. We show the result in Figure \ref{cavity_v_t_74} when the solid disc arrives at the top of the cavity. \begin{remark} Notice that we have not considered the case of $\mu^r<1$, because we find that all the three methods (one-field FDM, explicit IFEM and implicit IFEM) may be unstable when $\Delta t\to 0$. However we shall not discuss this stability issue in more detail here as it is not the primary purpose of this paper. Please refer to \cite{Wang_2019,yongxing2018} for stability analysis. \end{remark} \subsection{Oscillating leaflet in a channel} \label{subsec_leaflet} This numerical example is taken from \cite{Yu_2005,baaijens2001fictitious,Kadapa_2016}. The computational domain is a channel of dimension $L\times H$, with a leaflet of dimension $h\times w$ initially located across the channel at its midpoint as shown in Figure \ref{leaflet_geometry}. A periodic flow condition is prescribed on the inlet and outlet boundaries, given by \begin{equation} \bar{u}_x=1.5y\left(2-y\right)sin\left(2\pi t/T\right),\quad \bar{u}_y=0, \end{equation} with $T$ being the dimensionless period of the input flow and equal to 10. In this test, $L=4$, $H=1$, $h=0.8$ and $w=0.0212$. \begin{figure}[h!] \centering \includegraphics[width=5in,angle=0]{leaflet_geometry} \captionsetup{justification=centering} \caption {\scriptsize Computational domain and boundary conditions for the oscillating leaflet.} \label{leaflet_geometry} \end{figure} The leaflet is approximated with 152 linear triangles with 116 nodes, and the fluid mesh is made up of $189\times47$ biquadratic squares with 36005 nodes. We extend parameters ($\rho^r=1$) used in the above three publications to two more general cases as shown in Table \ref{Parameter_sets_leaflet}. Using the first group of parameters, we demonstrate that the one-field FDM can use a time step of $\Delta t=5.0\times 10^{-3}$ while the explicit IFEM has to use a time step of $\Delta t=1.0\times 10^{-4}$ in order to remain stable (we reduce the time by a half over consecutive tests to check the convergence until finding a stable time step $\Delta t=7.8125\times 10^{-5}$, and then slightly increasing it we find $\Delta t=1.0\times 10^{-4}$ is also stable). However both simulations lead to almost identical results, as shown in Figure \ref{leaflet_defomration_parameter1}, which match the results of Fig. 3 in \cite{Yu_2005}. The reason for the difference in $\Delta t$ is due to the additional stabilizing terms added in the one-field FDM, as discussed in Remark \ref{not_trivial_terms}. Also notice that we have to use the same time step for both our implicit and explicit IFEM schemes in order to converge for this example, because of the huge forcing term on the right-hand side in equation (\ref{diffusion_explicit}) and (\ref{diffusion_implicit}). \begin{table}[h!] \centering \begin{tabular}{|c|c|c|c|c|} \hline Parameter sets & $Re$ & $\tilde{c}_1$ & $\rho^r$ & $\mu^r$ \\ \hline Parameter 1 & $100$ & $1000$ & $1$ & $1$ \\ \hline Parameter 2 & $100$ & $1000$ & $1.2$ & $1$ \\ \hline Parameter 3 & $300$ & $10000$ & $2$ & $2$ \\ \hline \end{tabular} \\ \captionsetup{justification=centering} \caption{Parameter sets for the oscillating leaflet in a channel.} \label{Parameter_sets_leaflet} \end{table} \begin{figure}[h!] \begin{minipage}[t]{0.5\linewidth} \centering \includegraphics[width=2.0in,angle=0]{leaflet_1} \captionsetup{justification=centering} \caption* {\scriptsize (a) $t/T=0.1$, $\|{\bf u}\|_r=8.62548\times 10^{-3}$}. \end{minipage} \begin{minipage}[t]{0.5\linewidth} \centering \includegraphics[width=2.3in,angle=0]{leaflet_2} \captionsetup{justification=centering} \caption* {\scriptsize (b) $t/T=0.2$, $\|{\bf u}\|_r=4.52988\times 10^{-2}$}. \end{minipage} \begin{minipage}[t]{0.5\linewidth} \centering \includegraphics[width=2.2in,angle=0]{leaflet_3} \captionsetup{justification=centering} \caption* {\scriptsize (c) $t/T=0.3$, $\|{\bf u}\|_r=4.12284\times 10^{-2}$} \end{minipage} \begin{minipage}[t]{0.5\linewidth} \centering \includegraphics[width=2.3in,angle=0]{leaflet_4} \captionsetup{justification=centering} \caption* {\scriptsize (d) $t/T=0.4$, $\|{\bf u}\|_r=1.03842\times 10^{-2}$}. \end{minipage} \captionsetup{justification=centering} \caption {\scriptsize Leaflet deformation at different times using Parameter set 1. Comparison between the one-field FDM and the explicit IFEM shows excellent agreement with \cite{Yu_2005}. Error measured by the $l^2$ norm of velocity difference: $\|{\bf u}\|_r=\|{\bf u}_{\rm FDM}-{\bf u}_{\rm IFEM}\| / \|{\bf u}_{\rm FDM}\|$.} \label{leaflet_defomration_parameter1} \end{figure} \begin{figure}[h!] \begin{minipage}[t]{0.5\linewidth} \includegraphics[width=2.0in,angle=0]{leaflet_5} \captionsetup{justification=centering} \caption* {\scriptsize (e) $t/T=0.5$, $\|{\bf u}\|_r=9.28756\times 10^{-3}$}. \end{minipage} \begin{minipage}[t]{0.5\linewidth} \centering \includegraphics[width=2.1in,angle=0]{leaflet_6} \captionsetup{justification=centering} \caption* {\scriptsize (f) $t/T=0.6$, $\|{\bf u}\|_r=3.03994\times 10^{-2}$}. \end{minipage} \begin{minipage}[t]{0.5\linewidth} \centering \includegraphics[width=2.3in,angle=0]{leaflet_7} \captionsetup{justification=centering} \caption* {\scriptsize (g) $t/T=0.7$, $\|{\bf u}\|_r=5.85640\times 10^{-2}$}. \end{minipage} \begin{minipage}[t]{0.5\linewidth} \centering \includegraphics[width=2.3in,angle=0]{leaflet_8} \captionsetup{justification=centering} \caption* {\scriptsize (h) $t/T=0.8$, $\|{\bf u}\|_r=2.54594\times 10^{-2}$}. \end{minipage} \captionsetup{justification=centering} \caption* {Figure \ref{leaflet_defomration_parameter1} (continued).} \end{figure} We then test a case with different density between fluid and solid: $\rho^r=1.2$. We use the same time step $\Delta t=1.0\times 10^{-4}$ for both the one-field FDM and the implicit IFEM, and their results, observed from Figure \ref{leaflet_defomration_parameter2}, are very close. The case of $\rho^r=2$ has also been tested, but our nonlinear implicit IFEM solver cannot converge at the first time step for any time step size. For completeness, we present the results using the proposed one-field FDM in Figures \ref{leaflet_defomration_parameter3_fliud} and \ref{leaflet_defomration_parameter3_solid}. \begin{figure}[h!] \begin{minipage}[t]{0.5\linewidth} \centering \includegraphics[width=2.1in,angle=0]{leaflet_p2_1} \captionsetup{justification=centering} \caption* {\scriptsize (a) $t/T=0.2$} \end{minipage} \begin{minipage}[t]{0.5\linewidth} \centering \includegraphics[width=2.0in,angle=0]{leaflet_p2_2} \captionsetup{justification=centering} \caption* {\scriptsize (b) $t/T=0.6$.} \end{minipage} \captionsetup{justification=centering} \caption {\scriptsize Deformation at the tip of the leaflet for Parameter set 2. Comparison is between the one-field FDM and implicit IFEM using the same time step $\Delta t=1.0\times 10^{-4}$.} \label{leaflet_defomration_parameter2} \end{figure} \begin{figure}[h!] \begin{minipage}[t]{1\linewidth} \centering \includegraphics[width=5in,angle=0]{leaflet_v_fluid_p3_1} \captionsetup{justification=centering} \caption* {\scriptsize (a) $t/T=0.1$} \end{minipage} \begin{minipage}[t]{1\linewidth} \centering \includegraphics[width=5in,angle=0]{leaflet_v_fluid_p3_3} \captionsetup{justification=centering} \caption* {\scriptsize (b) $t/T=0.3$.} \end{minipage} \begin{minipage}[t]{1\linewidth} \centering \includegraphics[width=5in,angle=0]{leaflet_v_fluid_p3_7} \captionsetup{justification=centering} \caption* {\scriptsize (c) $t/T=0.7$} \end{minipage} \begin{minipage}[t]{1\linewidth} \centering \includegraphics[width=5in,angle=0]{leaflet_v_fluid_p3_10} \captionsetup{justification=centering} \caption* {\scriptsize (d) $t/T=1.0$.} \end{minipage} \captionsetup{justification=centering} \caption {\scriptsize Velocity norm in the background domain for Parameter set 3 using the one-field FDM.} \label{leaflet_defomration_parameter3_fliud} \end{figure} \begin{figure}[h!] \begin{minipage}[t]{0.5\linewidth} \centering \includegraphics[width=2.2in,angle=0]{leaflet_v_solid_p3_1} \captionsetup{justification=centering} \caption* {\scriptsize (a) $t/T=0.1$} \end{minipage} \begin{minipage}[t]{0.5\linewidth} \centering \includegraphics[width=2.2in,angle=0]{leaflet_v_solid_p3_3} \captionsetup{justification=centering} \caption* {\scriptsize (b) $t/T=0.3$.} \end{minipage} \begin{minipage}[t]{0.5\linewidth} \centering \includegraphics[width=2.2in,angle=0]{leaflet_v_solid_p3_7} \captionsetup{justification=centering} \caption* {\scriptsize (c) $t/T=0.7$} \end{minipage} \begin{minipage}[t]{0.5\linewidth} \centering \includegraphics[width=2.2in,angle=0]{leaflet_v_solid_p3_10} \captionsetup{justification=centering} \caption* {\scriptsize (d) $t/T=1.0$.} \end{minipage} \captionsetup{justification=centering} \caption {\scriptsize Leaflet deformation at different times for Parameter set 3 using the one-field FDM.} \label{leaflet_defomration_parameter3_solid} \end{figure} \section{Conclusions} \label{sec_conclusions} In this article we have illustrated the relationship between the recently proposed one-field FDM and both the explicit (explicitly expressing the force term) and implicit (implicitly expressing the force term) IFEM. This is facilitated through the use of a particular operator splitting scheme. Furthermore, we show that the one-field FDM produces the same accuracy of results as the implicit IFEM, but requires no iteration, whilst it significantly improves upon the classical IFEM at very little additional computational complexity. The one-field FDM is shown to naturally deal with the case of different densities and/or viscosities of the fluid and solid. Therefore, whilst we may view the scheme of \cite{Wang_2017} as a fictitious domain method, it is also legitimate to consider it to be an alternative, highly efficient and robust, approximate solution strategy for the fully implicit IFEM methods of \cite{wang2006immersed, wang2007iterative, wang2009computational}. Even in the simple case of the same density and viscosity, where the explicit IFEM is known to be successful, we find that the additional terms added in the formulation of the one-field FDM have a helpful stabilizing effect, such that a larger time step can be adopted compared with the explicit IFEM.
{'timestamp': '2019-04-24T02:01:26', 'yymm': '1904', 'arxiv_id': '1904.10027', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.10027'}
arxiv
\section{Introduction} \begin{figure}[t] \setlength{\abovecaptionskip}{-0.2cm} \begin{center} \includegraphics[width=1\linewidth]{figure_1.pdf} \end{center} \caption{Understanding group activity in multi-person scene requires accurately determining relevant relation between actors. Our model learns to represent the scene by actor relation graph, and performs reasoning about group activity (``left spike" in the illustrated example) according to the graph structure and nodes features. Each node denotes an actor, and each edge represents the relation between two actors} \vspace{-4mm} \label{fig:figure_1} \end{figure} Group activity recognition is an important problem in video understanding~\cite{WangL0G18,SimonyanZ14,TranBFTP15,gan2015devnet} and has many practical applications, such as surveillance, sports video analysis, and social behavior understanding. To understand the scene of multiple persons, the model needs to not only describe the individual action of each actor in the context, but also infer their collective activity. The ability to accurately capture relevant relation between actors and perform relational reasoning is crucial for understanding group activity of multiple people~\cite{cite_a_12, cite_a_10, cite_d_1, cite_a_17, cite_a_18, cite_a_5, cite_a_2, cite_a_7}. However, modeling the relation between actors is challenging, as we only have access to individual action labels and collective activity labels, without knowledge of the underlying interaction information. It is expected to infer relation between actors from other aspects such as {\em appearance similarity} and {\em relative location}. Therefore, it is required to model these two important cues when we design effective deep models for group activity understanding. Recent deep learning methods have shown promising results for group activity recognition in videos~\cite{cite_a_1,cite_a_2,cite_a_4,cite_a_5,cite_a_6,cite_a_7,cite_a_17,cite_a_18}. Typically, these methods follow a two-stage recognition pipeline. First, the person-level features are extracted by a convolutional neural network (CNN). Then, a global module is designed to aggregate these person-level representations to yield a scene-level feature. Existing methods model the relation between these actors with an inflexible graphical model~\cite{cite_a_17}, whose structure is manually specified in advance, or using complex yet unintuitive message passing mechanism~\cite{cite_a_5,cite_a_18}. To capture temporal dynamics, a recurrent neural network (RNN) is usually used to model temporal evolution of densely sampled frames~\cite{cite_a_1,cite_a_2}. These models are generally expensive at computational cost and sometimes lack the flexibility dealing with group activity variation. In this work, we address the problem of capturing appearance and position relation between actors for group activity recognition. Our basic aim is to model actor relation in a more flexible and efficient way, where the graphical connection between actors could be automatically learned from video data, and inference for group activity recognition could be efficiently performed. Specifically, we propose to model the actor-actor relation by building a {\em Actor Relation Graph} (ARG), illustrated in Figure~\ref{fig:figure_1}, where the node in the graph denotes the actor's features, and the edge represents the relation between two actors. The ARG could be easily placed on top of any existing 2D CNN to form a unified group activity recognition framework. Thanks to the operation of graph convolution~\cite{cite_g_10}, the connections in ARG can be automatically optimized in an end-to-end manner. Thus, our model can discover and learn the potential relations among actors in a more flexible way. Once trained, our network can not only recognize individual actions and collective activity of a multi-person scene, but also on-the-fly generate the video-specific actor relation graph, facilitating further insights for group activity understanding. To further improve the efficiency of ARG for long-range temporal modeling in videos, we come up with two techniques to sparsify the connections in ARG. Specifically, in spatial domain, we design a {\em localized} ARG by forcing the connection between actors to be only in a local neighborhood. For temporal information, we observe that slowness is naturally video prior, where frames are densely captured but semantics varies very slow. Instead of connecting any pair frame, we propose a {\em randomized} ARG by randomly dropping several frames and only keeping a few. This random dropping operation is able to not only greatly improve the modeling efficiency but also largely increase the diversity of training samples, reducing the overfitting risk of ARG. In experiment, to fully utilize visual content, we empirically study different methods to compute pair-wise relation from the actor appearance features. Then we introduce constructing multiple relation graphs on an actors set to enable the model to focus on more diverse relation information among actors. We report performance on two group activity recognition benchmarks: the Volleyball dataset~\cite{cite_d_2} and the Collective Activity dataset~\cite{cite_d_1}. Our experimental results demonstrate that our ARG is able to obtain superior performance to the existing state-of-the-art approaches. The major contribution of this paper is summarized as follows: \begin{itemize} \item We construct flexible and efficient actor relation graphs to simultaneously capture the appearance and position relation between actors for group activity recognition. It provides an interpretable mechanism to explicitly model the relevant relations among people in the scene, and thus the capability of discriminating different group activities. \item We introduce an efficient inference scheme over the actor relation graphs by applying the GCN with sparse temporal sampling strategy. The proposed network is able to conduct relational reasoning over actor interactions for the purpose of group activity recognition. \item The proposed approach achieves the state-of-the-art results on two challenging benchmarks: the Volleyball dataset~\cite{cite_d_2} and the Collective Activity dataset~\cite{cite_d_1}. Visualizations of the learned actor graphs and relation features show that our approach has the ability to attend to the relation information for group activity recognition. \end{itemize} \begin{figure*}[t] \setlength{\abovecaptionskip}{-0.2cm} \begin{center} \includegraphics[width=1.0\linewidth]{figure_2.pdf} \end{center} \caption{An overview of our network framework for group activity recognition. We first extract feature vectors of actors from sampled video frames. We use a $d$-dimension vector to represent an actor bounding box. And the total number of bounding boxes in sampled frames equals $N$. Multiple actor relation graphs are built to capture relation information among actors. Afterwards, Graph Convolutional Networks are used to perform relational reasoning on graphs. The outputs of all graphs are then fused to produce the relational feature vectors of actors. Finally, original feature and relational feature are aggregated and fed into classifiers of group activity and individual action. } \label{fig:figure_2} \end{figure*} \section{Related Work} {\bf Group activity recognition.} Group activity recognition has been extensively studied from the research community. The earlier approaches are mostly based on a combination of hand-crafted visual features with probability graphical models~\cite{cite_a_10,cite_a_11,cite_a_12,cite_a_13,cite_a_15,cite_a_16,cite_a_19} or AND-OR grammar models~\cite{cite_a_9,cite_a_14}. Recently, the wide adoption of deep convolutional neural networks (CNNs) has demonstrated significant performance improvements on group activity recognition~\cite{cite_a_1,cite_a_2,cite_a_3,cite_a_4,cite_a_5,cite_a_6,cite_a_7,cite_a_17,cite_a_18}. Ibrahim \etal ~\cite{cite_a_2} designed a two-stage deep temporal model, which builds a LSTM model to represent action dynamics of individual people and another LSTM model to aggregate person-level information. Bagautdinov \etal ~\cite{cite_a_1} presented a unified framework for joint detection and activity recognition of multiple people. Ibrahim \etal ~\cite{cite_a_17} proposed a hierarchical relational network that builds a relational representation for each person. There are also efforts that explore modeling the scene context via structured recurrent neural networks ~\cite{cite_a_5,cite_a_7,cite_a_18} or generating captions ~\cite{cite_a_6}. Our work differs from these approaches in that it explicitly models the interactions information via building flexible and interpretable ARG. Moreover, instead of using RNN for information fusion, we employ GCN with sparse temporal sampling strategy which enables relational reasoning in an efficient manner. {\bf Visual relation.} Modeling or learning relation between objects or entities is an important problem in computer vision~\cite{cite_r_6,cite_r_7,cite_r_8,cite_r_9,Wang0T16}. Several recent works focus on detecting and recognizing human-object interactions (HOI)~\cite{cite_r_10,cite_r_11,cite_r_12,cite_r_13,cite_r_15}, which usually requires additional annotations of interactions. In scene understanding, a lot of efforts have been made on modeling pair-wise relationships for scene graph generation~\cite{cite_r_1,cite_r_2,cite_r_3,cite_r_4,cite_r_5,cite_g_16}. Santoro \etal ~\cite{cite_r_16} proposed a relation network module for relational reasoning between objects, which achieves super-human performance in visual question answering. Hu \etal ~\cite{cite_r_17} applied an object relation module to object detection, and verified the efficacy of modeling object relations in CNN based detection. Besides, many works showed that modeling interactions information can help action recognition~\cite{cite_r_18,cite_r_19,cite_r_20,cite_r_21,cite_r_22}. We show that explicitly exploiting the relation information can achieve significant gain on group activity recognition accuracy. {\bf Neural networks on graphs.} Recently, integrating graphical models with deep neural networks is an emerging topic in deep learning research. A considerable amount of models has arisen for reasoning on graph-structured data at various tasks, such as classification of graphs ~\cite{cite_g_5,cite_g_6,cite_g_7,cite_g_8,cite_g_9}, classification of nodes in graphs ~\cite{cite_g_10,cite_g_11,cite_g_12}, and modeling multi-agent interacting physical systems ~\cite{cite_g_1,cite_g_2,cite_g_3,cite_g_13}. In our work, we apply the Graph Convolutional Network (GCN)~\cite{cite_g_10} which was originally proposed for semi-supervised learning on the problem of classifying nodes in a graph. There are also applications of GCNs to single-human action recognition problems~\cite{cite_g_14,cite_g_15}. However, it would be inefficient to compute all pair-wise relation across all video-frame to build video as a fully-connected graph. Therefore, we build multi-person scene as a sparse graph according to relative location. Meanwhile, we propose to combine GCN with sparse temporal sampling strategy~\cite{cite_o_1} for more efficient learning. \section{Approach} Our goal is to recognize group activity in multi-person scene by explicitly exploiting relation information. To this end, we build {\em Actor Relation Graph} (ARG) to represent multi-person scene, and perform relational reasoning on it for group activity recognition. In this section, we will give detailed descriptions of our approach. First, we present an overview of our framework. Then, we introduce how to build ARG. Finally, we describe the efficient training and inference algorithms for ARG. \subsection{Group Activity Recognition Framework} \label{section:Framework} The overall network framework is illustrated in Figure~\ref{fig:figure_2}. Given a video sequence and the bounding boxes of the actors in the scene, our framework takes three key steps. First, we uniformly sample a set of $K$ frames from the video and extract feature vectors of actors from sampled frames. We follow the feature extraction strategy used in~\cite{cite_a_1}, which adopts Inception-v3~\cite{cite_o_4} to extract a multi-scale feature map for each frame. Besides that, we also have conducted experiments on other backbone models to verify the generality and effectiveness of our approach. We apply RoIAlign~\cite{cite_o_3} to extract the features for each actor bounding box from the frame feature map. After that, a fc layer is performed on the aligned features to get a $d$ dimensional appearance feature vector for each actor. The total number of bounding boxes in $K$ frames is denoted as $N$. We use a $ N \times d$ matrix $\mathbf{X}$ to represent feature vectors of actors. Afterwards, upon these original features of actors, we build actor relation graphs, where each node denotes an actor. Each edge in the graphs is a scalar weight, which is computed according to two actors' appearance features and their relative location. To represent diverse relation information, we construct multiple relation graphs from a same set of actors features. Finally, we perform learning and inference to recognize individual actions and group activity. We apply the GCN to conduct relational reasoning based on ARG. After graph convolution, the ARGs are fused together to generate relational representation for actors, which is also in $N \times d$ dimension. Then two classifiers respectively for recognizing individual actions and group activity will be applied on the pooled actors' relational representation and the original representation. We apply a fully connected layer on individual representation for individual action classification. The actor representations are maxpooled together to generate scene-level representation, which is used for group activity classification through another fully connected layer. \subsection{Building Actor Relation Graphs} \label{section:Graph} As mentioned above, ARG is the key component in our framework. We utilize the graph structure to explicitly model pair-wise relation information for group activity understanding. Our design is inspired by the recent success of relational reasoning and graph neural networks~\cite{cite_r_16,cite_g_10}. {\bf Graph definition.} Formally, the nodes in our graph correspond to a set of actors $A=\{(\mathbf{x}_i^a,\mathbf{x}_i^s)|i=1,\cdots,N\}$, where $N$ is the number of actors, $\mathbf{x}_i^a \in \mathbb{R}^{d}$ is actor $i$'s appearance feature, and and $\mathbf{x}_i^s=(t_i^x,t_i^y)$ is the center coordinates of actor $i$'s bounding box. We construct graph $\mathbf{G} \in \mathbb{R}^{N \times N}$ to represent pair-wise relation among actors, where relation value $\mathbf{G}_{ij}$ indicates the importance of actor $j$'s feature to actor $i$. In order to obtain sufficient representational power to capture underlying relation between two actors, both appearance features and position information need to be considered. Moreover, we note that appearance relation and position relation have different semantic attributes. To this end, we model the appearance relation and position relation in a separate and explicit way. The relation value is defined as a composite function below: \begin{equation} \mathbf{G}_{ij}=h\left( f_a(\mathbf{x}_i^a,\mathbf{x}_j^a),f_s(\mathbf{x}_i^s,\mathbf{x}_j^s) \right) , \label{eq:graph} \end{equation} where $f_a(\mathbf{x}_i^a,\mathbf{x}_j^a)$ denotes the appearance relation between two actors, and the position relation is computed by $f_s(\mathbf{x}_i^s,\mathbf{x}_j^s)$. The function $h$ fuses appearance and position relation to a scalar weight. In our experiments, we adopt the following function to compute relation value: \begin{equation} \mathbf{G}_{ij}=\frac{ f_s(\mathbf{x}_i^s,\mathbf{x}_j^s) ~ \mathrm{exp} \left( f_a(\mathbf{x}_i^a,\mathbf{x}_j^a) \right) }{ \sum_{j=1}^N f_s(\mathbf{x}_i^s,\mathbf{x}_j^s) ~ \mathrm{exp} \left( f_a(\mathbf{x}_i^a,\mathbf{x}_j^a) \right) } , \label{eq:graph_softmax} \end{equation} where we perform normalization on each actor node using softmax function so that the sum of all the relation values of one actor node $i$ will be $1$. {\bf Appearance relation.} Here we discuss different choices for computing appearance relation value between actors: \begin{enumerate} [fullwidth, itemindent=1.2em, nosep, label=(\arabic*)] \item {\em Dot-Product}: The dot-product similarity of appearance features can be considered as a simple form of relation value. It is computed as: \begin{equation} f_a(\mathbf{x}_i^a,\mathbf{x}_j^a)=\frac{(\mathbf{x}_i^a)^\mathrm{T} \mathbf{x}_j^a}{ \sqrt{d} }, \end{equation} where $\sqrt{d}$ acts as a normalization factor. \item {\em Embedded Dot-Product}: Inspired by the Scaled Dot-Product Attention mechanism~\cite{cite_s_1}, we can extend the dot-product operation to compute similarity in an embedding space, and the corresponding function can be expressed as: \begin{equation} f_a(\mathbf{x}_i^a,\mathbf{x}_j^a)=\frac{\theta(\mathbf{x}_i^a)^\mathrm{T}\phi(\mathbf{x}_j^a)}{\sqrt{d_k}}, \label{eq:embedded_dot_product} \end{equation} where $\theta(\mathbf{x}_i^a)=\mathbf{W}_\theta \mathbf{x}_i^a+\mathbf{b}_\theta$ and $\phi(\mathbf{x}_j^a)=\mathbf{W}_\phi \mathbf{x}_j^a+\mathbf{b}_\phi$ are two learnable linear transformations. $\mathbf{W}_\theta \in \mathbb{R}^{d_k \times d}$ and $\mathbf{W}_\phi \in \mathbb{R}^{d_k \times d}$ are weight matrices, $\mathbf{b}_\theta \in \mathbb{R}^{d_k}$ and $\mathbf{b}_\phi \in \mathbb{R}^{d_k}$ are weight vectors. By learnable transformations of original features, we can learn the relation value between two actors in a subspace. \item {\em Relation Network}: We also evaluate the Relation Network module proposed in~\cite{cite_r_16}. It can be written as: \begin{equation} f_a(\mathbf{x}_i^a,\mathbf{x}_j^a)=\mathrm{ReLU} \left( \mathbf{W}[\theta(\mathbf{x}_i^a), \phi(\mathbf{x}_j^a)]+\mathbf{b} \right) , \end{equation} where $[ \cdot,\cdot ]$ is the concatenation operation and $\mathbf{W}$ and $\mathbf{b}$ are learnable weights that project the concatenated vector to a scalar, followed by a ReLU non-linearity. \end{enumerate} {\bf Position relation.} In order to add spatial structural information to actor graph, the position relation between actors needs to be considered. To this end, we investigate two approaches to use spatial features in our work: \begin{enumerate} [fullwidth, itemindent=1.2em, nosep, label=(\arabic*)] \item {\em Distance Mask}: Generally, signals from local entities are more important than the signals from distant entities. And the relation information in the local scope has more significance than global relation for modeling the group activity. Based on these observations, we can set $\mathbf{G}_{ij}$ as zero for two actors whose distance is above a certain threshold. We call the resulted ARG as {\em localized ARG}. The $f_s$ is formed as: \begin{equation} f_s(\mathbf{x}_i^s,\mathbf{x}_j^s)=\mathbb{I} \left( d(\mathbf{x}_i^s,\mathbf{x}_j^s) \leq \mu \right) , \end{equation} where $\mathbb{I}(\cdot)$ is the indicator function, $d(\mathbf{x}_i^s,\mathbf{x}_j^s)$ denotes the Euclidean distance between center points of two actors' bounding boxes, and $\mu$ acts as a distance threshold which is a hyper-parameter. \item {\em Distance Encoding}: Alternatively, we can use the recent approaches~\cite{cite_s_1} for learning position relation. Specifically, the position relation value is computed as \begin{equation} f_s(\mathbf{x}_i^s,\mathbf{x}_j^s)=\mathrm{ReLU} \left( \mathbf{W}_{s}\mathcal{E}(\mathbf{x}_i^s,\mathbf{x}_j^s)+\mathbf{b}_s \right) , \end{equation} the relative distance between two actors is embedded to a high-dimensional representation by $\mathcal{E}$, using cosine and sine functions of different wavelengths. The feature dimension after embedding is $d_s$. We then transform the embedded feature into a scalar by weight vectors $\mathbf{W}_{s}$ and $\mathbf{b}_s$, followed by a ReLU activation. \end{enumerate} {\bf Multiple graphs.} A single ARG $\mathbf{G}$ typically focuses on a specific relation signal between actors, therefore discarding a considerable amount of context information. In order to capture diverse types of relation signals, we can extend the single actor relation graph into multiple graphs. That is, we build a group of graphs $\mathcal{G}=(\mathbf{G}^1,\mathbf{G}^2,\cdots,\mathbf{G}^{N_g})$ on a same actors set,where $N_g$ is the number of graphs. Every graph $\mathbf{G}^i$ is computed in the same way according to \myref{eq:graph_softmax}, but with unshared weights. Building multiple relation graphs allows the model to jointly attend to different types of relation between actors. Hence, the model can make more robust relational reasoning upon the graphs. {\bf Temporal modeling.} Temporal context information is a crucial cue for activity recognition. Different from prior works, which employ Recurrent Neural Network to aggregate temporal information on dense frames, our model merges the information in the temporal domain via a sparse temporal sampling strategy~\cite{cite_o_1}. During training, we randomly sample a set of $K=3$ frames from the entire video, and build temporal graphs upon the actors in these frames. We call the resulted ARG as {\em randomized ARG}. At testing time, we can use a sliding window approach, and the activity scores from all windows are mean-pooled to form global activity prediction. Empirically we find that sparsely sampling frames when training yields significant improvements on recognition accuracy. A key reason is that, existing group activity recognition datasets (e.g., Collective Activity dataset and Volleyball dataset) remain limited, in both size and diversity. Therefore, randomly sampling the video frames results in more diversity during training and reduces the risk of over-fitting. Moreover, this sparse sampling strategy preserves temporal information with dramatically lower cost, thus enabling end-to-end learning under a reasonable budget in both time and computing resources. \subsection{Reasoning and Training on Graphs} Once the ARGs are built, we can perform relational reasoning on them for recognizing individual actions and group activity. We first review a graph reasoning module, called Graph Convolutional Network (GCN)~\cite{cite_g_10}. GCN takes a graph as input, performs computations over the structure, and returns a graph as output, which can be considered as a ``graph-to-graph" block. For a target node $i$ in the graph, it aggregates features from all neighbor nodes according to the edge weight between them. Formally, one layer of GCN can be written as: \begin{equation} \mathbf{Z}^{(l+1)}=\sigma \left( \mathbf{G}\mathbf{Z}^{(l)}\mathbf{W}^{(l)} \right) , \end{equation} where $\mathbf{G} \in \mathbb{R}^{N \times N}$ is the matrix representation of the graph. $\mathbf{Z}^{(l)} \in \mathbb{R}^{N \times d}$ is the feature representations of nodes in the $l^{th}$ layer, and $\mathbf{Z}^{(0)}=\mathbf{X}$. $\mathbf{W}^{(l)} \in \mathbb{R}^{d \times d}$ is the layer-specific learnable weight matrix. $\sigma (\cdot)$ denotes an activation function, and we adopt ReLU in this work. This layer-wise propagation can be stacked into multi-layers. For simplicity, we only use a layer of GCN in this work. The original GCN operates on a single graph structure. After GCN, the way to fuse a group of graphs together remains an open question. In this work, we employ the late fusion scheme, namely fuse the features of same actor in different graphs after GCN: \begin{equation} \mathbf{Z}^{(l+1)} = \sum^{N_g}_{i=1}{\sigma \left( \mathbf{G}^i\mathbf{Z}^{(l)}\mathbf{W}^{(l,i)} \right)} , \end{equation} where we employ element-wise sum as a fusion function. We also evaluate concatenation as fusion function. Alternatively, a group of graphs can also be fused by early fusion, that is, fused via summation to one graph before GCN. We compare different methods of fusing a group of graphs in our experiments. Finally the output relational features from GCN are fused with original features via summation to form the scene representation. As illustrated in Figure~\ref{fig:figure_2}, the scene representation is fed to two classifiers to generate individual actions and group activity predictions. The whole model can be trained in an end-to-end manner with backpropagation. Combining with standard cross-entropy loss, the final loss function is formed as \begin{equation} \mathcal{L}=\mathcal{L}_1(y^{G},\hat{y}^{G}) + \lambda\mathcal{L}_2(y^{I},\hat{y}^{I}) , \end{equation} where $\mathcal{L}_1$ and $\mathcal{L}_2$ are the cross-entropy loss, $y^{G}$ and $y^{I}$ denote the ground-truth labels of group activity and individual action, $\hat{y}^{G}$ and $\hat{y}^{I}$ are the predictions to group activity and individual action. The first term corresponds to group activity classification loss, and the second is the loss of the individual action classification. The weight $\lambda$ is used to balance these two tasks. \begin{table} \begin{subtable}{0.48\textwidth} \begin{center} \begin{tabular}{|l|c|} \hline Method & Accuracy \\ \hline\hline base model & 89.8\% \\ \hline dot-product & {\bf 91.3\%} \\ embedded dot-product & {\bf 91.3\%} \\ relation network & 90.7\% \\ \hline \end{tabular} \caption{Exploration of different appearance relation functions.} \label{table:table_1a} \end{center} \label{} \end{subtable} \begin{subtable}{0.48\textwidth} \begin{center} \begin{tabular}{|l|c|} \hline Method & Accuracy \\ \hline\hline no position relation & 91.3\% \\ \hline distance mask & {\bf 91.6\%} \\ distance encoding & 91.5\% \\ \hline \end{tabular} \caption{Exploration of different position relation functions.} \label{table:table_1b} \end{center} \label{} \end{subtable} \begin{subtable}{0.48\textwidth} \begin{center} \resizebox{\linewidth}{!}{ \begin{tabular}{|l|c|c|c|c|c|} \hline Number & 1 & 4 & 8 & 16 & 32 \\ \hline Accuracy & 91.6\% & 92.0\% & 92.0\% & {\bf 92.1\%} & 92.0\% \\ \hline \end{tabular} } \caption{Exploration of number of graphs.} \label{table:table_1c} \end{center} \label{} \end{subtable} \begin{subtable}{0.48\textwidth} \begin{center} \begin{tabular}{|l|c|} \hline Method & Accuracy \\ \hline\hline early fusion & 90.8\% \\ late fusion (summation) & {\bf 92.1\%} \\ late fusion (concatenation) & 91.9\% \\ \hline \end{tabular} \caption{Exploration of different methods for fusing multiple graphs.} \label{table:table_1d} \end{center} \label{} \end{subtable} \begin{subtable}{0.48\textwidth} \begin{center} \begin{tabular}{|l|c|} \hline Method & Accuracy \\ \hline\hline single frame & 92.1\% \\ \hline TSN (3 frames) & 92.3\% \\ temporal-graphs (3 frames) & {\bf 92.5\%} \\ \hline \end{tabular} \caption{Exploration of temporal modeling methods.} \label{table:table_1e} \end{center} \end{subtable} \caption{Ablation studies for group activity recognition accuracy on the Volleyball dataset.} \label{table:table_1} \end{table} \section{Experiments} \label{section:Experiments} In this section, we first introduce two widely-adopted datasets and the implementation details of our approach. Then, we perform a number of ablation studies to understand the effects of proposed components in our model. We also compare the performance of our model with the state of the art methods. Finally, we visualize our learned actor relation graphs and features. \subsection{Datasets and Implementation Details} {\bf Datasets.} We conduct experiments on two publicly available group activity recognition datasets, namely the Volleyball dataset and the Collective Activity dataset. The Volleyball dataset~\cite{cite_d_2} is composed of 4830 clips gathered from 55 volleyball games, with 3493 training clips and 1337 for testing. Each clip is labeled with one of 8 group activity labels (right set, right spike, right pass, right winpoint, left set, left spike, left pass and left winpoint). Only the middle frame of each clip is annotated with the players' bounding boxes and their individual actions from 9 personal action labels (waiting, setting, digging, failing, spiking, blocking, jumping, moving and standing). Following~\cite{cite_a_2}, we use 10 frames to train and test our model, which corresponds to 5 frames before the annotated frame and 4 frames after. To get the ground truth bounding boxes of unannotated frames, we use the tracklet data provided by~\cite{cite_a_1}. The Collective Activity dataset~\cite{cite_d_1} contains 44 short video sequences (about 2500 frames) from 5 group activities (crossing, waiting, queueing, walking and talking) and 6 individual actions (NA, crossing, waiting, queueing, walking and talking). The group activity label for a frame is defined by the activity in which most people participate. We follow the same evaluation scheme of~\cite{cite_a_18} and select $1/3$ of the video sequences for testing and the rest for training. {\bf Implementation details.} We extract 1024-dimensional feature vector for each actor with ground-truth bounding boxes, using the methods mentioned in Section~\ref{section:Framework}. During ablation studies, we adopt Inception-v3 as backbone network. We also experiment with VGG~\cite{cite_o_6} network for fair comparison with prior methods. Due to memory limits, we train our model in two stages: first, we fine-tune the ImageNet pre-trained model on single frame randomly selected from each video without using GCN. We refer to the fine-tuned model described above as our base model throughout experiments. The base model performs group activity and individual action classification on original features of actors without relational reasoning. Then we fix weights of the feature extraction part of network, and further train the network with GCN. We adopt stochastic gradient descent with ADAM to learn the network parameters with fixed hyper-parameters to $\beta_1=0.9,\beta_2=0.999,\epsilon=10^{-8}$. For the Volleyball dataset, we train the network in 150 epochs using mini-batch size of 32 and a learning rate ranging from $0.0002$ to $0.00001$. For the Collective Activity dataset, we use mini-batch size of 16 with a learning rate of $0.0001$, and train the network in 80 epochs. The individual action loss weight $\lambda=1$ is used. Besides, the parameters of the GCN are set as $d_k=256,d_s=32$, and we adopt the $1/5$ of the image width to be the distance mask threshold $\mu$. Our implementation is based on PyTorch deep learning framework. The running time for inferring a video is approximately 0.2s on a single TITAN-XP GPU. \subsection{Ablation Studies} In this subsection, we perform detailed ablation studies on the Volleyball dataset to understand the contributions of the proposed model components to relation modeling using group activity recognition accuracy as evaluation metric. The results are shown in Table~\ref{table:table_1}. {\bf Appearance relation.} We begin our experiments by studying the effect of modeling the appearance relation between actors and different functions to compute appearance relation value. Based on single frame, we build single ARG without using position relation. The results are listed in Table~\ref{table:table_1a}. We first observe that explicitly modeling the relation between actors brings significant performance improvement. All models with GCN outperform the base model. Then it is shown that the dot-product and embedded dot-product yield same recognition accuracy of $91.3\%$, and perform better than the relation network. We conjecture that dot-product operation is more stable for representing relation information. In the following experiments, embedded dot-product is used to compute appearance relation value. {\bf Position relation.} We further add spatial structural information to ARG. In Section~\ref{section:Graph}, we present two methods to use spatial features: distance mask and distance encoding. Results on comparing the performance of these two methods are reported in Table~\ref{table:table_1b}. We can see that these two methods both obtain better performance than those without using spatial features, demonstrating the effectiveness of modeling position relation. And the distance mask yields slightly better accuracy than distance encoding. In the rest of the paper, we choose distance mask to represent position relation. {\bf Multiple graphs.} We also investigate the effectiveness of building a group of graphs to capture different kinds of relation information. First, we compare the performance of using different number of graphs. As shown in Table~\ref{table:table_1c}, we observe that building multiple graphs leads to consistent and significant gain compared with only building single graph, and is able to further boost accuracy from $91.6\%$ to $92.1\%$. Then we evaluate three methods to fuse a group of graphs: (1) early fusion, (2) late fusion via summation, (3) late fusion via concatenation. The results of experiments using 16 graphs are summarized in Table~\ref{table:table_1d}. We see that the late fusion via summation achieves the best performance. We note that the early fusion scheme, which aggregates a group of graphs by summation before GCN, results in the performance drops dramatically. This observation indicates that the relation values learned by different graphs encode different semantic information and will cause confusion for relational reasoning if they are fused before graph convolution. We adopt $N_g=16$ and late fusion via summation in the following experiments. {\bf Temporal modeling.} With all the design choices set, we now extend our model to temporal domain. As mentioned in Section~\ref{section:Graph}, we employ sparse temporal sampling strategy~\cite{cite_o_1}, and uniformly sample a set of $K=3$ frames from the entire video during training. In the simplest setting, we can handle the input frames separately, then fuse the prediction scores of different frames as Temporal Segment Network (TSN)~\cite{cite_o_1}. Alternatively, we can build temporal graphs upon the actors in input frames and fuse temporal information by GCN. We report the accuracies of these two temporal modeling methods in Table~\ref{table:table_1e}. We see that TSN modeling is helpful to improve the performance of our model. Moreover, building temporal graphs further boosts accuracy to $92.5\%$, which demonstrates that temporal reasoning helps to differentiate between group activity categories. \begin{table}[t] \begin{subtable}{0.48\textwidth} \begin{center} \resizebox{\linewidth}{!}{ \begin{tabular}{|l|c|c|c|} \hline \multirow{2}*{Method} & \multirow{2}*{Backbone} & Group & Individual \\ ~ & ~ & activity & action \\ \hline\hline HDTM~\cite{cite_a_2} & AlexNet & 81.9\% & - \\ CERN~\cite{cite_a_4} & VGG16 & 83.3\% & - \\ stagNet (GT)~\cite{cite_a_18} & VGG16 & 89.3\% & - \\ stagNet (PRO)~\cite{cite_a_18} & VGG16 & 87.6\% & - \\ HRN~\cite{cite_a_17} & VGG19 & 89.5\% & - \\ SSU (GT)~\cite{cite_a_1} & Inception-v3 & 90.6\% & 81.8\% \\ SSU (PRO)~\cite{cite_a_1} & Inception-v3 & 86.2\% & 77.4\% \\ \hline\hline OURS (GT) & Inception-v3 & 92.5\% & 83.0\% \\ OURS (PRO) & Inception-v3 & 91.5\% & - \\ OURS (GT) & VGG16 & 91.9\% & \bf{83.1}\% \\ OURS (GT) & VGG19 & \bf{92.6\%} & 82.6\% \\ \hline \end{tabular} } \caption{Comparison with state of the art on the Volleyball dataset.} \label{table:table_2a} \end{center} \label{} \end{subtable} \begin{subtable}{0.48\textwidth} \begin{center} \resizebox{\linewidth}{!}{ \begin{tabular}{|l|c|c|} \hline Method & Backbone & Group activity \\ \hline\hline SIM~\cite{cite_a_5} & AlexNet & 81.2\% \\ HDTM~\cite{cite_a_2} & AlexNet & 81.5\% \\ Cardinality Kernel~\cite{cite_a_19} & None & 83.4\% \\ SBGAR~\cite{cite_a_6} & Inception-v3 & 86.1\% \\ CERN~\cite{cite_a_4} & VGG16 & 87.2\% \\ stagNet (GT)~\cite{cite_a_18} & VGG16 & 89.1\% \\ stagNet (PRO)~\cite{cite_a_18} & VGG16 & 87.9\% \\ \hline\hline OURS (GT) & Inception-v3 & \bf{91.0\%} \\ OURS (PRO) & Inception-v3 & 90.2\% \\ OURS (GT) & VGG16 & 90.1\% \\ \hline \end{tabular} } \end{center} \caption{Comparison with state of the art on the Collective dataset.} \label{table:table_2b} \end{subtable} \label{} \vspace{-2mm} \caption{Comparison with state of the art methods. GT and PRO indicate using ground-truth and proposal-based bounding boxes, respectively.} \vspace{-2mm} \label{table:table_2} \end{table} \begin{figure*}[t] \setlength{\abovecaptionskip}{-0.3cm} \setlength{\belowcaptionskip}{-0.2cm} \begin{center} \includegraphics[width=0.92\linewidth]{visual.pdf} \end{center} \caption{Visualization of learned actor relation graphs. Each row shows two examples. For each example, we plot: (1) input frame with group-truth bounding boxes and group activity label; (2) matrix $\mathbf{G}$ of learned relation graph with ground-truth individual action labels. The actor who has max column sum of $\mathbf{G}$ in each frame is denoted with red star. } \label{fig:visual} \end{figure*} \begin{figure*} \setlength{\abovecaptionskip}{-0.3cm} \setlength{\belowcaptionskip}{-0.2cm} \begin{center} \includegraphics[width=0.92\linewidth]{tsne.pdf} \end{center} \caption{t-SNE~\cite{cite_o_2} visualization of embedding of video representation on the Volleyball dataset learned by different model variants: base model, single graph, multiple graphs, temporal multiple graphs. Each video is visualized as one point and colors denote different group activities (better view in color version).} \label{fig:tsne} \end{figure*} \subsection{Comparison with the State of the Art} Now, we compare our best models with the state-of-the-art methods in Table~\ref{table:table_2}. For fair comparison with prior methods, we report our results with both Inception-v3 and VGG backbone network. Meanwhile, we perform proposal-based experiment. We train a Faster-RCNN~\cite{cite_o_7} with training data. Using the bounding boxes from Faster-RCNN at testing time, our model can still achieve promising accuracy. Table~\ref{table:table_2a} shows the comparison with previous results on the Volleyball dataset for group activity and individual action recognition. Our method surpasses all the existing methods by a good margin, establishing the new state-of-the-art. Our model with Inception-v3 utilizes the same feature extraction strategy as~\cite{cite_a_1}, and outperforms it by about $2\%$ on group activity recognition accuracy, since our model can capture and exploit the relation information among actors. And, we also achieve better performance on individual action recognition task. Meanwhile, our method outperforms the recent methods using hierarchical relational networks~\cite{cite_a_17} or semantic RNN~\cite{cite_a_18}, mostly because we explicitly model the appearance and position relation graph, and adopt more efficient temporal modeling method. We further evaluate the proposed model on the Collective Activity dataset. The results and comparison with previous methods are listed in Table~\ref{table:table_2b}. Our temporal multiple graphs model again achieves the state-of-the-art performance with $91.0\%$ group activity recognition accuracy. This outstanding performance shows the effectiveness and generality of proposed ARG for capturing the relation information in multiple people scene. \subsection{Model Visualization} {\bf Actor relation graph visualization} We visualize several examples of the relation graph generated by our model in Figure~\ref{fig:visual}. We use the single graph model on single frame, because it is easier to visualize. Visualization results facilitate us understanding how ARG works. We can see that our model is able to capture relation information for group activity recognition, and the generated ARG can automatically discover the key actor to determine the group activity in the scene. {\bf t-SNE visualization of the learned representation.} Figure~\ref{fig:tsne} shows the t-SNE~\cite{cite_o_2} visualization for embedding the video representation learned by different model variants. Specifically, we project the representations of videos on the validation set of Volleyball dataset into 2-dimensional space using t-SNE. We can observe that the scene-level representations learned by using ARG are better separated. Moreover, building multiple graphs and aggregating temporal information lead to better differentiate group activities. These visualization results indicate our ARG models are more effective for group activity recognition. \vspace{-3mm} \section{Conclusion} This paper has presented a flexible and efficient approach to determine relevant relation between actors in a multi-person scene. We learn {\em Actor Relation Graph} (ARG) to perform relational reasoning on graphs for group activity recognition. We also evaluate the proposed model on two datasets and establish new state-of-the-art results. The comprehensive ablation experiments and visualization results show that our model is able to learn relation information for understanding group activity. In the future, we plan to further understand how ARG works, and incorporate more global scene information for group activity recognition. \vspace{-2mm} \section*{Acknowledgement} This work is supported by the National Science Foundation of China under Grant No.61321491, and Collaborative Innovation Center of Novel Software Technology and Industrialization. {\small \bibliographystyle{ieee}
{'timestamp': '2019-04-24T02:05:02', 'yymm': '1904', 'arxiv_id': '1904.10117', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.10117'}
arxiv
\section{Introduction} \label{Introduction} Over recent years, deep learning approaches to remote sensing have established new state of the art results for land cover classification. Pre-trained convolutional neural networks (CNNs) such as GoogleNet and CaffeNet have achieved remarkable performance on land use classification tasks when fine tuned with remote sensing data \cite{Castelluccio2015LandUC}. In order to exploit the temporal nature of agriculture, Rubwurm and Korner \yrcite{RuBwurm2017TemporalVM} applied recurrent neural networks (RNN) and long short term memory networks (LSTM) to the task of temporal vegetation classification, finding that time series information greatly improved classification accuracy on multi-class vegetation data. Recently, capsule networks have been proposed for remote sensing classification tasks, though their applications primarily involve high-resolution satellite imagery. Deng et al. \yrcite{Deng2018HyperspectralIC} achieved a 20\% relative improvement in land use classification accuracy with capsule networks over CNN, additionally finding that capsule networks required far fewer labelled training data points to achieve high confidence in predictions. Paoletti et al. \yrcite{Paoletti2019CapsuleNF} also employ capsule networks to classify land use in high resolution satellite imagery, finding that the architecture greatly outperforms deep that of a deep CNN. In contrast to capsule networks, attention networks are relatively underused in the remote sensing field. Liu et al. \yrcite{Liu2018AttentionBN} developed a stacked LSTM network which reweighted later layers with attention over the input and the previous hidden state. Xu et al. \yrcite{xu_tao_lu_zhong_2018} incorporate attention layers over convolutional filters to create an embedding that combines weighted feature maps. However, these applications are primarily limited to high resolution spatial imagery and their applications to low resolution imagery are not well understood. This paper presents a new deep learning architecture (CapsAttn) which combines capsule and attention layers with CNN and LSTM layers to achieve state of the art results on temporal crop type classification with low-resolution satellite imagery. \section{Methodology} The data set used for this paper was provided in Rubworm and Korner \yrcite{RuBwurm2017TemporalVM}, comprising 26 Sentinel 2A images taken during 2016 of a 102 x 42 km area in Munich, Germany. The 10 m bands (2 blue, 3 green, 4 red, 8 near-infrared) and 20 m bands (11 short-wave-infrared-1, 12 short-wave-infrared-2) down-sampled to 10 m resolution were extracted from 406,000 points of interest were within the data set. Input data was formatted to 3 x 3 px neighborhoods for each of the 26 time steps with an approximate 75, 5, and 20 percent train, validation, and test ratio. Ground truth labels were provided by the Bavarian Ministry of Agriculture, totalling 19 classes with at least 400 occurrences (corn, corn, meadow, asparagus, rape, hops, summer oats, winter spelt, fallow, winter wheat, winter barley, winter rye, beans, winter triticale, summer barley, peas, potatoes, soybeans, and sugar beets). Sample points were additionally classified into cloud, water, snow, and cloud shadow, as well as an other category for non-agricultural pixels. \subsubsection{Model design} The general model architecture (shown in Figure \ref{model-figure} and Table \ref{model-table}) begins with a 1x1 2D convolution over the 6 input channels with ReLU activation. The convolution output is passed to a primary capsule prior to the squashing activation function. The capsules are flattened and fed into a many-to-many bidirectional LSTM with 240 units, before being weighted with time-distributed attention and passed to two dense layers for classification. \begin{table}[h!] \vskip -0.1in \caption{Architecture layer shape and activation.} \label{model-table} \vskip 0.15in \begin{center} \begin{small} \begin{sc} \begin{tabular}{lcccr} \toprule Layer & Shape & Activation\\ \midrule Input & 26 x 3 x 3 x 6 & \\ 2D-Conv & 26 x 3 x 3 x 128 & ReLU \\ Primary Caps & 26 x 1280 x 10& ReLU \\ Capsule & 26 x 23 x 10 & Squash\\ Bi-LSTM & 26 x 480 & Tanh\\ Attention &26 x 480 & Tanh \\ Dense &26 x 512 & ReLu \\ Dense &26 x 23 & Softmax \\ \bottomrule \end{tabular} \end{sc} \end{small} \end{center} \vskip -0.21in \end{table} This paper employs the capsule architecture set forth by Sabour, Frosst, and Hinton \yrcite{capsnet}. Instead of using margin and reconstruction loss and masking capsule layers with ground truth information, we use cross entropy loss for three reasons. First, unmasked capsule outputs provide less sparse input to the LSTM. Secondly, backpropagating margin loss through the LSTM to the capsule layer may reduce the amount of information passed between time steps in the LSTM, as the network will be incentivized to maintain more information about the individual time step, partially defeating the LSTM's purpose of creating a time-dependent representation. Finally, the use of capsule layers with cross entropy loss allows the architecture to create a flattened representation of the image that mitigates translation invariance issues in a similar manner as max pooling, without discarding any of the valuable and limited training information per sample. The output state of each time step from the LSTM layer is passed to distributed attention layers using the equations in (1-3) as introduced by Yang et al. \yrcite{inproceedings}, \begin{align} u_{it} &= \text{tanh}(W_w h_{it}+b_s), \\ \alpha_i &= \frac{\text{exp}(u_{it}^Tu_w)}{\sum_t \text{exp}(u_{it}^T u_w}, \\ s_i &= \sum_t \alpha_{it}h_{it} \end{align} where $W$, $h$, and $b$ refer to the weight matrix, hidden state, and bias, respectively, and $\alpha$ is a learned parameter weighing each hidden state. Three weight vectors are learned at each time step to weight and combine every time step into a vector that is then passed to two fully connected layers for classification. Training was implemented on an Ubuntu 16.1 server running Tensorflow 1.5.1 with an implementation of capsule layers written in Keras 2.0.8. Training took approximately 12 hours on a Nvidia K80 GPU. A batch size of 50 was used with a learning rate of 0.01 and the Adam optimizer. Regularization methods, including dropout, batch normalization, and kernel regularization were tested. However, the model did not overfit and regularization did not improve generalization ability. Deeper networks, with stacked LSTM and/or 2D convolution layers, were also tested with a variety of skip connections to help gradient flow, but did not improve over the presented architecture. \begin{figure*}[ht] \vskip 0.2in \begin{center} \centerline{\includegraphics[width=14cm]{figure2.png}} \caption{Diagrammatic overview of model architecture. Shape and activation specifics are outlined in Table \ref{model-table}.} \label{model-figure} \end{center} \vskip -0.2in \end{figure*} \section{Results} \begin{table}[h] \caption{Model metrics comparing the proposed architecture with previous approaches. LSTM, RNN, CNN, and SVM results taken from Rubworm and Korner \yrcite{RuBwurm2017TemporalVM}. Metrics are weighted to account for class inbalance using the methodology in Rubworm and Korner \yrcite{RuBwurm2017TemporalVM}.} \label{sample-table} \vskip 0.15in \begin{center} \begin{small} \begin{sc} \begin{tabular}{lcccr} \toprule Model & Acc. & Precision & Recall & F-score \\ \midrule \textbf{CapsAttn} & \textbf{88.0} & \textbf{87.5} & \textbf{85.6} & \textbf{86.5} \\ CapsLSTM & 86.7 & 85.1 & 83.8 & 84.5 \\ CNNAttn & 86.3 & 83.8 & 82.6 & 84.1 \\ CNN-LSTM & 85.6 & 83.9 & 82.1 & 82.3 \\ LSTM & 74.3 & 78.4 & 74.5 & 75.3 \\ RNN & 72.9 & 77.3 & 73.0 & 74.0 \\ CNN & 64.3 & 59.2 & 57.2 & 56.7 \\ SVM & 31.1 & 31.4 & 31.1 & 31.1 \\ \bottomrule \end{tabular} \end{sc} \end{small} \end{center} \vskip -0.1in \end{table} Utilizing capsule layers and time distributed attention, the present architecture (hereafter referred to as CapsAttn) achieves state of the art results on crop type classification, improving upon the results reported by Rubworm and Korner \yrcite{RuBwurm2017TemporalVM} by a relative margin of over 80\%. Further metrics are provided in Table \ref{sample-table}, indicating that CapsAttn outperforms previous approaches. These results suggest that both capsule layers and attention can increase performance in low-resolution satellite classification. The CNN-LSTM network, with the output of a 1x1 2D convolution and 2D max pooling fed as input to an LSTM, also performed better than the LSTM in Rubworm and Korner \yrcite{RuBwurm2017TemporalVM}. This suggests that, while temporal information is important when classifying vegetation with Sentinel data, spatial relationships should not be discarded. The ablation study in Table \ref{sample-table} shows that capsule layers and distributed attention independently increase classification performance, but the combination of both performs the best. \begin{figure}[h] \vskip 0.2in \begin{center} \centerline{\includegraphics[width=\columnwidth]{figure1.png}} \caption{Confusion matrix weighted by percent accuracy of CapsAttn on the test data set.} \label{icml-historical} \end{center} \vskip -0.2in \end{figure} Following the results of Rubworm and Korner \yrcite{RuBwurm2017TemporalVM} which demonstrated that time series classification greatly outperforms single-image classification for low resolution vegetation analysis, the present results suggest that distributed attention layers allow for more complicated time dependencies to be learned. Learning separate weights at each time step allows the architecture to differentiate between, for example, time dependencies between winter and early growing season, and spring and harvest season. Attention layers with shared weights did not see any significant improvement over the architecture without attention, indicating that learning individual weights at each time step is critical for the network to understand the complicated time dependencies present in agricultural growing patterns. This paper diverges from previous remote sensing papers that have utilized capsule networks by eschewing margin and reconstruction loss. As outlined in the methodology, this was done due to the simplicity of the data, number of classes, and issues imposed by masking with a recurrent decoder. Other papers outside of remote sensing where time series or recurrent classification is necessary, such as in polyphonic sound detection \cite{liu_tang_song_dai_2018}, and text classification \cite{srivastava-etal-2018-identifying} have also found that unmasked capsule layers with cross entropy loss perform better than masked capsule layers with margin loss. As such, this paper suggests that the model architecture and data complexity should inform the choice of loss function for capsule layers in remote sensing. Overall, this paper introduces a state-of-the-art classification architecture for agricultural crops that allows for accurate classification with low resolution imagery, reducing error rate versus the previous state-of-the-art by nearly 50\%. \nocite{langley00}
{'timestamp': '2019-04-24T02:05:52', 'yymm': '1904', 'arxiv_id': '1904.10130', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.10130'}
arxiv
\section{Conclusion and Future Work} \label{sec:conclusion} We present Flexible BFT, a protocol that supports diverse clients with different assumptions to use the same ledger. Flexible BFT allows the clients to tolerate combined (Byzantine plus alive-but-corrupt\xspace) faults exceeding 1/2 and 1/3 for synchrony and partial synchrony respectively. At a technical level, under synchrony, we show a synchronous protocol where the replicas execute a network speed protocol and only the commit rule uses the synchrony assumption. For partial synchrony, we introduce the notion of Flexible Byzantine Quorums by deconstructing existing BFT protocols to understand the role played by the different quorums. We combine the two to form Flexible BFT which obtains the best of both worlds. Our liveness proof in Section~\ref{sec:proof} employs a strong assumption that all clients have correct commit rules. This is because our alive-but-corrupt\xspace fault model did not specify what these replicas would do if they can violate safety for some clients. In particular, they may stop helping liveness. However, we believe this will not be a concern once we move to a more realistic rational model. In that case, the best strategy for alive-but-corrupt\xspace replicas is to attack the safety of clients with unsafe commit rules while preserving liveness for clients with correct commit rules. Such an analysis in the rational fault model remains interesting future work. Our protocol also assumes that all replicas have clocks that advance at the same rate. It is interesting to explore whether our protocol can be modified to work with clock drifts. \section{Discussion} \label{sec:discussion} As we have seen, three parameters ${q_{r}}$, ${q_c}$, and $\Delta$ determine the protocol. ${q_{r}}$ is the only parameter for the replicas and is picked by the service administrator. The choice of ${q_{r}}$ determines a set of client assumptions that can be supported. ${q_c}$ and $\Delta$ are chosen by clients to commit blocks. In this section, we first discuss the client assumptions supported by a given ${q_{r}}$ and then discuss the trade-offs between different choices of ${q_{r}}$. \subsection{Client Assumptions Supported by ${q_{r}}$} \label{sec:client-beliefs-given} \begin{figure}[tbp] \centering \includegraphics[width=0.45\textwidth]{single-curve.pdf} \caption{\textbf{Clients supported for ${q_{r}} = 2/3$.}} \label{fig:clients-supported} \end{figure} Figure~\ref{fig:clients-supported} represents the clients supported at ${q_{r}} = 2/3$. The x-axis represents Byzantine faults and the y-axis represents total faults (Byzantine plus a-b-c\xspace). Each point on this graph represents a client fault assumption as a pair: (Byzantine faults, total faults). The shaded gray area indicates an ``invalid area'' since we cannot have fewer total faults than Byzantine faults. A missing dimension in this figure is the choice of $\Delta$. Thus, the synchrony guarantee shown in this figure is for clients that choose a correct synchrony bound. Clients with partial-synchrony assumptions can get fault tolerance on (or below) the starred orange line. The right most point on the line is $(1/3, 1/3)$, i.e., we tolerate less than a third of Byzantine replicas and no additional a-b-c\xspace replicas. This is the setting of existing partially synchronous consensus protocols~\cite{DLS88,castro1999practical,yin2018hotstuff}. Flexible BFT\xspace generalizes these protocols by giving clients the option of moving up-left along the line, i.e., tolerating fewer Byzantine and more total faults. By choosing ${q_c}>{q_{r}}$, a client tolerates $< {q_c}+{q_{r}}-1$ total faults for safety and $\leq 1-{q_c}$ Byzantine faults for liveness. In other words, as a client moves left, for every additional vote it requires, it tolerates one fewer Byzantine fault and gains overall one higher total number of faults (i.e., two more a-b-c\xspace faults). The left most point on this line $(0, 2/3)$ tolerating no Byzantine replicas and the highest fraction of a-b-c\xspace replicas. Moreover, for clients who believe in synchrony, if their $\Delta$ assumption is correct, they enjoy 1/3 Byzantine tolerance and 2/3 total tolerance represented by the green diamond. This is because synchronous commit rules are not parameterized by the number of votes received. \paragraph{How do clients pick their commit rules?} In Figure~\ref{fig:clients-supported}, the shaded starred orange portion of the plot represent fault tolerance provided by the partially synchronous commit rule (CR1). Specifically, setting ${q_c}$ to the total fault fraction yields the necessary commit rule. On the other hand, if a client's required fault tolerance lies in the circled green portion of the plot, then the synchronous commit rule (CR2) with an appropriate $\Delta$ picked by the client yields the necessary commit rule. Finally, if a client's target fault tolerance corresponds to the white region of the plot, then it is not achievable with this ${q_{r}}$. \paragraph{Clients with incorrect assumptions and recovery.} If a client has incorrect assumption with respect to the fault threshold or synchrony parameter $\Delta$, then it can lose safety or liveness. If a client believing in synchrony picks too small a $\Delta$ and commits a value $b$, it is possible that a conflicting value $b'$ may also be certified. Replicas may choose to extend the branch containing $b'$, effectively reverting $b$ and causing a safety violation. Whenever a client detects such a safety violation, it may need to revert some of its commits and increase $\Delta$ to recover. For a client with partial-synchrony assumption, if it loses safety, it can update its fault model to move left along the orange starred line, i.e., tolerate higher total faults but fewer Byzantine. On the other hand, if it observes no progress as its threshold ${q_c}$ is not met, then it moves towards the right. However, if the true fault model is in the circled green region in Figure~\ref{fig:clients-supported}, then the client cannot find a partially synchronous commit rule that is both safe and live and eventually has to switch to using a synchronous commit rule. Recall that the goal of a-b-c\xspace replicas is to attack safety. Thus, clients with incorrect assumptions may be exploited by a-b-c\xspace replicas for their own gain (e.g., by double-spending). When a client updates to a correct assumption and recovers from unsafe commits, their subsequent commits would be safe and final. This is remotely analogous to Bitcoin -- if a client commits to a transaction when it is a few blocks deep and a powerful adversary succeeds in creating an alternative longer fork, the commit is reverted. \subsection{Comparing Different ${q_{r}}$ Choices} \label{sec:comp-diff-qmins} \begin{figure}[tbp] \centering \includegraphics[width=0.45\textwidth]{pbft.pdf} \caption{Clients supported by Flexible BFT\xspace at different ${q_{r}}$'s. The legend represents the different ${q_{r}}$ values.} \label{fig:varying-qmin} \end{figure} We now look at the service administrator's choice at picking ${q_{r}}$. In general, the service administrator's goal is to tolerate a large number of Byzantine and a-b-c\xspace faults, i.e., move towards top and/or right of the figure. Figure~\ref{fig:varying-qmin} shows the trade-offs in terms of clients supported by different ${q_{r}}$ values in Flexible BFT\xspace. First, it can be observed that for clients with partial-synchrony assumptions, ${q_{r}} \geq 2/3$ dominates ${q_{r}} < 2/3$. Observe that the fraction of Byzantine replicas $(B)$ are bounded by $B < {q_c}+{q_{r}}-1$ and $B \leq 1-{q_c}$, so $B \leq {q_{r}}/2$. Thus, as ${q_{r}}$ decreases, Byzantine fault tolerance decreases. Moreover, since the total fault tolerance is ${q_c} + {q_{r}} - 1$, a lower ${q_{r}}$ also tolerates a smaller fraction of total faults for a fixed ${q_c}$. For ${q_{r}} \geq 2/3$ or for clients believing in synchrony, no value of ${q_{r}}$ is Pareto optimal. For clients with partial-synchrony assumptions, as ${q_{r}}$ increases, the total fault tolerance for safety increases. But since ${q_c} \geq {q_{r}}$, we have $B \leq 1 - {q_{r}}$, and hence the Byzantine tolerance for liveness decreases. For clients believing in synchrony, the total fault tolerance for safety is $< {q_{r}}$ and the Byzantine fault tolerance for liveness is $\geq 1-{q_{r}}$. In both cases, the choice of ${q_{r}}$ represents a safety-liveness trade-off. \subsection{Separating Alive-but-corrupt\xspace Resilience from Diversity} So far, we presented the Flexible BFT\xspace techniques and protocols to simultaneously support diverse client support and stronger a-b-c\xspace fault tolerance. Indeed, we believe both properties are desirable and they strengthen each other. But we remark that these two properties can be provided separately. It is relatively straightforward to provide stronger fault tolerance in the a-b-c\xspace model in a classic uniform setting. For example, under partial-synchrony, one can simply use a larger quorum in PBFT (without the ${q_{r}}$/$q$ replica/client quorum separation). But we note that a higher total (a-b-c\xspace plus Byzantine) tolerance comes at the price of a lower Byzantine tolerance. In a uniform setting, this means \emph{all} clients have to sacrifice some Byzantine tolerance. In the diverse setting, Flexible BFT\xspace gives clients the freedom to choose the fault assumption they believe in, and a client can choose the classic Byzantine fault model. On the flip side, if one hopes to support diverse clients in the classic Byzantine fault (no a-b-c\xspace faults), the ``dimension of diversity'' reduces. One example is the network speed replica protocol in Section~\ref{sec:overv-synchr-flex}, which supports clients that believe in different synchrony bounds. That protocol can be further extended to support clients with a (uniform) partial-synchrony assumption. Clients with partial-synchrony assumption are uniform since we have not identified any type of ``diversity'' outside a-b-c\xspace faults for them. \section{Introduction} \label{sec:introduction} Byzantine fault tolerant (BFT) protocols are used to build replicated services~\cite{PSL80,LSP82,schneider1990implementing}. Recently, they have received revived interest as the algorithmic foundation of what is known as decentralized ledgers, or blockchains. In the classic approach to BFT protocol designs, a protocol designer or a service administrator first picks a set of assumptions (e.g., the fraction of Byzantine faults and certain timing assumptions) and then devises a protocol (or chooses an existing one) tailored for that particular setting. The assumptions made by the protocol designer are imposed upon all parties involved --- every replica maintaining the service as well as every client (also known as the "learner" role) using the service. Such a protocol collapses if deployed under settings that differ from the one it is designed for. In particular, optimal-resilience partially synchronous solutions~\cite{DLS88,castro1999practical} break (lose safety and liveness) if the fraction of Byzantine faults exceeds $1/3$. Similarly, optimal-resilience synchronous solutions~\cite{abraham2018synchronous,hanke2018dfinity} do not obtain safety or liveness if the fraction of Byzantine faults exceeds $1/2$ or if the synchrony bound is violated. In this work, we introduce a new approach for BFT protocol design called \emph{Flexible BFT\xspace}. Our approach offers advantages in the two aspects above. First, the Flexible BFT\xspace approach enables protocols that tolerate more than $1/3$ (resp.\ $1/2$) corruption faults in the partial-synchrony (resp.\ synchrony) model --- provided that the number of Byzantine faults do not exceed the respective resilience bounds. Second, the Flexible BFT\xspace approach allows a certain degree of separation between the fault model and the protocol design. As a result, Flexible BFT\xspace allows diverse clients with different fault assumptions and timing assumptions (synchrony or not) to participate in the same protocol. We elaborate on these two aspects below. \paragraph{Stronger resilience.} We introduce a mixed fault model with a new type of fault called \emph{alive-but-corrupt\xspace} (a-b-c\xspace for short) faults. Alive-but-corrupt\xspace replicas actively try to disrupt the system from maintaining a safe consensus decision and they might arbitrarily deviate from the protocol for this purpose. However, if they cannot break safety, they will not try to prevent the system from reaching a (safe) decision. The rationale for this new type of fault is that violating safety may provide the attacker gains (e.g., a double spend attack) but preventing liveness usually does not. In fact, a-b-c\xspace replicas may gain rewards from keeping the replicated service live, e.g., by collecting service fees. We show a family of protocols that tolerate a combination of Byzantine and a-b-c\xspace faults that exceeds $1/3$ in the partially synchronous model and exceeds $1/2$ in the synchronous model. Our results do not violate existing resilience bounds because the fraction of Byzantine faults is always smaller than the respective bounds. \paragraph{Diversity.} The Flexible BFT\xspace approach further provides certain separation between the fault model and the protocol. The design approach builds a protocol whose transcript can be interpreted by external clients with diverse beliefs, who draw different consensus commit decisions based on their beliefs. Flexible BFT\xspace guarantees safety and liveness so far as the clients' beliefs are correct; thus two clients with correct assumptions agree with each other. Clients specify (i) the fault threshold they need to tolerate, and (ii) the message delay bound, if any, they believe in. For example, one instance of Flexible BFT\xspace can support a client that requires tolerance against $1/5$ Byzantine faults plus $3/10$ a-b-c\xspace faults, while simultaneously supporting another client who requires tolerance against $1/10$ Byzantine faults plus $1/2$ a-b-c\xspace faults, and a third client who believes in synchrony and requires $3/10$ Byzantine plus $2/5$ a-b-c\xspace tolerance. This novel separation of fault model from protocol design can be useful in practice in several ways. First, different clients may naturally hold different assumptions about the system. Some clients may be more cautious and require a higher resilience than others; some clients may believe in synchrony while others do not. Moreover, even the same client may assume a larger fraction of faults when dealing with a \$1M transaction compared to a \$5 one. The rationale is that more replicas may be willing to collude to double spend a high-value transaction. In this case, the client can wait for more votes before committing the \$1M transaction. Last but not least, a client may update its assumptions based on certain events it observes. For example, if a client receives votes for conflicting values, which may indicate an attempt at attacking safety, it can start requiring more votes than usual; if a client who believes in synchrony notices abnormally long message delays, which may indicate an attack on network infrastructure, it can update its synchrony bound to be more conservative or switch to a partial-synchrony assumption. The notion of ``commit'' needs to be clarified in our new model. Clients in Flexible BFT\xspace have different assumptions and hence different commit rules. It is then possible and common that a value is committed by one client but not another. Flexible BFT\xspace guarantees that any two clients whose assumptions are correct (but possibly different) commit to the same value. If a client's assumption is incorrect, however, it may commit inconsistent values which may later be reverted. While this new notion of commit may sound radical at first, it is the implicit behavior of existing BFT protocols. If the assumption made by the service administrator is violated in a classic BFT protocol (e.g., there are more Byzantine faults than provisioned), clients may commit to different values and they have no recourse. In this sense, Flexible BFT\xspace is a robust generalization of classic BFT protocols. In Flexible BFT\xspace, if a client performs conflicting commits, it should update its assumption to be more cautious and re-interpret what values are committed under its new assumption. In fact, this ``recovery'' behavior is somewhat akin to Bitcoin. A client in Bitcoin decides how many confirmations are needed (i.e., how ``deeply buried'') to commit a block. If the client commits but subsequently an alternative longer fork appears, its commit is reverted. Going forward, the client may increase the number of confirmations it requires. \paragraph{Key techniques.} Flexible BFT\xspace centers around two new techniques. The first one is a novel synchronous BFT protocol with replicas executing at \emph{network speed}; that is, the protocol run by the replicas does not assume synchrony. This allows clients in the same protocol to assume different message delay bounds and commit at their own pace. The protocol thus separates timing assumptions of replicas from timing assumptions of clients. Note that this is only possible via Flexible BFT\xspace's separation of protocol from the fault model: the action of committing is only carried out by clients, not by replicas. The other technique involves a breakdown of the different roles that quorums play in different steps of partially synchronous BFT protocols. Once again, made possible by the separation in Flexible BFT\xspace, we will use one quorum size for replicas to run a protocol, and let clients choose their own quorum sizes for committing in the protocol. \paragraph{Contributions.} To summarize, our work has the following contributions. \begin{enumerate}[topsep=8pt,itemsep=8pt] \item \textbf{Alive-but-corrupt faults.} We introduce a new type of fault, called alive-but-corrupt\xspace fault, which attack safety but not liveness. \item \textbf{Synchronous BFT with network speed replicas.} We present a synchronous protocol in which only the commit step requires synchrony. Since replicas no longer perform commits in our approach, the protocol simultaneously supports clients assuming different synchrony bounds. \item \textbf{Flexible Byzantine Quorums.} We deconstruct existing BFT protocols to understand the role played by different quorums and introduce the notion of Flexible Byzantine Quorums. A protocol based on Flexible Byzantine Quorums simultaneously supports clients assuming different fault models. \item \textbf{One BFT Consensus Solution for the Populace.} Putting the above together, we present a new approach for BFT design, Flexible BFT\xspace. Our approach has stronger resilience and diversity: Flexible BFT\xspace tolerates a fraction of combined (Byzantine plus a-b-c\xspace) faults beyond existing resilience bounds. And clients with diverse fault and timing beliefs are supported in the same protocol. \end{enumerate} \paragraph{Organization.} The rest of the paper is organized as follows. Section~\ref{sec:model} defines the Flexible BFT\xspace model where replicas and clients are separated. We will describe in more detail our key techniques for synchrony and partial-synchrony in Sections~\ref{sec:overv-synchr-flex}~and~\ref{sec:overview-async}, respectively. Section~\ref{sec:protocol} puts these techniques together and presents the final protocol. Section~\ref{sec:discussion} discusses the result obtained by the Flexible BFT design and Section~\ref{sec:related-work} describes related work. \section*{Acknowledgement} We thank Ittai Abraham and Ben Maurer for many useful discussions on Flexible BFT. We thank Marcos Aguilera for many insightful comments on an earlier draft of this work \bibliographystyle{plain} \section{Modeling Flexible BFT\xspace} \label{sec:model} The goal of Flexible BFT\xspace is to build a replicated service that takes requests from clients and provides clients an interface of a single non-faulty server, i.e., it provides clients with the same totally ordered sequence of values. Internally, the replicated service uses multiple servers, also called replicas, to tolerate some number of faulty servers. The total number of replicas is denoted by $n$. In this paper, whenever we speak about a set of replicas or messages, we denote the set size as its fraction over $n$. For example, we refer to a set of $m$ replicas as ``$q$ replicas'' where $q=m/n$. Borrowing notation from Lamport~\cite{lamport2006fast}, such a replicated service has three logical actors: \emph{proposers} capable of sending new values, \emph{acceptors} who add these values to a totally ordered sequence (called a blockchain), and \emph{learners} who decide on a sequence of values based on the transcript of the protocol and execute them on a state machine. Existing replication protocols provide the following two properties: \begin{description}[topsep=8pt,itemsep=4pt] \item[-] \textbf{Safety.} Any two learners learn the same sequence of values. \item[-] \textbf{Liveness.} A value proposed by a proposer will eventually be executed by every learner. \end{description} In existing replication protocols, the learners are assumed to be \emph{uniform}, i.e., they interpret a transcript using the same rules and hence decide on the same sequence of values. In Flexible BFT\xspace, we consider diverse learners with different assumptions. Based on their own assumptions, they may interpret the transcript of the protocol differently. We show that so far as the assumptions of two different learners are both correct, they will eventually learn the same sequence of values. A replication protocol in the Flexible BFT\xspace approach satisfies the following properties: \begin{description}[topsep=8pt,itemsep=4pt] \item[-] \textbf{Safety for diverse learners.} Any two learners with correct but potentially different assumptions learn the same sequence of values. \item[-] \textbf{Liveness for diverse learners.} A value proposed by a proposer will eventually be executed by every learner with a correct assumption. \end{description} In a replicated service, clients act as proposers and learners, whereas the replicas (replicated servers) are acceptors. Thus, safety and liveness guarantees are defined with respect to clients. \paragraph{Fault model.} We assume two types of faults within the replicas: Byzantine and \emph{alive-but-corrupt\xspace} (a-b-c\xspace for short). Byzantine replicas behave arbitrarily. On the other hand, the goal of a-b-c\xspace replicas is to attack safety but to preserve liveness. These replicas will take any actions that help them break safety of the protocol. However, if they cannot succeed in breaking safety, they will help provide liveness. Consequently, in this new fault model, the safety proof should treat a-b-c\xspace replicas similarly to Byzantine. Then, \emph{once safety is proved}, the liveness proof can treat a-b-c\xspace replicas similarly to honest. We assume that the adversary is static, i.e., the adversary determines which replicas are Byzantine and a-b-c\xspace before the start of the protocol. \paragraph{Other assumptions.} We assume hash functions, digital signatures and a public-key infrastructure (PKI). We use $\sig{x}_R$ to denote a message $x$ signed by a replica $R$. We assume pair-wise communication channels between replicas. We assume that all replicas have clocks that advance at the same rate. \section{Flexible Byzantine Quorums for Partial Synchrony - Overview} \label{sec:overview-async} In this section, we explain the high-level insights of Flexible Byzantine Quorums in Flexible BFT\xspace. Again, for ease of exposition, we focus on a single-shot consensus and do not consider termination. We start by reviewing the Byzantine Quorum Systems~\cite{Malkhi:1997:BQS:258533.258650} that underlie existing partially synchronous protocols that tolerate 1/3 Byzantine faults (Section~\ref{sec:byz-quorums}). We will illustrate that multiple uses of 2/3-quorums actually serve different purposes in these protocols. We then generalize these protocols to use \emph{Flexible Byzantine Quorums}~(Section~\ref{sec:flexible-byz-quorum}), the key idea that enables more than 1/3 fault tolerance and allows diverse clients with varying assumptions to co-exist. \subsection{Background: Quorums in PBFT} \label{sec:byz-quorums} Existing protocols for solving consensus in the partially synchronous setting with optimal $1/3$-resilience revolve around voting by \emph{Byzantine quorums} of replicas. Two properties of Byzantine quorums are utilized for achieving safety and liveness. First, any two quorums intersect at one honest replica -- quorum intersection. Second, there exists a quorum that contains no Byzantine faulty replicas -- quorum availability. Concretely, when less than $1/3$ the replicas are Byzantine, quorums are set to size ${q_{r}}=2/3$. (To be precise, ${q_{r}}$ is slightly larger than 2/3, i.e., $2f+1$ out of $3f+1$ where $f$ is the number of faults, but we will use ${q_{r}}=2/3$ for ease of exposition.) This guarantees an intersection of size at least $2{q_{r}}-1=1/3$, hence at least one honest replica in the intersection. As for availability, there exist ${q_{r}}=2/3$ honest replicas to form a quorum. To dissect the use of quorums in BFT protocols, consider their use in PBFT~\cite{castro1999practical} for providing safety and liveness. PBFT operates in a view-by-view manner. Each view has a unique leader and consists of the following steps: \begin{itemize} \item[-] \textbf{Propose.} A leader $L$ proposes a value $b$. \item[-] \textbf{Vote 1.} On receiving the first value $b$ for a view $v$, a replica votes for $b$ if it is \emph{safe}, as determined by a locking mechanism described below. A set of ${q_{r}}$ votes form a certificate $\mathcal{C}^{{q_{r}}}(b)$. \item[-] \textbf{Vote 2.} On collecting $\mathcal{C}^{{q_{r}}}(b)$, a replica ``locks'' on $b$ and votes for $\mathcal{C}^{{q_{r}}}(b)$. \item[-] \textbf{Commit.} On collecting ${q_{r}}$ votes for $\mathcal{C}^{{q_{r}}}(b)$, a client learns that proposal $b$ becomes a committed decision. \end{itemize} If a replica locks on a value $b$ in a view, then it votes only for $b$ in subsequent views unless it ``unlocks'' from $b$. A replica ``unlocks'' from $b$ if it learns that ${q_{r}}$ replicas are \emph{not} locked on $b$ in that view or higher (they may be locked on other values or they may not be locked at all). The properties of Byzantine quorums are harnessed in PBFT for safety and liveness as follows: \begin{description}[topsep=8pt,itemsep=4pt] \item[Quorum intersection within a view.] Safety within a view is ensured by the first round of votes. A replica votes only once per view. For two distinct values to both obtain certificates, one honest replica needs to vote for both, which cannot happen. \item[Quorum intersection across views.] Safety across views is ensured by the locking mechanism. If $b$ becomes a committed decision in a view, then a quorum of replicas lock on $b$ in that view. For an honest replica among them to unlock from $b$, a quorum of replicas need to claim they are not locked on $b$. At least one replica in the intersection is honest and would need to falsely claim it is not locked, which cannot happen. \item[Quorum availability within a view.] Liveness within each view is guaranteed by having an honest quorum respond to a non-faulty leader. \end{description} \subsection{Flexible Byzantine Quorums} \label{sec:flexible-byz-quorum} Our Flexible BFT\xspace approach separates the quorums used in BFT protocols for the replicas (acceptors) from the quorums used for learning when a decision becomes committed. More specifically, we denote the quorum used for forming certificates (locking) by ${q_\text{lck}}$ and the quorum used for unlocking by ${q_\text{ulck}}$. We denote the quorum employed by clients for learning certificate uniqueness by ${q_\text{unq}}$, and the quorum used for learning commit safety by ${q_\text{cmt}}$. In other words, clients mandate ${q_\text{unq}}$ first-round votes and ${q_\text{cmt}}$ second-round votes in order to commit a decision. Below, we outline a modified PBFT-like protocol that uses these different quorum sizes instead of a single quorum size $q$. We then introduce a new definition, Flexible Byzantine Quorums, that capture the requirements needed for these quorums to provide safety and liveness. \begin{figure}[h] \centering \begin{boxedminipage}{\columnwidth} \begin{itemize}[itemsep=4pt,leftmargin=*] \item[-] \textbf{Propose.} A leader $L$ proposes a value $b$. \item[-] \textbf{Vote 1.} On receiving the first value $b$ for a view $v$, a replica votes for $b$ if it is \emph{safe}, as determined by a locking mechanism described below. A set of ${q_\text{lck}}$ votes forms a certificate $\mathcal{C}^{{q_\text{lck}}}(b)$. \item[-] \textbf{Vote 2.} On collecting $\mathcal{C}^{{q_\text{lck}}}(b)$, a replica ``locks'' on $b$ and votes for $\mathcal{C}^{{q_\text{lck}}}(b)$. \item[-] \textbf{Commit.} On collecting ${q_\text{unq}}$ votes for $b$ and ${q_\text{cmt}}$ votes for $\mathcal{C}^{{q_\text{lck}}}(b)$, a client learns that proposal $b$ becomes a committed decision. \end{itemize} If a replica locks on a value $b$ in a view, then it votes only for $b$ in subsequent views unless it ``unlocks'' from $b$ by learning that ${q_\text{ulck}}$ replicas are not locked on $b$. \end{boxedminipage} \end{figure} \begin{description}[topsep=8pt,itemsep=4pt] \item[Flexible quorum intersection (a) within a view.] Contrary to PBFT, in Flexible BFT\xspace, a pair of ${q_\text{lck}}$ certificates need not necessarily intersect in an honest replica. Indeed, locking on a value does not preclude conflicting locks. It only mandates that every ${q_\text{lck}}$ quorum intersects with every ${q_\text{unq}}$ quorum at at least one honest replica. For safety, it is essential that the fraction of faulty replicas is less than ${q_\text{lck}}+{q_\text{unq}}-1$. \item[Flexible quorum intersection (b) across views.] If a client commits a value $b$ in a view, ${q_\text{cmt}}$ replicas lock on $b$ in that view. For an honest replica among them to unlock from $b$, ${q_\text{ulck}}$ replicas need to claim they are not locked on $b$. This property mandates that every ${q_\text{ulck}}$ quorum intersects with every ${q_\text{cmt}}$ quorum at at least one honest replica. Thus, for safety, it is essential that the fraction of faulty replicas is less than ${q_\text{ulck}} + {q_\text{cmt}} - 1$. \item[Flexible quorum availability within a view.] For liveness, Byzantine replicas cannot exceed {$1-\max({q_\text{unq}}, {q_\text{cmt}}, {q_\text{lck}}, {q_\text{ulck}})$} so that the aforementioned quorums can be formed at different stages of the protocol. \end{description} Given the above analysis, Flexible BFT\xspace ensures safety if the fraction of faulty replicas is less than $\min({q_\text{unq}} + {q_\text{lck}} - 1, {q_\text{cmt}} + {q_\text{ulck}} - 1)$, and provides liveness if the fraction of Byzantine replicas is at most $1-\max({q_\text{unq}}, {q_\text{cmt}}, {q_\text{lck}}, {q_\text{ulck}})$. It is optimal to use \emph{balanced quorum sizes} where ${q_\text{lck}} = {q_\text{ulck}}$ and ${q_\text{unq}} = {q_\text{cmt}}$. To see this, first note that we should make sure ${q_\text{unq}} + {q_\text{lck}} = {q_\text{cmt}} + {q_\text{ulck}}$; otherwise, suppose the right-hand side is smaller, then setting $({q_\text{cmt}},{q_\text{ulck}})$ to equal $({q_\text{unq}},{q_\text{lck}})$ improves safety tolerance without affecting liveness tolerance. Next, observe that if we have ${q_\text{unq}} + {q_\text{lck}} = {q_\text{cmt}} + {q_\text{ulck}}$ but ${q_\text{lck}} > {q_\text{ulck}}$ (and hence ${q_\text{unq}} < {q_\text{cmt}}$), then once again setting $({q_\text{cmt}},{q_\text{ulck}})$ to equal $({q_\text{unq}},{q_\text{lck}})$ improves safety tolerance without affecting liveness tolerance. Thus, in this paper, we set ${q_\text{lck}} = {q_{r}}$ and ${q_\text{unq}} = {q_\text{cmt}} = {q_c}$. Since replicas use ${q_{r}}$ votes to lock, these votes can always be used by the clients to commit ${q_\text{cmt}}$ quorums. Thus, ${q_c} \geq {q_{r}}$. The Flexible Byzantine Quorum requirements collapse into the following two conditions. \begin{description} \item[Flexible quorum intersection.] The fraction of faulty replicas is $< {q_c} + {q_{r}} - 1$. \item[Flexible quorum availability.] The fraction of Byzantine replicas is $\leq 1-{q_c}$. \end{description} \paragraph{Tolerating a-b-c\xspace faults.} If all faults in the system are Byzantine faults, then the best parameter choice is ${q_c}={q_{r}} \geq 2/3$ for $<1/3$ fault tolerance, and Flexible Byzantine Quorums degenerate to basic Byzantine quorums. However, in our model, a-b-c\xspace replicas are only interested in attacking safety but not liveness. This allows us to tolerate ${q_c} + {q_{r}} - 1$ total faults (Byzantine plus a-b-c\xspace), which can be more than $1/3$. For example, if we set ${q_{r}} = 0.7$ and ${q_c} = 0.8$, then such a protocol can tolerate $0.2$ Byzantine faults plus $0.3$ a-b-c\xspace faults. We discuss the choice for ${q_{r}}$ and ${q_c}$ and their rationale in Section~\ref{sec:discussion}. \paragraph{Separating client commit rules from the replica protocol.} \label{sec:client-coexist-partial} A key property of the Flexible Byzantine Quorum approach is that it decouples the BFT protocol from client commit rules. The decoupling allows clients assuming different fault models to utilize the same protocol. In the above protocol, the propose and two voting steps are executed by the replicas and they are only parameterized by ${q_{r}}$. The commit step can be carried by different clients using different commit thresholds ${q_c}$. Thus, a fixed ${q_{r}}$ determines a possible set of clients with varying commit rules (in terms of Byzantine and a-b-c\xspace adversaries). Recall that a Byzantine adversary can behave arbitrarily and thus may not provide liveness whereas an a-b-c\xspace adversary only intends to attack safety but not liveness. Thus, a client who believes that a large fraction of the adversary may attempt to break safety, not progress, can choose a larger ${q_c}$. By doing so, it seeks stronger safety against dishonest replicas, while trading liveness. Conversely, a client that assumes that a large fraction of the adversary attacks liveness must choose a smaller ${q_c}$. \subsection{Safety and Liveness} \label{sec:proof} We introduce the notion of \emph{direct} and \emph{indirect} commit to aid the proofs. We say a block is committed \emph{directly} under \textbf{CR1} if the block and its immediate successor both get ${q_c}$ votes in the same view. We say a block is committed \emph{directly} under \textbf{CR2} if some honest replica reports an undisturbed-$2\Delta$ period after its successor block was obtained. We say a block is committed \emph{indirectly} if neither condition applies to it but it is committed as a result of a block extending it being committed directly. We remark that the direct commit notion, especially for \textbf{CR2}, is merely a proof technique. A client cannot tell whether a replica is honest, and thus has no way of knowing whether a block is directly committed under \textbf{CR2}. \begin{lemma} If a client directly commits a block $B_l$ in view $v$ using a correct commit rule, then a certified block that ranks no lower than $\CommitCert_{v}(B_{l})$ must equal or extend $B_l$. \label{lemma:unique-cert} \end{lemma} \begin{proof} To elaborate on the lemma, a certified block $\CommitCert_{v'}(B'_{l'})$ ranks no lower than $\CommitCert_{v}(B_{l})$ if either (i) $v'=v$ and $l' \geq l$, or (ii) $v'>v$. We need to show that if $B_l$ is directly committed, then any certified block that ranks no lower either equals or extends $B_l$. We consider the two commit rules separately. For both commit rules, we will use induction on $v'$ to prove the lemma. \bigskip For $\textbf{CR1}$ with parameter ${q_c}$ to be correct, flexible quorum intersection needs to hold, i.e., the fraction of faulty replicas must be less than ${q_c}+{q_{r}}-1$. $B_l$ being directly committed under $\textbf{CR1}$ with parameter ${q_c}$ implies that there are ${q_c}$ votes in view $v$ for $B_l$ and $B_{l+1}$ where $B_{l+1}$ extends $B_l$. For the base case, a block $B'_{l'}$ with $l'\geq l$ that does not extend $B_l$ cannot get certified in view $v$, because that would require ${q_c}+{q_{r}}-1$ replicas to vote for two equivocating blocks in view $v$. Next, we show the inductive step. Note that ${q_c}$ replicas voted for $B_{l+1}$ in view $v$, which contains $\CommitCert_{v}(B_{l})$. Thus, they lock $B_l$ or a block extending $B_l$ by the end of view $v$. Due to the inductive hypothesis, any certified block that ranks equally or higher from view $v$ up to view $v'$ either equals or extends $B_l$. Thus, by the end of view $v'$, those ${q_c}$ replicas still lock $B_l$ or a block extending $B_l$. Since the total fraction of faults is less than ${q_c}+{q_{r}}-1$, the status $\mathcal{S}$ shown by the leader of view $v'+1$ must include a certificate for $B_l$ or a block extending it; moreover, any certificate that ranks equal to or higher than $\CommitCert_{v}(B_{l})$ is for a block that equals or extends $B_l$. Thus, only a block that equals or extends $B_l$ can gather votes from those ${q_c}$ replicas in view $v'+1$ and only a block that equals or extends $B_l$ can get certified in view $v'+1$. \bigskip For $\textbf{CR2}$ with synchrony bound $\Delta$ to be correct, $\Delta$ must be an upper bound on worst case message delay and the fraction of faulty replicas is less than ${q_{r}}$. $B_l$ being directly committed under $\textbf{CR2}$ with $\Delta$-synchrony implies that at least one honest replica voted for $B_{l+1}$ extending $B_l$ in view $v$, and did not hear an equivocating block or view change within $2\Delta$ time after that. Call this replica $h$. Suppose $h$ voted for $B_{l+1}$ extending $B_l$ in view $v$ at time $t$, and did not hear an equivocating block or view change by time $t+2\Delta$. We first show the base case: a block $B'_{l'}$ with $l'\geq l$ certified in view $v$ must equal or extend $B_l$. Observe that if $B'_{l'}$ with $l'\geq l$ does not equal or extend $B_l$, then it equivocates $B_l$. No honest replica voted for $B'_{l'}$ before time $t+\Delta$, because otherwise $h$ would have received the vote for $B'_{l'}$ by time $t+2\Delta$, No honest replica would vote for $B'_{l'}$ after time $t+\Delta$ either, because by then they would have received (from $h$) and voted for $B_l$. Thus, $B'_{l'}$ cannot get certified in view $v$. We then show the inductive step. Because $h$ did not hear view change by time $t+2\Delta$, all honest replicas are still in view $v$ by time $t+\Delta$, which means they all receive $B_{l+1}$ from $h$ by the end of view $v$. Thus, they lock $B_l$ or a block extending $B_l$ by the end of view $v$. Due to the inductive hypothesis, any certified block that ranks equally or higher from view $v$ up to view $v'$ either equals or extends $B_l$. Thus, by the end of view $v'$, all honest replicas still lock $B_l$ or a block extending $B_l$. Since the total fraction of faults is less than ${q_{r}}$, the status $\mathcal{S}$ shown by the leader of view $v'+1$ must include a certificate for $B_l$ or a block extending it; moreover, any certificate that ranks equal to or higher than $\CommitCert_{v}(B_{l})$ is for a block that equals or extends $B_l$. Thus, only a block that equals or extends $B_l$ can gather honest votes in view $v'+1$ and only a block that equals or extends $B_l$ can get certified in view $v'+1$. \end{proof} \begin{theorem}[Safety] Two clients with correct commit rules commit the same block $B_k$ for each height $k$. \label{thm:safety} \end{theorem} \begin{proof} Suppose for contradiction that two distinct blocks $B_k$ and $B'_k$ are committed at height $k$. Suppose $B_k$ is committed as a result of $B_{l}$ being directly committed in view $v$ and $B'_k$ is committed as a result of $B'_{l'}$ being directly committed in view $v'$. This implies $B_l$ is or extends $B_k$; similarly, $B'_{l'}$ is or extends $B'_k$. Without loss of generality, assume $v \leq v'$. If $v=v'$, further assume $l \leq l'$ without loss of generality. By Lemma~\ref{lemma:unique-cert}, the certified block $\CommitCert_{v'}(B'_{l'})$ must equal or extend $B_l$. Thus, $B'_k=B_k$. \end{proof} \begin{theorem}[Liveness] If all clients have correct commit rules, they all keep committing new blocks. \label{thm:liveness} \end{theorem} \begin{proof} By the definition of a-b-c\xspace faults, if they cannot violate safety, they will preserve liveness. Theorem~\ref{thm:safety} shows that if all clients have correct commit rules, then safety is guaranteed \emph{even if a-b-c\xspace replicas behave arbitrarily}. Thus, once we proved safety, we can treat a-b-c\xspace replicas as honest when proving liveness. Observe that a correct commit rule tolerates at most $1-{q_{r}}$ Byzantine faults. If a Byzantine leader prevents liveness, there will be ${q_{r}}$ blame messages against it, and a view change will ensue to replace the leader. Eventually, a non-Byzantine (honest or a-b-c\xspace) replica becomes the leader and drives consensus in new heights. If replicas use increasing timeouts, eventually, all non-Byzantine replicas stay in the same view for sufficiently long. When both conditions occur, if a client's commit rule is correct (either \textbf{CR1} and \textbf{CR2}), due to quorum availability, it will receive enough votes in the same view to commit. \end{proof} \section{Flexible BFT Protocol} \label{sec:protocol} In this section, we combine the ideas presented in Sections~\ref{sec:overv-synchr-flex} and \ref{sec:overview-async} to obtain a final protocol that supports both types of clients. A client can either assume partial synchrony, with freedom to choose ${q_c}$ as described in the previous section, or assume synchrony with its own choice of $\Delta$, as described in Section~\ref{sec:overv-synchr-flex}. Replicas execute a protocol at the network speed with a parameter ${q_{r}}$. We first give the protocol executed by the replicas and then discuss how clients commit depending on their assumptions. Moreover, inspired by Casper~\cite{DBLP:journals/corr/abs-1710-09437} and HotStuff~\cite{yin2018hotstuff}, we show a protocol where the rounds of voting can be pipelined. \subsection{Notation} Before describing the protocol, we will first define some data structures and terminologies that will aid presentation. \paragraph{Block format.} The pipelined protocol forms a chain of values. We use the term \emph{block} to refer to each value in the chain. We refer to a block's position in the chain as its \emph{height}. A block $B_k$ at height $k$ has the following format $$B_k := (b_k, h_{k-1})$$ where $b_k$ denotes a proposed value at height $k$ and $h_{k-1} := H(B_{k-1})$ is a hash digest of the predecessor block. The first block $B_1=(b_1, \bot)$ has no predecessor. Every subsequent block $B_k$ must specify a predecessor block $B_{k-1}$ by including a hash of it. We say a block is \emph{valid} if (i) its predecessor is valid or $\bot$, and (ii) its proposed value meets application-level validity conditions and is consistent with its chain of ancestors (e.g., does not double spend a transaction in one of its ancestor blocks). \paragraph{Block extension and equivocation.} We say $B_l$ \emph{extends} $B_k$, if $B_k$ is an ancestor of $B_l$ ($l>k$). We say two blocks $B_l$ and $B'_{l'}$ \emph{equivocate} one another if they are not equal and do not extend one another. \paragraph{Certificates and certified blocks.} In the protocol, replicas vote for blocks by signing them. We use $\CommitCert_{v}{(B_{k})}$ to denote a set of signatures on $h_{k} = H(B_{k})$ by ${q_{r}}$ replicas in view $v$. ${q_{r}}$ is a parameter fixed for the protocol instance. We call $\CommitCert_{v}{(B_{k})}$ a certificate for $B_{k}$ from view $v$. Certified blocks are ranked first by the views in which they are certified and then by their heights. In other words, a block $B_k$ certified in view $v$ is ranked \emph{higher} than a block $B_{k'}$ certified in view $v'$ if either (i) $v > v'$ or (ii) $v = v'$ and $k>k'$. \paragraph{Locked blocks.} At any time, a replica locks the highest certified block to its knowledge. During the protocol execution, each replica keeps track of all signatures for all blocks and keeps updating its locked block. Looking ahead, the notion of locked block will be used to guard the safety of a client commit. \subsection{Replica Protocol} The replica protocol progresses in a view-by-view fashion. Each view has a designated leader who is responsible for driving consensus on a sequence of blocks. Leaders can be chosen statically, e.g., round robin, or randomly using more sophisticated techniques~\cite{CKS05,Algorand}. In our description, we assume a round robin selection of leaders, i.e., ($v$ {\sf mod} $n$) is the leader of view $v$. At a high level, the protocol does the following: The leader proposes a block to all replicas. The replicas vote on it if safe to do so. The block becomes certified once ${q_{r}}$ replicas vote on it. The leader will then propose another block extending the previous one, chaining blocks one after another at increasing heights. Unlike regular consensus protocols where replicas determine when a block is committed, in Flexible BFT\xspace, replicas only certify blocks while committing is offloaded to the clients. If at any time replicas detect malicious leader behavior or lack of progress in a view, they blame the leader and engage in a view change protocol to replace the leader and move to the next view. The new leader collects a status from different replicas and continues to propose blocks based on this status. We explain the steady state and view change protocols in more detail below. \begin{figure*}[tb] \centering \begin{boxedminipage}{\textwidth} Let $v$ be the current view number and replica $L$ be the leader in this view. Perform the following steps in an iteration. \begin{enumerate}[topsep=8pt,itemsep=8pt,leftmargin=*] \setlength\itemsep{0.5em} \item \textbf{Propose. } \label{step:propose} \Comment{Executed by the leader of view $v$} The leader $L$ broadcasts $\sig{\mathsf{propose}, B_k, v, \CommitCert_{v'}(B_{k-1}), \mathcal{S}}_L$. Here, $B_k := (b_k, h_{k-1})$ is the newly proposed block and it should extend the highest certified block known to $L$. In the steady state, an honest leader $L$ would extend the previous block it proposed, in which case $v'=v$ and $\mathcal{S} = \bot$. Immediately after a view change, $L$ determines the highest certified block from the status $\mathcal{S}$ received during the view change. \item \label{step:vote} \textbf{Vote.} \Comment{Executed by all replicas} When a replica $R$ receives a valid proposal $\sig{\mathsf{propose}, B_k, v, \CommitCert_{v'}(B_{k-1}), \mathcal{S}}_L$ from the leader $L$, $R$ broadcasts the proposal and a vote $\sig{\mathsf{vote}, B_k, v}_R$ if (i) the proposal is the first one in view $v$, and it extends the highest certified block in $\mathcal{S}$, or (ii) the proposal extends the last proposed block in the view. In addition, replica $R$ records the following based on the messages it receives. \begin{itemize}[topsep=8pt,itemsep=4pt] \item[-] $R$ keeps track of the number of votes received for this block in this view as $q_{B_{k},v}$. \item[-] If block $B_{k-1}$ has been proposed in view $v$, $R$ marks $B_{k-1}$ as a locked block and records the locked time as ${\mathsf{t\text{-}{lock}}}_{k-1,v}$. \item[-] If a block equivocating $B_{k-1}$ is proposed by $L$ in view $v$ (possibly received through a vote), $R$ records the time ${\mathsf{t}\text{-}\mathsf{equiv}}_{k-1,v}$ at which the equivocating block is received. \end{itemize} The replica then enters the next iteration. If the replica observes no progress or equivocating blocks in the same view $v$, it stops voting in view $v$ and sends $\sig{\mathsf{view\text{-}change},v}_r$ message to all replicas. \end{enumerate} \end{boxedminipage} \caption{Flexible BFT steady state protocol.} \label{fig:steady} \end{figure*} \paragraph{Steady state protocol.} The steady state protocol is described in Figure~\ref{fig:steady}. In the steady state, there is a unique leader who, in an iteration, proposes a block, waits for votes from ${q_{r}}$ replicas and moves to the next iteration. In the steady state, an honest leader always extends the previous block it proposed. Immediately after a view change, since the previous leaders could have been Byzantine and may have proposed equivocating blocks, the new leader needs to determine a safe block to propose. It does so by collecting a status of locked blocks from ${q_{r}}$ replicas denoted by $\mathcal{S}$ (described in the view change protocol). For a replica $R$ in the steady state, on receiving a proposal for block $B_{k}$, a replica votes for it if it extends the previous proposed block in the view or if it extends the highest certified block in $\mathcal{S}$. Replica $R$ can potentially receive blocks out of order and thus receive $B_{k}$ before its ancestor blocks. In this case, replica $R$ waits until it receives the ancestor blocks, verifies the validity of those blocks and $B_k$ before voting for $B_k$. In addition, replica $R$ records the following to aid a client commit: \begin{itemize} \item[-] \textbf{Number of votes.} It records the number of votes received for $B_{k}$ in view $v$ as $q_{B_{k}, v}$. Observe that votes are broadcast by all replicas and the number of votes for a block can be greater than ${q_{r}}$. $q_{B_{k}, v}$ will be updated each time the replica hears about a new vote in view $v$. \item[-] \textbf{Lock time.} If $B_{k-1}$ was proposed in the same view $v$, it locks $B_{k-1}$ and records the locked time as ${\mathsf{t\text{-}{lock}}}_{k-1, v}$. \item[-] \textbf{Equivocation time.} If the replica ever observes an equivocating block at height $k$ in view $v$ through a proposal or vote, it stores the time of equivocation as ${\mathsf{t}\text{-}\mathsf{equiv}}_{k,v}$. \end{itemize} Looking ahead, the locked time ${\mathsf{t\text{-}{lock}}}_{k-1,v}$ and equivocation time ${\mathsf{t}\text{-}\mathsf{equiv}}_{k-1,v}$ will be used by clients with synchrony assumptions to commit, and the number of votes $q_{B_{k}, v}$ will be used by clients with partial-synchrony assumptions to commit. \paragraph{Leader monitoring.} If a replica detects a lack of progress in view $v$ or observes malicious leader behavior such as more than one height-$k$ blocks in the same view, it blames the leader of view $v$ by broadcasting a $\sig{\mathsf{view\text{-}change}, v}$ message. It quits view $v$ and stops voting and broadcasting blocks in view $v$. To determine lack of progress, the replicas may simply guess a time bound for message arrival or use increasing timeouts for each view~\cite{castro1999practical}. \paragraph{View change.} The view change protocol is described in Figure~\ref{fig:vc}. If a replica gathers ${q_{r}}$ $\sig{\mathsf{view\text{-}change}, v}$ messages from distinct replicas, it forwards them to all other replicas and enters a new view $v + 1$ (Step~\ref{step:new_view}). It records the time at which it received the blame certificate as ${\mathsf{t\text{-}{viewchange}}}_{v}$. Upon entering a new view, a replica reports to the leader of the new view $L'$ its locked block and transitions to the steady state (Step~\ref{step:status}). ${q_{r}}$ status messages form the status $\mathcal{S}$. The first block $L'$ proposes in the new view should extend the highest certified block among these ${q_{r}}$ status messages. \begin{figure*}[htbp] \centering \begin{boxedminipage}{\textwidth} Let $L$ and $L'$ be the leaders of views $v$ and $v+1$, respectively. \begin{enumerate}[topsep=8pt,itemsep=8pt,leftmargin=*,label=(\roman*)] \setlength\itemsep{0.5em} \item \label{step:new_view} \textbf{New-view.} Upon gathering ${q_{r}}$ $\sig{\mathsf{view\text{-}change}, v}$ messages, broadcast them and enter view $v+1$. Record the time as ${\mathsf{t\text{-}{viewchange}}}_{v}$. \item \label{step:status} \textbf{Status.} Suppose $B_j$ is the block locked by the replica. Send a status of its locked block to the leader $L'$ using $\sig{\mathsf{status}, v, B_j, \CommitCert_{v'}(B_j)}$ and transition to the steady state. Here, $v'$ is the view in which $B_j$ was certified. \end{enumerate} \end{boxedminipage} \caption{Flexible BFT view change protocol.} \label{fig:vc} \end{figure*} \subsection{Client Commit Rules} \label{sec:commit-rules} \begin{figure*}[htbp] \centering \begin{boxedminipage}{\textwidth} \begin{enumerate}[itemsep=8pt,leftmargin=0.2cm,label=] \item \textbf{(CR1) Partially-synchronous commit.} A block $B_k$ is committed under the partially synchronous rule with parameter ${q_c}$ iff there exist $l \geq k$ and $v$ such that \begin{enumerate}[topsep=8pt,itemsep=4pt] \item $\CommitCert_{v}(B_l)$ and $\CommitCert_{v}(B_{l+1})$ exist where $B_{l+1}$ extends $B_l$ and $B_k$ (if $l = k$, $B_l = B_k$). \item $q_{B_{l}, v} \geq {q_c}$ and $q_{B_{l+1}, v} \geq {q_c}$. \end{enumerate} \item \textbf{(CR2) Synchronous commit.} A block $B_k$ is committed assuming $\Delta-$synchrony iff the following holds for ${q_{r}}$ replicas. There exist $l \geq k$ and $v$ (possibly different across replicas) such that, \begin{enumerate}[topsep=8pt,itemsep=4pt] \item $\CommitCert_{v}(B_l)$ exists where $B_l$ extends $B_k$ (if $l = k$, $B_l = B_k$). \item An undisturbed-$2\Delta$ period is observed after $B_{l+1}$ is obtained, i.e., no equivocating block or view change of view $v$ were observed before $2\Delta$ time after $B_{l+1}$ was obtained, i.e., $$\min({\mathsf{current}\text{-}\mathsf{time}}, {\mathsf{t}\text{-}\mathsf{equiv}}_{l,v}, {\mathsf{t\text{-}{viewchange}}}_v) - {\mathsf{t\text{-}{lock}}}_{l,v} \geq 2\Delta$$ \end{enumerate} \end{enumerate} \end{boxedminipage} \caption{Flexible BFT commit rules} \label{fig:commit-rules} \end{figure*} As mentioned in the introduction, Flexible BFT\xspace supports clients with different assumptions. Clients in Flexible BFT\xspace learn the state of the protocol from the replicas and based on their own assumptions determine whether a block has been committed. Broadly, we supports two types of clients: those who believe in synchrony and those who believe in partial synchrony. \subsubsection{Clients with Partial-Synchrony Assumptions (CR1)} A client with partial-synchrony assumptions deduces whether a block has been committed by based on the number of votes received by a block. A block $B_l$ (together with its ancestors) is committed with parameter ${q_c}$ iff $B_l$ and its immediate successor both receive $\geq {q_c}$ votes in the same view. \paragraph{Safety of CR1.} A CR1 commit based on ${q_c}$ votes is safe against $<{q_c}+{q_{r}}-1$ faulty replicas (Byzantine plus a-b-c\xspace). Observe that if $B_l$ gets ${q_c}$ votes in view $v$, due to flexible quorum intersection, a conflicting block cannot be certified in view $v$, unless $\geq {q_c}+{q_{r}}-1$ replicas are faulty. Moreover, $B_{l+1}$ extending $B_l$ has also received ${q_c}$ votes in view $v$. Thus, ${q_c}$ replicas lock block $B_l$ in view $v$. In subsequent views, honest replicas that have locked $B_l$ will only vote for a block that equals or extends $B_l$ unless they unlock. However, due to flexible quorum intersection, they will not unlock unless $\geq {q_c}+{q_{r}}-1$ replicas are faulty. Proof of Lemma~\ref{lemma:unique-cert} formalizes this argument. \subsubsection{Client with Synchrony Assumptions (CR2)} Intuitively, a CR2 commit involves ${q_{r}}$ replicas collectively stating that no ``bad event'' happens within ``sufficient time'' in a view. Here, a bad event refers to either leader equivocation or view change (the latter indicates sufficient replicas believe leader is faulty) and the ``sufficient time'' is $2\Delta$; where $\Delta$ is a synchrony bound chosen by the client. More formally, a replica states that a synchronous commit for block $B_k$ for a given parameter $\Delta$ (set by a client) is satisfied iff the following holds. There exists $B_{l+1}$ that extends $B_l$ and $B_k$, and the replica observes an undisturbed-$2\Delta$ period after obtaining $B_{l+1}$ during which (i) no equivocating block is observed, and (ii) no blame certificate/view change certificate for view $v$ was obtained, i.e., $$\min({\mathsf{current}\text{-}\mathsf{time}}, {\mathsf{t}\text{-}\mathsf{equiv}}_{l,v}, {\mathsf{t\text{-}{viewchange}}}_v) - {\mathsf{t\text{-}{lock}}}_{l,v} \geq 2\Delta$$ where ${\mathsf{t}\text{-}\mathsf{equiv}}_{l,v}$ denotes the time equivocation for $B_l$ in view $v$ was observed ($\infty$ if no equivocation), ${\mathsf{t\text{-}{viewchange}}}_v$ denotes the time at which view change happened from view $v$ to $v + 1$ ($\infty$ if no view change has happened yet), and ${\mathsf{t\text{-}{lock}}}_{l,v}$ denotes the time at which $B_l$ was locked (or $B_{l+1}$ was proposed) in view $v$. Note that the client does not require the ${q_{r}}$ fraction of replicas to report the same height $l$ or view $v$. \paragraph{Safety of CR2.} A client believing in synchrony assumes that all messages between replicas arrive within $\Delta$ time after they were sent. If the client's chosen $\Delta$ is a correct upper bound on message delay, then a CR2 commit is safe against ${q_{r}}$ faulty replicas (Byzantine plus a-b-c\xspace), as we explain below. If less than ${q_{r}}$ replicas are faulty, at least one honest replica reported an \emph{undisturbed-$2\Delta$} period. Let us call this honest replica $h$ and analyze the situation from $h$'s perspective to explain why an undisturbed $2\Delta$ period ensures safety. Observe that replicas in Flexible BFT\xspace forward the proposal when voting. If $\Delta$-synchrony holds, every other honest replica learns about the proposal $B_l$ at most $\Delta$ time after $h$ learns about it. If any honest replica voted for a conflicting block or quit view $v$, $h$ would have known within $2\Delta$ time. \input{proof} \subsection{Efficiency} \paragraph{Latency.} Clients with a synchrony assumption incur a latency of $2\Delta$ plus a few network speed rounds. In terms of the maximum network delay $\Delta$, this matches the state-of-the-art synchronous protocols~\cite{abraham2019sync}. The distinction though is that $\Delta$ now depends on the client assumption and hence different clients may commit with different latencies Clients with partial-synchrony assumptions incur a latency of two rounds of voting; this matches PBFT~\cite{castro1999practical}. \paragraph{Communication.} Every vote and new-view messages are broadcast to all replicas, incurring $O(n^2)$ communication messages. This is the same complexity of PBFT~\cite{castro1999practical} and Sync HotStuff~\cite{abraham2019sync}. \section{Related Work} \label{sec:related-work} \begin{figure}[htbp] \centering \begin{subfigure}{0.45\textwidth} \includegraphics[width=1\linewidth]{compare.pdf} \end{subfigure} \begin{subfigure}{0.45\textwidth} \begin{tabular}{c l} $+$ & Partially Synchronous protocols~\cite{castro1999practical,Yin03,Martin06,Zyzzyva07,yin2018hotstuff,buchman2016tendermint}\\ $\times$ & Synchronous Protocols~\cite{pass2018thunderella,hanke2018dfinity,abraham2019sync,abraham2018synchronous}\\ $\blacktriangle$ & Thunderella, Sync HotStuff ($\vartriangle$: optimistic)~\cite{pass2018thunderella,abraham2019sync}\\ $\blacklozenge$ & Zyzzyva, SBFT ($\lozenge$: optimistic)~\cite{Zyzzyva07} \end{tabular} \end{subfigure} \caption{\textbf{Comparing Flexible BFT\xspace to existing consensus protocols.} The legend represent different ${q_{r}}$ values.} \label{fig:compare} \end{figure} Most BFT protocols are designed with a uniform assumption about the system. The literature on BFT consensus is vast and is largely beyond scope for review here; we refer the reader to the standard textbooks in distributed computing~\cite{lynch1996distributed,attiya2004distributed}. \paragraph{Resilience.} Figure~\ref{fig:compare} compares resilience in Flexible BFT\xspace with some existing consensus protocols. The x axis represents a Byzantine resilience threshold, the y axis the total resilience against corruption under the a-b-c\xspace fault mode. The three different colors (red, green, blue) represent three possible instantiations of Flexible BFT\xspace at different ${q_{r}}$'s. Each point in the figure represents an abstract ``client'' belief. For the partial synchrony model, client beliefs form lines, and for synchronous settings, clients beliefs are individual circles. The locus of points on a given color represents all client assumptions supported for a corresponding ${q_{r}}$, representing the diversity of clients supported. The figure depicts state-of-art resilience combinations by existing consensus solutions via uncolored shapes, $+, \times, \vartriangle, \blacktriangle, \lozenge, \blacklozenge$. Partially synchronous protocols~\cite{castro1999practical, yin2018hotstuff,buchman2016tendermint} that tolerate one-third Byzantine faults can all be represented by the `+' symbol at $(1/3, 1/3)$. Similarly, synchronous protocols~\cite{hanke2018dfinity,abraham2018dfinity,abraham2018synchronous} that tolerate one-half Byzantine faults are represented by the `$\times$' symbol at $(1/2, 1/2)$. It is worth noting that some of these works employ two commit rules that differ in number of votes or synchrony~\cite{Martin06,Zyzzyva07,pass2018thunderella,abraham2019sync}. For instance, Thunderella and Sync HotStuff optimistically commit in an asynchronous fashion based on quorums of size $\geq 3/4$, as represented by a hollow triangle at $(1/4, 1/2)$. Similarly, FaB~\cite{Martin06}, Zyzzyva~\cite{Zyzzyva07} and SBFT~\cite{gueta2018sbft} optimistically commit when they receive all votes but wait for two rounds of votes otherwise. These are represented by two points in the figure. Despite the two commit rules, these protocols do not have client diversity, all parties involved (replicas and clients) make the same assumptions and reach the same commit decisions. \paragraph{Diverse client beliefs.} A simple notion of client diversity exists in Bitcoin's probabilistic commit rule. One client may consider a transaction committed after six confirmations while another may require only one confirmation. Generally, the notion of client diversity has been discussed informally at public blockchain forums. Another example of diversity is considered in the XFT protocol~\cite{XFT}. The protocol supports two types of clients: clients that assume crash faults under partial synchrony, or clients that assume Byzantine faults but believe in synchrony. Yet another notion of diversity is considered by the federated Byzantine consensus model and the Stellar protocol~\cite{mazieres2015stellar}. The Stellar protocol allows nodes to pick their own quorums. Our Flexible BFT\xspace approach instead considers diverse clients in terms of a-b-c\xspace adversaries and synchrony. The model and techniques in~\cite{mazieres2015stellar} and our paper are largely orthogonal and complementary. \paragraph{Flexible Paxos.} Flexible Paxos by Howard et al.~\cite{DBLP:conf/opodis/HowardMS16} observes that Paxos may use non-intersecting quorums within a view but an intersection is required across views. Our Flexible Quorum Intersection (b) can be viewed as its counterpart in the Byzantine and a-b-c\xspace setting. In addition, Flexible BFT\xspace applies the flexible quorum idea to support diverse clients with different fault model and timing assumptions. \paragraph{Mixed fault model.} Fault models that mix Byzantine and crash faults have been considered in various works, e.g., FaB~\cite{Martin06} and SBFT~\cite{abraham2019sync}. The a-b-c\xspace faults are in a sense the opposite of crash faults, mixing Byzantine with ``anti-crashes''. Our a-b-c\xspace adversary bears similarity to a rational adversary in the BAR model~\cite{aiyer2005bar}, with several important differences. BAR assumes no collusion exists among rational replicas themselves and between rational and Byzantine replicas, whereas a-b-c\xspace replicas have no such constraint. BAR solutions are designed to expose cheating behavior and thus deter rational replicas from cheating. The Flexible BFT\xspace approach does not rely on deterrence for good behavior, and breaks beyond the $1/3$ ($1/2$) corruption tolerance threshold in asynchronous (synchronous) systems. Last, BAR solutions address only the partial synchrony settings. At the same time, BAR provides a game theoretic proof of rationality. More generally, game theoretical modeling and analysis with collusion have been performed to other problems such as secret sharing and multiparty computation~\cite{abraham2006distributed,lysyanskaya2006rationality,gordon2006rational,kol2008cryptography}. Analyzing incentives for the a-b-c\xspace model remains an open challenge. \section{Synchronous BFT with Network Speed Replicas - Overview} \label{sec:overv-synchr-flex} \begin{figure*}[ht] \begin{boxedminipage}{\textwidth} \paragraph{Protocol executed by the replicas.} \begin{enumerate} \setlength\itemsep{0.5em} \item \textbf{Propose. } \label{step:sync-propose} The leader $L$ of view $v$ proposes a value $b$. \item \textbf{Vote.} \label{step:sync-vote} On receiving the first value $b$ in a view $v$, a replica broadcasts $b$ and votes for $b$ if it is \emph{safe} to do so, as determined by a locking mechanism described later. The replica records the following. \begin{itemize} \item[-] If the replica collects ${q_{r}}$ votes on $b$, denoted as $\mathcal{C}^{q_{r}}_v(b)$ and called a certificate of $b$ from view $v$, then it ``locks'' on $b$ and records the lock time as ${\mathsf{t\text{-}{lock}}}_v$. \item[-] If the replica observes an equivocating value signed by $L$ at any time after entering view $v$, it records the time of equivocation as ${\mathsf{t}\text{-}\mathsf{equiv}}_v$. It blames the leader by broadcasting $\sig{\mathsf{view\text{-}change}, v}$ and the equivocating values. \item[-] If the replica does not receive a proposal for sufficient time in view $v$, it times out and broadcasts $\sig{\mathsf{view\text{-}change}, v}$. \item[-] If the replica collects a set of ${q_{r}}$ $\sig{\mathsf{view\text{-}change}, v}$ messages, it records the time as ${\mathsf{t\text{-}{viewchange}}}_v$, broadcasts them and enters view $v+1$. \end{itemize} \end{enumerate} If a replica locks on a value $b$ in a view, then it votes only for $b$ in subsequent views unless it ``unlocks'' from $b$ by learning that ${q_{r}}$ replicas are not locked on $b$ in that view or higher views (they may be locked on other values or they may not be locked at all). \paragraph{Commit rules for clients.} A value $b$ is said to be committed by a client assuming $\Delta$-synchrony iff ${q_{r}}$ replicas each report that there exists a view $v$ such that, \begin{enumerate} \item $b$ is certified, i.e., $\mathcal{C}^{q_{r}}_v(b)$ exists. \item the replica observed an undisturbed-$2\Delta$ period after certification, i.e., no equivocating value or view change was observed at a time before $2\Delta$ after it was certified, or more formally, $\min({\mathsf{current}\text{-}\mathsf{time}}, {\mathsf{t}\text{-}\mathsf{equiv}}_v, {\mathsf{t\text{-}{viewchange}}}_v) - {\mathsf{t\text{-}{lock}}}_v \geq 2\Delta$ \end{enumerate} \end{boxedminipage} \caption{Synchronous BFT with network speed replicas.} \label{fig:sync-bft} \end{figure*} Early synchronous protocols~\cite{DS83,katz2009expected,micali2017optimal} have relied on synchrony in two ways. First, the replicas assume a maximum network delay $\Delta$ for communication between them. Second, they require a lock step execution, i.e., all replicas are in the same round at the same time. Hanke et al. showed a synchronous protocol without lock step execution~\cite{hanke2018dfinity}. Their protocol still contains a synchronous step in which all replicas perform a blocking wait of $2\Delta$ time before proceeding to subsequent steps. Sync HotStuff~\cite{abraham2019sync} improves on it further to remove replicas' blocking waits during good periods (when the leader is honest), but blocking waits are still required by replicas during bad situations (view changes). In this section, we show a synchronous protocol where the replicas do not ever have blocking waits and execute at the network speed. In other words, replicas run a partially synchronous protocol and do not rely on synchrony at any point. Clients, on the other hand, rely on synchrony bounds to commit. This separation is what allows our protocol to support clients with different assumptions on the value of $\Delta$. To the best of our knowledge, this is the first synchronous protocol to achieve such a separation. In addition, the protocol tolerates a combined Byzantine plus a-b-c\xspace fault ratio greater than a half (Byzantine fault tolerance is still less than half). For simplicity, in this overview, we show a protocol for single shot consensus. In our final protocol in Section~\ref{sec:protocol}, we will consider a pipelined version of the protocol for consensus on a sequence of values. We do not consider termination for the single-shot consensus protocol in this overview because our final replication protocol is supposed to run forever. The protocol is shown in Figure~\ref{fig:sync-bft}. It runs in a sequence of views. Each view has a designated leader who may be selected in a round robin order. The leader drives consensus in that view. In each view, the protocol runs in two steps -- propose and vote. In the propose step, the leader proposes a value $b$. In the vote step, replicas vote for the value if it is \emph{safe} to do so. The vote also acts as a \emph{re-proposal} of the value. If a replica observes a set of ${q_{r}}$ votes on $b$, called a certificate $\CommitCert(b)$, it ``locks'' on $b$. For now, we assume ${q_{r}} = 1/2$. (To be precise, ${q_{r}}$ is slight larger than 1/2, e.g., $f+1$ out of $2f+1$.) We will revisit the choice of ${q_{r}}$ in Section~\ref{sec:discussion}. In subsequent views, a replica will not vote for a value other than $b$ unless it learns that ${q_{r}}$ replicas are not locked on $b$. In addition, the replicas switch views (i.e., change leader) if they either observe an equivocation or if they do not receive a proposal from the leader within some timeout. A client commits $b$ if ${q_{r}}$ replicas state that there exists a view in which $b$ is certified and no equivocating value or view change was observed at a time before $2\Delta$ after it was certified. Here, $\Delta$ is the maximum network delay the client believes in. The protocol ensures safety if there are fewer than ${q_{r}}$ faulty replicas. The key argument for safety is the following: If an honest replica $h$ satisfies the commit condition for some value $b$ in a view, then (a) no other value can be certified and (b) all honest replicas are locked on $b$ at the end of that view. To elaborate, satisfying the commit condition implies that some honest replica $h$ has observed an undisturbed-$2\Delta$ period after it locked on $b$, i.e., it did not observe an equivocation or a view change. Suppose the condition is satisfied at time $t$. This implies that other replicas did not observe an equivocation or a view change before $t-\Delta$. The two properties above hold if the quorum honesty conditions described below hold. For liveness, if Byzantine leaders equivocate or do not propose a safe value, they will be blamed by both honest and a-b-c\xspace replicas and a view change will ensue. Eventually there will be an honest or a-b-c\xspace leader to drive consensus if quorum availability holds. \begin{description}[topsep=8pt,itemsep=4pt] \item[Quorum honesty (a) within a view.] Since the undisturbed period starts after $b$ is certified, $h$ must have voted (and re-proposed) $b$ at a time earlier than $t-2\Delta$. Every honest replica must have received $b$ before $t - \Delta$. Since they had not voted for an equivocating value by then, they must have voted for $b$. Since the number of faults is less than ${q_{r}}$, every certificate needs to contain an honest replica's vote. Thus, no certificate for any other value can be formed in this view. \item[Quorum honesty (b) across views.] $h$ sends $\mathcal{C}^{q_{r}}_v(b)$ at time $t-2\Delta$. All honest receive $\mathcal{C}^{q_{r}}_v(b)$ by time $t-\Delta$ and become locked on $b$. For an honest replica to unlock from $b$ in subsequent views, ${q_{r}}$ replicas need to claim that they are not locked on $b$. At least one of them is honest and would need to falsely claim it is not locked, which cannot happen. \item[Quorum availability.] Byzantine replicas do not exceed $1-{q_{r}}$ so that ${q_{r}}$ replicas respond to the leader. \end{description} \paragraph{Tolerating a-b-c\xspace faults.} If we have only honest and Byzantine replicas (and no a-b-c\xspace replicas), quorum honesty requires the fraction of Byzantine replicas $B < {q_{r}}$. Quorum availability requires $B \leq 1-{q_{r}}$. If we optimize for maximizing $B$, we obtain ${q_{r}} \geq 1/2$. Now, suppose $P$ represents the fraction of a-b-c\xspace replicas. Quorum honesty requires $B + P < {q_{r}}$, and quorum availability requires $B \leq 1-{q_{r}}$. Thus, the protocol supports varying values of $B$ and $P$ at different values of ${q_{r}} > 1/2$ such that safety and liveness are both preserved. \paragraph{Separating client synchrony assumption from the replica protocol.} The most interesting aspect of this protocol is the separation of the client commit rule from the protocol design. In particular, although this is a synchronous protocol, the replica protocol does not rely on any synchrony bound. This allows clients to choose their own message delay bounds. Any client that uses a correct message delay bound enjoys safety.
{'timestamp': '2019-06-03T02:02:53', 'yymm': '1904', 'arxiv_id': '1904.10067', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.10067'}
arxiv
\subsection*{Keywords} Learning, Reinforcement Learning, Imitation Learning, Sample Efficiency, Games. \subsection*{Competition type} Regular. \section{Competition description} \input{sections/competititon_description/background_impact} \input{sections/competititon_description/novelty} \input{sections/competititon_description/data} \input{sections/competititon_description/tasks} \input{sections/competititon_description/metrics} \input{sections/competititon_description/baselines_code_materials} \input{sections/competititon_description/tutorial_docs} \section{Organizational aspects} \input{sections/organization} \section{Resources} \input{sections/resources} \bibliographystyle{plainnat} \subsection{Background and impact} Many of the recent, most celebrated successes of artificial intelligence (AI), such as AlphaStar, AlphaGo, OpenAI Five, and their derivative systems, utilize deep reinforcement learning to achieve human or super-human level performance in sequential decision-making tasks. As established by~\citet{amodei_hednandez_2018}, these improvements to the state-of-the-art have thus far required exponentially increasing computational power to achieve such performance. In part, this is due to an increase in the computation required per environment-sample; however, the most significant change is the number of environment-samples required for training. For example, DQN~\cite{mnih2015human}, A3C~\cite{mnih2016asynchronous}, and Rainbow DQN~\cite{hessel2018rainbow} have been applied to ATARI 2600 games~\cite{bellemare2013arcade} and require from 44 to over 200 million frames (200 to over 900 hours) to achieve human-level performance. On more complex domains: OpenAI Five utilizes 11,000+ years of Dota 2 gameplay~\cite{openai_2018}, AlphaGoZero uses 4.9 million games of self-play in Go~\cite{silver2017mastering}, and AlphaStar uses 200 years of Starcraft~II gameplay~\cite{deepmind}. Due to the growing computational requirements, a shrinking portion of the AI community has the resources to improve these systems and reproduce state-of-the-art results. Additionally, the application of many reinforcement learning techniques to real-world challenges, such as self-driving vehicles, is hindered by the raw number of required samples. In these real-world domains, policy roll-outs can be costly and simulators are not yet accurate enough to yield policies robust to real-world conditions. One well-known way to reduce the environment sample-complexity of the aforementioned methods is to leverage human priors and demonstrations of the desired behavior. Techniques utilizing trajectory examples, such as imitation learning and Bayesian reinforcement learning, have been successfully applied to older benchmarks and real-world problems where samples from the environment are costly. In many simple games with singular tasks, such as the Atari 2600, OpenAI Gym, and TORCS environments, imitation learning can drastically reduce the number of environment samples needed through pretraining and hybrid RL techniques~\cite{hester2018deep, cruz2017pre, panse2018imitation, gao2018reinforcement}. Further, in some real-world tasks, such as robotic manipulation~\cite{finn2017one, finn2016guided} and self-driving~\cite{bojarski2016end}, in which it is expensive to gather a large number of samples from the environment, imitation-based methods are often the only means of generating solutions using few samples. Despite their success, these techniques are still not sufficiently sample-efficient for application to many real-world domains. \paragraph{Impact.} To that end, the central aim of our proposed competition is the advancement and development of novel, sample-efficient methods which leverage human priors for sequential decision-making problems. Due to the competition's design, organizational team, and support, we are confident that the competition will catalyze research towards the deployment of reinforcement learning in the real world, democratized access to AI/ML, and reproducibility. By enforcing constraints on the computation and sample budgets of the considered techniques, we believe that the methods developed during the competition will broaden participation in deep RL research by lowering the computational barrier to entry. While computational resources inherently have a cost barrier, large-scale, open-access datasets can be widely used. To that end, we center our proposed competition around techniques which leverage the newly introduced MineRL{} dataset. To maximize the development of domain-agnostic techniques that enable the application of deep reinforcement learning to sample-limited, real-world domains, such as robotics, we carefully developed a novel data-pipeline and hold-out environment evaluation scheme with AICrowd to prevent the over-engineering of submissions to the competition task. The proposed competition is ambitious, so we have taken meaningful steps to ensure its smooth execution. Specifically, we secured several crucial partnerships with organizations and individuals. Our primary partner, Microsoft Research, is providing significant computational resources to enable direct, fair evaluation of the participants' training procedures. We developed a relationship with AICrowd.com to provide the submission orchestration platform for our competition, as well as continued support throughout the competition to ensure that participants can easily submit their algorithms. In addition, we have partnered with Preferred Networks to provide a set of standard baseline implementations including standard reinforcement learning techniques, hierarchical methods, and basic imitation learning methods. \subsubsection{Domain Interest} \begin{figure} \begin{center} \includegraphics[width=0.9\textwidth]{./assets/item_hierarchy_final.png} \caption{\small A subset of the Minecraft item hierarchy (totaling 371 unique items). Each node is a unique Minecraft item, block, or non-player character, and a directed edge between two nodes denotes that one is a prerequisite for another. Each item presents is own unique set of challenges, so coverage of the full hierarchy by one player takes several hundred hours.} \label{fig:hierarchicality} \end{center} \vspace{-19pt} \end{figure} Minecraft is a compelling domain for the development of reinforcement and imitation learning based methods because of the unique challenges it presents: Minecraft is a 3D, first-person, open-world game centered around the gathering of resources and creation of structures and items. Notably, the procedurally generated world is composed of discrete blocks that allow modification; over the course of gameplay, players change their surroundings by gathering resources (such as wood from trees) and constructing structures (such as shelter and storage). Since Minecraft is an embodied domain and the agent's surroundings are varied and dynamic, it presents many of the same challenges as real-world robotics domains. Therefore, solutions created for this competition are a step toward applying these same methods to real-world problems. An additional reason Minecraft is an appealing competition domain is its popularity as a video game; of all games ever released, it has the second-most total copies sold. Given its popularity, potential participants are more likely to be familiar with it than other domains based on video games. Likewise, the competition will be of greater interest due to its relationship with such a well-known game. Furthermore, there is existing research interest in Minecraft. With the development of Malmo~\cite{johnson2016malmo}, a simulator for Minecraft, the environment has garnered great research interest: many researchers~\cite{shu2017hierarchical, tessler2017deep, oh2016control} have leveraged Minecraft's massive hierarchality and expressive power as a simulator to make great strides in language-grounded, interpretable multi-task option-extraction, hierarchical lifelong learning, and active perception. However, much of the existing research utilizes toy tasks in Minecraft, often restricted to 2D movement, discrete positions, or artificially confined maps unrepresentative of the intrinsic complexity that human players typically face. These restrictions reflect the difficulty of the domain, the challenge of coping with fully-embodied human state- and action-spaces, and the complexity exhibited in optimal human policies. Our competition and the release of the large-scale MineRL-v0 dataset of human demonstrations will serve to catalyze research on this domain in two ways: (1) our preliminary results indicate that through imitation learning, basic reinforcement learning approaches can finally deal directly with the full, unrestricted state- and action-space of Minecraft; and (2) due to the difficult and crucial research challenges exhibited on the primary competition task, \texttt{ObtainDiamond}, we believe that the competition will bring work on the Minecraft domain to the fore of sample-efficient reinforcement learning research. \subsection{Data}\label{sec:data} \begin{wrapfigure}{r}{0.5\textwidth} \begin{center} \vspace{-25pt} \includegraphics[width=0.49\textwidth]{./assets/tasks_smaller.png} \caption{\small Images of various stages of six of seven total environments.} \label{fig:tasks} \vspace{-65pt} \end{center} \end{wrapfigure} For this competition, we introduce two main components: a set of sequential decision making environments in Minecraft and a corresponding public large-scale dataset of human demonstrations. \subsubsection{Environment} We define \emph{one primary competition environment}, \texttt{ObtainDiamond}, and six other auxiliary environments that encompass a significant portion of human Minecraft play. We select these environment domains to highlight many of the hardest challenges in reinforcement learning, such as sparse rewards, long reward horizons, and efficient hierarchical planning. \paragraph{Primary Environment.} The main task of the competition is solving the \texttt{ObtainDiamond} environment. In this environment, the agent begins in a random starting location without any items, and is tasked with obtaining a diamond. The agent receives a high reward for obtaining a diamond as well as smaller, auxillary rewards for obtaining prerequisite items. Episodes end due to the agent (a) dying, (b) successfully obtaining a diamond, or (c) reaching the maximum step count of 18000 frames (15 minutes). The \texttt{ObtainDiamond} environment is a difficult environment for a number of reasons. Diamonds only exist in a small portion of the world and are 2-10 times rarer than other ores in Minecraft. Additionally, obtaining a diamond requires many prerequisite items. For these reasons, it is practically impossible for an agent to obtain a diamond via naive random exploration. \paragraph{Auxillary Environments.} We provide six auxillary environments (in four families), which we believe will be useful for solving \texttt{ObtainDiamond} (see Section~\ref{sec:data_use}): \begin{enumerate} \item \texttt{Navigate}: In this environment, the agent must move to a goal location. This represents a basic primitive used in many tasks throughout Minecraft. In addition to standard observations, the agent has access to a ``compass'' observation, which points to a set location, 64 meters from the start location. The agent is given a sparse reward (+100 upon reaching the goal, at which point the episode terminates). We also support a dense, reward-shaped version of Navigate, in which the agent is given a reward every tick corresponding to the change in distance between the agent and the goal. \item \texttt{Treechop}: In this environment, the agent must collect wood, a key resource in Minecraft and a prerequisite item for diamonds. The agent begins in a forest biome (near many trees) with an iron axe for cutting trees. The agent is given +1 reward for obtaining each unit of wood, and the episode terminates once the agent obtains 64 units or the step limit is reached. \item \texttt{Obtain<Item>}: We include a three additional obtain environments, similar to that of \texttt{ObtainDiamond}, but with different goal items to obtain. They are: \begin{enumerate} \item \texttt{CookedMeat}: cooked meat of a (cow, chicken, sheep, or pig), which is necessary for survival in Minecraft. In this environment, the agent is given a specific kind of meat to obtain. \item \texttt{Bed}: made out of dye, wool, and wood, an item that is also vital to Minecraft survival. In this environment, the agent is given a specific color of bed to create. \item \texttt{IronPickaxe}: is a direct prerequisite item of the diamond. It is significantly easier to solve than \texttt{ObtainDiamond}: iron is 20 times more common in the Minecraft world than diamonds, and this environment is typically solved by humans in less than 10 minutes. \end{enumerate} \item \texttt{Survival}: This environment is the standard, open-ended game mode used by most human players when playing the game casually. There is no specified reward function in this case, but data from this environment can be used to help train agents in more structured tasks, such as \texttt{ObtainDiamond}. \end{enumerate} \subsubsection{Dataset} \begin{wrapfigure}{r}{0.5\textwidth} \vspace{-25pt} \begin{center} \includegraphics[width=0.47\textwidth]{./assets/datapipeline_new.png} \caption{\small A diagram of the MineRL data collection platform. Our system renders demonstrations from packet-level data, so we can easily rerender our data with different parameters.} \label{fig:platform_diagram} \end{center} \vspace{-19pt} \end{wrapfigure} The MineRL-v0 dataset consists of over 60 million state-action-(reward) tuples of recorded human demonstrations over the seven environments mentioned above. Each trajectory is contiguously sampled every Minecraft game tick (at 20 game ticks per second). Each state is comprised of an RGB video frame of the player's point-of-view and a comprehensive set of features from the game-state at that tick: player inventory, item collection events, distances to objectives, player attributes (health, level, achievements), and details about the current GUI the player has open. The action recorded at each tick consists of: all the keyboard presses, the change in view pitch and yaw (mouse movements), player GUI interactions, and agglomerative actions such as item crafting. Human trajectories are accompanied by a large set of automatically generated annotations. For all of the environments, we include metrics which indicate the quality of the demonstration, such as timestamped rewards, number of no-ops, number of deaths, and total score. Additionally, trajectory meta-data includes timestamped markers for hierarchical labelings; e.g. when a house-like structure is built or certain objectives such as chopping down a tree are met. Data is made available both in the competition materials as well as through a standalone website \url{http://minerl.io} \subsubsection{Data Collection} For this competition, we use our novel platform for the collection of player trajectories in Minecraft, enabling the construction of the MineRL-v0 dataset. As shown in Figure~\ref{fig:platform_diagram}, our platform consists of (1) \emph{a public game server and website}, where we obtain permission to record trajectories of Minecraft players in natural gameplay; (2) \emph{a custom Minecraft client plugin}, which records all packet level communication between the client and the server, so we can re-simulate and re-render human demonstrations with modifications to the game state and graphics; and (3) \emph{a data processing pipeline}, which enables us to produce automatically annotated datasets of task demonstrations. \paragraph{Data Acquisition.} Minecraft players find the MineRL~server on standard Minecraft server lists. Players first use our webpage to provide IRB\footnote{The data collection study was approved by Carnegie Mellon University's institutional review board as \texttt{STUDY2018\_00000364}.} consent to have their gameplay anonymously recorded. Then, they download a plugin for their Minecraft client, which records and streams users' client-server game packets to the MineRL~data repository. When playing on our server, users select an environment to solve and receive in-game currency proportional to the amount of reward obtained. For the \texttt{Survival} environment (where there is no known reward function), players receive rewards only for duration of gameplay, so as not to impose an artificial reward function. \paragraph{Data Pipeline.} Our data pipeline allows us to resimulate recorded trajectories into several algorithmically consumable formats. The pipeline serves as an extension to the core Minecraft game code and synchronously resends each recorded packet from the MineRL{} data repository to a Minecraft client using our custom API for automatic annotation and game-state modification. This API allows us to add annotations based on any aspect of the game state accessible from existing Minecraft simulators. Notably, it allows us to rerender the same data with different textures, shaders, and lighting-conditions which we will use to create test and validation environment-dataset pairs for this competition. \subsubsection{Data Usefulness}\label{sec:data_use} \begin{wrapfigure}{r}{0.5\textwidth} \vspace{-25pt} \begin{center} \includegraphics[width=0.49\textwidth]{./assets/task_performance.png} \caption{\small Normalized histograms of the lengths of human demonstration on various MineRL~tasks. The red {\color{red} \tiny\sf{E}} denotes the upper threshold for expert play on each task.} \label{fig:human_quality} \end{center} \vspace{-20pt} \end{wrapfigure} \paragraph{Human Performance.} A majority of the human demonstrations in the dataset fall within the range of expert level play. Figure \ref{fig:human_quality} shows the distribution over trajectory length for each environment. The red region in each histogram denotes the range of times which correspond to play at an expert level, computed as the average time required for task completion by players with at least five years of Minecraft experience. The large number of expert samples and rich labelings of demonstration performance enable application of many standard imitation learning techniques which assume optimality of the base policy. In addition, the beginner and intermediate level trajectories allow for the further development of techniques which leverage imperfect demonstrations. \begin{wrapfigure}{r}{0.5\textwidth} \begin{center} \vspace{-15pt} \includegraphics[width=0.47\textwidth]{./assets/item_graphs.png} \caption{\small Item precedence frequency graphs for \texttt{ObtainDiamond} (left), \texttt{ObtainCookedMeat} (middle), and \texttt{ObtainIronPickaxe} (right). The thickness of each line indicates the number of times a player collected item $A$ then subsequently item $B$. } \label{fig:task_hist} \vspace{-18pt} \end{center} \end{wrapfigure} \paragraph{Hierarchality.} Minecraft is deeply hierarchical as shown in Figure \ref{fig:hierarchicality}, and the MineRL~data collection platform is designed to capture these hierarchies both explicitly and implicitly. Due to the subtask labelings provided in MineRL-v0, we can inspect and quantify the extent to which these environments overlap. Figure \ref{fig:task_hist} shows precedence frequency graphs constructed from MineRL{} trajectories on the \texttt{ObtainDiamond}, \texttt{Obtain} \texttt{CookedMeat}, and \texttt{ObtainIronPickaxe} tasks. The policies for obtaining a diamond consist of subpolicies which obtain wood, stone, crafting tables, and furnaces, all of which appear in \texttt{ObtainIronPickaxe} and \texttt{ObtainCookedMeat} as well. There is even greater overlap between \texttt{ObtainDiamond} and \texttt{ObtainIronPickaxe}: most of the item hierarchy for \texttt{ObtainDiamond} consists of the hierarchy for \texttt{ObtainIronPickaxe}. \paragraph{Interface} Participants will be provided with an OpenAI Gym\cite{openai_2017} wrapper for the environment and a simple interface for loading demonstrations from the MineRL-v0 dataset as illustrated in figures \ref{fig:env_code}, \ref{fig:mineral_code_1}, and \ref{fig:mineral_code_2}. This makes interacting with the environment and our data as simple as a few lines of code. Our data will be released in the form of Numpy \texttt{.npz} files composed of state-action-reward tuples in vector form, and can be found along with accompanying documentation on the competition website. \begin{figure} \begin{center} \vspace{-15pt} \includegraphics[width=0.87\textwidth]{./assets/malmo_env.png} \caption{\small Example code for running a single episode of a random agent in \texttt{ObtainDiamond}. } \label{fig:env_code} \vspace{-18pt} \end{center} \end{figure} \begin{figure} \begin{center} \vspace{-15pt} \includegraphics[width=0.87\textwidth]{./assets/mineral_dat_1.png} \caption{\small Utilizing individual trajectories of the MineRL dataset.} \label{fig:mineral_code_1} \end{center} \end{figure} \begin{figure} \begin{center} \vspace{-15pt} \includegraphics[width=0.87\textwidth]{./assets/mineral_dat_2.png} \caption{\small Using the MineRL wrapper to filter demonstrations based on metadata} \label{fig:mineral_code_2} \vspace{-18pt} \end{center} \end{figure} \subsection{Novelty} \paragraph{Reinforcement Learning.} To date, all existing reinforcement learning competitions have focused on the development of policies or meta-policies which perform well on extremely complex domains or generalize across a distribution of tasks~\cite{kidzinski2018learning, nichol2018gotta, perez2019multi}. However, the focus of these competitions is performing well on a given domain and not the development of robust algorithms that are applicable to a broad set of domains. Often, the winning submissions are the result of massive amounts of computational resources or highly specific, hand-engineered features. In contrast, our competition is the first of its kind to directly consider the efficiency of the training procedures of different algorithms. We evaluate submissions solely on their ability to perform well within a \emph{strict} computation and environment-sample budget. Moreover, we are uniquely positioned to propose such a competition due to the nature of our human demonstration dataset and environment: our dataset is constructed by directly recording the game-state as human experts play, so we are able to later make multiple renders of both the environment and data with varied lighting, geometry, textures, and gamestate dynamics, thus yielding development, validation, and hold-out evaluation dataset/environment pairs. As a result, competitors are naturally prohibited from hand-engineering or warm-starting their learning algorithms and winning solely due to resource advantages. \paragraph{Imitation Learning.} To our knowledge, no competitions have explicitly focused on the use of imitation learning alongside reinforcement learning. This is in large part due to a lack of large-scale, publicly available datasets of human or expert demonstrations. Our competition is the first to explicitly involve and encourage the use of imitation learning to solve the given task, and in that capacity, we release the largest-ever dataset of human demonstrations on an embodied domain. The large number of trajectories and rich demonstration-performance annotations enable the application of many standard imitation learning techniques and encourage further development of new ones that use hierarchical labels, varying agent performance levels, and auxiliary state information. \paragraph{Minecraft.} A few competitions have already used Minecraft due to its expressive power as a domain. The first one was The Malm\"{o} Collaborative AI Challenge\footnote{\url{https://www.microsoft.com/en-us/research/academic-program/collaborative-ai-challenge}}, in which agents worked in pairs to solve a collaborative task in a decentralized manner. Later, C. Salge et al.~\cite{salge2018generative} organized the Generative Design in Minecraft (GDMC): Settlement Generation Competition, in which participants were asked to implement methods that would procedurally build complete cities in any given, unknown landscape. These two contests highlight the versatility of this framework as a benchmark for different AI tasks. In 2019, Perez-Liebana et al.~\cite{perez2019multi} organized the Multi-Agent Reinforcement Learning in Malm\"{O} (MARL\"{O}) competition. This competition pitted groups of agents to compete against each other in three different games. Each og the games was parameterizable to prevent the agents from overfitting to specific visuals and layouts. The objective of the competition was to build an agent that would learn, in a cooperative or competitive multi-agent task, to play the games in the presence of other agents. The MARL\"{O} competition successfuly attracted a large number of entries from both existing research institutions and the general public, indicating a broad level of accessibility and excitement for the Minecraft domain within and outside of the existing research community. In comparison with previous contests, our competition tackles one main task and provides a massive number of hierarchical subtasks and demonstrations (see Section \ref{sec:data}). The main task and its subtasks are not trivial; however, agent progress can be easily measured, which allows for a clear comparison between submitted methods. Further, the target of the present competition is to promote research on \textit{efficient learning}, focusing directly on the sample- and computational-efficiency of the submitted algorithms. \subsection{Baselines, code, and material provided} \label{sec:baselines} \paragraph{Preliminary Results} \begin{wrapfigure}{r}{0.5\textwidth} \begin{center} \vspace{-25pt} \includegraphics[width=0.49\textwidth]{./assets/dqn.png} \caption{\small Performance graphs over time with DQN and PreDQN on \texttt{Navigate}(Dense)} \label{fig:dqn} \vspace{-20pt} \end{center} \end{wrapfigure} We present preliminary results showing the usefulness of the data for improving sample efficiency and overall performance. We compare algorithms by the highest average reward obtained over a 100-episode window during training. We also report the performance of random policies and 50th percentile human performance. The results are summarized in Table~\ref{table:perf}. In the presented comparison, the DQN is an implementation of Double Dueling DQN and Behavioral Cloning is a supervised learning method trained on expert trajectories. PreDQN denotes a version of DQN pretrained on the MineRL{}-v0 data: specifically, PreDQN is trained by performing Bellman updates on minibatches drawn from expert trajectories with accompanying reward labels. Before training, we initialize the replay buffer with expert demonstrations. In all environments, the learned agents perform significantly worse than humans. \texttt{Treechop} exhibits the largest difference: on average, humans achieve a score of 64, but reinforcement agents achieve scores of less than 4. These results suggest that our environments are quite challenging, especially given that the \texttt{Obtain<Item>} environments build upon the Treechop environment by requiring the completion of several additional sub-goals. We hypothesize that a large source of difficulty stems from the environment’s inherent long-horizon credit assignment problems. For example, it is hard for agents to learn to navigate through water because it takes many transitions before the agent dies by drowning. In light of these difficulties, our data is useful in improving performance and sample efficiency: in all environments, methods that leverage human data perform better. As seen in Figure~\ref{fig:dqn}, the expert demonstrations were able to achieve higher reward per episode and attain high performance using fewer samples. Expert demonstrations are particularly helpful in environments where random exploration is unlikely to yield any reward, like Navigate (Sparse). These preliminary results indicate that human demonstrations will be crucial in solving the main competition environment. \begin{table} \small \centering \begin{tabular}{lccc} \toprule & \texttt{Treechop} & \texttt{Navigate} (S) & \texttt{Navigate} (D) \\ \midrule DQN (Minh et al., 2015\cite{mnih2015human})& 3.73 $\pm$ 0.61 & 0.00 $\pm$ 0.00 & 55.59 $\pm$ 11.38 \\ A2C (Minh et al. 2016\cite{mnih2016asynchronous})& 2.61 $\pm$ 0.50 & 0.00 $\pm$ 0.00 & -0.97 $\pm$ 3.23 \\ Behavioral Cloning & \textbf{43.9} $\pm$ \textbf{31.46} & 4.23 $\pm$ 4.15 & 5.57 $\pm$ 6.00 \\ PreDQN & {4.16} $\pm$ {0.82} & {6.00} $\pm$ \textbf{4.65} & \textbf{94.96} $\pm$ \textbf{13.42} \\ \midrule Human & 64.00 $\pm$ 0.00 & 100.00 $\pm$ 0.00 & 164.00 $\pm$ 0.00 \\ Random & 3.81 $\pm$ 0.57 & 1.00 $\pm$ 1.95 & -4.37 $\pm$ 5.10 \\ \bottomrule \end{tabular} \caption{ \small Results in \texttt{Treechop}, \texttt{Navigate} (S)parse, and \texttt{Navigate} (D)ense, over the best 100 contiguous episodes. $\pm$ denotes standard deviation. Note: humans achieve the maximum score for all environments shown. } \label{table:perf} \vspace{0pt} \end{table} \paragraph{Planned Baselines.} We will provide baselines on state of the art RL algorithms such as DQN, A2C, and PPO as well as pretrained (on human data) alternatives of each. We also provide code for imitation learning algorithms such as Behavioral Cloning and GAIL. \paragraph{Starting Code and Documentation.} We will release an open-source Github repository with starting code including the baselines mentioned above, an OpenAI Gym interface for the Minecraft simulator, and a data-loader to accompany the data we will release on \url(http://minerl.io/docs/). Additionally, we will release a public Docker container for ease of use. \subsection{Tutorial and documentation} A competition page that will contain instructions, documentation, and updates to the competition can be found at \href{http://minerl.io/competition}{http://minerl.io/competition}. \subsection{Metrics} \label{sec:metrics} \begin{wraptable}{r}{0.5 \textwidth} \vspace{-20pt} \centering \tiny \begin{tabular}{ll|ll} {Milestone} & {Reward} & {Milestone} & {Reward} \\ \midrule log & 1 & furnace & 32 \\ planks & 2 & stone\_pickaxe & 32 \\ stick & 4 & iron\_ore & 64 \\ crafting\_table & 4 & iron\_ingot & 128 \\ wooden\_pickaxe & 8 & iron\_pickaxe & 256 \\ stone & 16 & diamond & 1024 \end{tabular} \caption{ \small Rewards for sub-goals and main goal (diamond) for \texttt{Obtain Diamond}.} \label{table:rew} \vspace{-10pt} \end{wraptable} Following training, participants will be evaluated on the average score of their model over 500 episodes. Scores are computed as the sum of the milestone rewards achieved by the agent in a given episode as outlined in Table~\ref{table:rew}. A milestone is reached when an agent obtains the first instance of the specified item. Ties are broken by the number of episodes required to achieve the last milestone. An automatic evaluation script will be included with starter code. For official evaluation and validation, a fixed map seed will be selected for each episode. These seeds will not be available to participants during the competition. \subsection{Tasks and application scenarios} \subsubsection{Task} The primary task of the competition is solving the \texttt{ObtainDiamond} environment. As previously described (see Section~\ref{sec:data}), agents begin at a random position on a randomly generated Minecraft survival map with no items in their inventory. The task consists of controlling an embodied agent to obtain a single diamond. This task can only be accomplished by navigating the complex item hierarchy of Minecraft. The learning algorithm will have direct access to a $64$x$64$ pixel point-of-view observation from the perspective of the embodied Minecraft agent, as well as a set of discrete observations of the agent's inventory for every item required for obtaining a diamond (see Figure~\ref{fig:task_hist}). The action space of the agent is the Cartesian product of continuous view adjustment (turning and pitching), binary movement commands (left/right, forward/backward), and discrete actions for placing blocks, crafting items, smelting items, and mining/hitting enemies. The agent is rewarded for completing the full task. Due to the difficulty of the task, the agent is also rewarded for reaching a set of milestones of increasing difficulty that form a set of prerequisites for the full task (see Section~\ref{sec:metrics}). The competition task embodies two crucial challenges in reinforcement learning: sparse rewards and long time horizons. The sparsity of the posed task (in both its time structure and long time horizon) necessitates the use of efficient exploration techniques, human priors for policy bootstrapping, or reward shaping via inverse reinforcement learning techniques. Although this task is challenging, preliminary results indicate the potential of existing and new methods utilizing human demonstrations to make progress in solving it (see Section~\ref{sec:baselines}). Progress towards solving the \texttt{ObtainDiamond} environment under strict sample complexity constraints lends itself to the development of sample-efficient--and therefore more computationally accessible--sequential decision making algorithms. In particular, because we maintain multiple versions of the dataset and environment for development, validation, and evaluation, it is difficult to engineer domain-specific solutions to the competition challenge. The best performing techniques must explicitly implement strategies that efficiently leverage human priors across general domains. In this sense, the application scenarios of the competition are those which stand to benefit from the development of such algorithms; to that end, we believe that this competition is a step towards democratizing access to deep reinforcement learning based techniques and enabling their application to real-world problems. \subsubsection{Domain Interest} \begin{figure} \begin{center} \includegraphics[width=0.9\textwidth]{./assets/item_hierarchy_final.png} \caption{\small A subset of the Minecraft item hierarchy (totaling 371 unique items). Each node is a unique Minecraft item, block, or non-player character, and a directed edge between two nodes denotes that one is a prerequisite for another. Each item presents is own unique set of challenges, so coverage of the full hierarchy by one player takes several hundred hours.} \label{fig:hierarchicality} \end{center} \vspace{-19pt} \end{figure} Minecraft is a compelling domain for the development of reinforcement and imitation learning based methods because of the unique challenges it presents: Minecraft is a 3D, first-person, open-world game centered around the gathering of resources and creation of structures and items. Notably, the procedurally generated world is composed of discrete blocks that allow modification; over the course of gameplay, players change their surroundings by gathering resources (such as wood from trees) and constructing structures (such as shelter and storage). Since Minecraft is an embodied domain and the agent's surroundings are varied and dynamic, it presents many of the same challenges as real-world robotics domains. Therefore, solutions created for this competition are a step toward applying these same methods to real-world problems. An additional reason Minecraft is an appealing competition domain is its popularity as a video game; of all games ever released, it has the second-most total copies sold. Given its popularity, potential participants are more likely to be familiar with it than other domains based on video games. Likewise, the competition will be of greater interest due to its relationship with such a well-known game. % Furthermore, there is existing research interest in Minecraft. With the development of Malmo~\cite{johnson2016malmo}, a simulator for Minecraft, the environment has garnered great research interest: many researchers~\cite{shu2017hierarchical, tessler2017deep, oh2016control} have leveraged Minecraft's massive hierarchality and expressive power as a simulator to make great strides in language-grounded, interpretable multi-task option-extraction, hierarchical lifelong learning, and active perception. However, much of the existing research utilizes toy tasks in Minecraft, often restricted to 2D movement, discrete positions, or artificially confined maps unrepresentative of the intrinsic complexity that human players typically face. These restrictions reflect the difficulty of the domain, the challenge of coping with fully-embodied human state- and action-spaces, and the complexity exhibited in optimal human policies. Our competition and the release of the large-scale MineRL-v0 dataset of human demonstrations will serve to catalyze research on this domain in two ways: (1) our preliminary results indicate that through imitation learning, basic reinforcement learning approaches can finally deal directly with the full, unrestricted state- and action-space of Minecraft; and (2) due to the difficult and crucial research challenges exhibited on the primary competition task, \texttt{ObtainDiamond}, we believe that the competition will bring work on the Minecraft domain to the fore of sample-efficient reinforcement learning research. \todo{@steph, could you please review these last two centences.} \subsection{Protocol} \subsubsection{Submission Protocol} \label{subsec:sub_protocol} The evaluation of the submissions will be managed by AICrowd.com, an open-source platform for organizing machine learning competitions. Throughout the competition, participants will work on their code bases as git repositories on \url{https://gitlab.aicrowd.com}. Participants must package their intended software runtime in their repositories. Doing so ensures that the AICrowd evaluators can automatically build relevant Docker images from their repositories and orchestrate them as needed. This approach also ensures that all successfully-evaluated, user-submitted code is both versioned across time and completely reproducible. \paragraph{Software Runtime Packaging.} Packaging and specification of the software runtime is among the most time consuming (and frustrating) tasks for many participants. To simplify this step, we will support numerous approaches to easily package the software runtime with the help of \texttt{aicrowd-repo2docker} (\url{https://pypi.org/project/aicrowd-repo2docker/}). The \texttt{aicrowd-repo2docker} is a tool which lets participants specify their runtime using Anaconda environment exports, \texttt{requirements.txt}, or a traditional Dockerfile. This significantly decreases the barrier to entry for less technically-inclined participants by transforming an irritating debug cycle to a deterministic one-liner that performs the work behind the scenes. \paragraph{Submission Mechanism.} Participants will collaborate on their git repository throughout the competition. Whenever they are ready to make a submission, they will create and push a \textit{git tag}, which triggers the evaluation pipeline. \paragraph{Orchestration of the Submissions.} The ability to reliably orchestrate user submissions over large periods of time is a key determining feature of the success of the proposed competition. We will use the evaluators of AICrowd, which use custom Kubernetes clusters to orchestrate the submissions against pre-agreed resource usage constraints. The same setup has previously been successfully used in numerous other machine learning competitions, such as NeurIPS 2017: Learning to Run Challenge, NeurIPS 2018: AI for Prosthetics Challenge, NeurIPS 2018: Adversarial Vision Challenge, and the 2018 MarLO challenge. The evaluation setup allows for evaluations of arbitrarily long time-periods, and also can privately provide feedback about the current state of the evaluation to the respective participants. \subsubsection{General Competition Structure} \paragraph{Round 1: General Entry.} In this round, participants will register on the competition website, and receive the following materials: \begin{itemize} \item Starter code for running the Malmo environments for the competition task. \item Basic baseline implementations provided by Preferred Networks and the competition organizers (see Section~\ref{sec:baselines}). \item Two different renders of the human demonstration dataset (one for methods development, the other for validation) with modified textures, lighting conditions, and minor game state changes. \item The Docker Images and Azure quick-start template that the competition organizers will use to validate the training performance of the competitor's models. \item Several scripts enabling the procurement of the standard cloud compute\footnote{For this competition we will specifically be restricting competitors to NC6 v2 Azure instances with 6 CPU cores, 112 GiB RAM, 736 GiB SDD, and a single NVIDIA P100 GPU.} used to evaluate the sample-efficiency of participants' submissions. \end{itemize} Competitors will use the provided human demonstrations to develop and test procedures for efficiently training models to solve the competition task. When satisfied with their models, participants will follow the submission protocols (described in Section~\ref{subsec:sub_protocol}) to submit their code for evaluation. The automated evaluation setup will evaluate the submissions against the validation environment, to compute and report the metrics (described in Section~\ref{sec:metrics}) on the leaderboard of the competition. Because the full training phase is quite resource intensive, it is not be possible to run the training for all the submissions in this round; however, the evaluator will ensure that the submitted code includes the relevant subroutines for the training of the models by running a short integration test on the training code before doing the actual evaluation on the validation environment. Once Round 1 is complete, the organizers will examine the code repositories of the top 20 submissions to ensure compliance with the competition rules. The top 20 submissions which comply with the competition rules will then automatically be trained on validation dataset and environment by the competition orchestration platform. The resulting trained models will then be evaluated again over several hundred episodes. Their performance will be compared with the submission's final model performance during Round 1 to ensure that no warm-starting or adversarial modifications of the evaluation harness was made. For those submissions whose end-of-round and organizer-ran performance distributions disagree, the offending teams will be contacted for appeal. If none is made, the organizers will remove those submissions from the competition and then evaluate a corresponding number of submissions beyond the original top 20 selected. When twenty fully-compliant and qualified submissions are determined, their submissions will automatically go through the training process on the hold-out evaluation environment and dataset to seed the leaderboard of the subsequent round. The code repositories associated with the corresponding submissions will be forked, and scrubbed of any files larger than 15MB to ensure that participants are not using any pre trained models (pre trained on the dataset of this competition) in the subsequent round. \paragraph{Round 2: Finals.} In this round, the top 20 performing teams will continue to develop their algorithms. Their work will be evaluated against a confidential, held-out test environment and test dataset, to which they will not have access. Specifically, participants will be able to make a submission (as described in Section~\ref{subsec:sub_protocol}) twice during Round 2 and the automated evaluator will evaluate their algorithms on the test dataset and simulator, compute and report the metrics back to the participants. This is done to prevent competitors from over-fitting to the training and validation datasets/simulators. All submitted code repositories will be scrubbed to remove any files larger than 30MB to ensure participants are not checking in any model weighs pretrained on the previously released training dataset. While the container running the submitted code will not have external network access, relevant exceptions are added to ensure participants can download and use the pretrained models included in popular frameworks like PyTorch, tensorflow. Participants can request to add network exceptions for any other publicly available pretrained models, which will be validated by AICrowd on a case by case basis. Further, participants will submit a written report/workshop submission for their technical approach to the problem; this report will be used to bolster the impact of this competition on sample-efficient reinforcement learning research. At the end of the second period, the competition organizers will execute a final run of the participants’ algorithms and the winners will be selected for each of the competition tracks. \paragraph{User Submitted Code.} At the end of the competition, all the participants will be provided a time window of 3 weeks to appeal the mandatory open-sourcing policy and categorically object if they do not want their code repositories associated with this competition to be open sourced. Such appeals will be handled by the competition organizers, but competitors are typically prohibited from participating in the competition if they are not willing to release their submissions publicly for reproducibility. As a default configuration, all the associated code repositories will be made public and available at \url{https://gitlab.aicrowd.com} after the 3 week window at the end of the competition. \paragraph{NeurIPS Workshop.} After winners have been selected, there will be a public NeurIPS workshop to exhibit the technical approaches developed during the competition. At the workshop, we will feature talks by several researchers in sample-efficient reinforcement learning and AI democratization. To that end, we plan to contact Jia Li, an adjunct professor at Stanford University involved in democratizing AI for healthcare, Emma Brunskill, an assistant professor at Stanford University whose research focuses on efficient and hierarchical RL, and Michael Littman, a professor at Brown University whose research focuses on learning from demonstrations. Further details of this workshop are to be determined. \subsection{Rules} The aim of the competition is to develop sample-efficient training algorithms. Therefore, we discourage the use of environment-specific, hand-engineered features because they do not demonstrate fundamental algorithmic improvements. The following rules attempt to capture the spirit of the competition and any submissions found to be violating the rules may be deemed ineligible for participation by the organizers. \begin{itemize} \item The submission must train a machine learning model. A manually specified policy may not be used as a component of this model. \item Submissions may re-use open-source code with proper attribution. At the end of the competition, submissions need be open-sourced to enable reproducibility. \item Participants are limited to the provided dataset, no additional resources in source or available over the internet may be used. \item In Round 1, participants must submit their code along with self-reported scores. The submitted code must finish training within two days on the provided platform and attain a final performance not significantly less than the self-reported score. This training must be “from scratch” (i.e., no information may be carried over from previous training through saved model weights or otherwise). Submissions which fail to train or which do not attain the self-reported score are not eligible for the next round. \item Agents will be evaluated using unique seeds per episode. These seeds will not be available to participants until the competition has completed. \item During the evaluation of the submitted code, the individual containers will not have access to any external network to avoid any information leak. \end{itemize} \paragraph{Cheating.} We have designed the competition to prevent rule breaking and to discourage submissions that circumvent the competition goals. First off, the competitors' submissions are tested on variants of the environment/data with different textures and lighting, discouraging the any priors that are not trained from scratch. Inherent stochasticity in the environment, such as different world and spawn locations, discourage the use of hard-coded policies. Furthermore, we will use automatic evaluation scripts to verify the participants' submitted scores in the first round and perform a manual code review of the finalists of each round in the competition. We highlight that the evaluation dataset/environment pair on which participants will be evaluated is \emph{completely inaccessible} to competitors, and measures are taken to prevent information leak. \begin{figure}g \begin{center} \vspace{-35pt} \includegraphics[width=\textwidth]{./assets/timeline.png} \vspace{-20pt} \caption{\small Proposed timeline for competition } \label{fig:schedule} \vspace{-25pt} \end{center} \end{figure} \subsection{Schedule and readiness} \subsubsection{Schedule} Given the difficulty of the problem posed, ample time shall be given to allow participants to fully realize their solutions. Our proposed timeline gives competitors over 120 days to prepare, evaluate, and receive feedback on their solutions before the end of the first round. \begin{itemize} \item [Mar 23] \textbf{Competition Accepted} \item [Apr 3] \textbf{Dataset Starter-kit Completed} - Demonstration code for leveraging the MineRL dataset is finalized and posted. \item [Apr 16] \textbf{Submission Framework Completed} - Submission framework is finalized enabling the submission and automatic evaluation of models via \texttt{aicrowd-repo2docker}. \item [Apr 28] \textbf{Baselines Completed} - Baselines developed by Preferred Networks (PFN) are finalized and integrated into starting materials. \item [Jun 1] \textbf{First Round Begins} - Participants invited to download starting materials and baselines and to begin developing their submission. \item [Sep 22] \textbf{End of First Round} - Submissions for consideration into entry into the final round are closed. Models will be evaluated by organizers and partners. \item [Sep 27] \textbf{First Round Results Posted} - Official results will be posted notifying finalists. \item [Sep 30] \textbf{Final Round Begins} - Finalists are invited to submit their models against the held out validation texture pack to ensure their models generalize well. \item [Oct 25] \textbf{End of Final Round} - Submissions for finalists are closed and organizers begin training finalists latest submission for evaluation. \item [Nov 12] \textbf{Final Results Posted} - Official results of model training and evaluation are posted. \item [Dec 1] \textbf{Special Awards Posted} - Additional awards granted by the advisory committee are posted. \item [Dec 8] \textbf{NeurIPS 2019} - Winning teams will be invited to the conference to present their results. \end{itemize} \subsubsection{Readiness.} At the time of writing this proposal the following key milestones are complete: the dataset is fully collected, cleaned, and automatically annotated; the competition environments have been finalized and implemented; the advisory committee is fully established; the partnerships with Microsoft, Preferred Networks, and AICrowd have been confirmed and all parties are working closely to release the competition on schedule; correspondence with several affinity groups has been made, and a specific plan for attracting underrepresented groups is finalized; and the major software components of the competition infrastructure have been developed. If accepted to the NeurIPS competition track, there are no major roadblocks preventing the execution of the competition. \subsection{Competition promotion} \paragraph{Partnership with Affinity Groups} We plan to partner with a number of affinity groups to promote the participation of groups traditionally underrepresented at NeurIPS in our competition. Specifically, we reached out to organizers of Women in Machine Learning (WiML), LatinX in AI (LXAI), Black in AI (BAI), and Queer in Artificial Intelligence. We also reached out to organizations, such as Deep Learning Indaba and Data Science Africa, to work with them to determine how to increase participation of individuals often underrepresented in North American conferences and competitions. \paragraph{Promotion through General Mailing Lists} To promote participation in the competition, we plan to distribute the call to general technical mailing lists, such as Robotics Worldwide and Machine Learning News, company mailing lists, such as DeepMind's internal mailing list, and institutional mailing lists. We plan to promote participation of underrepresented groups in the competition by distributing the call to affinity group mailing lists, including, but not limited to Women in Machine Learning (WiML), LatinX in AI (LXAI), Black in AI (BAI), and Queer in AI. Furthermore, we plan to reach out to researchers and/or lab directors who are members of underrepresented groups, such as those employed at historically black or all-female universities and colleges, to encourage their participation in the competition. By contacting these researchers, we will be able to promote the competition to individuals who are not on any of the aforementioned mailing lists, but are still members of underrepresented groups. \paragraph{Media Coverage} To increase general interest and excitement surrounding the competition, we will reach out to the media coordinator at Carnegie Mellon University. By doing so, our competition will be promoted by popular online magazines and websites, such as Wired. We will also post about the competition on relevant popular subreddits, such as \url{r/machinelearning} and /r/datascience, and promote it through social media. We will utilize our industry and academic partners to post on their various social media platforms, such as the Carnegie Mellon University Twitter and the Microsoft Facebook page. \paragraph{Promotion at Conferences.} Several of our advisors will directly promote the competition via keynote talks at various AI/ML related conferences including: Structure and priors in RL workshop at ICLR (early May, \url{http://spirl.info/2019/about/}), RLDM (early July, \url{http://rldm.org/}), Industry day at CoG (August, \url{http://ieee-cog.org}), and the ReWork Deep Learning Summit (\url{https://www.re-work.co/}). \subsection{Organizing team} \subsubsection{Organizers} \paragraph{William H. Guss.} William Guss is a Ph.D. candidate in the Machine Learning Department at CMU and co-founder of Infoplay AI. He is advised by Dr. Ruslan Salakhutdinov and his research spans sample-efficient reinforcement learning, natural language processing, and deep learning theory. William completed his bachelors in Pure Mathematics at UC Berkeley where he was awarded the Regents' and Chancellor's Scholarship, the highest honor awarded to incoming undergraduates. During his time at Berkeley, William received the Amazon Alexa Prize Grant for the development of conversational AI and co-founded Machine Learning at Berkeley. William is from Salt Lake City, Utah and grew up in an economically impacted, low-income neighborhood without basic access to computational resources. As a result, William is committed to working towards developing research and initiatives which promote socioeconomically-equal access to AI/ML systems and their development. \paragraph{Cayden Codel.} Cayden Codel is an undergraduate computer science student at Carnegie Mellon University interested in machine learning and cybersecurity. Since June 2018, he has developed and helped manage the MineRL data collection pipeline, expanded the available Malmo testing environments, and built many Minecraft server features and minigames. \paragraph{Katja Hofmann.} Katja Hofmann is a Senior Researcher at the Machine Intelligence and Perception group at Microsoft Research Cambridge. Her research focuses on reinforcement learning with applications in video games, as she believes that games will drive a transformation of how people interact with AI technology. She is the research lead of Project Malmo, which uses the popular game Minecraft as an experimentation platform for developing intelligent technology, and has previously co-organized two competitions based on the Malmo platform. Her long-term goal is to develop AI systems that learn to collaborate with people, to empower their users and help solve complex real-world problems. \paragraph{Brandon Houghton.} Brandon Houghton is a Research Associate at CMU and co-creator of the MineRL{} dataset. Graduating from the School of Computer Science at Carnegie Mellon University in the Fall of 2018, Brandon has worked on many machine learning projects, such as discovering invariants in physical systems as well as learning lane boundaries for autonomous driving. \paragraph{Noboru Kuno.} Noboru Kuno is a Senior Research Program Manager at Microsoft Research in Redmond, USA. He is a member of Artificial Intelligence Engaged team of Microsoft Research Outreach. He leads the design, launch and development of research programs for AI projects such as Project Malmo, working in partnership with research communities and universities worldwide. \paragraph{Stephanie Milani.} Stephanie Milani is a Canadian-American Computer Science and Psychology undergraduate student at the University of Maryland, Baltimore County. She will be joining Carnegie Mellon's Machine Learning Department as a Ph.D. student in September 2019. Her general research interest is in sequential decision-making problems, with an emphasis on reinforcement learning. Previously, she conducted research in hierarchical model-based reinforcement learning and planning, reinforcement learning and planning that integrates human norms, and the intersection of behavioral psychology and neuroscience. Since 2016, she has worked to increase the participation of underrepresented minorities in CS and AI by developing curriculum at the local and state level, co-founding a mentoring and tutoring program between UMBC and a local middle school, organizing outreach events to introduce middle and high school students to CS, and leading efforts within the UMBC Computer Science Education community. She has been nationally recognized for her outreach efforts in CS education through a Newman Civic Fellowship. \paragraph{Sharada Mohanty.} Sharada Mohanty is the CEO and Co-founder of AICrowd, an opensource platform encouraging reproducible artificial intelligence research. He was the co-organizer of many large-scale machine learning competitions, such as NeurIPS 2017: Learning to Run Challenge, NeurIPS 2018: AI for Prosthetics Challenge, NeurIPS 2018: Adversarial Vision Challenge, and the 2018 MarLO Challenge. During his Ph.D. at EPFL, he worked on numerous problems at the intersection of AI and health, with a strong interest in reinforcement learning. In his current role, he focuses on building better engineering tools for AI researchers and making research in AI accessible to a larger community of engineers. \paragraph{Diego Perez Liebana.} Diego Perez Liebana is a Lecturer in Computer Games and AI at QMUL and holds a Ph.D. in CS from the University of Essex (2015). His research interests are search algorithms, evolutionary computation, and reinforcement learning applied to real-time games and general video game playing. He has published more than 60 papers in leading conferences and journals in the area, including best paper awards (CIG, EvoStar). He is the main organizer behind popular AI game-based competitions in the field, serves as a reviewer in top conferences and journals, and is general chair of the upcoming IEEE Conference on Games (QMUL, 2019). He has experience in the videogames industry with titles published for both PC and consoles, and also developing AI tools for games. Diego previously organized the MarLO competition on multi-agent reinforcement learning in Minecraft. \paragraph{Ruslan Salakhutdinov.} Ruslan Salakhutdinov received his Ph.D. in machine learning (computer science) from the University of Toronto in 2009. After spending two post-doctoral years at the Massachusetts Institute of Technology Artificial Intelligence Lab, he joined the University of Toronto as an Assistant Professor in the Department of Computer Science and Department of Statistics. In February of 2016, he joined the Machine Learning Department at Carnegie Mellon University as an Associate Professor. Ruslan's primary interests lie in deep learning, machine learning, and large-scale optimization. His main research goal is to understand the computational and statistical principles required for discovering structure in large amounts of data. He is an action editor of the Journal of Machine Learning Research and served on the senior programme committee of several learning conferences including NeurIPS and ICML. He is an Alfred P. Sloan Research Fellow, Microsoft Research Faculty Fellow, Canada Research Chair in Statistical Machine Learning, a recipient of the Early Researcher Award, Connaught New Researcher Award, Google Faculty Award, Nvidia's Pioneers of AI award, and is a Senior Fellow of the Canadian Institute for Advanced Research. \paragraph{Nicholay Topin.} Nicholay Topin is a Machine Learning Ph.D. student advised by Dr. Manuela Veloso at Carnegie Mellon University. His current research focus is explainable deep reinforcement learning systems. Previously, he has worked on knowledge transfer for reinforcement learning and learning acceleration for deep learning architectures. \paragraph{Manuela Veloso.} Manuela Veloso is a Herbert A. Simon University Professor at Carnegie Mellon University and the head of AI research at JPMorgan Chase. She received her Ph.D. in computer science from Carnegie Mellon University in 1992. Since then, she has been a faculty member at the Carnegie Mellon School of Computer Science. Her research focuses on artificial intelligence and robotics, across a range of planning, execution, and learning algorithms. She cofounded the RoboCup Federation and served as president of AAAI from 2011 to 2016. She is a AAAI, IEEE, AAAS, and ACM fellow. \paragraph{Phillip Wang.} Phillip Wang is an undergraduate computer science student at CMU and a core contributor to the MineRL{} dataset. He has previously worked on NLP at Microsoft, Computer Vision at Cruise Automation, and Software Engineering at Facebook. He is currently interested in Deep Reinforcement Learning, and has previously conducted research in meta-learning, generative vision models, and voting rules. He also enjoys building out random engineering projects, including a dating app that acquired 20k+ users, 3D holographic video chat, and an online multiplayer real time strategy game that topped the charts of ProductHunt games. \subsubsection{Advisors} \paragraph{Chelsea Finn.} Chelsea Finn is a research scientist at Google Brain and a post-doctoral scholar at UC Berkeley. In September 2019, she will be joining Stanford's computer science department as an assistant professor. Her research interests lie in the ability to enable robots and other agents to develop broadly intelligent behavior through interaction. During her Ph.D., Finn developed deep learning algorithms for concurrently learning visual perception and control in robotic manipulation skills, inverse reinforcement methods for scalable acquisition of nonlinear reward functions, and meta-learning algorithms that can enable fast, few-shot adaptation in both visual perception and deep reinforcement learning. Finn received her Bachelors degree in Electrical Engineering and Computer Science at MIT. Her research has been recognized through an NSF graduate fellowship, a Facebook fellowship, the C.V. Ramamoorthy Distinguished Research Award, and the MIT Technology Review 35 under 35 Award, and her work has been covered by various media outlets, including the New York Times, Wired, and Bloomberg. With Sergey Levine and John Schulman, Finn also designed and taught a course on deep reinforcement learning, with thousands of followers online. Throughout her career, she has sought to increase the representation of underrepresented minorities within CS and AI by developing an AI outreach camp at Berkeley and a mentoring program across three universities, and leading efforts within the WiML and Berkeley WiCSE communities of women researchers. \paragraph{Sergey Levine.} Sergey Levine received a BS and MS in Computer Science from Stanford University in 2009, and a Ph.D. in Computer Science from Stanford University in 2014. He joined the faculty of the Department of Electrical Engineering and Computer Sciences at UC Berkeley in fall 2016. His work focuses on machine learning for decision making and control, with an emphasis on deep learning and reinforcement learning algorithms. Applications of his work include autonomous robots and vehicles, as well as computer vision and graphics. He has previously served as the general chair for the Conference on Robot Learning, program co-chair for the International Conference on Learning Representations, and organizer for numerous workshops at ICML, NeurIPS, and RSS. He has also served as co-organizer on the \emph{Learning to Run} and \emph{AI for Prosthetics} NeurIPS competitions. \paragraph{Harm van Seijen.} Harm van Seijen is the team lead of the Reinforcement Learning team at Microsoft Research Montr\'{e}al, which focuses on fundamental challenges in reinforcement learning. Areas of research within reinforcement learning that he is currently very interested in are transfer learning, continual learning, hierarchical approaches, and multi-agent systems. In his most recent project, the team developed an approach to break down a complex task into many smaller ones, called the hybrid reward architecture. Using this architecture, they were able to achieve the highest possible score of 999,990 points on the challenging Atari 2600 game Ms. Pac-Man. \paragraph{Oriol Vinyals.} Oriol Vinyals is a Research Scientist at Google DeepMind, working in deep learning. Prior to joining DeepMind, Oriol was part of the Google Brain team. He holds a Ph.D. in EECS from the University of California, Berkeley and is a recipient of the 2016 MIT TR35 innovator award. His research has been featured multiple times at the New York Times, BBC, etc., and his articles have been cited over 29000 times. His academic involvement includes program chair for the International Conference on Learning Representations (ICLR) of 2017 and 2018. Some of his contributions are used in Google Translate, Text-To-Speech, and Speech recognition, used by billions. At DeepMind he continues working on his areas of interest, which include artificial intelligence, with particular emphasis on machine learning, deep learning and reinforcement learning. \subsubsection{Partners and Sponsors} \paragraph{Microsoft Research.} Microsoft Research is the research subsidiary of Microsoft. It is dedicated to conducting both basic and applied research in computer science and software engineering. It is collaborating with academic, government and industry researchers to advance the state of the art of computer science. Microsoft supports this competition by providing a substantial amount of cloud computing resource as necessary to help this competition operate smoothly. Further, Microsoft will provide computation/travel grants to enable the broadest set of groups to participate. Microsoft also provides technical advise for the competition and supports the communication for the organizer to reach out to relevant audience. \paragraph{Preferred Networks, Inc.} Preferred Networks (PFN) is known as the company behind Chainer, the first deep learning framework to adopt the define-by-run paradigm for intuitive modeling of neural networks. PFN also actively develops ChainerRL, a flexible and comprehensive deep reinforcement learning library built on top of Chainer. ChainerRL contains high-quality, efficient implementations of deep reinforcement learning algorithms spanning multiple common benchmark tasks and environments. PFN is happy to be a partner of this competition and provide baseline implementations based on ChainerRL enabling contestants to quickly and easily understand how the environment works, prototype new reinforcement learning algorithms and realize their own solutions for the competition. \subsection{Resources provided by organizers, including prizes} { \paragraph{Mentorship.} We will facilitate a community forum through a publicly available discord server to enable participants to ask questions, provide feedback, and engage meaningfully with our organizers and advisory board. We hope to foster an active community to collaborate on these hard problems and will award small prizes to members with the most helpful votes at the end of the first round. \paragraph{Computing Resources.} In concert with our efforts to provide open, democratized access to AI, through our generous sponsor, Microsoft, we will provide 50 large compute grants totaling \$40,000 USD for teams that self identify as lacking access to the necessary compute power to participate in the competition. We will also provide groups with the evaluation resources for their experiments in Round 2. We will work with various affinity groups to ensure that selection of recipients for these resources reflects our commitment to enabling the participation of underrepresented groups and competitors from universities without access to large amounts of funding and resources. \paragraph{Travel Grants and Scholarships.} The competition organizers are committed to increasing the participation of groups traditionally underrepresented in reinforcement learning and, more generally, in machine learning (including, but not limited to: women, LGBTQ individuals, underrepresented racial and ethnic minorities, and individuals with disabilities). To that end, we will offer Inclusion@NeurIPS scholarships/travel grants for Round 1 participants who are traditionally underrepresented at NeurIPS to attend the conference. These individuals will be able to apply online for these grants; their applications will be evaluated by the competition organizers and partner affinity groups. We also plan to provide travel grants to enable all of the top participants from Round 2 to attend our NeurIPS workshop. \paragraph{Prizes.} Currently in discussion with sponsors / partners. } \subsection{Support and facilities requested} Due to the quality of sponsorships and industry partnerships we have secured for the competition thus far, we only request facility resources. We aim to host a NeurIPS 2019 Workshop on the competition with approximately 250 seats. We will reserve spots for guest speakers, organizers, Round 2 participants, and Round 1 participants attending NeurIPS. We request poster stands or materials for hanging the posters of the Round 2 participants. Additionally, we will need a projector, podium, and elevated stage so that guest speakers, finalists, and organizers can present and address the workshop attendees.
{'timestamp': '2021-01-20T02:11:19', 'yymm': '1904', 'arxiv_id': '1904.10079', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.10079'}
arxiv
\section{Introduction} \begin{abstract} Refining and extending previous work by Retor\'e \cite{Retore}, we develop a systematic approach to intersection types via natural deduction. We show how a step of beta reduction can be seen as performing, at the level of typing derivations, Prawitz reductions in parallel. Then we derive as immediate consequences of Subject Reduction the main theorems about normalization for intersection types: for system $\D$, strong normalization, for system $\DO$, the leftmost reduction termination for terms typable without $\Omega$. \end{abstract} \section{Introduction} One of the most remarkable properties of the intersection type systems $\DO$ and $\D$ \cite{CD} is that they characterize the normalizable and strongly normalizable terms of $\lambda$-calculus. In turn, this characterization allows to prove in a logically grounded and elegant way several fundamental theorems about $\lambda$-calculus, like the \emph{uniqueness of normal forms} and the \emph{termination of the leftmost redex reduction} for normalizable terms \cite{Krivine}. Unfortunately, since they exploit normalization for $\DO$, the first intersection-types-based proofs of these results employed the Tait reducibility technique \cite{Krivine}, very well known for not conveying any combinatorial information and for its logical complexity. Using reducibility to prove elementary theorems about $\lambda$-calculus is definitely an overkill and the resulting proofs are so indirect that are barely comprehensible. For these reasons, we are interested here in giving an elementary, direct, conceptually elegant proof of normalization for $\DO$, which may be used in elementary introductions to typed and untyped $\lambda$-calculus. With our approach, it will turn out, the most important elementary results of $\lambda$-calculus can be proved as corollaries of the normalization theorem for simply typed $\lambda$-calculus. The first elementary, arithmetical proof of strong normalization for system $\D$ was provided by Retor\'e \cite{Retore}; then several others followed (e.g. \cite{Bucciarelli, Valentini, David, Aschieri}). The beauty of Retor\'e's approach is that one sees that actually\dots there is nothing to prove. If one moves to a Prawitz-style natural deduction presentation of intersection types, instead of sticking to Gentzen-style natural deduction, as it is traditionally done \cite{Krivine}, then strong normalization becomes just consequence of Subject Reduction and normalization for natural deduction. The reason is that Gentzen-style natural deduction is based on sequents and, as a typing system, uses explicit contexts. As a result, the proof reductions are quite cumbersome to write and nowhere near the elegance achievable using Prawitz natural deduction trees. In fact, the usual proofs of Subject Reduction \cite{Krivine} provide no direct transformation of the typing derivation of a term into the typing derivations of the reducts. Writing the transformation explicitly, indeed, would be ugly. But without doing that, one misses the logical perspective on intersection types. Retor\'e treated directly only strict intersection types, that is, types not allowing conjunction on the right of implications. This limitation is not present in \cite{RonchiPimentel}, but the approach is not as direct and simple as Retor\'e's. Indeed, strong normalization for $\D$ is deduced from strong normalization of a more complex logical system, where judgements are sequences of sequents, like in hypersequent calculi. Since each proof of this system can be translated as a sequence of parallel natural deductions, its strong normalization can be derived. The goal of this paper is to address these limitations and extend the natural deduction approach to the typing system $\DO$, while refining Retor\'e's treatment of system $\D$ and removing the restriction to strict types. As corollaries, we shall obtain strong normalization for $\D$ and normalization for $\DO$. A similar program was outlined in \cite{Dezani}, but never carried out in detail. Moreover, the suggested normalization argument for $\DO$ is presented as standard cut-elimination technique, where one reduces at each step natural-deduction redexes of maximal complexity. This argument, however, is not suitable for proving termination of the leftmost reduction strategy for $\lambda$-calculus. Achieving that requires subtle adjustments and carefully formulated inductive statements, and indeed none of the aforementioned natural-deduction-based works straightforwardly generalizes to $\DO$ so that it can accomplish our goals. \section{Natural Deduction for Intersection Types} In this section we define a natural deduction presentation of Coppo-Dezani intersection type systems $\D$ and $\DO$. These systems were invented with the aim of providing a logical characterization of strongly normalizable and normalizable $\lambda$-terms. Namely, the terms typable in $\D$ are exactly the strongly normalizable ones, while the terms typable in $\DO$ are precisely the normalizable ones. We shall start by presenting the type inference rules, then we define a reduction relation on typing derivations, which consists in applying Prawitz reductions in parallel to the corresponding natural deduction. \subsection{Typing Derivations} A \textbf{typing tree} is a tree whose nodes are expressions of the form $t: A$, where $t$ is a $\lambda$-term and $A$ is a type built from type variables and $\top$, using the connectives $\rightarrow, \land$. A typing tree $\mathcal{D}$ with root $t: A$ will be denoted as $\AxiomC{$\mathcal{D}$} \noLine \UnaryInfC{$t: A$} \DisplayProof$. With $\AxiomC{$x: A$} \noLine \UnaryInfC{$\mathcal{D}$} \DisplayProof$, we denote a typing tree such that for all leaves $x: A$ and $x: B$, we have $A=B$. A \textbf{typing derivation} in system $\DO$ is a typing tree obtained by means of the following inference rules. $$ \AxiomC{} \UnaryInfC{$x: A$} \DisplayProof \qquad \AxiomC{} \UnaryInfC{$t: \top$} \DisplayProof $$ $$ \AxiomC{$x: A$} \noLine \UnaryInfC{$\mathcal{D}$} \noLine \UnaryInfC{$u:B$} \UnaryInfC{$\lambda x\, u: A\rightarrow B$} \DisplayProof \qquad \AxiomC{$t: A\rightarrow B$} \AxiomC{$u: A$} \BinaryInfC{$t\, u: B$} \DisplayProof $$ \begin{prooftree} \AxiomC{$t: A$} \AxiomC{$t: B$} \BinaryInfC{$t: A\land B$} \end{prooftree} $$ \AxiomC{$t: A\land B$} \UnaryInfC{$t: A$} \DisplayProof \qquad \AxiomC{$t: A\land B$} \UnaryInfC{$t: B$} \DisplayProof $$ We observe that the only inference rule that requires a condition to be applied is the $\rightarrow$-introduction rule. One can only conclude $\lambda x\, u: A\rightarrow B$ when there is a typing derivation $\mathcal{D}$ of $u: B$ such that all the occurrences of $x$ are declared of the same type $A$. In general we allow variables to be declared of multiple types in the leaves of typing derivations, as polymorphism is the essence of intersection types. There is no special technical reason: we could very well have restricted variables to have unique types, but since there is no gain in doing this, we avoid the restriction. By construction, if $x_{1}: A_{1}, \dots, x_{n}: A_{n}$, are all the leaves of a typing derivation $\mathcal{D}$ of $t: A$ such that $x_{1}, \dots, x_{n}$ are free variables of $t$, then $\mathcal{D}$ is isomorphic to a natural deduction of $A$ from assumptions $ A_{1}, \dots, A_{n}$; such a $\mathcal{D}$ will be called \textbf{a typing derivation of $t: A$ from $x_{1}: A_{1}, \dots, x_{n}: A_{n}$}. Not all natural deductions, of course, are isomorphic to typing derivations: the $\land$-introduction can only be applied when the typing derivations of the premises type the \emph{same} term. As usual, $\D$ is the typing system obtained from $\DO$ by dropping the rule $\AxiomC{} \UnaryInfC{$t: \top$} \DisplayProof $. Moreover, we assume Barendregt's convention: in any context, free variables are always different from bound variables, so that there is no risk of capturing free variables when substituting terms for variables, as in $\beta$-reduction. \subsection{Reduction Relation on Typing Derivations} We now define the standard operation of derivation composition. With $\mathcal{D}[t/x]$ we shall denote the replacement of every occurrence of $x$ in $\mathcal{D}$ with the $\lambda$-term $t$. If $$ \AxiomC{$x: A$} \noLine \UnaryInfC{$\mathcal{D}$} \noLine \UnaryInfC{$u:B$} \DisplayProof \qquad \AxiomC{$\mathcal{E}$} \noLine \UnaryInfC{$t: A$} \DisplayProof$$ are two typing trees, the tree $$\AxiomC{$\mathcal{E}$} \noLine \UnaryInfC{$t: A$} \noLine \UnaryInfC{$\mathcal{D}[t/x]$} \noLine \UnaryInfC{$u[t/x]:B$} \DisplayProof $$ denotes the typing tree obtained from $\mathcal{D}[t/x]$ by replacing each leaf $\AxiomC{}\UnaryInfC{$t: A$}\DisplayProof$ with the typing tree $\AxiomC{$\mathcal{E}$} \noLine \UnaryInfC{$t: A$}\DisplayProof$. Indeed, this operation is a correct composition of typing derivations. \begin{proposition}[Typing Derivation Composition] Let $$ \AxiomC{$x: A$} \noLine \UnaryInfC{$\mathcal{D}$} \noLine \UnaryInfC{$u:B$} \DisplayProof \qquad \AxiomC{$\mathcal{E}$} \noLine \UnaryInfC{$t: A$} \DisplayProof$$ be two typing derivations. Then $$\AxiomC{$\mathcal{E}$} \noLine \UnaryInfC{$t: A$} \noLine \UnaryInfC{$\mathcal{D}[t/x]$} \noLine \UnaryInfC{$u[t/x]:B$} \DisplayProof $$ is a typing derivation \end{proposition} \begin{proof} By straightforward induction on $\mathcal{D}$. \end{proof} In Table \ref{tab:derred}, we axiomatically define a binary reduction relation $\rightsquigarrow$ on typing derivations. The lefthand-side derivations of the first two reductions are called respectively $\rightarrow$-redexes and $\land$-redexes. A typing derivation is $\land$-\textbf{normal} if it does not contain $\land$-redexes and it is \textbf{normal} if it is not in relation $\rightsquigarrow$ with any typing derivation. From the logical point of view, the relation $\rightsquigarrow$ formalizes the operation of performing several Prawitz reduction steps in parallel on the natural deduction associated to the typing derivation. Namely, we interpret the $\land$-introduction rule as a parallel composition of derivations. We remark that for the $\rightarrow$-elimination rule we do not allow parallel reductions, but this is a minimalistic design choice, rather than a necessity. From the computational point of view, indeed, the relation $\rightsquigarrow$ is intended to formalize the exact amount of Prawitz reductions needed to type a single step of $\beta$-reduction In the following we shall need the well-known notion of weak head reduction over $\lambda$-terms. \begin{definition}[Weak Head Reduction] For every $\lambda$-term $t$, we say that $t\mapsto t'$ by \textbf{weak head reduction} if $$t= (\lambda x\, u)\, v\, t_{1}\dots t_{n}$$ $$t'= u[v/x]\, t_{1}\dots t_{n}$$ \end{definition} \begin{table}[h] \hrule $$\AxiomC{$x: A$} \noLine \UnaryInfC{$\mathcal{D}$} \noLine \UnaryInfC{$u:B$} \UnaryInfC{$\lambda x\, u: A\rightarrow B$} \AxiomC{$\mathcal{E}$} \noLine \UnaryInfC{$t: A$} \BinaryInfC{$(\lambda x\, u) t: B$} \DisplayProof \qquad \rightsquigarrow \qquad \AxiomC{$\mathcal{E}$} \noLine \UnaryInfC{$t: A$} \noLine \UnaryInfC{$\mathcal{D}[t/x]$} \noLine \UnaryInfC{$u[t/x]:B$} \DisplayProof $$ $$ \AxiomC{$\mathcal{D}_{1}$} \noLine \UnaryInfC{$t: A_{1}$} \AxiomC{$\mathcal{D}_{2}$} \noLine \UnaryInfC{$t: A_{2}$} \BinaryInfC{$t: A_{1}\land A_{2}$} \UnaryInfC{$t: A_{i}$} \DisplayProof \qquad \rightsquigarrow \qquad \AxiomC{$\mathcal{D}_{i}$} \noLine \UnaryInfC{$t: A_{i}$} \DisplayProof $$ $$\AxiomC{$\mathcal{D}$} \noLine \UnaryInfC{$t: B$} \DisplayProof \rightsquigarrow \AxiomC{$\mathcal{D'}$} \noLine \UnaryInfC{$t': B$} \DisplayProof \qquad \Rightarrow \qquad \AxiomC{$\mathcal{D}$} \noLine \UnaryInfC{$t: B$} \UnaryInfC{$\lambda x\, t: A\rightarrow B$} \DisplayProof \rightsquigarrow \AxiomC{$\mathcal{D}'$} \noLine \UnaryInfC{$t': B$} \UnaryInfC{$\lambda x\, t': A\rightarrow B$} \DisplayProof $$ $$\AxiomC{$\mathcal{D}$} \noLine \UnaryInfC{$t: A_{1}\land A_{2}$} \DisplayProof \rightsquigarrow \AxiomC{$\mathcal{D'}$} \noLine \UnaryInfC{$t': A_{1}\land A_{2}$} \DisplayProof \qquad \Rightarrow \qquad \AxiomC{$\mathcal{D}$} \noLine \UnaryInfC{$t: A_{1}\land A_{2}$} \UnaryInfC{$t: A_{i}$} \DisplayProof \rightsquigarrow \AxiomC{$\mathcal{D}'$} \noLine \UnaryInfC{$t': A_{1}\land A_{2}$} \UnaryInfC{$ t': A_{i}$} \DisplayProof $$ $$\AxiomC{$\mathcal{D}$} \noLine \UnaryInfC{$t: A$} \DisplayProof \rightsquigarrow \AxiomC{$\mathcal{D}'$} \noLine \UnaryInfC{$t': A$} \DisplayProof, \AxiomC{$\mathcal{E}$} \noLine \UnaryInfC{$t: B$} \DisplayProof \rightsquigarrow \AxiomC{$\mathcal{E}'$} \noLine \UnaryInfC{$t': B$} \DisplayProof \qquad \Rightarrow \qquad \AxiomC{$\mathcal{D}$} \noLine \UnaryInfC{$t: A$} \AxiomC{$\mathcal{E}$} \noLine \UnaryInfC{$t: B$} \BinaryInfC{$t: A\land B$} \DisplayProof \rightsquigarrow \AxiomC{$\mathcal{D}'$} \noLine \UnaryInfC{$t': A$} \AxiomC{$\mathcal{E}'$} \noLine \UnaryInfC{$t': B$} \BinaryInfC{$t': A\land B$} \DisplayProof $$ $$\AxiomC{$\mathcal{D}$} \noLine \UnaryInfC{$t: A$} \DisplayProof \rightsquigarrow \AxiomC{$\mathcal{D}'$} \noLine \UnaryInfC{$t': A$} \DisplayProof \qquad \Rightarrow \qquad \AxiomC{$\mathcal{D}$} \noLine \UnaryInfC{$t: A\rightarrow B$} \AxiomC{$\mathcal{E}$} \noLine \UnaryInfC{$u: A$} \BinaryInfC{$t\, u: B$} \DisplayProof \rightsquigarrow \AxiomC{$\mathcal{D}'$} \noLine \UnaryInfC{$t': A\rightarrow B$} \AxiomC{$\mathcal{E}$} \noLine \UnaryInfC{$u: A$} \BinaryInfC{$t'\, u: B$} \DisplayProof $$ $$\AxiomC{$\mathcal{E}$} \noLine \UnaryInfC{$u: A$} \DisplayProof \rightsquigarrow \AxiomC{$\mathcal{E}'$} \noLine \UnaryInfC{$u': A$} \DisplayProof \qquad \Rightarrow \qquad \AxiomC{$\mathcal{D}$} \noLine \UnaryInfC{$t: A\rightarrow B$} \AxiomC{$\mathcal{E}$} \noLine \UnaryInfC{$u: A$} \BinaryInfC{$t\, u: B$} \DisplayProof \rightsquigarrow \AxiomC{$\mathcal{D}$} \noLine \UnaryInfC{$t: A\rightarrow B$} \AxiomC{$\mathcal{E}'$} \noLine \UnaryInfC{$u': A$} \BinaryInfC{$t\, u': B$} \DisplayProof $$ \hrule \caption{Reduction relation on typing derivations}\label{tab:derred} \end{table} \section{Subject Reduction} The goal of this section is to prove Subject Reduction for system $\D$. We instead prove later a Subjection Reduction for system $\DO$, because in $\DO$ we are only interested in the contraction of the leftmost redex. Since the relation $\rightsquigarrow$ embodies a Prawitz-style transformation of natural deductions, it always terminates. \begin{proposition} The reduction relation $\rightsquigarrow$ is strongly normalizing. \end{proposition} \begin{proof} It is straightforward to prove, by induction on $\mathcal{D}$, that if $\mathcal{D}\rightsquigarrow\mathcal{D'}$, the natural deduction corresponding to $\mathcal{D}$ reduces in a certain number of steps to the natural deduction corresponding to $\mathcal{D}'$, using the standard Prawitz reductions for $\rightarrow$ and $\land$. Therefore, the relation $\rightsquigarrow$ produces no infinite reduction path. \end{proof} Eliminating the useless $\land$-redex from typing derivations restores an important property of the simply typed $\lambda$-calculus: the only way to type a function with arrow type is by a $\rightarrow$-introduction. \begin{proposition}[Introduce!]\label{prop:introduce} Suppose $\mathcal{D}$ is a $\land$-normal typing derivation of $\lambda x\, u: T\neq \top$ whose last rule is not an $\land$-introduction. Then $$\mathcal{D}= \AxiomC{$x: A$} \noLine \UnaryInfC{$\mathcal{D}'$} \noLine \UnaryInfC{$u:B$} \UnaryInfC{$\lambda x\, u: A\rightarrow B$} \DisplayProof$$ with $T=A\rightarrow B$. \end{proposition} \begin{proof} We proceed by induction on $\mathcal{D}$ and by cases according to the last rule of $\mathcal{D}$. We observe that the last rule cannot be a leaf nor an $\rightarrow$ elimination, because the conclusion of $\mathcal{D}$ is not a variable nor an application and $T\neq \top$. Therefore, only two rules can be applied: \begin{itemize} \item The last rule of $\mathcal{D}$ is a $\rightarrow$-introduction. This is the thesis. \item $\mathcal{D}= \AxiomC{$\mathcal{E}$} \noLine \UnaryInfC{$\lambda x\, u: B_{1}\land B_{2}$} \UnaryInfC{$\lambda x\, u: B_{i}$} \DisplayProof$, with $T=B_i$. We show that this case is impossibile. Since $\mathcal{D}$ is $\land$-normal, the last rule of $\mathcal{E}$ is not an $\land$-introduction. But by induction hypothesis the last rule of $\mathcal{E}$ must be an $\rightarrow$-introduction, which is a contradiction. \end{itemize} \end{proof} We can now prove Subject Reduction in the usual way. The proof makes explicit the transformations that are implicit in the usual presentations of intersection types. \begin{theorem}[Subject Reduction for $\D$]\label{thm:subject} Suppose $\mathcal{D}$ is a typing derivation of $t: A$ in $\D$. Then $$t\mapsto t' \qquad \Rightarrow\qquad \AxiomC{$\mathcal{D}$} \noLine \UnaryInfC{$t: A$} \DisplayProof \rightsquigarrow^{+} \AxiomC{$\mathcal{D}'$} \noLine \UnaryInfC{$t': A$} \DisplayProof $$ \begin{proof} By straightforward induction on $\mathcal{D}$. \end{proof} \end{theorem} \section{Strong Normalization} As corollary of Subject Reduction we obtain strong normalization for system $\D$. \begin{theorem}[Strong Normalization] Suppose that $\mathcal{D}$ is a typing derivation of $t: A$ in $\D$. Then $t$ is strongly normalizable. \end{theorem} \begin{proof} We proceed by induction on the longest reduction of $\mathcal{D}$. If $t\mapsto t'$, then by Theorem \ref{thm:subject} we obtain $ \AxiomC{$\mathcal{D}$} \noLine \UnaryInfC{$t: A$} \DisplayProof \rightsquigarrow^{} \AxiomC{$\mathcal{D}'$} \noLine \UnaryInfC{$t': A$} \DisplayProof $ By induction hypothesis, $t$ is strongly normalizable. Since $t$ reduces only to strongly normalizable terms, it is strongly normalizable. \end{proof} \section{Normalization by Leftmost Redex Reduction} Before proving normalization for system $\DO$, we need a standard fact about intersection types. \begin{proposition}\label{prop:subtype} Suppose that $\mathcal{D}$ is an $\land$-normal typing derivation of $x\, t_{1}\dots t_{n}: A\neq \top$ in $\DO$ from $x_{1}: A_{1}, \dots, x_{m}: A_{m}$ and the last rule of $\mathcal{D}$ is not an $\land$-introduction. Then $A$ is a subformula of one among $A_{1}, \dots, A_{m}$. \end{proposition} \begin{proof} By induction on $\mathcal{D}$ and by cases according to the last rule of $\mathcal{D}$. We must consider only the following cases. \begin{itemize} \item $n=0$ and $\mathcal{D}= \AxiomC{} \UnaryInfC{$x: A_{i}$} \DisplayProof$, with $x=x_{i}$ and $A=A_{i}$. Then thesis is verified. \item $\mathcal{D}= \AxiomC{$\mathcal{E}$} \noLine \UnaryInfC{$x\, t_{1}\dots t_{n-1}: B\rightarrow A$} \AxiomC{$\mathcal{F}$} \noLine \UnaryInfC{$t_{n}: B$} \BinaryInfC{$x\, t_{1}\dots t_{n-1}\, t_{n}: A$}\DisplayProof$. The last rule of $\mathcal{E}$ is not an $\land$-introduction, therefore by induction hypothesis $B\rightarrow A$ must be a subformula of one among $A_{1}, \dots, A_{m}$, thus $A$ satisfies the thesis. \item $\mathcal{D}= \AxiomC{$\mathcal{E}$} \noLine \UnaryInfC{$x\, t_{1}\dots t_{n}: B_{1}\land B_{2}$} \UnaryInfC{$x\, t_{1}\dots t_{n}: B_{i}$} \DisplayProof$, with $A=B_i$. Since $\mathcal{D}$ is $\land$-normal, the last rule of $\mathcal{E}$ is not an $\land$-introduction, therefore by induction hypothesis $B_{1}\land B_{2}$ must be a subformula of one among $A_{1}, \dots, A_{m}$, thus $B_{i}$ satisfies the thesis. \end{itemize} \end{proof} We now prove the version of the Subject Reduction that we need for system $\DO$: by contracting the leftmost redex of a typable $\lambda$-term $t$, we induce a reduction of its typing derivation, provided $t$ is typable without $\top$. Intuitively, the leftmost redex cannot be inside a subterm of $t$ having type $\top$, the only case in which we would not have any transformation of the natural deduction associated to the typing derivation. \begin{lemma}[On the Left!]\label{lem:step} Suppose that $\mathcal{D}$ is a $\land$-normal typing derivation of $t: A\neq \top$ in $\DO$ from $x_{1}: A_{1}, \dots, x_{n}: A_{n}$. Then: \begin{enumerate} \item If the last rule of $\mathcal{D}$ is not a $\land$-introduction and $t\mapsto t'$ by weak head reduction, then $$ \AxiomC{$\mathcal{D}$} \noLine \UnaryInfC{$t: A$} \DisplayProof \rightsquigarrow^{+} \AxiomC{$\mathcal{D}'$} \noLine \UnaryInfC{$t': A$} \DisplayProof $$ \item If $A_{1}, \ldots, A_{n}, A$ do not contain $\top$ and $t\mapsto t'$ by leftmost redex reduction, then $$ \AxiomC{$\mathcal{D}$} \noLine \UnaryInfC{$t: A$} \DisplayProof \rightsquigarrow^{+} \AxiomC{$\mathcal{D}'$} \noLine \UnaryInfC{$t': A$} \DisplayProof $$ \end{enumerate} \end{lemma} \begin{proof} We prove 1. and 2. simultaneously by induction on the size of $\mathcal{D}$ and by cases according to the last rule of $\mathcal{D}$. \begin{itemize} \item $\mathcal{D}= \AxiomC{} \UnaryInfC{$x: A$} \DisplayProof$. This case is not possible, since $x$ does not reduce to any term.\\ \item $\mathcal{D}= \AxiomC{} \UnaryInfC{$t: \top$} \DisplayProof$, with $A=\top$. This case is not possible, since $A\neq\top$ by hypothesis.\\ \item $\mathcal{D}= \AxiomC{$x: B$} \noLine \UnaryInfC{$\mathcal{D}'$} \noLine \UnaryInfC{$u:C$} \UnaryInfC{$\lambda x\, u: B\rightarrow C$} \DisplayProof$ with $t=\lambda x\, u$, $t'=\lambda x\, u'$, $u\mapsto u'$ and $A=B\rightarrow C$. We observe that 1. is trivially true, since $t$ reduces to nothing by weak head reduction. Moving on to 2., we can apply the induction hypothesis to $\AxiomC{$\mathcal{D}'$} \noLine \UnaryInfC{$u: C$} \DisplayProof$, since $B$ does not contain $\top$ according to the hypotheses. We thus obtain $$ \AxiomC{$\mathcal{D}'$} \noLine \UnaryInfC{$u: C$} \DisplayProof \rightsquigarrow^{+} \AxiomC{$\mathcal{D}''$} \noLine \UnaryInfC{$u': C$} \DisplayProof $$ Therefore, $$\mathcal{D}= \AxiomC{$x: B$} \noLine \UnaryInfC{$\mathcal{D}'$} \noLine \UnaryInfC{$u: C$} \UnaryInfC{$\lambda x\, u: B\rightarrow C$} \DisplayProof \rightsquigarrow^{+} \AxiomC{$x: B$} \noLine \UnaryInfC{$\mathcal{D}''$} \noLine \UnaryInfC{$u': C$} \UnaryInfC{$\lambda x\, u': B\rightarrow C$} \DisplayProof$$ \item $\mathcal{D}= \AxiomC{$\mathcal{E}$} \noLine \UnaryInfC{$u: B\rightarrow A$} \AxiomC{$\mathcal{F}$} \noLine \UnaryInfC{$v: B$} \BinaryInfC{$u\, v: A$}\DisplayProof$, with $t= u\, v$. If $t\mapsto t'$ by weak head reduction, either $u\mapsto u'$ by weak head reduction and $t'=u'\, v$, or $u=\lambda x\, w$ and $t'= w[v/x]$. In the first case, the last rule of $\mathcal{E}$ cannot be an $\land$-introduction, so by induction hypothesis 1. we obtain $$ \AxiomC{$\mathcal{E}$} \noLine \UnaryInfC{$u: B\rightarrow A$} \DisplayProof \rightsquigarrow^{+} \AxiomC{$\mathcal{E}'$} \noLine \UnaryInfC{$u': B\rightarrow A$} \DisplayProof $$ therefore, $$ \AxiomC{$\mathcal{E}$} \noLine \UnaryInfC{$u: B\rightarrow A$} \AxiomC{$\mathcal{F}$} \noLine \UnaryInfC{$v: B$} \BinaryInfC{$u\, v: A$}\DisplayProof \rightsquigarrow^{+} \AxiomC{$\mathcal{E}'$} \noLine \UnaryInfC{$u': B\rightarrow A$} \AxiomC{$\mathcal{F}$} \noLine \UnaryInfC{$v: B$} \BinaryInfC{$u'\, v: A$}\DisplayProof$$ which proves 1. and 2. In the second case, since $\mathcal{E}$ is by hypothesis $\land$-normal, by Proposition \ref{prop:introduce}, $$\mathcal{E}= \AxiomC{$x: B$} \noLine \UnaryInfC{$\mathcal{E}'$} \noLine \UnaryInfC{$w:A$} \UnaryInfC{$\lambda x\, w: B\rightarrow A$} \DisplayProof $$ Therefore, $$ \AxiomC{$\mathcal{E}$} \noLine \UnaryInfC{$u: B\rightarrow A$} \AxiomC{$\mathcal{F}$} \noLine \UnaryInfC{$v: B$} \BinaryInfC{$u\, v: A$}\DisplayProof = \AxiomC{$x: B$} \noLine \UnaryInfC{$\mathcal{E}'$} \noLine \UnaryInfC{$w: A$} \UnaryInfC{$\lambda x\, w: B\rightarrow A$} \AxiomC{$\mathcal{F}$} \noLine \UnaryInfC{$v: B$} \BinaryInfC{$(\lambda x\, w)\, v: A$}\DisplayProof \rightsquigarrow^{+} \AxiomC{$\mathcal{F}$} \noLine \UnaryInfC{$v: B$} \noLine \UnaryInfC{$\mathcal{E}'[v/x]$} \noLine \UnaryInfC{$w[v/x]:A$} \DisplayProof $$ which proves 1. and 2. We can now assume that $t\mapsto t'$ not by weak head reduction, thus we are left to prove 2. Since, $t$ has no head redex, $t=x\, t_{1}\dots t_{m}$, with $u=x\, t_{1}\dots t_{m-1}$ and $v=t_{m}$. By Proposition \ref{prop:subtype}, $B\rightarrow A$ must be a subformula of some $A_{i}$. Therefore $B\rightarrow A$ and $B$ do not contain $\top$. Since $t'= u'\, v$, with $u\mapsto u'$, or $t'= u\, v'$, with $v\mapsto v'$, by induction hypothesis respectively $$ \AxiomC{$\mathcal{E}$} \noLine \UnaryInfC{$u: B\rightarrow A$} \DisplayProof \rightsquigarrow^{+} \AxiomC{$\mathcal{E}'$} \noLine \UnaryInfC{$u': B\rightarrow A$} \DisplayProof $$ or $$ \AxiomC{$\mathcal{F}$} \noLine \UnaryInfC{$v: B$} \DisplayProof \rightsquigarrow^{+} \AxiomC{$\mathcal{F}'$} \noLine \UnaryInfC{$v': B$} \DisplayProof $$ Therefore, $$ \AxiomC{$\mathcal{E}$} \noLine \UnaryInfC{$u: B\rightarrow A$} \AxiomC{$\mathcal{F}$} \noLine \UnaryInfC{$v: B$} \BinaryInfC{$u\, v: A$}\DisplayProof \rightsquigarrow^{+} \AxiomC{$\mathcal{E}'$} \noLine \UnaryInfC{$u': B\rightarrow A$} \AxiomC{$\mathcal{F}$} \noLine \UnaryInfC{$v: B$} \BinaryInfC{$u'\, v: A$}\DisplayProof$$ or $$ \AxiomC{$\mathcal{E}$} \noLine \UnaryInfC{$u: B\rightarrow A$} \AxiomC{$\mathcal{F}$} \noLine \UnaryInfC{$v: B$} \BinaryInfC{$u\, v: A$}\DisplayProof \rightsquigarrow^{+} \AxiomC{$\mathcal{E}$} \noLine \UnaryInfC{$u: B\rightarrow A$} \AxiomC{$\mathcal{F}'$} \noLine \UnaryInfC{$v': B$} \BinaryInfC{$u\, v': A$}\DisplayProof$$ which is the thesis. \item $\mathcal{D}= \AxiomC{$\mathcal{E}$} \noLine \UnaryInfC{$t: C$} \AxiomC{$\mathcal{F}$} \noLine \UnaryInfC{$t: B$} \BinaryInfC{$t: C\land B$} \DisplayProof$, with $A=C\land B$. By hypothesis on $\mathcal{D}$, 1. is trivially true, we thus prove 2. Since $C\land B$ does not contain $\top$, also $C$ and $B$ do not contain $\top$. Therefore by induction hypothesis 2., we get $$ \AxiomC{$\mathcal{E}$} \noLine \UnaryInfC{$t: C$} \DisplayProof \rightsquigarrow^{+} \AxiomC{$\mathcal{E}'$} \noLine \UnaryInfC{$t': C$} \DisplayProof $$ $$ \AxiomC{$\mathcal{F}$} \noLine \UnaryInfC{$t: B$} \DisplayProof \rightsquigarrow^{+} \AxiomC{$\mathcal{F}'$} \noLine \UnaryInfC{$t': B$} \DisplayProof $$ thus $$\AxiomC{$\mathcal{E}$} \noLine \UnaryInfC{$t: C$} \AxiomC{$\mathcal{F}$} \noLine \UnaryInfC{$t: B$} \BinaryInfC{$t: C\land B$} \DisplayProof \rightsquigarrow^{+} \AxiomC{$\mathcal{E}'$} \noLine \UnaryInfC{$t': C$} \AxiomC{$\mathcal{F}'$} \noLine \UnaryInfC{$t': B$} \BinaryInfC{$t': C\land B$} \DisplayProof$$ which proves 2. \item $\mathcal{D}= \AxiomC{$\mathcal{E}$} \noLine \UnaryInfC{$t: B_{1}\land B_{2}$} \UnaryInfC{$t: B_{i}$} \DisplayProof$, with $A=B_{i}$. We first observe that $t$ cannot start with $\lambda$, otherwise, since $\mathcal{D}$ is $\land$-normal and thus the last rule of $\mathcal{E}$ cannot be an $\land$-introduction, by Proposition \ref{prop:introduce} we would obtain that the last rule of $\mathcal{E}$ is a $\rightarrow$-introduction. Now, if $t\mapsto t'$ by weak head reduction, then by induction hypothesis 1., we get $$ \AxiomC{$\mathcal{E}$} \noLine \UnaryInfC{$t: B_{1}\land B_{2}$} \DisplayProof \rightsquigarrow^{+} \AxiomC{$\mathcal{E}'$} \noLine \UnaryInfC{$t': B_{1}\land B_{2}$} \DisplayProof $$ thus $$\AxiomC{$\mathcal{E}$} \noLine \UnaryInfC{$t: B_{1}\land B_{2}$} \UnaryInfC{$t: B_{i}$} \DisplayProof \rightsquigarrow^{+} \AxiomC{$\mathcal{E}'$} \noLine \UnaryInfC{$t': B_{1}\land B_{2}$} \UnaryInfC{$t': B_{i}$} \DisplayProof $$ which proves 1. and 2. Therefore, we can assume that $t\mapsto t'$ not by weak head reduction and we are left to prove 2. Since $t$ does not start with $\lambda$, it has no head redex, thus $t= x\, t_{1}\dots t_{m}$. By Proposition \ref{prop:subtype}, applied to $\mathcal{E}$, we obtain that $B_{1}\land B_{2}$ is a subformula of some among $A_{1}, \dots, A_{n}$, hence $B_{1}\land B_{2}$ cannot contain $\top$. By induction hypothesis, $$ \AxiomC{$\mathcal{E}$} \noLine \UnaryInfC{$t: B_{1}\land B_{2}$} \DisplayProof \rightsquigarrow^{+} \AxiomC{$\mathcal{E}'$} \noLine \UnaryInfC{$t': B_{1}\land B_{2}$} \DisplayProof $$ and we obtain the thesis. \end{itemize} \end{proof} We now prove that every term typable in $\DO$ without $\top$ is normalizable by leftmost redex reduction. The natural deduction proof sheds new light on this fundamental result. Every reduction step contracting the leftmost redex is actually a combination of reduction steps at the level of the natural deduction corresponding to the typing derivation. When this natural deduction reaches normal form, the term is in normal form. We also remark that the subformula property must hold. Since the term is typable without $\top$, the normal derivation is actually a derivation in system $\D$! This means that the subterms having type $\top$ are systematically erased. \begin{theorem}[Normalization by Leftmost Redex Reduction]\label{thm:norm} Suppose that $\mathcal{D}$ is a typing derivation of $t: A$ in $\DO$ from $x_{1}: A_{1}, \dots, x_{n}: A_{n}$ such that $A_{1}, \ldots, A_{n}, A$ do not contain $\top$. Then the leftmost redex reduction of $t$ terminates. \end{theorem} \begin{proof} We proceed by induction on the longest reduction of $\mathcal{D}$. We have that $ \AxiomC{$\mathcal{D}$} \noLine \UnaryInfC{$t: A$} \DisplayProof \rightsquigarrow^{*} \AxiomC{$\mathcal{D}'$} \noLine \UnaryInfC{$t: A$} \DisplayProof $, where $\mathcal{D}'$ is $\land$-normal. If $t$ is normal we are done. If $t\mapsto t'$ by leftmost redex reduction, by Lemma \ref{lem:step} we obtain $ \AxiomC{$\mathcal{D}'$} \noLine \UnaryInfC{$t: A$} \DisplayProof \rightsquigarrow^{+} \AxiomC{$\mathcal{D}''$} \noLine \UnaryInfC{$t': A$} \DisplayProof $ By induction hypothesis, the leftmost redex reduction of $t$ terminates, which yields the thesis. \end{proof}
{'timestamp': '2019-04-24T02:04:42', 'yymm': '1904', 'arxiv_id': '1904.10106', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.10106'}
arxiv
\section{Introduction} \label{intro} Convolutional neural network (CNN) models have surpassed human performance on image classification benchmarks like Imagenet (\cite{he2015delving, deng2009imagenet}). However, their predictions are often sensitive to small image transformations (\cite{szegedy2013intriguing, polar_bear}) that are visually imperceptible to humans. In contrast, human visual systems are robust to a wide variety of distortions, including color and noise distortions (\cite{geirhos2018generalisation}). Our goal is to systematically study this phenomenon of model brittleness to small image transformations to better understand and improve the robustness of computer vision models. Previously, model brittleness has commonly been studied through the framework of adversarial examples, where example images with minute but carefully constructed modifications can fool an otherwise accurate model (\cite{szegedy2013intriguing,kurakin2016adversarial,carlini2017adversarial}). Recent work has found that models are also brittle to examples that are not adversarially constructed. For instance, models are found to be sensitive to changes in camera settings such as exposure and contrast (\cite{temel2018traffic}), small translations and rotations (\cite{polar_bear, engstrom2017rotation}), and imperceptible variations across consecutive video frames (\cite{polar_bear}). Convolutional models are much more brittle than humans to synthetic distortions when the same distortions are not used during training. However, models trained on specific distortions can outperform humans on those specific distortions (\cite{geirhos2018generalisation}). To better evaluate the extent of model brittleness in the non-adversarial setting, the community has proposed datasets to benchmark robustness (\cite{hendrycks2018benchmarking} and \cite{temel2018traffic}). These proposed datasets mimic real world scenarios using increasingly more realistic synthetic distortions, such as perturbing clean images with artificial fog and snow. We present the first study of CNN robustness to natural transformations found across nearby video frames. We term this "natural robustness". This is an important type of robustness, because it models a diverse range of transformations that are closer to changes that occur in the natural environment than the synthetic distortions previously studied. We provide a framework, with dataset and evaluation metrics, to systematically evaluate natural robustness. Our results show that \begin{enumerate} \item More accurate image model architectures are more robust to natural evaluations. \item Small translations and synthetic color distortions are good proxies for evaluating natural robustness. \item No single regularization technique systematically improves natural robustness across model architectures. \end{enumerate} \section{Robustness Metrics}\label{sec:metric} Given a correct classification on one frame, we define natural robustness as the conditional accuracy on the neighboring frame, similar to the Jaggedness measure (\cite{polar_bear}). More formally, let $f:X \rightarrow Y$ be a model mapping from input space $X$ to prediction space $Y$, and $d:X \rightarrow X$ defines an image transformation function. The robustness of a model $f$ is defined as $R_d(f) = P(f((d(x)) = y | f(x) = y)$, where $y$ is the ground truth. We consider two kinds of transformations: 1) Synthetic distortions, such as adjusting the color saturation of an image, adding noise, etc., and 2) natural transformations that exist across consecutive frames of videos. Unlike some prior definitions of model robustness, our robustness definition is agnostic to the kind of transformation function. In \cite{hendrycks2018benchmarking}, robustness according to the relative mCE is defined to be proportional to $P(f(x) = y) - P(f(d(x)) = y)$. This formulation implicitly assumes that transformed images come from different distribution than the clean images, and are harder to classify. This robustness metric is trivial when considering natural robustness, because neighboring frames come from the same distribution and are equally difficult to classify. \section{Experimental Study Setup} \label{study_setup} \subsection{Dataset} We leverage a large scale dataset of videos, YouTube-BoundingBoxes(YT-BB) (\cite{real2017youtube}), to evaluate natural robustness. YT-BB contains 380K video segments of 15-20s across 210K unique videos and 24 classes. Each segment is selected to feature objects in natural settings without editing or post-processing. See Figure \ref{fig:example_data} for examples of both natural transformations and synthetic distortions. \subsection{Task} We create a classification task from YT-BB to train our image classification model. This ensures domain matching between images used during training and the video frames used during robustness evaluation. Prior work used handpicked YouTube videos to evaluate image models trained on ImageNet (\cite{polar_bear}). However, domain mismatch between training and evaluation can result in a significant drop in test accuracy. In our evaluation, we found that evaluating off-the-shelf ImageNet models on the YT-BB classification tasks, without finetuning, results in an average of 27\% drop in accuracy across 12 model architectures. To create this classification task, we split 210K videos into training, validation, and test. We divide the videos into contiguous shots of a single object, and randomly sample a subset of 56,209 frames from unique shots, which we term "anchor frames". These anchor frames make up the supervised classification task across 23 imbalanced classes. We then extract 5 consecutive frames at 15Hz before and after the anchor frames to evaluate natural robustness. The top row of figure \ref{fig:example_data} illustrates an example anchor frame and its neighbors, which we term "natural transformations". Neighboring frames are only used to evaluate natural robustness. Only anchor frames are used during training. For reproducibility, we release the video robustness dataset with exact anchor frames used in train, validation, and test in the ArXiv directory. \subsection{Models} We examine the robustness of 12 model architectures: VGG16, VGG19 (\cite{vgg-simonyan2014very}), ResNet-V1-50, ResNet-V1-101, ResNet-V1-152 (\cite{resnet-he2016deep}), MobileNet-V1 (\cite{howard2017mobilenets}), NASNet-Mobile (\cite{nasnet-zoph2018learning}), Inception-V1 (\cite{inception1-szegedy2015going}), Inception-V2, Inception-V3 (\cite{inception23-szegedy2016rethinking}), Inception-V4 (\cite{inception4-szegedy2017inception}), and Inception-ResNet-V2 (\cite{inception-resnet-szegedy2017inception}). For each model architecture, we train models on the YT-BB task from scratch and using transfer learning from pre-trained ImageNet checkpoints. We tune hyper-parameters using the same search space for every model independently. This gives us a total of 24 baseline models with a wide range of accuracy on this task. The preprocessing stage during training is particularly critical in determining the robustness of models against synthetic distortions. \cite{geirhos2018generalisation} demonstrated that training on synthetic distortions will disproportionately improve robustness to the distortion used during training. To ensure that our evaluation across models are fair and comparable, we use the same preprocessing step during all model training, using only random crop and resizing, skipping the color distortions that is typically used for training Inception models. \subsection{Natural Transformations and Synthetic Distortions} For each anchor frame in our classification task, we sample 10 neighboring frames, 5 frames before and after the anchor frames, at 15Hz. We call these neighboring frames the natural transformations of the anchor image. Similar to synthetic distortions, we can adjust the strength of the transformation defined by the temporal difference between the anchor and neighboring frame. We also evaluated model robustness to synthetic distortions for comparison against natural robustness. We implemented 10 varieties of synthetic distortions at 5 different levels of severity. We selected the following synthetic distortions from prior work: gaussian noise, gaussian blur, pixelate, shot noise, JPEG quality, hue, contrast, saturation, brightness, and small translations (\cite{hendrycks2018benchmarking, polar_bear, geirhos2018generalisation}). \cite{polar_bear} showed that the implementation of the translation distortion can significantly affect the results. In our implementation, we shift the evaluation crop of the image to create a set of translations, without introducing empty space or the need for in-painting. \section{Results} We examine the result of evaluating each of the 24 fully trained models, of 12 model architectures, on 11 transformations, each with 5 varying strengths. For the 12 models trained from scratch, the Top-1 accuracy on the 23-class YTBB classification task ranges from 72.5\% to 80.4\%. The same architectures fine-tuned from ImageNet obtained accuracy ranging from 83.90\% and 88.7\%. \subsection{Frames temporally closer in time have more similar model outputs} \begin{figure}[h] \begin{center} \includegraphics[width=\columnwidth]{figures/robustness_over_time6.png} \end{center} \caption{ {\bf Video frames that are closer in time (more visually similar) are more likely to result in similar model predictions.} We plot natural robustness as a function of the time elapsed between two frames, conditioned on the first frame being classified correctly. Model colors are determined by their test accuracy, ranging from 88.7\% (Inception-ResNet-V2) to 83.9\% (MobileNet-V1), when finetuned from ImageNet. Left: models fine-tuned on YT-BB task from ImageNet. Right: models trained on YT-BB task from scratch. } \label{fig:robustness_over_time} \end{figure} We expect our models to exhibit the property that more visually similar images have more similar outputs. During our evaluation, we found that this is indeed true. As seen in Figure \ref{fig:robustness_over_time}, frame pairs temporally closer together are more likely to be both classified correctly. We also evaluated the robustness of YT-BB models on synthetic distortions. The result can be found in \ref{fig:synth_robustness_over_time}. Our result reproduces that of \cite{geirhos2018generalisation}, showing that models are not robust to synthetic distortions and that robustness drops significantly as the severity of distortions increase. \subsection{More accurate models are more robust} \begin{figure}[h] \begin{center} \includegraphics[width=\columnwidth]{figures/natural_robustness8.png} \end{center} \caption{ {\bf More accurate models are generally more robust.} We plot the average robustness to two in-distribution transformations: translation (left) and natural transformation (right) against model accuracy. Robustness measure is averaged across 5 varying strengths of distortions. See Figure \ref{fig:robustness_over_time} for a common color legend. Models fine-tuned from ImageNet are borderless. } \label{fig:natural_robustness} \end{figure} \begin{figure}[h] \begin{center} \includegraphics[width=4.5in]{figures/synthetic_robustness10} \end{center} \caption{ {\bf Model accuracy on the test set is positively correlated with model robustness to synthetic color distortions but not correlated to robustness to other noisy synthetic distortions}. Plots are ordered based on $R^2$. Note that all models are with only random crop and resizing during preprocessing. See Figure \ref{fig:robustness_over_time} for a common legend. Models fine-tuned from ImageNet are borderless. } \label{fig:synthetic_robustness} \end{figure} We summarize each model's robustness to a given transformation as the average across varying strengths. In Figure \ref{fig:natural_robustness}, we see a strong correlation between model accuracy and robustness to both translation and natural transformations found in videos. The result on translation robustness contradicts the conclusion of \cite{polar_bear}, which states modern networks are less translation invariant. \cite{polar_bear} measure translation invariance by training their models on full-sized images, then evaluating their models by embedding the image within a larger image. This introduces a large change between training and evaluation, and Figure 8 in \cite{polar_bear} indicates the closer embedded size is to the original image, the more robust models are. Our work is focused on evaluating robustness to small transformations that are close to or even in the same distribution as those seen in training. Figure \ref{fig:synthetic_robustness} shows that more accurate models are also more robust to a number of synthetic distortions such as saturation, hue, and brightness. This conclusion is different from that of \cite{hendrycks2018benchmarking}, which claimed that model robustness is largely uncorrelated with model accuracy, according to their relative mCE metric. However, according to their unadjusted mCE robustness metric, more accurate classifiers are more accurate on the corrupted test set. As described in Sec. \ref{sec:metric}, the relative mCE metric is proportional to the drop in total accuracy from clean images to corrupted images. Our metric performs a more fine-grained measure of robustness, by computing accuracy on the corrupted image conditional on the clean image being classified correctly, rather than simply using the total accuracies. \subsection{Synthetic distortions as proxies of natural transformations} \begin{figure}[h] \begin{center} \includegraphics[width=3in]{figures/correlations4} \end{center} \caption{ {\bf Image translation, and synthetic adjustments to saturation and hue are good proxies for evaluating natural robustness.} We evaluate the correlation between pairs of robustness types to identify easy-to-implement proxies for evaluating natural robustness. Each pair of correlations is computed over 24 fully trained and tuned models across 12 model architectures. } \label{fig:correlations} \end{figure} In many settings, it's difficult to acquire domain-matching videos to evaluate natural robustness. We evaluate model robustness across 10 different synthetic distortions, and compute the correlation between different types of robustness. Shown in Figure \ref{fig:correlations}, we find that robustness to image translation and color distortions like saturation and hue are highly correlated with natural robustness, which indicates that these are good proxies for natural robustness in image models. \subsection{Distances between neighboring frames are much larger than distances between adversarial examples} \begin{figure}[h] \begin{center} \includegraphics[width=2.5in]{figures/adversarial_3_2.png} \end{center} \caption{ {\bf Distances between neighboring frames are larger than distances between typical adversarial examples. The same holds for neighboring frames that exhibit brittleness.} We plot the cumulative distribution (CDF) of $L_\infty$ norm for all frame pairs 66ms apart (black), and the CDF for pairs that exhibit brittleness. Only $1.6\%$ of normal frame pairs and less than $0.01\%$ of frame pairs that exhibit brittleness are found in the typical adversarial examples neighborhood. } \label{fig:adversarial} \end{figure} We next investigated the relationship between brittleness to natural transformations and adversarial examples. Adversarial examples are commonly defined as images within an $\epsilon-$ball of the clean image by $L_\infty$ norm that results in a mis-classification. In Figure \ref{fig:adversarial}, we analyze the distribution of 10,000 video frame pairs, all 66ms apart. The distribution of distances between consecutive frames have a mean of 213 and standard deviation of 49.1, which is much larger than what is typically considered for adversarial examples (less than an $\epsilon=16$ in $L_\infty$ space (\cite{kannan2018adversarial}). We then study frame pairs that exhibit brittleness, where the anchor frame is classified correctly but its neighbor is mistaken. Less than 0.01\% of frame pairs that exhibit brittleness fall within the definition of adversarial examples ($\epsilon=16$ ball in $L_\infty$ space). \subsection{No single training technique systematically improves robustness} \label{sec:enhancement} \begin{figure}[h] \begin{center} \includegraphics[width=\columnwidth]{figures/adversarial_rvr5.png} \end{center} \caption{ {\bf No single adversarial training or regularization technique systematically improves robustness across model architectures}. For each regularization technique, we plot the robustness after regularizing against robustness of the baseline model. We plot the line of equality to show whether regularizing improves robustness. See Figure \ref{fig:natural_robustness} for common legend. } \label{fig:rvr} \end{figure} Finally, we explore regularization and adversarial training techniques to improve the natural robustness of image classifiers. We explored adversarial training through adversarial logit pairing (\cite{kannan2018adversarial}); regularization techniques like weight decay (\cite{wd-hanson1989comparing}), label smoothing (\cite{inception4-szegedy2017inception}), clean logit squeezing, clean logit pairing (\cite{kannan2018adversarial}); and multi-class prediction with the sigmoid activation function on the logits (\cite{goodfellow2016deep}). We explore 25 hyperparameter settings for each training technique. All models trained are within 1.2\% of their original accuracy. We find that no single technique we explored improves natural robustness for all model architectures (Figure \ref{fig:rvr}). However, certain model architectures become more robust with specific training techniques. Figure \ref{fig:rvr} shows that adversarial logit pairing improves MobileNet-V1 robustness by 0.8\%, weight decay improves Resnet-V1-152 robustness by 1.2\%, and clean logit pairing and clean logit squeezing improves VGG19 robustness by 1\% and 1.3\% respectively. \section{Conclusion} In this work, we present the first study on natural robustness in CNNs by leveraging the large YT-BB video dataset (\cite{real2017youtube}). Our results show that more accurate models are also more robust to natural transformations. This implies that researchers should continue designing new architectures and training techniques that improve model accuracy. Our analysis also highlights that the correlation between accuracy and robustness depends highly on the type of distortions applied. This refines conclusions from prior works that show accuracy is uncorrelated with robustness on average (\cite{hendrycks2018benchmarking}). When video frames are not available to evaluate natural robustness directly, we identify synthetic color distortions as good proxies for natural transformations. This result also helps explain and support prior findings that color-based transformations are good data augmentation policies for natural images (\cite{cubuk2018autoaugment}). In exploring the relationship between brittleness found in videos and adversarial examples, we find that brittle examples in videos rarely fall within the typical definition of adversarial examples. This suggests that adversarial robustness does not directly measure robustness to natural transformations. Despite the misalignment in evaluation, we do find early signs that training techniques to improve adversarial robustness can improve robustness for some model architectures. However, no single training technique systematically improves natural robustness across model architectures, providing an interesting direction for future work.
{'timestamp': '2019-09-02T02:04:02', 'yymm': '1904', 'arxiv_id': '1904.10076', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.10076'}
arxiv
\section{Introduction} The use of deep neural networks (DNNs)~\cite{Bengio2009,Lecun2015} has become ubiquitous over the last few years due to their demonstrated efficacy in many challenging application areas, including image classification~\cite{Krizhevsky2012,Simonyan2014}, pose estimation~\cite{Tompson2014,Newell2016}, and speech recognition~\cite{Graves2013,Xiong2018}. However, the modelling accuracy of high-performance DNNs is a result of increased model size and complexity, rendering them impractical for real-world scenarios with limited computational and memory resources. As a result, methods for reducing the computational requirements of DNNs while maintaining performance accuracy are highly desirable. One such method is \textit{evolutionary deep intelligence}~\cite{Shafiee2018}. Inspired by nature, Shafiee \etal proposed a biologically-motivated method for synthesizing increasingly efficient and compact network architectures over successive generations from existing high-performance DNNs. While the seminal papers in evolutionary deep intelligence~\cite{Shafiee2018,Shafiee2016} formulated the synthesis process as asexual evolutionary synthesis, recent work~\cite{Chung2017_Mating,Chung2017_Poly} has investigated the use of sexual evolutionary synthesis to produce populations of increasingly compact DNNs at each generations. Most recently, Chung \etal~\cite{Chung2018} conducted an initial study into mitigating architectural mismatch during sexual evolutionary synthesis via a gene tagging system. While results showed no notable difference in performance accuracy, it raises an interesting question: how can we assess the architectural similarity of DNNs in a meaningful and useful way? In this work, we present a preliminary study exploring the quantification of network architectural similarity in populations of evolutionary synthesized neural networks via percentage overlap of architectural clusters. Architectural similarity is explored within the context of multi-parent sexual evolutionary synthesis, and will allow for the development of improved similarity-based mating policies during the evolutionary synthesis of highly efficient networks. \section{Methods} In this paper, we investigate the quantification of architectural similarity using generations of networks synthesized via multi-parent evolutionary synthesis with and without gene tagging~\cite{Chung2018}. \subsection{$m$-Parent Evolutionary Synthesis} Let the network architecture be formulated as $\mathcal{H}(N,S)$, where $N$ is the set of possible neurons and $S$ denotes the set of possible synapses in the network. Each neuron $n_j \in N$ is connected to neuron $n_k \in N$ via a set of synapses $\bar{s} \subset S$, such that the synaptic connectivity $s_j \in S$ has an associated $w_j \in W$ to denote the connection's strength. In the seminal evolutionary deep intelligence paper~\cite{Shafiee2016}, the synthesis probability $P(\mathcal{H}_{g}|\mathcal{H}_{g-1}, \mathcal{R}_{g})$ of a new network at generation $g$ is approximated by the synaptic probability $P(S_g|W_{g-1}, R_{g})$ to emulate heredity through the generations of networks. $P(\mathcal{H}_{g}|\mathcal{H}_{g-1}, \mathcal{R}_{g})$ is also conditional on an environmental factor model $\mathcal{R}_g$ to imitate natural selection via simulated environmental resources. Extending on~\cite{Shafiee2018,Shafiee2016}, Chung~\etal~\cite{Chung2017_Mating} generalized the synthesis process multi-parent ($m$-parent) evolutionary synthesis where a newly synthesized network $\mathcal{H}_{g(i)}$ can be dependent on a subset of all previously synthesized networks $\mathcal{H}_{G_i}$, with $G_i$ corresponding to the set of previous networks on which $\mathcal{H}_{g(i)}$ is dependent and $g(i)$ representing the generation number corresponding to the $i^{\text{th}}$ network. The synthesis probability combining the probabilities of $m$ parent networks $\mathcal{H}_{G_i}$ is represented by some cluster-level mating function $\mathcal{M}_c(\cdot)$ and some synapse-level mating function $\mathcal{M}_s(\cdot)$: \begin{align} P(\mathcal{H}_{g(i)}|\mathcal{H}_{G_i}, \mathcal{R}_{g(i)}) =& \prod_{C \in \mathcal{C}} \Big[ P(s_{g(i),C}|\mathcal{M}_c(W_{\mathcal{H}_{G_i}}), \mathcal{R}_{g(i)}^c) \cdot \nonumber \\ &\prod_{j \in C} P(s_{g(i),j}|\mathcal{M}_s(w_{\mathcal{H}_{G_i},j}), \mathcal{R}_{g(i)}^s) \Big]. \end{align} \subsection{Architecture Alignment via Gene Tagging} To encourage like-with-like mating during evolutionary synthesis, Chung \etal~\cite{Chung2018} recently introduced a gene tagging system to enforce structural alignment, \textit{i.e.}, only mating architectural clusters originating from the same location in the ancestor network. As such, the cluster-level and synapse-level mating functions are formulated as follows: \begin{align} \mathcal{M}_c(\overline{W}_{\mathcal{H}_{G_i}}) = \prod_{k \in \mathcal{K}_c} \alpha_{c,k} \overline{W}_{\mathcal{H}_k} \\ \mathcal{M}_s(\overline{w}_{\mathcal{H}_{G_i},j}) = \prod_{k \in \mathcal{K}_c}\alpha_{s,k} \overline{w}_{\mathcal{H}_k,j} \end{align} where $\mathcal{K}_c$ is the subset of parent networks with existing architectural clusters corresponding to a single gene tagged cluster $c \in C$, $C$ is the set of clusters that exists in $\mathcal{H}_{g(i)}$, and $\overline{W}$ and $\overline{w}$ are the gene tagged synaptic strengths. \subsection{Architectural Cluster Overlap} To investigate the quantification of architectural similarity in the context of multi-parent sexual evolutionary synthesis, the percentage overlap of architectural clusters between two networks is formulated as the proportion of intersecting clusters: \begin{align} \% overlap_{AB} = \frac{C_A \cap C_B}{C_A}, \end{align} where $C_A$ and $C_B$ represent the sets of architectural clusters that exist in the two networks being compared. Percentage overlap of architectural clusters is an intuitive representation of network architecture similarity made viable in the context of multi-parent evolutionary synthesis by leveraging the gene tagging system~\cite{Chung2018}. As such, gene tagging (which allows for architectural alignment during evolutionary synthesis) can similarly be used to calculate percentage overlap of existing architectural clusters originating from the same location in the ancestor network. Percentage overlap is indicative of network population diversity within a generation, \eg, relatively low average percentage overlap would indicate a generation of synthesized networks with comparatively higher architectural variability. \section{Results} \subsection{Experimental Setup} In this study, we used the network architectures synthesized in~\cite{Chung2018} with the least aggressive environmental factor model (${R}_{g(i)}^c,{R}_{g(i)}^s= 50$) and trained on the MNIST dataset~\cite{Lecun1998_MNIST}. Architectural similarity was assessed on the first seven generations of networks (after which the performance accuracy degraded to random guessing) synthesized with and without gene tagging. \subsection{Experimental Results} Figure~\ref{fig_scatter5} shows the performance accuracy as a function of storage size for the populations of synthesized networks in the first seven generations, where the best synthesized networks are closest to the top left, \textit{i.e.}, high performance accuracy and low storage size. Networks synthesized using gene tagging show a slightly slower progression in maintaining performance accuracy while decreasing storage size relative to networks synthesized without gene tagging. Synthesizing networks with gene tagging and without gene tagging both produced architectures that increase in variability over successive generations; however, networks synthesized with gene tagging diversify more slowly than those without gene tagging (as shown in Table~\ref{tab_avgOverlap}). Figure~\ref{fig_scatter5} and Table~\ref{tab_avgOverlap} also suggest that generations of networks approaching an optimal tradeoff between performance accuracy and storage size tend to also have the highest architectural variability, \eg, in generations 3 and 4. Lastly, it is worth noting that the increasing percentage overlap in generations 6 and 7 of networks synthesized without gene tagging is a result of sparse, low-variability architectures that can no longer represent the problem space (\textit{i.e.}, performance accuracy of $10\%$ on the 10-class MNIST dataset, equivalent to random guessing). Similarly, the percentage overlap in generations 6 and 7 of networks synthesized with gene tagging increases as the performance accuracy begins to rapidly decrease. \section{Discussion} We presented a preliminary study in assessing architectural similarity between deep neural networks to improve the sexual evolutionary synthesis process. Results show that networks synthesized using gene tagging have less architectural variability than networks synthesized without gene tagging, as quantified by relatively higher overlap percentages of architectural clusters. This indicates that the use of gene tagging is potentially restricting the exploration of highly efficient network architectures in the search space. Future work includes further investigation into quantities of information, \eg, mutual information, as well as the development of a custom similarity metric for optimal architectural similarity during sexual evolutionary synthesis. \begin{table}[t] \centering \caption{Average percentage overlap of architectural clusters in network models for the first seven generations of 5-parent sexual evolutionary synthesis. Note that the increasing percentage overlap in generations 6 and 7 of networks synthesized without gene tagging is a result of sparse, low-variability architectures that can no longer represent the problem space, while the unpredictability of percentage overlap in generations 6 and 7 of networks synthesized with gene tagging may be a result of some (but not all) networks having sparse, low-variability architectures.} \vspace{10pt} \begin{tabular}{|c|c|c|} \hline \textbf{Gen No.} & \textbf{Gene Tagging} & \textbf{No Gene Tagging} \\ \hline \hline 1 & $93.75\%$ & $93.71\%$ \\ \hline 2 & $87.59\%$ & $78.11\%$ \\ \hline 3 & $83.49\%$ & $68.84\%$ \\ \hline 4 & $71.81\%$ & $66.64\%$ \\ \hline 5 & $73.17\%$ & $68.44\%$ \\ \hline 6 & $69.09\%$ & $82.74\%$ \\ \hline 7 & $73.48\%$ & $91.05\%$ \\ \hline \end{tabular} \label{tab_avgOverlap} \end{table} \begin{figure}[t] \begin{center} \includegraphics[width=\linewidth]{5Parent_Scatter_7Generations.png} \end{center} \caption{Performance accuracy as a function of storage size for the first seven generations of 5-parent sexual evolutionary synthesis for networks synthesized with gene tagging (diamond) and without gene tagging (round). Plots best viewed in colour.} \label{fig_scatter5} \end{figure} {\small \bibliographystyle{ieee}
{'timestamp': '2019-04-23T02:26:19', 'yymm': '1904', 'arxiv_id': '1904.09879', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.09879'}
arxiv
\section{Introduction} \label{sec:intro} One of the hot topics of modern Artificial Intelligence (AI) is the ability for an agent to adapt its behavior to changing tasks. In the literature, this problem is often linked to the setting of Lifelong Reinforcement Learning (LRL) \citep{silver2013lifelong,abel2018state,abel2018policy} and learning in non-stationary environments \citep{choi1999hidden,jaulmes2005learning,hadoux2015markovian}. In LRL, the tasks presented to the agent change sequentially at discrete transition epochs \citep{silver2013lifelong}. Similarly, the non-stationary environments considered in the literature often evolve abruptly \citep{hadoux2015markovian,hadoux2014sequential,doya2002multiple,da2006dealing,choi1999hidden,choi2000hidden,choi2001solving,campo1991state,wiering2001reinforcement}. In this paper, we investigate environments continuously changing over time that we call \NSMDPmeaning{}es (\NSMDP{}s). In this setting, it is realistic to bound the evolution rate of the environment using a Lipschitz Continuity (LC) assumption. Model-based Reinforcement Learning approaches~\citep{sutton1998reinforcement} benefit from the knowledge of a model allowing them to reach impressive performances, as demonstrated by the Monte Carlo Tree Search (MCTS) algorithm~\citep{silver2016mastering}. In this matter, the necessity to have access to a model is a great concern of AI~\citep{asadi2018lipschitz,jaulmes2005learning,doya2002multiple,da2006dealing}. In the context of \NSMDP{}s, we assume that an agent is provided with a \emph{snapshot} model when its action is computed. By this, we mean that it only has access to the current model of the environment but not its future evolution, as if it took a photograph but would be unable to predict how it is going to evolve. This hypothesis is realistic, because many environments have a tractable state while their future evolution is hard to predict~\citep{da2006dealing,wiering2001reinforcement}. In order to solve LC-\NSMDP{}s, we propose a method that considers the worst-case possible evolution of the model and performs planning \wrt{} this model. This is equivalent to considering Nature as an adversarial agent. The paper is organized as follows: first we describe the \NSMDP{} setting and the regularity assumption (Section~\ref{sec:nsmdp}); then we outline related works (Section~\ref{sec:related}); follows the explanation of the worst-case approach proposed in this paper (Section~\ref{sec:worst}); then we describe an algorithm reflecting this approach (Section~\ref{sec:rats}); finally we illustrate its behavior empirically (Section~\ref{sec:expe}). \section{\NSMDPmeaning{}es} \label{sec:nsmdp} To define a \NSMDPmeaning{} (\NSMDP{}), we revert to the initial MDP model introduced by \citet{puterman2014markov , where the transition and reward functions depend on time. \begin{definition} \label{def:nsmdp} \textbf{\NSMDP{}.} An \NSMDP{} is an MDP whose transition and reward functions depend on the decision epoch. It is defined by a 5-tuple $\{ \S, \T, \A, \left(p_t\right)_{t\in \T}, \left(r_t\right)_{t\in \T} \}$ where $\S$ is a state space; $\T \equiv \{ 1, 2, \ldots, N \}$ is the set of decision epochs with $N \leq +\infty$; $\A$ is an action space; $p_t(s' \mid s, a)$ is the probability of reaching state $s'$ while performing action $a$ at decision epoch $t$ in state $s$; $r_t(s, a, s')$ is the scalar reward associated to the transition from $s$ to $s'$ with action $a$ at decision epoch $t$. \end{definition} This definition can be viewed as that of a stationary MDP whose state space has been enhanced with time. While this addition is trivial in episodic tasks where an agent is given the opportunity to interact several times with the same MDP, it is different when the experience is unique. Indeed, no exploration is allowed along the temporal axis. Within a stationary, infinite-horizon MDP with a discounted criterion, it is proven that there exists a Markovian deterministic stationary policy~\citep{puterman2014markov}. It is not the case within \NSMDP{}s where the optimal policy is non-stationary in the most general case. Additionally, we define the expected reward received when taking action $a$ at state $s$ and decision epoch $t$ as $R_t(s, a) = \E_{s' \sim p_t(\cdot \mid s, a)} \left[r_t(s, a, s') \right]$. Without loss of generality, we assume the reward function to be bounded between $-1$ and $1$. In this paper, we consider discrete time decision processes with constant transition durations, which imply deterministic decision times in Definition~\ref{def:nsmdp}. This assumption is mild since many discrete time sequential decision problems follow that assumption. A non-stationary policy $\pi$ is a sequence of \emph{decision rules} $\pi_t$ which map states to actions (or distributions over actions). For a stochastic non-stationary policy $\pi_t(a \mid s)$, the value of a state $s$ at decision epoch $t$ within an infinite horizon \NSMDP{} is defined, with $\gamma \in [0, 1)$ a discount factor, by: \begin{equation*} V^\pi_t(s) = \E \left[ \sum_{i = t}^{\infty} \gamma^{i - t} R_i(s_i, a_i) \Big| \begin{aligned} &s_t = s, \ a_i \sim \pi_i(\cdot \mid s_i), \ s_{i+1} \sim p_i(\cdot \mid s_i, a_i) \end{aligned} \right], \end{equation*} The definition of the state-action value function $Q^\pi_t$ for $\pi$ at decision epoch $t$ is straightforward: \begin{equation*} \label{eq:bellman} Q^\pi_t(s, a) = R_t(s, a) + \gamma \E_{s' \sim p_t(\cdot \mid s, a)} \left[ V^\pi_{t + 1}(s') \right]. \end{equation*} Overall, we defined an \NSMDP{} as an MDP where we stress out the distinction between state, time, and decision epoch due to the inability for an agent to explore the temporal axis at will. This distinction is particularly relevant for non-episodic tasks, \ie{} when there is no possibility to re-experience the same MDP starting from a prior date. \textbf{The regularity hypothesis.} Many real-world problems can be modeled as an \NSMDP{}. For instance, the problem of path planning for a glider immersed in a non-stationary atmosphere~\citep{chung2015learning,lecarpentier2017empirical}, or that of vehicle routing in dynamic traffic congestion. Realistically, we consider that the expected reward and transition functions do not evolve arbitrarily fast over time. Conversely, if such an assumption was not made, a chaotic evolution of the \NSMDP{} would be allowed which is both unrealistic and hard to solve. Hence, we assume that changes occur slowly over time. Mathematically, we formalize this hypothesis by bounding the evolution rate of the transition and expected reward functions, using the notion of Lipschitz Continuity (LC). \begin{definition} \textbf{Lipschitz Continuity.} Let $(X,d_X)$ and $(Y,d_Y)$ be two metric spaces and $f: X \rightarrow Y$, $f$ is $L$-Lipschitz Continuous ($L$-LC) with $L \in \R^+$ iff $d_Y(f(x), f(\hat{x})) \leq L \, d_X(x, \hat{x}) , \forall (x,\hat{x}) \in X^2$. $L$ is called a Lipschitz constant of the function $f$. \label{def:lc} \end{definition} We apply this hypothesis to the transition and reward functions of an \NSMDP{} so that those functions are LC \wrt{} time. For the transition function, this leads to the consideration of a metric between probability density functions. For that purpose, we use the 1-Wasserstein distance~\citep{villani2008optimal}. \begin{definition} \label{def:wasserstein-distance} \textbf{1-Wasserstein distance.} Let $(X, d_X)$ be a Polish metric space, $\mu, \nu$ any probability measures on $X$, $\Pi(\mu, \nu)$ the set of joint distributions on $X \times X$ with marginals $\mu$ and $\nu$. The 1-Wasserstein distance between $\mu$ and $\nu$ is $W_1 (\mu, \nu) = \inf_{\pi \in \Pi(\mu, \nu)} \int_{X \times X} d_X(x,y) d\pi(x,y)$. \end{definition} The choice of the Wasserstein distance is motivated by the fact that it quantifies the distance between two distributions in a physical manner, respectful of the topology of the measured space \citep{dabney2018distributional,asadi2018lipschitz}. First, it is sensitive to the difference between the supports of the distributions. Comparatively, the Kullback-Leibler divergence between distributions with disjoint supports is infinite. Secondly, if one consider two regions of the support where two distributions differ, the Wasserstein distance is sensitive to the distance between the elements of those regions. Comparatively, the total-variation metric is the same regardless of this distance. \begin{definition} \label{def:lc-nsmdp} \textbf{$(L_p, L_r)$-LC-\NSMDP{}.} An $(L_p, L_r)$-LC-\NSMDP{} is an \NSMDP{} whose transition and reward functions are respectively $L_p$-LC and $L_r$-LC \wrt{} time, \ie{}, $\forall (t, \hat{t}, s, s', a) \in \T^2 \times \S^2 \times \A$, \begin{equation*} W_1(p_t(\cdot \mid s, a), p_{\hat{t}}(\cdot \mid s, a)) \leq L_p |t - \hat{t}| \quad \textrm{and} \quad |r_t(s, a, s') - r_{\hat{t}}(s, a, s')| \leq L_r |t - \hat{t}|. \end{equation*} \end{definition} One should remark that the LC property should be defined with respect to actual decision times and not decision epoch indexes for the sake of realism. In the present case, both have the same value, and we choose to keep this convention for clarity. Our results however extend easily to the case where indexes and times do not coincide. From now on, we consider $(L_p, L_r)$-LC-\NSMDP{}s, making Lipschitz Continuity our regularity property. Notice that $R$ is defined as a convex combination of $r$ by the probability measure $p$. As a result, the notion of Lipschitz Continuity of $R$ is strongly related to that of $r$ and $p$ as showed by Property~\ref{prop:link-LR-LrLp}. All the proofs of the paper can be found in the Appendix. \begin{property} \label{prop:link-LR-LrLp} Given an $(L_p, L_r)$-LC-\NSMDP{}, the expected reward function $R_t: s, a \mapsto \E_{s' \sim p_t(\cdot \mid s, a)} \left\{ r_t(s, a, s') \right\}$ is $L_R$-LC with $L_R = L_r + L_p$. \end{property} This result shows $R$'s evolution rate is conditioned by the evolution rates of $r$ and $p$. It allows to work either with the reward function $r$ or its expectation $R$, benefiting from the same LC property. \section{Related work} \label{sec:related} \citet{iyengar2005robust} introduced the framework of robust MDPs, where the transition function is allowed to evolve within a set of functions due to uncertainty. This differs from our work in two fundamental aspects: 1) we consider uncertainty in the reward model as well; 2) we use a stronger Lipschitz formulation on the set of possible transition and reward functions, this last point being motivated by its relevance to the non-stationary setting. \citet{szita2002varepsilon} also consider the robust MDP setting and adopt a different constraint hypothesis on the set of possible functions than our LC assumption. They control the total variation distance of transition functions from subsequent decision epochs by a scalar value. Those slowly changing environments allow model-free RL algorithms such as Q-Learning to find near optimal policies. \citet{lim2013reinforcement} consider learning in robust MDPs where the model evolves in an adversarial manner for a subset of $\S \times \A$. In that setting, they propose to learn to what extent the adversary can modify the model and to deduce a behavior close to the minimax policy. \citet{even2009online} studied the case of non-stationary reward functions with fixed transition models. No assumption is made on the set of possible functions and they propose an algorithm achieving sub-linear regret w.r.t. the best stationary policy. \citet{dick2014online} viewed a similar setting from the perspective of online linear optimization. \citet{csaji2008value} studied the \NSMDP{} setting with an assumption of reward and transition functions varying in a neighborhood of a reference reward-transition function pair. Finally, \citet{abbasi2013online} address the adversarial \NSMDP{} setting with a mixing assumption constraint instead of the LC assumption we make. Non-stationary environments also have been studied through the framework of Hidden Mode MDPs (\HMMDP{}) introduced by \citet{choi1999hidden}. This is a special class of Partially Observable MDPs (POMDPs) \citep{kaelbling1998planning} where a hidden mode indexes a latent stationary MDP within which the agent evolves. Similarly to the context of LRL, the agent experiences a series of different MDPs over time. In this setting, \citet{choi1999hidden,choi2000hidden} proposed methods to learn the different models of the latent stationary MDPs. \citet{doya2002multiple} built a modular architecture switching between models and policies when a change is detected. Similarly, \citet{wiering2001reinforcement,da2006dealing,hadoux2014sequential} proposed a method tracking the switching occurrence and re-planning if needed. Overall, as in LRL, the \HMMDP{} setting considers abrupt evolution of the transition and reward functions whereas we consider a continuous one. Other settings have been considered, as by \citet{jaulmes2005learning}, who do not make particular hypothesis on the evolution of the \NSMDP{}. They build a learning algorithm for POMDPs solving, weighting recently experienced transitions more than older ones to account for the time dependency. To plan robustly within an \NSMDP{}, our approach consists in exploiting the \emph{slow} LC evolution of the environment. Utilizing Lipschitz continuity to infer bounds on a function is common in the RL, bandit and optimization communities \citep{kleinberg2008multi,rachelson2010locality,pirotta2015policy,pazis2013pac,munos2014bandits}. We implement this approach with a minimax-like algorithm~\citep{fudenberg1991game}, where the environment is seen as an adversarial agent. \section{Worst-case approach} \label{sec:worst} We consider finding an optimal policy within an LC-\NSMDP{} under the non-episodic task hypothesis. The latter prevents us from learning from previous experience data since they become outdated with time and no information samples have been collected yet for future time steps. An alternative is to use model-based RL algorithms such as MCTS. For a current state $s_0$, such algorithms focus on finding the optimal action $a_0^*$ by using a generative model. This action is then undertaken and the operation repeated at the next state. However, using the true \NSMDP{} model for this purpose is an unrealistic hypothesis, since this model is generally unknown. We assume the agent does not have access to the true \NSMDP{} model; instead, we introduce the notion of \emph{snapshot model} Intuitively, the snapshot associated to time $t_0$ is a temporal slice of the \NSMDP{} at $t_0$. \begin{definition} \textbf{Snapshot of an \NSMDP{}.} The snapshot of an \NSMDP{} $\{ \S, \T, \A, \left(p_t\right)_{t\in \T}, \left(r_t\right)_{t\in \T} \}$ at decision epoch $t_0$, denoted by MDP$_{t_0}$, is the stationary MDP defined by the 4-tuple $\{\S, \A, p_{t_0}, r_{t_0}\}$ where $p_{t_0}(s' \mid s, a)$ and $r_{t_0}(s, a, s')$ are the transition and reward functions of the \NSMDP{} at $t_0$. \end{definition} Similarly to the \NSMDP{}, this definition induces the existence of the snapshot expected reward $R_{t_0}$ defined by $R_{t_0} : s, a \mapsto \E_{s'\sim p_{t_0}(\cdot \mid s, a)} \left\{ r_{t_0}(s, a, s') \right\}$. Notice that the snapshot MDP$_{t_0}$ is stationary and coincides with the \NSMDP{} \emph{only} at $t_0$. Particularly, one can generate a trajectory $\{s_0, r_0, \cdots, s_k\}$ within an \NSMDP{} using the sequence of snapshots $\{\text{MDP}_{t_0}, \cdots, \text{MDP}_{t_0 + k - 1}\}$ as a model. Overall, the hypothesis of using snapshot models amounts to considering a planning agent only able to get the current stationary model of the environment. In real-world problems, predictions often are uncertain or hard to perform \eg{} in the thermal soaring problem of a glider. We consider a generic \emph{planning} agent at $s_0, t_0$, using MDP$_{t_0}$ as a model of the \NSMDP{}. By planning, we mean conducting a look-ahead search within the possible trajectories starting from $s_0, t_0$ given a model of the environment. The search allows in turn to identify an optimal action \wrt{} the model. This action is then undertaken and the agent jumps to the next state where the operation is repeated. The consequence of planning with MDP$_{t_0}$ is that the estimated value of an $s, t$ pair is the value of the optimal policy of $\text{MDP}_{t_0}$, written $V^*_{\text{MDP}_{t_0}}(s)$. The true optimal value of $s$ at $t$ within the \NSMDP{} does not match this estimate because of the non-stationarity. The intuition we develop is that, given the \emph{slow} evolution rate of the environment, for a state $s$ seen at a future decision epoch during the search, we can predict a scope into which the transition and reward functions at $s$ lie. \begin{property} \textbf{Set of admissible snapshot models.} \label{prop:set-admissible-future-snapshot} Consider an $(L_p, L_r)$-LC-\NSMDP{}, $s, t, a \in \STA{}$. The transition and expected reward functions $(p_t, R_t)$ of the snapshot $\text{MDP}_t$ respect \begin{equation*} (p_t, R_t) \in \Delta_{t} \eqdef \B_{W_1} \left( p_{t - 1}(\cdot \mid s, a), L_p \right) \times \B_{| \cdot |} \left( R_{t - 1}(s, a), L_R \right) \end{equation*} where $L_R = L_p + L_r$ and $\mathcal{B}_d \left( c, r \right)$ denotes the ball of centre $c$, defined with metric $d$ and radius $r$. \end{property} For a future prediction at $s, t$, we consider the question of using a better model than $p_{t_0}, R_{t_0}$. The underlying evolution of the \NSMDP{} being unknown, a desirable feature would be to use a model leading to a policy that is \emph{robust} to every possible evolution. To that end, we propose to use the snapshots corresponding to the worst possible evolution scenario under the constraints of Property~\ref{prop:set-admissible-future-snapshot}. We claim that such a practice is an efficient way to 1) ensure robust performance to all possible evolutions of the \NSMDP{} and 2) avoid catastrophic terminal states. Practically, this boils down to using a different value estimate for $s$ at $t$ than $V^*_{\text{MDP}_{t_0}}(s)$ which provided no robustness guarantees. Given a policy $\pi = \left(\pi_t\right)_{t\in \T}$ and a decision epoch $t$, a worst-case \NSMDP{} corresponds to a sequence of transition and reward models minimizing the expected value of applying $\pi$ in any pair $(s,t)$, while remaining within the bounds of Property~\ref{prop:set-admissible-future-snapshot}. We write $\overline{V}^{\pi}_t(s)$ this value for $s$ at decision epoch $t$. \begin{equation} \label{eq:worst-case-v} \overline{V}^{\pi}_{t}(s) \eqdef \min_{ \substack{\left( p_i, R_i \right) \in \Delta_i, \forall i \in \T} } \E \left[ \sum_{i = t}^{\infty} \gamma^{i-t} R_{i}(s_i, a_i) \Big| \begin{aligned} & s_t = s\\ & a_i \sim \pi_i(\cdot \mid s_i), s_{i+1} \sim p_{i}(\cdot \mid s_i, a_i) \end{aligned} \right] \end{equation} Intuitively, the worst-case \NSMDP{} is a model of a non-stationary environment leading to the poorest possible performance for $\pi$, while being an admissible evolution of MDP$_t$. Let us define $\overline{Q}^\pi_t(s,a)$ as the worst-case $Q$-value for the pair $(s,a)$ at decision epoch $t$: \begin{equation} \label{eq:worst-case-q} \overline{Q}^\pi_t(s,a) \eqdef \min_{\substack{\left({p},R\right) \in \Delta_t}} \E_{s'\sim p}\left[R(s,a) + \gamma \overline{V}^{\pi}_{t+1}(s')\right]. \end{equation} \section{Risk-Averse Tree-Search{} algorithm} \label{sec:rats} \textbf{The algorithm.} Tree search algorithms within MDPs have been well studied and cover two classes of search trees, namely closed loop~\citep{keller2013trial,kocsis2006bandit,browne2012survey} and open loop~\citep{bubeck2010open,lecarpentier2018open}. Following \citep{keller2013trial}, we consider closed loop search trees, composed of \emph{decision nodes} alternating with \emph{chance nodes}. We adapt their formulation to take time into account, resulting in the following definitions. A decision node at depth $t$, denoted by $\nu^{s, t}$, is labeled by a unique state / decision epoch pair $(s, t)$. The edges leading to its children chance nodes correspond to the available actions at $(s, t)$. A chance node, denoted by $\nu^{s, t, a}$, is labeled by a state / decision epoch / action triplet $(s, t, a)$. The edges leading to its children decision nodes correspond to the reachable state / decision epoch pairs $(s', t')$ after performing $a$ in $(s, t)$ as illustrated by Figure~\ref{fig:tree}. \begin{figure}[] \begin{subfigure}{.4\textwidth} \centering \includegraphics[trim={2.2cm 0cm 1.9cm 0cm}, clip, width=\textwidth]{img/tree/tree} \captionsetup{width=\textwidth} \captionof{figure}{ Tree structure, $d_{\max} = 2$, $\A = \{ a_1, a_2\}$. } \label{fig:tree} \end{subfigure}% \begin{subfigure}{.6\textwidth} \begin{tabular}{llccc} \toprule $\epsilon$ & & RATS{} & DP-snapshot& DP-NSMDP\\ \midrule \multirow{2}{4mm}{0} & $\E\left[\sum r\right]$ & -0.026 & \textbf{0.48} & \textbf{0.47}\\ \cmidrule(r){2-5} & CVaR & \textbf{-0.81} & -0.90 & -0.9 \\ \midrule \multirow{3}{4mm}{0.5} & $\E\left[\sum r\right]$ & \textbf{-0.032} & -0.46 & \textbf{-0.077} \\ \cmidrule(r){2-5} & CVaR & \textbf{-0.81} & -0.90 & \textbf{-0.81} \\ \midrule \multirow{3}{4mm}{1} & $\E\left[\sum r\right]$ & \textbf{0.67} & -0.78 & \textbf{0.66} \\ \cmidrule(r){2-5} & CVaR & \textbf{0.095} & -0.90 & \textbf{-0.033}\\ \bottomrule \end{tabular} \captionof{figure}{Expected return $\E\left[\sum r\right]$ and CVaR at 5\%. \label{table:result} \end{subfigure}% \caption{Tree structure and results from the Non-Stationary bridge experiment.} \end{figure} We consider the problem of estimating the optimal action $a_0^*$ at $s_0, t_0$ within a worst-case \NSMDP{}, knowing MDP$_{t_0}$. This problem is twofold. It requires 1) to estimate the worst-case \NSMDP{} given MDP$_{t_0}$ and 2) to explore the latter in order to identify $a_0^*$. We propose to tackle both problems with an algorithm inspired by the minimax algorithm~\citep{fudenberg1991game} where the \emph{max} operator corresponds to the agent's policy, seeking to maximize the return; and the \emph{min} operator corresponds to the worst-case model, seeking to minimize the return. Estimating the worst-case \NSMDP{} requires to estimate the sequence of subsequent snapshots minimizing Equation~\ref{eq:worst-case-q}. The inter-dependence of those snapshots (Equation~\ref{eq:worst-case-v}) makes the problem hard to solve \citep{iyengar2005robust}, particularly because of the combinatorial nature of the opponent's action space. Instead, we propose to solve a relaxation of this problem, by considering snapshots only constrained by MDP$_{t_0}$. Making this approximation leaves a possibility to violate property \ref{prop:set-admissible-future-snapshot} but allows for an efficient search within the developed tree and (as will be shown experimentally) leads to robust policies. For that purpose, we define the set of admissible snapshot models \wrt{} MDP$_{t_0}$ by $\Delta_{t_0}^t \eqdef \B_{W_1} \left( p_{t_0}(\cdot \mid s, a), L_p |t - t_0| \right) \times \B_{| \cdot |} \left( R_{t_0}(s, a), L_R |t - t_0| \right)$. The relaxed analogues of Equations~\ref{eq:worst-case-v} and~\ref{eq:worst-case-q} for $s, t, a \in \S \times \T \times \A$ are defined as follows: \begin{gather*} \hat{V}^{\pi}_{t_0,t}(s) \eqdef \min_{\left( p_i, R_i \right) \in \Delta_{t_0}^i, \forall i \in \T} \E \left[ \sum_{i = t}^{\infty} \gamma^{i-t} R_{i}(s_i, a_i) \Big| \begin{aligned} & s_t = s\\ & a_i \sim \pi_i(\cdot \mid s_i), s_{i+1} \sim p_{i}(\cdot \mid s_i, a_i) \end{aligned} \right],\\ \hat{Q}^\pi_{t_0,t}(s,a) \eqdef \min_{\left({p},R\right) \in \Delta_{t_0}^t} \E_{s'\sim p}\left[R(s,a) + \gamma \hat{V}^{\pi}_{t_0, t + 1}(s') \right]. \end{gather*} Their optimal counterparts, while seeking to find the optimal policy, verify the following equations: \begin{align} \hat{V}^*_{t_0,t}(s) & = \max \limits_{a\in \A} \hat{Q}^*_{t_0,t}(s,a), \label{eq:relaxed-optimal-worst-case-v}\\ \hat{Q}^*_{t_0,t}(s,a) & = \min \limits_{\substack{(p, R) \in \Delta_{t_0}^t}} \E\limits_{\substack{s' \sim p}} \left[ R(s, a) + \gamma \hat{V}^*_{t_0,t+1}(s') \right]. \label{eq:relaxed-optimal-worst-case-q} \end{align} We now provide a method to calculate those quantities within the nodes of the tree search algorithm.\\ \textbf{Max nodes.} A decision node $\nu^{s, t}$ corresponds to a max node due to the greediness of the agent \wrt{} the subsequent values of the children. We aim at maximizing the return while retaining a risk-averse behavior. As a result, the value of $\nu^{s, t}$ follows Equation~\ref{eq:relaxed-optimal-worst-case-v} and is defined as: \begin{equation} \label{eq:decision-node-value} V(\nu^{s, t}) = \max_{a \in \A} V(\nu^{s, t, a}). \end{equation} \textbf{Min nodes.} A chance node $\nu^{s, t, a}$ corresponds to a min node due to the use of a worst-case \NSMDP{} as a model which minimizes the value of $\nu^{s, t, a}$ \wrt{} the reward and the subsequent values of its children. Writing the value of $\nu^{s, t, a}$ as the value of $s, t, a$, within the worst-case snapshot minimizing Equation~\ref{eq:relaxed-optimal-worst-case-q}, and using the children's values as values for the next reachable states, leads to Equation~\ref{eq:chance-node-value}. \begin{equation} \label{eq:chance-node-value} V (\nu^{s, t, a}) = \min_{(p, R) \in \Delta_{t_0}^t} R(s, a) + \gamma \E_{s' \sim p} V (\nu^{s', t + 1}) \end{equation} Our approach considers the environment as an adversarial agent, as in an \emph{asymmetric} two-player game, in order to search for a robust plan. The resulting algorithm, RATS{} for Risk-Averse Tree-Search{}, is described in Algorithm~\ref{alg:rats}. Given an initial state / decision epoch pair, a minimax tree is built using the snapshot MDP$_{t_0}$ and the operators corresponding to Equations~\ref{eq:decision-node-value} and~\ref{eq:chance-node-value} in order to estimate the worst-case snapshots at each depth. The tree is built, the action leading to the best possible value from the root node is selected and a real transition is performed. The next state is then reached, the new snapshot model MDP$_{t_0 + 1}$ is acquired and the process re-starts. Notice the use of $R(\nu)$ and $p(\nu' \mid \nu)$ in the pseudo-code: they are light notations respectively standing for $R_t(s, a)$ corresponding to a chance node $\nu \equiv \nu^{s, t, a}$ and the probability $p_t(s' | s, a)$ to jump to a decision node $\nu'\equiv \nu^{s', t + 1}$ given a chance node $\nu \equiv \nu^{s,t,a}$. \begin{algorithm2e}[t] \DontPrintSemicolon \textbf{RATS} ($s_0$, $t_0$, maxDepth)\; $\nu_0$ = rootNode($s_0, t_0$)\; Minimax($\nu_0$)\; $\nu^* = \argmax_{\nu' \textbf{ in } \nu_0 \text{.children}} \nu'\text{.value}$\; \textbf{return }$\nu^*.\text{action}$\; \; \textbf{Minimax} ($\nu$, maxDepth)\; \If{$\nu$ is DecisionNode}{ \If{$\nu$.{\normalfont state} is terminal {\normalfont \textbf{or}} $\nu$.{\normalfont depth} = {\normalfont maxDepth}}{ \textbf{return }$\nu$.value = heuristicValue($\nu$.state)\; } \Else{ \textbf{return }$\nu$.value = $\max_{\nu' \in \nu \text{.children}}${Minimax}($\nu'$, maxDepth)\; } } \Else{ \textbf{return }$\nu\text{.value} = \min_{(p, R) \in \Delta_{t_0}^t} R(\nu) + \gamma \sum_{\nu' \in \nu\text{.children}} p(\nu' \mid \nu) \text{Minimax}(\nu', \text{maxDepth})$\; } \caption{RATS algorithm} \label{alg:rats} \end{algorithm2e} The tree built by RATS{} is entirely developed until the maximum depth $d_{\max}$. A heuristic function is used to evaluate the leaf nodes of the tree. \textbf{Analysis of RATS{}.} We are interested in characterizing Algorithm~\ref{alg:rats} without function approximation and therefore will consider finite, countable, $\S \times \A$ sets. We now detail the computation of the min operator (Property~\ref{prop:close-form-worst-case-snapshot}), the computational complexity of RATS{} (Property~\ref{prop:computational-complexity}) and the heuristic function. \begin{property} \label{prop:close-form-worst-case-snapshot} \textbf{Closed-form expression of the worst case snapshot of a chance node.} Following Algorithm~\ref{alg:rats}, a solution to Equation~\ref{eq:chance-node-value} is given by: \begin{equation*} \hat{R}(s, a) = R_{t_0}(s, a) - L_R |t - t_0| \quad \textrm{and} \quad \hat{p}(\cdot \mid s, a) = (1 - \lambda) p_{t_0}(\cdot \mid s, a) + \lambda p_{\text{sat}}(\cdot \mid s, a) \end{equation*} with $p_{\text{sat}}( \cdot \mid s, a) = (0, \cdots, 0, 1, 0, \cdots, 0)$ with $1$ at position $\argmin_{s'} V(\nu^{s', t + 1})$, $\lambda = 1 \text{ if } W_1(p_{\text{sat}}, p_0) \leq L_p |t - t_0|$ and $\lambda = L_p |t - t_0| / W_1 (p_{\text{sat}}, p_0)$ otherwise. \end{property} \begin{property} \textbf{Computational complexity.} The total computation complexity of Algorithm~\ref{alg:rats} is $\mathcal{O} (B |\S|^{1.5} |\A| \left( |\S| |\A| \right)^{d_{\max}})$ with $B$ the number of time steps and $d_{\max}$ the maximum depth. \label{prop:computational-complexity} \end{property} \textbf{Heuristic function.} As in vanilla minimax algorithms, Algorithm~\ref{alg:rats} bootstraps the values of the leaf nodes with a heuristic function if these leaves do not correspond to terminal states. Given such a leaf node $\nu^{s, t}$, a heuristic aims at estimating the value of the optimal policy at $(s,t)$ within the worst-case \NSMDP{}, \ie{} $\hat{V}^*_{t_0,t}(s)$. Let $H(s,t)$ be such a heuristic function, we call \emph{heuristic error} in $(s,t)$ the difference between $H(s,t)$ and $\hat{V}^*_{t_0,t}(s)$. Assuming that the heuristic error is uniformly bounded, the following property provides an upper bound on the propagated error due to the choice of $H$. \begin{property} \label{prop:heuristic-propagated-error} \textbf{Upper bound on the propagated heuristic error within RATS{}.} Consider an agent executing Algorithm~\ref{alg:rats} at $s_0, t_0$ with a heuristic function $H$. We note $\mathcal{L}$ the set of all leaf nodes. Suppose that the heuristic error is uniformly bounded, \ie{} $ \exists \delta > 0, \, \forall \nu^{s, t} \in \mathcal{L}, \, |H(s) - \hat{V}^*_{t_0,t}(s)| \leq \delta $. Then we have for every decision and chance nodes $\nu^{s, t}$ and $\nu^{s, t, a}$, at any depth $d \in [0, d_{\max}]$: \begin{align*} |V(\nu^{s, t}) - \hat{V}^*_{t_0,t}(s)| \leq \gamma^{(d_{\max} - d)} \delta \quad \text{ and } \quad |V(\nu^{s, t, a}) - \hat{Q}^*_{t_0,t}(s,a)| \leq \gamma^{(d_{\max} - d)} \delta. \end{align*} \end{property} This last result implies that with \emph{any} heuristic function $H$ inducing a uniform heuristic error, the propagated error at the root of the tree is guaranteed to be upper bounded by $\gamma^{d_{\max}} \delta$. In particular, since the reward function is bounded by hypothesis, we have $\hat{V}^*_{t_0,t}(s) \leq 1 / (1 - \gamma)$. Thus, selecting for instance the zero function ensures a root node heuristic error of at most ${\gamma^{d_{\max}}}/{(1 - \gamma)}$. In order to improve the precision of the algorithm, we propose to guide the heuristic by using a function reflecting better the value of state $s$ at leaf node $\nu^{s, t}$. The ideal function would of course be $H(s) = \hat{V}^*_{t_0,t}(s)$, reducing the heuristic error to zero, but this is intractable. Instead, we suggest to use the value of $s$ within the snapshot MDP$_t$ using an evaluation policy $\pi$, \ie{} $H(s) = V^\pi_{\text{MDP}_t}(s)$. This snapshot is also not available, but Property~\ref{prop:bound-leaf-value} provides a range wherein this value lies. \begin{property} \label{prop:bound-leaf-value} \textbf{Bounds on the snapshots values.} Let $s \in \S$, $\pi$ a stationary policy, MDP$_{t_0}$ and MDP$_t$ two snapshot MDPs, $t, t_0 \in \T^2$ be. We note $V^\pi_{\text{MDP}_{i}}(s)$ the value of $s$ within MDP$_{i}$ following $\pi$. Then, \begin{equation*} | V^\pi_{\text{MDP}_{t_0}}(s) - V^\pi_{\text{MDP}_t}(s) | \leq |t - t_0| L_R / (1-\gamma). \end{equation*} \end{property} Since $\text{MDP}_{t_0}$ is available, $V^\pi_{\text{MDP}_{t_0}}(s)$ can be estimated, \eg{} via Monte-Carlo roll-outs. Let $\widehat{V}^\pi_{\text{MDP}_{t_0}}(s)$ denote such an estimate. Following Property~\ref{prop:bound-leaf-value}, $V^\pi_{\text{MDP}_{t_0}}(s) - |t - t_0| L_R / (1-\gamma) \leq V^\pi_{\text{MDP}_t}(s)$. Hence, a worst-case heuristic on $V^\pi_{\text{MDP}_t}(s)$ is $H(s) = \widehat{V}^\pi_{\text{MDP}_{t_0}}(s) - |t - t_0| L_R / (1-\gamma)$. The bounds provided by Property~\ref{prop:heuristic-propagated-error} decrease quickly with $d_{\max}$, and given that $d_{\max}$ is \emph{large enough}, RATS{} provides the optimal risk-averse maximizing the worst-case value for any evolution of the \NSMDP{}. \section{Experiments} \label{sec:expe} We compare the RATS{} algorithm with two policies~\footnote{ \if\statecodewillbeprovided1 Code: https://github.com/SuReLI/rats-experiments \fi -- ML reproducibility checklist: Appendix Section~\ref{sec:reproducibility-checklist}. }. The first one, named DP-snapshot, uses Dynamic Programming to compute the optimal actions \wrt{} the snapshot models at each decision epoch. The second one, named DP-NSMDP, uses the real NSMDP as a model to provide its optimal action. The latter behaves as an omniscient agent and should be seen as an upper bound on the performance. We choose a particular grid-world domain coined ``Non-Stationary bridge'' illustrated in Appendix, Section~\ref{sec:nsbridge-figure}. An agent starts at the state labeled S in the center and the goal is to reach one of the two terminal states labeled G where a reward of +1 is received. The gray cells represent holes that are terminal states where a reward of -1 is received. Reaching the goal on the right leads to the highest payoff since it is closest to the initial state and a discount factor $\gamma = 0.9$ is applied. The actions are $\A = \{ \text{Up, Right, Down, Left} \}$. The transition function is stochastic and non-stationary. At decision epoch $t = 0$, any action deterministically yields the intuitive outcome. With time, when applying Left or Right, the probability to reach the positions usually stemming from Up and Down increases symmetrically until reaching 0.45. We set the Lipschitz constant $L_p = 1$. Aside, we introduce a parameter $\epsilon \in [0, 1]$ controlling the behavior of the environment. If $\epsilon = 0$, only the left-hand side bridge becomes slippery with time. It reflects a close to worst-case evolution for a policy aiming to the left-hand side goal. If $\epsilon = 1$, only the right-hand side bridge becomes slippery with time. It reflects a close to worst-case evolution for a policy aiming to the right-hand side goal. In between, the misstep probability is proportionally balanced between left and right. One should note that changing $\epsilon$ from 0 to 1 does not cover all the possible evolutions from MDP$_{t_0}$ but provides a concrete, graphical illustration of RATS's behavior for various possible evolutions of the \NSMDP{}. We tested RATS{} with $d_{\max} = 6$ so that leaf nodes in the search tree are terminal states. Hence, the optimal risk-averse policy is applied and no heuristic approximation is made. Our goal is to demonstrate that planning in this worst-case \NSMDP{} allows to minimize the loss given any possible evolution of the environment. To illustrate this, we report results reflecting different evolutions of the same \NSMDP{} using the $\epsilon$ factor. It should be noted that, at $t = 0$, RATS{} always moves to the left, even if the goal is further, since going to the right may be risky if the probabilities to go Up and Down increase. This corresponds to the careful, risk-averse, behavior. Conversely, DP-snapshot always moves to the right since $\text{MDP}_{0}$ does not capture this risk. As a result, the $\epsilon = 0$ case reflects a favorable evolution for DP-snapshot and a bad one for RATS{}. The opposite occurs with $\epsilon = 1$ where the cautious behavior dominates over the risky one, and the in-between cases mitigate this effect. In Figure~\ref{fig:return-vs-epsilon}, we display the achieved expected return for each algorithm as a function of $\epsilon$, \ie{} as a function of the possible evolutions of the \NSMDP{}. As expected, the performance of DP-snapshot strongly depends on this evolution. It achieves high return for $\epsilon = 0$ and low return for $\epsilon = 1$. Conversely, the performance of RATS{} varies less across the different values of $\epsilon$. The effect illustrated here is that RATS{} maximizes the minimal possible return given \emph{any} evolution of the \NSMDP{}. It provides the guarantee to achieve the best return in the worst-case. This behavior is highly desirable when one requires robust performance guarantees as, for instance, in critical certification processes. \begin{figure}[] \begin{subfigure}{.5\textwidth} \centerline{ \includegraphics[trim={0cm, 0cm, 0cm, 0mm}, clip, width=\textwidth]{img/return_vs_epsilon.pdf}} \captionsetup{width=\textwidth} \caption{Discounted return vs $\epsilon$, 50\% of standard deviation.} \label{fig:return-vs-epsilon} \end{subfigure}% \begin{subfigure}{.5\textwidth} \centerline{ \includegraphics[trim={2cm, 3mm, 2cm, 5mm}, clip, width=\textwidth,height=10.5em]{img/return_distributions_density.pdf}} \captionsetup{width=0.9\textwidth} \caption{Discounted return distributions $\epsilon \in \{ 0, 0.5, 1 \}$.} \label{fig:return-distributions} \end{subfigure} \caption{Discounted return of the three algorithms for various values of $\epsilon$.} \end{figure} Figure~\ref{fig:return-distributions} displays the return distributions of the three algorithms for $\epsilon \in \{ 0, 0.5, 1 \}$. The effect seen here is the tendency for RATS{} to diminish the left tail of the distribution corresponding to low returns for each evolution. It corresponds to the optimized criteria, \ie{} robustly maximizing the worst-case value. A common risk measure is the Conditional Value at Risk (CVaR) defined as the expected return in the worst $q$\% cases. We illustrate the CVaR at 5\% achieved by each algorithm in Table~\ref{table:result}. Notice that RATS{} always maximizes the CVaR compared to both DP-snapshot and DP-\NSMDP{}. Indeed, even if the latter uses the true model, the optimized criteria in DP is the expected return. \section{Conclusion} \label{sec:conclu} We proposed an approach for robust planning in non-stationary stochastic environments. We introduced the framework of Lipchitz Continuous Non-Stationary MDPs (\NSMDP{}s) and derived the Risk-Averse Tree-Search (RATS{}) algorithm, to predict the worst-case evolution and to plan optimally \wrt{} this worst-case \NSMDP{}. We analyzed RATS{} theoretically and showed that it approximates a worst-case \NSMDP{} with a control parameter that is the depth of the search tree. We showed empirically the benefit of the approach that searches for the highest lower bound on the worst achievable score. RATS{} is robust to every possible evolution of the environment, \ie{} maximizing the expected worst-case outcome on the whole set of possible \NSMDP{}s. Our method was applied to the uncertainty on the evolution of a model. Generally, it could be extended to any uncertainty on the model used for planning, given bounds on the set of the feasible models. The purpose of this contribution is to lay a basis of worst-case analysis for robust solutions to \NSMDP{}s. As is, RATS{} is computationally intensive and scaling the algorithm to larger problems is an exciting future challenge. \section*{Acknowledgments} This research was supported by the Occitanie region, France. \bibliographystyle{abbrvnat}
{'timestamp': '2020-01-16T02:14:27', 'yymm': '1904', 'arxiv_id': '1904.10090', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.10090'}
arxiv
\section{Introduction} \Glspl{gl:DSM} with detailed and realistic building shapes are beneficial data sources for many remote sensing applications, such as urban planning, cartographic analysis, environmental investigations, \etc. Several ways for deriving 3D elevation morphology, but the \glspl{gl:DSM} generated from space-borne data using stereo image matching techniques nowadays have lower costs compared to other technologies, show relatively high spatial resolution and wide coverage which is important for large-scale remote sensing applications, such as disaster monitoring. \begin{figure}[t] \centering \subcaptionbox{\label{fig:PAN2D}} {\frame{\includegraphics[width=.3\linewidth]{figures/PAN2D.jpg}} } \subcaptionbox{\label{fig:Dfilled2D}} {\frame{\includegraphics[width=.3\linewidth]{figures/Dfilled2D.jpg}} } \subcaptionbox{\label{fig:GT2D}} {\frame{\includegraphics[width=.3\linewidth]{figures/LOD2D.jpg}} } \caption{ Sample of area from our dataset illustrated both inputs to the network \subref{fig:PAN2D} \gls{gl:PAN} image and \subref{fig:Dfilled2D} photogrammetric \gls{gl:DSM}, and \subref{fig:GT2D} the ground truth \gls{gl:LoD}-2-\gls{gl:DSM}. The \gls{gl:DSM} images are color-shaded for better visualization. \label{fig:Img1}} \end{figure} However, apart from many advantages, \glspl{gl:DSM} generated by image-based matching techniques show a reasonable amount of noise and outliers because of matching errors or occlusions due to densely located buildings or trees, which cover parts of the building constructions. To solve these problems, algorithms from computer vision have been analyzed and adapted to satellite imagery processing. In the literature, very few of the proposed approaches work towards photogrammetric \gls{gl:DSM} improvement of urban areas. In contrast, earlier methodologies investigate the \glspl{gl:DSM} refinement by applying filtering techniques, such as Gaussian~\cite{walker2006comparative}, Kalman~\cite{wang1998applying}, geostatistical~\cite{felicisimo1994parametric}, or interpolation routines, including \gls{gl:IDW} and kriging~\cite{anderson2005lidar}. Despite achieving smoother surfaces of roof planes, they negatively influence the steepness of the building walls. Later, some methodologies proposed to additionally utilize spectral images for \gls{gl:DSM} refinement tasks, as, for instance, they contain accurate information about object boundaries or texture. For instance, \citet{krauss2010enhancement} transfer segmentation information from stereo satellite imagery to the \gls{gl:DSM} and, from statistical analysis and spectral information, perform object detection and classification. As a further step, this information is used to refine the \gls{gl:DSM}. \Citet{sirmacek2010enhancing} propose building shape refinement on \glspl{gl:DSM} by a multiple-step procedure. First, they extract possible building segments by thresholding the \gls{gl:nDSM}. Then, by considering Canny edge information from the spectral image, they fit rectangular boxes to detect building shapes. Finally, applying this information about detected rectangular boundaries, the building shapes are further enhanced. The drawback of this methodology is that they assign one single height value to each generated building object. Moreover, it is limited to the detection and enhancement of rectangular buildings only. \vspace{-5pt} Within recent years, the already well-studied branch of the deep learning family, \glspl{gl:CNN}, has also been applied to the remote sensing field. They achieve state-of-the-art results for image classification, object detection, or semantic segmentation tasks. However, most of these methodologies extract information from spectral imagery, while depth image processing is still not well explored, as it is not straightforward to work with continuous values. For example,~\citet{eigen2014depth} employ cascade deep network which first performs a coarse global prediction from a single spectral image and refines the predictions locally afterwards. \Citet{liu2016learning} join \glspl{gl:CNN} and \glspl{gl:CRF} in a unified framework while making use of superpixels for preserving sharp edges. In case of height prediction problems, only a couple of works made attempts to improve \glspl{gl:DSM}. Our earlier approaches~\cite{Bittner18:ALSb,bittner2018dsm} propose to refine building shapes to a high level of details from photogrammetric half-meter resolution satellite \glspl{gl:DSM} using \gls{gl:GAN}-based techniques. Mainly, they investigate \glspl{gl:cGAN} with two objective functions---\ie the negative log-likelihood and least square residuals---to generate accurate \gls{gl:LIDAR}-like and \gls{gl:LoD}-2-like \glspl{gl:DSM} with enhanced 3D building shapes directly from noisy input data. Moreover, the experiment performed on a completely new dataset, belonging to different geographical areas, showed the network's potential to generalize well to different cities with complex constructions without many difficulties. As it is common in the field of remote sensing to fuse data with different modalities to complement missing knowledge, in our followed work \cite{Bittner19:new} we introduce a \gls{gl:cGAN}-based network which merges depth and spectral information within an end-to-end framework. Fusing data from separate networks---which are fed with \gls{gl:PAN} images and \glspl{gl:DSM}---is performed at a \emph{later} stage right before producing the final output. Following up to the aforementioned approach, in this work, we investigate the fusion of spectral (\cref{fig:PAN2D}) and height (\cref{fig:Dfilled2D}) information at an \emph{earlier} stage within an end-to-end \HybridcGANdot\space network to further improve not only the small and simple residential buildings, but also complex industrial ones. Besides, we add an auxiliary \emph{normal vector loss} term to the objective function enforcing the model to produce more planar and flat roof surfaces, similar to the desired \gls{gl:LoD}2-\gls{gl:DSM} (\cref{fig:GT2D}) artificially produced from \gls{gl:CityGML} data. \section{Methodology} \subsection{Objective function} The advent of \gls{gl:GAN}-based domain adaptation neural networks, introduced by \citet{goodfellow2014generative}, lead to great performance gains in generating realistic, but entirely artificial images. These \glspl{gl:GAN} realize an adversarial manner of learning by training a pair of networks in a competing way: A \emph{generator} $\ensuremath{G}\xspace(\ensuremath{\V{\latentZ}}\xspace| \ensuremath{\V{\inputX}}\xspace) = \ensuremath{\V{\targetY}}\xspace$ produces a fake image $\ensuremath{\V{\targetY}}\xspace$ from a latent vector $\ensuremath{\V{\latentZ}}\xspace \sim {p}_\ensuremath{z}\xspace(\cdot)$ drawn from any distribution ${p}_\ensuremath{z}\xspace(\cdot)$% ---\eg a uniform distribution ${p}_\ensuremath{z}\xspace(\cdot) = \operatorname{Unif}(\cdot; a,b)$---% which looks like a real one $\ensuremath{\V{\targetY}}\xspace^* \sim {p}_\text{real}(\cdot)$. Adversarially, a \emph{discriminator} $\ensuremath{D}\xspace(\ensuremath{\V{\targetY}}\xspace| \ensuremath{\V{\inputX}}\xspace) \in [0,1]$ tries to decide whether a presented image $\ensuremath{\V{\targetY}}\xspace$ is a real or a generated fake one. Frequently, some external information in the form of a source image \ensuremath{\V{\inputX}}\xspace is additionally used as an input to restrict both the generator in its output and the discriminator in its expected input. The objective function for such conditional \glspl{gl:GAN} can be expressed through a two-player minimax game \begin{align} \underset{\ensuremath{G}\xspace}{\min} \; \underset{\ensuremath{D}\xspace}{\max} \; &\mathcal{L}_\text{cGAN}(G,D) = \mathbb{E}_{\ensuremath{\V{\inputX}}\xspace,\ensuremath{\V{\targetY}}\xspace \sim p_\text{real}(\ensuremath{\V{\targetY}}\xspace)}[\log \ensuremath{D}\xspace(\ensuremath{\V{\targetY}}\xspace| \ensuremath{\V{\inputX}}\xspace)] + \nonumber \\ &\mathbb{E}_{\ensuremath{\V{\inputX}}\xspace, \ensuremath{\V{\latentZ}}\xspace \sim p_\ensuremath{z}\xspace(\ensuremath{\V{\latentZ}}\xspace)}[\log(1 - \ensuremath{D}\xspace(\ensuremath{G}\xspace(\ensuremath{\V{\latentZ}}\xspace | \ensuremath{\V{\inputX}}\xspace)| \ensuremath{\V{\inputX}}\xspace))] , \label{eq:cGAN_objective} \end{align} where $\mathbb{E}[\cdot]$ denotes the expectation value. To overcome the problem of instability during training \gls{gl:cGAN} when its objective function is based on the negative log-likelihood, we use a least square loss $L_2$ instead which yields the \gls{gl:cLSGAN} objective function \begin{align} \mathcal{L}_\text{cLSGAN}(\ensuremath{G}\xspace,\ensuremath{D}\xspace) &= \mathbb{E}_{\ensuremath{\V{\inputX}}\xspace,\ensuremath{\V{\targetY}}\xspace \sim p_\text{real}(\ensuremath{\V{\targetY}}\xspace)}[(\ensuremath{D}\xspace(\ensuremath{\V{\targetY}}\xspace| \ensuremath{\V{\inputX}}\xspace) - 1)^2] \nonumber \\ &+ \mathbb{E}_{\ensuremath{\V{\inputX}}\xspace, \ensuremath{\V{\latentZ}}\xspace \sim p_\ensuremath{z}\xspace(\ensuremath{\V{\latentZ}}\xspace)}[\ensuremath{D}\xspace(\ensuremath{G}\xspace(\ensuremath{\V{\latentZ}}\xspace | \ensuremath{\V{\inputX}}\xspace)| \ensuremath{\V{\inputX}}\xspace)^2]. \label{eq:cLSGAN_objective} \end{align} In order to obtain \glspl{gl:DSM} in which the buildings feature sharply defined ridgelines and steep walls, we utilize the $L_1$ distance \begin{align} \mathcal{L}_{L_1}(\ensuremath{G}\xspace) &= \mathbb{E}_{\ensuremath{\V{\inputX}}\xspace,\ensuremath{\V{\targetY}}\xspace \sim p_\text{real}(\ensuremath{\V{\targetY}}\xspace), \ensuremath{\V{\latentZ}}\xspace \sim p_\ensuremath{z}\xspace(\ensuremath{\V{\latentZ}}\xspace)}[\lVert \V{y} - G(\ensuremath{\V{\latentZ}}\xspace | \ensuremath{\V{\inputX}}\xspace) \rVert_1], \label{eq:L1} \end{align} which prevents blurring effects. As our major goal is to improve roof surfaces by making them flatter and looking closer to realistic ones, we integrate a \emph{normal vector loss} term \begin{align} \label{eq:surface_normal} \mathcal{L}_{\text{normal}}(\mathcal{N}^\text{t}, \mathcal{N}^\text{p}) &= \frac{1}{m} \sum_{i=1}^{m} \left( 1 - \frac{\left\langle \V{n}_{i}^\text{t}, \V{n}_{i}^\text{p} \right\rangle } {\left\| \V{n}_{i}^\text{t} \right\| \left\| \V{n}_{i}^\text{p}\right\| } \right), \end{align} into the learning process, as proposed by \citet{hu2018revisiting}. This normal vector loss measures the angle between the set of surface normals $\mathcal{N}^\text{p} = \left\{ \V{n}_1^\text{p}, \ldots, \V{n}_m^\text{p}\right\}$ of an estimated \gls{gl:DSM} and the set of surface normals $\mathcal{N}^\text{t} = \left\{ \V{n}_1^\text{t}, \ldots, \V{n}_m^\text{t}\right\}$ of the target \gls{gl:LoD}2-\gls{gl:DSM}. Adding those three terms together leads to our final objective \begin{align} \label{eq:objective_function} \ensuremath{G}\xspace^\star = \arg \underset{G}{\min} \; \underset{D}{\max} \; \mathcal{L}_{\text{cGAN}}(G,D)+\lambda \mathcal{L}_{L_1}(G) \nonumber \\ + \gamma \mathcal{L}_{\text{normal}}(\mathcal{N}^\text{t}, \mathcal{N}^\text{p}) \,, \end{align} where \ensuremath{G}\xspace intents to minimize the objective function $\mathcal{L}_{\text{cLSGAN}}(G,D)$ against \ensuremath{D}\xspace that aims to maximize it. The parameters $0 \leq \lambda \in \mathbb{R}$ and $0 \leq \gamma \in \mathbb{R}$ are the balancing hyper-parameters. \begin{figure}[t] \centering \includegraphics[width=\columnwidth]{figures/arch_cond.jpg} \put (-240,49) {\scriptsize{DSM ($I_1$)}} \put (-240,105) {\scriptsize{PAN} ($I_2$)} \put (-47,114) {\scriptsize{\ensuremath{D}\xspace}} \put (-47,48) {\scriptsize{\ensuremath{D}\xspace}} \put (-155,43) {\scriptsize{\ensuremath{G}\xspace}} \put (-100,118) {\scriptsize{\ensuremath{G}\xspace($I_1,I_2$)}} \put (-90,58) {\scriptsize{$I_1$}} \put (-200,150) {\scriptsize{$E_2$}} \put (-200,93) {\scriptsize{$E_1$}} \put (-90,50) {\scriptsize{$I_1$}} \put (-90,-6) {\scriptsize{GT}} \put (-212,23) {\scriptsize{skip connections}} \put (-212,16) {\scriptsize{concatenation}} \put (-212,10) {\scriptsize{condition}} \caption{Schematic overview of the proposed architecture for the building shape refinement on photogrammetric \glspl{gl:DSM} by \HybridcGANdot\space using both depth and spectral information.} \label{fig:architecture} \end{figure} \subsection{Network architecture} We have already made an attempt to investigate the \gls{gl:LoD}2-like \gls{gl:DSM} generation with enhanced building shapes from a single noisy photogrammetric \gls{gl:DSM} using \gls{gl:cGAN} architecture with an objective function based on least square residuals~\cite{bittner2018dsm}. In this work, we refer to it as a single-stream \gls{gl:cGAN}. As each photogrammetric \gls{gl:DSM} is a product obtained from panchromatic image pairs, it seems reasonable to integrate depth and spectral data into one single network, as the latter provides sharper information about building silhouettes, which allows not only a better reconstruction of missing building parts but also the refinement of building outlines. We fuse two separate but identical \emph{UNet}-type networks at the later end within the \ensuremath{G}\xspace part of a \gls{gl:cGAN}, where the first stream is fed with the \gls{gl:PAN} image and the second stream with the stereo \gls{gl:DSM}, creating a so-called \WNetdot\space architecture~\cite{Bittner19:new}. In this paper, we examine the potential of an earlier fusion of data from different modalities, as it could potentially even better blend together the depth and spectral information. Mainly, the generator \ensuremath{G}\xspace of the proposed \HybridcGANdot\space network consists of two encoders $E_1$ and $E_2$, concatenated at the top layer, and a common decoder, which integrates information from two different modalities and generates an \gls{gl:LoD}2-like \gls{gl:DSM} with refined building shapes. The inputs to $E_1$ are the single-channel orthorectified \gls{gl:PAN} images, while $E_2$ receives the single-channel photogrammetric \glspl{gl:DSM} with continuous values. Since intensity and depth information have different physical meanings, it is unlikely to make sense to jointly propagate them right from the beginning. It seems reasonable to separate them first and allow the network to learn the most valuable features from each modality itself. The generator \ensuremath{G}\xspace is constructed based on an U-form network proposed by \citet{isola2016image}. As a result, in our case it has 14 skip connections from both the spectral stream and the depth stream allowing the decoder to learn back detailed features that were lost by pooling in the encoders. In particular, the encoder and decoder consist of 8 convolutional layers each, followed by a \gls{gl:LReLU}~\cite{Maas13:RNL} activation function \begin{align*} \sigma_\text{\acrshort{gl:LReLU}}(z)= \begin{cases} z, & \text{if $z>0$}\\ az, & \text{otherwise} \end{cases}, a \in \mathbb{R}^+, \end{align*} and \gls{gl:BN} in case of the encoder, and a \gls{gl:ReLU} activation function \begin{align*} \sigma_\text{\acrshort{gl:ReLU}}(z)= \begin{cases} z, & \text{if $z>0$}\\ 0, & \text{otherwise} \end{cases} \end{align*} and \gls{gl:BN} in case of the decoder. On top of the generator network \ensuremath{G}\xspace, the $\operatorname{tanh}$ activation function $\sigma_\text{tanh}(z) = \operatorname{tanh}(z)$ is applied. The discriminator network \ensuremath{D}\xspace is a binary classification network constructed with 5 convolutional layers, followed by \gls{gl:LReLU} activation function and a \gls{gl:BN} layer. It has a \emph{sigmoid} activation function $\sigma_\text{sigm}(z) = \frac{1}{1+\ensuremath{\mathrm{e}}^{-z}}$ at the top layer to output the likelihood that the input image belongs either to class 1 (\enquote{real}) or class 0 (\enquote{generated}). A schematic representation of the proposed architecture is depicted in \cref{fig:architecture}. All along the training phase, the two networks \ensuremath{G}\xspace and \ensuremath{D}\xspace are trained at the same time by alternating one gradient descent step of \ensuremath{D}\xspace and one gradient descent step of \ensuremath{G}\xspace. During the inference process, only the trained generator model \ensuremath{G}\xspace of the \HybridcGANdot\space network is involved. \section{Study Area and Experiments} \subsection{Dataset} Experiments have been carried out on data showing the city of Berlin, Germany, covering a total area of \SI{410}{\square\kilo\meter}. It consists of half-meter resolution orthorectified \gls{gl:PAN} images showing the closest nadir view and photogrammetric \glspl{gl:DSM} generated with \gls{gl:SGM}~\cite{d2011semiglobal} from six panchromatic Worldview-1 images acquired at two different days. As ground truth, the artificial \gls{gl:LoD}2-\gls{gl:DSM}, generated with a resolution of \SI{0.5}{\px} from a \gls{gl:CityGML} data model together with an available \gls{gl:DTM}, was used. The \gls{gl:CityGML} data model is freely available from the download portal \emph{Berlin 3D} \footnote{\url{http://www.businesslocationcenter.de/downloadportal}}. We followed the same \gls{gl:LoD}2-\gls{gl:DSM} creation procedure as in \citet{bittner2018dsm}. \begin{figure*}[t] \centering \subcaptionbox{\label{fig:testArea_O3_width_320_height_320_2}\Acrlong{gl:PAN} image} {\includegraphics[width=.47\linewidth]{figures/testArea_O3_xs_2141_ys_40183_width_320_height_320_2.jpg} }\hfill \subcaptionbox{\label{fig:test_DSM2LOD2GEOKOLref_width_320_height_320} Single depth-stream \gls{gl:DSM}~\cite{bittner2018dsm}} {\includegraphics[width=.47\linewidth]{figures/test_DSM2LOD2GEOKOLref_wthTANH_lsgan_width_320_height_320.jpg} \linethickness{0.5mm} \put(-43,95){\color{magenta}\vector(-1, 0){14}} \put(-3,40){\color{magenta}\vector(-1, 0){14}} \put(-40,45){\color{magenta}\vector(-1, 0){14}} \put(0,20){\color{magenta}\vector(-1, 0){14}} } \subcaptionbox{\label{fig:testArea_Dfilled_geoid_width_320_height_320} Photogrammetric \gls{gl:DSM}} {\includegraphics[width=.47\linewidth]{figures/testArea_Dfilled_geoid_xs_2141_ys_40183_width_320_height_320.jpg} }\hfill \subcaptionbox{\label{fig:test_O3andDSM2LODGEOKOLref_lsgan_width_320_height_320} \WNetcGANdot\space\cite{Bittner19:new}} {\includegraphics[width=.47\linewidth]{figures/test_O3andDSM2LODGEOKOLref_lsgan_width_320_height_320.jpg} } \subcaptionbox{\label{fig:testArea_LOD2filled_width_320_height_320} Ground truth} {\includegraphics[width=.47\linewidth]{figures/testArea_LOD2filled_wth_DGM_roi_intrp_GEOKOLref_xs_2141_ys_40183_width_320_height_320.jpg} }\hfill \subcaptionbox{\label{fig:test_O3andDSM2LODGEOKOLref_lsgan_NotSharedWeights_width_320_height_320} \HybridcGANdot\space (ours)} {\includegraphics[width=.47\linewidth]{figures/test_O3andDSM2LODGEOKOLref_lsgan_NotSharedWeights_width_320_height_320.jpg} \put (-153,83) {\color{yellow}\textbf{\scriptsize{1}}} \put (-120,81) {\color{yellow}\textbf{\scriptsize{2}}} } \caption{% Visual analysis of \glspl{gl:DSM}, generated by \subref{fig:testArea_Dfilled_geoid_width_320_height_320} a standard photogrammetric method, \subref{fig:test_DSM2LOD2GEOKOLref_width_320_height_320} the single-stream \gls{gl:cGAN} model~\cite{bittner2018dsm}, \subref{fig:test_O3andDSM2LODGEOKOLref_lsgan_width_320_height_320} the two-stream \WNetcGANdot\space\cite{Bittner19:new}, and \subref{fig:test_O3andDSM2LODGEOKOLref_lsgan_NotSharedWeights_width_320_height_320} our proposed \HybridcGANdot\space architecture. The \gls{gl:DSM} images are color-coded for better visualization. } \label{fig:smallBuildings} \end{figure*} \begin{figure*}[t] \centering \subcaptionbox{Single depth-stream \gls{gl:DSM}~\cite{bittner2018dsm}\label{fig:cLSGAN_profile}} {\parbox{.3\linewidth}{% \includegraphics[width=\linewidth]{figures/cLSGAN_profile1}\\ \includegraphics[width=\linewidth]{figures/cLSGAN_profile3}% }% } \subcaptionbox{\WNetcGANdot\space~\cite{Bittner19:new}\label{fig:IGARSS_profiles}} {\parbox{.3\linewidth}{% \includegraphics[width=\linewidth]{figures/IGARSS_profiles1.jpg} \includegraphics[width=\linewidth]{figures/IGARSS_profiles3.jpg} }% } \subcaptionbox{\HybridcGANdot\space (ours)\label{fig:HybridcGAN_profiles}} {\parbox{.3\linewidth}{% \includegraphics[width=\linewidth]{figures/HybridcGAN_profiles1.jpg} \includegraphics[width=\linewidth]{figures/HybridcGAN_profiles3.jpg} }% }\\ \vspace{0.2cm} \begin{center} \tikz{\path[draw=black,fill=red] (0,0) rectangle (0.5cm,0.4cm);}\hspace{0.1cm}\text{input \gls{gl:DSM}}\quad \tikz{\path[draw=black,fill=green] (0,0) rectangle (0.5cm,0.4cm);}\hspace{0.1cm}\text{Ground truth}\quad \tikz{\path[draw=black,fill=yellow] (0,0) rectangle (0.5cm,0.4cm);}\hspace{0.1cm}\text{Single depth-stream \gls{gl:DSM}~\cite{bittner2018dsm}}\\ \tikz{\path[draw=black,fill=black] (0,0) rectangle (0.5cm,0.4cm);}\hspace{0.1cm}\text{\WNetcGANdot\space~\cite{Bittner19:new}}\quad \tikz{\path[draw=black,fill=blue] (0,0) rectangle (0.5cm,0.4cm);}\hspace{0.1cm}\text{\HybridcGANdot\space (ours)} \end{center} \caption{% Visual investigation of profiles for two selected buildings from the \glspl{gl:DSM} generated by \subref{fig:cLSGAN_profile} the single-stream \gls{gl:cGAN} model~\cite{bittner2018dsm}, \subref{fig:IGARSS_profiles} the two-stream \WNetcGANdot\space model~\cite{Bittner19:new}, and \subref{fig:HybridcGAN_profiles} the proposed \HybridcGANdot\space architecture. The first row shows profiles of building \enquote{1} and the second row depicts the profiles of building \enquote{2} (\cf \cref{fig:test_O3andDSM2LODGEOKOLref_lsgan_NotSharedWeights_width_320_height_320}). } \label{fig:profiles} \end{figure*} \subsection{Implementation and Training Details} The proposed \HybridcGANdot\space network was realized using the \emph{PyTorch} python package based on the implementation published by \citet{isola2016image}. The prepared training dataset covers \SI{353}{\square\kilo\meter} and consists of \num{21480} pairs of patches of size \SI{256x256}{\px} obtained by tiling the given satellite image on the fly with random overlap in both horizontal and vertical directions. This procedure provides the network the possibility to learn building shapes, which, during one epoch, may be located on the patch border and, as a result, are only partially introduced to the network. For the validation phase, an area covering \SI{6}{\square\kilo\meter} was used for tuning the hyper-parameters. The \HybridcGANdot\space network and others, used in this paper for comparison, were trained on minibatch \gls{gl:SGD} using the Adam optimizer~\cite{kingma2014adam} with an initial learning rate of $\alpha = 0.0002$ and momentum parameters $\beta_1 = 0.5$ and $\beta_2 = 0.999$. We set the weighting hyper-parameters $\lambda = 1000$ and $\gamma = 10$ after performing training and examining the resulting generated images from the validation dataset. The complete number of epochs was set to 200 with a batch size of 5 on a single NVIDIA TITAN X (PASCAL) GPU with 12 GB of memory. Different to the training phase, where two networks \ensuremath{G}\xspace and \ensuremath{D}\xspace were trained at the same time by alternating one gradient descent step of \ensuremath{D}\xspace and one gradient descent step of \ensuremath{G}\xspace, in inference phase only the trained generator model \ensuremath{G}\xspace was involved. Stitching the predicted \gls{gl:LoD}2-like height images---entirely unseen during training and validation phases---with a fixed overlap of half the patch size in both horizontal and vertical directions, we generated the final full image covering an area of \SI{50}{\square\kilo\meter}. \begin{figure*}[t] \centering \subcaptionbox{\label{fig:testArea_O_1}\Acrlong{gl:PAN} image} {\frame{\includegraphics[width=.32\linewidth]{figures/testArea_O_xs_0_ys_10412_width_839_height_366.jpg}} } \subcaptionbox{\label{fig:testArea_Dfilled_geoid_1} Photogrammetric \gls{gl:DSM}} {\frame{\includegraphics[width=.32\linewidth]{figures/testArea_Dfilled_geoid_xs_0_ys_10412_width_839_height_366.jpg}} } \subcaptionbox{\label{fig:GT_1} Ground truth} {\frame{\includegraphics[width=.32\linewidth]{figures/testArea_LOD2filled_wth_DGM_roi_intrp_GEOKOLref_xs=0_ys_10412_width_839_height_366.jpg}} } \subcaptionbox{\label{fig:test_DSM2LOD2GEOKOLref_wthTANH_1} Single depth-stream~\cite{bittner2018dsm} \gls{gl:DSM}} {\frame{\includegraphics[width=.32\linewidth]{figures/test_DSM2LOD2GEOKOLref_wthTANH_lsgan_lA1000_batch5_xs=0_ys_10412_width_839_height_366.jpg}} } \subcaptionbox{\label{fig:test_OandDSM2LODGEOKOLref_1} \WNetcGANdot\space~\cite{Bittner19:new}} {\frame{\includegraphics[width=.32\linewidth]{figures/test_OandDSM2LODGEOKOLref_lsgan_lA1000_lSN10_wnet256_xs=0_ys_10412_width_839_height_366.jpg}} } \subcaptionbox{\label{fig:test_DSM2LOD2GEOKOLref_1} \HybridcGANdot\space (ours)} {\frame{\includegraphics[width=.32\linewidth]{figures/test_OandDSM2LODGEOKOLref_lsgan_NotSharedWeights_lA1000_lSN10_CoupledUnet256_xs=0_ys_10412_width_839_height_366.jpg}} } \caption{Visual analysis of \glspl{gl:DSM}, generated by \subref{fig:test_DSM2LOD2GEOKOLref_wthTANH_1} the single-stream \gls{gl:cGAN} model~\cite{bittner2018dsm}, \subref{fig:test_OandDSM2LODGEOKOLref_1} the two-stream \WNetcGANdot\space\cite{Bittner19:new}, and \subref{fig:test_DSM2LOD2GEOKOLref_1} our proposed \HybridcGANdot\space architecture. The \gls{gl:DSM} images are color-shaded for better visualization. \label{fig:Area1}} \end{figure*} \begin{figure*}[t] \setlength{\fboxsep}{0pt} \centering \subcaptionbox{\label{fig:testArea_Ortho_2}\Gls{gl:PAN} image} {\fbox{\includegraphics[width=.32\linewidth]{figures/testArea_O3_xs_3979_ys_16924_width_971_height_526_v2.jpg}} } \subcaptionbox{\label{fig:testArea_Dfilled_geoid_2} Photogrammetric \gls{gl:DSM}} {\fbox{\includegraphics[width=.32\linewidth]{figures/testArea_Dfilled_geoid_xs_3623_ys_20158_width_796_height_391.jpg}} } \subcaptionbox{\label{fig:GT_2} Ground truth} {\fbox{\includegraphics[width=.32\linewidth]{figures/testArea_LOD2filled_wth_DGM_roi_intrp_GEOKOLref_xs_3623_ys_20158_width_796_height_391.jpg}} } \subcaptionbox{\label{fig:DSM2LOD2GEOKOLref} Single depth-stream~\cite{bittner2018dsm}} {\fbox{\includegraphics[width=.32\linewidth]{figures/test_DSM2LOD2GEOKOLref_wthTANH_lsgan_lA1000_batch5_xs_3623_ys_20158_width_796_height_391.jpg}} } \subcaptionbox{\label{fig:test_O3andDSM2LODGEOKOLref_wnet_2} \WNetcGANdot\space~\cite{Bittner19:new}} {\fbox{\includegraphics[width=.32\linewidth]{figures/test_O3andDSM2LODGEOKOLref_lsgan_lA1000_lSN10_wnet256_xs_3623_ys_20158_width_796_height_391.jpg}} } \subcaptionbox{\label{fig:test_O3andDSM2LODGEOKOLref_lsgan_NotSharedWeights_2} \HybridcGANdot\space (ours)} {\fbox{\includegraphics[width=.32\linewidth]{figures/test_O3andDSM2LODGEOKOLref_lsgan_NotSharedWeights_lA1000_lSN10_CoupledUnet256_xs_3623_ys_20158_width_796_height_391.jpg}} } \caption{% Visual analysis of an \gls{gl:DSM}, generated by \subref{fig:DSM2LOD2GEOKOLref} the single-stream \gls{gl:cGAN} model~\cite{bittner2018dsm}, \subref{fig:test_O3andDSM2LODGEOKOLref_wnet_2} the two-stream \WNetcGANdot\space model~\cite{Bittner19:new}, and \subref{fig:test_O3andDSM2LODGEOKOLref_lsgan_NotSharedWeights_2} our proposed \HybridcGANdot\space architecture. The \gls{gl:DSM} images are color-coded for better visualization. } \label{fig:Area2} \end{figure*} \section{Results and Discussion} Selected test samples of the \glspl{gl:DSM} generated by the single-stream \gls{gl:cGAN} model~\cite{bittner2018dsm}, the two-stream \WNetcGANdot\space model~\cite{Bittner19:new}, and our proposed \HybridcGANdot\space model are illustrated in \cref{fig:smallBuildings,fig:Area1,fig:Area2}. One can notice that small buildings in all generated \glspl{gl:DSM} show more rectilinear borders and are not merged with adjacent trees, as present in the input \glspl{gl:DSM} (\cf \cref{fig:testArea_Dfilled_geoid_width_320_height_320,fig:testArea_Dfilled_geoid_1,fig:testArea_Dfilled_geoid_2}). The integration of spectral information into the model obviously benefits the building reconstruction process. First of all, the number of reconstructed buildings is increased. For instance, the magenta arrows in \cref{fig:test_DSM2LOD2GEOKOLref_width_320_height_320} highlight the areas in the \gls{gl:DSM} generated by the single-stream \gls{gl:cGAN} model, where the model was not able to reconstruct individual buildings, as opposed to the \WNetcGANdot\space network and our proposed \HybridcGANdot\space network. Second, the roof ridge lines are more distinguishable and rectilinear. This statement can be also confirmed by exemplary investigating the profiles of the two buildings highlighted in \cref{fig:test_O3andDSM2LODGEOKOLref_lsgan_NotSharedWeights_width_320_height_320}. From \cref{fig:profiles} we can notice that the \HybridcGANdot\space network was able to reconstruct much finer building shapes more similar to the ground truth. Moreover, the surfaces of roof planes are smoother or even flat in many cases affirming the influence of the normal vector loss. The profiles also demonstrate the strength of all networks to separate the buildings from adjacent vegetation. From the demonstrated results we can further conclude that most of the generated building shapes followed the correct pattern and feature improved roof forms. However, this statement is true for many residential and not big industrial buildings. How does the network behave in case of big and complicated building structures? The single depth-stream \gls{gl:cGAN} model~\cite{bittner2018dsm} and the two-stream \WNetcGANdot\space model~\cite{Bittner19:new} only partially extract such buildings. In case of spectral information integration, although at the late fusion, it helps to improve the silhouette of the buildings as well as the detailed constructions on the rooftops (\cf \cref{fig:test_O3andDSM2LODGEOKOLref_wnet_2,fig:test_OandDSM2LODGEOKOLref_1}) but still misses or has incompleted inside parts of structures. Moreover, as the input photogrammetric \glspl{gl:DSM} contain noise and many outliers, they propagate along the height image reconstruction and influence the results, as indicated by the dark blue areas in \cref{fig:test_DSM2LOD2GEOKOLref_wthTANH_1,fig:test_OandDSM2LODGEOKOLref_1}, and \cref{fig:DSM2LOD2GEOKOLref,fig:test_O3andDSM2LODGEOKOLref_wnet_2}. On the other hand, the proposed \HybridcGANdot\space network was able to not only eliminate those artifacts, but also to reconstruct the complete building structures at any single detail. Besides, although the building rooftops seem to be entirely flat in the ground truth data (\cf \cref{fig:GT_1,fig:GT_2})---which is not the case in reality---, such cases do not confuse the model during the training phase and make it capable to preserve detailed 3D information from input photogrammetric \gls{gl:DSM}. Those observations prove that the introduced \HybridcGANdot\space architecture may successfully blend together the spectral and height information. The earlier combination of both modalities forces the network to accommodate the information even better. In order to evaluate the generated elevation models quantitatively, we utilized error metrics commonly used in the relevant literature~\cite{hohle2009accuracy,zhang2014geostatistical,elaksher2010refinement,hobi2012accuracy}, namely, the \gls{gl:RMSE} \begin{align} \ensuremath{\varepsilon_\text{\acrshort{gl:RMSE}}}\xspace(\V{h},\hat{\V{h}}) &= \sqrt{\frac{1}{n}\sum\limits_{j=1}^n(\hat{h}_j - h_j)^2}, \intertext{the \gls{gl:NMAD}} \ensuremath{\varepsilon_\text{\acrshort{gl:NMAD}}}\xspace(\V{h},\hat{\V{h}}) &= 1.4826 \cdot \underset{j}{\operatorname{median}} (|\Delta h_j - m_{\Delta \V{h}}|), \intertext{and the \gls{gl:MAE}} \ensuremath{\varepsilon_\text{\acrshort{gl:MAE}}}\xspace(\V{h},\hat{\V{h}}) &= \frac{1}{n}\sum\limits_{j=1}^n|\hat{h}_j - h_j|, \end{align} where $\V{h} = (h_j)_j$ and $\hat{\V{h}} = (\hat{h}_j)_j, 1 \leq j \leq n,$ denote the actually observed and the predicted heights, respectively, height errors are defined as $\Delta h_j$, and the median error is $m_{\Delta \V{h}}$. The constant 1.4826, included in the \gls{gl:NMAD} metric, is comparable to the standard deviation if the data errors are distributed normally. This estimator can be considered more robust to outliers in the dataset~\cite{hohle2009accuracy}. To exclude the influence of time acquisition difference between the photogrammetric \glspl{gl:DSM} and the \gls{gl:CityGML} data model---carrying the risk of absence or the appearance of new buildings---, we manually checked the evaluation regions in this regard and carried out evaluation on regions showing buildings in both the photogrammetric \gls{gl:DSM} as well as in the reference \gls{gl:LoD}2-\gls{gl:DSM}. The obtained results for the three test area samples are presented in \cref{tab:table1,tab:table2,tab:table3}. In comparison to the other methods, the \glspl{gl:DSM} created by the single-stream model~\cite{bittner2018dsm} showed inferior results in terms of $\varepsilon_\text{\acrshort{gl:RMSE}}$ for all three areas. As we have already pointed out before in \cref{fig:test_DSM2LOD2GEOKOLref_width_320_height_320}, the model was not able to reconstruct some buildings at all or only partially reconstructed them, exemplary highlighted in \cref{fig:test_DSM2LOD2GEOKOLref_wthTANH_1,fig:DSM2LOD2GEOKOLref}. \begin{table} \caption{% Quantitative results for \gls{gl:RMSE}, \gls{gl:NMAD}, \gls{gl:MAE} metrics evaluated on 17 selected buildings existed on both input photogrammetric \gls{gl:DSM} and ground truth \gls{gl:LoD}2-\gls{gl:DSM} of the first area depicted in \cref{fig:smallBuildings}.% } \label{tab:table1} \centering \begin{tabular}{@{}v{3.75cm}xxx@{}} \toprule \multicolumn{1}{@{}X}{Method} & \multicolumn{3}{X@{}}{Error} \\ \cmidrule(l){2-4} & \multicolumn{1}{X}{\acrshort{gl:RMSE} (\si{\metre})} & \multicolumn{1}{X}{\acrshort{gl:NMAD} (\si{\metre})} & \multicolumn{1}{X@{}}{\acrshort{gl:MAE} (\si{\metre})}\\ \cmidrule(r){1-1} \cmidrule(lr){2-2} \cmidrule(lr){3-3} \cmidrule(l){4-4} \multicolumn{1}{@{}x}{photogrammetric \gls{gl:DSM}} & 1.66 & 1.01 & 1.23 \\ \multicolumn{1}{@{}x}{single-stream \gls{gl:cGAN} \cite{bittner2018dsm}} & 2.28 & 1.09 & 1.86 \\ \multicolumn{1}{@{}x}{\WNetcGANdot\space\cite{Bittner19:new}} & 1.63 & 0.72 & 1.22 \\ \addlinespace \multicolumn{1}{@{}x}{\HybridcGANdot\space (ours)} & \textbf{1.52} & \textbf{0.62} & \textbf{0.96} \\ \bottomrule \end{tabular} \end{table} \begin{table} \caption{% Quantitative results for \gls{gl:RMSE}, \gls{gl:NMAD}, \gls{gl:MAE} metrics evaluated on 7 selected buildings existed on both input photogrammetric \gls{gl:DSM} and ground truth \gls{gl:LoD}2-\gls{gl:DSM} of the first area depicted in \cref{fig:Area1}. } \label{tab:table2} \centering \begin{tabular}{@{}v{3.75cm}xxx@{}} \toprule \multicolumn{1}{@{}X}{Method} & \multicolumn{3}{X@{}}{Error} \\ \cmidrule(l){2-4} & \multicolumn{1}{X}{\acrshort{gl:RMSE} (\si{\metre})} & \multicolumn{1}{X}{\acrshort{gl:NMAD} (\si{\metre})} & \multicolumn{1}{X@{}}{\acrshort{gl:MAE} (\si{\metre})}\\ \cmidrule(r){1-1} \cmidrule(lr){2-2} \cmidrule(lr){3-3} \cmidrule(l){4-4} \multicolumn{1}{@{}x}{photogrammetric \gls{gl:DSM}} & 2.72 & \textbf{1.09} & \textbf{1.57}\\ \multicolumn{1}{@{}x}{single-stream \gls{gl:cGAN} \cite{bittner2018dsm}} & 4.13 & 1.88 & 2.68 \\ \multicolumn{1}{@{}x}{\WNetcGANdot\space\cite{Bittner19:new}} & 3.89 & 2.03 & 2.64 \\ \addlinespace \multicolumn{1}{@{}x}{\HybridcGANdot\space (ours)} & \textbf{2.64} & 1.34 & 1.69 \\ \bottomrule \end{tabular} \end{table} \begin{table} \caption{% Quantitative results for \gls{gl:RMSE}, \gls{gl:NMAD}, \gls{gl:MAE} metrics evaluated on 4 selected buildings existed on both input photogrammetric \gls{gl:DSM} and ground truth \gls{gl:LoD}2-\gls{gl:DSM} of the first area depicted in \cref{fig:Area2}. } \label{tab:table3} \centering \begin{tabular}{@{}v{3.75cm}xxx@{}} \toprule \multicolumn{1}{@{}X}{Method} & \multicolumn{3}{X@{}}{Error} \\ \cmidrule(l){2-4} & \multicolumn{1}{X}{\acrshort{gl:RMSE} (\si{\metre})} & \multicolumn{1}{X}{\acrshort{gl:NMAD} (\si{\metre})} & \multicolumn{1}{X@{}}{\acrshort{gl:MAE} (\si{\metre})}\\ \cmidrule(r){1-1} \cmidrule(lr){2-2} \cmidrule(lr){3-3} \cmidrule(l){4-4} \multicolumn{1}{@{}x}{photogrammetric \gls{gl:DSM}} & 2.19 & 0.62 & \textbf{1.12}\\ \multicolumn{1}{@{}x}{single-stream \gls{gl:cGAN} \cite{bittner2018dsm}} & 3.38 & \textbf{0.45} & 2.99 \\ \multicolumn{1}{@{}x}{\WNetcGANdot\space\cite{Bittner19:new}} & 3.16 & 1.15 & 2.02 \\ \addlinespace \multicolumn{1}{@{}x}{\HybridcGANdot\space (ours)} & \textbf{1.91} & 0.56 & 1.22 \\ \bottomrule \end{tabular} \end{table} With the intensity information integrated into the learning process, the \gls{gl:RMSE} error \ensuremath{\varepsilon_\text{\acrshort{gl:RMSE}}}\xspace decreased and, in case of our proposed \HybridcGANdot\space, achieved the lowest value, even smaller than for the input photogrammetric \gls{gl:DSM}. This observation provides evidence that the proposed model improves the noisy and inaccurate photogrammetric \glspl{gl:DSM} to a high level of details. Considering the other two metrics, \HybridcGANdot\space also outperformed the competing models, except for the third test area. The single-stream \gls{gl:DSM}~\cite{bittner2018dsm} achieved the lowest \gls{gl:NMAD} error with $\ensuremath{\varepsilon_\text{\acrshort{gl:NMAD}}}\xspace=0.45$. This seems reasonable, as the buildings show flat roofs in the ground truth, which is not the case for neither the input photogrammetric \gls{gl:DSM}, nor for the \glspl{gl:DSM} generated by the models with spectral information integrated. As the \gls{gl:NMAD} metric is sensible to outliers, it shows higher values for the results with more detailed roofs. Our results demonstrate that deep learning models visually produce fairly reasonable reconstructed \glspl{gl:DSM}. However, the used \gls{gl:RMSE}, \gls{gl:NMAD}, \gls{gl:MAE} metrics do not give good enough insight into the depth estimation quality, as they mainly consider the overall accuracy by reporting global statistics of depth residuals. Moreover, the available ground truth data with only sufficient quality also influences evaluation procedure. \glsresetall \section{Conclusion} We presented a methodology for automatic building shape refinement from low-quality \glspl{gl:DSM} to the \gls{gl:LoD} 2 from multiple spaceborne remote sensing data on the basis of \glspl{gl:cGAN}. The network automatically combines the advantages of \gls{gl:PAN} imagery and photogrammetric \gls{gl:DSM}, while complementing their individual drawbacks, and, from obtained results, shows the potential of generating \glspl{gl:DSM} with completed not only residential but also industrial building structures. Moreover, the generated roof surfaces are smoother and more planar, giving evidence of the positive influence of the auxiliary \emph{normal vector loss} function. Besides, a 3D visualization of the generated elevation models illustrates the realistic appearance of the buildings and their strong resemblance to the ground truth. \printbibliography \end{document}
{'timestamp': '2019-04-23T02:27:58', 'yymm': '1904', 'arxiv_id': '1904.09935', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.09935'}
arxiv
\section{Bold Hearts} \label{sec:boldhearts} The team Bold Hearts has been founded as part of the Adaptive Systems Research Group at the University of Hertfordshire. The team started participating in RoboCup in 2003 in the simulation leagues and made a transition to the Humanoid KidSize League in 2013. We hope to participate in that league in 2019 for the seventh year in a row. The following are the main achievements of team Bold Hearts in the Humanoid League over the last few years. \begin{itemize} \item Quarter-finalist RoboCup World Championchip 2017 (1st in group) \item 2nd round RoboCup World Championship 2016 (1st in group) \item 1st Iran Open 2016 \item 2nd round RoboCup World Championship 2015 (1st in group) \item 3rd German Open 2015 \item 2nd RoboCup World Championship 2014 \end{itemize} \section{Introducing New Members Gradually} Recruiting new members is a crucial task, as with most RoboCup teams. It is important for the team's overall success to continuously recruit new members and transfer knowledge to the new generations. We have always kept a well maintained wiki for new members to read up on the given infrastructure. Additionally, we have made it easier to set up the code by using tools such as Ansible and Docker\footnote{\url{https://www.ansible.com/} and \url{https://www.docker.com/}}. However, there has been a lack of students with C++ knowledge. This is the language of choice for our custom framework, which is presented in previous team description papers~\cite{tdp-18}. Additionally, robotics itself is very complex, therefore working with real robots without pre-knowledge is a challenge in itself. We decided to tackle this issue on different levels. Firstly, we plan on moving to a framework which allows modular development in Python and C++, see section~\ref{sec:middleware} for more details. Students then need to understand the level of complexity of robotic tasks. Some known contributors to the RoboCup community approached this issue gradually themselves, by firstly participating in, e.g., simulation league and only later entering the hardware league. We want to emulate this locally, by offering students a very simple and accessible idea of RoboCup with a simple, standalone 2D simulator called PythoCup. It is written in Python and was firstly developed for the Humanoid soccer school 2013 by our team. It has now been adapted for the use of PyGame and is published on GitLab\footnote{\url{https://gitlab.com/boldhearts/pythocup}}. \begin{figure}[ht] \centering \includegraphics[width=.49\textwidth]{figs/Pythocup-2player-1} \includegraphics[width=.49\textwidth]{figs/Pythocup-2player-3} \caption{Two scenes of a PythoCup game. The left screenshot shows the moment before the game starts. The right screenshot shows the blue player attacking the goal of the red player.} \label{fig:pythocup_screenshot} \end{figure}% We expect several benefits for new students/participants and existing team members. Setting up PythoCup is simple and manipulating the behaviour of the robots can be achieved in a few steps, yet it offers the possibility to achieve already quite sophisticated agents. We hope that this will ease the process for new members joining the team. Additionally, we expect that some important robotic related problems will derive naturally and therefore we hope that new members get a glimpse of RoboCup related problems quickly. Another benefit is that those who have learnt these skills can then help introduce new members, creating a pyramid of experience. After mastering PythoCup, the next step will be to allow students to set up our code for the humanoid robots. They will be given an isolated modular problem to solve. Testing will be done in the simulator (e.g.~Gazebo) and already small changes will yield different, visible output. \section{Robotic Hardware and Design} \begin{figure}[htb] \centering \includegraphics[width=.93\textwidth]{figs/boldbot} \caption{The BoldBot robot in its second version. It is incrementally developed with a Darwin-OP as its base. The torso has been scaled up to fit an Odroid-XU4, the new main processing unit. The shin, thigh, arm, head bracket and the foot plate have been redesigned, scaled up and 3D~printed.} \label{fig:boldbot} \end{figure} As described in our last years' team description paper, we started with incrementally developing a new robot platform based on the Darwin-OP~\cite{tdp-18}. The main processing unit has been replaced with an Odroid-XU4. Shins, legs, foot plates, head bracket and arms have been redesigned and 3D printed. Figure~\ref{fig:boldbot} shows one of our robots with its newly designed parts. At the RoboCup 2018 competition, we participated with 4 robots of that configuration. The robots were equipped with four different webcam models: Logitech C910, C920, C920c and C930e. For this year's configuration, we decided on using Logitech C920 Pro HD webcam for all robots. For the self-printed limbs, we mainly used PLA and ABS and a range of different printers. PLA seems to be most sturdy and well suited for our needs. One of our biggest challenges during the RoboCup 2018 competition was mounting the printed parts to the servos. The plastic parts had to resist a lot of stress on a small area of contact of the screws. When the plastic parts broke, they usually did so around the horn mounting area. To help address this, we use the outer horn disc as additional support for the motors, as seen in Fig.~\ref{fig:redesign}. This gives greater support in 180 degrees (towards the model) where the parts are typically stressed. Despite being thinner, the parts are stronger as the force is spread more evenly across the model. In the near future, we plan to investigate the use of metal inserts to further increase the strength of printed parts in the form of: small washers per screw, a larger washer inserted into the model and an embedded nut per screw. \begin{figure}[ht] \centering \includegraphics[width=0.3565\textwidth]{figs/thigh-original} \includegraphics[width=0.3565\textwidth]{figs/thigh-improve} \includegraphics[width=0.271\textwidth]{figs/dynamixel-models} \caption{Depicted is the design of the thigh of the BoldBot model used in RoboCup 2018 (left).We redesigned this part with some additional support structure (middle). We will investigate whether the support for the horn and bearing will help to reduce the stress on the screws. The picture on the right shows the design of Dynamixel servos. These models can be used in OpenSCAD for designing limbs.} \label{fig:redesign} \end{figure} For all our designs we utilise OpenSCAD, a tool which allows for parametric designs, enabling us to adapt the length of a limb without redesign. Like the Darwin, all BoldBot servos are Dynamixel MX-28. It turned out that, with increasing the robot size, these servos are already too weak for the robot to stand up or to locomote. We therefore also parametrised Dynamixel servos for the models MX-28, MX-64 and MX-106\footnote{Open-sourced here: \url{https://gitlab.com/boldhearts/dynamixel-scad}} with OpenSCAD. This enables us to redesign limbs with reference to the used model more easily. \section{Vision} \label{sec:vision} In previous years, our object recognition methods were based on a lookup-table~(LUT) approach. The LUT was created based on thresholds in HSV colour space, that were manually tweaked for each separate competition and/or field. Besides being time consuming during setup, the method was no longer very applicable in the modern non-colour-coded RoboCup scenario. The hardware upgrade that our robots received allows the application of more advanced computer vision methods, however it is not yet feasible to run some of the latest large-scale deep learning models. We managed to scale such models down to be able to run fast enough on our mobile hardware with sufficient accuracy, the full details of which were presented at the RoboCup 2018 symposium~\cite{DijkScheunemann-18}. Here we will summarise this work. Rather than using a direct object recognition approach, similar to the popular YOLO and RCNN family of CNNs, which are too complex to run or need a highly optimised domain-specific candidate selection process, we use the more general method of semantic segmentation. Besides being able to process a full resolution frame faster, without requiring specific domain knowledge, this method has the additional benefit of a single network being able to handle multiple image resolutions without retraining. Finally, the output is a per-pixel labelling of the image, equivalent to the output of traditional LUT based methods, so it fits seamlessly into our existing pipeline. The neural networks that we use have an ecoder-decoder structure similar to other, large-scale, segmentation networks in the literature, such as U-Net~\cite{ronneberger2015u} and SegNet~\cite{badrinarayanan2017segnet}. In such networks, a first series of convolution layers encode the input into successively lower resolution but higher dimensional feature maps, after which a second series of layers decode these maps into a full-resolution pixelwise classification. This architecture is shown in Fig.~\ref{fig:cnn}. \begin{figure} \noindent\resizebox{\textwidth}{!}{ \begin{tikzpicture}[baseline = (current bounding box.west)] \newcommand{\networkLayer}[6]{ \def\a{#1} \def0.02{0.02} \def\c{#2} \def\t{#3} \ifthenelse {\equal{#6} {}} {\def\y{0}} {\def\y{#6}} \draw[line width=0.25mm](\c+\t,0,0) -- (\c+\t,\a,0) -- (\t,\a,0); \draw[line width=0.25mm](\t,0,\a) -- (\c+\t,0,\a) node[midway,below] {#5} -- (\c+\t,\a,\a) -- (\t,\a,\a) -- (\t,0,\a); \draw[line width=0.25mm](\c+\t,0,0) -- (\c+\t,0,\a); \draw[line width=0.25mm](\c+\t,\a,0) -- (\c+\t,\a,\a); \draw[line width=0.25mm](\t,\a,0) -- (\t,\a,\a); \filldraw[#4] (\t+0.02,0.02,\a) -- (\c+\t-0.02,0.02,\a) -- (\c+\t-0.02,\a-0.02,\a) -- (\t+0.02,\a-0.02,\a) -- (\t+0.02,0.02,\a); \filldraw[#4] (\t+0.02,\a,\a-0.02) -- (\c+\t-0.02,\a,\a-0.02) -- (\c+\t-0.02,\a,0.02) -- (\t+0.02,\a,0.02); \ifthenelse {\equal{#4} {}} {} {\filldraw[#4] (\c+\t,0.02,\a-0.02) -- (\c+\t,0.02,0.02) -- (\c+\t,\a-0.02,0.02) -- (\c+\t,\a-0.02,\a-0.02);} } \networkLayer{3.0}{0.1}{-0.2}{color=Goldenrod}{}{} \networkLayer{3.0}{0.1}{0.0}{color=SkyBlue}{E1}{} \networkLayer{2.5}{0.1}{0.2}{color=ForestGreen}{}{} \networkLayer{2.5}{0.1}{0.4}{color=Goldenrod}{}{} \networkLayer{2.5}{0.2}{0.8}{color=SkyBlue}{E2}{} \networkLayer{2.0}{0.2}{1.1}{color=ForestGreen}{}{} \networkLayer{2.0}{0.2}{1.4}{color=Goldenrod}{}{} \networkLayer{2.0}{0.4}{1.9}{color=SkyBlue}{E3}{} \networkLayer{1.5}{0.4}{2.4}{color=ForestGreen}{}{} \networkLayer{1.5}{0.4}{2.9}{color=Goldenrod}{}{} \networkLayer{1.5}{0.8}{3.5}{color=SkyBlue}{E4}{} \networkLayer{1.5}{0.8}{4.4}{color=Goldenrod}{}{} \networkLayer{1.5}{0.8}{5.4}{color=SkyBlue}{D1}{} \networkLayer{1.5}{0.8}{6.3}{color=Goldenrod}{}{} \networkLayer{2.0}{0.4}{7.3}{color=Salmon}{}{} \networkLayer{2.0}{0.4}{7.8}{color=SkyBlue}{D2}{} \networkLayer{2.0}{0.4}{8.3}{color=Goldenrod}{}{} \networkLayer{2.5}{0.2}{8.9}{color=Salmon}{}{} \networkLayer{2.5}{0.2}{9.2}{color=SkyBlue}{D3}{} \networkLayer{2.5}{0.2}{9.5}{color=Goldenrod}{}{} \networkLayer{3.0}{0.1}{9.9}{color=Salmon}{}{} \networkLayer{3.0}{0.05}{10.1}{color=SkyBlue}{D4}{} \networkLayer{3.0}{0.05}{10.7}{color=Violet!50}{O}{} \end{tikzpicture}\hspace{2ex} \begin{tikzpicture}[baseline = (current bounding box.east)] \matrix [draw=black!33] at (current bounding box.east) { \node [shape=rectangle, fill=SkyBlue, label=right:SepConv + ReLU] {}; \\ \node [shape=rectangle, fill=ForestGreen, label=right:MaxPool] {}; \\ \node [shape=rectangle, fill=Goldenrod, label=right:BatchNorm] {}; \\ \node [shape=rectangle, fill=Salmon, label=right:UpSample] {}; \\ \node [shape=rectangle, fill=Violet!50, label=right:SoftMax] {}; \\ }; \end{tikzpicture} } \caption{The architecture of the network consists of a series of fully convolutonal encoding (E1--E4) and decoding (D1--D4) steps. A pixelwise softmax output layer provides the final classifications.}\label{fig:cnn} \end{figure} The main techniques that make it possible to process frames at full resolution and high rate are: \begin{description} \item[Depthwise Separable Convolution] By breaking up a full 3D convolution operation into separate per-layer 2D convolutions plus a 1x1 depthwise convolution, the number of computations per layer is reduced significantly, without a great loss of performance. \item[Stride] Using a stride of 2 reduces the number of computations in a convolution layer by 4, again without great loss (and sometimes even slight increase) of performance. \end{description} Figure~\ref{fig:exampleimages} shows typical results of these networks. At the RoboCup 2018 competition we were able to train and run such networks by collecting and labelling imagery at location (using the Bit-Bots' Imagetagger\footnote{\url{https://imagetagger.bit-bots.de/}}). Training of the network took a few hours on a laptop with a GeForce GT 750M GPU. \begin{figure} \centering \scriptsize \begin{tabular}{@{}c@{}c@{}c@{\hspace{1em}}c@{}c@{}c@{}} \includegraphics[width=.16\textwidth]{figs/ball-60-rgb} &% \includegraphics[width=.16\textwidth]{figs/ball-5-rgb} &% \includegraphics[width=.16\textwidth]{figs/ball-49-rgb} &% \includegraphics[width=.16\textwidth]{figs/goal-60-rgb} &% \includegraphics[width=.16\textwidth]{figs/goal-62-rgb} &% \includegraphics[width=.16\textwidth]{figs/goal-75-rgb} \\[-5pt]% \includegraphics[width=.16\textwidth]{figs/ball-60-target} &% \includegraphics[width=.16\textwidth]{figs/ball-5-target} &% \includegraphics[width=.16\textwidth]{figs/ball-49-target} &% \includegraphics[width=.16\textwidth]{figs/goal-60-target} &% \includegraphics[width=.16\textwidth]{figs/goal-62-target} &% \includegraphics[width=.16\textwidth]{figs/goal-75-target} \\[-5pt]% \includegraphics[width=.16\textwidth]{figs/ball-60-res-l4f5m2s1} &% \includegraphics[width=.16\textwidth]{figs/ball-5-res-l4f5m2s1} &% \includegraphics[width=.16\textwidth]{figs/ball-49-res-l4f5m2s1} &% \includegraphics[width=.16\textwidth]{figs/goal-60-res-l4f5m2s1} &% \includegraphics[width=.16\textwidth]{figs/goal-62-res-l4f5m2s1} &% \includegraphics[width=.16\textwidth]{figs/goal-75-res-l4f5m2s1} \\ \end{tabular} \caption{Examples of input (top), target (middle) and segmentation outputs (bottom) of the segmentation network. Left: ball detection, right: goal post detection.} \label{fig:exampleimages} \end{figure} During development of these methods, several open sets from the Imagetagger were used. Additionally, we have created and released two datasets: one with the bottom of the goalposts annotated to train goal detection and one with ball anotations created and used during the RoboCup 2018 competition in Montreal~(See section~\ref{sec:research_contribution}). \section{Using ROS 2 as Middleware} \label{sec:middleware} From 2013, we have developed and used our own software framework, with all modules created from scratch, except for some that were partly based on the source code originally supplied with the Darwin-OP platform~\cite{DijkNoakesEtAl-14}. Although shown to be capable of performing well, over the years the framework has become more and more complex, and being completely custom it is now difficult for new members to get into it. We have opted to replace the base framework completely, and have reviewed several options: a new framework from scratch again, the NUClear framework\footnote{\url{https://github.com/Fastcode/NUClear}}~\cite{houliston2016nuclear}, ROS 1\footnote{\url{http://www.ros.org/}}, and ROS 2\footnote{\url{https://index.ros.org/doc/ros2/}}. ROS 1 was discarded as an option, as we have learned throughout the years that efficiency of the framework is crucial for our limited hardware, and seeing that multi-robot teams, small platforms and real-time systems are explicit use cases that ROS 1 is not ideal for that sparked the development of ROS 2. NUClear does offer a very efficient, modular platform, that has been proven in the RoboCup scenario. However, ROS 2 is currently in a state that offers most of the same benefits, while having much wider support, including from large entities from the industry, such as Intel and Amazon. With an eye on the future and the transferability of skills learned by our (student) members outside/after participation in the team, we opted to use ROS 2. ROS 2 is based on Data Distribution Services~(DDS) for real-time systems. This connectivity framework aims for enabling scalability and real-time data exchange using a publisher-subscriber architecture. ROS 2 sits on top of that, providing standard messages and tools to adapt DDS for robotic needs. Publishers and subscribers can be written in C++ or Python. \begin{figure} \centering \includegraphics[width=.75\textwidth]{figs/rviz2} \caption{Screenshot of RViz2, showing camera feed and robot model built from joint states read from subcontroller.} \label{fig:rviz2} \end{figure} Our main efforts to move to use ROS 2 as our middleware consist of: \begin{description} \item[Creating hardware specific interfaces] Our robots are based on the Robotis CM-730 sub-controller. Robotis has released ROS 1 packages for their products, but at the moment there is no ROS 2 effort. We have created and are finalising a ROS 2 driver for the CM-730, which we will release in the near future. Figure~\ref{fig:rviz2}~(right) shows the result of the robot model built using the output of this driver. \item[Porting ROS 1 packages] Only a subset of existing ROS packages has been ported to ROS 2. We are porting several missing packages, such as a USB camera driver, which we will contribute upstream (Sec.~\ref{sec:research_contribution}). Figure~\ref{fig:rviz2}~(left) shows the output of the camera driver. \item[Porting our modules] Once all hardware interfaces are in place, we can port our existing modules over to the new platform. \end{description} \section{Research and Open-Source Contributions 2018} \label{sec:research_contribution} We presented our recent vision research at the RoboCup symposium 2018, it was ``Deep Learning for Semantic Segmentation on Minimal Hardware''~\cite{DijkScheunemann-18} and it is briefly described in section~\ref{sec:vision}. We also published the related annotated image sets created and used during the RoboCup 2018 competition in Montreal: \begin{itemize} \item goal-posts: \url{https://imagetagger.bit-bots.de/images/imageset/233} \item ball: \url{https://imagetagger.bit-bots.de/images/imageset/12/} \end{itemize}% The following is a list of open-source contributions: \begin{itemize} \item SCAD models for Dynamixel's MX-28, MX-64 and MX-106 servos, horns and bearings: \url{https://gitlab.com/boldhearts/dynamixel-scad} \item porting the ROS 1 usb\_cam package to ROS 2: \url{https://github.com/ros-drivers/usb_cam/pull/106} \item a simple, standalone 2D~simulator: \url{http://gitlab.com/boldhearts/pythocup} \end{itemize} \section{Acknowledgements} \label{sec:acknowledgements} Team Bold Hearts would like to acknowledge the crucial open source projects used to develop our team: ROS 2, OpenSCAD, GitLab, TensorFlow and Bit-Bots Imagetagger\footnote{\url{https://www.openscad.org}, \url{https://gitlab.com/}, \url{https://www.tensorflow.org/}, \url{https://imagetagger.bit-bots.de}}.
{'timestamp': '2019-04-24T02:02:57', 'yymm': '1904', 'arxiv_id': '1904.10066', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.10066'}
arxiv
\section{Introduction} Deep learning techniques have successfully tackled various computer vision problems such as object detection~\cite{he2017mask,ren2015faster,fan2019shifting,liu2016ssd,fan2018salient,zhao2019contrast}, image, video and 3d shape generation~\cite{kingma2013auto, goodfellow2014generative, xie2016cooperative,xie2016theory,reed2016generative, xie2017synthesizing, xie2018learning, zhao2018learning, tian2018cr}, pose estimation~\cite{peng2018jointly,tang2019adatransform,zhao2019semantic,tang2018quantized,tang2018cu}, object recognition~\cite{krizhevsky2012imagenet, szegedy2015going, he2016deep}, etc. Especially, these advanced deep learning methods equip the machine with the comparable ability of object recognition to human beings when abundant labeled training samples are provided. However, this ability will decrease dramatically for classes that are insufficiently represented or even not present in the training data, thus increasing the difficulty of real-world applications due to the costly data collection and annotation effort. This limitation attracts the intense interest of researchers in zero-shot learning (ZSL). \begin{figure}[t] \centering \includegraphics[width=1.0\columnwidth]{tenser_v5.png} \caption{Demonstration of the feature-to-feature translator for generative zero-shot learning. Training (blue flow): given the class-level semantic features $C$ and the observed visual features $X$, (i) the latent factors $Z$ are inferred by MCMC and (ii) the weights $\theta$ of the translator are updated by the gradient ascent for maximum likelihood. Translation (black flow): once the translator is learned, arbitrary number of synthetic visual features can be generated for unseen classes by translating the unseen class semantic features along with $Z$ randomly sampled from Gaussian distribution. The generated samples for unseen classes are useful for zero-shot learning.} \label{fig:intro} \vspace{-2em} \end{figure} ZSL aims to recognize novel classes where no training data is available for these classes. The key to make ZSL work is to use the semantic description of classes as the bridge to connect the seen classes and unseen classes. Recently, generative ZSL approaches ~\cite{bucher2017generating, zhu2018generative,xian2018feature,felix2018multi, wang2017zero, verma2018generalized} have emerged as a new trend of ZSL strategy by exploiting the successful generative models, e.g., variational autoencoders (VAE) ~\cite{kingma2013auto, rezende2014stochastic}, generative adversarial networks (GAN)~\cite{goodfellow2014generative, mirza2014conditional}, etc, to learn mappings from class-level semantic features (e.g., attributes or description embeddings) to visual features. The synthetic visual features for unseen classes through well-trained generative models establish the visual description of unseen classes and make the conventional supervised classification applicable. The quality of generative ZSL approaches mainly depends on how well the generative model can emulate the data distribution. GAN-based methods~\cite{zhu2018generative,xian2018feature,felix2018multi} employ the conditional generator network which maps class-level semantic features along with Gaussian white noise as latent factors to visual features. The conditional generator is trained in an adversarial manner where a well-designed discriminator network is recruited to play a minimax game with the conditional generator. The adversarial training strategy gets around the intractable inference of latent factors in training; however, the imbalance between the discriminator and the generator would lead to non-convergence and mode collapse issues. VAE-based methods~\cite{wang2017zero,verma2018generalized} associate the conditional generator network with an additional encoder that approximates the posterior distribution for the purpose of inference of latent factors, and train both models by maximizing the variational lower bound. In this paper, we will show that neither of these assisting networks is necessary for training the conditional generator. In our framework of generative ZSL, we adopt a conditional generator as a feature-to-feature translator network that translates the class-level semantic features along with the instance-level latent factors to visual features as shown in Figure~\ref{fig:intro}. However, different from GAN and VAE-based methods, we resort to a theoretically more accurate estimator, maximum likelihood estimation (MLE) with EM-like strategy~\cite{dempster1977maximum}, to train the network, without the requirement of auxiliary networks for assistance. The hard nut to crack in training latent variable models by MLE is the intractable posterior distribution that is required for computing the gradient of the observed-data log-likelihood. In the proposed framework, we adopt Markov chain Monte Carlo (MCMC), such as Langevin dynamics ~\cite{welling2011bayesian, neal2011mcmc}, for computing the posterior distribution. We show that the maximum likelihood algorithm involves the computation of the gradient of observed-data log-likelihood with respect to model parameters and the gradient with respect to latent factors, both of which can be efficiently computed by back-propagation. Specifically, the proposed translator is learned by alternating back-propagation (ABP) algorithm, which iterates the following two steps: (i) \emph{inferential back-propagation}: for each training example, inferring the continuous latent factors by sampling from the current learned posterior distribution via Langevin dynamics, where the gradient of the log joint density can be calculated by back-propagation, (ii) \emph{learning back-propagation}: updating the model parameters given the inferred latent factors and the training examples by gradient ascent, where the gradient of the log-likelihood with respect to the model parameters can again be calculated by back-propagation. The ABP algorithm was originally proposed for training unconditional generator networks \cite{han2017alternating, xie2019learning}. In this paper, we generalize ABP to learning conditional generator network for feature-to-feature translation, where the class-level semantic features play the role of condition. It is worth mentioning that the proposed model is capable of learning from incomplete training examples, where visual features are partially corrupted or inaccessible due to occlusion in image space. Specifically, our model can learn from incomplete data by making latent factors only explain the visible parts of the visual features conditioned on class-level semantic features, while GAN or VAE-based methods can hardly deal with this situation. Our contributions can be summarized as follows: (1) We propose a feature-to-feature translator for generative ZSL, where we learn a mapping from class-level semantic features, along with instance-level latent factors following Gaussian white noise distribution, to visual features. (2) We propose to learn the translator via alternating back-propagation (ABP) algorithm for maximum likelihood, without relying on other assisting networks, which makes our framework more statistically rigorous and elegant. (3) We show that the proposed framework can learn from incomplete training examples where visual features are partially visible due to corruption or occlusion in image space. (4) Comprehensive experiments conducted on various ZSL tasks show the state-of-the-art performance of our framework, and a thorough analysis of the model demonstrates the superiority of the proposed framework in different aspects. \section{Related Work} \textbf{X-to-Y Translation}. We are not the first to apply conditional generators to learn X-to-Y mapping. A text-to-image translation is proposed for image synthesis from text description~\cite{reed2016generative}. Zhu \emph{et al}~\cite{zhu2017unpaired} has studied image-to-image translation problem for different types of image processing tasks, which include synthesizing photos from label maps or edge maps and generating color images from their grey-scaled versions. Recently, video-to-video translation problem has been tackled by learning a mapping function from an input source video (e.g., a sequence of semantic segmentation masks) to a target realistic video~\cite{wang2018vid2vid}. Our work learns a feature-to-feature mapping for ZSL. Additionally, all other works mentioned above are based on the framework of GANs, which means that well-designed discriminator networks need to be resorted to in the training stage. Our framework differs in that it is trained by an alternating back-propagation algorithm without incorporating any extra assisting networks. This makes our framework considerably simpler and computationally more efficient than those based on GANs. \textbf{Generative Models}. Our model is essentially a conditional latent variable model. The alternating back-propagation (ABP) training method for our model is related to variational inference (e.g., VAE) and adversarial learning (e.g., GAN), both of which require an extra assisting network with a separate set of learning parameters to avoid the explaining-away inference of latent variables in the model. Unlike VAE and GAN, ABP does not involve an auxiliary network and performs explicit explaining-away inference by directly sampling from the posterior distribution via MCMC, such as Langevin dynamics, which is powered by back-propagation. Our model trained by ABP is much simpler, more natural and statistically rigorous than those trained by adversarial learning and variational inference schemes. ABP has been used to train general generators~\cite{han2017alternating} and deformable generators \cite{xing2018deformable} for image patterns, as well as dynamic generators~\cite{xie2019learning} for video patterns. Our paper is a generalization of \cite{han2017alternating, xie2019learning} by applying ABP to train a conditional version of the generator model for feature-to-feature translation. The generative ConvNet \cite{xie2016theory} and the Wasserstein INN \cite{lee2018wasserstein} are two one-piece models that learn energy-based generative models for data generation. Both \cite{xie2016theory} and \cite{lee2018wasserstein} generate data via iterative MCMC sampling, while our model generates data via direct ancestral sampling, which is much more efficient. \textbf{Zero-Shot Learning}. Several pioneering works for ZSL ~\cite{lampert2009learning, lampert2014attribute} make use of class attributes as intermediate information to classifiy images for unseen classes. Some ZSL methods are based on the bilinear compatibility function between the visual and semantic features, which can be learned by using (a) the ranking loss (e.g., ALE~\cite{akata2016label} and DeViSE~\cite{frome2013devise}), (b) the structural SVM loss ~\cite{akata2015evaluation} or (c) the ridge regression loss (e.g., ESZSL~\cite{romera2015embarrassingly} and PTZSL~\cite{Elhosein_2017_CVPR}). To enhance the expressive power of the models, several ZSL approaches~\cite{xian2016latent,zhang2017learning,li2019rethinking,li2019on,zhu2019learning} learn non-linear multimodal embedding. Taking advantage of the generative models in data generation, several methods~\cite{zhu2018generative,felix2018multi, wen2016discriminative, verma2018generalized, bucher2017generating,wang2017zero} resort to generating visual features from unseen classes for ZSL. Both GAZSL~\cite{zhu2018generative} and FGZSL~\cite{wen2016discriminative} pair a Wasserstein GAN~\cite{arjovsky2017wasserstein,gulrajani2017improved} with a classification loss as regularization to increase the inter-class discrimination of synthetic features. MCGZSL~\cite{felix2018multi} adopts cycle consistency loss ~\cite{zhu2017unpaired} to regularize the generator for ZSL . \cite{wang2017zero, verma2018generalized} employ conditional VAEs~\cite{sohn2015learning} framework to learn feature generator. Our model also learns to generate visual features from unseen classes by a conditional generator, however, different from the generative ZSL methods mentioned above, our model is trained by alternating back-propagation, without the need of assisting models for training. \section{Feature-to-Feature Translator}\label{sec:learning} \subsection{Conditional Latent Variable Model for Feature-to-Feature Translation} Let $S=\{(X_i, C_i),i=1,...,n\}$ be the training data of the seen classes, where $X_i \in \mathcal{X}^{D}$ is the $D$-dimensional visual features (e.g., CNN features extracted from images) for the $i$-th image and $C_i \in \mathcal{C}^K$ is its $K$-dimensional class-level semantic features (e.g., class attribute embedding). Because one class usually corresponds to many image examples, we aim at finding a one-to-many class-to-instance feature generator. Specifically, we try to learn a mapping $g: \mathcal{C}^{K} \times \mathcal{Z}^{d} \rightarrow \mathcal{X}^{D}$ that seeks to explain the visual features $X_i$ extracted from each image by its corresponding class-level features $C_i$ and a $d$-dimensional vector of latent factors $Z_i \in \mathcal{Z}^{d}$ that accounts for instance variations. We assume $Z_i$ is sampled from a Gaussian prior distribution $N(0, I_d)$, where $I_d$ stands for the $d$-dimensional identity matrix. Once the generator $g$ learns to generate image features from class features, it can also generate $\widetilde{X}$ from any unseen classes. Formally, the feature-to-feature mapping can be formulated by a conditional latent variable model as follows: \vspace{-0.2em} \begin{equation} \begin{aligned} &Z \sim \mathcal{N}(0, I_d),\\ &X = g_{\theta}(C, Z) + \epsilon, \epsilon \sim \mathcal{N}(0,\sigma^2 I_D),\\ \end{aligned} \label{eq:model1} \end{equation} where $\theta$ contains all the learning parameters in the mapping function $g$, and $\epsilon$ is a $D$-dimensional noise vector following Gaussian distribution. The mapping $g$ can be any non-linear mapping. In this paper we adopt the top-down MLP parameterization of $g$, which is also called the conditional generator network, to map the latent factors $Z$ along with the class features $C$ to the visual features $X$. Generally, the model is defined by a prior distribution of latent factors $Z \sim p(Z)$ and the conditional distribution to generate visual features given the class features and the latent factors, i.e., $[X|Z, C] \sim p_{\theta}(X| Z, C)$. Let $q_{\text{data}}(X|C)$ be the true distribution that generates the training visual features given their associated class features. The goal of learning this model is to minimize the Kullback-Leibler divergence $\text{KL}(q_{\text{data}}(X|C)\Vert p_{\theta}(X|C))$ over $\theta$. \subsection{Learning by Alternating Back-Propagation} \subsubsection{Maximum Likelihood Learning} The maximum likelihood estimation (MLE) of our model $p_{\theta}(X|C)$ is equivalent to minimizing the Kullback-Leibler divergence $\text{KL}(q_{\text{data}}(X|C)\Vert p_{\theta}(X|C))$ over $\theta$. The complete data model is given by \vspace{-0.4em} \begin{equation} \begin{aligned} &\log p_{\theta}(X,Z |C) = \log[p_{\theta}(X|Z, C)p(Z)]\\ &= -\frac{1}{2\sigma^2} \Vert X-g_{\theta}(C,Z) \Vert ^2 -\frac{1}{2} \Vert Z \Vert ^2 + {\rm const}, \end{aligned} \end{equation} where the constant term is independent of $X$, $Z$ and $\theta$. The observed-data model or the log-likelihood is obtained by integrating out the latent factors $Z$: \vspace{-0.4em} \begin{equation} \log p_{\theta}(X|C) = \log \int p_{\theta}(X|Z,C)p(Z)dZ . \end{equation} Suppose we observe the training data $S=\{(X_i, C_i),i=1,...,n\}$, and $[X|C] \sim p_{\theta}(X|C)$, the goal of MLE is to maximize the observed-data log-likelihood: \vspace{-1em} \begin{equation} \begin{aligned} L(\theta)& = \sum_{i=1}^{n} \log p_{\theta}(X_i|C_i).\\ \end{aligned} \label{eq:likelihood} \end{equation} Without loss of generality, we consider one observed pair $(X_i, C_i)$ and omit subscript $i$ for brevity. To maximize the log-likelihood, we adopt gradient ascent strategy. The gradient of the log-likelihood with respect to $\theta$ can be calculated by the following equation: \begin{equation} \begin{aligned} \frac{\partial}{\partial \theta}\log p_{\theta}(X|C) &= \frac{1}{p_{\theta}(X|C)}\frac{\partial}{\partial \theta}p_{\theta}(X|C)\\ &=\mathbb{E}_{Z \sim p_{\theta}(Z|X,C)}\left[ \frac{\partial}{\partial \theta} \log p_{\theta}(X,Z|C)\right]. \end{aligned} \label{eq:gradient} \end{equation} \vspace{-2.1em} \subsubsection{Inferential Back-Popagation} Since the expectation with respect to the posterior distribution $p_{\theta}(Z|X,C)$ in Equation (\ref{eq:gradient}) is analytically intractable, we resort to the average of the MCMC samples to approximate the expectation. Specifically, we employ Langevin dynamics which carries out sampling by iterating: \begin{equation} \begin{aligned} Z_{\tau+1} &= Z_{\tau} + \frac{s^2}{2} \frac{\partial}{\partial Z} \log p_{\theta}(X,Z_{\tau}|C) + sU_\tau,\\ &= Z_{\tau} + sU_{\tau} + \\ &\frac{s^2}{2}\left[ \frac{1}{\sigma^2}(X-g_{\theta}(C,Z_{\tau})) \frac{\partial}{\partial Z}g_{\theta}(C,Z_{\tau})-Z_{\tau}\right], \end{aligned} \label{eq:inference} \end{equation} where $\tau$ denotes the time step for Langevin dynamics, $U_\tau$ is the Gaussian white noise corresponding to the Brownian motion, which is added to prevent the chain from being trapped by local modes, and $s$ is the step size. Because of the high computational cost of MCMC, it is infeasible to generate independent samples from scratch in each learning iteration. In practice, the MCMC transition of latent factors $Z$ in the current iteration starts from the previous updated result of $Z$, which is obtained from the previous learning iteration. We initialize $Z$ with Gaussian white noise at the beginning. Persistent MCMC update with such a warm start scheme is effective and efficient enough to provide fair samples from the posterior distribution. We infer the latent factors $Z_i$ for each observed pair $(X_i, C_i)$ by sampling a single copy of $Z_i$ from $p_{\theta}(Z_i|X_i,C_i)$ via running finite steps of Langevin dynamics starting from the current $Z_i$ (i.e., the warm start). This is a conditional explaining-away inference solving an inverse problem, which is that given the specific visual features of an image and its associated class features, how to obtain its corresponding latent factors. Unlike VAE, our model does not need to recruit an extra network for inference. \subsubsection{Learning Back-Popagation} Once $Z$ is inferred, we learn the model via stochastic gradient algorithm by updating $\theta$ based on the Monte Carlo approximation of the gradient of $L(\theta)$ in Equation~(\ref{eq:gradient}): \vspace{-0.4em} \begin{equation} \begin{aligned} &\theta_{t+1} = \theta_{t} +\gamma_t \frac{\partial}{\partial \theta}L(\theta), \end{aligned} \label{eq:learning1} \end{equation} where $t$ is the time step for the gradient algorithm, $\gamma_t$ is the learning rate, and \begingroup\makeatletter\def\f@size{9.0}\check@mathfonts \def\maketag@@@#1{\hbox{\m@th\large\normalfont#1}}% \begin{equation} \begin{aligned} \frac{\partial}{\partial \theta}L(\theta) &\approx \sum_{i=1}^n \frac{\partial}{\partial \theta} \log p_{\theta}(X_i,Z_i|C_i) \\ &= -\sum_{i=1}^n \frac{\partial}{\partial \theta} \frac{1}{2 \sigma^2} \Vert X_i-g_{\theta}(C_i,Z_i) \Vert ^2 \\ & =\sum_{i=1}^n \frac{1}{\sigma^2}(X_i-g_{\theta}(C_i,Z_i)) \frac{\partial}{\partial \theta} g_{\theta}(C_i,Z_i) . \end{aligned} \label{eq:learning2} \end{equation} \endgroup The Equation (\ref{eq:learning1}) corresponds to a non-linear regression problem, where it seeks to find the $\theta$ to predict visual features $X_i$ by its corresponding observed class features $C_i$ and the inferred latent factors $Z_i$. \subsubsection{Alternating Back-Propagation Algorithm} The key to compute Equation (\ref{eq:inference}) is to calculate $\partial g_{\theta}(C,Z)/ \partial Z$, while the key to compute Equation (\ref{eq:learning2}) is to calculate $\partial g_{\theta}(C,Z)/ \partial \theta$. Both of them can be efficiently computed by back-propagation. Algorithm \ref{alg:abp} describes the details of the learning and sampling algorithm. \begin{algorithm} \caption{Alternating back-propagation procedure for learning feature-to-feature translator.} \label{code:3} \begin{algorithmic}[1] \REQUIRE training samples $\{(X_i, C_i), i=1,...,n\}$, the maximal number of loops $N_{step}$, the number of Langevin steps $l$, the learning rate $\gamma_t$. \ENSURE the learned parameters $\theta$, the inferred latent factors $\{Z_i, i = 1, ..., n\}$. \item[] \STATE Initialize $\theta$ and $Z_i$, for $i = 1, ..., {n}$. \FOR{t = 1,..., $N_{step}$} \STATE {\bf Inferential back-propagation}: For each $i$, run $l$ steps of Langevin dynamics to sample $Z_i \sim p_{\theta}(Z_i|X_i, C_i)$ with warm start, i.e., starting from the current $Z_i$, each step follows equation (\ref{eq:inference}). \STATE {\bf Learning back-propagation}: Update $\theta \leftarrow \theta + \gamma_t {L}'(\theta) $, where ${L}'(\theta)$ is computed according to equation (\ref{eq:learning2}), with learning rate $\gamma_t$. \ENDFOR \end{algorithmic} \label{alg:abp} \end{algorithm} \subsection{Comparison with Variational Inference} Our learning algorithm presented in Algorithm \ref{alg:abp} seeks to minimize $\text{KL}(q_{\text{data}}(X|C) \Vert p_{\theta}(X|C))$, while variational auto-encoder (VAE) changes the objective to \begingroup\makeatletter\def\f@size{11.0}\check@mathfonts \def\maketag@@@#1{\hbox{\m@th\large\normalfont#1}}% \begin{equation*} \begin{aligned} \min_{\theta, \phi} \text{KL}(q_{\text{data}}(X|C)p_{\phi}(Z|X,C)\Vert p(Z|C)p_{\theta}(X|Z,C)) \end{aligned} \label{eq:VAE} \end{equation*} \endgroup by utilizing an extra inference model $p_{\phi}(Z|X,C)$ with parameter $\phi$ to infer latent variable $Z$, where the inference model $p_{\phi}(Z|X,C)$ is an analytically tractable approximation to $p_{\theta}(Z|X,C)$. Compared to the maximum likelihood objective $\text{KL}(q_{\text{data}}(X|C)\Vert p_{\theta}(X|C))$, which is the KL-divergence between the marginal distributions of $X$ conditioned on $C$, while the VAE objective is the KL-divergence between the joint distributions of $(Z,X)$ conditioned on $C$ (i.e., an upper bound of the maximum likelihood objective.) as shown below: \begingroup\makeatletter\def\f@size{9.0}\check@mathfonts \def\maketag@@@#1{\hbox{\m@th\large\normalfont#1}}% \begin{equation*} \begin{aligned} &\text{KL}(q_{\text{data}}(X|C)p_{\phi}(Z|X,C)\Vert p_{\theta}(Z, X|C)) = \\ &\text{KL}(q_{\text{data}}(X|C) \Vert p_{\theta}(X|C)) + \text{KL}( p_{\phi}(Z|X,C) \Vert p_{\theta}(Z|X,C) ). \end{aligned} \label{eq:VAE} \end{equation*} \endgroup The accuracy of variational inference depends on the accuracy of the inference model $p_{\phi}(Z|X,C)$ as an approximation of the true posterior distribution $p_{\theta}(Z|X,C)$. That is, when $\text{KL}( p_{\phi}(Z|X,C) \Vert p_{\theta}(Z|X,C))=0$, the variational inference is equivalent to the maximum likelihood solution. Therefore, our learning algorithm is more natural, straightforward, accurate, and computationally efficient than VAE. \section{Zero-Shot Learning} \subsection{Classification in Zero-Shot Learning} The feature-to-feature translator that maps $[C, Z] \rightarrow X$ can be considered as an explicit implementation of the local linear embedding \cite{roweis2000nonlinear}, where $[C, Z]$ is the embedding of $X$, with disentanglement of class features $C$ and non-class features $Z$. Given any unseen class $C^{u} \in \mathcal{C}^K$, we can generate arbitrarily many visual features for the unseen class by first sampling $Z$ from $\mathcal{N}(0,I_d)$ and then mapping $(C^{u}, Z)$ into $X$ via the learned feature-to-feature translator $\widetilde{X} = g_{\theta}(C^{u}, Z)+\epsilon$. With generated data of unseen classes, the labels of testing examples from unseen classes can be predicted via any conventional supervised classifiers. Here we employ a KNN classifier ($K$=20) for ZSL for its simplicity and a softmax classifier for GZSL as suggested in~\cite{xian2018feature}. \subsection{Learning from Incomplete Visual Features} The inferential back-propagation step performs an explaining-away inference, where the latent factors compete with each other to explain the observed visual features. This is very useful in the scenario where the training visual features are incomplete. In this case, our model is still able to learn from incomplete visual features via alternating back-propagation algorithm. The latent factors can still be obtained by explaining the incomplete observed visual features, and the model parameters can still be updated as before. Taking the features in~\cite{zhu2018generative} as an example, Zhu \emph{et al} train a part detector to localize small semantic parts of birds such as heads and tails, and concatenate the extracted features of parts as the visual representation of the object for ZSL. The part features are inaccessible in two cases: (a) the semantic parts don't appear in the images, for example, no tails can be observed when birds are in front view; (b) the detector fails to discover the parts. In these cases, zeros are assigned to the corresponding bins of feature vector for the missing parts. We can easily adapt our ABP algorithm to the above situation by changing the computation of $\Vert X-g_{\theta}(C,Z) \Vert ^2$ to $\Vert M \circ(X-g_{\theta}(C,Z)) \Vert ^2 $, where $M$ is the given binary indicator matrix with the same size of $X$, with 1 indicating ``visible'' and 0 indicating ``missing'', and sign $\circ$ denotes element-wise matrix multiplication operation. The indicator matrices $M_i$ vary for different visual features $X_i$. Note that GAN or VAE-based methods can hardly handle learning from incomplete visual features. \section{Experiments} \subsection{Experiment Settings} \textbf{Datasets}. We evaluate the proposed framework for generative ZSL on four widely used ZSL benchmark datasets and compare it with a number of state-of-the-art baselines. The datasets include: (1) Caltech-UCSD Birds-200-2011 (CUB)~\cite{WahCUB_200_2011}, (2) Animal with Attributes (AwA1)~\cite{lampert2014attribute}, (3) Animal with Attributes 2 (AwA2)~\cite{xian2018zero}, (4) SUN attribute (SUN)~\cite{patterson2012sun}. CUB is a fine-grained dataset of bird species with 312 class-level attributes. AwA1 is a coarse-grained dataset including 50 classes of animals with 85 attributes. Since the original images in AwA1 are not publicly available due to the copyright license issue, Xian \emph{et al}~\cite{xian2018zero} create a new dataset AwA2 by collecting new images for each class in AwA1 while keeping the attribute annotations the same as AwA1. SUN contains 717 types of scenes with 102 attributes. We follow the train/test split settings in~\cite{xian2018zero}, which ensures that no unseen classes are included in the ImageNet dataset where the visual feature extractor is pretrained, to avoid violating the setting of ZSL. Besides, we also conduct experiments on a large-scale dataset, i.e., ImageNet-21K~\cite{imagenet_cvpr09}. In this challenging dataset, no attribute annotations are available. We use the word embedding of the class names as the semantic represention of the classes~\cite{changpinyo2016synthesized}. \textbf{Implementation Details}. Our translator is implemented by a multilayer perceptron with a single hidden layer of 4,096 nodes. LeakyReLU and ReLU are used as nonlinear activation functions on the hidden layer and the output layer respectively. The dimension of latent factors $z$ is set to be 10. We fix $\sigma$ = 0.3, $l$ = 10 and $s$ = 0.3. Our model is trained with a batch size of 64 and the Adam optimizer with a learning rate of $10^{-3}$, $\beta_1$ = 0.9, and $\beta_2$ = 0.999. The number of epochs is 50. Our model is implemented using Pytorch framework~\cite{paszke2017automatic} and trained on one NVIDIA TITAN Xp GPU. Our code is publicly available online\footnote{\url{https://github.com/EthanZhu90/ZSL_ABP}} . \subsection{Zero-Shot Learning} As for zero-shot learning setting, we follow the evaluation protocol used in~\cite{xian2018zero}, where results are measured by average per-class top-1 accuracy. We compare with 15 state-of-the-art methods, including 11 non-generative ones and 4 generative ones which are separately shown in Table~\ref{table:zsl}. For GAZSL, FGZSL, and MCGZSL, we get results by running their codes. We reimplement the VZSL by ourselves since no code is publicly available. The results of other methods are published in~\cite{xian2018zero}. From Table~\ref{table:zsl}, we can observe that: (i) the generative methods have an overall performance superior to the non-generative ones (ii) our proposed model consistently outperforms previous state-of-the-art methods and shows great superiorities on AwA1 and AwA2, where the improvements are up to $3.1\%$. This validates that our model trained by alternating back-propagation is significantly beneficial to ZSL tasks. \begin{table}[t] \renewcommand{\arraystretch}{1.0} \begin{center} \scalebox{1.0}{ \begin{tabular}{|c|l|cccc|} \hline &Method & CUB & AwA1 & AwA2 & SUN \\\hline \multirow{10}{*}{$\mathcal{x}$}&DAP~\cite{lampert2014attribute} & 40.0 & 44.1 & 46.1 & 39.9\\ &CMT~\cite{socher2013zero} & 34.6 & 39.5 & 37.9 & 39.9\\ &LATEM~\cite{xian2016latent} & 49.3 & 55.1 & 55.8 & 55.3\\ &ALE~\cite{akata2016label} & 54.9 & 59.9 & 62.5 &58.1\\ &DEVISE~\cite{frome2013devise} & 52.0 & 54.2 & 59.7 &56.5\\ &SJE~\cite{akata2015evaluation} & 53.9 & 65.6 & 61.9 &53.7\\ &ESZSL~\cite{romera2015embarrassingly} & 53.9 & 58.2 & 58.6 & 54.5\\ &SYNC~\cite{changpinyo2016synthesized} & 55.6 & 54.0 &46.6 &56.3 \\ &SAE~\cite{kodirov2017semantic} & 33.3 & 53.0 & 54,1 &40.3 \\ &DEM~\cite{zhang2017learning} & 51.7 & 65.7 & 66.5 & 60.8 \\ &GFZSL~\cite{verma2017simple} & 49.3 & 68.3 &63.8 &60.6\\\hline \multirow{5}{*}{$\mathcal{y}$} &VZSL~\cite{wang2017zero} & 56.3 &\underline{67.1} & 66.8 &59.0\\ &GAZSL~\cite{zhu2018generative} & 55.8 & 63.7 & 64.2 &\underline{60.1}\\ &FGZSL~\cite{xian2018feature} & 57.7 & 65.6 & 66.9 &58.6\\ &MCGZSL~\cite{felix2018multi} & \underline{58.4} &66.8 & \underline{67.3} &60.0 \\ &Ours & \textbf{58.5} &\textbf{69.3} & \textbf{70.4} &\textbf{61.5} \\ \hline \end{tabular} } \end{center} \vspace{-1em} \caption{Performance comparison for zero-shot learning on CUB, AwA1, AwA2 and SUN datasets. The performance is measured by average per-class top-1 accuracy (\%). $\mathcal{y}$ and $\mathcal{x}$ indicate generative and non-generative methods, respectively. The best and the second best results are marked in bold and underlined respectively.} \label{table:zsl} \vspace{-1em} \end{table} \subsection{Generalized Zero-Shot Learning} In the generalized zero-shot learning setting, a test image is classified to the union of seen and unseen classes. This setting is more practical and difficult as it removes the assumption that test images only come from unseen classes. Following the protocol proposed by~\cite{xian2018zero}, we compute the harmonic mean of accuracies on seen and unseen classes: $H = \frac{2 \cdot A_{\mathcal{S}} \cdot A_{\mathcal{U}}}{A_{\mathcal{S}} + A_{\mathcal{U}}}$, where $A_{\mathcal{S}}$ and $A_{\mathcal{U}}$ denote the accuracies of classifying images from seen classes and those from unseen classes respectively. We evaluate our method on four datasets and show the performance comparison with 13 state-of-the-art methods in Table~\ref{table:gzsl}. The experimental results show that non-generative methods achieving high performance on seen classes perform badly on unseen classes, indicating that those methods are biased in favor of seen classes. In contrast, those generative methods can mitigate the bias and perform well on both unseen and seen classes. Compared with other generative ZSL methods, our method obtains much higher accuracies on unseen classes and comparable accuracies on seen classes. It improves the state-of-the-art performances by notable margins on most datasets (e.g., $4.0\%$ on AwA2 in terms of harmonic mean), demonstrating the capability for generalized zero-shot learning. \begin{table*}[t] \renewcommand{\arraystretch}{1.0} \begin{center} \scalebox{1.0}{ \begin{tabular}{|c|l|rrr|rrr|rrr|rrr|} \hline && \multicolumn{3}{c|}{CUB} & \multicolumn{3}{c|}{AwA1} & \multicolumn{3}{c|}{AwA2} & \multicolumn{3}{c|}{SUN} \\ &\multicolumn{1}{c}{Method} & \multicolumn{1}{|c}{$A_{\mathcal{U}}$} & $A_{\mathcal{S}}$ & $H$ & \multicolumn{1}{c}{$A_{\mathcal{U}}$} & $A_{\mathcal{S}}$ & $H$ & \multicolumn{1}{c}{$A_{\mathcal{U}}$} & $A_{\mathcal{S}}$ & $H$ & \multicolumn{1}{c}{$A_{\mathcal{U}}$} & $A_{\mathcal{S}}$ & $H$\\ \hline \multirow{8}{*}{$\mathcal{x}$} &DAP \cite{lampert2014attribute} & 1.7 & \textbf{67.9} & 3.3 & 0.0 &\textbf{88.7} & 0.0 & 0.0 & 84.7 & 0.0 & 4.2 & 25.1 & 7.2\\ &DEVISE \cite{frome2013devise} & 23.8 & 53.0 & 32.8 & 13.4 & 68.7 &22.4 & 17.1 & 74.7 & 27.8 & 16.9 & 27.4 & 20.9\\ &CMT \cite{socher2013zero} &7.2 &49.8 &12.6 &0.9 &\underline{87.6} &1.8 &0.5 &\textbf{90.0} &1.0 &8.1 &21.8 &11.8\\ &SJE \cite{akata2015evaluation} & 23.5 & 59.2 & 33.6 & 11.3 & 74.6 &19.6 & 8.0 & 73.9 & 14.4 & 14.7 & 30.5 & 19.8\\ &LATEM \cite{xian2016latent} & 15.2 & 57.3 & 24.0 & 7.3 & 71.7 &13.3 & 11.5 & 77.3 & 20.0 & 14.7 & 28.8 & 19.5\\ &ESZSL \cite{romera2015embarrassingly} & 12.6 & \underline{63.8} & 21.0 & 6.6 & 75.6 &12.1 & 5.9 & 77.8 & 11.0 &11.0 & 27.9 & 15.8\\ &ALE \cite{akata2016label} & 23.7 & 62.8 & 34.4 & 16.8 & 76.1 &27.5 & 14.0 & 81.8 & 23.9 & 21.8 & 33.1 & 26.3\\ &SAE \cite{kodirov2017semantic} & 7.8 & 54.0 & 13.6 & 1.8 & 77.1 &3.5 & 1.1 & 82.2 & 2.2 & 8.8 & 18.0 & 11.8\\ &DEM \cite{zhang2017learning} &19.6 &57.9 &29.2 &32.8 &84.7 &47.3 &30.5 &\underline{86.4} &45.1 &20.5 &34.3 &25.6\\ \hline \multirow{6}{*}{$\mathcal{y}$} &VZSL \cite{wang2017zero} &44.9 &54.1 &49.1 &53.4 &68.3 &59.9 &51.7 &67.2 &58.4 &43.5 &34.9 &38.7 \\ &GAZSL \cite{zhu2018generative} &26.5 &57.4 &36.2 &32.8 &84.7 &47.3 &\textbf{59.9} &68.3 &53.4 &21.7 &34.5 &26.7\\ &FGZSL \cite{kodirov2017semantic} &\underline{45.9} &54.6 &49.9 &53.1 &68.0 &59.6 &50.2 &67.5 &57.5 &40.2 &\underline{36.4} &38.2\\ &MCGZSL~\cite{felix2018multi} &45.7 &61.0 &\textbf{52.3} &\underline{56.9}&64.0&\underline{60.2} &51.9 &67.2 &\underline{58.6} &\textbf{49.4} &33.6 &\underline{40.0}\\ &Ours &\textbf{47.0} &54.8 &\underline{50.6} &\textbf{57.3} &67.1 &\textbf{61.8} &\underline{55.3} &72.6 &\textbf{62.6} &\underline{45.3} &\textbf{36.8} &\textbf{40.6}\\\hline \end{tabular} } \end{center} \vspace{-1em} \caption{Performance comparison for generalized zero-shot learning. $\mathcal{y}$ and $\mathcal{x}$ indicate generative and non-generative model-based methods respectively. The best and the second best results are marked in bold and underlined respectively.} \label{table:gzsl} \end{table*} \subsection{Large-Scale Experiments} \label{sec:large} We also evaluate the performance of our model on the large-scale ImageNet-21K~\cite{imagenet_cvpr09} dataset. The dataset contains a total of 14 million images from more than 21K classes. The relation among classes follows the WordNet~\cite{miller1995wordnet} hierarchy. Following the same protocol in ~\cite{xian2018zero, changpinyo2016synthesized}, we keep a specific subset of 1K classes for training, and use either all the remaining classes or a subset of it for testing. Specifically, the subsets for testing are determined according to the hierarchical distance from the training classes, or their population. For example, \textit{2Hop} contains 1,509 unseen classes that are within two tree hops of the seen 1K classes based on the class hierarchy, while \textit{3Hop} increases the number of unseen classes to 7,678 by extending the range to three tree hops. \textit{M500}, \textit{M1K} and \textit{M5K} contain 500, 1K, and 5K most populated classes, while \textit{L500}, \textit{L1K} and \textit{L5K} contain 500, 1K, and 5K least populated classes respectively. We compare our method with three baseline methods, which include a visual-semantic embedding-based method, i.e., ALE, and two generative model-based methods, i.e., VZSL and FGZSL. The results are shown in Figure~\ref{fig:imagenet}. A notable observation is that all methods perform much better in \textit{2Hop} subset than in \textit{3Hop} subset. Two vital factors accounting for the observation are: in \textit{3Hop} subset, (i) the unseen classes are semantically less related to the training classes, making it difficult to transfer knowledge, (ii) a dramatic increase in the number of unseen classes (from $1,509$ to $7,678$) makes the classification even harder. Generally, it is evident that generative methods have superior performances. Among the three generative methods, our proposed method achieves the best accuracies in most cases, demonstrating that it is very competitive in this realistic and challenging task. \begin{figure}[t] \centering \begin{subfigure}[b]{0.235\textwidth} \includegraphics[width=1\columnwidth]{paper_semantic_zsl.pdf} \caption{ZSL} \label{fig:cub} \end{subfigure} \begin{subfigure}[b]{0.235\textwidth} \includegraphics[width=1\columnwidth]{paper_semantic_gzsl.pdf} \caption{GZSL} \label{fig:awa} \end{subfigure} \caption{ZSL and GZSL results on ImageNet. For GZSL, $A_{\mathcal{U}}$ is reported.} \label{fig:imagenet} \end{figure} \subsection{Comparison with GAN \& VAE-based Methods} To thoroughly evaluate the performance of our model, we perform extensive ablation experiments. We study the comparison of our method with GAN and VAE-based methods (i.e., FGZSL and VZSL) in terms of \textbf{(i)} the speed of the convergence,\textbf{ (ii)} the number of model parameters, \textbf{ (iii)} ZSL performance when generating different numbers of features for unseen classes,\textbf{ (iv)} ZSL performance under different numbers of seen classes for training. \begin{figure}[t] \centering \begin{subfigure}[b]{0.235\textwidth} \includegraphics[width=1\columnwidth]{curve_cub_v2.pdf} \label{fig:cub} \end{subfigure} \begin{subfigure}[b]{0.235\textwidth} \includegraphics[width=0.99\columnwidth]{curve_awa1_v3.pdf} \label{fig:awa} \end{subfigure} \vspace{-2.0em} \caption{Convergence comparison: top-1 accuracies in the validation set over different numbers of training epochs.} \label{fig:curve} \vspace{-1.0em} \end{figure} \textbf{\emph{Comparison (i)}} To investigate the advantage of our proposed method, we display the convergence curves of different models. We reserve a subset of seen classes as the validation set, and the remaining seen classes are used for training. Considering that various loss functions used in different methods are not comparable, we instead use the average per-class top-1 accuracy of the validation set as the convergence indicator. Figure~\ref{fig:curve} shows classification accuracies over different numbers of training epochs on CUB and AwA1 datasets. The convergence trends on both datasets are similar. Among these three methods, ours converges fastest, while the GAN-based method is the slowest one. \begin{table}[h] \begin{center} \scalebox{0.9}{ \begin{tabular}{|l |c |c | } \hline Dataset &\# of Parameters &\# of Mult-Adds\\\hline FGZSL~\cite{xian2018feature} & 20.62M & 41.23M \\ VZSL~\cite{wang2017zero} & 21.90M & 43.78M \\ Ours & 9.71M & 19.42M \\\hline \end{tabular} } \end{center} \vspace{-1em} \caption{Comparison of the number of parameters and the computational cost among three generative model-based ZSL methods that are applied to CUB dataset.} \label{table:param} \end{table} \textbf{\emph{Comparison (ii)}} Another advantage of our proposed model is the small number of parameters, or equivalently, the low computational load. We compare our method with FGZSL and VZSL for the CUB dataset in terms of the number of parameters and the number of element-wise multiplication and addition operations in Table~\ref{table:param}. Note that these numbers might get changed when the methods are applied to other datasets, because different datasets may have various dimensions of semantic and visual features. Due to the incorporation of auxiliary networks in VAE and GAN-based methods (i.e., the encoder in VAE and the discriminator in GAN), these models require more parameters and computations. Our method only contains one single conditional generator, therefore its parameter size and computational cost are only half of those in GAN and VAE-based frameworks. \vspace{0.5em} \textbf{\emph{Comparison (iii)}} Figure~\ref{fig:pseudo} shows the accuracies of three methods with different numbers of synthetic features for each unseen class. The same curve trends appear on both CUB and AwA1 datasets. The results are better with larger number of synthetic samples. When the number increases to 300, all the performances are similar and stable, indicating that each of the models is saturated as no improvement appears with more samples. Compared with FGZSL, our model performs much better with fewer samples (e.g., $50.1\%$ v.s. $29.1\%$ on CUB and $60.1\%$ v.s. $38.9\%$ on AwA1 with only 1 sample). The VZSL model performs slightly worse than ours. \begin{figure}[t] \centering \begin{subfigure}[b]{0.235\textwidth} \includegraphics[width=1\columnwidth]{curve_CUB_sample_number.pdf} \label{fig:cub} \end{subfigure} \begin{subfigure}[b]{0.235\textwidth} \includegraphics[width=0.99\columnwidth]{curve_AWA1_sample_number.pdf} \label{fig:awa} \end{subfigure} \vspace{-2.0em} \caption{ Comparison of top-1 per-class accuracies of unseen classes with different numbers of synthetic features per class.} \label{fig:pseudo} \vspace{-1.5em} \end{figure} \textbf{\emph{Comparison (iv)}} As pointed out in~\cite{song2018transductive}, the number of unseen classes usually dramatically surpasses that of seen classes in the real world. However, most ZSL benchmark datasets are far away from this situation. For instance, only 72 out of 717 classes on the SUN dataset are specified as unseen classes. This motivates us to investigate how models perform with different numbers of seen classes for training. We conduct experiments on the SUN dataset as it contains more classes than other datasets. We keep the unseen classes the same and randomly sample different numbers of seen classes for training. To make the experiments closer to the real world situation, we report the performance in the generalized ZSL setting, as shown in Figure~\ref{fig:class}. As the number of seen classes increases, the accuracies of seen classes of all methods consistently decrease, indicating the increasing difficulty in discriminating seen class examples. From another perspective, more seen classes can provide more knowledge to associate the visual and semantic features, resulting in the improvement in the performance on unseen classes. Compared with other generative methods, our model achieves the best $A_{\mathcal{U}}$ while keeping decent $A_{\mathcal{S}}$. \begin{figure}[t] \centering \includegraphics[width=0.6\columnwidth]{curve_SUN_class_number.pdf} \caption{Comparison of top-1 per-class accuracies of unseen classes among different methods with different numbers of seen classes in training.} \label{fig:class} \end{figure} \begin{comment} \begin{figure}[h] \centering \includegraphics[width=0.9\columnwidth]{figures/tsne-crop.pdf} \vspace{-1.0em} \caption{ t-SNE visulization for AwA1. (a) Origianl CNN features (b) Generated features by our model.} \label{fig:tsne} \vspace{-0.5em} \end{figure} \end{comment} \subsection{Learning from Incomplete Visual Features} Zhu \emph{et al} \cite{Elhosein_2017_CVPR, zhu2018generative} propose to use concatenated part features for ZSL, where those part features are either from groundtruth part annotations or extracted by a learned part detector, denoted as GTA and DET features respectively. The missing ratio in GTA is $9.3\%$, while the ratio decreases to $4.0\%$ in DET due to the high recall of their part detector. We first evaluate the performance of our model and GAZSL~\cite{zhu2018generative} with GTA features and DET features. As shown in Table~\ref{table:inc}, our method outperforms GAZSL by $2.6\%$ and $2.5\%$ using GTA and DET features respectively. To further analyze the power of our model in dealing with incomplete visual features, we increase the missing ratio of the DET features by randomly masking some valid feature values. As the missing ratio increases, the performances of both methods drop due to the reason that less and less useful information can be used. However, our method can still achieve a decent performance of $51.6\%$ in the most challenging situation where the missing ratio reaches $90\%$, while the accuracy of GAZSL is only $37.7\%$. This confirms the claimed power of our model in learning from incomplete visual features for ZSL. \begin{table}[t] \renewcommand{\arraystretch}{1.0} \begin{center} \scalebox{0.85}{ \begin{tabular}{|lcc|cccc|} \hline & & &\multicolumn{4}{|c|}{DET$^*$}\\ Method & GTA &DET &\multicolumn{1}{ |c }{$30\%$} &\multicolumn{1}{ c }{$50\%$} &\multicolumn{1}{ c}{$70\%$} &\multicolumn{1}{ c| }{$90\%$}\\ \hline GAZSL~\cite{zhu2018generative} & 74.1 & 72.7 &68.5 &63.7 &55.6 &37.7\\ Ours & 76.7 & 75.2 &72.9 &71.3 &64.8 &51.6\\ \hline \end{tabular} } \end{center} \vspace{-1.2em} \caption{Zero-shot learning performance (top-1 accuracy $\%$) of the models trained on incomplete visual features with different missing ratios.} \label{table:inc} \vspace{-1.2em} \end{table} \section{Conclusion} We propose a feature-to-feature translator learned by an alternating back-propagation algorithm as a general-purpose solution to zero-shot learning. Unlike other generative models, such as GAN and VAE, our method is simple yet effective, and does not rely on any assisting networks for training. The alternating back-propagation algorithm iterates the inferential back-propagation for inferring the instance-level latent factors and the learning back-propagation for updating the model parameters. We present a solution to learning from incomplete visual features for ZSL. We show that our framework outperforms the existing generative ZSL methods. \textbf{Acknowledgment.} This work is partially supported by NSFUSA award 1409683. We thank Prof. Ying Nian Wu for helpful discussions. {\small \bibliographystyle{ieee}
{'timestamp': '2019-11-12T02:21:49', 'yymm': '1904', 'arxiv_id': '1904.10056', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.10056'}
arxiv
\section{Conclusion} We propose a self-supervised autoencoding algorithm, LBS-AE, to align articulated mesh models to point clouds. The decoder leverages an artist-defined mesh rig, and using LBS. We constrain the encoder to infer interpretable joint angles. We also propose the structured Chamfer distance for training LBS-AE, defined by inferring a meaningful segmentation of the target data to improve the correspondence finding via nearest neighbor search in the original Chamfer distance. By combining LBS-AE and the segmentation inference, we demonstrate we can train these two components simultaneously without supervision (labeling) from data. As training progress, the proposed model can start adapting to the data distribution and improve with self-supervision. In addition to opening a new route to model fitting without supervision, the proposed algorithm also provides a successful example showing how to encode existing prior knowledge in a geometric deep learning model. \section{Experiment} \label{sec:exp} \paragraph{Datasets} We consider hand and body data. For body data, we test on FAUST benchmark~\cite{bogo2014faust}, which captures real human body with correspondence labeling. For hand data, we use a multi-view capture system to captured $1,524$ poses from three people, which have missing area and different densities of points across areas. The examples of reconstructed meshes are shown in Figure~\ref{fig:hand}. For numerical evaluation, in addition to FAUST, we also consider synthetic data since we do not have labeling information on the hand data (\eg key points, poses, correspondence). To generate synthetic hands, we first estimate pose parameters of the captured data under LBS. To model the modality gap, we prepare different base templates with various thickness and length of palms and fingers. We then generate data with LBS based on those templates and the inferred pose parameters. We also generate synthetic human body shapes using SMPL~\cite{bogo2016keep}. We sample $20,000$ parameter configurations estimated by SURREAL~\cite{varol2017learning} and $3,000$ samples of bent shapes from~\cite{groueix20183d}. For both synthetic hand and body data, the scale of each shape is in $[-1, 1]^3$ and we generate $2300$ and $300$ examples as holdout testing sets. \vspace{-10pt} \paragraph{Architectures} The architecture of $f$ follows~\cite{li2018point} to use DeepSet~\cite{zaheer2017deep}, which shows competitive performance with PointNet~\cite{qi2017pointnet} with half the number of parameters. The output is set to be $J\times 3$ dimensions, where $J$ is the number of joints. We use the previous layer's activations as $\phi(\Xb)$ for $d$. We use a three layer MLP to model $d$, where the input is the concatenation of $v$, $f(\Xb)$ and $\phi(\Xb)$, and the hidden layer sizes are $256$ and $128$. For segmentation network $s$, we use~\cite{qi2017pointnet} because of better performance. For hand data, we use an artist-created LBS, while we use the LBS part from SMPL~\cite{loper2015smpl} for body data. \begin{figure} \centering \includegraphics[trim={120 10 90 0},clip,width=0.185\linewidth]{figs/hand/data_0.png} \includegraphics[trim={180 100 180 100},clip,width=0.185\linewidth]{figs/hand/data_31.png} \includegraphics[trim={200 100 60 100},clip,width=0.185\linewidth]{figs/hand/data_22.png} \includegraphics[trim={200 100 60 0},clip,width=0.185\linewidth]{figs/hand/data_9.png} \includegraphics[trim={180 100 100 20},clip,width=0.185\linewidth]{figs/hand/data_35.png} \vspace{-8pt} \caption{Examples of the captured hands.} \vspace{-12pt} \label{fig:hand} \end{figure} \subsection{Study on Segmentation Learning} \label{sec:seg_exp} One goal of the proposed LBS-AE is to leverage geometry structures of the shape, by learning segmentation jointly to improve correspondence finding via nearest neighbor searching when measuring the difference between two shapes. Different from previous works (\eg \cite{wei2016dense}), we do not rely on any human labels. We study how the segmentation learning with self-supervision interacts with the model fitting to data. We train different variants of LBS-AE to fit the captured hands data. The first is learning LBS-AE with CD only (LBS-AE$_{\text{CD}}$). The objective is \eqref{eq:all} without $\Lcal_{s^2, 0.5}$. We then train the segmentation network $s$ for SCD with hand poses sampled from uniform distributions based on $\Ub$ instead of $\Ub^d$. Note that there is no interaction between learning $s$ and the other networks $f$ and $d$. The segmentation and reconstructed results are shown in Figure~\ref{fig:lbsae_cd}. We observe that the segmentation network trained on randomly sampled poses from a uniform distribution can only segment easy poses correctly and fail on challenging cases, such as feast poses, because of the difference between true pose distributions and the uniform distribution used as well as the modality gaps between real hands and synthetic hands from LBS. On the other hand, LBS-AE$_{\text{CD}}$ is stuck at different local optimums. For example, it recovers to stretch the ring finger instead of the little finger for the third pose. Secondly, we study the importance of adapting to different modalities. In Figure~\ref{fig:modality}, we train segmentation and LBS fitting jointly with SCD. However, when we augment the data for training segmentation, we only adapt to pose distributions via $f(\Xb)$, instead of using the deformed $\Ub^d$. Therefore, the training data for $s$ for this case has a modality gap between it and the true data. Compared with Figure~\ref{fig:lbsae_cd}, the joint training benefits the performance, for example, on the feast pose. It suggests how good segmentation learning benefits reconstruction. Nevertheless, it still fails on the third pose. By training LBS-AE and the segmentation jointly with inferred modalities and poses, we could fit the poses better as shown in Figure~\ref{fig:hand_lbs}. This difference demonstrates the importance of training segmentation adapting to the pose distributions and different modalities. \begin{figure} \centering \begin{subfigure}[b]{0.152\textwidth} \centering \includegraphics[width=\textwidth]{figs/hand/all1} \caption{LBS-AE$_{\text{CD}}$} \label{fig:lbsae_cd} \end{subfigure} \begin{subfigure}[b]{0.152\textwidth} \centering \includegraphics[width=\textwidth]{figs/hand/all2} \caption{Modality Gap} \label{fig:modality} \end{subfigure} \begin{subfigure}[b]{0.15\textwidth} \centering \includegraphics[width=\textwidth]{figs/hand/all3} \caption{LBS-AE} \label{fig:hand_lbs} \end{subfigure} \vspace{-8pt} \caption{Ablation study of the proposed LBS-AE. For each block, the left column is the inferred segmentations of input shapes while the right column is the reconstruction.} \vspace{-12pt} \label{fig:loo} \end{figure} \vspace{-10pt} \paragraph{Numerical Results} We also quantitatively investigate the learned segmentation when ground truth is available. We train $s$ with (1) randomly sampled shapes from uniform distributions over joint angle ranges ({\tt Random}) and (2) the proposed joint training ({\tt Joint}). We use pretraining as initialization as describing in Section~\ref{sec:scd}. We then train these two algorithms on the synthetic hand and body data and evaluate segmentation accuracy on the testing sets. The results are shown in Figure~\ref{fig:seg_acc}. {\tt Random} is exactly the same as pretraining. After pretraining, {\tt Random} is almost converged. On the other hand, {\tt Joint} improves the segmentation accuracy in both cases by gradually adapting to the true pose distribution when the joint angle regressor$f$ is improved. It justifies the effectiveness of the proposed joint training where we can infer the segmentation in a self-supervised manner. For hand data, as we show in Figure~\ref{fig:loo}, there are many \emph{touching-skin} poses where fingers are touched to each other. For those poses, there are strong correlations between joints in each pose, which are hard to be sampled by a simple uniform distribution and results in a performance gap in Figure~\ref{fig:hand_acc}. For body data, many poses from SURREAL are with separate limbs, which {\tt Random} can generalize surprisingly well. Although it seems {\tt Joint} only leads to incremental improvement over {\tt Random}, we argue this gap is substantial, especially for resolving challenging touching-skin cases as we will show in Section~\ref{sec:quant}. \begin{figure} \centering \begin{subfigure}[b]{0.23\textwidth} \centering \includegraphics[width=\textwidth]{figs/others/hand_acc} \caption{Synthetic Hands} \label{fig:hand_acc} \end{subfigure} \begin{subfigure}[b]{0.23\textwidth} \centering \includegraphics[width=\textwidth]{figs/others/body_acc} \caption{SMPL} \label{fig:body_acc} \end{subfigure} \vspace{-8pt} \caption{Segmentation accuracy on holdout testing sets.} \vspace{-10pt} \label{fig:seg_acc} \end{figure} \subsection{Qualitative Study} We compare the proposed algorithm with the unsupervised learning variant of~\cite{groueix20183d}, which learns the deformation by entirely relying on neural networks. Their objective is similar to \eqref{eq:all}, but using CD and Laplacian regularization only. For fair comparison, we also generate synthetic data on the fly with randomly sampled poses and correspondence for~\cite{groueix20183d}, which boosts its performance. We also compare with the simplified version of the proposed algorithm by using CD instead of SCD, which is denoted as LBS-AE$_{\text{CD}}$ as above. We fit and reconstruct the hand and body data as shown in Figure~\ref{fig:qual_hand}. For the thumb-up pose, due to wrong correspondences from nearest neighbor search, both~\cite{groueix20183d} and LBS-AE$_{\text{CD}}$ reconstruct wrong poses. The wrong correspondence causes problems to~\cite{groueix20183d}. Since the deformation from templates to targeted shapes fully relies on a deep neural network, when the correspondence is wrong and the network is powerful, it learns distorted deformation even with a Laplacian regularization. On the other hand, since LBS-AE$_{\text{CD}}$ still utilizes LBS, the deformation network $d$ is easier to regularize, which results in better finger reconstructions. We note that~\cite{groueix20183d} learns proper deformation if the correspondence can be found correctly, such as the third row in Figure~\ref{fig:qual_hand}. In both cases, the proposed LBS-AE can learn segmentation well and recover the poses better. Lastly, we consider fitting FAUST, with only $200$ samples, as shown in Figure~\ref{fig:qual_faust}. With limited and diverse poses, we have less hint of how the poses deform~\cite{wei2016dense}, a nearest neighbor search is easily trapped in bad local optimums as we mentioned in Figure~\ref{fig:local}. The proposed LBS-AE still results in reasonable reconstructions and segmentation, though the right arm in the second row suffers from the local optimum issues within the segmentation. A fix is to learn more fine-grained segmentation, but it brings the trade-off between task difficulty and model capacity, which we leave for future work. \input{qual} \subsection{Quantitative Study} \label{sec:quant} We conduct quantitative analysis on reconstruction, pose estimation, and correspondence on synthetic hand and body data. We use $\sqrt{\text{CD}}$ as the proxy to reconstructions. Pose estimation compares the average $\ell_2$ distance between true joint positions and inferred ones while correspondence also measures the average $\ell_2$ between found and true correspondences. We randomly generate $4000$ testing pairs from the testing data for correspondence comparison. Given two shapes, we fit the shapes via the trained models. Since we know the correspondence of the reconstructions, we project the data onto the reconstructions to find the correspondence. For more details, we refer readers to~\cite{groueix20183d}. We compare three variants of~\cite{groueix20183d}, including the supervised version with full correspondence, and the unsupervised version with and without synthetic data augmentation aforementioned. For LBS-AE, we also consider three variants, including a simple CD baseline (LBS-AE$_{\text{CD}}$), a segmentation network $s$ trained on poses from uniform distributions LBS-AE$_{\text{RAND}}$ and joint training version (LBS-AE). The results are shown in Table~\ref{tb:quant}. For LBS-AE variants, the jointly trained LBS-AE is better than LBS-AE$_{\text{CD}}$ and LBS-AE$_{\text{RAND}}$. It supports the hypothesis in Section~\ref{sec:seg_exp}, that joint training facilitates improving model fitting and segmentation. Also, as shown in Section~\ref{sec:seg_exp}, the pretrained segmentation network still has reasonable testing accuracy and brings an improvement over using CD loss only. On the other hand, the supervised version of~\cite{groueix20183d} trained with full correspondence is worse than the proposed unsupervised LBS-AE due to generalization ability. For correspondence on the SMPL training set, supervised \cite{groueix20183d} achieves $0.065$ while LBS-AE achieve $0.069$. If we increase the training data size three times, supervised~\cite{groueix20183d} improves its correspondence result to be $0.095$. For hand data, supervised~\cite{groueix20183d} generalizes even worse with only $1500$ training examples. It suggests that leveraging LBS models into the model can not only use smaller networks but also generalize better than relying on an unconstrained deformation from a deep network. \begin{table} \small \centering \setlength{\tabcolsep}{0.4em} \begin{tabular}{c|c|c|c|c|c|c} \hline & \multicolumn{3}{c|}{SMPL}& \multicolumn{3}{c}{Syn. Hand} \\ \hline Algorithm & Recon & Pose & Corre.& Recon & Pose & Corre. \\ \hline Unsup.~\cite{groueix20183d} & 0.076 & 0.082 & 0.136 & 0.099 & 0.035 & 0.176 \\ Unsup.+Aug~\cite{groueix20183d} & 0.081 & 0.081 & 0.132 & 0.069 & 0.049 & 0.140 \\ Sup.~\cite{groueix20183d} & 0.073 & 0.071 & 0.104& 0.062 & 0.047 & 0.135 \\ \hline LBS-AE$_{\text{CD}}$ & 0.051 & 0.152 & 0.147 & 0.082 & 0.069 & 0.168 \ \\ LBS-AE$_{\text{RAND}}$& 0.041 & 0.058 & 0.100 & 0.069 & 0.050 & 0.137\\ LBS-AE & {\bf 0.037} & {\bf 0.048} & {\bf 0.091} & {\bf 0.053} & {\bf 0.035} & {\bf 0.111} \\ \hline \end{tabular} \caption{Quantitative results on synthetic data.} \label{tb:quant} \end{table} \vspace{-8pt} \paragraph{Deformation Network} We also investigate the ability of the deformation in LBS-AE. For data generated via SMPL, we know the ground truth of deformed templates $\Ub^{gt}$ of each shape. The average $\ell_2$ distance between corresponding points from $\Ub^{gt}$ and $\Ub^d$ is $0.02$, while the average distance between $\Ub^{gt}$ and $\Ub$ is $0.03$. \vspace{-8pt} \paragraph{Real-World Benchmark.} One representative real-world benchmark is FAUST~\cite{bogo2014faust}. We follow the protocol used in~\cite{groueix20183d} for comparison, where they train on SMPL with SURREAL parameters and then fine-tune on FAUST. In~\cite{groueix20183d}, they use a different number of data from SMPL with SURREAL parameters, while we only use 23K. The numerical results are shown in Table~\ref{tb:faust}. With only 23K SMPL data and self-supervision, we are better than unsupervised~\cite{groueix20183d} with 50K data, supervised~\cite{groueix20183d} with 10K data, and the supervised learning algorithm FMNet~\cite{litany2017deep}. We show some visualization of the inferred correspondence in Figure~\ref{fig:corr}. \begin{table} \centering \begin{tabular}{c|c|c} \hline Algorithm & Inter. error (cm) & Intra. err (cm) \\ \hline FMNet~\cite{litany2017deep} & 4.826 & 2.44 \\ Unsup.~\cite{groueix20183d} (230K) & 4.88 & - \\ Sup.~\cite{groueix20183d} (10K) & 4.70 & - \\ Sup.~\cite{groueix20183d} (230K) & 3.26 & 1.985 \\ \hline LBS-AE (23K) & 4.08 & 2.161\\ \hline \end{tabular} \vspace{-5pt} \caption{Correspondence results on FAUST testing set.} \vspace{-8pt} \label{tb:faust} \end{table} \begin{figure} \centering \begin{subfigure}[b]{0.155\textwidth} \centering \includegraphics[trim={130 100 130 20},clip,width=0.48\textwidth]{figs/corr/corr_006} \includegraphics[trim={130 100 130 20},clip,width=0.48\textwidth]{figs/corr/corr_021} \caption{} \end{subfigure} \hfill \begin{subfigure}[b]{0.155\textwidth} \centering \includegraphics[trim={130 100 130 20},clip,width=0.48\textwidth]{figs/corr/corr_011} \includegraphics[trim={130 100 130 20},clip,width=0.48\textwidth]{figs/corr/corr_107} \caption{} \end{subfigure} \hfill \begin{subfigure}[b]{0.155\textwidth} \centering \includegraphics[trim={130 100 130 20},clip,width=0.48\textwidth]{figs/corr/corr_012} \includegraphics[trim={130 100 130 20},clip,width=0.48\textwidth]{figs/corr/corr_043} \caption{} \end{subfigure} \vspace{-20pt} \caption{Inferred correspondence of FAUST testing data.} \vspace{-12pt} \label{fig:corr} \end{figure} \section{Introduction} The registration of unstructured point-clouds to a common mesh representation is an important problem in computer vision and has been extensively studied in the past decades. Works in this area can be coarsely grouped together based on how much prior knowledge and supervision is incorporated into the fitting method. On one end of the spectrum, there are entirely unsupervised and object-agnostic models, such as FoldingNet \cite{yang2018foldingnet} or AtlasNet~\cite{groueix2018atlasnet}. These methods learn to deform a flat 2D surface to match the target geometry, while making no assumptions about the objects being modeled other than that they can be represented as a 2D surface. Adding slightly more prior knowledge, 3D-CODED~\cite{groueix20183d} uses a template mesh (\eg hand or body) with a topology better suited to the object of interest. On the other end of the spectrum are highly specialized models for specific objects, such as hands and bodies. Works of this kind include SCAPE~\cite{Anguelov2005}, Dyna~\cite{pons2015dyna}, SMPL~\cite{loper2015smpl}, and MANO~\cite{romero2017embodied}. These models are built using high-resolution 3D scans with correspondence and human curation. They model correctives for different poses and modalities (\eg body types) and can be used as high-quality generative models of geometry. A number of works learn to manipulate these models to fit data based on different sources of supervision, such as key points~\cite{bogo2016keep,lassner2017unite,mehta2017vnect,tung2017self,joo2018total} and/or prior distributions of model parameters~\cite{kanazawa2018learning, kanazawa2018end}. In this paper, we present an unsupervised/self-supervised algorithm, LBS Autoencoder (LBS-AE), to fit such articulated mesh models to point cloud data. The proposed algorithm is a middle ground of the two ends of spectrum discussed above in two senses. First, we assume an articulated template model of the object class is available, but not the statistics of its articulation in our dataset nor the specific shape of the object instance. We argue that this prior information is widely available for many common objects of interest in the form of ``rigged'' or ``skinned'' mesh models, which are typically created by artists for use in animation. In addition to a template mesh describing the geometric shape, these prior models have two more components: (1) a kinematic hierarchy of transforms describing the degrees of freedom, and (2) a skinning function that defines how transforms in the hierarchy influence each of the mesh vertices. This enables registration to data by manipulating the transforms in the model. One common example is Linear Blending Skinning (LBS). Therefore, instead of relying on deep networks to learn the full deformation process from a single template~\cite{groueix20183d}, we leverage LBS as part of the decoder to model coarse joint deformations. Different from hand-crafted models such as SMPL~\cite{loper2015smpl}, LBS by itself does not model pose-dependent correctives between the template and data, nor does it model the space of non-articulated shape variation (\eg body shape). To model these, we also allow our network to learn deformations of the template mesh which, when posed by LBS, result in a better fit to the data. The encoder therefore learns a latent representation from which it can infer both joint angles for use by the LBS deformation, as well as corrective deformations to the template mesh. Second, for fitting models to data during the training, existing works either rely on explicit supervision (\eg correspondence~\cite{groueix20183d} and key points~\cite{joo2018total}) or unsupervised nearest neighbors search (\eg Chamfer Distance (CD)~\cite{yang2018foldingnet}) to find point correspondence between the model and data for measuring reconstruction loss. Rather than using external supervision, we introduce a ``Structured Chamfer Distance'' (SCD), which improves the blind nearest neighbor search in CD based on an inferred coarse correspondence. The idea is to segment the point clouds into corresponding regions (we use regions defined by the LBS weighting). After inferring the segmentation on the input point cloud and the template, we then apply nearest neighbor search between corresponding regions as high-level correspondence. The challenge is we do not assume external supervision to be available for the input point clouds. Instead, we utilize the learned LBS-AE model to generate \emph{self-supervision} to train the segmentation network from scratch. As the LBS-AE fitting is improved during training, the training data from self-supervision for segmentation also improves, leading to improved segmentation of the real data. We are then able to use the improved segmentation to achieve better correspondence and in turn better LBS-AE model fitting. In this paper, we present a joint training framework to learn these two components simultaneously. Since LBS-AE does not require any explicit correspondence nor key points, it is similar to approaches which are sometimes referred to as ``unsupervised'' in the pose estimation literature~\cite{tewari2018high, genova2018unsupervised}, but it is different from existing unsupervised learning approach~\cite{yang2018foldingnet} in that it leverages LBS deformation to generate \emph{self-supervision} during training. In this work, we show that the space of deformations described by an artist-defined rig may sometimes already be sufficiently constrained to allow fitting to real data without any additional labeling. Such a model-fitting pipeline without additional supervision has the potential to simplify geometric registration tasks by requiring less human labeling effort. For example, when fitting an artist-defined hand rig to point clouds of hands, our method allows for unsupervised hand pose estimation. When fitting a body model to 3D scans of body data, this allows recovering the joint angles of the body as well as registering the mesh vertices. In the experiments, we present the results on fitting real hands as well as benchmark body data on the SURREAL and FAUST datasets. \section{Proposed Method} We propose to learn a function $\Fcal(\cdot)$ that takes as input an unstructured point cloud $\Xb{=}\{x\}_{i=1}^n$, where each $x_i$ is a 3D point and $n$ is a variable number, and produces as output a fixed number $m$ of corresponded vertices $\Vb{=}\{v_i\}_{i=1}^{m}$, where $\Vb = \Fcal\left( \Xb\right)$. The vertices $\Vb$ form a mesh with fixed topology whose geometry should closely match that of the input\footnote{Note that, although we assume the inputs are point clouds, they could also be the vertices of a mesh without using any topology information.}. Rather than allowing $\Fcal(\cdot)$ to be any arbitrary deformation produced by a deep neural network (as in~\cite{yang2018foldingnet,groueix2018atlasnet}), we force the output to be produced by Linear Blending Skinning (LBS) to explicitly encode the motion of joints. We allow additional non-linear deformations (also given by a neural network) to model deviations from the LBS approximation. However, an important difference with respect to similar models, such as SMPL~\cite{loper2015smpl} or MANO~\cite{romero2017embodied}, is that we do not pre-learn the space of non-LBS deformations on a curated set (and then fix them) but rather learn these simultaneously on the data that is to be aligned, with no additional supervision. \paragraph{Linear Blending Skinning} We start by briefly introducing LBS~\cite{magnenat1988joint}, which is the core building component of the proposed work. LBS models deformation of a mesh from a rest pose as a weighted sum of the skeleton bone transformations applied to each vertex. We follow the notation outlined in~\cite{loper2015smpl}, which is a strong influence on our model. An LBS model with $J$ joints can be defined as follows \begin{equation} \Vb = M(\Theta, \Ub), \label{eq:lbs} \end{equation} with $\Vb$ the vertices of the deformed shape after LBS. The LBS function $M$ takes two parameters, one is the vertices $\Ub=\{u_i\}_{i=1}^{m}$ of a base mesh (template), and the other are the relative joint rotation angles $\Theta\in \RR^{J\times 3}$ for each joint $j$ with respect to its parents. If $\Theta=\mathbf{0}$, then $M(\mathbf{0}, \Ub)=\Ub$. Two additional parameters, the skinning weights $w$ and the joint hierarchy $K$, are required by LBS. We will consider them fixed by the artist-defined rig. In particular, $w\in\RR^{m\times J}$ defines the weights of each vertex contributing to joint $j$ and $\sum_j w_{i,j}=1$ for all $i$. $K$ is the joint hierarchy. Each vertex $v_i \in \Vb$ can then be written as \[ v_i = \left( \Ib_3, \mathbf{0}\right)\cdot \sum_{j=1}^J w_{i,j} \Tcal_j(\Theta, K) \begin{pmatrix} u_i \\ 1 \end{pmatrix}, \] where $\Tcal_j(\Theta, K)\in \mbox{SE}(3)$ is a transformation matrix for each joint $j$, which encodes the transformation from the rest pose to the posed mesh in world coordinate, constructed by traversing the hierarchy $K$ from the root to $j$. Since each $v_i$ is constructed by a sequence of linear operations, the LBS $M(\Theta, \Ub)$ is differentiable respect to $\Theta$ and $\Ub$. A simple example constructed from the LBS component in SMPL~\cite{loper2015smpl} is shown in Figure~\ref{fig:lbs_temp} and~\ref{fig:lbs_control}. In this work, both the joint angles and the template mesh used in the LBS function are produced by deep networks from the input point cloud data, \begin{equation} \Vb = M(f( \Xb ) , d( \Xb, \Ub )), \label{eq:lbs_full} \end{equation} where we identify a \emph{joint angle estimation} network $f$, and a \emph{template deformation} network $d$ which we describe below. \begin{figure} \centering \begin{subfigure}[b]{0.15\textwidth} \centering \includegraphics[width=\textwidth]{figs/others/smpl_template} \vspace{-20pt} \caption{$\Ub$} \label{fig:lbs_temp} \end{subfigure} \begin{subfigure}[b]{0.15\textwidth} \centering \includegraphics[width=\textwidth]{figs/others/smpl_example} \vspace{-20pt} \caption{$M(\theta, \Ub)$} \label{fig:lbs_control} \end{subfigure} \begin{subfigure}[b]{0.15\textwidth} \centering \includegraphics[width=\textwidth]{figs/others/smpl_deform} \vspace{-20pt} \caption{$\Ub^d$} \label{fig:deform} \end{subfigure} \vspace{-5pt} \caption{(a) Template mesh, (b) LBS deformation of the template using joint angles $\theta$, and (c) a deformed template.} \label{fig:lbs} \end{figure} \vspace{-5pt} \paragraph{Joint Angle (Pose) Estimation} Given an LBS model defined in~\eqref{eq:lbs}, the goal is to regress joint angles based on input $\Xb$ via a function $f: \Xb\rightarrow \Theta$ such that $M(f(\Xb), \Ub)\approx \Xb$. We use a deep neural network, which takes set data (\eg point cloud) as input~\cite{qi2017pointnet, zaheer2017deep} to $f$, but we must also specify how to compare $\Xb$ and $\Vb$ from $M(\cdot)$. Losses that assume uniformly sampled surfaces (such as distribution matching~\cite{li2018point} or optimal transport) are less suitable, because reconstructed point clouds typically exhibit some amount of missing data and non-uniform sampling. Instead, we adopt a Chamfer distance (CD)~\cite{yang2018foldingnet} defined as $\Lcal_c(\Xb, \Vb) = $ \begin{equation} \frac{1}{n}\sum_{i=1}^n \| x_i - \Ncal_\Vb(x_i) \|^2 + \frac{1}{m}\sum_{j=1}^m \| v_j - \Ncal_\Xb(v_j) \|^2, \label{eq:chamfer} \end{equation} where $\Ncal_\Vb(x_i)=\arg\min_{v_j\in \Vb} \|x_i-v_j\|$ is the nearest neighbor of $x_i$ in $\Vb$. This is also called Iterative Closest Point (ICP) in the registration literature~\cite{besl1992method}. After finding nearest neighbors, we learn $f$ by back-propagating this point-wise loss through the differentiable LBS $\Vb=M(f(\Xb),\Ub)$. Also note that we only sample a subset of points for estimating~\eqref{eq:chamfer} under SGD training schemes. In practice, we observe that it takes many iterations for PointNet~\cite{qi2017pointnet} or DeepSet~\cite{zaheer2017deep} architectures to improve if the target loss is CD instead of corresponded supervision. Similar behaviors were observed in~\cite{yang2018foldingnet, li2018point}, where the algorithms may take millions of iterations to converge. To alleviate this problem, we utilize LBS to generate data based on a given $\Theta'$ for \emph{self-supervision} by optimizing \[ \min_f \Lcal_\Theta = \|f( M(\Theta', \Ub) ) - \Theta' \|^2. \] It is similar to the \emph{loop-back} loss~\cite{genova2018unsupervised} that ensures $f$ can correctly reinterpret the model's own output from $M$. Different from~\cite{genova2018unsupervised, kanazawa2018end}, we do not assume a prior pose distribution is available. Our $\Theta'$ comes from two sources of randomness. One is uniform distributions within the given joint angle ranges (specified by the artist-defined rig) and the second is we uniformly perturb the inferred angles from input samples with a small uniform noise on the fly, which can gradually adapt to the training data distribution when the estimation is improved as training progresses (see Section~\ref{sec:scd} and Figure~\ref{fig:mix}). \begin{figure}[t] \centering \includegraphics[width=1.01\linewidth]{figs/others/lbs_dec3} \caption{LBS-AE. Given a point cloud $\Xb$ of a input shape, we encode $\Xb$ into a latent code $\phi(\Xb)$ and the inferred joint angles $f(\Xb)$. The decoder contains a deformation network $d$ to deform the template $\Ub$ into $\Ub^d$, then uses a LBS to pose $\Ub^d$ into $\Vb^d$ as the reconstruction.} \label{fig:dec} \end{figure} \vspace{-8pt} \paragraph{Template Deformation} Although LBS can represent large pose deformations, due to limitations of LBS as well as differences between the artist modeled mesh and the real data, there will be a large residual in the fitting. We refer to this residual as a \emph{modality gap} between the model and reality, and alleviate this difference by using a neural network $d$ to produce the template mesh to be posed by LBS. The deformation network $d(\phi(\Xb), u_i)$ takes two sources as input, where $u_i$ is each vertex in the template mesh $\Ub$, and $\phi(\Xb)$ are features from an intermediate layer in $f$, which contains information about the state of $\Xb$. This yields a deformed template $\Ub^d = \{d(\phi(\Xb), u_i)\}_{i=1}^m$. One example is shown in Figure~\ref{fig:deform}. After LBS, we denote the deformed and posed mesh as $\Vb^d = M(f(\Xb), \Ub^d)$, and denote by $\Vb=M(f(\Xb), \Ub)$ the posed original template. If $d$ is high-capacity, $f(\Xb)$ can learn to generate all-zero joint angles for the LBS component (ignoring the input $\Xb$), and explain all deformations instead with $d$. That is, $M(f(\Xb), \Ub^d)=M(\mathbf{0}, \Ub^d)=\Ub^d \approx \Xb$, which reduces to the unsupervised version of~\cite{groueix20183d}. Instead of using explicit regularization to constrain $d$ (\eg $\|d(\phi(\Xb), \Ub^B)\|$), we propose a composition of two Chamfer distances as \begin{equation} \Lcal_{c^2,\lambda} = \Lcal_c\left(\Xb, \Vb^d\right) + \lambda \Lcal_c\left(\Xb, \Vb\right). \label{eq:c_chamfer} \end{equation} The second term in ~\eqref{eq:c_chamfer} enforces $f(\Xb)$ to learn correct joint angles even without template deformation. Lastly, we follow~\cite{kanazawa2018learning, groueix20183d} and apply Laplacian regularization $\Lcal_{\text{\tt lap}} = \|L\Vb^d\|$ to encourage smoothness of the deformed template, where $L$ is the discrete Laplace-Beltrami operator constructed from mesh $\Ub$ and its faces. \vspace{-8pt} \paragraph{LBS-based Autoencoder} The proposed algorithm can be interpreted as an encoder-decoder scheme. The joint angle regressor is the encoder, which compresses $\Xb$ into style codes $\phi(\Xb)$ and interpretable joint angles $f(\Xb)$. The decoder, different from standard autoencoders, is constructed by combining a human designed LBS function and a style deformation network $d$ on the base template. We call the proposed algorithm LBS-AE as shown in Figure~\ref{fig:dec}. \subsection{Structured Chamfer Distance} \label{sec:scd} To train an autoencoder, we have to define proper reconstruction errors for different data. In LBS-AE, the objective that provides information about input point clouds is only CD~\eqref{eq:chamfer}. However, it is known that CD has many undesirable local optima, which hinders the algorithm from improving. A local optimum example of CD is shown in Figure~\ref{fig:local}. To move the middle finger from the current estimate towards the index finger to fit the input, the Chamfer distance must increase before decreasing. This local optimum is caused by incorrect correspondences found by nearest neighbor search (the nearest neighbor of the middle finger of the current estimate is the ring finger of the input). \begin{figure} \centering \begin{subfigure}[b]{0.10\textwidth} \centering \includegraphics[trim={50 10 10 10},clip,width=\textwidth]{figs/others/target} \vspace{-20pt} \caption{Input} \label{fig:local_t} \end{subfigure} \begin{subfigure}[b]{0.10\textwidth} \centering \includegraphics[trim={50 10 10 10},clip,width=\textwidth]{figs/others/local} \vspace{-20pt} \caption{Estimate} \label{fig:local_e} \end{subfigure} \begin{subfigure}[b]{0.26\textwidth} \centering \includegraphics[width=\textwidth]{figs/others/chamfer_local} \label{fig:d_template} \vspace{-20pt} \caption{} \end{subfigure} \vspace{-5pt} \caption{When we try to move the middle finger of the current estimate (b) toward the target (a), the Chamfer distance increases before decreasing, showing a local optimum that is difficult to overcome.} \label{fig:local} \vspace{-15pt} \end{figure} \paragraph{High-Level Correspondence} Given a pair of sets $(\Vb, \Xb)$, for each $v \in \Vb$, we want to find its correspondence $\Ccal_\Xb(v)$ in $\Xb$. In CD, we use the nearest neighbor $\Ncal_\Xb(v)$ to approximate $\Ccal_\Xb(v)$, which can be wrong, as shown in Figure~\ref{fig:local}. Instead of searching for nearest neighbors $\Ncal_\Xb(v)$ over the entire set $X$, we propose to search within a subset $X' \subset X$, where $\Ccal_\Xb(v) \in X'$, by eliminating irrelevant points in $\Xb$. Following this idea, we partition $\Xb$ into $k$ subsets, $\Xb^1 \dots \Xb^k$, where we use $s(x; \Xb)\in \{1, \dots, k\}$ to denote which subset $x$ belongs to. A desirable partition should ensure $s(v; \Vb) =s(\Ccal_\Xb(v); \Xb)$; then, to find the nearest neighbor of $v$, we need only consider $\Xb^{s(v)}\subset \Xb$. We then define the \emph{Structured Chamfer Distance} (SCD) as $\Lcal_s(\Xb, \Vb)=$ \begin{equation} \frac{1}{n}\sum_{i=1}^n \| x_i - \Ncal_{\Vb^{s(x)}}(x_i) \|^2 + \frac{1}{m}\sum_{j=1}^m \| v_j - \Ncal_{\Xb^{s(v)}}(v_j) \|^2, \label{eq:s_chamfer} \end{equation} where we ease the notation of $s(x, \Xb)$ and $s(v, \Vb)$ to be $s(x)$ and $s(v)$. Compared with CD, which finds nearest neighbors from \emph{all to all}, SCD uses \emph{region to region} based on the high-level correspondence by leveraging the structure of data. Similar to~\eqref{eq:c_chamfer}, we define \begin{equation} \Lcal_{s^2,\lambda} = \Lcal_s\left(\Xb, \Vb^d\right) + \lambda \Lcal_s\left(\Xb, \Vb\right). \label{eq:c_s_chamfer} \end{equation} \setlength{\columnsep}{5pt} \begin{wrapfigure}[7]{r}{0.45\linewidth} \centering \vspace{-10pt} \includegraphics[clip,width=1\linewidth]{figs/others/partitions.pdf} \vspace{-18pt} \caption{Joint Partitions.} \label{fig:partition} \end{wrapfigure} In this paper, we partition the vertices based on the LBS skinning weights at a chosen granularity. Examples of hand and body data are shown in Figure~\ref{fig:partition}, which use the structure and our prior knowledge of the human body. These satisfy the property that the true correspondence is within the same partition. With the proposed SCD, we can improve the local optimum in Figure~\ref{fig:local}. \paragraph{Segmentation Inference} For the deformed mesh $\Vb$, we can easily infer the partition $s(v;\Vb)$, because the mapping between vertices and joints is defined by the LBS skinning weights $w$. We directly use $\argmax_j w_{i,j}$ as labels. Without additional labeling or keypoint information, the difficulty is to infer $s(x;\Xb)$ for $x \in \Xb$, which is a point cloud segmentation task~\cite{qi2017pointnet}. However, without labels for $\Xb$, we are not able to train a segmentation model on $\Xb$ directly. Instead, similar to the self-supervision technique used for training the joint angle regressor, we propose to train a segmentation network $s$ with the data $(\Vb^d, \Yb)$ generated by LBS, where $\Yb$ are the labels for $w$ defined in LBS and $\Vb=M(\Theta, \Ub^d)$. Note that $\Theta$ follows the same distribution as before, which contains uniform sampling for exploration and perturbation of the inferred angles $f(\Xb)$, as shown in Figure~\ref{fig:mix}. Instead of using the base template $\Ub$ only, we use the inferred deformed template $\Ub^d$ to adapt to the real data modality, which improves performance (see Section \ref{sec:seg_exp}). \begin{figure}[t] \centering \includegraphics[width=1.0\linewidth]{figs/others/mix2} \caption{The mixture distribution of self-supervision data from the LBS at iteration $t$. We sample from (1) the perturbed distribution centered at the $f_t(\Xb_i)$ and (2) a uniform distribution.} \label{fig:mix} \end{figure} The final objective for training the shape deformation pipeline including $f(\cdot)$ and $d(\cdot)$ is\footnote{We use $\lambda=0.5$, $\lambda_{\text{\tt lap}}=0.005$, $\lambda_\theta=0.5$ in all experiments.} \begin{equation} \Lcal = \Lcal_{c^2, 0.5} + \lambda_s \Lcal_{s^2, 0.5} + \lambda_{\text{\tt lap}} \Lcal_{\text{\tt lap}} + \lambda_{\theta} \Lcal_{\Theta}, \label{eq:all} \end{equation} and we use standard cross-entropy for training $s$. In practice, since $s$ is noisy during the first iterations, we pretrain it for $50K$ iterations with poses from uniform distributions over joint angles. Note that, for pretraining, we can only use the base template $\Ub$ to synthesize data. After that, we then learn everything jointly by updating each network alternatively. The final algorithm, LBS-AE with SCD as reconstruction loss, is shown in Algorithm~\ref{algo:lbsae}. \begin{algorithm}[t] \caption{LBS-AE with SCD} \label{algo:lbsae} \begin{algorithmic} \STATE\textbf{Inputs:} \textbullet~Point Clouds: $\{\Xb\}$ \\ \hspace{33pt}\textbullet~LBS: $M(;w, K, \Ub)$ and angle ranges $(R_l, R_u)$ \vspace{-10pt} \STATE Pretrain $s$ on uniformly sampled poses from LBS \STATE\textbf{while} $f$ and $d$ have not converged: \STATE\hspace{8pt}1. Sample minibatch $\{\Xb_i\}_{i=1}^B$, $\{\Xb_i'\}_{i=1}^B$ \STATE\hspace{8pt}2. $\Theta'= \{ f(\Xb_i)+\epsilon_i \}_{i=1}^B \cup \Theta_r\sim \mbox{Unif}(R_l,R_u)$ \STATE\hspace{8pt}3. Generate $(\Vb^d, \Yb)$ based on $\Theta'$ to update $s$ \STATE\hspace{8pt}4. Infer segmentation labels $\{s(\Xb_i')\}_{i=1}^B$ \STATE\hspace{8pt}5. Update $f$ and $d$ based on (1)-(3) (Eq.~\eqref{eq:all}) \end{algorithmic} \end{algorithm} \section{Related Works} \paragraph{LBS Extensions} Various extensions have been proposed to fix some of the shortcomings of LBS~\cite{lewis2000pose, sloan2001shape, wang2002multi, kavan2005spherical, rhee2006real, joshi2007harmonic, kavan2008geometric, le2012smooth, zuffi2015stitched, loper2015smpl, bailey2018fast}, where we only name afew here. The proposed template deformation follows the idea of~\cite{kurihara2004modeling, rhee2006real, zuffi2015stitched, loper2015smpl} to model the modalities and corrections of LBS on the base template rest pose. \cite{zuffi2015stitched,loper2015smpl} use PCA-like algorithms to model modalities via a weighted sum of learned shape basis. Instead, our approach is similar to~\cite{bailey2018fast} by learning modalities via a deformation network. The main difference between LBS-AE and~\cite{zuffi2015stitched, loper2015smpl, bailey2018fast} is we do not rely on correspondence information to learn the template deformation $d$ a priori. We simultaneously learn $d$ and infer pose parameters without external labeling. \vspace{-10pt} \paragraph{Deep Learning for 3D Data} Many deep learning techniques have been developed for different types of 3D information, such as 3D voxels~\cite{girdhar2016learning, wu20153d,wu2016learning}, geometry images~\cite{sinha2016deep, sinha2017surfnet}, meshes~\cite{bronstein2017geometric}, depth maps~\cite{wang2016action} and point clouds~\cite{qi2017pointnet, qi2017pointnet++, zaheer2017deep}. Autoencoders for point clouds are explored by~\cite{yang2018foldingnet, groueix2018atlasnet, li2018point, achlioptas2018learning}. \vspace{-10pt} \paragraph{Model Fitting with Different Knowledge} Different works have studied to registration via fitting a mesh model by leveraging different levels of information about the data. \cite{kanazawa2018end} use SMPL~\cite{loper2015smpl} to reconstruct meshes from images by using key points and prior knowledge of distributions of pose parameters. \cite{kanazawa2018learning} explore using a template instead of a controllable model to reconstruct the mesh with key points. \cite{bogo2016keep, joo2018total} also adopt pretrained key point detectors from other sources of data as supervision. Simultaneous training to improve model fitting and key point detection are explored by~\cite{lassner2017unite, mehta2017vnect}. The main difference from the proposed joint training in LBS-AE is we do not rely on an additional source of real-world data to pretrain networks, as needed to train these key point detectors. \cite{wei2016dense} share a similar idea of using segmentation for nearest neighbor search, but they trained the segmentation from labeled examples. \cite{genova2018unsupervised} propose to control morphable models instead of rig models for modeling faces. They also utilize prior knowledge of the 3DMM parameter distributions for real faces. We note that most of the works discussed above aim to recover 3D models from images. \cite{groueix20183d} is the most related work to the proposed LBS-AE, but doesn't use LBS-based deformation. They use a base template and learn the full deformation process with a neural network trained by correspondences provided a priori or from nearest neighbor search. More comparison between~\cite{groueix20183d} and LBS-AE will be studied in Section~\ref{sec:exp}. Lastly, learning body segmentation via SMPL is studied by~\cite{varol2017learning}, but with a focus on learning a segmentation using SMPL with parameters inferred from real-world data to synthesize training examples. \vspace{-5pt} \paragraph{Loss Function with Auxiliary Neural Networks} Using auxiliary neural networks to define objectives for training targeted models is also broadly studied in GAN literature (\eg~\cite{goodfellow2014generative, mao2016least, nowozin2016f, arjovsky2017wasserstein, li2017mmd, mroueh2017fisher, gulrajani2017improved}). \cite{li2018point} use a GAN loss for matching input and reconstructed point clouds. By leveraging prior knowledge, the auxiliary network adopted by LBS-AE is an interpretable segmentation network which can be trained without adversarial training.
{'timestamp': '2019-04-24T02:01:43', 'yymm': '1904', 'arxiv_id': '1904.10037', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.10037'}
arxiv
\section{Introduction} The increasing availability of videos and their importance in application domains, such as social media and surveillance, has created a pressing need for automated video analysis methods. A particular challenge arises in long video clips which have noisy or nonexistent labels, which are common in many settings including surveillance and instructional videos. While classical video retrieval works at the level of entire clips, a more challenging and important task is to efficiently sift through large amounts of unorganized video content and retrieve specific moments of interest. A promising formulation of this task is the paradigm of temporal activity localization via language query (TALL), which was introduced by Gao et al.~\cite{gao2017tall} and Hendricks et al.~\cite{hendricks2017localizing}. The TALL task is illustrated in Fig.~\ref{fig:howtotrip} and shows a few frames from a climbing video along with a language query describing the event of interest ``Climber adjusts his feet for the first time.'' In the figure the green frame denotes the desired output, the first frame in which the feet are being adjusted. Note that the solution to this problem requires local and global temporal information: local cues are needed to identify the specific frame in which the feet are adjusted, but global cues are also needed to identify the first time this occurs, since the climber adjusts his feet throughout the clip. \begin{figure}[t] \centering \includegraphics[width=3.1in]{tripping-motivation.pdf} \caption {Figure demonstrating video search method where given an input query, a human would normally forward the video until relevant objects or objects arrive and then proceed slowly to obtain the appropriate temporal boundaries.} \label{fig:howtotrip} \vspace{-0.2in} \end{figure} The MCN~\cite{hendricks2017localizing} and CTRL~\cite{gao2017tall} architectures, along with more recent work by Yuan et al.~\cite{yuan2018find}, have obtained encouraging results for the TALL task, however, they all suffer from a significant limitation which we address in this paper: Existing methods construct temporally-dense representations of the entire video clip which are then analyzed to identify the target events. This can be very inefficient in long video clips, where the target might be a single short moment. This approach starkly contrasts to how humans search for events of interest, as illustrated schematically in Fig.~\ref{fig:howtotrip}. A human would fast-forward through the video from the beginning, effectively sampling sparse sets of frames until they got closer to the region of interest. Then, they would look frame-by-frame until the start and end points are localized. At that point the search would terminate, leaving the vast majority of frames unexamined. Note that efficient solutions must go well beyond simple heuristics, since events of interest can occur anywhere within a target clip and the global position may not be obvious from the query. In order to develop an efficient solution to the TALL task it is necessary to address two main challenges: 1) Devising an effective joint representation (embedding) of video and language features to support localization; and 2) Learning an efficient search strategy that can mimic the human ability to sample a video clip intelligently to localize an event of interest. Most prior works on TALL address the issue of constructing a joint embedding space through a sliding window approach that pools at different temporal scales. This strategy has achieved some success, but it is not well suited for efficient search because it provides only a coarse control over which frames are evaluated. In contrast, our usage of gated-attention architecture is effective in aligning the text queries, which often consist of an object and its attributes or an action, with the video features that consist of convolutional filters that can identify these elements. Two prior works~\cite{yuan2018find,xu2018text} also utilize an attention model, but they do not address its use in efficient search. We address the challenge of efficient search through a combination of reinforcement learning (RL) and fine-grained video analysis. Our approach is inspired in part by strategies used by human video annotators. In addition, we make an analogy to the success of RL in language-guided navigation tasks in 3D environments~\cite{anderson2018vision, chaplot2018gated, das2018embodied, gordon2018iqa}. Specifically, we make an analogy between temporally localizing events in a video through playback controls and the actions an agent would take to navigate around an environment looking for a specific object of interest. We share with the navigation task, the fact that labeled data is not available for explicitly modeling the relationship between actions and rewards, but it is possible to learn a model through simulation. Our approach to temporal localization uses a novel architecture for combining the multi-modal video and text features with a policy learning module that learns to step forward and rewind the video and receives awards for accurate temporal localization. In summary this paper makes two contributions: First, we present a novel end-to-end reinforcement learning framework called TripNet that addresses the problem of temporal activity localization via a language query. TripNet uses gated-attention to align text and visual features, leading to improved accuracy. Second, we present experimental results on the datasets Charades-STA~\cite{gao2017tall}, ActivityNet Captions~\cite{krishna2017dense} and TACoS~\cite{rohrbach2012database}. These results demonstrate that TripNet achieves state of the art results in accuracy while significantly increasing efficiency, by evaluating only 32-41\% of the total video. \section{Related Work} \paragraph{Querying using Natural Language} This paper is most-closely related to prior works on the TALL problem, beginning with the two works~\cite{gao2017tall,hendricks2017localizing} that introduced it. These works additionally introduced a dataset for the task, Charades-STA\cite{gao2017tall} and DiDeMo\cite{hendricks2017localizing}. Each dataset contains untrimmed videos with multiple sentence queries and the corresponding start and end timestamp of the clip within the video. The two papers adopt a supervised cross modal embedding approach, in which sentences and videos are projected into a embedding space, optimized so that queries and their corresponding video clips will lie close together, while non-corresponding clips will be far apart. At test time both approaches run a sliding window across the video and compute an alignment score between the candidate window and the language query. The window with the highest score is then selected as the localized query. Follow-up works on the TALL task have differed in the design of the embedding process~\cite{chen2018temporally}. \cite{liu2018attentive,song2018val,yuan2018find} modified the original approach by adding self-attention and co-attention to the embedding process. \cite{xu2018text} introduces early fusion of the text queries and video features rather than using an attention mechanism. Additionally, \cite{xu2018text} uses the text to produce activity segment proposals as their candidate windows instead of using a fixed sliding window approach. Pre-processing of the sentence queries has not been a primary focus of previous works, with most methods using a simple LSTM based architecture for sentence embedding, with Glove~\cite{pennington2014glove} or Skip-Thought~\cite{kiros2015skip} vectors to represent the sentences. Other work in video-based localization which predated TALL either uses a limited set of text vocabulary to search for specific events or uses structured videos~\cite{bojanowski2015weakly,sener2015unsupervised,tellex2009towards,hahn2018learning}. Other earlier works address the task of retrieving objects using natural language questions, which is less complex than than localizing actions in videos~\cite{hu2016natural,johnson2017clevr,mao2016generation}. \vspace{-0.1in} \paragraph{Temporal Localization} Temporal action localization refers to localizing activities over a known set of action labels in untrimmed videos. Some existing work in this area has found success by extracting CNN features from the video frames, pooling the features and feeding them into either single or multi-stage classifiers to obtain action predictions, along with temporal labels~\cite{chao2018rethinking,dai2017temporal,yuan2016temporal,xu2017r}. These methods use a sliding window approach. Often, multiple window sizes are used and candidate windows are densely sampled, meaning that the candidates overlap with each other. This method has high accuracy, but it is an exhaustive search method that leads to high computational costs. There are also TALL methods that forgo the end-to-end approach and instead use a two-stage approach: first generating temporal proposals, and second, classifying the proposals into action categories~\cite{buch2017sst, gao2017cascaded, ghosh2019excl, ge2019mac, heilbron2017scc, shou2017cdc, rodriguez2020proposal, shou2016temporal}. Unlike both sets of previous methods, our proposed model TripNet, uses reinforcement learning to perform temporal localization using natural language queries. In action-recognition methods~\cite{bian2017revisiting, ma2018attend, donahue2015long, liu2009recognizing, miech2017learnable,sigurdsson2016asynchronous, tran2014c3d}, Frame glimpse~\cite{yeung2016end} and Action Search~\cite{alwassel2018action} use reinforcement learning to identify an action while looking at the smallest possible number of frames. These works focus only on classifying actions (as opposed to parsing natural language activities) in trimmed videos and and the former does not perform any type of temporal boundary localization. A recent work~\cite{he2019read} also uses RL to learn the temporal video boundaries. However, it analyzes the entire video and does not focus on the efficiency of localizing the action. Another work~\cite{wang2019language}, uses RL to estimate the activity location using fixed temporal boundaries. Furthermore, it uses Faster R-CNN trained on the Visual Genome dataset to provide semantic concepts to the model. \vspace{-0.1in} \paragraph{3D navigation and Reinforcement Learning} Locating a specific activity within a video using a reinforcement learning agent is analogous to the task of navigating through a three dimensional world. How can we efficiently learn to navigate through the temporal landscape of the video? The parallels between our approach and navigation lead us to additionally review the related work in the areas of language-based navigation and embodied perception~\cite{anderson2018vision,gordon2018iqa}. Recently, the task of Embodied Question Answering~\cite{das2018embodied} was introduced. In this task, an agent is asked questions about the environment, such as ``what color is the bathtub,'' and the agent must navigate to the bathtub and answer the question. The method introduced in \cite{das2018embodied} focuses on grounding the language of the question not directly into the pixels of the scene but into actions for navigating around the scene. We seek to ground our text query into actions for skipping around the video to narrow down on the correct clip. Another recent work ~\cite{chaplot2018gated} explores giving visually grounded instructions such as ``go to the green red torch'' to an agent and having them learn to navigate their environment to find the object and complete the instruction. \section{Methods} \noindent We now describe TripNet, an end to end reinforcement learning method for localizing and retrieving temporal activities in videos given a natural language query as shown in Figure ~\ref{fig:tripnet-model}. {\bf Problem Formulation:} The localization problem that we solve is defined as follows: Given an untrimmed video $V$ and a language query $L$, our goal is to temporally localize the specific clip $W$ in $V$ which is described by $L$. In other words, let us denote the untrimmed video as $V = \{f_n\}^N_{n=1}$ where $N$ is the number of frames in the video, we want to find the clip $W = \{f_{n}, \ldots, f_{n+k}\}$ that corresponds best to $L$. It is possible to solve this problem efficiently because videos have an inherent temporal structure, such that an observation made at frame $n$ conveys information about frames both in the past and in the future. Some challenges of the problem are, how to encode the uncertainty in the location of the target event in a video, and how to update the uncertainty from successive observations. While a Bayesian formulation could be employed, the measurement and update model would need to be learned and supervision for this is not available. Since it is computationally feasible to simulate the search process (in fact it is only a one-dimensional space, in contrast to standard navigation tasks) we adopt an reinforcement learning (RL) approach. We are motivated by human annotators who observe a short clip and make a decision to skip forward or backward in the video by some number of frames, until they can narrow down to the target clip. We emulate this sequential decision process using RL. Using RL we train an agent that can steer a fixed sized window around the video to find $W$ without looking at all frames of $V$. We employ the actor-critic method A3C~\cite{mnih2016asynchronous} to learn the policy $\pi$ that maps $(V, L) \to W$. The intuition is that the agent will take large jumps around the video until it finds visual features that identify proximity to $L$, and then it will start to take smaller steps as it narrows in on the target clip. \begin{figure*}[t] \centering \includegraphics[width=\textwidth]{model.jpg} \caption{TripNet localizes specific moments in videos based on a natural language query. There are two main components of TripNet: the state processing module and the policy learning module. The state processing module encodes the state into a joint visual and linguistic representation which is then fed to the policy learning module on which it generates the action policy. The sampled action in this figure is skipping forward by j frames and the state is updated accordingly.} \label{fig:tripnet-model} \vspace{-0.2in} \end{figure*} \subsection{State and Action Space} At each time step, the agent observes the current state, which consists of the sentence $L$ and a candidate clip of the video. The clip is defined by a bounding window [$W_{start}$, $W_{end}$] where start and end are frame numbers. At time step $t=0$, the bounding window is set to [$0$, $X$], where X is the average length of annotated clips within the dataset.\footnote{Note that this means that the search process always starts at the beginning of the video. We also explored starting at the middle and end of the clip and found empirically that starting at the beginning performed the best.} This window size is fixed and does not change. At each time step the state processing module creates a state representation vector which is fed into the policy learning module, on which it generates an action policy. This policy is a distribution over all the possible actions. An action is then sampled according to the policy. Our action space consists of 7 predefined actions: move the entire bounding window $W_{start}$, $W_{end}$ forward or backward by $h$ frames, $j$ frames, or 1 second of frames or TERMINATE. Where $h = N/10$ and $j = N/5$. These navigation steps makes aligning the visual and text features easier. Making the RL agent explicitly learn the window size significantly increases the state space and leads to a drop in accuracy and efficiency with our current framework. However, an additional function to adjust the box width over the fixed window size could be learned, analogous to the refinement of the anchor boxes used in object detectors. These actions were chosen so that amount of movement is proportional to the length of the video. If the bounding window is at the start or end of the full video and an action is chosen that would push the bounding window outside the video's length, the bounding window remains the same as the previous time step. The action TERMINATE ends the search and returns the clip of the current state as the video clip predicted to be best matched to $L$. \subsection{TripNet architecture} We now describe the architecture of TripNet, which is illustrated in Figure \ref{fig:tripnet-model}. \paragraph{State Processing Module} At each time step, the state-processing module takes the current state as an input and outputs a joint-representation of the input video clip and the sentence query $L$. The joint representation is used by the policy learner to create an action policy from which the optimal action to take is sampled. The clip is fed into C3D \cite{tran2015learning} to extract the spatio-temporal features from the fifth convolutional layer. We mean-pool the C3D features across frames and denote the result as $x_M$. To encode the sentence query, we first pass $L$ through a Gated Recurrent Unit (GRU)~\cite{chung2014empirical} which outputs a vector $x_L$. We then transform the query embedding into an attention vector that we can apply to the video embedding. To do so, the sentence query embedding $x_L$ is passed through a fully connected linear layer with a sigmoid activation function. The output of this layer is expanded to be the same dimension of $x_M$. We call the output of the linear layer the attention vector, $att_L$. We perform a Hadamard multiplication between $att_L$ and $x_M$ and the result is output as the state representation $s_t$. This attention unit is our gated attention architecture for activity localization. Hence, the gated attention unit is designed to gate specific filters based on the attention vector from the language query~\cite{dhingra2016gated}. The gating mechanism allows the model to focus on specific filters that can attend to specific objects, and their attributes, from the query description. In our experiments, we implement an additional baseline using a simple concatenation operation between the video and text representations to demonstrate the effectiveness of our gated-attention architecture. Here, we only perform self-attention over the mean pooled C3D features. Then, we take a Skip-Thought~\cite{kiros2015skip} encoding of the sentence query and concatenate it with the features of the video frames to produce the state representation. In the experiments, we denote this method as TripNet-Concat. \paragraph{Policy Learning Module} We use an actor-critic method to model the sequential decision process of grounding the language query to a temporal video location. The module employs a deep neural network to learn the policy and value functions. The network consists of a fully connected linear layer followed by an LSTM, which is followed by a fully connected layer to output the value function $v(s_t|\theta_v)$ and fully connected layer to output the policy $\pi(a_t | s_t,\theta_\pi)$, for state, $s_t$ and action, $a_t$ at time $t$, $\theta_v$ is the critic branch parameters and $\theta_\pi$ is actor branch parameters. The policy, $\pi$, is a probabilistic distribution over all possible actions given the current state. Since we are trying to model a sequential problem we use an LSTM so that the system can have memory of the previous states which will inevitably positively impact the future actions. Specifically, we use the asynchronous actor-critic method known as A3C \cite{mnih2016asynchronous} with Generalized Advantage Estimation~\cite{schulman2015high} that reduces policy gradient variance. The method runs multiple parallel threads that each run their own episodes and update global network parameters at the end of the episode. Since the goal is to learn a policy that returns the best matching clip, we want to reward actions that bring the bounding windows [$W_{start}$, $W_{end}$] closer to the bounds of the ground truth clip. Hence, the action to take, should return a state that has a clip with more overlap with the ground-truth than the previous state. Therefore, we use reward shaping by having our reward be the difference of potentials between the previous state and current state. However, we want to ensure the agent is taking an efficient number of jumps and not excessively sampling the clip. In order to encourage this behavior, we give a small negative reward in proportion with the total number of steps thus far. As a result, the agent is encouraged to find the clip window as quickly as possible. We experiment to find the optimal negative reward factor $\beta$. We found using a negative reward factor results in the agent taking more actions with larger frame jump. Hence, our reward at any time step $t$ is calculated as follows: \small \begin{equation} reward_t = (IOU_t(s_t) - IOU_t(s_{t-1})) - \beta*t \end{equation} \normalsize where we set $\beta$ to .01. We calculate the IOU between the clip of the state at time $t$, [$W_{start}^t$, $W_{end}^t$], and the ground truth clip for sentence $L$, [$G_{start}$, $G_{end}$] as follows: \small \begin{equation} \label{iou} IOU_t = \frac{min(W_{end}^t,G_{end})-max(W_{start}^t,G_{start})}{max(W_{end}^t,G_{end})-min(W_{start}^t,G_{start})} \end{equation} \normalsize We use the common loss functions for A3C for the value and policy loss. For training the value function, we set the value loss to the mean squared loss between the discounted reward sum and the estimated value: \small \begin{equation} Loss_{value} = \sum_t (R_t- v(s_t|\theta_v))^2 * \gamma_1, \end{equation} \normalsize where we set $\gamma_1$ to .5 and $R_t$ is the accumulated reward. For training the policy function, we use the policy gradient loss: \small \begin{equation} \begin{aligned} Loss_{policy} =-\sum_t log(\pi(a_t|s_t,\theta_\pi)) *GAE(s_t) \\- \gamma_0*H(\pi(a_t|s_t,\theta_\pi)), \end{aligned} \end{equation} \normalsize where GAE is the generalized advantage estimation function, H is the calculation of entropy and $\gamma_0$ is set to 0.5. Therefore, the total loss for our policy learning module is: \small \begin{equation} Loss = Loss_\pi + \gamma_1 + Loss_v. \end{equation} \normalsize \section{Evaluation} \label{sec:eval} We evaluate the TripNet architecture on three video datasets, Charades-STA~\cite{gao2017tall}, ActivityNet Captions~\cite{krishna2017dense} and TACoS~\cite{regneri2013grounding}. Charades-STA was created for the moment retrieval task and the other datasets were created for video captioning, but are often used to evaluate the moment retrieval task. Note that we chose not to include the DiDeMo~\cite{hendricks2017localizing} dataset because the evaluation is based on splitting the video into 21 pre-defined segments, instead of utilizing continuously-variable start and end times. This would require a change in the set of actions for our agent. We do, however, compare our approach against the method from ~\cite{hendricks2017localizing} on other datasets. Please refer to supplementary materials for the details on the datasets as well as the implementation details of our system. \subsection{Experiments} \label{sec:exp} \setlength{\tabcolsep}{5pt} \begin{table*}[t] \begin{center} \resizebox{\textwidth}{!}{ \begin{tabular}{l c ccc c ccc c ccc} \toprule & & \multicolumn{3}{c}{ActivityNet} & & \multicolumn{3}{c}{TACoS} & & \multicolumn{3}{c}{Charades} \\\cmidrule(l{2pt}r{2pt}){3-5} \cmidrule(l{2pt}r{2pt}){7-9} \cmidrule(l{2pt}r{2pt}){10-12} Method && \multicolumn{1}{c}{\scriptsize $\[email protected]$}& \multicolumn{1}{c}{\scriptsize $\[email protected]$}& \multicolumn{1}{c}{\scriptsize $\[email protected]$}&& \multicolumn{1}{c}{\scriptsize $\[email protected]$}& \multicolumn{1}{c}{\scriptsize $\[email protected]$}& \multicolumn{1}{c}{\scriptsize $\[email protected]$}&& \multicolumn{1}{c}{\scriptsize $\[email protected]$}& \multicolumn{1}{c}{\scriptsize $\[email protected]$}& \multicolumn{1}{c}{\scriptsize $\[email protected]$} \\ \toprule MCN~\cite{hendricks2017localizing} && 21.37 & 9.58 & - && 1.64 & 1.25 & - && - & - & -\\ CTRL~\cite{gao2017tall} && 28.70 & 14.00 & - && 18.32 & 13.3 & - && - & 23.63 & 8.89\\ TGN~\cite{chen2018temporally} && 45.51 & 28.47 & - && 21.77 & 18.9 & - && - & - & -\\ ABLR~\cite{yuan2018find} && \textbf{55.67} & \textbf{36.79} & -&& - & - & - && - & - & -\\ ACRN~\cite{liu2018attentive} && 31.29 & 16.17 & - &&19.52 & 14.62 & - && - & - & -\\ MLVI~\cite{xu2018text} && 45.30 & 27.70 & 13.60 && - & - & - && \textbf{54.70} & 35.60 & 15.80\\ VAL \cite{song2018val} && - & - & - && 19.76 & 14.74 & - && - & 23.12 & 9.16\\ SM-RL\cite{wang2019language} && - & - & - && 20.25 & 15.95 & - && 24.36 & 11.17 & -\\ \midrule TripNet-Concat && 36.75 & 25.64 & 10.25 && 18.24 & 14.16 & 6.47 && 41.84 & 27.23 & 12.62\\ TripNet-GA && 48.42 & 32.19 & \textbf{13.93} && \textbf{23.95} & \textbf{19.17} & \textbf{9.52} && 54.64 & \textbf{38.29} & \textbf{16.07}\\ \bottomrule \end{tabular} } \caption{The accuracy of each method on ActivityNet, TACoS and Charades measured by IoU at multiple $\alpha$ values.} \label{tab:acc} \end{center} \end{table*} \paragraph{Evaluation Metric.} We use Intersection over Union (IoU) at different alpha thresholds to measure the difference between the ground truth clip and the clip that TripNet temporally aligns to the query. If a predicted window and the ground truth window have an IoU that is above the set alpha threshold, we classify the prediction as correct, otherwise we classify it as incorrect. See Equation \ref{iou} for how the IoU is calculated. The results over the different datasets and methods are shown in Table \ref{tab:acc}. Most previous work uses a R@k-IoU, which is a IoU score for the top k returned clips. These works used a sliding window approach allowing their alignment system to return k-top candidate windows based on confidence scores. In contrast, TripNet searches the video until it finds the best aligned clip and returns only that clip. As a result, all reported IoU scores are measured at R@1. \subsubsection{Comparison and Baseline Methods} We compare against other methods both from prior work and a baseline version of the TripNet architecture. The prior work we compare against is as follows: MCN~\cite{hendricks2017localizing}, CTRL~\cite{gao2017tall}, TGN~\cite{chen2018temporally}, ABLR~\cite{yuan2018find}, ACRN~\cite{liu2018attentive}, MLVI~\cite{xu2018text}, VAL~\cite{song2018val} and SM-RL~\cite{wang2019language}. Besides SM-RL, all prior works tackle the task by learning to jointly represent the ground truth moment clip and the moment description query. To generate candidate windows during testing, these methods go over the whole video using a sliding window and then, choose the candidate window that best corresponds to the query encoding. This methodology relies on seeing all frames of the video at least once, if not more, during test time. We provide accuracy results in Table \ref{tab:acc} for 3 datasets, compiling the performance numbers reported in the prior works for comparison to the performance of TripNet. We can see that, in terms of accuracy, TripNet outperforms all other methods on the Charades-STA and TACoS datasets, and that it performs comparably to the state of the art on ActivityNet Captions. Using a state processing module for TripNet that does not use attention (TripNet-Concat) performs consistently worse than the state processing module for TripNet that uses the gated attention architecture (TripNet-GA), since multi-modal fusion between vision and language shows improvement with different attention mechanisms. \small \begin{table}[t!] \begin{center} \footnotesize \resizebox{\textwidth}{!}{ \begin{tabular}{l c c c} \toprule \textbf{Dataset} & \% of Frames Used & Avg. \# Actions & Bounding Window Size\\ \toprule ActivityNet & 41.65 & 5.56 & 35.7s\\ Charades & 33.11 & 4.16 & 8.3s\\ TACoS & 32.7 & 9.84 & 8.0s\\ \toprule \end{tabular} } \vspace{0.1in} \caption{The efficiency of the TripNet architecture on different datasets. Number of actions includes the TERMINATE action. Size of the bounding window is in seconds. The methods were tested on the same Titan Xp GPU.} \label{tab:tripnet-eff} \vspace{-0.2in} \end{center} \end{table} \normalsize \small \begin{table} \begin{center} \footnotesize \resizebox{.6\textwidth}{!}{ \begin{tabular}{l c c c} \toprule Method & Charades & ActivityNet & TACoS\\ \toprule CTRL \cite{gao2017tall} & 44.19ms & 218.95ms & 342.12ms\\ MCN \cite{hendricks2017localizing} & 78.16ms & 499.32ms & 674.01ms\\ TGN \cite{chen2018temporally} & 18.2ms & 90.2ms & 144.7ms\\ TripNet-GA & 5.13ms & 6.23ms & 11.27ms\\ \toprule \end{tabular} } \vspace{0.1in} \caption{The average time in milliseconds that it takes to localize a moment on different datasets.} \label{tab:time} \vspace{-0.2in} \end{center} \end{table} \normalsize More specifically, in Table \ref{tab:acc}, ABLR processes all frames and encodes the intermediate representations of each frame and word using Bi-LSTM, followed by two levels of attention over it. It then regresses the coordinates over this comprehensive intermediate representation. Hence, this regression-based approach over all frames is beneficial for the TALL task. However, it is computationally inefficient to perform this processing over all frames. On the other hand, in our method feature extraction is only performed if requested by the RL step and is suitable for long surveillance videos where ABLR may not be practical. We also see an overall drop in performance of TripNet on TACoS, despite outperforming other recent work. We don't believe this is due to the length of the videos but instead due to the nature of the content in the video. TACoS contains long cooking videos all taken in the same kitchen making the dataset more difficult. While ActivityNet videos are up to four times longer than Charades-STA videos, TripNet is nonetheless able to maintain high accuracy on ActivityNet, illustrating TripNet's ability to scale to videos of different lengths. In the analysis of our results, we found that one source of IoU inaccuracy was the size of the bounding window. TripNet currently uses a fixed size bounding window that the agent moves around the video until it returns a predicted clip. The size of the fixed window is equal to the mean length of the ground truth annotated clips. A possible direction for future work would be to add actions that expand and contract the size of the bounding window. \subsubsection{Efficiency} We now describe how the different competing methods construct their candidate windows, in order to provide an understanding of the computational cost of each approach. \noindent MCN \cite{hendricks2017localizing}: creates 21 candidate windows across the video. CTRL \cite{gao2017tall}, VAL \cite{song2018val}, ACRN \cite{liu2018attentive}: use a sliding windows of multiple sizes to generate candidate windows. TGN \cite{chen2018temporally}: does not use a sliding window but generates candidate windows across the video at different scales. ABLR\cite{yuan2018find}: encodes the entire video and then uses attention via the language query to localize the clip. The method still requires two passes over the entire video. MLVI \cite{xu2018text}: trains a separate network to generate candidate window proposals. \textbf{TripNet}: TripNet is the only method that does not need to watch the entire video to temporally localize a described moment. Instead, our trained agent efficiently moves a candidate window around the video until it localizes the described clip. Measurements of efficiency are described in Table \ref{tab:tripnet-eff}. In order to get a better understanding of efficiency, we run the CTRL ~\cite{gao2017tall}, TGN \cite{chen2018temporally}, MCN \cite{hendricks2017localizing}, and TripNet-GA over the dataset test splits and compute the average time it takes to localize a moment in the video. This is shown in Table~\ref{tab:time}. \subsubsection{Qualitative Results} In Figure \ref{fig:qualresult}, we show the qualitative results of TripNet-GA on the Charades-STA dataset. In the figure, we show the sequential list of actions the agent takes in order to temporally localize a moment in the video. The green boxes represent the bounding window of the state at time t and the yellow box represents the ground truth bounding window. The first video is 33 seconds long (792 frames) and the second video is 20 seconds long (480 frames). In both examples the agent skips both backwards and forwards. In the first example, TripNet sees 408 of the frames of the video, which is 51\% of the video. In the second example TripNet sees 384 frames of the video, which is 80\% of the frames. \begin{figure*}[h!] \centering \includegraphics[width=\textwidth]{result.jpg} \caption{Qualitative performance of TripNet-GA: We show two examples where the TripNet agent skips through the video looking at different candidate windows before terminating the search. Both these videos are from the Charades-STA dataset.} \label{fig:qualresult} \vspace{-0.1in} \end{figure* \section{Conclusion} \label{sec:conclusion} Localizing moments in long, untrimmed videos using natural language queries is a useful and challenging task for fine-grained video retrieval. Most previous works are designed to analyze 100\% of the video frames. In this paper, we have introduced a system that uses a gated-attention mechanism over cross-modal features to automatically localize a moment in time given a natural language text query with high accuracy. Our model incorporates a policy network which is trained for efficient search performance, resulting in an system that on average examines less then 50\% of the video frames in order to localize a clip of interest, while achieving a high level of accuracy.
{'timestamp': '2020-08-19T02:22:38', 'yymm': '1904', 'arxiv_id': '1904.09936', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.09936'}
arxiv
\section{Introduction} In this paper we re-examine part of the Linear-Time spectrum that forms part of the field of study of van Glabbeek in~\cite{vG1,vG2}, specifically the part characterised by {\em finite linear} observations. A number of different forms of process calculus have been developed for the modeling of concurrent programs, including Hoare's Communicating Sequential Processes (CSP)~\cite{hoare1985communicating}, Milner's Calculus of Communicating Systems (CCS)~\cite{milner1986calculus}, and the $\pi$-calculus~\cite{milner1992calculus}. Unlike the latter two, CSP's semantics are traditionally given in behavioural semantic models coarser than bisimulation, normally ones that depend on linear observations only. Thus, while the immediate range of options possible from a state can be observed, only one of them can be followed in a linear observation and so branching behaviour is not recorded. In this paper, we study finite\footnote{Models that use a mixture of finite and infinite linear behaviours are also frequently used, the latter involving, {\em inter alia}, divergences and infinite traces.} linear-time observational models for CSP; that is, models where all observations considered can be determined in a finite time by an experimenter who can see the visible events a process communicates and the sets of events it can offer in any stable state. While the experimenter can run the process arbitrarily often, he or she can only record the results of individual finite executions. Thus each behaviour recorded can be deduced from a single finite sequence of events and the visible events that link them, together with the sets of events accepted in stable states during and immediately after this \emph{trace}. The representation in the model is determined purely by the sent of these linear behaviours that it is possible to observe of the process being examined. At least six such models have been actively considered for CSP, but the state-of-the art refinement checking tool, FDR4~\cite{fdr3,fdr3j}\footnote{See {\tt https://www.cs.ox.ac.uk/projects/fdr/}. At the time of writing there is no major academic paper as a source for FDR4 as opposed to its predecessor FDR3.}, currently only supports two, namely \emph{traces} and \emph{ stable failures}\footnote{The word {\em stable} here emphasises that the refusal components of failures are only recorded in stable (namely $\tau$-free) states. This distinguishes it both from other models where failures are recorded for other reasons: van Glabbeek (private correspondence) argues that there is in fact an {\em unstable} failures model (though anything but finite observation), citing~\cite{ufm} as evidence, and several versions have included failures on divergent traces or because of divergence-strictness. We emphasise that all of the models considered in this paper only observe acceptances and refusals in stable states.}. FDR4 also supports the (divergence-strict) failures-divergences model, which is not finite observational. The question we address in this paper supposes that we have an automated proof tool such as FDR that answers questions about how a process is represented in model A, and asks under what circumstances it is possible to answer questions posed in model B, especially the core property of refinement. It seems intuitive that if model A records more details than model B, then by looking carefully at how A codes the details recorded in B, the above ought to be possible. We will later see some techniques for achieving this. However it does not intuitively seem likely that we can do the reverse. Surprisingly, however, we find it can be done by the use of process operators for which the coarser model B is not compositional. Sometimes we can use such operators to transform observable features of behaviour that B does not see into ones that it does. The operator we choose in the world of CSP is the relatively new {\em priority} operator. While simple to define in operational semantics, this is only compositional over the finest possible finite-linear-obseration model of CSP. Priority is not part of ``standard'' CSP, but is implemented in the model checker FDR4 and greatly extends the expressive power of the notation. We present first a construction which produces a context $\mathcal{C}$ such that refinement questions in the well-known stable failures model correspond to trace refinement questions under the application of $\mathcal{C}$. We then generalise this to show (Theorem \ref{thm:ratshift}) that a similar construction is possible not only for the six models which have been studied, but also for any sensible finite observational model (where `sensible' means that the model can be recognised by a finite-memory computer, in a sense which we shall make precise). In fact we can seemingly handle any equivalence determined in a compact way by finitary observations, even though not a congruence. We first briefly describe the language of CSP. We next give an informal description of our construction for the stable failures model. To prove the result in full generality, we first give a formal definition of a finite observational model, and of the notion of rationality. We then describe our general construction. In a case study we consider the discrete version of the Timed Failures model of Timed CSP, a closely related notation which already depends on priority thanks to its need to enforce the principle of maximal progress. For that we show not only how model shifting can obtain exactly what is needed but also show how Timed Failures checking can be reduced to its relative Refusal Testing. Finally we discuss performance and optimisation issues. The present paper is a revised and extended version of~\cite{msh}, with the main additions being the study of Timed CSP and the model translation options available there, plus a description of how to include CSP termination $\tick$. \section{The CSP language} We provide a brief outline of the language, largely taken from \cite{roscoe2009revivals}; the reader is encouraged to consult \cite{roscoe2010understanding} for a more comprehensive treatment. Throughout, $\Sigma$ is taken to be a finite nonempty set of communications that are visible and can only happen when the observing environment permits via handshaken communication. The actions of every process are taken from $\Sigma\cup\{\tau\}$, where $\tau$ is the invisible internal action that cannot be prevented by the environment. We extend this to $\Sigma\cup\{\tau,\tick\}$ if we want the language to allow the successful termination process $\mathord{\csp@skip}$ and sequential compositions as described below. $\tick$ is different from other events, because it is observable but not controllable: in that sense it is between a regular $\Sigma$ event and $\tau$. It only ever appears at the end of traces and from a state which has refusal set $\Sigma$ and acceptance set $\{\tick\}$, although that state is not stable in the usual sense. It thus complicates matters a little so the reader might prefer to ignore it when first studying this paper. We will later contemplate a second event with special semantics: $tock$ signifying the passage of time. The constant processes of our core version of CSP are: \begin{itemize} \item $\mathord{\csp@stop}$ which does nothing---a representation of deadlock. \item $\mathord{\csp@divergence}$ which performs (only) an infinite sequence of internal $\tau$ actions---a representation of divergence or livelock. \item $\mathord{\csp@chaos}$ which can do anything except diverge, though this absence of divergence is unimportant when studying finite behaviour models. \item $\mathord{\csp@skip}$ which terminates successfully. \end{itemize} The prefixing operator introduces communication: \begin{itemize} \item $a\mathrel{\csp@then} P$ communicates the event $a$ before behaving like $P$. \end{itemize} There are two main forms of binary choice between a pair of processes:\begin{itemize} \item $P\mathrel{\csp@intchoice} Q$ lets the process decide to behave like $P$ or like $Q$: this is \emph{nondeterministic} or \emph{internal} choice. \item $P\mathrel{\csp@extchoice} Q$ offers the environment the choice between the initial $\Sigma$-events of $P$ and $Q$. If the one selected is unambiguous then it continues to behave like the one chosen; if it is an initial event of both then the subsequent behaviour is nondeterministic. The occurence of $\tau$ in one of $P$ and $Q$ does \emph{not} resolve the choice (unlike CCS $+$). This is \emph{external} choice. \end{itemize} A further form of binary choice is the asymmetric $P\rhd Q$, sometimes called {\em sliding} choice. This offers any initial visible action of $P$ from an unstable (in the combination) state and can (until such an action happens) perform a $\tau$ action to $Q$. It can be re-written in terms of prefix, external choice and hiding. It represents a convenient shorthand way of creating processes in which visible actions happen from an unstable state, so this is not an operator one is likely to use much for building practical systems, rather a tool for analysing how systems can behave. As discussed in~\cite{roscoe2010understanding}, to give a full treatment of CSP in any model finer than stable failures, it is necessary to contemplate processes that have visible actions performed from unstable states. We only have a single parallel operator in our core language since all the usual ones of CSP can be defined in terms of it as discussed in Chapter 2 etc. of \cite{roscoe2010understanding}. \begin{itemize} \item $P\@ifnextchar[{\@dparallel}{\mathrel{\csp@parallel}}[X]Q$ runs $P$ and $Q$ in parallel, allowing each of them to perform any action in $\Sigma\setminus X$ independently, whereas actions in $X$ must be synchronised between the two. \end{itemize} There are two operators that change the nature of a process's communications. \begin{itemize} \item $P\mathrel{\csp@hide} X$, for $X\subseteq\Sigma$, \emph{hides} $X$ by turning all $P$'s $X$-actions into $\tau$s. \item $P\rename{R}$ applies the \emph{renaming} relation $R\subseteq\Sigma\times\Sigma$ to $P$: if $(a,b)\in R$ and $P$ can perform $a$, then $P\rename{R}$ can perform $b$. The domain of $R$ must include all visible events used by $P$. Renaming by the relation $\{(a,b)\}$ is denoted $\rensubs{a}{b}$. \item Sequential composition $P;Q$ allows $P$ to run until it terminates successfully ($\tick$). $P$'s $\tick$ is turned into $\tau$ and then $Q$ is started. So if $P$ and $Q$ respectively have traces $s\csp@cat\trace{\tick}$ and $t$, then $P;Q$ has the trace $s\csp@cat t$. \end{itemize} There is another operator that allows one process to follow another: \begin{itemize} \item $P\:\Theta_{a:A} \:Q$ behaves like $P$ until an event in the set $A$ occurs, at which point $P$ is shut down and $Q$ is started. This is the \emph{throw} operator, and it is important for establishing clean expressivity results. \end{itemize} The final CSP construct is \emph{recursion}: this can be single or mutual (including mutual recursions over infinite parameter spaces), can be defined by systems of equations or (in the case of single recursion) in line via the notation $\rec{p}{P}$, for a term $P$ that may include the free process identifier $p$. Recursion can be interpreted operationally as having a $\tau$-action corresponding to a single unwinding. Denotationally, we regard $P$ as a function on the space of denotations, and interpret $\rec{p}{P}$ as the least (or sometimes provably unique) fixed point of this function. We also make use of the \emph{interleaving} operator $\mathrel{\csp@interleave}$, which allows processes to perform actions independently and is equivalent to $\@ifnextchar[{\@dparallel}{\mathrel{\csp@parallel}}[\emptyset]$, and the process $\mathord{\csp@run}_X$, which always offers every element of the set $X$ and is defined by \[\mathord{\csp@run}_X=\mathop{\csp@bigextchoice}\nolimits_{x\in X}x\mathrel{\csp@then}\mathord{\csp@run}_X\] This completes our list of operators other than priority. While others, for example $\triangle$ (interrupt) are sometimes used, they are all expressible in terms of the above (see ch.9 of \cite{roscoe2010understanding}). \subsection{Priority} The priority operator is introduced and discussed in detail in Chapter 20 of \cite{roscoe2010understanding} as well as \cite{priexp}. It allows us to specify an ordering on the set of visible events $\Sigma$, and prevents lower-priority events from occuring whenever a higher-priority event or $\tau$ is available. The operator described in \cite{roscoe2010understanding} as implemented in FDR4~\cite{fdr3} is parametrised by three arguments: a process $P$, a partial order $\leq$ on the event set $\Sigma$, and a subset $X\subseteq\Sigma$ of events that can occur when a $\tau$ is available. We require that all elements of $X$ are maximal with respect to $\leq$ and additionally require that if $a$ is any event incomparable to $\tau$, then $a$ is also maximal. Failing to respect these principles means that the operator might undermine some basic principles of CSP. Writing $\mathit{initials}(P)\subseteq\Sigma\cup\{\tau\}$ for the set of events that $P$ can immediately perform, and extending $\leq$ to a partial order on $\Sigma\cup\{\tau\}$ by adding $y\leq\tau\forall y\in\Sigma\setminus X$, we define the operational semantics of $\mathrm{\bf prioritise}$ as follows: \[\frac{P\@ifnextchar[{\@trans}{\transcommandoperatortype{\longrightarrow}}[a] P'\land\forall b\neq a.a\leq b\Rightarrow b\notin\mathit{initials}(P)}{\mathrm{\bf prioritise}(P,\leq,X)\@ifnextchar[{\@trans}{\transcommandoperatortype{\longrightarrow}}[a]\mathrm{\bf prioritise}(P',\leq,X)} \:(a\in\Sigma\cup\{\tau\}).\] $\mathrm{\bf prioritise}$ makes enormous contributions to the expressive power of CSP as explained in~\cite{priexp}, meaning that CSP+$\mathrm{\bf prioritise}$ can be considered a universal language for a much wider class of operational semantics than the {\em CSP-like} class described in~\cite{cspexpr,roscoe2010understanding}. It should not therefore be surprising that $\mathrm{\bf prioritise}$ is not compositional over denotational finite observation models other than the most precise model, as we will discuss below. So we think of it as an optional addition to CSP rather than an integral part of it; when we refer below to particular types of observation as giving rise to valid models for CSP, we will mean CSP without priority. If we admit successful termination $\tick$, then it must have the same priority as $\tau$. \section{Example: the stable failures model} We introduce our model shifting construction using the \emph{stable failures} model: we will produce a context $\mathcal{C}$ such that for any processes $P,Q$, we have that $Q$ refines $P$ in the stable failures model if and only $\mathcal{C}[Q]$ refines $\mathcal{C}[P]$ in the traces model. \subsection{The traces and failures models} The \emph{traces} model $\@ifnextchar[{\@model{T}}{\mathcal{T}}$ is familiar from both process algebra and automata theory, and represents a process by the set of (finite) strings of events it is able to accept. Thus each process is associated (for fixed alphabet $\Sigma$) to a subset of $\Sigma^*$ the set of finite words over $\Sigma$ (plus words of the form $w\trace{\tick}$ if we allow $SKIP$ and sequential composition). The \emph{stable failures} model $\@ifnextchar[{\@model{F}}{\mathcal{F}}$ also records sets $X$ of events that the process is able to stably refuse after a trace $s$ (that is, the process is able after trace $s$ to be in a state where no $\tau$ events are possible, and where the set of initial events is disjoint from $X$). Thus a process is associated to a subset of $\Sigma^*\times (\mathcal{P}(\Sigma)\cup\{\mathrel{\csp@spot}\})$, where $\mathrel{\csp@spot}$ represents the absence of a recorded refusal set.\footnote{This is equivalent to the standard presentation in which a process is represented by a subset of $\Sigma^*$ and one of $\Sigma^*\times\mathcal{P}(\Sigma)$: the trace component is just $\{s:(s,\mathrel{\csp@spot})\in\@ifnextchar[{\@model{F}}{\mathcal{F}}(P)\}$.} We would add the symbol $\tick$ to this set when including termination. Note that recording $\bullet$ does not imply that there is no refusal to observe, simply that we have not observed stability. The observation of the refusal $\emptyset$ implies that the process can be stable after the present trace, whereas observing $\bullet$ does not. In any model $\@ifnextchar[{\@model{M}}{\mathcal{M}}$, we say that $Q$ \emph{$\@ifnextchar[{\@model{M}}{\mathcal{M}}$-refines} $P$, and write $P\refinedby[M] Q$, if the set associated to $Q$ is a subset of that corresponding to $P$. Because $\tick$ can be seen, but happens automatically, we need to distinguish a process like $\mathord{\csp@skip}$ which must terminate from one that can but may not like $\mathord{\csp@stop}\mathrel{\csp@intchoice}\mathord{\csp@skip}$. After all if these are subsituted for $P$ in $P;Q$ we get processes equivalent to $Q$ and $\mathord{\csp@stop}\mathrel{\csp@intchoice} Q$. However the state that accepts $\tick$ can be thought of as being able to refuse the rest of the visible events $\Sigma$, since it can terminate all by itself. \subsection{Model shifting for the stable failures model} We first consider this without $\tick$. The construction is as follows: \begin{lemma}For each finite alphabet $\Sigma$ there exists a context $\mathcal{C}$ (over an expanded alphabet) such that for any processes $P$ and $Q$ we have that $P\refinedby[F] Q$ if and only if $\mathcal{C}[P]\refinedby[T]\mathcal{C}[Q]$.\end{lemma} \noindent{\bf Proof}\\ \textbf{Step 1:} We use priority to produce a process (over an expanded alphabet) that can communicate an event $x'$ if and only if the original process $P$ is able to stably refuse $x$. This is done by expanding the alphabet $\Sigma$ to $\Sigma\cup\Sigma'$ (where $\Sigma'$ contains a corresponding primed event $x'$ for every event $x\in\Sigma$), and prioritising with respect to the partial order which prioritises each $x$ over the corresponding $x'$ and makes $\tau$ incomparable to $x$ and greater than $x'$. We must also introduce an event $\mathit{stab}$ to signify the observation of stability (i.e. no $\tau$ is possible in this state) without requiring any refusals to be possible. This is necessary in order to be able to record an empty refusal set. The priority order $\leq_1$ is then the above (i.e. $x'<x$ for all $x\in\Sigma$) extended by making $stab$ less than only $\tau$ and independent of all $x$ and $x'$. We can now fire up these new events as follows: \[\mathcal{C}_1[P] = \mathrm{\bf prioritise}(P\mathrel{\csp@interleave} \mathord{\csp@run}_{\Sigma'\cup\{\mathit{stab}\}},\leq_1,\Sigma).\] This process has a state $\xi'$ for each state $\xi$ of $P$, where $\xi'$ has the same unprimed events (and corresponding transitions) as $\xi$. Furthermore $\xi'$ can communicate $x'$ just when $\xi$ is stable and can refuse $X$, and $\mathit{stab}$ just when $\xi$ is stable. \textbf{Step 2:} We now recall that the definition of the stable failures model only allows a refusal set to be recorded at the \emph{end} of a trace, and is not interested in (so does not record) what happens after the refusal set. We gain this effect by using a regulator process to prevent a primed event (or $\mathit{stab}$) from being followed by an unprimed event. Let \[\begin{array}{rl} \mathit{UNSTABLE} = &\mathop{\csp@bigextchoice}\nolimits_{x\in\Sigma} x\mathrel{\csp@then} \mathit{UNSTABLE} \\ \mathrel{\csp@extchoice} &\mathop{\csp@bigextchoice}\nolimits_{x\in\Sigma'\cup\{\mathit{stab}\}} x \mathrel{\csp@then} \mathit{STABLE} \\ \mathit{STABLE} = &\mathop{\csp@bigextchoice}\nolimits_{x\in\Sigma'\cup\{\mathit{stab}\}} x \mathrel{\csp@then}\mathit{STABLE}, \end{array}\] and define $\mathcal{C}$ by \[\mathcal{C}[P] = \mathcal{C}_1[P] \@ifnextchar[{\@dparallel}{\mathrel{\csp@parallel}}[\Sigma\cup\Sigma' \cup\{\mathit{stab}\}] \mathit{UNSTABLE}.\] A trace of $\mathcal{C}[P]$ consists of: firstly, a trace $s$ of $P$; followed by, if $P$ can after $s$ be in a stable state, then for some such state $\sigma_0$ any string formed from the events that can be refused in $\sigma_0$, together with $\mathit{stab}$. The lemma clearly follows. \hspace*{1pt}\hfill\rule[-.2ex]{.8ex}{1.6ex}\vspace{.5ex}\pagebreak[3] It is clear that any such context must involve an operator that is not compositional over traces, for otherwise we would have $P\@ifnextchar[{\@lessdet}{\mathrel\sqsubseteq}[\mathrm{T}] Q$ implies $\mathcal{C}[P]\@ifnextchar[{\@lessdet}{\mathrel\sqsubseteq}[\mathrm{T}] \mathcal{C}[Q]$, which is equivalent to $P\@ifnextchar[{\@lessdet}{\mathrel\sqsubseteq}[\mathrm{F}] Q$, and this is not true for general $P$ and $Q$ (consider for instance $P=a\mathrel{\csp@then}\mathord{\csp@stop}$, $Q=(a\mathrel{\csp@then}\mathord{\csp@stop} )\mathrel{\csp@intchoice}\mathord{\csp@stop}$). It follows that only contexts which like ours involve priority or some operator with similar status can achieve this. Adding $\tick$ to the model causes a few issues with the above. For one thing it creates a refusal (namely of everything except $\tick$) from what could be an unstable state, namely a state that can perform $\tick$ and perhaps also a $\tau$. And secondly we need to find an effective way of making processes show their refusal of $\tick$, and their refusal of all events other than $\tick$, when respectively appropriate. One way of doing these things is to add to the state space so that termination goes through multiple stages. Create a new event $term$ and consider $P;term\mathrel{\csp@then}\mathord{\csp@skip}$. This performs any behaviour of $P$ except that all $\tick$s of $P$ become $\tau$s and lead to $term\mathrel{\csp@then}\mathord{\csp@skip}$. That of course is a stable state. If we now (treating $term$ as a member of $\Sigma$) apply $\mathcal C$ as defined above, this will be able to perform $term'$ in any stable state that cannot terminate, and will perform every $a'$ event other than $term'$ every time it reaches the state $term\mathrel{\csp@then}\mathord{\csp@skip}$. Thus if we define \[\mathcal{C}^{\tick}(P) = \mathcal{C}(P;term\mathrel{\csp@then}\mathord{\csp@skip})\mathrel{\csp@hide} term\] we get exactly the decorated traces we might have expected from the stable failures representation of $P$ except that instead of having an event $\tick'$ we have $term'$. \section{Semantic models} In order to generalise this construction to arbitrary finite observational semantic models, we must give formal definitions not only of particular models but of the very notion of a finite observational model. \subsection{Finite observations} We consider only models arising from \emph{finite linear observations}. Intuitively, we postulate that we are able to observe the process performing a finite number of visible actions, and that where the process was stable (unable to perform a $\tau$) immediately before an action, we are able to observe the \emph{acceptance set} of actions it was willing to perform. Note that there cannot be two separate stable states before visible event $b$ without another visible event $c$ between them, even though it is possible to have many visible events between stable states. Thus it makes no sense to record two separate refusals or acceptance sets between consecutive visible events. Similarly it does not make sense to record both an acceptance and a refusal, since observing an acceptance set means that recording a refusal conveys no extra information: if acceptance $A$ is observed then no other is seen before the next visible event, and observable refusals are exactly those disjoint from $A$. We are unable to finitely observe \emph{instability}: the most we are able to record from an action in an unstable state is that we did not \emph{observe} stability. Thus in any context where we can observe stability we can also fail to observe it by simply not looking. We take models to be defined over finite alphabets $\Sigma$, and take an arbitrary linear ordering on each finite $\Sigma$ to be \emph{alphabetical}. The most precise finite observational model is that considering all finite linear observations, and is denoted $\@ifnextchar[{\@model{FL}}{\mathcal{FL}}$: \begin{definition}\label{def:flobs}The set of \emph{finite linear observations} over an alphabet $\Sigma$ is \[\@ifnextchar[{\@model{FL}}{\mathcal{FL}}_\Sigma:=\{\seq{A_0,a_1,A_1,\ldots,A_{n-1},a_n,A_n}:n\in \mathbb{N}, a_i\in \Sigma, A_i \subseteq \Sigma{\tt or } A_i=\mathrel{\csp@spot}\},\] where the $a_i$ are interpreted as a sequence of communicated events, and the $A_i$ denote stable acceptance sets, or in the case of $\mathrel{\csp@spot}$ failure to observe stability. Let the set of such observations corresponding to a process $P$ be denoted $\@ifnextchar[{\@model{FL}}{\mathcal{FL}}_\Sigma(P)$. This needs to be extended to encompass final $\tick$s if we want to include termination.\end{definition} (Sometimes we will drop the $\Sigma$ and just write $\@ifnextchar[{\@model{FL}}{\mathcal{FL}}(P)$). More formally, $\@ifnextchar[{\@model{FL}}{\mathcal{FL}}(P)$ can be defined inductively; for instance \[\@ifnextchar[{\@model{FL}}{\mathcal{FL}}(P\mathrel{\csp@extchoice} Q):=\left\{\seq{A\union B}\csp@cat\alpha, \seq{A\union B}\csp@cat\beta : \seq{A}\csp@cat\alpha\in \@ifnextchar[{\@model{FL}}{\mathcal{FL}}(P), \seq{B}\csp@cat\beta \in \@ifnextchar[{\@model{FL}}{\mathcal{FL}}(Q)\right\}\] (where $X\cup\bullet := \bullet$ for any set $X$). See Section 11.1.1 of \cite{roscoe2010understanding} for further details. Observe that $\@ifnextchar[{\@model{FL}}{\mathcal{FL}}$ has a natural partial order corresponding to extensions (where $\alpha\csp@cat\langle\mathrel{\csp@spot}\rangle\csp@cat\beta$ and $\alpha\csp@cat\langle A\rangle$ are both extended by $\alpha\csp@cat\langle A\rangle\csp@cat\beta$ for any set $A$ and any $\alpha$ and $\beta$). Note that for any process $P$ we have that $\@ifnextchar[{\@model{FL}}{\mathcal{FL}}(P)$ is downwards-closed with respect to this partial order. The definition of priority over $\@ifnextchar[{\@model{FL}}{\mathcal{FL}}$ (accommodating final $\tick$s) is as follows. $\mathrm{\bf prioritise}(P,\leq,X)$ is, with $\leq$ extended to the whole of $\Sigma\cup\{\tau\}$ by making all elements not in $X$ incomparable to all others \[\begin{array}{c} \{ \trace{A_0,b_1,A_1,\ldots,A_{n-1},b_n,A_n}\mid \trace{Z_0,b_1,Z_1,\ldots,Z_{n-1},b_n,Z_n}\in P\} \\ \cup \\ \{ \trace{A_0,b_1,A_1,\ldots,A_{n-1},b_n,\bullet,\tick}\mid \trace{Z_0,b_1,Z_1,\ldots,Z_{n-1},b_n,\bullet,\tick}\in P\} \end{array} \] where for each $i$ one of the following holds: \begin{itemize} \item $b_i$ is maximal under $\leq$ and $A_i=\bullet$ (so there is no condition on $Z_i$ except that it exists). \item $a_i$ is not maximal under $\leq$ and $A_{i-1}=\bullet$ and $Z_i$ is not $\bullet$ and neither does $Z_i$ contain any $c>b_i$. \item Neither $A_i$ nor $Z_i$ is $\bullet$, and $A_i=\{a\in Z_i\mid \neg\exists b\in Z_i.b>a\}$, \item and in each case where $A_{i-1}\neq\bullet$, $a_i\in A_{i-1}$. \end{itemize} This is not possible for the other studied finite behaviour models of CSP: the statement that it is for refusal testing $\@ifnextchar[{\@model{RT}}{\mathcal{RT}}$ in~\cite{roscoe2010understanding} is not true, though it is possible for some partical orders $\leq$ including those needed for maximal progress in timed modelling of the sort we will see later. \subsection{Finite observational models} We consider precisely the models which are derivable from the observations of $\@ifnextchar[{\@model{FL}}{\mathcal{FL}}$, which are well-defined in the sense that they are compositional over CSP syntax (other than priority), and which respect extension of the alphabet $\Sigma$. \begin{definition}\label{def:premodel}A finite observational \emph{pre-model} $\@ifnextchar[{\@model{M}}{\mathcal{M}}$ consists for each (finite) alphabet $\Sigma$ of a set of \emph{observations}, $\mathrm{obs}_\Sigma(\@ifnextchar[{\@model{M}}{\mathcal{M}})$, together with a relation $\@ifnextchar[{\@model{M}}{\mathcal{M}}_\Sigma\subseteq\@ifnextchar[{\@model{FL}}{\mathcal{FL}}_\Sigma\times\mathrm{obs}_\Sigma(\@ifnextchar[{\@model{M}}{\mathcal{M}})$. The representation of a process $P$ in $\@ifnextchar[{\@model{M}}{\mathcal{M}}_{\Sigma}$ is denoted $\@ifnextchar[{\@model{M}}{\mathcal{M}}_\Sigma(P)$, and is given by \[\@ifnextchar[{\@model{M}}{\mathcal{M}}_\Sigma(P):=\@ifnextchar[{\@model{M}}{\mathcal{M}}_\Sigma(\@ifnextchar[{\@model{FL}}{\mathcal{FL}}_\Sigma(P))=\{y\in\mathrm{obs}_\Sigma(\@ifnextchar[{\@model{M}}{\mathcal{M}}):\exists x\in\@ifnextchar[{\@model{FL}}{\mathcal{FL}}_\Sigma(P).(x,y)\in\@ifnextchar[{\@model{M}}{\mathcal{M}}_\Sigma\}.\] For processes $P$ and $Q$ over alphabet $\Sigma$, if we have $\@ifnextchar[{\@model{M}}{\mathcal{M}}_\Sigma(Q)\subseteq\@ifnextchar[{\@model{M}}{\mathcal{M}}_\Sigma(P)$ then we say $Q$ \emph{$\@ifnextchar[{\@model{M}}{\mathcal{M}}$-refines} $P$, and write $P\refinedby[M]Q$. \end{definition} (As before we will sometimes drop the $\Sigma$). Note that this definition is less general than if we had defined a pre-model to be any equivalence relation on $\mathcal{P}\left(\@ifnextchar[{\@model{FL}}{\mathcal{FL}}_\Sigma\right)$. For example, the equivalence relating sets of the same cardinality has no corresponding pre-model. Definition \ref{def:premodel} agrees with that sketched in \cite{roscoe2010understanding}. Without loss of generality, $\@ifnextchar[{\@model{M}}{\mathcal{M}}_\Sigma$ does not identify any elements of $\mathrm{obs}_\Sigma(\@ifnextchar[{\@model{M}}{\mathcal{M}})$; that is, we have $\@ifnextchar[{\@model{M}}{\mathcal{M}}_\Sigma^{-1}(x)=\@ifnextchar[{\@model{M}}{\mathcal{M}}_\Sigma^{-1}(y)$ only if $x=y$ (otherwise quotient by this equivalence relation). Subject to this assumption, $\@ifnextchar[{\@model{M}}{\mathcal{M}}_\Sigma$ induces a partial order on $\mathrm{obs}_\Sigma(\@ifnextchar[{\@model{M}}{\mathcal{M}})$: \begin{definition}The partial order \emph{induced by $\@ifnextchar[{\@model{M}}{\mathcal{M}}_\Sigma$ on $\mathrm{obs}_\Sigma(\@ifnextchar[{\@model{M}}{\mathcal{M}})$} is given by: $x\leq y$ if and only if for all $b\in\@ifnextchar[{\@model{M}}{\mathcal{M}}_\Sigma^{-1}(y)$ there exists $a\in\@ifnextchar[{\@model{M}}{\mathcal{M}}_\Sigma^{-1}(x)$ with $a\leq b$.\end{definition} Observe that for any process $P$ it follows from this definition that $\@ifnextchar[{\@model{M}}{\mathcal{M}}(P)$ is downwards-closed with respect to this partial order (since $\@ifnextchar[{\@model{FL}}{\mathcal{FL}}(P)$ is downwards-closed). \begin{definition}\label{def:comp}A pre-model $\@ifnextchar[{\@model{M}}{\mathcal{M}}$ is \emph{compositional} if for all CSP operators $\bigoplus$, say of arity $k$, and for all processes $P_1,\ldots,P_k$ and $Q_1,\ldots,Q_k$ such that $\@ifnextchar[{\@model{M}}{\mathcal{M}}(P_i)=\@ifnextchar[{\@model{M}}{\mathcal{M}}(Q_i)$ for all $i$, we have \[\@ifnextchar[{\@model{M}}{\mathcal{M}}\left(\bigoplus(P_i)_{i=1\ldots k}\right) = \@ifnextchar[{\@model{M}}{\mathcal{M}}\left(\bigoplus(Q_i)_{i=1\ldots k}\right).\]\end{definition} This means that the operator defined on processes in $\mathrm{obs}(\@ifnextchar[{\@model{M}}{\mathcal{M}})$ by taking the pushforward of $\bigoplus$ along $\@ifnextchar[{\@model{M}}{\mathcal{M}}$ is well-defined: for any sets $X_1,\ldots,X_k\subseteq\mathrm{obs}(\@ifnextchar[{\@model{M}}{\mathcal{M}})$ which correspond to the images of CSP processes, take processes $P_1,\ldots,P_k$ such that $X_i=\@ifnextchar[{\@model{M}}{\mathcal{M}}(P_i)$, and let \[\bigoplus(X_i)_{i=1\ldots k} = \@ifnextchar[{\@model{M}}{\mathcal{M}}\left(\bigoplus(P_i)_{i=1\ldots k}\right).\] Definition \ref{def:comp} says that the result of this does not depend on the choice of the $P_i$. Note that it is not necessary to require the equivalent of Definition \ref{def:comp} for recursion in the definition of a model, because of the following lemma which shows that least fixed point recursion is automatically well-defined (and formalises some arguments given in \cite{roscoe2010understanding}): \begin{lemma}Let $\@ifnextchar[{\@model{M}}{\mathcal{M}}$ be a compositional pre-model. Let $\mathcal{C}_1,\mathcal{C}_2$ be CSP contexts, such that for any process $P$ we have $\@ifnextchar[{\@model{M}}{\mathcal{M}}(\mathcal{C}_1[P])=\@ifnextchar[{\@model{M}}{\mathcal{M}}(\mathcal{C}_2[P])$. Let the least fixed points of $\mathcal{C}_1$ and $\mathcal{C}_2$ (viewed as functions on $\mathcal{P}(\@ifnextchar[{\@model{FL}}{\mathcal{FL}})$ under the subset order) be $P_1$ and $P_2$ respectively. Then $\@ifnextchar[{\@model{M}}{\mathcal{M}}(P_1)=\@ifnextchar[{\@model{M}}{\mathcal{M}}(P_2)$.\end{lemma} \noindent{\bf Proof}\\ Using the fact that CSP contexts induce Scott-continuous functions on $\mathcal{P}(\@ifnextchar[{\@model{FL}}{\mathcal{FL}})$ (see \cite{hoare1985communicating}, Section 2.8.2), the Kleene fixed point theorem gives that $P_i=\bigcup_{n=0}^{\infty}\mathcal{C}_i^n(\bot)$. Now any $x\in\@ifnextchar[{\@model{M}}{\mathcal{M}}(P_1)$ is in the union taken up to some finite $N$, and since finite unions correspond to internal choice, and $\bot$ to the process $\mathord{\csp@divergence}$, we have that the unions up to $N$ of $\mathcal{C}_1$ and $\mathcal{C}_2$ agree under $\@ifnextchar[{\@model{M}}{\mathcal{M}}$ by compositionality. Hence $x\in\@ifnextchar[{\@model{M}}{\mathcal{M}}(P_2)$, so $\@ifnextchar[{\@model{M}}{\mathcal{M}}(P_1)\subseteq\@ifnextchar[{\@model{M}}{\mathcal{M}}(P_2)$. Similarly $\@ifnextchar[{\@model{M}}{\mathcal{M}}(P_2)\subseteq\@ifnextchar[{\@model{M}}{\mathcal{M}}(P_1)$. \hspace*{1pt}\hfill\rule[-.2ex]{.8ex}{1.6ex}\vspace{.5ex}\pagebreak[3] \begin{definition}A pre-model $\@ifnextchar[{\@model{M}}{\mathcal{M}}$ is \emph{extensional} if for all alphabets $\Sigma_1\subseteq\Sigma_2$ we have that $\mathrm{obs}_{\Sigma_1}(\@ifnextchar[{\@model{M}}{\mathcal{M}})\subseteq\mathrm{obs}_{\Sigma_2}(\@ifnextchar[{\@model{M}}{\mathcal{M}})$, and $\@ifnextchar[{\@model{M}}{\mathcal{M}}_{\Sigma_2}$ agrees with $\@ifnextchar[{\@model{M}}{\mathcal{M}}_{\Sigma_1}$ on $\@ifnextchar[{\@model{FL}}{\mathcal{FL}}(\Sigma_1)\times\mathrm{obs}_{\Sigma_1}(\@ifnextchar[{\@model{M}}{\mathcal{M}})$.\end{definition} \begin{definition}\label{def:mod}A pre-model is a \emph{model} if it is compositional and extensional.\end{definition} In this setting, we now describe the five main finite observational models coarser than $\@ifnextchar[{\@model{FL}}{\mathcal{FL}}$: traces, stable failures, revivals, acceptances and refusal testing. \subsubsection{The traces model}\quad The coarsest model measures only the \emph{traces} of a process; that is, the sequences of events it is able to accept. This corresponds to the language of the process viewed as a nondeterministic finite automaton (NFA). \begin{definition}\label{def:trmod}The \emph{traces} model, $\@ifnextchar[{\@model{T}}{\mathcal{T}}$, is given by \[\mathrm{obs}_\Sigma(\@ifnextchar[{\@model{T}}{\mathcal{T}}) = \Sigma^*,\;\@ifnextchar[{\@model{T}}{\mathcal{T}}_\Sigma = \mathit{trace}_\Sigma\] where $\mathit{trace}$ is the equivalence relation which relates the observation \\ $\seq{A_0,a_1,A_1,\ldots,a_n,A_n}$ to the string $a_1\ldots a_n$.\end{definition} \subsubsection{Failures}\quad The traces model gives us information about what a process is \emph{allowed} to do, but it in some sense tells us nothing about what it is \emph{required} to do. In particular, the process $\mathord{\csp@stop}$ trace-refines any other process. In order to specify liveness properties, we can incorporate some information about the events the process is allowed to refuse, begining with the \emph{stable failures} model. Intuitively, this captures traces $s$, together with the sets of events the process is allowed to stably refuse after $s$. \begin{definition}\label{def:famod}The \emph{stable failures} model, $\@ifnextchar[{\@model{F}}{\mathcal{F}}$, is given by \[\mathrm{obs}_\Sigma(\@ifnextchar[{\@model{F}}{\mathcal{F}}) = \Sigma^*\times(\mathcal{P}(\Sigma)\cup\{\mathrel{\csp@spot}\}),\;\@ifnextchar[{\@model{F}}{\mathcal{F}}_\Sigma = \mathit{fail}_\Sigma,\] where $\mathit{fail}_\Sigma$ relates the observation $\seq{A_0,\ldots,a_n,A_n}$ to all pairs $(a_1\ldots a_n,X)$, for all $X\subseteq\Sigma\setminus A_n$ if $A_n\neq\,\mathrel{\csp@spot}$, and for $X=\,\mathrel{\csp@spot}$ otherwise.\end{definition} \subsubsection{Revivals}\quad The next coarsest model, first introduced in \cite{roscoe2009revivals}, is the \emph{revivals} model. Intuitively this captures traces $s$, together with sets $X$ that can be stably refused after $s$, and events $a$ (if any) that can then be accepted. \begin{definition}The \emph{revivals} model, $\@ifnextchar[{\@model{R}}{\mathcal{R}}$, is given by \[\mathrm{obs}_\Sigma(\@ifnextchar[{\@model{R}}{\mathcal{R}}) = \Sigma^*\times (\mathcal{P}(\Sigma)\cup\{\mathrel{\csp@spot}\})\times (\Sigma\cup\{\mathrel{\csp@spot}\}),\;\@ifnextchar[{\@model{R}}{\mathcal{R}}_\Sigma = \mathit{rev}_\Sigma),\] where $\mathit{rev}_\Sigma$ relates the observation $\seq{A_0,a_1,\ldots,a_{n-1},A_{n-1},a_n,A_n}$ to \begin{enumerate}[(i)] \item the triples $(a_1\ldots a_{n-1},X,a_n)$, for all $X\subseteq\Sigma\setminus A_{n-1}$ if $A_{n-1}\neq\,\mathrel{\csp@spot}$ and for $X=\,\mathrel{\csp@spot}$ otherwise, and \item the triples $(a_1\ldots a_n,X,\mathrel{\csp@spot})$, for all $X\subseteq\Sigma\setminus A_n$ if $A_n\neq\,\mathrel{\csp@spot}$ and for $X=\,\mathrel{\csp@spot}$ otherwise.\end{enumerate}\end{definition} A finite linear observation is related to all triples consisting of: its initial trace; a stable refusal that could have been observed, or $\mathrel{\csp@spot}$ if the original observation did not observe stability; and optionally (part (i) above) a single further event that can be accepted. \subsubsection{Acceptances}\quad All the models considered up to now refer only to sets of refusals, which in particular are closed under subsets. The next model, \emph{acceptances} (also known as `ready sets'), refines the previous three and also considers the precise sets of events that can be stably accepted at the ends of traces. \begin{definition}The \emph{acceptances} model, $\@ifnextchar[{\@model{A}}{\mathcal{A}}$, is given by \[\mathrm{obs}_\Sigma(\@ifnextchar[{\@model{A}}{\mathcal{A}}) = \Sigma^*\times(\mathcal{P}(\Sigma)\cup\{\mathrel{\csp@spot}\}),\; \@ifnextchar[{\@model{A}}{\mathcal{A}}_\Sigma = \mathit{acc}_\Sigma,\] where $\mathit{acc}_\Sigma$ relates the observation $\seq{A_0,a_1,\ldots,a_n,A_n}$ to the pair $(a_1\ldots a_n,A_n)$.\end{definition} It is convenient to note here that, just as we were able to use $a'$ as a cipher for the refusal of $a$ when model shifting, we can introduce a second one $a''$ as a chipher for stable acceptance of $a$: it is performed (without changing the state) just when $a'$ is stably refused. We will apply this idea and discuss it further below. \subsubsection{Refusal testing}\quad The final model we consider is that of \emph{refusal testing}, first introduced in \cite{phillips1987refusal}. This refines $\@ifnextchar[{\@model{F}}{\mathcal{F}}$ and $\@ifnextchar[{\@model{R}}{\mathcal{R}}$ by considering an entire history of events and stable refusal sets. It is incomparable to $\@ifnextchar[{\@model{A}}{\mathcal{A}}$, because it does not capture precise acceptance sets. \begin{definition}\label{def:rtmod}The \emph{refusal testing} model, $\@ifnextchar[{\@model{RT}}{\mathcal{RT}}$, is given by \[\mathrm{obs}_\Sigma(\@ifnextchar[{\@model{RT}}{\mathcal{RT}}) = \{\seq{X_0,a_1,X_1,\ldots,a_n,X_n}:n\in\mathbb{N},a_i\in\Sigma, X_i\subseteq\Sigma{\tt or }X_i=\mathrel{\csp@spot}\}\] \[\@ifnextchar[{\@model{RT}}{\mathcal{RT}}_\Sigma = \mathit{rt}_\Sigma,\] where $\mathit{rt}_\Sigma$ relates the observation $\seq{A_0,\ldots,a_n,A_n}$ to $\seq{X_0,\ldots,a_n,X_n}$, for all $X_i\subseteq\Sigma\setminus A_i$ if $A_i\neq\,\mathrel{\csp@spot}$, and for $X_i=\,\mathrel{\csp@spot}$ otherwise. \end{definition} The correct way to handle $\tick$, if needed, in any of these models is to add to the respective transformation in exactly the same way we did for stable failures. This is to be expected because $\tick$ only ever happens at the end of traces. Clearly we will need to use $term''$ as a cipher for $\tick''$ in appropriate cases. \subsection{Rational models} We will later on wish to consider only models $\@ifnextchar[{\@model{M}}{\mathcal{M}}$ for which the correspondence between $\@ifnextchar[{\@model{FL}}{\mathcal{FL}}$-observations and $\@ifnextchar[{\@model{M}}{\mathcal{M}}$ observations is decidable by a finite memory computer. We will interpret this notion as saying the the relation $\@ifnextchar[{\@model{M}}{\mathcal{M}}_\Sigma$ corresponds to the language accepted by some finite state automaton. In order to do this, we must first decide how to convert elements of $\@ifnextchar[{\@model{FL}}{\mathcal{FL}}_\Sigma$ to words in a language. We do this in the obvious way (the reasons for using fresh variables to represent the $A_i$ will become apparent in Section \ref{sec:modshift}). \begin{definition}The \emph{canonical encoding} of $\@ifnextchar[{\@model{FL}}{\mathcal{FL}}_\Sigma$ is over the alphabet $\Xi :=\Sigma\cup\Sigma''\cup\mathit{Sym}$, where $\Sigma'':=\{a'':a\in\Sigma\}$ and $\mathit{Sym}=\{\langle,\rangle,`{\tt,}',\mathrel{\csp@spot}\}$.\footnote{Note that this somewhat unsatisfactory notation denotes a set of four elements: the angle brackets $\langle$ and $\rangle$, the comma , and the symbol $\mathrel{\csp@spot}$.} It is given by the representation in Definition \ref{def:flobs}, where sets $A_i$ are expressed by listing the elements of $\Sigma''$ corresponding to the members of $A_i$ in alphabetical order. We denote this encoding by $\phi_\Sigma:\@ifnextchar[{\@model{FL}}{\mathcal{FL}}_\Sigma\rightarrow\Xi^*$.\end{definition} We now define a model to be \emph{rational} (borrowing a term from automata theory) if its defining relation can be recognised (when suitably encoded) by some nondeterministic finite automaton. \begin{definition}\label{def:ratmod}A model $\@ifnextchar[{\@model{M}}{\mathcal{M}}$ is \emph{rational} if for every alphabet $\Sigma$, there is some finite alphabet $\Theta$ and a map $\psi_\Sigma:\mathrm{obs}_\Sigma(\@ifnextchar[{\@model{M}}{\mathcal{M}})\rightarrow\Theta^*$, such that there is a (nondeterministic) finite automaton $\mathcal{A}$ recognising $\left\{\left(\phi_\Sigma(x),\psi_\Sigma(y)\right):(x,y)\in\@ifnextchar[{\@model{M}}{\mathcal{M}}_\Sigma\right\}$, and such that $\psi_\Sigma$ is \emph{order-reflecting} (that is, $\psi_\Sigma(x)\leq\psi_\Sigma(y)$ only if $x\leq y$), with respect to the prefix partial order on $\Theta^*$, and the partial order induced by $\@ifnextchar[{\@model{M}}{\mathcal{M}}_\Sigma$ on $\mathrm{obs}_\Sigma(\@ifnextchar[{\@model{M}}{\mathcal{M}})$. \end{definition} What does it mean for an automaton to `recognise' a relation? \begin{definition}\label{def:rec}For alphabets $\Sigma$ and $T$, a relation $\mathcal{R}\subseteq\Sigma^*\times T^*$ is \emph{recognised} by an automaton $\mathcal{A}$ just when: \begin{enumerate}[(i)] \item The event-set of $\mathcal{A}$ is $\mathrm{left}.\Sigma\cup\mathrm{right}.T$, and \item For any $s\in\Sigma^*, t\in T^*$, we have $s\mathcal{R}t$ if and only if there is some interleaving of $\mathrm{left}.s$ and $\mathrm{right}.t$ accepted by $\mathcal{A}$. \end{enumerate} \end{definition} Note that recognisability in the sense of Definition \ref{def:rec} is easily shown to be equivalent to the common notion of recognisability by a \emph{finite state transducer} given for instance in \cite{shallit2009second}, but the above definition is more convenient for our purposes. Note also that $\@ifnextchar[{\@model{FL}}{\mathcal{FL}}$ itself (viewing $\@ifnextchar[{\@model{FL}}{\mathcal{FL}}_\Sigma$ as the diagonal relation) is trivially rational. \begin{lemma}The models $\@ifnextchar[{\@model{T}}{\mathcal{T}},\@ifnextchar[{\@model{F}}{\mathcal{F}},\@ifnextchar[{\@model{R}}{\mathcal{R}},\@ifnextchar[{\@model{A}}{\mathcal{A}}$ and $\@ifnextchar[{\@model{RT}}{\mathcal{RT}}$ are rational.\end{lemma} \noindent{\bf Proof}\\ By inspection of Definitions \ref{def:trmod}--\ref{def:rtmod}. We take $\Theta=\Sigma\cup\Sigma'\cup\Sigma''\cup\mathit{Sym}$, with $\Sigma''$ and the expression of acceptance sets as in the canonical encoding of $\@ifnextchar[{\@model{FL}}{\mathcal{FL}}$, and refusal sets expressed in the corresponding way over $\Sigma':=\{a':a\in\Sigma\}$.\hspace*{1pt}\hfill\rule[-.2ex]{.8ex}{1.6ex}\vspace{.5ex}\pagebreak[3] Note that not all relations are rational. For instance, the `counting relation' mapping each finite linear observation to its length is clearly not rational. We do not know whether the additional constraint of being a finite observational model necessarily implies rationality; however, no irrational models are known. We therefore tentatively conjecture: that {\em every finite observational model is rational.} \section{Model shifting}\label{sec:modshift} We now come to the main substance of this paper: we prove results on `model shifting', showing that there exist contexts allowing us to pass between different semantic models and the basic traces model. The main result is Theorem \ref{thm:ratshift}, which shows that this is possible for any rational model. \subsection{Model shifting for $\mathcal{FL}$} We begin by proving the result for the finest model, $\@ifnextchar[{\@model{FL}}{\mathcal{FL}}$. We show that there exists a context $\mathcal{C}_{\@ifnextchar[{\@model{FL}}{\mathcal{FL}}}$ such that for any process $P$, the finite linear observations of $P$ correspond to the traces of $\mathcal{C}_{\@ifnextchar[{\@model{FL}}{\mathcal{FL}}}(P)$. \begin{lemma}[Model shifting for $\@ifnextchar[{\@model{FL}}{\mathcal{FL}}$]\label{lem:msfl}For every alphabet $\Sigma$, there exists a context $\mathcal{C}_{\@ifnextchar[{\@model{FL}}{\mathcal{FL}}}$ over alphabet $T:=\Sigma\cup\Sigma'\cup\Sigma''\cup\{\mathit{done}\}$, and an order-reflecting map $\pi:\@ifnextchar[{\@model{FL}}{\mathcal{FL}}_\Sigma\rightarrow T^*$ (with respect to the extension partial order on $\@ifnextchar[{\@model{FL}}{\mathcal{FL}}_\Sigma$ and the prefix partial order on $T^*$) such that for any process $P$ over $\Sigma$ we have $\@ifnextchar[{\@model{T}}{\mathcal{T}}(\mathcal{C}_{\@ifnextchar[{\@model{FL}}{\mathcal{FL}}}[P]) = \mathrm{pref}(\pi(\@ifnextchar[{\@model{FL}}{\mathcal{FL}}(P)))$ (where $\mathrm{pref}(X)$ is the prefix-closure of the set $X$). \end{lemma} \noindent{\bf Proof}\\ We will use the unprimed alphabet $\Sigma$ to denote communicated events from the original trace, and the double-primed alphabet $\Sigma''$ to denote (members of) stable acceptances. $\Sigma'$ will be used in an intermediate step to denote refusals, and $\mathit{done}$ will be used to distinguish $\emptyset$ (representing an empty acceptance set) from $\mathrel{\csp@spot}$ (representing a failure to observe anything). \textbf{Step 1:} We first produce a process which is able to communicate events $x_i'$, just when the original process can stably refuse the corresponding $x_i$. Define the partial order $\leq_1 = \langle x' <_1 x: x \in\Sigma\rangle$, which prevents refusal events when the corresponding event can occur. Let the context $\mathcal{C}_1$ be given by \[\mathcal{C}_1[X] = \mathrm{\bf prioritise}(X\mathrel{\csp@interleave}\mathord{\csp@run}_{\Sigma'},\leq_1,\Sigma).\] Note that the third argument prevents primed events from occurring in unstable states. \textbf{Step 2:} We now similarly introduce acceptance events, which can happen in stable states when the corresponding refusal can't. The crucial difference between $a$ and $a''$ is that $a$ usually changes the underlying process state, whereas $a''$ leaves it alone. $a''$ means that $P$ can perform $a$ from its present stable state, but does not explore what happens when it does. Similarly define the partial order $\leq_2 = \langle x'' <_2 x' : x\in\Sigma\rangle$, which prevents acceptance events when the corresponding refusal is possible. Let the context $\mathcal{C}_2$ be defined by \[\mathcal{C}_2[X] = \mathrm{\bf prioritise}(\mathcal{C}_1[X]\mathrel{\csp@interleave}\mathord{\csp@run}_{\Sigma''},\leq_2,\Sigma).\] \textbf{Step 3:} We now ensure that an acceptance set inferred from a trace is a complete set accepted by the process under examination. This is most straightforwardly done by employing a regulator process, which can either accept an unprimed event or accept the alphabetically first refusal or acceptance event, followed by a refusal or acceptance for each event in turn. In the latter case it then communicates a $\mathit{done}$ event, and returns to its original state. It has thus recorded the complete set of events accepted by $P$'s present state. The $\mathit{done}$ event is necessary in order to distinguish between a terminal $\emptyset$, which can have a $\mathit{done}$ after the last event, and a terminal $\mathrel{\csp@spot}$, which cannot (observe that a $\emptyset$ cannot occur other than at the end). Along the way, we hide the refusal events. Let $a$ and $z$ denote the alphabetically (by which me mean in a fixed but arbitrary linear order on $\Sigma$) first and last events respectively, and let ${\tt succ }x$ denote the alphabetical successor of $x$. Define the processes \[\begin{array}{rl} \mathit{UNSTABLE} &= \mathop{\csp@bigextchoice}\nolimits_{x\in\Sigma} x\mathrel{\csp@then}\mathit{UNSTABLE} \\ &\qquad\mathrel{\csp@extchoice} a'\mathrel{\csp@then}\mathit{STABLE}(a) \mathrel{\csp@extchoice} a''\mathrel{\csp@then}\mathit{STABLE}(a) \\ \mathit{STABLE}(x) &= x'\mathrel{\csp@then}\mathit{STABLE}({\tt succ } x)\mathrel{\csp@extchoice} x''\mathrel{\csp@then}\mathit{STABLE}({\tt succ } x)\qquad (x\neq z) \\ \mathit{STABLE}(z) &= \mathit{done}\mathrel{\csp@then}\mathit{UNSTABLE}, \end{array}\] and let \[\mathcal{C}_{\@ifnextchar[{\@model{FL}}{\mathcal{FL}}}[X] = \left(\mathcal{C}_2[X]\@ifnextchar[{\@dparallel}{\mathrel{\csp@parallel}}[\Sigma\cup\Sigma'\cup\Sigma'']\mathit{UNSTABLE}\right)\mathrel{\csp@hide}\Sigma'.\] A little care is required here. We can prevent acceptances from being `skipped over' by prioritising the double-primed events in alphabetical order, but we also have to prevent acceptances from ending early, i.e. prevent an unprimed event from happening prematurely. The most obvious solution is to prioritise acceptance events over unprimed events. This does not work, however, because the prioritise operator forces all events which can be performed in unstable states to be maximal in the order, and in the LTS representing the underlying process, any event can happen as an alternative to $\tau$. We instead use the event $\mathit{done}$ to mark the end of an acceptance set, and use a regulator process to prevent a double-primed event from being followed by an unprimed event without an intervening $\mathit{done}$. This also distinguishes between $\emptyset$, represented by a $\mathit{done}$ between two unprimed events, and $\mathrel{\csp@spot}$, represented by consecutive unprimed events. Define the partial order \[\omega_3 = \langle x'' < y'' : y <_\alpha x\rangle \cup \langle \mathit{done} < x'' : x\in\Sigma\rangle,\] which prevents jumps in acceptance sets, and allows $\mathit{done}$ only in stable states where no double-primed events are left to be communicated. Let the context $\mathcal{C}_3$ be defined by \[\mathcal{C}_3[X] = \mathrm{\bf prioritise}(\mathcal{C}_2[X]\mathrel{\csp@interleave}\mathord{\csp@run}_\mathit{done},\omega_3,\Sigma).\] We now define the regulator process which prevents sequences of double-primed events not concluded by $\mathit{done}$: \[\begin{array}{rl} DREG &= \left( \mathop{\csp@bigextchoice}\nolimits_{x\in\Sigma} x\mathrel{\csp@then} DREG\right) \mathrel{\csp@extchoice} \left(\mathop{\csp@bigextchoice}\nolimits_{x\in\Sigma} x''\mathrel{\csp@then} DREG'\right) \\ DREG' &= \left(\mathop{\csp@bigextchoice}\nolimits_{x\in\Sigma}x''\mathrel{\csp@then} DREG'\right) \mathrel{\csp@extchoice} \mathit{done}\mathrel{\csp@then} DREG, \end{array}\] and then define the context $\mathcal{C}_{\@ifnextchar[{\@model{FL}}{\mathcal{FL}}}$ by \[\mathcal{C}_{\@ifnextchar[{\@model{FL}}{\mathcal{FL}}}[X] = \mathcal{C}_3[X] \@ifnextchar[{\@dparallel}{\mathrel{\csp@parallel}}[\Sigma\cup\Sigma''\cup\{\mathit{done}\}] DREG.\] \textbf{Step 4:} We now complete the proof by defining the function $\pi$ inductively as follows: \[\begin{array}{rl} \pi(s\csp@cat\langle \mathrel{\csp@spot}\rangle ) &= \pi(s)\\ \pi(s\csp@cat\langle x\rangle ) &= \pi(s)\csp@cat\langle x\rangle \\ \pi(s\csp@cat\langle A &=\{x_1,\ldots,x_k\}\rangle) = \pi(s)\csp@cat\langle x_1'' \ldots x_k'' \mathit{done}\rangle, \end{array}\] where without loss of generality the $x_i$ are listed in alphabetical order. It is clear that this is order-reflecting, and by the construction above satisfies $\@ifnextchar[{\@model{T}}{\mathcal{T}}(\mathcal{C}_{\@ifnextchar[{\@model{FL}}{\mathcal{FL}}}[P]) = \mathrm{pref}(\pi(\@ifnextchar[{\@model{FL}}{\mathcal{FL}}(P)))$. \hspace*{1pt}\hfill\rule[-.2ex]{.8ex}{1.6ex}\vspace{.5ex}\pagebreak[3] This result allows us to translate questions of $\@ifnextchar[{\@model{FL}}{\mathcal{FL}}$-refinement into questions of trace refinement under $\mathcal{C}_{\@ifnextchar[{\@model{FL}}{\mathcal{FL}}}$, as follows: \begin{corollary}\label{cor:flinc}For $\mathcal{C}_{\@ifnextchar[{\@model{FL}}{\mathcal{FL}}}$ as in Lemma \ref{lem:msfl}, and for any processes $P$ and $Q$, we have $P\@ifnextchar[{\@lessdet}{\mathrel\sqsubseteq}[\mathrm{FL}] Q$ if and only if $\mathcal{C}_{\@ifnextchar[{\@model{FL}}{\mathcal{FL}}}[P]\@ifnextchar[{\@lessdet}{\mathrel\sqsubseteq}[\mathrm{T}]\mathcal{C}_{\@ifnextchar[{\@model{FL}}{\mathcal{FL}}}[Q]$. \end{corollary} \noindent{\bf Proof}\\ Certainly if $\@ifnextchar[{\@model{FL}}{\mathcal{FL}}(Q)\subseteq\@ifnextchar[{\@model{FL}}{\mathcal{FL}}(P)$ then $\@ifnextchar[{\@model{T}}{\mathcal{T}}(\mathcal{C}_{\@ifnextchar[{\@model{FL}}{\mathcal{FL}}}[Q]) = \mathrm{pref}(\pi(\@ifnextchar[{\@model{FL}}{\mathcal{FL}}(Q))) \subseteq \mathrm{pref}(\pi(\@ifnextchar[{\@model{FL}}{\mathcal{FL}}(P))) = \@ifnextchar[{\@model{T}}{\mathcal{T}}(\mathcal{C}_{\@ifnextchar[{\@model{FL}}{\mathcal{FL}}}[P])$ and so $\mathcal{C}_{\@ifnextchar[{\@model{FL}}{\mathcal{FL}}}[P]\@ifnextchar[{\@lessdet}{\mathrel\sqsubseteq}[\mathrm{T}]\mathcal{C}_{\@ifnextchar[{\@model{FL}}{\mathcal{FL}}}[Q]$. Conversely, suppose there exists $x\in\@ifnextchar[{\@model{FL}}{\mathcal{FL}}(Q)\setminus\@ifnextchar[{\@model{FL}}{\mathcal{FL}}(P)$. Then since $\@ifnextchar[{\@model{FL}}{\mathcal{FL}}(P)$ is downwards-closed, we have $x\nleq y$ for all $y\in\@ifnextchar[{\@model{FL}}{\mathcal{FL}}(P)$. Since $\pi$ is order-reflecting, we have correspondingly $\pi(x)\nleq\pi(y)$ for all $y\in\@ifnextchar[{\@model{FL}}{\mathcal{FL}}(P)$. Hence $\pi(x)\notin\mathrm{pref}(\pi(\@ifnextchar[{\@model{FL}}{\mathcal{FL}}(P)))$, so $\mathrm{pref}(\pi(\@ifnextchar[{\@model{FL}}{\mathcal{FL}}(Q))) \nsubseteq \mathrm{pref}(\pi(\@ifnextchar[{\@model{FL}}{\mathcal{FL}}(P)))$. \hspace*{1pt}\hfill\rule[-.2ex]{.8ex}{1.6ex}\vspace{.5ex}\pagebreak[3] \subsection{Model shifting for rational observational models} We now have essentially all we need to prove the main theorem. We formally record a well known fact, that any Nondeterministic Finite Austomaton (NFA) can be implemented as a CSP process (up to prefix-closure, since trace-sets are prefix-closed but regular languages are not): \begin{lemma}[Implementation for NFA]\label{lem:impl}Let $\mathcal{A} = (\Sigma,Q,\delta,q_0,F)$ be a (nondeterministic) finite automaton. Then there exists a CSP process $P_{\mathcal{A}}$ such that $\mathrm{pref}(L(\mathcal{A})) = \mathrm{pref}(\@ifnextchar[{\@model{T}}{\mathcal{T}}(P_{\mathcal{A}}))$. \end{lemma} See Chapter 7 of \cite{roscoe1997tpc} for the proof. \begin{theorem}[Model shifting for rational models]\label{thm:ratshift}For every rational model $\@ifnextchar[{\@model{M}}{\mathcal{M}}$, there exists a context $\mathcal{C}_{\@ifnextchar[{\@model{M}}{\mathcal{M}}}$ such that for any process $P$ we have $\@ifnextchar[{\@model{T}}{\mathcal{T}}(\mathcal{C}_{\@ifnextchar[{\@model{M}}{\mathcal{M}}}[P])=\mathrm{pref}(\psi(\@ifnextchar[{\@model{M}}{\mathcal{M}}(P)))$. \end{theorem} \noindent{\bf Proof}\\ Let $\mathcal{A}$ be the automaton recognising $(\phi\times\psi)(\@ifnextchar[{\@model{M}}{\mathcal{M}})$ (as from Definition \ref{def:ratmod}), and let $P_{\mathcal{A}}$ be the corresponding process from Lemma \ref{lem:impl}. We first apply Lemma \ref{lem:msfl} to produce a process whose traces correspond to the finite linear observations of the original process, prefixed with $\mathrm{left}$: let $\mathcal{C}_{\@ifnextchar[{\@model{FL}}{\mathcal{FL}}}$ be the context from Lemma \ref{lem:msfl}, and let the context $\mathcal{C}_1$ be defined by \[\mathcal{C}_1[X] = \mathcal{C}_{\@ifnextchar[{\@model{FL}}{\mathcal{FL}}}[X]\rensubs{\mathrm{left}.x}{x}.\] We now compose in parallel with $P_{\mathcal{A}}$, to produde a process whose traces correspond to the $\@ifnextchar[{\@model{M}}{\mathcal{M}}$-observations of the original process. Let $\mathcal{C}_2$ be defined by \[\mathcal{C}_2[X] = \left(\left(\mathcal{C}_1[X]\@ifnextchar[{\@dparallel}{\mathrel{\csp@parallel}}[\{|\mathrm{left}|\}]P_{\mathcal{A}}\right) \mathrel{\csp@hide} \{|\mathrm{left}|\}\right) \rensubs{x}{\mathrm{right}.x}.\] Then the traces of $\mathcal{C}_2[X]$ are precisely the prefixes of the images under $\psi$ of the observations corresponding to $X$, as required. \hspace*{1pt}\hfill\rule[-.2ex]{.8ex}{1.6ex}\vspace{.5ex}\pagebreak[3] By the same argument as for Corollary \ref{cor:flinc}, we have \begin{corollary}\label{cor:ratref}For any rational model $\@ifnextchar[{\@model{M}}{\mathcal{M}}$, let $\mathcal{C}_{\@ifnextchar[{\@model{M}}{\mathcal{M}}}$ be as in Theorem $\ref{thm:ratshift}$. Then for any processes $P$ and $Q$, we have $P\refinedby[M]Q$ if and only if $\mathcal{C}_{\@ifnextchar[{\@model{M}}{\mathcal{M}}}[P]\@ifnextchar[{\@lessdet}{\mathrel\sqsubseteq}[\mathrm{T}]\mathcal{C}_{\@ifnextchar[{\@model{M}}{\mathcal{M}}}[Q]$. \end{corollary} \section{Implementation} We demonstrate the technique by implementing contexts with the property of Corollary \ref{cor:ratref}; source code may be found at \cite{testsource}. For the sake of efficiency we work directly rather than using the general construction of Theorem \ref{thm:ratshift}. The context {\tt C1} introduces refusal events and a {\tt stab} event, which can occur only when the corresponding normal events can be refused. This implements the refusal testing model, and the context {\tt CF} which allows only normal events optionally followed by some refusals (and {\tt stab}) implements the stable failures model. This is however suboptimal over large alphabets, in the typical situation where most events are refused most of the time. FDR4's inbuilt failures refinement checking codes refusal in terms of \emph{minimal acceptance} sets (checking that each such acceptance of the specification is a superset of one of the implementation). Minimal acceptances are typically smaller than maximal refusal sets. For models based on acceptance sets rather than refusal sets, we have to consider the whole collection of them rather than just the minimal ones. We can introduce a second extra copy of $\Sigma$, namely $\Sigma''$, where $a''$ will mean that the current stable state of $P$ can accept $a$, but the communication of $a''$ will not change the state of $P$. We can do this essentially by applying the previous construction (creating $a'$) to itself. This uses an order $\leq''$ under which $a''<'a'$ on the process ${\cal C}(P)$: \[{\cal C''}(P) = (\mathrm{\bf prioritise}({\cal C}(P),\leq'',\Sigma\cup\Sigma')\@ifnextchar[{\@dparallel}{\mathrel{\csp@parallel}}[\Sigma\cup\Sigma'\cup\Sigma''\cup\{stab\}]Reg''\] Here $Reg''$ is a process that initially will accept a $\Sigma$ event or $a'$ or $a''$ for the alphabetically first member $a$ of $\Sigma$. If either of the latter it will insist on getting each subsequent member of $\Sigma$ in one of these two forms until it has pieced together the complete acceptance set. Thus as soon as the present state of $P$ is recognised as stable, $Reg''$ establishes its complete acceptance set before permitting to $P$ to carry on further if desired. (For the acceptances model with only acceptances at the ends of traces, there is no need to do so.) As an alternative, $Reg''$ could communicate an event such as $done$ when it gets to the end of the list of events, which would enable us to hide the refusal events $\Sigma'$. Similar constructions with slightly different restrictions on the permissible sequences of events produce efficient processes for the revivals and refusal testing models. We will generalise this below. \subsection{Testing}\label{sec:test} We test this implementation by constructing processes which are first distinguished by the stable failures, revivals, refusal testing and acceptance models respectively (the latter two being also distinguished by the finite linear observations model). The processes, and the models which do and do not distinguish them, are shown in Table \ref{tab:heir} (recall the precision hierarchy of models: $\@ifnextchar[{\@model{T}}{\mathcal{T}}\leq\@ifnextchar[{\@model{F}}{\mathcal{F}}\leq\@ifnextchar[{\@model{R}}{\mathcal{R}}\leq\{\@ifnextchar[{\@model{A}}{\mathcal{A}},\@ifnextchar[{\@model{RT}}{\mathcal{RT}}\}\leq\@ifnextchar[{\@model{FL}}{\mathcal{FL}}$). The correct results are obtained when these checks are run in FDR4 with the implementation described above. \begin{table}[htb]\small \centering \begin{tabular}{llll} \hline Specification & Implementation & Passes & Fails \\ \hline $a\mathrel{\csp@then}\mathord{\csp@divergence}$ & $a\mathrel{\csp@then}\mathord{\csp@stop}$ & $\@ifnextchar[{\@model{T}}{\mathcal{T}}$ & $\@ifnextchar[{\@model{F}}{\mathcal{F}}$ \\ $((a\mathrel{\csp@then}\mathord{\csp@divergence})\mathrel{\csp@extchoice}\mathord{\csp@divergence})\mathrel{\csp@intchoice}\mathord{\csp@stop}$ & $a\mathrel{\csp@then}\mathord{\csp@divergence}$ & $\@ifnextchar[{\@model{F}}{\mathcal{F}}$ & $\@ifnextchar[{\@model{R}}{\mathcal{R}}$ \\ $(a\mathrel{\csp@then}\mathord{\csp@divergence})\mathrel{\csp@intchoice}(\mathord{\csp@divergence}\triangle(a\mathrel{\csp@then}\mathord{\csp@stop}))$ & $a\mathrel{\csp@then}\mathord{\csp@stop}$ & $\@ifnextchar[{\@model{R}}{\mathcal{R}},\@ifnextchar[{\@model{A}}{\mathcal{A}}$ & $\@ifnextchar[{\@model{RT}}{\mathcal{RT}}, \@ifnextchar[{\@model{FL}}{\mathcal{FL}}$ \\ $(a\mathrel{\csp@then}\mathord{\csp@stop})\mathrel{\csp@intchoice}(b\mathrel{\csp@then}\mathord{\csp@stop})$ & $(a\mathrel{\csp@then}\mathord{\csp@stop})\mathrel{\csp@extchoice}(b\mathrel{\csp@then}\mathord{\csp@stop})$ & $\@ifnextchar[{\@model{R}}{\mathcal{R}},\@ifnextchar[{\@model{RT}}{\mathcal{RT}}$ & $\@ifnextchar[{\@model{A}}{\mathcal{A}},\@ifnextchar[{\@model{FL}}{\mathcal{FL}}$ \\ \hline \end{tabular} \caption{Tests distinguishing levels of the model precision heir achy. $\triangle$ is the \emph{interrupt} operator; see \cite{roscoe2010understanding} for details.} \label{tab:heir} \end{table} \subsection{Performance} We assess the performance of our simulation by running those examples from Table 1 of \cite{gibson2015practical} which involve refinement checks (as opposed to deadlock- or divergence-freedom assertions), and comparing the timings for our construction against the time taken by FDR4's inbuilt failures refinement check (since $\@ifnextchar[{\@model{F}}{\mathcal{F}}$ is the only model for which we have a point of comparison between a direct implementation and the methods developed in this paper). Results are shown in Table \ref{tab:perf}, for both the original and revised contexts described above; the performance of the $\@ifnextchar[{\@model{FL}}{\mathcal{FL}}$ check is also shown. As may be seen, performance is somewhat worse but not catastrophically so. Note however that these processes involve rather small alphabets; performance is expected to be worse for larger alphabets. {\small \begin{table}[htb]\small \centering \begin{tabular}{|l|ccc|ccc|ccc|ccc|} \hline & \multicolumn{3}{|c|}{Inbuilt $\@ifnextchar[{\@model{F}}{\mathcal{F}}$} & \multicolumn{3}{|c|}{{\tt CF}} & \multicolumn{3}{|c|}{{\tt CF'}} & \multicolumn{3}{|c|}{{\tt FL}} \\ \hline File & $|S|$ & $|\Delta |$ & $T(s)$ & $|S|$ & $|\Delta |$ & $T(s)$ & $|S|$ & $|\Delta |$ & $T(s)$ & $|S|$ & $|\Delta |$ & $T(s)$\\ \hline {\tt inv} & 21 & 220 & 23 & 21 & 220 & 78 & 21 & 220 & 125 & 21 & 220 & 145\\ {\tt nspk} & 6.9 & 121 & 22 & 6.3 & 114 & 73 & 4.1 & 72 & 55 & 5.4 & 97M & 92\\ {\tt swp} & 24 & 57 & 16 & 30 & 123 & 61 & 43 & 76 & 107 & 42 & 93 & 131 \\ \hline \end{tabular} \caption{Experimental results comparing the performance of our construction with FDR3's inbuilt failures refinement check. $|S|$ is the number of states, $|\Delta|$ is the number of transitions, $T$ is the time (in seconds), all state and transition counts are in millions.} \label{tab:perf} \end{table} } \subsection{Example: Conflict detection} We now illustrate the usefulness of richer semantic models than just traces and stable failures by giving a sample application of the revivals model. Suppose that we have a process $P$ consisting of the parallel composition of two sub-processes $Q$ and $R$. The stable failures model is able to detect when $P$ can refuse all the events of their shared alphabet, or deadlock in the case when they are synchronised on the whole alphabet. However, it is unable to distinguish between the two possible causes of this: it may be that one of the arguments is able to refuse the entire shared alphabet, or it may be that each accepts some events from the shared alphabet, but the acceptances of $Q$ and $R$ are disjoint. We refer to the latter situation as a `conflict'. The absence of conflict (and similar situations) is at the core of a number of useful ways of proving deadlock-freedom for networks of processes running in parallel~\cite{deadlockfreedom1988}. The revivals model can be used to detect conflicts. For a process $P=Q\@ifnextchar[{\@dparallel}{\mathrel{\csp@parallel}}[X][Y]R$, we introduce a fresh event $a$ to represent a generic event from the shared alphabet, and form the process $P'=Q'\@ifnextchar[{\@dparallel}{\mathrel{\csp@parallel}}[X'][Y']R'$, where $Q'=Q\rename{\{(x,x),(x,a):x\in X\}}$, $X'=X\cup\{a\}$, and similarly for $R'$ and $Y'$. Conflicts of $P$ now correspond to revivals $(s,X\cap Y,a)$, where $s$ is a trace not containing $a$. \section{Timed Failures and Timed CSP} Timed CSP is a notation which adds a $WAIT\;t$ construct to CSP and reinterprets how processes behave in a timed context. So not only does it constrain the order that things happen, but also when they happen. Introduced in~\cite{rr}, it has been widely used and studied~\cite{sch,schop,davies1995brief}. $WAIT\:t$ behaves like $SKIP$ except that termination takes place exactly $t$ time units after it starts. It introduced and uses the vital principle of {\em maximal progress}, namely that no action that is not waiting for some other party's agreement is delayed: such actions do not sit waiting while time passes. That principle fundamentally changes the nature of its semantic models. Consider how the hiding operator is defined. It is perfectly legitimate to have a process $P$ that offers the initial visible events $a$ and $b$ for an indefinite length of time, say $P=a\mathrel{\csp@then} P1\mathrel{\csp@extchoice} b\mathrel{\csp@then} P2$. However $P\mathrel{\csp@hide} \{a\}$ cannot perform the initial $b$ at any time other than the very beginning because the $a$ has become a $\tau$. So $P\mathrel{\csp@hide} X$ only uses those behaviours of $P$ which refuse $X$ whenever time is passing. Timed CSP was originally described on the basis of continuous (non-negative real) time values. The basic unit of semantic discourse is a {\em timed failure}, the coupling of a timed trace~-- a sequence of events with non-strictly increasing times~-- and a timed refusal, which is the union of a suitably finitary products of a half-open time interval $[t_1,t_2)$ (containing $t_1$ but not $t_2$) and a set of events. Thus the refusal set changes only finitely often in a finite time, coinciding with the fact that a process can only perform finitely many actions in this time. This continuous model of time takes it well outside the finitary world that model checking finds comfortable. However it has long been known that restricting the $t$ in $WAIT\;t$ statements to integers makes it susceptible to a much more finitary analysis by region graphs~\cite{jackson}. However the latter represents a technique remote from the core algorithms of FDR so it has never been implemented for CSP, though it has for other notations~\cite{up}. In~\cite{ou1,ou2}, Joel Ouaknine made the following important discoveries: \begin{itemize} \item It makes sense to interpret Timed CSP with integer $WAIT$ over the positive integers as time domain. \item The technique of {\em digitisation} (effectively a uniform mapping of general times to integers) provides a natural mapping between these two representations. \item Properties that are {\em closed under inverse digitisation} can be decided over continuous Timed CSP by analysis over Discrete Timed CSP, and these include many practically important specifications. \item It is in principle possible to interpret Discrete Timed CSP in a modified (by the addition of two new operators) $tock$-CSP (a dialect developed by Roscoe in the early 1990's for reasoning about timed systems in FDR) and therefore in principle it is possible to reason about continuous Timed CSP in FDR. The definition of Timed CSP hiding over LTSs involves prioritising $\tau$ and $\tick$ over $tock$. \end{itemize} This was implemented as described in in~\cite{mctcsp}, originally in the context of the last versions of FDR2 and Timed CSP continues to be supported in FDR4. There is an important thing missing from these implementations, however, namely refinement checking in the Timed Failures Model, the details of which we describe below. That means that although it is possible to check properties of complete Timed CSP systems, there is no satisfactory compositional theory for (Discrete) Timed CSP. For example one cannot automate the reasoning that if $C[P,Q]$ (a term in Timed CSP) satisfies $SPEC$, and $P\sqsubseteq P'$ and $Q\sqsubseteq Q'$ then $C[P',Q']$ satisfied $SPEC$, because FDR does not give us a means of checking the necessary refinements. The purpose of this section is to show how Timed Failures refinement can be reduced to things FDR can do, filling this hole. Given the methods described in this paper to date, it is natural to try model shifting, and we will do this below. There is another option offered to us by late versions of FDR2, namely reduction to the Refusal Testing model which is implemented in that but not (at the time of writing) later versions of FDR. We will discuss these in turn. \subsection{A summary of Discrete Timed Failures} The Discrete Timed Failures model $\cal D$ consists, in one presentation, of sequences of the form \[(s_0,X_0,tock,s_1,X_1,tock,\ldots,s_{n-1},X_{n-1},tock,s_n,X_n)\] where each of $s_i$ is a member of $\Sigma^*$, each of $X_i$ is a subset of $\Sigma$, and $tock\not\in\Sigma$. Since $tock$ never happens from an unstable state, there is no need to have the possibility of $\bullet$ as discussed above for other models before $tock$, and it would be misleading to have it. We do however allow $\bullet$ for $X_n$. What this means, of course, is that the trace $s_0$ occurs, after which it reaches a stable state where $tock$ occurs, and this is repeated for other $s_i$ and $X_i$ until, after the last $tock$, the trace $s_n$ is performed followed by the refusal $x_n$ (not including $tock$) or potentially instability. Recall that we apply the principle of maximal progress, so that $tock$ only happens from a stable state: this means that if, after behaviour $\ldots s_n$, stability is not observable, then $tock$ can never happen and we have reached an error state. It is, however, convenient to have this type of error state in our model because misconstrued systems can behave like this. Like other CSP models, it has healthiness conditions, or in other words properties that the representation of any real process must satisfy. These are analogous to those of related untimed models, such as prefix closure and subset closure on refusal sets, and the certain refusal of impossible events. A property that it inherits from continuous Timed CSP is {\em no instantaneous withdrawal}, meaning that if, following behaviour $\beta$, it is impossible for a process to refuse $a$ leading up to the next $tock$, then the process must still have the possibility of performing $a$ after $\beta\trace{tock}$. This amounts to the statement that the passage of time as represented by $tock$ is not directly visible to the processes concerned, and is much discussed in the continuous context in~\cite{tsm,tni}. $\cal{D}$ is a rational model, since it can be obtained from the standard representation of $\@ifnextchar[{\@model{RT}}{\mathcal{RT}}$ by the rational transduction which deletes all refusal sets preceding events other than $tock$ (and replaces non-terminal occurences of $\mathrel{\csp@spot}$ by $\emptyset$, since $tock$ can only occur in stable states). Hence by Theorem \ref{thm:ratshift} it can be model shifted: there exists a context $\mathcal{C}_{\mathcal{D}}$ such that trace refinement under $\mathcal{C}_{\mathcal{D}}$ is equivalent to refinement in $\cal{D}$. The operational semantics of Discrete Timed CSP processes, under the transformation described and implemented in~\cite{mctcsp}. Have the property that $tock$ is available in every stable state and no unstable state. \subsection{Model shifting Timed Failures} We can capture this through model shifting by introducing a primed copy $a'$ of each $a\in\Sigma$ and using the following construct involving a regulator which ensures that an ordinary event cannot follow a refusal flag. This means that its traces consist of pairs of traces of $\Sigma$ and traces of $\Sigma'$ (which can be empty) interspersed with a $tock$ between consecutive pairs. \[\begin{array}{rcl} CS_{TF}(P) &=& \mathrm{\bf prioritise}(\leq,P\mathrel{\csp@interleave} RUN(\Sigma'),\Sigma)\@ifnextchar[{\@dparallel}{\mathrel{\csp@parallel}} Reg\\[2ex] Reg&=& tock\mathrel{\csp@then} Reg\\ &&\mathrel{\csp@extchoice} (\mathop{\csp@bigextchoice}\nolimits_{a\in\Sigma} a\mathrel{\csp@then} Reg)\\ &&\mathrel{\csp@extchoice} (\mathrel{\csp@extchoice}_{a\in \Sigma} a'\mathrel{\csp@then} Reg1)\\[1ex] Reg1&=& tock\mathrel{\csp@then} Reg\\ &&\mathrel{\csp@extchoice} (\mathop{\csp@bigextchoice}\nolimits_{a\in \Sigma} a'\mathrel{\csp@then} Reg1) \end{array}\] and $a'<a$ (as well as the implicit $a'<\tau$) for each $a\in\Sigma$. We have assumed here that any prioritisation needed to ensure maximal progress has already been applied before this, so that the LTS being operated on here has the correct behaviour under a normal interpretation. Note that this regulator allows only allows refusal events and $tock$ after refusal events $a'$, thus forcing the decorated traces (namely combinations of real events and the $a'$ ones signifying refusals) to exactly follow the structure set out for timed failures above. Thus aside from the exact structure of the model, we have followed the same procedure as that used for the stable failures model above. Note that \begin{itemize} \item Events in $\Sigma$ cannot follow refusal (primed events); only other primed events or $tock$. \item There would have been no harm in using the $stab$ event seen for stable failures (perhaps most elegantly so that it can only happen as the last event), but for Timed CSP processes this would make no difference to the equivalence or refinement relations induced. This is because $stab$ would be possible after a trace if and only if $tock$ is. \item Timed Failures refinement between two Timed CSP processes is decided by traces refinement between the decorated and regulated transformed processes as defined above. Thus it does not matter (when using them for this purpose) that the regulator adds in further refusals not possible for the original process (namely, after any $a'$ event, the regulated process refuses the whole of $\Sigma$. \end{itemize} \subsection{Reducing Timed Failures to refusal testing} In effect the Timed Failures model is the refusal testing model with all refusal sets that precede a non-$tock$ event ignored. If follows that if we can create a context $C[\cdot]$ in CSP such that $C[P]$ contains precisely the behaviours of $P$ that should not be forgotten, then we can state that $C[P]\sqsubseteq_{RT} C[Q]$ if and only if $P\sqsubseteq_{TF}Q$. This seems difficult, not least because when observing $P$ refusing something, we cannot stop it performing any action other than $tock$ without affecting the refusal itself. We can again solve this by use of a regulator process which allows any $\Sigma$ event to happen at any time from an unstable state and carry on, or from a stable state allow any $\Sigma$ event leading to the divergent process $DIV$, or $tock$ after which the regulator just carries on. \[\begin{array}{rcl} RE GP&=&(\mathop{\csp@bigextchoice}\nolimits_{a\in \Sigma} a\mathrel{\csp@then} RE GP)\\ &&\rhd\\ &&(tock \mathrel{\csp@then} RE GP\\ &&\mathrel{\csp@extchoice} \mathop{\csp@bigextchoice}\nolimits_{a\in\Sigma} a\mathrel{\csp@then} DIV) \end{array}\] $RE GP$ is thus a three-state process: in the initial state all the $\Sigma$ events can happen as can a $\tau$ taking it to the second and stable state. The third state is $DIV$. Note how unstable states and the fact that $DIV$ is refinement-maximal in the model are crucial in making this construction work. As before, this regulator is synchronised with $P$ to perform the transformation. So we have defined a projection \[\Pi_{TF}(P) = P\@ifnextchar[{\@dparallel}{\mathrel{\csp@parallel}} RE GP\] This and $MS TF(P)$ are thus faithful representations of the timed failures semantics of $P$ in two different models. They can be used for comparisons under refinement in these models. Because $\Pi_{TF}$ simply records behaviours with refusals before members of $\Sigma$ from all processes, we notice that in general \[P\sqsubseteq_{TF} Q\Leftrightarrow \Pi_{TF}(P)\sqsubseteq_{RT}\Pi_{TF}(Q) \Leftrightarrow P\sqsubseteq_{RT}\Pi_{TF}(Q)\] \section{Case study: Timed Sliding Window Protocol} The sliding window protocol has long been used as a case study with FDR: it is well known and reasonably easy to understand, at least in an untimed setting. It is a development of the alternating bit protocol in which the messages in a fixed-length window on the input stream are simultaneously available for transmission and acknowledgement across an erroneous medium which, in our version, can lose and duplicate messages but not re-order them. We have re-interpreted this in Timed CSP with the following features: \begin{itemize} \item There is a parameter $W$ which defines the width of the window. Because the windows held by the sender and receiver processes may be out of step, we need to define $B=2W$ to be the bound on the amount of buffering the system can provide. \item In common with other CSP codings of this protocol, we need to make the indexing space of places in the input and output streams finite by replacing the natural non-negative integers by integers modulo some $N$ which must be at least $2W$ (though there is no requirement that $B$ and $N$ are the same). This is sufficient to ensure that acknowledgement tags never get confused as referring to the wrong message. \item Round robin sending of message components from unacknowledged items in the current window: this clearly has a bearing on the timing behaviour of the transmission and acknowledgements that the system exhibits. \item The occurrence of errors is limited by a parameter which forces them to be spaced: at least $K$ time units must pass between consecutive ones. To achieve this elegantly we have used the controlled error model~\cite{roscoe1997tpc} in which errors are triggered by events that can be restricted by external regulators, and then lazily abstracted. It turns out that lazy abstraction (originally proposed in~\cite{roscoe1997tpc}) needs reformulating in Timed CSP. We will detail this below. Clearly it would be possible to use different error assumptions. \item We have assumed for simplicity that all ordinary actions take one time unit to complete. \item Where a message is duplicated, we need to assume that the duplicate is available reasonably quickly, say within 2 time units of the original send. If it can be deferred indefinitely this causes subtle errors in the sense that deferred duplication can prevent the system from settling sufficiently. \end{itemize} We can create a Timed Failures specification in CSP which says, following established models for regular CSP, that the resulting system is a buffer bounded by $B$ (so it never contains more than $B$ items) but is only obliged to input when it has nothing in it. Whenever it is nonempty it is obliged to output, but these two obligations do not kick in before some parameter $D$ time units from the previous external communication. This is slightly trickier than we might think because of the way in which the implementation process can entirely legitimately change its behaviour over time. So in an interval where it can legitimately accept or refuse an input $left.1$, at one point it can refuse to communicate it, while later accepting it after time has passed. In hand-coded $tock$-CSP this can be expressed as \begin{verbatim} TFBUFF(n) = let TFB(s,k) = if k < n then ((#s>0 & right!head(s) -> TFB(tail(s),0) [] #s<B & left?x -> TFB(s^<x>,0)) [> tock -> TFB(s,k+1)) else ((#s>0 & right!head(s) -> TFB(tail(s),0)) [] (#s==0 & left?x -> TFB(<x>,0)) [] ((#s>0 and #s<B) & (left?x -> TFB(s^<x>,0) [> STOP)) [] tock -> TFB(s,k)) within TFB(<>,0) \end{verbatim} This says that if we have not yet reached the point where offers must be made (i.e. \verb+k < n+) then it can perform permitted actions but can (expressed via \verb+[>+ or sliding choice) also refuse them and wait for time to pass. In Timed CSP a completely equivalent specification can be divided into three separate parts: one to control the buffer behaviour, one to handle what the specification says about when offers must be made as opposed to can be made, and the final one to control nondeterminism by creating the most nondeterministic timed process on a given alphabet. The last of these is notably trickier than in the untimed world because where a process has the choice, over a period, to accept or refuse an event $b$, it is not sufficient for it to make the choice once and for all. So we have \begin{verbatim} TCHAOS(A) = let onestep = ([] x:A @ x -> onestep) [> WAIT(1) within onestep;TCHAOS(A) \end{verbatim} In Timed CSP lazy abstraction needs to be formulated with this revised $Chaos$ definition \begin{verbatim} LAbs(A)(P) = (P [|A|] TCHAOS(A))\A \end{verbatim} noting that the passage of time ($tock$) is implicitly synchonised here as well as $A$, and priority of $\tau$ over $tock$ will also apply. In the main part of the buffer specification we do not create this style of nondeterminism, but instead use two variants of the externally visible events: one that will be made nondeterministic by the above and one that will not: \begin{verbatim} TFB(s) = (#s>0 & right!head(s) -> TFB(tail(s))) [] (#s>0 & rightnd!head(s) -> TFB(tail(s))) [] (#s==0 & left?x -> TFB(<x>)) [] (#s<B & (leftnd?x -> TFB(s^<x>))) \end{verbatim} The above always allows the nondeterministic variants of the events, and allows the ''deterministic'' ones when they should be offered if sufficient time has passed since the last visible event. Thus \verb+left+ is only offered deterministically when the buffer is empty, no matter how long since the last event. The choice over whether the offers available must be made, implemented by allowing the deterministic versions of events, is made by the following process \begin{verbatim} TEnable(E,R,m) = let Rest = diff(R,E) En = [] x:R @ x -> Dis(m) Dis(k) = if k==0 then En else (([] x:Rest @ x -> Dis(m)) [] WAIT(1);Dis(k-1)) within Dis(m) \end{verbatim} The three parameters here are the events that are enabled when there has been sufficient delay (here \verb+{|left,right|}+), the ones that reset the clock (here \verb+{|left,right,leftng,rightnd|}+ and the time by which offers have to be made. The full specifiation is put together by combining the above process, \verb+TFB(<>)+ and \verb+TCHAOS({|leftnd,rightnd|})+ and renaming \verb+leftnd, rightnd+ to respectively \verb+left, right+. Given the subtlety of the above and the fact that it is hard to be sure that \verb+TBUFF+ is right when it is written in $tock$ CSP rather than Timed CSP, it is reassuring that FDR readily proves that the two versions of the specification are equivalent in the Timed Failures model. The authors have run a number of checks of versions of the Timed CSP version of the protocol against this and other specifications. When compared against FDR's inbuilt stable failures refinement (a less discerning one than timed failures, so not always producing the same results) the overheads were low, typically about 50\% states and time. \subsection{Experiments} Files illustrating this section can be downloaded\footnote{\tt http://www.cs.ox.ac.uk/people/publications/personal/Bill.Roscoe.html}. The following reports on the check of the Timed CSP sliding window protocol with two items of $DATA$ and a window of width $4$ against the specification that says it is an $8$-bounded buffer when there is a minimum time between errors of $3$. It is specified to make stable offers by 42 time units. (In general the longer between errors, the faster the system makes settled offers.) The first check does this by model shifting, but it fails when the check is nearly complete because it can fail to have the offer ready on time. In fact the corresponding check is passed when 42 is replaced by 45 (but not 44). \begin{verbatim} assert CTFMS(TFBUFF(42)) [T= CTFMS(TLAbs({loss,dup})(ELSYSTEM(3))) \end{verbatim} The statistics from this check were as follows: {\em Visited 49,239,989 states and 166,698,488 transitions in 118.91 seconds (on ply 261} The following is a failures check of the same system without model shifting, which happens to find the same problem. \begin{verbatim} assert TFBUFF(42) [F= TLAbs({loss,dup})(ELSYSTEM(3)) \end{verbatim} {\em Visited 41,779,778 states and 107,648,549 transitions in 81.64 seconds (on ply 261)} The following are the statistics from the same check simplified to a no-model shifting traces check, which does not find the problem, and so passes. {\em Visited 15,413,107 states and 36,428,632 transitions in 19.71 seconds (on ply 186)} The smaller state count here is probably mainly because the normalised specification in this final case is significantly smaller, as the count-down to forcing an offer is irrelevant to traces. It is noteworthy that the overhead of model shifting (relatively speaking) is here less than reported earlier for the untimed case. We expect this is explained because the unshifted checks in the timed case already contain (timed) prioritisation before it is applied as part of model shifting. The experiments in this section were performed on a MacBook with a 2.7GHz Intel Core i7 processor. \section{Conclusions} We have seen how the expressive power of CSP, particularly when extended by priority, allows seemingly any finite behaviour model of CSP to be reduced to traces. Indeed this extends to any finitely expressed rules for what can be observed within finite linear behaviours, whether the resulting equivalence is compositional or not. This considerably extends the range of what can be done with a tool like FDR. The final section shows an alternative approach to this, namely reducing a less discerning model to a more discerning one without priority. This worked well for reducing timed failures to refusal testing, but other reductions (for example ones involving both acceptances and refusal sets) do not always seem to be so efficient. For example reducing a refusal sets process to the acceptances model seems unnecessarily complex as, for example, the process $CHAOS$ needs exponentially many acceptance sets where a single maximal refusal suffices. We discovered that it is entirely practical to use this technique to reason about large systems. Furthermore the authors have found that the debugging feedback that FDR gives to model shifting checks is very understandable and usable. In particular the authors were pleased to find that the results of this paper make automated reasoning about Timed CSP practical. They have already found it most informative about the expressive power of the notation. It seems possible that, as with untimed CSP, the availability of automated refinement checking will bring about enrichments in the notations of Timed CSP that help it in expressing practical systems and specifications. Model shifting means that it is far easier to experiment with automated verification in a variety of semantic models, so it will only very occasionally be necessary for a new one to be directly supperted. We believe that similar considerations will apply to classes of models that include infinite observations such as divergences, infinite traces, where these can be extended to incorporate refusals and acceptances as part of such observations. In such cases we imagine that model shifting will take care of the aspects of infinite behaviours that are present in their finite prefixes, and that the ways that infinitary aspects are handled will follow one of the three traces models available in CSP. These are \begin{itemize} \item finite traces (used in the present paper), \item divergence-strict finite and infinite traces, so as soon as an observation is made that can be followed by immediate divergence, we deem all continuations to be in the process model whether or not the process itself can do them operationally, and finally \item with full divergence strictness replaced by the weak divergence strictness discussed in~\cite{ds} (here an infinite behaviour with infinitely many divergent prefixes is added as above). \end{itemize} Thus it should be possible to handle virtually the entire hierarchy of models described in~\cite{roscoe2010understanding} in terms of variants on traces and model shifting. This will be the subject of future research. \subsubsection*{Acknowledgements} The authors are grateful to Tom Gibson-Robinson for helpful discussions and practical assistance with FDR4. This work has been partially sponsored by DARPA under agreement number FA8750-12-2-0247 and by a grant from EPSRC.
{'timestamp': '2019-04-23T02:26:16', 'yymm': '1904', 'arxiv_id': '1904.09875', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.09875'}
arxiv
\section{Introduction} \label{sec:intro} \input{sections/intro.tex} \section{Fall Detection} \label{sec:fall_detection} \input{sections/fall_detection.tex} \section{Privacy-Enhancing BWD-Based Fall Detection} \label{sec:private_falldetection} \input{sections/private_falldetection.tex} \section{Implementation} \label{sec:imp} \input{sections/implementation.tex} \section{Evaluation} \label{sec:eval} \input{sections/evaluation.tex} \section{Conclusion} \label{sec:conc} \input{sections/conclusion.tex} \bibliographystyle{ACM-Reference-Format} \subsection{Workflow} \label{sec:workflow} \begin{figure} \centering \includegraphics[width=\linewidth]{figures/high-level-arch.pdf} \caption{High-level workflow for MPC-based fall detection.} \label{fig:high_level} \end{figure} The principle stages of the proposed system architecture are illustrated in Figure \ref{fig:high_level} and described as follows: \begin{enumerate} \item \emph{Data acquisition}. The collection of tri-axial IMU data on a master device, e.g. smartphone, at an appropriate sampling frequency for fall detection. This may be unimodal input, i.e. only accelerometer~\cite{liu2012fall,mauldin2018smartfall,cao2012falld,doukas2007patient,yavuz2010smartphone}; multi-modal using, for example, accelerometer and gyroscope together~\cite{santoyo2018analysis}; or aggregating measurements from multiple sensors in a body-area network~\cite{luvstrek2009fall}. \item \emph{Secret sharing}. Given a data sample from a given IMU modality, $\textbf{d} = \{A_x, A_y, A_z\}$, the master device splits each component into $n$ shares using SSSS. In this work, we set $n$ equal to the number of authorised communicating parties, while the reconstruction threshold is fixed at $t=3$. In short, IMU samples are split as follows: \[ \textbf{D}= \begin{pmatrix} [A_x]_0 & [A_x]_1 & [A_x]_2 & \cdots & [A_x]_n \\ [A_y]_0 & [A_y]_1 & [A_y]_2 & \cdots & [A_y]_n \\ [A_z]_0 & [A_z]_1 & [A_z]_2 & \cdots & [A_z]_n \end{pmatrix} \] Where the rows comprise the individual shares of a particular component, while each column represents the $i^{th}$ share of all components. \item \emph{Share distribution}. The master device transmits the column elements $q \in \textbf{D}_{*j}$ to each cloud service instance individually; that is, $[A_x]_0$, $[A_y]_0$ and $[A_z]_0$, is transmitted to party $P_0$, $[A_x]_1$, $[A_y]_1$ and $[A_z]_1$ to $P_1$, and so on. By sharing each sample independently, no single cloud-based party may recover the underlying IMU samples assuming the reconstruction threshold above. In this work, we tackle the base case that the parties are operating under an honest-but-curious model, where the protocol specification is adhered to; the focus is on protecting against unauthorised disclosure of measurements from a single compromised service, as per Section \ref{sec:threat_model}. \item \emph{MPC-based inferencing}. The parties use arithmetic operations upon the received shares to perform fall detection feature extraction, such as computing the vector magnitude of IMU samples, and subsequently classification using a desired method, e.g. SVM, kNN, NB, etc. \item \emph{Classification decision}. The resulting label, $\textbf{L} \in \{0,1\}$, is used to denote the occurrence of a fall in a binary fashion. This value may be returned to the device in order to raise an alarm or telephone an emergency contact number, or performed by the cloud service itself. \end{enumerate} \subsection{Rationale} \todo[inline]{Disuss why cloud based approch and not locally} Existing work has already identified several advantages for adopting a cloud-based approach for mobility-based sensing services as opposed to, for example, a local deployment whereby IMU measurements are acquired, processed, and classified aboard the device itself~\cite{doukas2011managing,fortino2014bodycloud,gravina2017cloud}. This includes \emph{algorithm agility} for greater flexibility in changing the underlying classification algorithm on a single or small number of servers, without potential penetration issues of updating large numbers of devices in the field. A cloud-based approach also makes fewer assumptions about devices being able to ... A multi-party cloud-based approach...algorithm agility/can easily make updates, resilience against compromised parties (assuming non-collusion threshold). Bad points: communication overhead with device. Why not fully homomorphic encryption? TEE? SE? \todo[inline]{Forensics/auditing: trusted authority with access to cloud instances can retrieve IMU data shares} \subsection{Datasets} \subsection{Classification Error Rates} We now present error rates achieved by the models used in our MPC-based implementations of SmartFall~\cite{mauldin2018smartfall} using the standard and derivative-based features described in Section \ref{sec:feature_extraction}. The authors of \cite{mauldin2018smartfall} provide a publicly-available dataset comprising labelled IMU accelerometer measurements. These correspond to binary fall events from seven participants between 21--55 years old wearing a Microsoft Band 2 smartwatch. An off-line Python application was used to generate the model parameters. Firstly, a sliding window of 750ms was used with data sampled at a frequency of 31.25Hz, over which the vector magnitude and $\Delta s$ were computed. This was repeated for the derivative-based feature extraction. Next, six classifiers---Gaussian NB, SVM (with linear kernel), and logistic regression models for both feature types---were trained independently using the Scikit-Learn library~\cite{pedregosa2011scikit}. The inclusion of logistic regression goes beyond the classifiers evaluated in \cite{mauldin2018smartfall}. The dataset was split using a 80:20 training-test set ratio, and five-fold cross-validation was used to select the best performing model, whose final error rate was measured using the test set. The parameters of the best performing models were subsequently exported and implemented within the inferencing procedures detailed in Section \ref{sec:inferencing}. Tables \ref{tab:errors} and \ref{tab:errors_gradient} presents the error rates for each model with respect to classification accuracy, precision, recall, and F1-scores averaged across all participants for the SmartFall and derivative-based features respectively. The achieved results, i.e. $93.6\%$ accuracy and $0.733$ F1-score in the best case for SVM, are commensurate with the original SmartFall proposal and other fall detection work listed previously in Table \ref{tab:related}. We note that the derivative features outperform the original features in terms of precision, recall and F1-score, e.g. $0.804$ F1-score for NB versus $0.732$, and $0.835$ recall for SVM versus $0.663$; however, the classification accuracy is broadly similar for both feature types. \begin{table} \centering \caption{Classification error with SmartFall features.} \begin{threeparttable} \begin{tabular}{@{}ccccc@{}} \toprule \textbf{Algorithm} & \textbf{Accuracy} & \textbf{Precision} & \textbf{Recall} & \textbf{F1-Score}\\ \midrule \textbf{LR} & 0.933 & 0.780 & 0.688 & 0.731\\ \textbf{NB} & 0.926 & 0.704 & 0.762 & 0.732\\ \textbf{SVM} & 0.936 & 0.819 & 0.663 & 0.733\\\bottomrule \end{tabular} \begin{tablenotes} \item LR: Logistic Regression, NB: Na\"{i}ve Bayes, SVM: Support Vector Machine. \end{tablenotes} \end{threeparttable} \label{tab:errors} \end{table} \begin{table} \centering \caption{Classification error with derivative-based features.} \begin{threeparttable} \begin{tabular}{@{}ccccc@{}} \toprule \textbf{Algorithm} & \textbf{Accuracy} & \textbf{Precision} & \textbf{Recall} & \textbf{F1-Score}\\ \midrule \textbf{LR} & 0.936 & 0.771 & 0.812 & 0.791\\ \textbf{NB} & 0.934 & 0.725 & 0.903 & 0.804\\ \textbf{SVM} & 0.937 & 0.762 & 0.835 & 0.797\\\bottomrule \end{tabular} \end{threeparttable} \label{tab:errors_gradient} \end{table} \subsection{Computational Performance} This suite of experiments evaluates the latencies incurred by the device and cloud entities. \subsubsection{Device-side Latency} Here, we measure the average time to both construct the shares using SSSS and their transmission time to $n=3$ parties, with a reconstruction threshold of $t=3$. This is measured for the sharing and transmission of samples in a sliding window of 750ms (21 samples at 31.25Hz). The mean share construction time, averaged across all windows in the dataset, took 6.1ms ($\sigma=0.9$), with the upload time taking 398ms ($\sigma=23.9$ms), 404ms ($\sigma=25.9$ms) and 493.2ms ($\sigma=33.9$ms) for configurations A, B and C respectively. These timings are measured by the device-side Python application using the \texttt{time} module, which executed upon a Raspberry Pi 3 located in Belgium, Europe. The device specifications were listed previously in Section \ref{sec:device_app}. \begin{table} \centering \caption{Mean feature extraction and inferencing times (milliseconds) using SmartFall features for each configuration; S.D. shown in brackets.} \resizebox{\linewidth}{!}{% \begin{threeparttable} \begin{tabular}{@{}ccccccc@{}} \toprule \multicolumn{1}{l}{} & \multicolumn{2}{c}{\textbf{Config A}} & \multicolumn{2}{c}{\textbf{Config B}} & \multicolumn{2}{c}{\textbf{Config C}} \\ \midrule \textbf{Alg.} & \textbf{FE} & \textbf{IN} & \textbf{FE} & \textbf{IN} & \textbf{FE} & \textbf{IN} \\\midrule \textbf{LR} & | & 308 (91) & | & 383 (104) & | & 507 (150) \\ \textbf{SVM} & \textbf{779 (119)}$^{\dag}$ & --- & \textbf{1005 (125)} & --- & \textbf{1204 (194)} & --- \\ \textbf{NB} & | & 509 (103) & | & 557 (226) & | & 692 (114) \\ \bottomrule \end{tabular} \begin{tablenotes} \item $\dag$: Common feature extraction for all algorithms, | : Repeat all column-wise entries, ---: Repeat previous entry (column-wise), Alg.: Algorithm, FE: Feature extraction, IN: Inferencing. \end{tablenotes} \end{threeparttable} } \label{tab:smartfall_times} \end{table} \begin{table} \centering \caption{Mean feature extraction and inferencing times (milliseconds) using derivative-based features.} \resizebox{0.92\linewidth}{!}{% \begin{threeparttable} \begin{tabular}{@{}ccccccc@{}} \toprule \multicolumn{1}{l}{} & \multicolumn{2}{c}{\textbf{Config A}} & \multicolumn{2}{c}{\textbf{Config B}} & \multicolumn{2}{c}{\textbf{Config C}} \\ \midrule \textbf{Alg.} & \textbf{FE} & \textbf{IN} & \textbf{FE} & \textbf{IN} & \textbf{FE} & \textbf{IN} \\\midrule \textbf{LR} & | & 297 (106) & | & 365 (95) & | & 490 (104) \\ \textbf{SVM} & \textbf{68 (15)}$^{\dag}$ & --- & \textbf{102 (19)} & --- & \textbf{111 (24)} & --- \\ \textbf{NB} & | & 552 (103) & | & 602 (106) & | & 742 (113) \\ \bottomrule \end{tabular} \begin{tablenotes} \item $\dag$: Common feature extraction for all algorithms, | : Repeat all column-wise entries, ---: Repeat previous entry (column-wise), Alg.: Algorithm, FE: Feature extraction, IN: Inferencing. \end{tablenotes} \end{threeparttable} } \label{tab:gradient_times} \end{table} \subsubsection{Cloud-side Latency} We measure the average wall-clock times of the MPC-based feature extraction and inferencing procedures, which were described in Sections \ref{sec:feature_extraction} and \ref{sec:inferencing}. The total time for classifying each window can be considered as the sum of these two values. These were measured within the server-side Python application also via the \texttt{time} module. We report the times for each cloud configuration using the standard SmartFall features in Table \ref{tab:smartfall_times} and the derivative-based features in Table \ref{tab:gradient_times}. The results are also illustrated in Figures \ref{fig:execution_times_smartfall} and \ref{fig:execution_times_derivative}. \begin{figure} \centering \includegraphics[width=0.86\linewidth]{figures/total_times.pdf} \caption{Mean window execution times using SmartFall features for Config. A (no hatch), B (hatched), and C (dotted).} \label{fig:execution_times_smartfall} \end{figure} \begin{figure} \centering \includegraphics[width=0.88\linewidth]{figures/total_times_grad.pdf} \caption{Mean window execution times using derivative features for Config. A (no hatch), B (hatched), and C (dotted).} \label{fig:execution_times_derivative} \end{figure} \subsection{Discussion} One concern with MPC, raised previously in Section~\ref{sec:mpc_fund}, is the inter-party communication cost for performing multiplication- and comparison-heavy functions, which were used in the feature extraction and inferencing procedures. With the original SmartFall features, inferencing and feature extraction takes approximately 1900ms in the worst case with Naive Bayes under Config C, to $\sim$1100ms in the best case using LR with Config A. We also observe that the feature extraction stage dominates the execution times using this feature type, accounting for approximately two-thirds of each tested algorithm's total time. In contrast, this inverts with the use of derivative features, which require fewer rounds of inter-party communication; the \emph{inferencing} stage becomes the dominant factor for all algorithms, rather than the feature extraction. The execution time is also substantially reduced for the derivative-based features; reducing from 1087ms to 365ms using LR with Config A, for example, between the SmartFall and derivative-based features respectively. In general, the derivative-based features are extracted $\sim$11x faster than the originally proposed SmartFall features in \cite{mauldin2018smartfall}; the \emph{total} execution time, including inferencing, exhibits a $\sim$2.8x increase between derivative- and SmartFall-based experiments. We also see that the SVM and LR algorithms execute in similar times due to the mathematical similarities of inferencing, requiring an inner product operation that necessitates only a single round of communication. NB, however, is relatively expensive from requiring two multiplications for each feature in the window: one for finding the square of the feature subtracted from the mean, and the inverse multiplication (division) of this value by the variance. The choice of server configuration, i.e. the parties' geographical distribution, also has a significant effect on the total execution time; increasing, for example, from approximately 1087ms to 1711ms using SmartFall features with SVM-based inferencing, corresponding to a $\sim$57\% increase from Config A to C. Similar results are exhibited for all SmartFall- and derivative-based experiments. Lastly, we observe that, in some instances, the total execution time falls within that required for acquiring the measurements within the window (750ms). This applies for all derivative-based prediction using configurations A and B, but only the SVM and LR inferencing algorithms using Config C. This leads us to believe that these would be best suited for real-time prediction \subsection{Ambient Devices} \subsection{Ambient Device-based Systems} Privacy-enhancing fall detection has focused almost entirely on non-cryptographic techniques from ambient-based devices, such as silhouetting, blurring and foreground masking from camera data. Mastorakis and Makris~\cite{mastorakis2014fall} and Zhang et al.~\cite{zhang2012privacy} employ RGBD data from a Microsoft Kinect to detect five ADLs, using only the depth values and foreground mask of the RGB data, thus occluding users' facial features. Tao et al.~\cite{tao2012privacy} study the use of a ceiling-based sensor network comprising infrared cameras for fall detection in a home environment. The sensors output binary values to indicate the existence of persons underneath, which are used to model a map of the user's home. Edgcomb and Vahid~\cite{edgcomb2012automated} explore four techniques for privacy-enhancing video-based fall detection: \emph{blurring} (of the user), \emph{silhouetting}, and covering the user with a graphical \emph{box} and \emph{oval}. Raw video imagery is first taken from a stationary in-home camera, before applying one of these techniques. \subsection{BWD-based Systems} The use of ambient-based devices has inherent issues associated with detecting falls in occluded areas: fitting multiple cameras to cover all possible locations in the user's living environment---bathroom, bedroom, kitchen, and so on---may impose significant costs relating to unit installation and maintenance. Another paradigm employs devices likely to be already owned and carried by the user, such as a smartwatch or smartphone. Unlike the previous section, we are unaware of proposals that investigate privacy-enhancing fall detection from BWDs to the best of our knowledge. As such, we provide a general review of highly-cited and state-of-the-art work from the literature. Mauldin et al.~\cite{mauldin2018smartfall} present SmartFall, which uses accelerometer data sampled at 31.25Hz from a user-worn smartwatch to detect user falls. Smartwatch data is streamed to the user's smartphone that extracts features pertaining to the vector magnitude of the accelerometer data and the difference between the maximum and minimum magnitudes over a 750ms sliding window (Equations \ref{eq:mag} and \ref{eq:delta_s}). Na\"{i}ve Bayes, Support Vector Machine (SVM) and Recurrent Neural Network (RNN) classifiers are evaluated using labelled data from seven volunteers between 21--55 years old, alongside the Farseeing dataset~\cite{mellone2012smartphone} with data from 2,000 participants. Results of 0.37--0.79 precision, 0.55--1.0 recall, and 0.65--0.99 accuracy are reported, depending on the chosen dataset and classifier. \begin{equation} |\vec{v}| = \sqrt{x^2 + y^2 + z^2} \label{eq:mag} \end{equation} \begin{equation} \Delta s = \max(|\vec{v_i}|) - \min(|\vec{v_j}|), i \neq j \label{eq:delta_s} \end{equation} Liu and Cheng~\cite{liu2012fall} investigate IMUs placed at users' waists that collects accelerometer measurements at 200Hz. The vector magnitude is computed, along with the fast changed vector, vertical acceleration and posture angle between the vertical acceleration and gravity over a 0.1s sliding window. The features are inputted to an SVM with labelled fall data from 15 volunteers who performed 10 simulated falls and 11 ADLs repeated 10 times. The proposal yields error rates of 98.38\% accuracy, 97.40\% recall, and 99.27\% precision. Santoyo-Ram{\'o}n et al.~\cite{santoyo2018analysis} investigate IMUs attached to the user's chest, waist, wrist and thigh---the data from which is aggregated into 15 second segments by a smartphone. A sliding window of 0.5s is used in which the fast changed vector of accelerometer measurements is computed alongside the magnitudes' mean, standard deviation and mean absolute distance, and the mean rotation angle and mean module of the $(Y, Z)$ and $(X, Z)$ components. The features are inputted to SVM, k-Nearest Neighbour, Na\"{i}ve Bayes and Decision Tree classifiers, and evaluated using data from 19 subjects who performed 746 ADLs and falls. The geometric mean of the precision and recall is used as the performance metric, with results of 0.614--0.999 depending on the algorithm and sensor combination. Doukas et al.~\cite{doukas2007patient} investigate the use of an accelerometer attached to the user's foot for fall detection. The sensor data is transmitted to a receiving device, such as a laptop, where it is normalised and inputted to an SVM classifier in raw form after applying a Kalman filter. The evaluation reports a classification accuracy of 98.2\% using a limited set of labelled data from two volunteers. Cao et al.~\cite{cao2012falld} present E-FallD, which uses accelerometer data from an Android smartphone. The vector magnitude of the accelerometer components is computed and a global threshold is fixed for identifying falls based on the phone's measured acceleration. The work also investigates multiple thresholds customised to the user's gender, age, and body mass index (BMI). The authors recruit 20 participants of varying gender, age and BMI, who perform a total of 400 falls and 1200 ADLs. The approach yields results of 86.75\% precision and 85.5\% recall using global thresholds, and 92.75\% precision and 86.75\% recall with customised thresholds. Similarly, Vilarinho et al.~\cite{vilarinho2015combined} use accelerometer data from an Android smartphone and smartwatch. Here, a rule-based system is devised for threshold-based detection using the vector magnitude, fall index, and absolute vertical acceleration as features over a 0.8s sliding window. The approach is evaluated using data from three participants, who performed 12 falls and 7 ADLs each, with a reported 0.68 classification accuracy, 0.78 precision, and 0.63 recall. Yavuz et al.~\cite{yavuz2010smartphone} propose another system based on accelerometer values from an Android smartphone. In contrast, the authors use solely frequency domain features, namely the wavelet coefficients after applying a discrete wavelet transform. A threshold-based approach is used to test the coefficients generated from the phone against those of previously observed falls. 100 fall sequences from five volunteers were collected to evaluate the system, with results of 46-95\% precision and 88-90\% recall. Albert et al.~\cite{albert2012fall} use accelerometer values from an LG G1 Android smartphone located at the user's pelvic region. 178 features across several categories are subsequently extracted: moments, e.g. kurtosis and skew; moments between successive samples; smoothed root mean squares; extremities, e.g. min and max; histogram values; Fourier components; mean acceleration magnitude; and cross products. The features are inputted to five classifiers---SVM, Logistic Regression, Na\"{i}ve Bayes, Decision Tree and kNN---and evaluated using data from 18 simulated falls from 15 subjects, resulting in 98\% classification accuracy. Musci et al.~\cite{musci2018online} evaluate the use of recurrent neural networks (RNNs) and long short-term memory units (LSTMs), and propose a deep learning architecture for ternary fall detection for whether or not a fall has occurred, and whether one is about to occur. The proposal is evaluated using the SisFall dataset from \cite{sucerquia2018real}, comprising accelerometer and gyroscope measurements from a smartphone and a custom IMU attached to the waists of 38 users; the dataset is labelled with respect to the three aforementioned states. A confusion matrix of the three classes reports 92.86--97.16\% classification accuracy following hyperparameter optimisation. Lu{\v{s}}trek and Kalu{\v{z}}a~\cite{luvstrek2009fall} explore the use of a body area network (BAN) comprising 12 IMUs at the user's shoulders, wrists, hips, knees and ankles. Features are collected regarding the coordinates of units in a body coordinate system, their velocities, absolute distance, and relative angles. The features are used as input to seven machine learning algorithms---SVM, DT, kNN, NB, Random Forest, Adaboost, and bagging---implemented in the Weka library. Three participants were recruited who performed a total of 45 activities: 15 falls and 10 lying down, sitting down and walking ADLs each. 73.4--96.3\% classification accuracy is reported depending on the algorithm used, with SVM yielding the best case. \subsection{Discussion} Generally, fall detection systems rely upon traditional supervised learning algorithms and, more recently, deep neural networks (LSTMs and RNNs), trained over labelled fall data collected \emph{a priori}. The majority of existing work models binary classification, i.e. `fall' or `not fall', while other work also models whether a fall \emph{may} be about to occur and classification of general ADLs, such as sitting, walking, and lying down. \begin{figure} \centering \includegraphics[width=0.85\linewidth]{figures/fall_detection.pdf} \caption{Overview of IMU-based binary fall detection.} \label{fig:fall_detection} \vspace{-0.5cm} \end{figure} Additionally, the generation of \emph{global} models that generalise to all users, rather than individuals, is also a common facet of current work. For BWD-based systems, accelerometer measurements are used ubiquitously from which a variety of features are extracted prior to classification, which is illustrated in Figure \ref{fig:fall_detection} for the binary case. Most work focuses on time-domain features, such as the vector magnitude, arithmetic mean, standard deviation, and maximum and minimum values. The choice of algorithm remains varied, although SVMs tend to exhibit the best performance with 0.9838~\cite{liu2012fall}, 0.982~\cite{doukas2007patient} and 0.73--0.99~\cite{mauldin2018smartfall} accuracy. Recent work \cite{mauldin2018smartfall,musci2018online} has begun to explore the application of deep learning using LSTMs and RNNs with promising results---0.9286--0.9716~\cite{musci2018online} and 0.85--0.99~\cite{mauldin2018smartfall} accuracy---but work in the area remains limited. Rather than using machine learning for the discovery of optimal decision boundaries, another widely-used approach has been the use of manually set threshold values, which are discovered experimentally. Proponents of this approach have touted faster classification as an advantage over machine learning-based systems, and thus more suitable for constrained devices; however, such approaches generally yield higher error rates and are evaluated over limited datasets, e.g. with five~\cite{yavuz2010smartphone} and three~\cite{vilarinho2015combined} participants. We present a summary of BWD-based systems in Table \ref{tab:related}. \begin{table} \centering \caption{Comparison of BWD-based fall detection systems.} \resizebox{\columnwidth}{!}{% \begin{threeparttable} \renewcommand{\arraystretch}{1.3} \begin{tabular}{@{}ccc@{}} \toprule \textbf{Proposals} & \textbf{Algorithms} & \textbf{Error Rates} \\ \midrule SmartFall~\cite{mauldin2018smartfall} & NB, SVM, RNN & \makecell{0.37--0.79 (P), 0.55--1.0 (R),\\0.65--0.99 (A)} \\[0.4cm] Liu \& Cheng~\cite{liu2012fall} & SVM & \makecell{0.9927 (P), 0.9740 (R),\\0.9838 (A)} \\[0.5cm] S-R et al.~\cite{santoyo2018analysis} & \makecell{SVM, kNN,\\NB, DT} & 0.614--0.999 (GMPR) \\[0.3cm] Doukas et al.~\cite{doukas2007patient} & SVM & 0.982 (A) \\[0.3cm] E-FallD~\cite{cao2012falld} & Thresholds & \makecell{{\it GT}: 0.8675 (P), 0.855 (R)\\{\it CT}: 0.9275 (P), 0.8675 (R)}\\[0.3cm] Vilarinho et al.~\cite{vilarinho2015combined} & Thresholds & \makecell{0.78 (P), 0.63 (R), 0.68 (A)}\\[0.3cm] Yavuz et al.~\cite{yavuz2010smartphone} & Thresholds & 0.88--0.90 (P), 0.46--0.95 (R) \\[0.3cm] Albert et al.~\cite{albert2012fall} & \makecell{SVM, LR, NB,\\DT, kNN} & 0.982 (A) \\[0.3cm] Musci et al.~\cite{musci2018online} & RNN, LSTM & 0.9286--0.9716 (A) \\[0.3cm] Lu{\v{s}}trek \& Kalu{\v{z}}a~\cite{luvstrek2009fall} & \makecell{SVM, DT, kNN,\\NB, RF, Adaboost,\\Bagging} & 0.732--0.963 (A) \\ \bottomrule \end{tabular} \begin{tablenotes} \item P: Precision, R: Recall, A: Classification accuracy, GMPR: Geometric mean of precision and recall. \end{tablenotes} \end{threeparttable} } \label{tab:related} \end{table} \subsection{Device Application} \label{sec:device_app} A Python application was developed that reads CSV IMU data line-by-line from file and creates shares of each sensor modality component using SSSS. The resulting shares are base 64-encoded and JSON-formatted, and transmitted over TLS to their respective cloud parties using the method described in Section \ref{sec:workflow}. The application was deployed on a Raspberry Pi 3 Model B, with a Broadcom BCM2837 system-on-chip with a quad-core ARM Cortex-A53 at 1.2GHz, 1GB RAM, and Broadcom BCM43438 WiFi module (802.11N, 150 Mbit/s at 2.4GHz). The board was connected to a corporate WiFi network over which all communications occurred. Benchmarking procedures were also implemented using the Python \texttt{time} module, which wraps functions from the GNU C standard library, for measuring the upload time for transmitting the shares and receiving an acknowledgement from the server. \subsection{Cloud Framework} \label{sec:cloud_imp} We developed a cloud-based framework for performing MPC using arithmetic secret sharing comprising three applications. \textbf{\emph{Web server}}. A Python web server application that implements a public-facing service for retrieving JSON-formatted shares from the device application; performs database initialisation, storage, and retrieval; and bootstraps the launching of MPC-based operations with other parties and returns the result to the device. \textbf{\emph{MPyC instance}}. We make use of MPyC---an open-source Python library developed by Schoenmakers~\cite{schoenmakers:mpyc} intended for the rapid prototyping of MPC-based systems. MPyC is based on the VIFF framework by Damg{\aa}rd et al.~\cite{damgaard2009asynchronous}, which implements numerous MPC operation protocols using arithmetic secret sharing, and abstracts the complexity of network management, e.g. socket connections, message formatting and transmission, and reconstructing and computing upon shares between the parties. \textbf{\emph{Database}}. Stores time-series IMU shares received from the device application; our implementation uses MongoDB\footnote{MongoDB: \url{https://www.mongodb.com}}, a JSON document-based NoSQL database. \subsubsection{Deployment} \label{sec:server_app} \begin{table} \centering \caption{MPC server location configurations using AWS.} \begin{tabular}{cccc}\toprule \textbf{Config} & \textbf{Party 1} & \textbf{Party 2} & \textbf{Party 3} \\\midrule \textbf{A} & \texttt{US\_Oregon} & \texttt{Canada\_Central} & \texttt{US\_Ohio}\\ \textbf{B} & \texttt{US\_Oregon} & \texttt{Canada\_Central} & \texttt{Europe\_London}\\ \textbf{C} & \texttt{US\_Oregon} & \texttt{Europe\_London} & \texttt{Asia\_Singapore} \\\bottomrule \end{tabular} \label{tab:mpc_aws_configs} \end{table} We deploy our architecture using three MPC parties deployed in geographically disparate locations available via AWS: US West (Oregon), US East (Ohio), Central Canada, Europe (London), and South East Asia (Singapore). These configurations are listed in Table \ref{tab:mpc_aws_configs}, representing a strictly North American deployment (Config A), North America and Europe (Config B), and North America, Europe and Asia (Config C). The three server-side applications, listed above, were deployed collectively on separate AWS EC2 instances in their respective region; each instance was also pre-loaded with the other instances' TLS certificates and static IP addresses in configuration files. We use three \texttt{t2.micro} AWS instances, featuring a single-core Intel Xeon Scalable Processor at 3.3 GHz, with 1GB RAM and up to 0.72Gbit/s network throughput. At the time of publication, this incurs an operating cost of \$0.0116 (USD) per hour, or \$8.47 per month per instance~\cite{amazon:ec2}. \subsubsection{Feature Extraction} \label{sec:feature_extraction} In this work, we implement MPC-based feature extraction for replicating the SmartFall proposal by Mauldin et al.~\cite{mauldin2018smartfall}, which uses two features: the samples' vector magnitudes, and the difference between the maximum and minimum magnitudes, $\Delta s$ (Equations \ref{eq:mag} and \ref{eq:delta_s} respectively), over a sliding window of 750ms. This is managed in our framework by aggregating shares in an array of size 24, assuming a sampling frequency of 31.25Hz as in \cite{mauldin2018smartfall}. The vector magnitude is found for each sample via the Newton-Raphson method for computing the square root, while $\Delta s$ relies upon MPyC's maximum and minimum functions of a list of secret-shared elements. These are internally implemented by recursively finding the maximum (or minimum) of each list half, computing their difference, and performing a $\geq$ or $\leq$ operation with zero---the costs of which were listed in Table \ref{tab:comm}. An important observation is that the choice of features dramatically affects the asymptotic cost of MPC-based operations. Features reliant upon large numbers of multiplication, comparison or Boolean operations will necessitate many rounds of inter-party communication versus features that can be computed locally, such as additions or multiplications with public values, as noted in Section \ref{sec:mpc_fund}. We note that the SmartFall features, i.e. the vector magnitude and computing $\Delta s$ in a sliding window, imposes significant cost for the square root and minimum and maximum functions respectively. To address this, we also explore derivative-based features, which are used extensively for feature extraction in computer vision tasks \cite{sift, bay_surf, hog}. In particular, inspired by the SURF features used in Bay et al. \cite{bay_surf}, we use the sum of the derivatives and the sum of the squared derivatives for each data channel within the window, resulting in a six-dimensional feature vector, $f$, listed in Equation \ref{eq:f}. \begin{equation} f = \sum \frac{d x}{d t}, \sum \frac{d y}{d t}, \sum \frac{d z}{d t}, \sum \big(\frac{d x}{d t}\big)^{2}, \sum \big(\frac{d y}{d t}\big)^2, \sum \big(\frac{d z}{d t}\big)^2 \label{eq:f} \end{equation} Where $\frac{d x}{d t}$, $\frac{d y}{d t}$, and $\frac{d z}{d t}$ represent the differentials of the $x$, $y$ an $z$ measurement components respectively. The derivative is computed by convolution as follows: \begin{equation} \frac{d u}{d t} = A_u * h \end{equation} Where $A_u$ is the $u$-th component of an accelerometer measurement and $h$ is a filter kernel with impulse response $[-0.5, 0, 0.5]$. This feature extraction scheme is substantially more efficient, requiring only a single round of inter-party communication for each derivative squaring operation; the summing operations can be performed locally without communication, as can the convolution operation using a filter kernel that performs multiplications with constant values. \subsubsection{Privacy-Enhancing Inferencing} \label{sec:inferencing} We developed a range of MPC-based functions for privacy-preserving inferencing from measurement shares, which were implemented using the fundamental operations from Section~\ref{sec:mpc_fund}. At present, we have developed MPC-based implementations of the following classifiers. \emph{Logistic Regression} (LR) is a linear model of the probability of a binary response given a feature vector, $\vec{x} = [x_1, x_2, \dots, x_n]$. LR applies the logit function to $\vec{x}$ and parameters, $\vec{\theta}$, that minimise some cost function, e.g. ordinary least squares. The decision boundary, $h$, is represented by a linear combination of the parameters and features; that is, $h(\vec{\theta}, \vec{x}) = \sum^{n}_{i=0} \theta_{i}x_{i}$. A \emph{Support Vector Machine} (SVM) attempts to find a hyperplane that maximises the margin (distance) between linearly separable data points of classes in the training set. We implement a traditional SVM with linear kernel for binary classification, whereby samples are classified using a given set of weights, $\vec{w}$, feature vector, $\vec{x}$, bias, $b$, and evaluating Equation~\ref{eq:svm}. Note that, for inferencing, both SVM and LR reduce to a single inner product. With MPC, a na\"{i}ve approach requires $m$ rounds of communication to compute each $\theta_{i} x_{i}$; however, \cite{de2012design} demonstrated how to compute the inner product of two vectors using LSSS requiring only a single round of communication with (non-interactive) local summations, which is reproduced in Algorithm \ref{fig:inner_prod} for two shared vectors, $[\textbf{a}]$ and $[\textbf{b}]$. \begin{equation} C= \begin{cases} 1, & \text{if}\ \vec{\theta} \cdot \vec{x} + b \geq 0\\ 0, & \text{otherwise} \end{cases} \label{eq:svm} \end{equation} \begin{algorithm}[t] \DontPrintSemicolon \SetAlgoLined \KwData{$[\textbf{a}] = ([a_1], [a_2],\dots,[a_m]), [\textbf{b}] = ([b_1], [b_2], \dots, [b_m])$} \KwResult{$[c]$, where $c= \sum^{m}_{j=1}a_j \cdot b_j$} \ForEach{$i \in \{1, 2, \dots, 2t+1\}$ \textbf{\textup{in parallel}}}{ Party $P_i$ computes $d_i \gets \sum^{m}_{j=1}[a_j]_i \cdot [b_j]_i$ $P_i$ shares $d_i$ into $[d_i] \gets SSSS(d_i)$ } $[c] \gets \sum^{2t+1}_{i=1}([d_i] \cdot \prod_{\ell=1, \ell \neq i}^{2t+1}\frac{-\ell}{i-\ell})$ \KwRet $[c]$ \caption{Inner product with LSSS \cite{chen:ping}.} \label{fig:inner_prod} \end{algorithm} \emph{Na\"{i}ve Bayes} (NB) is a probabilistic classifier that uses Bayes' Theorem with a strong independence assumption between features. A feature vector is subsequently classified by maximising the posterior probability for each class label using the prior and conditional probabilities computed in the training phase. In our case, we use Gaussian NB to compute the log-likelihoods of real-valued inputs, parameterised by mean $\mu$ with variance $\sigma^{2}$ and evaluated as follows: \begin{equation} \label{eq:naivebayes} g_i(\vec{x}) = \ln(P(C_i)) - \sum_{j=1}^{n}\frac{||x_j-\mu_{ij}||^2}{2\sigma_{ij}^2} \end{equation} Where $n$ is the number of features and $P(C_i)$ is the probability of the occurrence of class $C_i$. \subsection{Document Structure} This paper proceeds with a general review of fall detection systems in Section \ref{sec:fall_detection}, which is followed by a discussion of the privacy challenges associated with existing systems. In Section \ref{sec:private_falldetection}, we present the assumptions and threat model in greater detail, before introducing and motivating the use of MPC as a solution to the aforementioned challenges. This section also develops the design of the proposed framework after which, in Section \ref{sec:imp}, the implementation details are discussed. Section \ref{sec:eval} presents an evaluation of the proposed framework, comprising a discussion of the methodology and experimental results in the form of classification and computational performance. Lastly, we conclude our work in Section \ref{sec:conc}, including a discussion of future research directions. \subsection{Privacy Challenges} To the best of our knowledge, privacy-enhancing BWD-based fall detection is yet to be investigated. Accelerometers, used in the bulk of current proposals, measure fine-grained movements at high frequency rates (typically $>$30Hz) on commodity devices, such as smartphones and smartwatches. A wealth of literature exists surrounding the identification of users based on their gait using accelerometer measurements alone from such devices~\cite{gafurov2007gait,thang2012gait,mantyjarvi2005identifying,juefei2012gait,gafurov2007survey}. Furthermore, we are also aware of IMU measurements being used for recognising non-fall ADLs~\cite{stikic2008adl, hong2010mobile} and performing user position tracking using dead reckoning~\cite{pratama2012smartphone,kang2015smartpdr,wang2018pedestrian}, which could be exploited to violate user privacy. \subsection{Applying Multi-Party Computation (MPC)} We observe that MPC can be applied to acquire data, extract features, and perform fall classification in a way that preserves IMU measurement confidentiality. In this work, we tackle the base case of MPC using arithmetic secret sharing from Shamir's secret sharing scheme (SSSS)~\cite{shamir1979share}, which is briefly described as follows. \subsubsection{Shamir's Secret Sharing Scheme} SSSS divides a secret $\mathcal{S}$ into $n$ shares, $\textbf{s} = \{s_1, s_2, \dots, s_n\}$, such that knowing $t$ shares from $\textbf{s}$ makes $\mathcal{S}$ easy to compute, but knowing fewer shares than $t$ renders $\mathcal{S}$ undetermined. The scheme relies on the fact that $t$ points are required to construct a polynomial of degree $t-1$, which is defined in the field $\mathbb{F}_P$. Next, $t-1$ positive integers, $a_1,\dots,a_{t-1}$ are chosen with $a_i < P$, with the secret assigned as $a_0 = \mathcal{S}$. The polynomial $f(x) = a_0 + a_{1}x + a_{2}x^{2} + a_{3}x^{3} + \cdots + a_{t-1}x^{t-1}$ is built with which $n$ points are constructed from $i=1,\dots,n$, to retrieve pairs $(i, f(i))$. Any subset with $t$ distinct pairs can be used to recover the constant term, $a_0$, i.e. the secret, which is found using Lagrange interpolation. \subsubsection{MPC from Arithmetic Secret Sharing} \label{sec:mpc_fund} An important observation is that SSSS allows each party to locally compute linear combinations of secrets and public values. Firstly, let us define $[x]_i$ as the $i^{th}$ share of data item, $x$. SSSS allows parties to locally compute the following arithmetic operations over their shares~\cite{chen:ping}: \begin{itemize} \item \emph{Addition} ($[c] \gets [a] + [b]$): Each party $p_i$ can compute a new share, $[c]_i$, that is the addition of two other shares, i.e. $[c]_i = [a]_i + [b]_i$. \item \emph{Addition of a secret and public value} ($[c] \gets [a] + \alpha, \alpha \in \mathbb{F}_P$): Party $p_i$ can compute a new share from the addition of a held share and a public value $\alpha \in \mathbb{F}_P$; that is, $[c]_i = [a]_i + \alpha$. \item \emph{Multiplication of a secret and public value} ($[c] \gets [a] \cdot \alpha, \alpha \in \mathbb{F}_P$): $p_i$ can compute a new share of the multiplication of a held share with a public value, $[c]_i = [a]_i \cdot \alpha$. \end{itemize} Computing a new share that is the multiplication of two others, $[c] = [a] \cdot [b]$, is less straightforward: given that SSSS uses polynomials of degree $t$, then $[a\cdot b] \neq [a]_i\cdot[b]_i$, as the resulting polynomial has degree $2t$. A method for computing $t$-degree polynomials representing $[c] \gets [a]\cdot[b]$ was presented in \cite{ben1988completeness}. As opposed to entirely local computation for addition of shares and the addition and multiplication of a share with a constant value, multiplying shares necessitates one round of communication. While many functions can be computed using only these operations, they preclude integer comparison, e.g. $=$, $\neq$, $<$, and $>$, and Boolean operations, e.g. {\tt AND} and {\tt OR}. The reader is referred to \cite{chen:ping} for a comprehensive description and analysis of these protocols; the differences in asymptotic communication complexity are reproduced from \cite{chen:ping} in Table \ref{tab:comm}. \begin{table} \centering \caption{Communication cost for MPC functions using arithmetic secret sharing~\cite{chen:ping}.} \begin{threeparttable} \begin{tabular}{cc} \toprule \textbf{Function} & \makecell{\textbf{Communication}\\\textbf{Cost} (in rounds)} \\ \midrule Multiplication & 1 \\ Inner Product & 1 \\ Inverse & 1 \\ Random element & 1 \\ Random bit & 3 \\ Equality ($=$) & 2 \\ $\geq$ & $2m+4$\\ $\leq$ & $2m+4$\\ {\tt AND}, {\tt OR} & $2\log(k)$\\\bottomrule \end{tabular} \begin{tablenotes} \item Where $k$ is the number of operands and $m$ is the bound $x,y \in [0,2^{m}-1]$ wherein operands $x$ and $y$ lie. \end{tablenotes} \end{threeparttable} \label{tab:comm} \end{table} \subsection{Assumptions and Threat Model} \label{sec:threat_model} An outsourcing model is assumed whereby a body-worn device streams IMU measurements to a cloud-based service that performs the feature extraction and classification. The focus is on binary classification for inferring the occurrence of falls using a globally-trained model in line with the bulk of existing work from Section~\ref{sec:fall_detection}. We divide the entities involved into two categories. \subsubsection{Source device} We assume the existence of a body-worn device---a smartphone in the user's pocket, smartwatch, a sensor placed on the user's belt, or otherwise---with an IMU. The device is also assumed to possess the ability to split measurements into shares using SSSS and stream them to an Internet-facing service over a secure channel, such as TLS using a pre-installed certificate. In this work, the IMU measurements are considered to be trusted; the focus is on the unauthorised disclosure of measurements after departing the device over a network to a cloud-based service. \subsubsection{Cloud service} Comprises the software components---database instance, REST APIs, and so on---for receiving, storing and classifying falls from IMU sensor data on a public cloud platform. The primary threat is the exfiltration and disclosure of raw IMU measurements from a remote attacker, such as from an unsecured, public-facing database, e.g. AWS S3 bucket, which could be used to model and infer users' general ADLs, position, or gait for user identification. This work tackles the base case for MPC where parties operate under an honest-but-curious model, whereby the protocol specification is executed as intended. We also assume that the output, i.e. whether or not a fall occurred, is learned by the cloud services in order to contact an emergency number or provide alternative remediation. We note that \emph{some} information may be revealed by the communication between the device and the cloud service, such as the absence of receiving protected IMU data at certain times of day, e.g. at night where the user deactivates their smartphone or smartwatch before sleeping. However, this is orthogonal to the ultimate goal of this work of preventing either the service or an external adversary from learning additional information from IMU measurements beyond that intended for detecting falls \subsection{Workflow} \label{sec:workflow} The principle stages of the proposed system were illustrated previously in Figure \ref{fig:high_level} and described as follows: \begin{enumerate} \item \emph{Data acquisition}. The collection of tri-axial IMU data on the device, e.g. smartphone, at an appropriate sampling frequency. This may be unimodal input, i.e. \emph{only} accelerometer~\cite{liu2012fall,mauldin2018smartfall,cao2012falld,doukas2007patient,yavuz2010smartphone}; multi-modal, e.g. accelerometer and gyroscope together~\cite{santoyo2018analysis}; or aggregating measurements from multiple sensors in a body-area network~\cite{luvstrek2009fall}. % \item \emph{Secret sharing}. Given a tri-axial IMU sample, $[A_x, A_y, A_z]$, the master device splits each component into $n$ shares using SSSS. In this work, we set $n$ equal to the number of authorised communicating parties, while the reconstruction threshold is fixed at $t=3$. In short, IMU samples are split as follows: \[ \textbf{D}= \begin{pmatrix} [A_x]_0 & [A_x]_1 & [A_x]_2 & \cdots & [A_x]_n \\ [A_y]_0 & [A_y]_1 & [A_y]_2 & \cdots & [A_y]_n \\ [A_z]_0 & [A_z]_1 & [A_z]_2 & \cdots & [A_z]_n \end{pmatrix} \] Where the rows comprise the individual shares of a particular component, while each column represents the $i^{th}$ share of all components. \item \emph{Share distribution}. The device individually transmits the column elements from $\textbf{D}$ to each cloud service instance; that is, $[A_x]_0$, $[A_y]_0$ and $[A_z]_0$, is sent to party $P_0$, $[A_x]_1$, $[A_y]_1$ and $[A_z]_1$ to $P_1$, and so on. By sharing each sample independently, no single cloud-based party may recover the underlying IMU samples assuming the reconstruction threshold above. \item \emph{MPC-based inferencing}. The parties use arithmetic operations upon the received shares to perform fall detection feature extraction, such as computing the vector magnitude of IMU samples, and subsequent classification using a desired machine learning classifiers, e.g. support vector machine (SVM), logistic regression (LR), and na\"{i}ve Bayes (NB). \item \emph{Classification decision}. The resulting label, $\textbf{L} \in \{0,1\}$, is used to denote the occurrence of a fall in a binary fashion. This value may be used to raise an alarm or telephone an emergency contact number. \end{enumerate}
{'timestamp': '2019-06-21T02:10:49', 'yymm': '1904', 'arxiv_id': '1904.09896', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.09896'}
arxiv
\section{Introduction} \label{sec:Introduction} \IEEEPARstart{T}hree dimensional (3D) perceptions aid robots to perceive and understand environments, thus increase the intelligence of robots. 3D geometric data can be provided by the depth camera, LiDAR scanners, and Radars. These sensors usually measure the distance between the target and sensor by projecting impulse signals to the target, such as laser and infrared light, and measuring the reflected pulses or time of flight. Hence, 3D geometric data can provide 3D spatial information and are less affected by the intensity of illumination, which are more robust than RGB (red, green, and blue) images. For instance, 3D sensors can perceive environments at night. Besides, 3D geometric data from different viewpoints can be fused to provide complete environmental information. Consequently, 3D geometric data are crucial for robots to execute tasks in real environments. Additionally, 3D understanding is eagerly in demand in real applications, including self-driving \cite{qi_frustum_2017}, automatic indoor navigation \cite{zhu_target-driven_2017}, and robotics \cite{zhang_environmental_2019, zhang_sensor_2019}. A point cloud generally represents a set of 3D points in 3D space ($\mathbb{R}^3$). Each point in the point cloud has three coordinates: $x$, $y$, and $z$. The point cloud is the most common representation of 3D geometric data. For instance, the raw data of depth camera, LiDAR scanners, and Radars, are usually point clouds. Moreover, other 3D representations of geometric data, such as the mesh, voxel, and depth image, can be converted to point clouds easily. Therefore, it is significant to recognize point clouds. For this reason, we consider designing methods to recognize point clouds in this paper. To be specific, we focus on two tasks: point cloud classification and segmentation. As shown in \autoref{fig:1-Overview}, the point cloud classification takes the whole point cloud as input and output the category of the input point cloud. The segmentation is to classify each point to a specific part of the point cloud. For these two tasks, there are two classic public datasets: ModelNet40 \cite{wu_3d_2015} and ShapeNet \cite{yi_scalable_2016}. A brief explanation of these two datasets is shown in \autoref{sec:Materials}. \begin{figure}[htpb] \centerline{\includegraphics[width=8cm]{figures/1-Overview.png}} \caption{\textbf{Applications of LDGCNN}: point cloud classification and segmentation.} \label{fig:1-Overview} \end{figure} Traditionally, researchers tend to design handcrafted features, like shape context \cite{belongie_shape_2002}, point feature histograms \cite{rusu_fast_2009}, local surface feature description \cite{guo_3d_2014}, and patch context \cite{hu_semantic_2018} to recognize point cloud. However, these handcrafted features are usually designed to solve specific problems and difficult to generalize to new tasks. Recently, deep learning methods achieve success on the classification and segmentation of objects \cite{krizhevsky_imagenet_2012, ronneberger_u-net:_2015}. Researchers are inclined to design data-driven methods to learn features and recognize point cloud automatically. Deep learning methods have developed significantly in processing 2D images \cite{girshick_rich_2014}, but it is still challenging to classify and segment point cloud accurately. Because point cloud is sparse, unstructured, and unordered, typical convolutional neural network (CNN) and recurrent neural network (RNN), which require regular image format or ordered sequence, are not suitable to recognize point cloud directly. To recognize point cloud, previous researchers propose three kinds of deep learning methods: view based method, volumetric method, and geometric method. We discuss these methods in detail below. \subsection{View based method} Previous researchers attempt to project a point cloud to 2D images along different directions and apply standard 2D CNN to extract features. The features learned from different images are aggregated to a global feature through a view-pooling layer, then this global feature can be utilized to classify objects \cite{wu_3d_2015, yavartanoo_spnet:_2018, chen_veram:_2018}. Although the view based method can achieve high accuracy in the classification task, it is nontrivial to apply this method to segment point cloud, which classifies each point to a specific category. \subsection{Volumetric method} Another method to recognize the point cloud is to apply voxelization to convert the unstructured point cloud to a structured 3D grid. Then 3D CNN and volumetric CNN can be utilized to classify and segment the 3D grid \cite{maturana_voxnet:_2015, wang_voxsegnet:_2019}. Nevertheless, the point cloud is sparse, and it is wasteful to use a 3D grid to represent a point cloud. Additionally, considering the high memory and computational cost of the volumetric data, the resolution of the 3D grid is usually low, which can cause quantization artifacts. Consequently, it is problematic to utilize the volumetric method to process the large-scale point cloud. \subsection{Geometric method} Recent years, Qi et al. introduce a PointNet to classify and segment point cloud directly \cite{qi_pointnet:_2017}, which pioneers the geometric method to process unstructured data \cite{zhang_directional_2019}. There are several characteristics for point cloud: sparsity, permutation invariance, and transformation invariance. Considering the sparsity of point clouds, researchers of PointNet process points directly rather than projecting the point cloud to images or a volumetric grid. To solve the permutation invariant problem, they design a multi-layer perceptron (MLP) to extract features from each point independently. Because MLPs for different points share the parameters, the same type of features can be extracted from different points. Moreover, they use the max pooling layer to extract a global feature to aggregate the information from all points. Both the shared MLP and max-pooling layer are symmetric, and thus the permutation invariant problem is solved. Additionally, they design a transformation network to estimate the affine transformation matrix of the point cloud. Then they offset the point cloud using the estimated transformation matrix to solve the transformation invariant problem. PointNet is ingenious and can classify and segment point cloud directly, but it processes each point individually without extracting the local information between a point and its neighbors. Local features among neighboring points can be more robust than the coordinates of each point because the point cloud can rotate and shift. In consequence, researchers of PointNet improve their network to PointNet++ \cite{qi_pointnet++:_2017}. They apply PointNet recursively on the nested partitions to extract local features and combine learned features from multiple scales. After extracting the local feature, PointNet++ achieves the state-of-art results for point cloud classification and segmentation tasks on several common 3D datasets. However, PointNet++ still processes each point in the local point set individually and does not extract the relationships, such as distance and edge vector, between the point and its neighbors. Recently, researchers start to design variants of PointNet for learning local features from the relationships of point pairs. The k-dimensional tree (KD-tree) is utilized to split point cloud into subdivisions. Researchers perform the multiplicative transformations on these subdivisions step by step and classify the point cloud. However, these partitions based on the KD-tree can vary if the scale of point cloud changes. Wang et al. design an edge convolutional operator to extract feature from a center point ($\bm{p_c}$) and the edge vector from its neighbor to itself ($\bm{p_n}-\bm{p_c}$). Moreover, they apply the k-nearest neighbors (K-NN) algorithm before each edge convolutional layer. Hence, not only do they search neighbors in the input Euclidean space $\mathbb{R}^3$, but also they cluster similar features in the feature space. Benefiting from extracting dynamic features, their dynamic graph CNN (DGCNN) achieves state-of-art results on several point cloud recognition tasks \cite{wang_dynamic_2018}. Lately, Xu et al. state that MLP does not work well on point cloud and they design a new convolutional layer, SpiderCNN, based on the Taylor polynomial to extract local geodesic information \cite{xu_spidercnn:_2018}. However, for the same input (1024 points) as DGCNN, the classification accuracy of SpiderCNN is slightly lower than that of DGCNN. Hence, this complex convolutional kernel seems not to outperform the MLP, which is concise and effective. To extract hierarchical features from the point cloud, Li et al. downsample the point cloud randomly and apply PointCNN to learn relationships among new neighbors in sparser point cloud \cite{li_pointcnn:_2018}. Moreover, they learn a transformation matrix from the local point set to permutate points into potentially canonical order. They decrease the forward time of network because of downsampling and achieves similar accuracy as DGCNN. However, the downsampling may influence the accuracy of the segmenting point cloud because each point should be classified into a category. Up to now, the DGCNN achieves the highest classification accuracy on the modelNet40 dataset when there are only 1024 points in the input point cloud. Although some other methods, such as self-organizing network \cite{li_so-net:_2018} and Geometric CNN (Geo-CNN) \cite{lan_modeling_2018}, can increase the classification accuracy further, they require denser point cloud, which consists of 10,000 or 5,000 points and normal vectors. Because datasets of ModelNet40 and ShapeNet are generated from computer-aided design (CAD) models, it is easy to acquire denser point cloud with normal vectors. Nevertheless, it is a different case in real applications. 3D sensors, like LiDAR scanners, can only capture sparse point cloud. Moreover, there is no normal vector in the raw data of 3D sensors. Consequently, DGCNN seems to be more practical, but there are also some problems. Firstly, the DGCNN relies on the transformation network to offset the point cloud, but this transformation network doubles the size of the network. Besides, the deep features and their neighbors may be too similar to provide valuable edge vectors. Moreover, there are many trainable parameters in the DGCNN, and it is difficult to find the best parameters when we train the whole network. In this paper, we optimize the network architecture of DGCNN to increase the performance and decrease the model size of the network. Because our network links the hierarchical features from different dynamic graphs, we call it linked dynamic graph CNN (LDGCNN). We apply K-NN and MLP with sharing parameters to extract the local feature from the central point and its neighbors. Then we add shortcuts between different layers to link the hierarchical features to calculate informative edge vectors. Moreover, there are two parts in our LDGCNN: convolutional layers (feature extractor) and fully connected layers (classifier). After training the LDGCNN, we freeze the feature extractor and retrain the classifier to improve the performance of the network. In the experiments, we evaluate our LDGCNN on two public datasets: ModelNet40 and ShapeNet for classification and segmentation. The experimental results show that our LDGCNN achieves state-of-art performance on these two datasets. The key contributions of this paper include: \begin{itemize} \item We link hierarchical features from different dynamic graphs to calculate informative edge vectors and avoid vanishing gradient problem. \item We remove the transformation network from the DGCNN and demonstrate that we can use MLP to extract transformation invariant features. \item We increase the performance of LDGCNN by freezing the feature extractor and retraining the classifier. \item We evaluate our LDGCNN and show that it achieves state-of-art performance on two classic 3D datasets. \end{itemize} In the following parts of this paper, we introduce the dataset of ModelNet40 and ShapeNet in \autoref{sec:Materials}. Then we describe the research problems, our theoretical methods, and network architecture in \autoref{sec:Methods}. The experimental results and corresponding discussions are shown in \autoref{sec:Results}. Finally, we conclude this paper in \autoref{sec:Conclusions}. \section{Materials} \label{sec:Materials} The dataset of classification is ModelNet40 \cite{wu_3d_2015}, which includes 12,311 CAD modes belonging to 40 categories. This dataset is split into training set (9843 models) and validation set (2468 models) \cite{qi_pointnet:_2017}. However, there is no testing set for ModelNet40. We discuss this problem in \autoref{subsubsec: classification}. In addition, each CAD model is sampled by 1024 points, which are normalized to a unit sphere. The segmentation task is based on ShapeNet part dataset \cite{yi_scalable_2016}, which consists of 16,881 CAD models from 16 categories. Previous researchers sample each CAD model to 2048 points, and each point is annotated with one of 50 parts. The training, validation, and testing datasets in our paper are the same as in \cite{wang_dynamic_2018}. \section{Methods} \label{sec:Methods} Our LDGCNN is inspired by PointNet \cite{qi_pointnet:_2017} and DGCNN \cite{wang_dynamic_2018}. We construct a directed graph for the point cloud. Then we extract features from the constructed graph and utilize features to classify and segment point cloud. In the following, we discuss the research problems and corresponding solutions. \subsection{Problem statement} The input of our method is a point cloud, which is a set of 3D points: \begin{equation} \{\bm{p_i} = (x_i, y_i, z_i)| i = 1, 2,...,n\} \end{equation} where $\bm{p_i}$ is one point of point cloud and consists of three coordinates $(x_i, y_i, z_i)$. The index of this point and the number of points in the point cloud are $i$ and $n$, respectively. We focus on two tasks in this paper: point cloud classification and segmentation. For point cloud classification, we need to classify the category of the whole point cloud. Hence, we should find a classification function $f_c$ to convert the input point cloud to the probability distribution on each category $\bm{Pr}$: \begin{equation} \bm{Pr} = f_c(\{\bm{p_1}, \bm{p_2},..., \bm{p_n}\}) \end{equation} As for the point cloud segmentation, each point $\bm{p_i}$ can be classified as a specific category. Therefore, we need to find a segmentation function $f_s$ to calculate the probability distribution on each category $\bm{Pr_i}$ for each point $\bm{p_i}$: \begin{equation} \{\bm{Pr_i}|i = 1, 2,..., n\} = \{f_s(\bm{p_i})|i = 1, 2,..., n\} \end{equation} There are several design constraints for the classification function $f_c$ and segmentation function $f_s$; \subsubsection{Permutation invariance} \label{subsubsec:permutation_invariance} The point cloud is a point set rather than the sequence signal. Thus the order of points may vary but does not influence the category of the point cloud. The classification function should not be influenced by order of input points: \begin{equation} \begin{split} (j_1, j_2,..., j_n) &\neq (i_1, i_2,..., i_n)\\ f_c(\{\bm{p_{j_1}}, \bm{p_{j_2}},..., \bm{p_{j_n}}\}) &= f_c(\{\bm{p_{i_1}}, \bm{p_{i_2}},..., \bm{p_{i_n}}\}) \end{split} \end{equation} where $(j_1, j_2,..., j_n)$ and $(i_1, i_2,..., i_n)$ represent two different sequences. \subsubsection{Transformation invariance} \label{subsubsec:transformation_invariance} In the real application, the relative position and direction between the sensor and objects might change, thus causing the translation and rotation of generated point cloud. However, the results of classification and segmentation should not be changed by the above affine transformations: \begin{equation} \begin{split} f_c(\bm{R}\{\bm{p_{i_1}}, \bm{p_{i_2}},..., \bm{p_{i_n}}\} + \bm{b}) &= f_c(\{\bm{p_{i_1}}, \bm{p_{i_2}},..., \bm{p_{i_n}}\})\\ f_s(\bm{R}\bm{p_i} + \bm{b}) &= f_s(\bm{p_i}) \end{split} \end{equation} where $\bm{R}$ and $\bm{b}$ are rotation matrix and translation vector. \subsubsection{Extracting local features} \label{subsubsec:local_features} Local features are relationships between the point and its neighbors, which are critical to the success of point cloud recognition. Consequently, we need to learn the local features rather than process each point individually: \begin{equation} \begin{split} \bm{P} &= \{\bm{p_i} = (x_i, y_i, z_i)| i = 1, 2,...,n\} \subset \mathbb{R}^3\\ \bm{L_i} &= \{\bm{p_{i_k}}| k = 1, 2,..., K\} \subseteq \bm{P}\\ \bm{Pr} &= f_c(\{\bm{L_1}, \bm{L_2},..., \bm{L_n}\})\\ \bm{Pr_i} &= f_s(\bm{L_i}) \end{split} \end{equation} where $\bm{L_i}$ and $\bm{p_{i_k}}$ are the local point set and neighbor of a point $\bm{p_i}$. \subsection{Graph generation} Graph neural network is an applicable method to process point cloud because it propagates on each node individually ignoring the input order of nodes and extracts edges to learn the information of dependency between two nodes \cite{zhou_graph_2018}. To apply graph neural network on the point cloud, we need to convert it to a directed graph first. Graph $G$ is composed of vertices $V$ and edges $E$: \begin{equation} \begin{split} G = (V, E), V \subset \mathbb{R}^C, E \subseteq V \times V \end{split} \end{equation} where $C$ is the dimension of each vertice. We do not construct fully connected edges for the point cloud because it consumes large memory. A simple method is to utilize K-NN to construct a locally directed graph, which is shown in \autoref{fig:2-graph}. In this local directed graph, each point $\bm{p_i}$ is a central node, and the edges $\bm{e_i}$ between the central node and its k-nearest neighbors are calculated: \begin{equation} \begin{split} G &= (V, E)\\ V &= \{\bm{p_i}| i = 1, 2,..., n\}\\ E &= \{\bm{e_i} = (\bm{e_{i_1}}, \bm{e_{i_2}},..., \bm{e_{i_K}})| i = 1, 2,..., n\}\\ \bm{e_{i_j}} &= \bm{p_{i_j}} - \bm{p_i} \end{split} \end{equation} where $\bm{p_{i_j}}$ and $\bm{e_{i_j}}$ are one neighbor of central point $\bm{p_i}$ and the directed edge from the neighbor $\bm{p_{i_j}}$ to the cnetral point $\bm{p_i}$, respectively. The number of neighbors is denoted by $K$. Like DGCNN \cite{wang_dynamic_2018}, we apply K-NN before each convolutional layer, then we can construct the local graph in both Euclidean space and feature space. Hence, the point $\bm{p_i}$ also represents the central point in the feature space and the point $\bm{p_{i_j}}$ is a neighbor of central point $\bm{p_i}$ in the feature space. \begin{figure}[htbp] \centerline{\includegraphics[width=8cm]{figures/2-Graph.pdf}} \caption{\textbf{Graph of point cloud}. The $\bm{p_i}$ and $\{\bm{p_{i_1}},..., \bm{p_{i_4}}\}$ are a central point and its neighbors. The directed edges from the neighbors to the central point are denoted by $\{\bm{e_{i_1}},..., \bm{e_{i_4}}\}$.} \label{fig:2-graph} \end{figure} \subsection{Graph feature extraction} After constructing the local graph, we extract local graph features based on the edge convolutional layer \cite{wang_dynamic_2018}. The feature extraction function $f_e$ is the same for all points, hence we exemplify this operation using one central point $\bm{p_i}$ and its $K$ neighbors. The input is the local graph of the central point $\bm{p_i}$ and the output is the local feature $\bm{l_i}$: \begin{equation}\label{eq:local_feature} \begin{split} \bm{l_i} &= f_e(G(\bm{p_i}, \bm{e_i}))\\ &= \max\{\bm{h}(\bm{p_i}, \bm{e_{i_1}}), \bm{h}(\bm{p_i}, \bm{e_{i_2}}),..., \bm{h}(\bm{p_i}, \bm{e_{i_K}})\} \end{split} \end{equation} where $\bm{h}(\bm{p_i}, \bm{e_{i_j}})$ is the hidden feature vector for the central point $\bm{p_i}$ and one edge vector $\bm{e_{i_j}}$. In (\ref{eq:local_feature}), we use the max-pooling operation because it is not influenced by the order of neighbors and can extract the most predominant feature among all edges. Moreover, we utilize a MLP to extract the hidden feature vector $\bm{h}(\bm{p_i}, \bm{e_{i_j}})$: \begin{equation} \begin{split} h_{c'}(\bm{p_i}, \bm{e_{i_j}}) &= \sum_{c=1}^C w_{c'c}p_{ic} + w_{c'(c+C)}(p_{i_jc} - p_{ic}) + b_{c'}\\ \bm{h(\bm{p_i}, \bm{e_{i_j}})} &= (h_{1}(\bm{p_i}, \bm{e_{i_j}}), h_{2}(\bm{p_i}, \bm{e_{i_j}}),..., h_{C'}(\bm{p_i}, \bm{e_{i_j}})) \end{split} \end{equation} where $p_{ic}$ and $p_{i_jc}$ are values in the channel $c$ for the central point $\bm{p_i}$ and its neighbor $\bm{p_{i_j}}$. The numbers of channels for input point $\bm{p_i}$ and output hidden feature vector $\bm{h(\bm{p_i}, \bm{e_{i_j}})}$ are $C$ and $C'$, respectively. The value in the channel $c'$ for the hidden feature vector is denoted by $h_{c'}(\bm{p_i}, \bm{e_{i_j}})$. The trainable parameters for the MLP are $w_{c'c}$, $w_{c'(c+C)}$, and $b_{c'}$. \subsection{Transformation invariant function} \label{subsubsec:transformation} Both PointNet \cite{qi_pointnet:_2017} and DGCNN \cite{wang_dynamic_2018} rely on a transformation network to estimate the rotation matrix of the point cloud and offset the point cloud. However, the transformation network doubles the size of the network. Moreover, through experiments, we find that the network still has satisfactory performance after removing the transformation network. Therefore, we discuss the corresponding reasons here. The output of transformation network is a $3\times3$ matrix $\bm{R}$, which can offset the point cloud $\bm{P}$: \begin{equation}\label{eq:rotaion_offset} \begin{split} \bm{P}_\text{offset} = \begin{bmatrix} x_{1} & y_{1} & z_{1} \\ x_{2} & y_{2} & z_{2} \\ \vdots & \vdots & \vdots \\ x_{n} & y_{n} & z_{n} \\ \end{bmatrix} \begin{bmatrix} r_{11} & r_{12} & r_{13} \\ r_{21} & r_{22} & r_{23} \\ r_{31} & r_{32} & r_{33} \\ \end{bmatrix} \end{split} \end{equation} where $r_{ij}$ is the value of rotation matrix $\bm{R}$ on the $i$th row and $j$th column. Additionally, $x_i$, $y_i$, and $z_i$ are coordinates of one point $\bm{p_i}$ in the point cloud $\bm{P}$. If we convert the MLP to matrix form, we can find the hidden feature vector is: \begin{equation}\label{eq:MLP} \begin{split} \bm{h}(\bm{P}) &= \begin{bmatrix} x_{1} & y_{1} & z_{1} \\ x_{2} & y_{2} & z_{2} \\ \vdots & \vdots & \vdots \\ x_{n} & y_{n} & z_{n} \\ \end{bmatrix} \begin{bmatrix} w_{11} & w_{12} & \cdots & w_{1C'} \\ w_{21} & w_{22} & \cdots & w_{2C'} \\ w_{31} & w_{32} & \cdots & w_{3C'} \end{bmatrix}\\ &+ \begin{bmatrix} b_{1} & b_{2} & \cdots & b_{C'} \end{bmatrix} \end{split} \end{equation} where $w_{ic'}$ and $b_{c'}$ are trainable parameters for the MLP in the channel $c'$. The number of output channel is $C'$. Compared (\ref{eq:MLP}) with (\ref{eq:rotaion_offset}), we can discover that they are similar. The difference is that the transformation network can estimate a specific matrix for each point cloud, whereas the MLP is static for all point cloud. The parameters of the MLP in different channels can rotate the point cloud with different angles and shift the point cloud with different translations. Considering that we have at least 64 output channels, the MLP can observe the point cloud along at least 64 directions, which can make the network to be rotation invariant approximately. Furthermore, we augment the training data to increase the generalization capability of the network. Like the PointNet++ \cite{qi_pointnet++:_2017}, we also rotate, shift, and scale the input point cloud randomly and add random noise on each point. After augmenting the training data, the network can learn rotation and translation invariant features. \subsection{LDGCNN architecture} The architecture of our LDGCNN is shown in \autoref{fig:3-LDGCNN_architecture} and the detailed explanations are stated in the caption of \autoref{fig:3-LDGCNN_architecture}. Our network is similar to the DGCNN \cite{wang_dynamic_2018}, and there are several differences between our LDGCNN and DGCNN: \begin{itemize} \item We link hierarchical features from different layers. \item We remove the transformation network. \end{itemize} The reason for removing the transformation network is discussed in \autoref{subsubsec:transformation}. Here we explain why we link hierarchical features from different layers. The first reason is that linking hierarchical features can avoid vanishing gradient problem for the deep neural network, which is demonstrated in \cite{he_deep_2016}. Besides, neighborhood indices based on current features are different from that based on previous features. Hence, we can learn new features by using current indices to extract edges from previous features. Moreover, neighbors of current features are similar to each other, which may cause the edge vector to approach zero. If we use current neighborhood indices to calculate the edges from previous features, we may get informative edge vectors. \begin{figure*}[htpb] \centerline{\includegraphics[width=16cm]{figures/3-LDGCNN_architecture.pdf}} \caption{\textbf{LDGCNN architecture}. MLP represents the multi-layer perceptron, which shares parameters for all points and is a symmetric function. The layer sizes of MLP are the same as the sizes of output or indicated by the numbers in the bracket. In the edge convolutional layer, the MLP $(C', C')$ for segmentation has two layers with $C'$ channels. The input of the classification network is a point cloud consisting of $n$ 3D points, and the output values are the classification scores for $m$ classes. The edge convolutional layer is applied to extract local features from the aggregated features and their neighbors, which consist of features from input layer (layer index = 1) to current layer (layer index = $L$). The numbers of channels in different layers are denoted by $C_1,..., C_L$. Then shortcuts and a max-pooling layer are used to aggregate features to a global feature, which is utilized to classify the point cloud by fully connected layers (MLPs). The segmentation network is an extension of classification network. We stack the global feature with the extracted local features and utilize MLPs to calculate segmentation scores for each point. We use the ReLU and Batchnorm in each layer. In the fully connected layers, Dropout layer is applied after each MLP layer.} \label{fig:3-LDGCNN_architecture} \end{figure*} \subsection{Freezing feature extractor and retraining classifier} We increase the performance of our network further by freezing feature extractor (network before the global feature) and retraining the classifier (MLP after the global feature). Theoretically, training the whole network can find the global minimum. However, there are too many parameters in the network, and it is almost impossible to find the global minimum through training. Conversely, the network may fall into an inferior local minimum because of the large size of parameters. After freezing the feature extractor, the back propagation only influences the parameters of the classifier, which consists of three fully connected layers. Consequently, I save the global features after training the whole network, then I utilize these global features to train the classifier separately, which help my network to achieve better performance. \section{Results} \label{sec:Results} \subsection{Implementation details} Our training strategy is the same as \cite{wang_dynamic_2018}. The Adam optimizer with 0.001 learning rate is used to optimize the whole network. The number of input points, batch size, and momentum are 1024, 32 and 0.9, respectively. We set the number of neighbors $K$ to 20. Moreover, the dropout rate is set as 0.5 for all dropout layers. After training the whole network, I freeze the feature extractor and retrain the classifier. In the retraining process, I only change the optimizer to Momentum. For the segmentation network, we change the number of neighbors $K$ to 30 because the number of input points changes to 2048. Other settings are the same as that for classification. Furthermore, we train our classification network on one NVIDIA TITAN V GPU. Then we use two NVIDIA TITAN V GPUs to train our segmentation network. \subsection{Point cloud classification} \label{subsubsec: classification} We evaluate the performance of our classification network on the ModelNet40 dataset \cite{wu_3d_2015}, which is introduced in \autoref{sec:Materials}. As shown in \autoref{tab:classification}, our LDGCNN achieves the highest accuracy on this dataset. For the same input (1024 points), the overall classification accuracy of our network (92.9\%) is 0.7\% higher than that of DGCNN and PointCNN. Previous researchers present that they split the ModelNet40 to the training set and testing set \cite{qi_pointnet:_2017, wang_dynamic_2018}. However, they write their best testing accuracy in their papers. The testing accuracy of the last epoch for their training can be about 1\%-1.5\% lower than their best testing accuracy. Consequently, they regard the testing set as the validation set and use the validation set to optimize their hyper-parameters and determine the time of stop training. Because we need to compare our networks with previous networks, we also use the validation set of ModelNet40 to determine the time to stop training. Since we use the same strategy of splitting dataset and training as previous researchers, the higher classification accuracy of our network still validates that our network achieves the state-of-art performance. \begin{table}[htbp] \centering \caption {\label{tab:classification} Classification results on ModelNet40. MA represents mean per-class accuracy, and the per-class accuracy is the ratio of the number of correct classifications to that of the objects in a class. OA denotes the overall accuracy, which is the ratio of the number of overall correct classifications to that of overall objects.} \renewcommand{\arraystretch}{1} \begin{center} \begin{tabular}{l l l l} \toprule Method & Input & MA (\%) & OA (\%) \\ \midrule PointNet \cite{qi_pointnet:_2017} & 1024 points & 86.0 & 89.2 \\ PointNet++ \cite{qi_pointnet++:_2017} & 5000 points+normal & - & 90.7 \\ KD-Net \cite{klokov_escape_2017} & 1024 points & - & 91.8 \\ DGCNN \cite{wang_dynamic_2018} & 1024 points & 90.2 & 92.2 \\ SpiderCNN \cite{xu_spidercnn:_2018} & 1024 points+normal & - & 92.4 \\ PointCNN \cite{li_pointcnn:_2018} & 1024 points & 88.1 & 92.2 \\ \midrule \textbf{Ours} & 1024 points & \textbf{90.3} & \textbf{92.9} \\ \bottomrule \end{tabular} \end{center} \end{table} \subsection{Point cloud segmentation} The Intersection-over-Union (IoU) is utilized to evaluate the performance of our network for point cloud segmentation on ShapeNet \cite{yi_scalable_2016}, which is described in \autoref{sec:Materials}. The segmentation network predicts the label of each point, and we compare the predictions with ground truth. Then the intersection and union of predicted points and ground truth points are calculated. The IoU is the ratio of the number of points in the intersection to that in the union. As shown in \autoref{tab:segmentation}, our segmentation network also achieves the state-of-art performance. Moreover, we compare our segmented point cloud with that of ground truth and DGCNN in \autoref{fig:4-segmentation}. \begin{table*}[!t] \centering \caption {\label{tab:segmentation} Part segmentation results on ShapeNet. The values in the table are mean IoU (\%) on points} \renewcommand{\arraystretch}{1} \begin{center} \resizebox{2.1\columnwidth}{!}{ \begin{small} \begin{sc} \begin{tabular}{l|c|cccccccccccccccc} \toprule & \textbf{mean} & areo & bag & cap & car & chair & ear & guitar & knife & lamp & laptop & motor & mug & pistol & rocket & skate & table\\ & & & & & & & phone& & & & & & & & & board & \\ \midrule \# shapes & &2690 &76 &55 & 898 & 3758 & 69 & 787 & 392 & 1547 & 451 & 202 & 184 & 283 & 66 & 152 & 5271\\ \midrule PointNet \cite{qi_pointnet:_2017} & 83.7 & 83.4 & 78.7 & 82.5 & 74.9 & 89.6 & 73.0 & \textbf{91.5} & 85.9 & 80.8 & 95.3 & 65.2 & 93.0 & 81.2 & 57.9 & 72.8 & 80.6\\ PointNet++ \cite{qi_pointnet++:_2017} & \textbf{85.1} & 82.4 & 79.0 & \textbf{87.7} & 77.3 & 90.8 & 71.8 & 91.0 & 85.9 & \textbf{83.7} & 95.3 & \textbf{71.6} & 94.1 & 81.3 & 58.7 & \textbf{76.4} & \textbf{82.6}\\ KD-Net \cite{klokov_escape_2017}& 82.3 & 80.1 & 74.6 & 74.3 & 70.3 & 88.6 & 73.5 & 90.2 & 87.2 & 81.0 & 94.9 & 57.4 & 86.7 & 78.1 & 51.8 & 69.9 & 80.3\\ DGCNN \cite{wang_dynamic_2018} & \textbf{85.1} & \textbf{84.2} & \textbf{83.7} & 84.4 & 77.1 & \textbf{90.9} & \textbf{78.5} & \textbf{91.5} & 87.3 & 82.9 & \textbf{96.0} & 67.8 & 93.3 & \textbf{82.6} & \textbf{59.7} & 75.5 & 82.0\\ \midrule \textbf{Ours} & \textbf{85.1} & 84.0 & 83.0 & 84.9 & \textbf{78.4} & 90.6 & 74.4 & 91.0 & \textbf{88.1} & 83.4 & 95.8 & 67.4 & \textbf{94.9} & 82.3 & 59.2 & 76.0 & 81.9\\ \bottomrule \end{tabular} \end{sc} \end{small} } \end{center} \end{table*} \begin{figure}[htpb] \centerline{\includegraphics[width=8cm]{figures/4-segmentation-01.png}} \caption{\textbf{Qualitative results for point cloud segmentation.} Comparison of segmentation results among ground truth (left), LDGCNN (middle), and DGCNN (right).} \label{fig:4-segmentation} \end{figure} \subsection{Time and space complexity analysis} We evaluate our model complexity by comparing the number of parameters and forward time of our classification network with that of other classification networks. The forward time is estimated based on the computing capacity of one NVIDIA TITAN V GPU. As shown in \autoref{tab:time}, the model size of our network is smaller than that of PointNet, PointNet++, and DGCNN. The forward time of our network is shorter than that of DGCNN, but is longer than that of PointNet++ and PointNet, because we apply K-NN to search neighbors in each edge convolutional layer. Compared to DGCNN, our network is more concise and achieves higher classification accuracy. \begin{table}[htbp] \centering \caption {\label{tab:time} Comparison of the number of parameters, forward time, and overall accuracy (OA) among different classification networks.} \renewcommand{\arraystretch}{1} \begin{center} \begin{tabular}{l l l l} \toprule Method & \#Parameters (M) & Forward time (ms) & OA (\%) \\ \midrule PointNet \cite{qi_pointnet:_2017} & 3.48 & \textbf{0.8} & 89.2\\ PointNet++ \cite{qi_pointnet++:_2017} & 1.48 & 1.4 & 90.7 \\ DGCNN \cite{wang_dynamic_2018} & 1.84 & 3.1 & 92.2 \\ \midrule \textbf{Ours} & \textbf{1.08} & 2.8 & \textbf{92.9} \\ \bottomrule \end{tabular} \end{center} \end{table} \subsection{Visualization and ablation experiments} T-distributed stochastic neighbor embedding (T-SNE) is utilized to show the performance of our feature extractor \cite{maaten_visualizing_2008}. The T-SNE reduces the dimension of high-dimensional features to visualize the separability of the features. As shown in \autoref{fig:5-t-SNE}, the extracted features are much more discriminative than original point cloud. \begin{figure}[htpb] \centerline{\includegraphics[width=8cm]{figures/5-T-SNE_Comparison.pdf}} \caption{\textbf{T-SNE visualization of original point cloud and extracted features.} Points with the same color belong to the same category.} \label{fig:5-t-SNE} \end{figure} Furthermore, we analyze the effects of our two components: removing the transformation network and freezing feature extractor and retraining the classifier. As shown in \autoref{tab:components}, we increase the overall classification accuracy from 91.8\% to 92.9\% by freezing feature extractor and retraining the classifier. Moreover, the transformation network cannot increase the performance of our network. This result validates our assumption that the MLP can substitute the transformation network for approximating rotation invariance, which is proposed in \autoref{subsubsec:transformation}. \begin{table}[htbp] \centering \caption {\label{tab:components} Effects of combining different components. The definitions of MA and OA are the same as in \autoref{tab:classification}.} \renewcommand{\arraystretch}{1} \begin{center} \begin{tabular}{l | c c c c} \toprule Transformation network & & x & & x\\ Freezing \& retraining & & & x & x\\ OA(\%) & 91.8 & 91.8 & \textbf{92.9} & 92.4 \\ MA(\%) & 88.8 & 89.0 & \textbf{90.3} & 89.7 \\ \bottomrule \end{tabular} \end{center} \end{table} \section{Conclusions} \label{sec:Conclusions} In this paper, we proposed a LDGCNN to classify and segment point cloud directly. Compared to DGCNN, we decreased the model size of network by removing the transformation network and optimized the network architecture through linking hierarchical features from different dynamic graphs. After training the whole network, we froze the feature extractor and retrained the classifier, which increased the classification accuracy on ModelNet40 from 91.8\% to 92.9\%. Our network achieved state-of-art performance on two standard datasets: ModelNet40 and ShapeNet. In addition, we provided theoretical analysis of our network and visualized classification and segmentation results. In the future, we will evaluate our LDGCNN on more semantic segmentation datasets and apply it on the real-time environmental understanding application. \bibliographystyle{IEEEtran}
{'timestamp': '2019-08-07T02:07:22', 'yymm': '1904', 'arxiv_id': '1904.10014', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.10014'}
arxiv
\section{Introduction}\label{sec_intro} Determining optimal routing paths in near real-time is at the heart of many humanitarian, civil, and commercial challenges. In the humanitarian realm, for example, traveling to disaster stricken areas can be problematic for relief organizations, particularly if flooding has destroyed bridges or submerged thoroughfares. Autonomous vehicle navigation is one of many examples on the commercial front, as self-driving cars rely heavily upon highly accurate road maps. Existing data collection methods such as manual road labeling or aggregation of mobile GPS tracks are currently insufficient to properly capture either underserved regions (due to infrequent data collection), or the dynamic changes inherent to road networks in rapidly changing environments. We believe the frequent revisits of satellite imaging constellations may accelerate existing efforts to quickly update road network and routing information. Yet while satellites in theory provide an optimal method to rapidly obtain relevant updates, most existing computer vision research methods for extracting information from satellite imagery are neither fully automated, nor able to extract routing information from imaging pixels. Current approaches to road labeling are often manually intensive. Classical computer vision techniques such as thresholding and edge detectors are often very helpful in identifying rough outlines of roads, though usually require manual inspection and validation. In the commercial realm, projects such as Bing Maps and Google Maps have been very successful in developing road networks from overhead imagery, though such processes are still labor intensive, and proprietary. On the open source side, OpenStreetMap (OSM) \cite{OpenStreetMap} is an extensive data set built and curated by a community of mappers. It primarily consists of streets, but contains some building, point of interest, and geographic labels as well. The OSM community developed a robust schema for roads, including the type of road (e.g., residential, highway, etc), as well as other metadata (e.g., speed limit). For many regions of the world, OSM road networks are remarkably complete, though in developing nations the networks are often poor. Regardless of region, OSM labels are at times outdated due to dynamic road networks, or poorly registered with overhead imagery (i.e., labels are offset from the coordinate system of the imagery), see Figure \ref{fig:osm_goof}. \begin{figure} \centering \includegraphics[width=0.95\linewidth]{osm_goofs.jpg} \caption{Potential issues with OSM data. Left: OSM roads (orange) overlaid on Khartoum imagery; the road traveling left to right across the image is missed. Right: OSM road labels (orange) and SpaceNet building footprints (yellow); in some cases road labels are misaligned and pass through buildings.} \label{fig:osm_goof} \vspace{-6pt} \end{figure} In dynamic scenarios (such as natural disasters) where timely high quality road network revisions are crucial, the manual and semi-automated techniques discussed above often fail to provide updates on the requisite sufficient timescale. A fully automated approach to road network extraction therefore warrants investigation, and is explored in the following sections. \subsection{Existing Approaches and Datasets} Existing publicly available labeled overhead or satellite imagery datasets tend to be relatively small, or labeled with lower fidelity than desired for foundational mapping. For example, the ISPRS semantic labeling benchmark \cite{isprs_sem} dataset contains high quality 2D semantic labels over two cities in Germany and covers a compact area of 4.8 km$^2$; imagery is obtained via an aerial platform and is 3 or 4 channel and 5-10 cm in resolution. The TorontoCity Dataset \cite{torontocity} contains high resolution 5-10 cm aerial 4-channel imagery, and $\sim700$ km$^2$ of coverage; building and roads are labeled at high fidelity (among other items), but the data has yet to be publicly released. The Massachusetts Roads Dataset \cite{MnihThesis} contains 3-channel imagery at 1 meter resolution, and $2600$ km$^2$ of coverage; the imagery and labels are publicly available, though labels are scraped from OpenStreetMap and not independently collected or validated. The large dataset size, higher resolution (0.3 meter resolution), and hand-labeled and quality controlled labels of SpaceNet \cite{spacenet} provide a significant enhancement over current datasets and provide an opportunity for algorithm improvement. Extracting road pixels in small image chips from aerial imagery has a rich history (e.g. \cite{zhang2017}, \cite{mattyus16} \cite{wang2016}, \cite{zhang2017}, \cite{sironi14}, \cite{mnihroads}). These algorithms generally use a segmentation + post-processing approach combined with lower resolution imagery (resolution $\geq 1$ meter), and OpenStreetMap labels. Extracting road networks directly has also been attempted by a number of studies. \cite{stoica04} attempted road extraction via a Gibbs point process, while \cite{wegner13} showed some success with road network extraction with a conditional random field model. \cite{chai13} used junction-point processes to recover line networks in both roads and retinal images \cite{turet13} extracted road networks by representing image data as a graph of potential paths. \cite{mattyus15} extracted road centerlines and widths via OSM and a Markov random field process. \cite{mosinska18} used a topology-aware loss function to extract road networks from aerial features as well as cell membranes in microscopy. Of greatest interest for this work are recent papers by \cite{deeproadmapper} and \cite{roadtracer}. \cite{deeproadmapper} used a segmentation followed by $A^{*}$ search, applied to the not-yet-released TorontoCity Dataset. The RoadTracer \cite{roadtracer} paper utilized an interesting approach that used OSM labels to directly extract road networks from imagery without intermediate steps such as segmentation. While this approach is compelling, according to the authors it ``struggled in areas where roads were close together'' \cite{fbastani_roads} and underperforms other techniques such as segmentation+post-processing when applied to higher resolution data with dense labels. Given that \cite{roadtracer} noted superior performance to \cite{deeproadmapper}, we compare our results to the RoadTracer paper. \subsection{DataSet} We use the SpaceNet 3 dataset, comprised of 30 cm WorldView3 DigitalGlobe satellite imagery and attendant road centerline labels. Imagery covers 3000 square kilometers, and over 8000 km of roads are labeled \cite{spacenet}. Training images and labels are tiled into $1300 \times 1300$ pixel ($\approx400 \, \rm{m}$) chips. \begin{comment} \begin{figure} \centering \includegraphics[width=0.95\linewidth]{sn_data1.jpg} \caption{400 m SpaceNet chip of Las Vegas. Left: SpaceNet GeoJSON road label. Right: RGB image overlaid with road centerlines (orange).} \label{fig:sn_data1} \vspace{-0pt} \end{figure} \end{comment} \section{Narrow-Field Baseline Algorithm}\label{sec:algo} We initially train and test an algorithm on the SpaceNet chips. Our approach is to combine recent work in satellite imagery semantic segmentation with improved post-processing techniques for road vector simplification. We begin with inferring a segmentation mask using convolutional neural networks (CNNs). We assume a road centerline halfwidth of 2m and create training masks using the raw imagery and SpaceNet geoJSON road labels (see Figure \ref{fig:baseline_train}). We create a binary road mask for each of the 2780 SpaceNet training image chips. To train our model we cast the training masks into a 2-layer stack consisting of source (road) and background. \begin{figure}[] \centering \includegraphics[width=0.95\linewidth]{baseline_train1.jpg} \caption{Left: SpaceNet GeoJSON label. Middle: Image with road network overlaid in orange. Right. Segmentation mask of road centerlines.} \label{fig:baseline_train} \vspace{-6pt} \end{figure} We train a segmentation model inspired by the winning SpaceNet 3 algorithm \cite{albu}, and use a ResNet34 \cite{resnet} encoder with a U-Net \cite{unet} inspired decoder. We include skip connections every layer of the network, with an Adam optimizer and a custom loss function of: \begin{equation} \label{eqn:c} \mathcal{L} =0.8 \times {\rm BCE} \, + \,0.2 \times (1 - {\rm Dice}) \end{equation} where `BCE' is binary cross entropy, and `Dice' is the Dice coefficient. 3-band RGB SpaceNet training data is split into four folds (1 fold is a unique combination of 75\% train + 25\% validation) and training occurs for 30 epochs. At inference time the 4 models from the 4 folds are merged by mean to give the final road mask prediction. These road mask predictions are then refined into road vectors via the process described in Figure \ref{fig:baseline}. \begin{figure}[] \centering \includegraphics[width=0.95\linewidth]{baseline.jpg} \caption{Initial baseline algorithm. Left: Using road masks, we train CNN segmentation algorithms (such as PSPNet \cite{pspnet} or U-Net \cite{unet}) to infer road masks from SpaceNet imagery. Left center: These outputs masks are then refined using standard techniques: thresholding, opening, closing, and smoothing. Right center: A skeleton is created from this refined mask (e.g.: sckit-image skeletonize \cite{skimage}. Right: This skeleton is subsequently rendered into a graph structure with the {\it sknw} package \cite{sknw}. } \label{fig:baseline} \vspace{-6pt} \end{figure} We also attempt to close small gaps and remove spurious connections not already corrected by the opening and closing procedures. As such, we remove disconnected subgraphs with an integrated path length of less than 80 meters. We also follow \cite{albu} and remove terminal vertices if it lies on an edge less than 10 pixels in length, and connect terminal vertices if the distance to the nearest non-connected node is less than 20 pixels. The final narrow-field baseline algorithm consists of the steps detailed in Table \ref{tab:algo}; an example result is displayed in Figure \ref{fig:baseline_ex}. \begin{table}[] \caption{Baseline inference algorithm} \label{tab:algo} \small \centering \begin{tabular}{ll} \toprule Step & Description \\ \toprule 1 & Apply the 4 trained segmentation models to test data \\ 2 & Merge these 4 predictions into a total road mask \\ 3 & Clean road mask with opening, closing, smoothing \\ 4 & Skeletonize road mask \\ 5 & Extract graph from skeleton \\ 6 & Remove spurious edges and close small gaps in graph \\ \bottomrule \end{tabular} \end{table} \begin{figure}[] \centering \includegraphics[width=0.95\linewidth]{baseline_ex.jpg} \caption{Sample output of baseline algorithm applied to SpaceNet test data.} \label{fig:baseline_ex} \vspace{-6pt} \end{figure} \section{Evaluation Metrics}\label{sec:metrics} Historically, pixel-based metrics (such as F1 score) have been used to assess the quality of road proposals, though such metrics are suboptimal for a number of reasons (see \cite{spacenet} for further discussion). Accordingly, we use the graph-theoretic Average Path Length Similarity (APLS) and map topology (TOPO) \cite{topo_metric} metrics that were created to measure similarity between ground truth and proposal road graphs. \subsection{APLS Metric}\label{sec:apls} \begin{figure} \centering \includegraphics[width=0.95\linewidth]{apls_fig0.jpg} \caption{\textbf{APLS metric.} APLS compares path length difference between sample ground truth and proposal graphs. Left: Shortest path between source (green) and target (red) node in the ground truth graph is shown in yellow, with a path length of $\approx948$ meters. Right: Shortest path between source and target node in the proposal graph with 30 edges removed, with a path length of $\approx1027$ meters; this difference in length forms the basis for the metric \cite{spacenet}. } \label{fig:apls_fig0} \vspace{-6pt} \end{figure} To measure the difference between ground truth and proposal graphs, the APLS \cite{spacenet} metric sums the differences in optimal path lengths between nodes in the ground truth graph G and the proposal graph G', with missing paths in the graph assigned a score of 0. The APLS metric scales from 0 (poor) to 1 (perfect). Missing nodes of high centrality will be penalized much more heavily by the APLS metric than missing nodes of low centrality. For the SpaceNet 3 challenge midpoints were injected along each edge of the graph, and routes computed between all nodes in the graph. For the large graphs we consider here this approach is computationally intractable, so in this paper we refrain from injecting midpoints along edges, and select 500 random control nodes. This approach yields an APLS score $\approx3-6\%$ lower than the greedy approach since midpoints along the graph edges tend to increase the total score. In essence, APLS measures the optimal routes between nodes of interest, so in our effort to determine optimal routes directly from imagery, this metric provides a good measure of success. \subsection{TOPO Metric} The TOPO metric \cite{topo_metric} is an alternative metric for computing road graph similarity. TOPO compares the nodes that can be reached within a small local vicinity of a number of seed nodes, categorizing proposal nodes as true positives, false positives, or false negatives depending on whether they fall within a buffer region (referred t to as the ``hole size''). By design, this metric evaluates local subgraphs in a small subregion ($\sim 300$ meters in extent), and relies upon physical geometry. Connections between greatly disparate points ($>300$ meters apart) are not measured. \section{Comparison with OSM}\label{sec:osm} OpenStreetMap (OSM) is a great crowd-sourced resource curated by a community of volunteers, and consists primarily of hand-drawn road labels. Though OSM is a great resource, it is incomplete in many areas (see Figure \ref{fig:osm_goof}). As a means of comparison between OSM and SpaceNet labels, we use our baseline algorithm to train two models on SpaceNet imagery. One model uses ground truth masks rendered from OSM labels, while the other model uses the exact same algorithm, but uses ground truth segmentation masks rendered from SpaceNet labels. Table \ref{tab:osm_vs_sn} displays APLS scores computed over a subset of the SpaceNet test chips, and demonstrates that the model trained and tested on SpaceNet labels is far superior to other combinations, with a $\approx 60 - 90\%$ improvement. This is likely due in part to the the more uniform labeling schema and validation procedures adopted by the SpaceNet labeling team. \begin{table}[h] \caption{OSM vs SpaceNet Performance} \label{tab:osm_vs_sn} \small \centering \begin{tabular}{llllll} \toprule Model & Test Labels & APLS \\ \toprule OSM & OSM & 0.47 \\ OSM & SpaceNet & 0.46 \\ SpaceNet & OSM & 0.39 \\ SpaceNet & SpaceNet & 0.75 \\ \bottomrule \end{tabular} \end{table} \section{Scaling to Large Images} \label{sec:cresi} The process detailed in Section \ref{sec:algo} works well for small input images below $\sim2000$ pixels in extent, yet fails for images larger than this due to a saturation of GPU memory. For example, even for a relatively simple architecture such as U-Net, typical GPU hardware (NVIDIA Titan X GPU with 12 GB memory) will saturate for images $> 2000$ pixels in extent and reasonable batch sizes $\leq 4$. In this section we describe a straightforward methodology for scaling up the algorithm to larger images. We call this approach City-scale Road Extraction from Satellite Imagery (CRESI). The first step in this methodology provided by the Broad Area Satellite Imagery Semantic Segmentation (BASISS) \cite{basiss} methodology; this approach is outlined in Figure \ref{fig:SIMRDWN_training}, and returns a road pixel mask for a large test image. \begin{figure}[] \begin{center} \includegraphics[width=0.95\linewidth]{basiss_test.jpg} \end{center} \caption{Process of slicing a large satellite image (top) and ground truth road mask (bottom) into smaller cutouts for algorithm training or inference \cite{basiss}.} \label{fig:SIMRDWN_training} \vspace{-6pt} \end{figure} We take this scaled road mask and apply Steps 3-6 of Table \ref{tab:algo} to retrieve the final road network prediction. The final algorithm is given by Table \ref{tab:algo2}. The output of the CRESI algorithm is a {\it networkx} \cite{networkx} graph structure, with full access to the many algorithms included in the {\it networkx} package. \begin{table}[h] \caption{CRESI Inference Algorithm} \label{tab:algo2} \small \centering \begin{tabular}{ll} \toprule Step & Description \\ \toprule 1 & Split large test image into smaller windows \\ 2 & Apply the 4 trained models to each window \\ 3 & For each window, merge the 4 predictions \\ 4 & Build the total normalized road mask \\ 5 & Clean road mask with opening, closing, smoothing \\ 6 & Skeletonize road mask \\ 7 & Extract graph from skeleton \\%with {\it sknw} \\ 8 & Remove spurious edges and close small gaps in graph \\ \bottomrule \end{tabular} \end{table} \section{Large Area Testing} \subsection{Test Data}\label{sec:testdata} We extract test images from all four of the SpaceNet cities with road labels: Las Vegas, Khartoum, Paris, and Shanghai. As the labeled SpaceNet regions are non-contiguous and irregularly shaped, we define rectangular subregions of the images where labels do exist within the entirety of the region. The SpaceNet road labels in these regions form our ground truth, while the images serve as input to our trained model. The regions are defined below in Table \ref{tab:test_regs}. \begin{comment} \begin{figure}[h] \begin{center} \includegraphics[width=0.97\linewidth]{shanghai_reg0.jpg} \end{center} \caption{SpaceNet road vector labels over Shanghai (purple). The label boundary is discontinuous and irregularly shaped, so we define rectangular regions for testing purposes (e.g.~ the blue region denotes test region Shanghai$\_$0),} \label{fig:shanghai_reg0} \end{figure} \end{comment} \begin{table}[h] \caption{Test Regions} \label{tab:test_regs} \small \centering \begin{tabular}{lll} \toprule Test Region & Area & Road Length \\ & (Km$^2$) & (Total Km) \\ \toprule Khartoum$\_$0 & 3.0 & 76.7 \\ Khartoum$\_$1 & 8.0 & 172.6 \\ Khartoum$\_$2 & 8.3 & 128.9\\ Khartoum$\_$3 & 9.0 & 144.4 \\ Las Vegas$\_$0 & 68.1 & 1023.9\\ Las Vegas$\_$1 & 177.0 & 2832.8\\ Las Vegas$\_$2 & 106.7 & 1612.1\\ Paris$\_$0 & 15.8 & 179.9\\ Paris$\_$1 & 7.5 & 65.4\\ Paris$\_$2 & 2.2 & 25.9\\ Shanghai$\_$0 & 54.6 & 922.1\\ Shanghai$\_$1 & 89.8 & 1216.4\\ Shanghai$\_$2 & 87.5 & 663.7\\ \hline Total & 608.0 & 9064.8\\ \bottomrule \end{tabular} \end{table} \section{Results}\label{sec:results} We apply the CRESI algorithm described in Table \ref{tab:algo2} to the test images of Section \ref{sec:testdata}. Evaluation takes place with the APLS metric adapted for large images (no midpoints along edges and a maximum of 500 random control nodes), along with the TOPO metric, using an aggressive buffer size (for APLS) or hole size (for TOPO) of 4 meters. We report scores in Table \ref{tab:test_perf} as the weighted (by road length) mean and standard deviation of the test regions of Table \ref{tab:algo2}. Figure \ref{fig:res_r0} displays the graph output of the algorithm. Since the algorithm output is a \rm{ networkx} graph structure, myriad graph algorithms can by easily applied. In addition, since we retain geographic information throughout the graph creation process, we can overlay the graph nodes and edges on the original GeoTIFF that we input into our model. Figures \ref{fig:res_r00} and \ref{fig:res_r1} display portion of Las Vegas and Paris, respectively, overlaid with the inferred road network. Figure \ref{fig:res_r1}demonstrates that road network extraction is possible even for atypical lighting conditions and off-nadir observation angles, and also that CRESI lends itself to optimal routing in complex road systems. \begin{table}[h] \vspace{-6pt} \caption{CRESI Performance} \label{tab:test_perf} \small \centering \begin{tabular}{lll} \toprule Test Region & APLS & TOPO \\ \toprule Khartoum & $ 0.64 \pm 0.07$ & $0.54 \pm 0.08$ \\ Las Vegas & $ 0.83 \pm 0.02$ & $0.65 \pm 0.01$ \\ Paris & $ 0.64 \pm 0.03$ & $0.44 \pm 0.01$ \\ Shanghai & $ 0.51 \pm 0.01$ & $0.43 \pm 0.02$ \\ \hline Total & $ 0.73 \pm 0.12$ & $0.58 \pm 0.09$ \\ \bottomrule \end{tabular} \vspace{-6pt} \end{table} \begin{comment} name: khartoum_data (mean, std, var) apls: (0.6378612151703533, 0.07435108512855905, 0.005528083859794235) topo: (0.5354518817795494, 0.07500690995072394, 0.005626036540356009) name: vegas_data (mean, std, var) apls: (0.8276985733825981, 0.018718628205921118, 0.0003503870419115056) topo: (0.6507963775203591, 0.013237132107011553, 0.00017522166641847613) name: paris_data (mean, std, var) apls: (0.6424138015965603, 0.032949882461728086, 0.0010856947542416961) topo: (0.43533270235356325, 0.013927328625168765, 0.00019397048263344527) name: shanghai_data (mean, std, var) apls: (0.5112832428285208, 0.011659707744285309, 0.0001359487846821468) topo: (0.42878249420794523, 0.0240178436281901, 0.0005768568125481919) name: total_data (mean, std, var) apls: (0.7299314534217464, 0.12413914396719641, 0.015410527064908317) 4meter topo: (0.5802606976294039, 0.0918275437417535, 0.008432297789643653) 12meter topo: (0.7370481223780092, 0.09442871031774867, 0.008916781332273294) \end{comment} \subsection{Comparison to Previous Work} Solutions from the recent SpaceNet 3 challenge maxed out at 0.67 \cite{sn3_solutions}. The area-weighted total score of Table \ref{tab:test_perf} corresponds to a score 0f 0.66 if using city-wide averaging as in the SpaceNet 3 challenge. Recall from Section \ref{sec:apls} that we use a slightly different formulation of APLS than the SpaceNet challenge that yields a score $\approx 3 - 6\%$ lower than the SpaceNet challenge; therefore our reported score of 0.66 would yield a SpaceNet score of $\approx 0.68 - 0.70$. The total TOPO score of 0.58 compares favorably with the RoadTracer implementation, which reports an F1 score of $\approx 0.43$ for a larger (less restrictive) TOPO hole size, or a TOPO F1 score of $\approx 0.37$ for the DeepRoadMapper implementation (Figure 8 of \cite{roadtracer}). The RoadTracer work used OSM labels and 0.6 m resolution aerial imagery. To perform a more direct comparison to this work, we degrade imagery to 0.6 m resolution and train a new model; we also adopt a TOPO hole size of 12 meters to compare directly with the RoadTracer TOPO scores. With the model trained (and tested) on 0.6 m data we observe a decrease of $14\%$ in the APLS score, to $0.63 \pm 0.22$. The TOPO score actually rises slightly to $0.60 \pm 0.22$ due to the less stringent hole size. This TOPO score represents a $40\%$ improvement over the RoadTracer implementation, though we caveat that testing and training is still on different cities for CRESI and RoadTracer, and SpaceNet labels were shown in Section \ref{sec:osm} to provide a significant improvement over OSM labels (which RoadTracer uses). A direct comparison between these methods is reserved for a later work. \begin{figure \vspace{-6pt} \begin{center} \includegraphics[width=0.94\linewidth]{shanghai_0_shp.jpg} \end{center} \vspace{-6pt} \caption{Output of CRESI inference as applied to the Shanghai$\_0$ test region. } \label{fig:res_r0} \vspace{-6pt} \end{figure} \begin{figure \begin{center} \includegraphics[width=0.97\linewidth]{las_vegas_0_ox_plot_c.jpg} \end{center} \caption{Output of CRESI inference as applied to the Vegas$\_0$ test region. The APLS score for this prediction is 0.86. There are 1023.9 km of labeled SpaceNet roads in this region, and 1029.8 km of predicted roads.} \label{fig:res_r00} \vspace{-6pt} \end{figure} \begin{comment} \begin{figure \begin{center} \includegraphics[width=0.99\linewidth]{AOI_5_Khartoum_MUL-PanSharpen_Cloud_RGB_ox_partial.jpg} \end{center} \caption{Output of CRESI inference for a large image strip over Khartoum. The area of this region is 274 km$^2$, with 4000 km of roads, which far exceeds the available labels for Khartoum.} \label{fig:res_khartoum0} \end{figure} \end{comment} \begin{figure \begin{center} \includegraphics[width=0.99\linewidth]{paris_1_ox_route_r00_c.jpg} \end{center} \caption{Optimal route (red) computed between two nodes of interest on the graph output of CRESI for a subset of the Paris$\_$0 test region. } \label{fig:res_r1} \vspace{-6pt} \end{figure} \subsection {Inference Speed} Inference code has not been optimized for speed, but even so inference runs at a rate of $160 \,{\rm km}^2$ (approximately the area of Washington D.C.) per ${\rm hour}$ on a single GPU machine. On a four GPU cluster the speed is a minimum of $370 \, {\rm km}^2 / \, {\rm hour}$. \section{Conclusion} Optimized routing is crucial to a number of challenges, from humanitarian to military. Satellite imagery may aid greatly in determining efficient routes, particularly in cases of natural disasters or other dynamic events where the high revisit rate of satellites may be able to provide updates far faster than terrestrial methods. In this paper we demonstrated methods to extract city-scale road networks directly from remote sensing imagery. GPU memory limitations constrain segmentation algorithms to inspect images of size $\sim1000$ pixels in extent, yet any eventual application of road inference must be able to process images far larger than a mere $\sim300$ meters in extent. Accordingly, we demonstrate methods to infer road networks for input images of arbitrary size. This is accomplished via a multi-step algorithm that segments small image chips, extracts a graph skeleton, refines nodes and edges, and stitches chipped predictions together to yield a final large road network graph. Measuring performance with the APLS graph theoretic metric we observe superior performance for models trained and tested on SpaceNet data over OSM data. Over four SpaceNet test cities, we achieve a total score of APLS = $0.73 \pm 0.12$, and inference speed of $160 \, {\rm km} ^2 \, / \, \rm{hour}$. The TOPO scores are a significant improvement over existing methods, partly due to the higher fidelity labels provided by SpaceNet over OSM. High fidelity road networks are key to optimized routing and intelligent transportation systems, and this paper demonstrates one method for extracting such road networks in resource starved or dynamic environments. \bibliographystyle{IEEEtran}
{'timestamp': '2019-07-23T02:23:40', 'yymm': '1904', 'arxiv_id': '1904.09901', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.09901'}
arxiv
\section{Introduction} Indoor localization is an essential component of many Internet of Things (IoT) applications \cite{macagnano2014IOT}. Applications such as healthcare management \cite{Wyffels2014health}, object tracking \cite{Zheng2017track}, and IoT-based smart environment \cite{Alletto2016smartplace} all require precise indoor location information. From the device perspective, wireless indoor localization can be classified as either device-based or device-free, depending on whether or not a tracking device needs to be attached to the target to be localized \cite{Xiao2016devicefree}. Device-based methods generally have the advantages of higher accuracy and robustness against environmental interferences and dynamics as compared to device-free methods. However, device-free methods have the advantages of less hardware costs, less power demands, better privacy, and provision of real-time positioning and tracking, and find a wide array of IoT applications such as intrusion detection, elderly care, etc. From the mathematical techniques perspective, wireless indoor localization can be classified as using triangulation/trilateration or fingerprinting for position calculation. The triangulation/trilateration technique calculates the location of a target based on distances and/or angles of the target with respect to signal sources. The fingerprinting technique matches the online testing measurements with the database created from offline site survey to determine the location of a target. For fingerprinting indoor localization, machine learning-based approaches have been studied \cite{Mager2015ml,Wur2018ml,Zhou2017ml,Saha2003DNNlocal,Zhang2016,Wang2017DNNlocal,Chang2018,Wang2017DNNfree,Gao2017DNNfree}. In \cite{Mager2015ml}, machine learning classifiers such as $k$-nearest neighbor ($k$-NN), support vector machine (SVM), linear discriminant analysis (LDA), and random forests for localization in changing environments were studied and compared. Wu {\it et al.} \cite{Wur2018ml} proposed an indoor localization system using the Naive Bayes classifier and compared it with $k$-NN and SVM. Zhou {\it et al.} \cite{Zhou2017ml} applied SVM to device-free localization based on channel state information (CSI) fingerprinting. In \cite{Saha2003DNNlocal,Zhang2016,Wang2017DNNlocal,Chang2018,Wang2017DNNfree,Gao2017DNNfree}, deep neural network (DNN)-based approaches to indoor localization have been proposed. Saha {\it et al.} \cite{Saha2003DNNlocal} proposed a localization scheme based on the received signal strength (RSS) of Wi-Fi using a neural network-based classifier, which was shown to outperform the nearest neighbor classifier and the histogram matching method. Zhang {\it et al.} \cite{Zhang2016} developed an RSS-based Wi-Fi localization scheme that combines DNN and hidden Markov model (HMM). It was shown that DNN outperforms other machine learning approaches including $k$-NN, SVM, and locally linear embedding (LLE) each in combination with HMM, in terms of root mean square error (RMSE). Wang {\it et al.} \cite{Wang2017DNNlocal} proposed a novel deep learning-based fingerprinting indoor localization system based on the CSI of Wi-Fi. A multilayer framework of a deep network was developed for learning discriminative features so as to effectively reduce the distance error in comparison with the probabilistic methods. Chang {\it et al.} \cite{Chang2018} proposed a device-free DNN-based Wi-Fi fingerprinting localization system. CSI pre-processing and data augmentation (including noise injection and interperson interpolation) were incorporated into the DNN framework for enhanced robustness and performance. Wang {\it et al.} \cite{Wang2017DNNfree} designed a machine learning framework for simultaneous location, activity, and gesture recognition by integrating a sparse autoencoder network with the softmax-regression-based classification module. The learning process can automatically learn the discriminative features from the RSS measurements and achieve an accuracy higher than $85\%$, which is better than the system without utilizing the learning process. Gao {\it et al.} \cite{Gao2017DNNfree} used a multilayer deep learning-based image processing framework to learn the optimized deep features from the radio images (transformed from the amplitude and phase information of the measured CSI) to estimate the location and activity of a target person. Note that \cite{Saha2003DNNlocal,Zhang2016,Wang2017DNNlocal} are device-based and \cite{Mager2015ml,Wur2018ml,Zhou2017ml,Chang2018,Wang2017DNNfree,Gao2017DNNfree} are device-free indoor localization schemes. DNNs have achieved extraordinary results in many areas. While the DNN can perform automatic feature extraction without much human intervention, it is largely conceived as a ``black box," and the design of a neural network is typically a trial-and-error process. The transparency issue of the DNN has received increasing attention lately, where both machine learning and visualization communities have attempted to understand the training process and interpret the machine cognition in a visually conceivable way. Craven and Shavlik \cite{Craven1992vis} surveyed several visualization techniques, including Hinton diagrams, bond diagrams, hyperplane diagrams, response-function plots, and trajectory diagrams, which help provide visual evidence for understanding the learning and decision-making processes of neural networks. Mohamed {\it et al.} \cite{Mohamed2012dimension} introduced a dimension-reduction technique which shows that pre-training, fine-tuning, and nonlinear hidden layers are three major components that contribute to the superb acoustic recognition performance of deep belief networks (DBNs). Rauber {\it et al.} \cite{Rauber2017dimension} analyzed the DNNs by visualizing the low-dimensional projections of hidden layer activations, and provided insights into how the learned representations of samples have evolved during training. Bach {\it et al.} \cite{Bach2015heatmap} introduced the layer-wise relevance propagation (LRP) algorithm for identifying important pixels linked to a particular DNN prediction in a given input image. The significant features extracted by the training process were visualized in the pixel/input space. Samek {\it et al.} \cite{Samek2017heatmap} showed that LRP, as compared to the sensitivity analysis and the deconvolution method, can more accurately identify important pixels based on which the DNN prediction was made. Applying the visual analytics techniques to understand the working mechanism of DNNs in wireless indoor localization has not been studied. The significance of this endeavor is twofold. First, providing visual evidence and interpretation of DNN workings in wireless indoor localization is by itself valuable, as the wireless signal patterns generally lack visual evidence and human intuition to interpret important features. Making DNN classifier interpretable also opens up new ways for model improvement and allows for analysis and comparison of various machine learning models for wireless indoor localization. Second, since the features in wireless localization applications are physical signatures of multiple-input multiple-output (MIMO) wireless links, an investigation and discussion from specifically wireless perspectives provides new insights on DNNs which cannot be directly inferred from other domain applications. Specifically, in this paper, we address the following issues: 1) How well has the DNN learned and been trained in device-free Wi-Fi indoor localization? 2) What critical features (wireless signatures) has the DNN learned to distinguish different classes in device-free Wi-Fi indoor localization? Toward these ends, we adopt several visualization techniques to provide quantitative and plausible explanations of DNN workings in this specific application. Our main contributions are summarized as follows: \begin{itemize} \item We model the device-free wireless indoor localization as a classification problem using the DNN, which yields a better average precision and recall rate than the $k$-NN and SVM techniques. \item To the best of our knowledge, this paper presents the first study that provides visual analysis to understand the mechanism of DNN-based device-free wireless indoor localization. We employ two visual analytics techniques, namely, dimensionality reduction visualization and visual analytics and information visualization, to analyze the resultant clustering effect among the data after DNN and visualize the critical channels of a given input relative to a particular output decision. \item We exploit the relevance score of a channel in an input CSI relative to a specific output class by regarding it as a correlation coefficient between two channels: one associated with the location class of the input CSI and the other associated with the specific output class that is learned by the DNN. Particularly, we develop the progressive channel nullification and channel modification procedures to evaluate the impacts of the channels with higher absolute values of relevance scores on the output prediction of each class. With extensive experiments using these two channel manipulation procedures, we justify that relevance scores are truly reliable quantitative indicators of critical features that distinguish classes, which allows for a better understanding of the critical features in wireless signals learned by the DNN which cannot be well interpreted by human perceptions. \end{itemize} The rest of the paper is organized as follows. Section~\ref{sec:experiments} provides preliminaries on the system and experiments of DNN-based device-free Wi-Fi indoor localization. Section~\ref{sec:method} presents the visual analytics techniques. Sections~\ref{sec:results_exp1} and \ref{sec:results_exp2} present the results and discussion. Finally, Section~\ref{sec:conclusion} concludes the paper. \section{Experiments and Datasets} \label{sec:experiments} Two real-world experiments for device-free Wi-Fi indoor localization were conducted, in a conference room and in a lounge, respectively, at the Research Center for Information Technology Innovation, Academia Sinica. The two environments exemplify different but common, realistic indoor settings (open space in the conference room and space with furniture/obstructions in the lounge) for our analysis. \subsection{Experimental Settings} \begin{figure}[t] \begin{center} \subfigure[]{ \label{fig:exp1_floorplan} \includegraphics[width=0.48\columnwidth,height=2.2in]{exp1_floorplan}} \hspace*{-0.06in} \subfigure[]{ \label{fig:exp1_photograph} \includegraphics[width=0.48\columnwidth,height=2.2in]{exp1_photograph}} \caption{Experiment 1 (conference room). A single Wi-Fi AP (Tx) and a single fixed-location receiver (Rx) are deployed for device-free indoor localization. (a) Floor plan. (b) Photograph.} \label{fig:exp1} \end{center} \end{figure} \begin{figure}[t] \begin{center} \subfigure[]{ \label{fig:exp2_floorplan} \includegraphics[width=0.48\columnwidth,height=2.2in]{exp2_floorplan}} \hspace*{-0.06in} \subfigure[]{ \label{fig:exp2_photograph} \includegraphics[width=0.48\columnwidth,height=2.2in]{exp2_photograph}} \caption{Experiment 2 (lounge). A single Wi-Fi AP (Tx) and a single fixed-location receiver (Rx) are deployed for device-free indoor localization. (a) Floor plan. (b) Photograph.} \label{fig:exp2} \end{center} \end{figure} The experimental settings in the conference room are depicted in Fig.~\ref{fig:exp1}. The conference room has dimensions $5.8\times 8.6$ m$^2$. There are $M=16$ target locations ($p_1,p_2,\ldots,p_{16}$) which are $1.2$ m apart between any two nearest locations. A single Wi-Fi access point (AP) of the model Zyxel NBG-419N as the transmitter (Tx) and a single ASUS laptop equipped with Ubuntu 10.04 LTS and Intel Wi-Fi Wireless Link 5300 802.11n MIMO-OFDM radios \cite{Daniel2011tool5300} as the receiver (Rx) are both placed at fixed locations with heights $88$ cm and $82$ cm, respectively. No tracking device is attached to the target to be localized (i.e., device-free). The receiver pings the packets sent from the transmitter and collects channel state information (CSI) during packet transmissions. The CSI data are used to train a DNN-based classification model for localization. The experimental settings in the lounge are depicted in Fig.~\ref{fig:exp2}. The lounge has dimensions $5.4\times 6.6$ m$^2$. There are $M=14$ target locations ($p_1,p_2,\ldots,p_{14}$) which are $1.2$ m apart between two nearest locations. Unlike the conference room experiment, the target locations here are not uniformly arranged due to obstructions. The Wi-Fi transmitter and receiver are placed at fixed locations with heights $76$ cm and $69$ cm, respectively. All other settings are the same as in the conference room experiment. \subsection{Datasets} In the conference room experiment, CSI data for both training and testing phases were collected. In the offline training phase, the same person stood at each of the $16$ locations and then the fixed-location receiver pings the packets from the transmitter. The same procedure was repeated eight times, in two days and at four different times each day (morning, noon, afternoon, evening). Overall, $200$ CSI samples were collected for each location ($3200$ samples for all $16$ locations). Each CSI sample is a $K$-dimensional vector, where $K=120$ is specified by the number of OFDM subcarriers ($30$) multiplied by two transmit and two receive antennas. The elements of the $K$-dimensional CSI sample, termed {\it CSI channels} or simply {\it channels} in this paper, are indexed in the order of $30$ subcarriers for transmit antenna 1 and receive antenna 1 pairing (denoted by Tx1--Rx1), $30$ subcarriers for Tx1--Rx2, $30$ subcarriers for Tx2--Rx1, and $30$ subcarriers for Tx2--Rx2. In the online testing phase, a similar task was performed, which is independent of the training phase. Each of the $16$ locations was tested twice, at different times of the same day to incorporate environmental variations. In each test, $100$ CSI samples were collected for each location ($1600$ for all $16$ locations). In the lounge experiment, in the offline training phase, the same person stood at each of the $14$ locations with four different orientations at each location (facing forward, backward, right, and left with respect to the transmitter), and the fixed-location receiver pings the packets from the transmitter. The same procedure was repeated $12$ times, in two days with six times of two hours apart each day. Overall, $384$ CSI samples were collected for each location ($5376$ samples for all $14$ locations). In the online testing phase, the same task was performed, independently of the training phase. Each of the $14$ locations was tested twice, at different times of the same day. In each test, $92$ CSI samples were collected for each location ($1288$ for all $14$ locations). \subsection{Deep Neural Networks} \begin{figure}[t] \begin{center} \includegraphics[width=0.85\columnwidth]{DNN} \caption{The architecture of the DNN.} \label{fig:DNN} \end{center} \end{figure} A fully connected feedforward network consisting of an input layer, $L=3$ hidden layers (from first to third, $300$, $280$, and $260$ neurons, respectively)\footnote{It is known that by increasing the number of hidden neurons we can improve the approximation of the desired function, yet with a higher computational cost. The selection of the number of hidden layers and the number of neurons in each hidden layer here is based on both conventional wisdom and our experiments to strike a reasonable tradeoff between complexity and performance.}, and an output layer is adopted, as illustrated in Fig.~\ref{fig:DNN}. The input to the input layer is the $K$-dimensional raw CSI data, denoted by ${\mathbf x}=[x_1, x_2, \ldots, x_{K}]^T$, where $x_k$ denotes the input data of CSI channel $k$. The input to neuron $i$ in the first hidden layer is $z_i^{(1)}=\sum_{j} w_{i,j}^{(1)}x_{j} + b_{i}^{(1)}$, where $w_{i,j}^{(1)}$ and $b_{i}^{(1)}$ are the weight and bias with self-explanatory indices. The output of neuron $i$ in the first hidden layer is given by $a_{i}^{(1)}={\rm ReLU}\big( z_i^{(1)}\big)$, where ${\rm ReLU}(\cdot)$ is the rectified linear unit (ReLU) activation function defined by ${\rm ReLU}(x)=\max(0,x)$. The input of neuron $i$ in the $l$th ($l=2,\ldots,L$) hidden layer is similarly given by $z_{i}^{(l)}=\sum_{k=1}w_{i,k}^{(l)}a_{k}^{(l-1)}+b_{i}^{(l)}$, with the corresponding output $a_{i}^{(l)}={\rm ReLU}\big( z_{i}^{(l)} \big)$. The softmax output of neuron $i$ in the output layer is described by $y_i=\exp\big( z_i^{(L+1)} \big)/\sum_{m=1}^M \exp\big( z_m^{(L+1)}\big)$. The prediction is location $p_{m'}$, where $m'=\mathop{\arg\max}\limits_{m}~y_m\triangleq f({\bf x})$, with $f(\cdot)$ denoting the decision function of the DNN. The network is trained in a supervised manner with the cross-entropy objective function, with $30$ iterations of pre-training and $1500$ iterations of backpropagation. \subsection{Performance} \begin{table*}[t] \begin{center} \caption{Experiment 1 (Conference Room): Precision and Recall (Unit: $\%$, after Rounding) for Locations $p_{1},\ldots,p_{16}$ for $k$-NN, SVM, and DNN Based Device-Free Indoor Localization} \label{tab:exp1_Precision and Recall} \vspace*{1mm} \begin{tabular}{|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|} \hline Measure & Scheme &$p_{1}$ & $p_{2}$ & $p_{3}$ & $p_{4}$ & $p_{5}$ & $p_{6}$ & $p_{7}$ & $p_{8}$ & $p_{9}$ & $p_{10}$ & $p_{11}$ & $p_{12}$ & $p_{13}$ & $p_{14}$ & $p_{15}$ & $p_{16}$ & Avg. \\\hline\hline \multirow{3}{*}{Precision} & $k$-NN & $85$ & $100$ & $59$ & $100$ & $85$ & $99$ & $100$ & $95$ & $31$ & $70$ & $98$ & $73$ & $40$ & $98$ & $100$ & $83$ & $82.25$ \\\cline{2-19} & SVM & $100$ & $100$ & $47$ & $96$ & $93$ & $91$ & $96$ & $97$ & $61$ & $79$ & $95$ & $93$ & $58$ & $100$ & $100$ & $70$ & $86$ \\\cline{2-19} & DNN & $100$ & $100$ & $33$ & $94$ & $100$ & $96$ & $75$ & $85$ & $90$ & $76$ & $100$ & $94$ & $51$ & $100$ & $95$ & $88$ & $86.06$ \\\hline\hline \multirow{3}{*}{Recall} & $k$-NN & $34$ & $45$ & $96$ & $53$ & $41$ & $100$ & $100$ & $72$ & $99$ & $96$ & $85$ & $38$ & $55$ & $60$ & $60$ & $100$ & $70.88$ \\\cline{2-19} & SVM & $19$ & $100$ & $99$ & $78$ & $26$ & $100$ & $99$ & $55$ & $95$ & $98$ & $99$ & $100$ & $84$ & $53$ & $60$ & $100$ & $79.06$ \\\cline{2-19} & DNN & $8$ & $100$ & $62$ & $96$ & $11$ & $100$ & $96$ & $65$ & $100$ & $100$ & $100$ & $100$ & $89$ & $55$ & $88$ & $100$ & $79.37$ \\\hline \end{tabular} \end{center} \end{table*} \begin{table*}[t] \begin{center} \caption{Experiment 2 (Lounge): Precision and Recall (Unit: $\%$, after Rounding) for Locations $p_{1},\ldots,p_{14}$ for $k$-NN, SVM, and DNN Based Device-Free Indoor Localization} \label{tab:exp2_Precision and Recall} \vspace*{1mm} \begin{tabular}{|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|} \hline Measure & Scheme &$p_{1}$ & $p_{2}$ & $p_{3}$ & $p_{4}$ & $p_{5}$ & $p_{6}$ & $p_{7}$ & $p_{8}$ & $p_{9}$ & $p_{10}$ & $p_{11}$ & $p_{12}$ & $p_{13}$ & $p_{14}$ & Avg. \\\hline\hline \multirow{3}{*}{Precision} & $k$-NN & $36$ & $97$ & $17$ & $62$ & $71$ & $43$ & $52$ & $74$ & $82$ & $51$ & $96$ & $100$ & $45$ & $46$ & $62.29$ \\\cline{2-17} & SVM & $98$ & $100$ & $24$ & $86$ & $68$ & $48$ & $74$ & $96$ & $98$ & $93$ & $66$ & $41$ & $52$ & $76$ & $72.86$ \\\cline{2-17} & DNN & $94$ & $98$ & $34$ & $89$ & $61$ & $65$ & $92$ & $35$ & $66$ & $84$ & $88$ & $99$ & $53$ & $68$ & $73.29$ \\\hline\hline \multirow{3}{*}{Recall} & $k$-NN & $16$ & $16$ & $65$ & $26$ & $65$ & $60$ & $36$ & $57$ & $58$ & $36$ & $14$ & $86$ & $67$ & $63$ & $47.5$ \\\cline{2-17} & SVM & $28$ & $33$ & $65$ & $33$ & $65$ & $65$ & $63$ & $65$ & $51$ & $65$ & $51$ & $98$ & $64$ & $65$ & $57.93$ \\\cline{2-17} & DNN & $43$ & $42$ & $65$ & $70$ & $65$ & $65$ & $61$ & $78$ & $63$ & $65$ & $29$ & $96$ & $80$ & $70$ & $63.71$ \\\hline \end{tabular} \end{center} \end{table*} Table~\ref{tab:exp1_Precision and Recall} and Table~\ref{tab:exp2_Precision and Recall} summarize the location-specific statistical measures, i.e., {\it precision} and {\it recall}, for the conference room experiment and lounge experiment, respectively, for DNN-based device-free indoor localization system in comparison with $k$-NN ($k=5$, the best-performing configuration\footnote{More precisely, $k=5$ achieves the highest macro-average recall and second-highest macro-average precision in the conference room experiment, and the highest macro-average recall and precision in the lounge experiment, among commonly used $k=1, 3, 5, 7$ values. Besides, $k=5$ achieves the highest F1-score, which is the harmonic mean of the macro-average precision and recall, in both experiments.}) and SVM. $k$-NN classification is based on the raw CSI data and is adopted to benchmark the analysis of DNN in Sections~\ref{sec:results_exp1} and \ref{sec:results_exp2}. SVM with a Gaussian radial basis function (RBF) kernel and the one-against-all technique \cite{Zhou2017ml,Wu2016} for solving the multi-classification problem is adopted. The precision and recall measure the percentages of correct classification for each predicted and true class in the testing, respectively. \section{Visual Analytics Techniques} \label{sec:method} Two visual analytics techniques are employed to facilitate the analysis, visualization, and evaluation of the neural network in the application of device-free Wi-Fi indoor localization. \subsection{Dimensionality Reduction Visualization} A dimensionality reduction technique called t-distributed stochastic neighbor embedding (t-SNE) \cite{Maaten2008tsne} is employed to project the high-dimensional data to the low-dimensional space for ease of visualization. In the projection, t-SNE aims to preserve the pairwise relationship of the high-dimensional data in the low-dimensional space. Specifically, t-SNE first converts the pairwise distances between datapoints in the high-dimensional space to joint probabilities, i.e., the joint probabilities of high-dimensional datapoints ${\mathbf x}_i$ and ${\mathbf x}_j$ are defined as $p_{ij}=\exp(-\left\|{\mathbf x}_i-{\mathbf x}_j\right\|^2)/\sum_{k\neq l}\exp(-\left\|{\mathbf x}_k-{\mathbf x}_l\right\|^2)$ for $i\neq j$, and $p_{ii}=0,\forall i$. Then, t-SNE finds the low-dimensional data representation such that the low-dimensional counterparts have similar joint probabilities as the high-dimensional data. The joint probabilities $q_{ij}$ for the low-dimensional counterparts $\boldsymbol{\chi}_i$ and $\boldsymbol{\chi}_j$ are defined as $q_{ij}=(1+\left\|\boldsymbol{\chi}_i-\boldsymbol{\chi}_j\right\|^2)^{-1}/\sum_{k\neq l} (1+\left\|\boldsymbol{\chi}_k-\boldsymbol{\chi}_l\right\|^2)^{-1}$ for $i\neq j$, and $q_{ii}=0,\forall i$, which is based on the heavy-tailed Student t-distribution instead of Gaussian as in the high-dimensional space to avoid the ``crowding problem" \cite{Maaten2008tsne} in the low-dimensional representation. t-SNE finds the low-dimensional data representation with such $q_{ij}$'s that the Kullback-Leibler divergence between $p_{ij}$'s and $q_{ij}$'s, i.e., $\sum_i \sum_j p_{ij}\log (p_{ij}/q_{ij})$, is minimized. In our application, the high-dimensional input or hidden-layer activations are projected to the 2D space via t-SNE and presented as scatterplots. In the scatterplot, the points are colored or labeled according to the corresponding classes (i.e., locations $p_1,\ldots,p_{16}$). We adopt the {\it silhouette score} \cite{Rousseeuw1987SC} to visually assess the clustering of points into different classes in the 2D representation. The silhouette score $s(i)$ of the $i$th point is defined as $s(i)=(d_{\rm nearest}(i)-d_{\rm intra}(i)) / \max\{d_{\rm intra}(i), d_{\rm nearest}(i)\}$, where $d_{\rm intra}(i)$ is the mean distance between the $i$th point and all other points within the same cluster (i.e., the mean intra-cluster distance), and $d_{\rm nearest}(i)$ is the minimum mean distance between the $i$th point and all points in any other cluster (i.e., the mean nearest-cluster distance). The silhouette score lies in the interval $[-1, 1]$. The score is close to $1$ if $d_{\rm nearest}(i) \gg d_{\rm intra}(i)$, i.e., the data are well-clustered, close to $-1$ if $d_{\rm nearest}(i) \ll d_{\rm intra}(i)$, i.e., the data are not well-clustered in the sense that the data would have been better clustered if clustered to the neighboring cluster, and near zero if $d_{\rm nearest}(i) \approx d_{\rm intra}(i)$, i.e., the data are in between two clusters. We calculate the average silhouette score over all points for each scatterplot. \subsection{Visual Analytics and Information Visualization} Layer-wise relevance propagation (LRP) \cite{Bach2015heatmap} is developed to quantify the contribution of the data in each input neuron to a specific output prediction. This is achieved by decomposing a specific pre-softmax value, i.e., $z_{m}^{(L+1)}$, in the output layer into {\em relevance scores} of the neurons in the previous hidden layer which are then propagated backward toward the input layer. The back-propagation rule in LRP is constrained by the conservation principle \cite{Bach2015heatmap}, i.e., \begin{align} \sum_i h_i(p_n\to p_m) &= \sum_i R_i^{(l)}(p_n\to p_m) = z_{m}^{(L+1)}, \nonumber\\ & m,n=1,\ldots,M; l=1,\ldots,L \label{eq:R_conservation} \end{align} where $h_i(p_n\to p_m)$ and $R_i^{(l)}(p_n\to p_m)$ are the relevance scores of CSI channel $i$ in the input layer and of neuron $i$ in the $l$th hidden layer, respectively, corresponding to the input CSI data of location $p_n$ and the output DNN decision of location $p_m$. The conservation principle forces the sum of the relevance scores to be preserved in all layers and equal to $z_{m}^{(L+1)}$, the output score before softmax. The conservation principle can be applied repeatedly backward in all layers to obtain the relevance scores. The relevance score of neuron $i$ in the $L$th hidden layer is given by \begin{align} R_i^{(L)}(p_n\to p_m) = \frac{a_{i}^{(L)}w_{m,i}^{(L+1)}}{\sum_{j}a_{j}^{(L)}w_{m,j}^{(L+1)}+b_{m}^{(L+1)}}z_m^{(L+1)} \end{align} for some $m, n$, which approximates the conservation principle. The relevance scores of neuron $i$ in the $l$th ($l=1,\ldots,L-1$) hidden layer and of CSI channel $i$ in the input layer are given respectively by \begin{align} R_i^{(l-1)}(p_n\to p_m) &= \sum_{k}\frac{a_{i}^{(l-1)}w_{k,i}^{(l)}}{\sum_{j}a_{j}^{(l-1)}w_{k,j}^{(l)}+b_{k}^{(l)}}R_k^{(l)}(p_n\to p_m), \nonumber\\ &\qquad\qquad\qquad\qquad\qquad l=2,\ldots,L, \label{eq:R_layer} \\ h_i(p_n\to p_m) &= \sum_{k}\frac{x_{i}w_{k,i}^{(1)}}{\sum_{j}x_{j}w_{k,j}^{(1)}+b_{k}^{(1)}}R_k^{(1)}(p_n\to p_m)\label{eq:R_input} \end{align} for some $m, n$. The relevance score $h_i(p_n\to p_m)$ is normalized to $[-1,1]$ by $h'_i(p_n\to p_m)=\frac{h_i(p_n\to p_m)}{\max_{j=1,\ldots,K}(\left| h_j(p_n\to p_m) \right|)}$. A positive valued $h'_i(p_n\to p_m)$ suggests that CSI channel $i$ provides positive evidence in support of the DNN prediction of location $p_m$ given the input CSI data of location $p_n$, a negative valued $h'_i(p_n\to p_m)$ suggests that CSI channel $i$ provides negative evidence against such a prediction, and a near-zero $h'_i(p_n\to p_m)$ suggests that CSI channel $i$ provides little evidence for or against such a prediction. To examine how each input CSI channel has contributed to a specific output DNN decision through the relevance scores, we propose two channel manipulation processes, inspired by the approach in \cite{Bach2015heatmap} where the process is associated with flipping the pixel value of a binary image. We first define, for some $m,n$, the following channel ordering sequences, where each $(r_1,\ldots, r_{K})$ represents a permutation of the natural channel ordering $(1,\ldots,K)$ according to a certain ordering of the normalized relevance scores: \begin{enumerate} \item $\mathcal{O}_1(p_n{\to} p_m) = (r_1,\ldots, r_{K})$ such that the corresponding sequence of relevance scores is in descending order, i.e., $h'_{r_1}(p_n\to p_m)\geq h'_{r_2}(p_n\to p_m)\geq\cdots\geq h'_{r_K}(p_n\to p_m)$. \item $\mathcal{O}_2(p_n{\to} p_m) = (r_1,\ldots, r_{K})$ such that the corresponding sequence of relevance scores is in ascending order, i.e., $h'_{r_1}(p_n\to p_m)\leq h'_{r_2}(p_n\to p_m)\leq\cdots\leq h'_{r_K}(p_n\to p_m)$. \item $\mathcal{O}_3(p_n{\to} p_m) = (r_1,\ldots, r_{K})$ such that the corresponding sequence of relevance scores satisfies $|h'_{r_1}(p_n\to p_m)|\geq |h'_{r_2}(p_n\to p_m)|\geq\cdots\geq |h'_{r_K}(p_n\to p_m)|$. \item $\mathcal{O}_4(p_n{\to} p_m) = (r_1,\ldots, r_{K})$ such that the corresponding sequence of relevance scores satisfies $|h'_{r_1}(p_n\to p_m)|\leq |h'_{r_2}(p_n\to p_m)|\leq\cdots\leq |h'_{r_K}(p_n\to p_m)|$. \end{enumerate} Then, the proposed channel manipulation processes to facilitate information visualization are described below. \subsubsection{Channel Nullification} The process is to progressively nullify or remove the channel in the input CSI data of location $p_n$, denoted by ${\mathbf x}_{p_n}=[x_{p_n,1},x_{p_n,2},\ldots,x_{p_n,K}]^T$, one channel at a time according to a specific channel ordering sequence, and measure the impact of the nullified channel on the classification result. The $t$th ($t=1,\ldots,K$) step in the removal process returns ${\mathbf x}_{p_n}^{(t)}=g_{\rm null}({\mathbf x}_{p_n}^{(t-1)},r_t)$, where ${\mathbf x}_{p_n}^{(0)}\triangleq {\mathbf x}_{p_n}$, and the function $g_{\rm null}$ sets the $r_t$-th element of ${\mathbf x}_{p_n}^{(t-1)}$ to zero. The influence of nullified CSI channels is reflected by the classification decision $f({\mathbf x}_{p_n}^{(t)})$ of the DNN. \subsubsection{Channel Modification} The process is to progressively modify the channel in the input CSI data of location $p_n$ ``toward'' that of location $p_m$, one channel at a time according to a specific channel ordering sequence, given the input CSI data of location $p_n$ and the output DNN decision of location $p_m$. The $t$th ($t=1,\ldots,K$) step in the modification process returns ${\mathbf x}_{p_n}^{(t)}=g_{\rm mod}({\mathbf x}_{p_n}^{(t-1)},r_t)$, where ${\mathbf x}_{p_n}^{(0)}\triangleq {\mathbf x}_{p_n}$, and the function $g_{\rm mod}$ sets the $r_t$-th element of ${\mathbf x}_{p_n}^{(t-1)}$ to $\max\left(0, {\mathbb E}\left[x_{p_m,r_t}\right]{+}h'_{r_t}(p_n{\to} p_m) \frac{\sigma_{x_{p_m,r_t}}}{\sigma_{x_{p_n,r_t}}} \left(x_{p_n,r_t} {-} {\mathbb E}\left[x_{p_n,r_t}\right] \right)\right)$, which is based on the linear minimum mean square error (LMMSE) estimation of unknown $X$ given $Y$, i.e., $\widehat{X}={\mathbb E}[X]+\rho \frac{\sigma_X}{\sigma_Y}(Y - {\mathbb E}[Y])$, with correlation coefficient $\rho$ and standard deviations $\sigma_X,\sigma_Y$. The influence of modified CSI channels is reflected by the classification decision $f({\mathbf x}_{p_n}^{(t)})$ of the DNN. We examine the percentage of correct classification for each true class $p_n$ in the testing (i.e., recall), and also the percentage of classification as location $p_m$ given the true class $p_n$, after channel nullification/modification. More specifically, we calculate, for $t=1,\ldots,K$, the number of $f({\mathbf x}_{p_n}^{(t)})=n$ and $f({\mathbf x}_{p_n}^{(t)})=m$, respectively, divided by the number of testing samples for location $p_n$. The proposed technique can be extended to examine the contribution of each subcarrier to the DNN decision. We can calculate \begin{align} &s'_i(p_n\to p_m) \nonumber\\ &\quad=\frac{1}{4}\Big(h'_i(p_n\to p_m)+h'_{i+30}(p_n\to p_m) \nonumber\\ &\qquad +h'_{i+60}(p_n\to p_m)+h'_{i+90}(p_n\to p_m)\Big), \nonumber\\ &\qquad\qquad\qquad\qquad\qquad\qquad i=1,\ldots,30 \label{eq:subcarrier_relevance_score} \end{align} to represent the average normalized relevance scores of subcarrier $i$ corresponding to the input CSI data of location $p_n$ and output DNN decision of location $p_m$. Once we have the relevance scores of all the subcarriers corresponding to input $p_n$ and output $p_m$, we can define subcarrier ordering sequences similar to $\mathcal{O}_1$--$\mathcal{O}_4$ to rank the importance of subcarriers according to $s'_i(p_n\to p_m)$. By a slight abuse of notations, we use the same $\mathcal{O}_1$--$\mathcal{O}_4$ to denote the subcarrier ordering sequences and clearly make the distinction from channel ordering sequences in the context. Subcarrier nullification/modification procedures are also similarly defined. For example, nullification of subcarrier $i$ represents setting the $i$th, $(i+30)$th, $(i+60)$th, and $(i+90)$th elements of the CSI sample to zero. \begin{figure*}[t] \begin{center} \includegraphics[width=2\columnwidth]{exp1_tSNE_training} \caption{The 2D visualization of (a) the raw CSI samples, (b) the last DNN hidden layer activations before training (with random initializations), and (c) the last DNN hidden layer activations after training. For each location, the training samples are shown with a darker shade to distinguish from the testing samples with a lighter shade of the same color. The silhouette scores (calculated for the training samples only) for (a)--(c) are $0.22$, $0.09$, and $0.66$, respectively. The rectangular boxes in (a) and (c) enclose all the training samples for location $p_{13}$. Black location markers refer to training samples and colored location markers (in colors corresponding to respective locations) refer to testing samples collected at the respective locations.} \label{fig:tsne_training} \end{center} \end{figure*} \begin{figure*}[t] \begin{center} \includegraphics[width=2\columnwidth]{exp1_tSNE_testing} \caption{Same plots as Fig.~\ref{fig:tsne_training}, but here, for each location, the testing samples are shown with a darker shade to distinguish from the training samples with a lighter shade of the same color. The silhouette scores (calculated for the testing samples only) for (a)--(c) are $-0.01$, $0.16$, and $0.41$, respectively. The rectangular boxes in (a) and (c) enclose the testing samples for location $p_{11}$ and the nearby training samples. Black location markers refer to training samples and colored location markers (in colors corresponding to respective locations) refer to testing samples collected at the respective locations.} \label{fig:tsne_testing} \end{center} \end{figure*} \section{Analysis and Visualization of Experimental Results: Experiment 1 (Conference Room)} \label{sec:results_exp1} The results for experiment 1 (conference room) and experiment 2 (lounge) are analyzed and discussed in this section and next section, respectively. \subsection{Training Effects} \label{sec:results_exp1_1} The 2D visualization (via t-SNE) of 1) the raw CSI samples, 2) the last DNN hidden layer activations (i.e., $a_i^{(L)}$'s) before training (with random initializations, i.e., all the weights and biases are randomly generated from a Gaussian distribution with mean zero and standard deviation one), and 3) the last DNN hidden layer activations after training, are presented in Fig.~\ref{fig:tsne_training}(a)--(c), respectively. $200$ training samples and $100\times 2=200$ testing samples per location are plotted and color-coded. For each location, the training samples are shown with a darker shade to distinguish from the testing samples with a lighter shade of the same color. It is observed from Fig.~\ref{fig:tsne_training}(a) that the raw CSI samples are highly scattered, with a silhouette score of $0.22$, showing that the indoor localization problem at hand is not an easy classification problem. The untrained DNN shows similar visual separation among different classes (silhouette score: $0.09$) in Fig.~\ref{fig:tsne_training}(b). The trained DNN yields much improved visual separation (silhouette score: $0.66$), as shown in Fig.~\ref{fig:tsne_training}(c), by automatically extracting important CSI features to distinguish among different classes. It is expected that, as more distinctive patterns are learned through DNN training, different locations can be better classified with DNN in the testing. We use location $p_{13}$ as an example. The rectangular boxes in Fig.~\ref{fig:tsne_training}(a) and Fig.~\ref{fig:tsne_training}(c) enclose all the training samples for location $p_{13}$. It is seen that after DNN training these training samples become more concentrated. This leads to reduced misclassification of other locations as location $p_{13}$ in the testing. Specifically, for the DNN scheme, only locations $p_{1}$, $p_{5}$, and $p_{13}$ are classified as location $p_{13}$ in the testing, while for the $k$-NN scheme based on the raw CSI samples, locations $p_{1}$, $p_{4}$, $p_{5}$, $p_{9}$, $p_{12}$, $p_{13}$, and $p_{15}$ are classified as location $p_{13}$ in the testing. Quantitatively, DNN yields a higher precision than $k$-NN for location $p_{13}$ ($51\%$ vs. $40\%$), as shown in Table~\ref{tab:exp1_Precision and Recall}. Overall, DNN generally yields higher precision values, with a higher macro-average precision as compared to $k$-NN ($86.06\%$ vs. $82.25\%$). Thus, DNN training is effective in learning discriminative features from the original noisy wireless signals. \subsection{Testing Performance} \label{sec:results_exp1_2} Fig.~\ref{fig:tsne_testing} depicts the same figure as Fig.~\ref{fig:tsne_training}, but with the testing samples (instead of the training samples) highlighted in a darker shade of the same color. It is observed that Fig.~\ref{fig:tsne_testing}(c) presents better visual separation than Fig.~\ref{fig:tsne_testing}(a), with silhouette scores (calculated for the testing samples only) of $0.41$ vs. $-0.01$. Since testing was performed in two different time slots, Fig.~\ref{fig:tsne_testing}(c) suggests that the trained DNN model modifies the testing samples collected in different time slots to be more coherent, even though the raw testing data are more scattered in the data space due to environmental variations in two different time slots. The more concentrated distribution of the testing samples per location leads to the reduced misclassification of other locations as the true location in the testing, as shown by the higher macro-average recall for DNN than for $k$-NN ($79.37\%$ vs. $70.88\%$ in Table~\ref{tab:exp1_Precision and Recall}). Consider location $p_{11}$ as an example. In Fig.~\ref{fig:tsne_testing}(a), the testing samples for location $p_{11}$ are located near the training samples for locations $p_{11}$ and $p_{13}$, as enclosed by the rectangular box. After the DNN operation, the distribution of the testing data is altered, where the testing samples for location $p_{11}$ are now located near the training samples for location $p_{11}$ only, as enclosed by the rectangular box in Fig.~\ref{fig:tsne_testing}(c). The visual distribution matches the classification results where the recall for $k$-NN and DNN for location $p_{11}$ are $85\%$ and $100\%$, respectively. \subsection{Line-of-Sight Effects} \label{sec:results_exp1_3} It is observed from Table~\ref{tab:exp1_Precision and Recall} that, for DNN, $p_{1}$ and $p_{5}$ have very small values of recall but large values of precision. This suggests that location $p_{1}$ (or $p_{5}$) is largely misclassified as another location (small recall), and very few other locations are misclassified as location $p_1$ (or $p_{5}$) (large precision). A confusion matrix analysis reveals that the testing samples for location $p_{1}$ are predominantly misclassified as locations $p_3$ and $p_{13}$, and the testing samples for location $p_{5}$ are predominantly misclassified as locations $p_3$, $p_9$, and $p_{13}$. Fig.~\ref{fig:tsne_training}(c) and Fig.~\ref{fig:tsne_testing}(c) show that the testing samples for locations $p_{1}$ and $p_{5}$ are near the training samples for locations $p_{3}$, $p_{9}$, and $p_{13}$. Fig.~\ref{fig:tsne_training}(c) also shows that the training samples for locations $p_{1}$, $p_{5}$, $p_{9}$, and $p_{13}$ are close to each other, which suggests that locations $p_{1}$, $p_{5}$, $p_{9}$, and $p_{13}$ are not discernable after DNN learning. Fig.~\ref{fig:tsne_training}(a) shows that the raw CSI training samples for these four locations are also not well separated, which indicates that these original CSI patterns in the radio map are not discernable, making it difficult for the DNN to distinguish the location-specific features in the learning process. This may be in part because $p_{1}$, $p_{5}$, $p_{9}$, and $p_{13}$ are farther away from the line-of-sight (LoS) between the Wi-Fi transmitter and receiver. However, since the propagation of wireless signals is sensitive to room layouts and object placement, the CSI patterns and the resulting classification results are not the same for $p_{4}$, $p_{8}$, $p_{12}$, and $p_{16}$, which are also farther away from the LoS, in this experiment. \subsection{Discriminative Features} \label{sec:results_exp1_4} \begin{figure}[t] \begin{center} \includegraphics[width=1\columnwidth]{exp1_LRP_p6_p13} \caption{The percentage of correct classification (true class: $p_6$ (or $p_{13}$)) after progressive channel nullification according to the channel ordering sequences $\mathcal{O}_3(p_6\to p_6)$ and $\mathcal{O}_4(p_6\to p_6)$ (or $\mathcal{O}_3(p_{13}\to p_{13})$ and $\mathcal{O}_4(p_{13}\to p_{13})$).} \label{fig:LRP_p6_p13} \end{center} \end{figure} \begin{figure}[t] \begin{center} \includegraphics[width=1\columnwidth]{exp1_LRP_p6_p10_p11} \caption{The percentage of classification as $p_6$ and $p_{10}$ (true class: $p_6$) after progressive channel modification according to the channel ordering sequence $\mathcal{O}_2(p_6\to p_{10})$, in comparison with the same setting but after progressive channel nullification, and with a different pair of locations $p_{11}$ and $p_{10}$ (true class: $p_{11}$) after progressive channel modification according to the channel ordering sequence $\mathcal{O}_2(p_{11}\to p_{10})$.} \label{fig:LRP_p6_p10_p11} \end{center} \end{figure} Fig.~\ref{fig:LRP_p6_p13} shows the effect of progressive channel nullification on the DNN prediction using locations $p_6$ and $p_{13}$ as an example of locations nearer and farther from the LoS, respectively. For location $p_6$, channel nullification according to channel ordering sequences $\mathcal{O}_3(p_6\to p_6)$ and $\mathcal{O}_4(p_6\to p_6)$ represent, respectively, that the most relevant and irrelevant channels, as determined by LRP, leading to the correct DNN decision of location $p_6$ are progressively nullified. As can be seen, the percentage of correct classification generally decreases, more rapidly for $\mathcal{O}_3$ than for $\mathcal{O}_4$, as more channels are nullified. For $\mathcal{O}_3$, when as few as $20$ channels (out of $120$) are nullified, the percentage of correct classification drops from $100\%$ (the recall for location $p_6$) to nearly $0\%$, showing that the channels with large absolute values of relevance scores are indeed important and indispensable features for correct classification. Also, this shows that DNN can extract a small fraction of channels as dominant features. For $\mathcal{O}_4$, when the most irrelevant channels are nullified progressively, the percentage of correct classification still generally decreases, albeit more slowly. This is because, while these channels have little impact on the classification of the true class, they could have a pronounced impact on the classification of other classes. For example, when the channel corresponding to the leading element $r_1$ of $\mathcal{O}_4(p_6\to p_6)$ has a large CSI amplitude and a negative valued $h'_{r_1}(p_6\to p_{m})$ for some $m\neq 6$, nullifying this specific channel may erase the original negative evidence against the wrong class $p_m, m\neq 6$, resulting in an increased chance of a wrong DNN decision of location $p_m, m\neq 6$. For location $p_{13}$, the same general trend is observed, even though the percentage of correct classification drops even more rapidly from $89\%$ (the recall for location $p_{13}$) to $0\%$, since locations farther from the LoS could easily mutually misclassify as each other, as discussed previously. Fig.~\ref{fig:LRP_p6_p10_p11} shows how the percentages of classification change as channels of the true class ($p_6$) are progressively modified toward another class ($p_{10}$) according to the channel ordering sequence $\mathcal{O}_2(p_6\to p_{10})$. Note that the leading elements of $\mathcal{O}_2(p_6\to p_{10})$ are channels that have the most negative relevance scores, i.e., provide the most negative evidence against the prediction of location $p_{10}$ given the true class being location $p_6$. By modifying these channels of location $p_6$ toward those of location $p_{10}$, we gradually erase the evidence against the prediction of location $p_{10}$ and enhance the evidence for the prediction of location $p_{10}$ (analogous to pixel flipping in binary images). Thus, we expect that the percentage of predicting location $p_6$ ($p_{10}$) will decrease (increase), provided that the relevance scores are reliable indicators of critical features that distinguish between classes. This is confirmed in Fig.~\ref{fig:LRP_p6_p10_p11}. In comparison, nullifying, instead of modifying, the same channels in the same order does not yield the same effect. Since channel nullification erases the evidence against, but does not enhance the evidence for, the prediction of location $p_{10}$, misclassification favors not only location $p_{10}$ but other locations as well. Fig.~\ref{fig:LRP_p6_p10_p11} also shows that channel nullification yields a significantly faster decreasing rate of correct classification than channel modification. This suggests that making radical changes to the channels such as nullification poses a more harmful effect on the correct classification than modifying the channels to another, possibly similar, pattern. As will be illustrated (in Figs.~\ref{fig:LRP_waveform}(a) and \ref{fig:LRP_waveform}(h)), the CSI patterns of locations $p_6$ and $p_{10}$ are somewhat similar (by visual inspection) and these two locations are easily misclassified as each other. The raw training samples of locations $p_6$ and $p_{10}$ are close to each other as seen in Fig.~\ref{fig:tsne_training}(a). The recall for location $p_{10}$ for $k$-NN based on the raw CSI data is $96\%$ from Table~\ref{tab:exp1_Precision and Recall}, and the $4\%$ misses have all been classified as location $p_6$. This may explain the fact that when channels of location $p_6$ are modified toward those of location $p_{10}$, all misclassified samples are classified as location $p_{10}$ (i.e., the two topmost curves in Fig.~\ref{fig:LRP_p6_p10_p11} exhibit symmetric trends). For a different pair of locations, e.g., locations $p_{11}$ and $p_{10}$, as compared in Fig.~\ref{fig:LRP_p6_p10_p11}, we observe that the decrease in classification as the true class ($p_{11}$) does not lead to the increase in classification as another class ($p_{10}$) in a symmetric way. Eventually, though, as the majority of channels are such modified, the percentage of classification as the true class decreases to $0\%$ and the percentage of classification as another class increases to $100\%$, regardless of the pairs of locations. \begin{figure}[t] \begin{center} \subfigure[]{ \label{fig:LRP_heatmap_p6_p6} \includegraphics[width=0.47\columnwidth,height=1.13in]{exp1_LRP_heatmap_p6_p6}} \hspace*{-0.06in} \subfigure[]{ \label{fig:LRP_heatmap_p6_p10} \includegraphics[width=0.47\columnwidth,height=1.13in]{exp1_LRP_heatmap_p6_p10}} \caption{Heatmaps of relevance scores (a) $h'_i(p_6\to p_6)$ and (b) $h'_i(p_6\to p_{10})$ for $i=1,\ldots,120$, superimposed on the $200$ testing samples of CSI of location $p_6$.} \label{fig:LRP_heatmap} \end{center} \end{figure} \begin{figure}[t] \begin{center} \includegraphics[width=\columnwidth]{exp1_LRP_waveform_p6_p10} \caption{$200$ testing samples of CSI of location $p_6$ (in (a)) progressively modified toward $200$ testing samples of CSI of location $p_{10}$ (in (h)) according to the channel ordering sequence $\mathcal{O}_2(p_6\to p_{10})$. The unmodified/modified channels are color-coded by the CSI of $p_6$/$p_{10}$ (in (b)--(g)). The percentages of correct classification as $p_6$ and the numbers of channels modified ($t$) are shown.} \label{fig:LRP_waveform} \end{center} \end{figure} Figs.~\ref{fig:LRP_heatmap} and \ref{fig:LRP_waveform} examine the specific channels progressively modified which lead to the result shown by the topmost curve in Fig.~\ref{fig:LRP_p6_p10_p11}. The heatmaps of relevance scores $h'_i(p_6\to p_6)$ and $h'_i(p_6\to p_{10})$ are shown on top of the CSI of location $p_6$ in Fig.~\ref{fig:LRP_heatmap}. Progressive channel modification is visualized in Fig.~\ref{fig:LRP_waveform}. The channel modification starts with the channels with the most negative valued $h'_i(p_6\to p_{10})$, i.e., the blue-colored channels in Fig.~\ref{fig:LRP_heatmap_p6_p10}. When up to $10$ channels are modified, the percentage of correct classification remains $100\%$. When more channels are modified, the percentage starts to decline. Comparing Figs.~\ref{fig:LRP_waveform}(b) and \ref{fig:LRP_waveform}(c), the additional channels modified, roughly corresponding to the red-circled ones in Fig.~\ref{fig:LRP_waveform}(c), are evidence in support of predicting $p_6$ (yellow/red in Fig.~\ref{fig:LRP_heatmap_p6_p6}) but neutral or against predicting $p_{10}$ (cyan/blue in Fig.~\ref{fig:LRP_heatmap_p6_p10}). In Fig.~\ref{fig:LRP_waveform}(c), for the $25\%$ misclassified samples, the channels with $h'_i(p_6\to p_6)>0.4$ (i.e., strong evidence in support of predicting $p_6$) have all been modified. By modifying these critical channels in support of predicting $p_6$, the percentage of correct classification as $p_6$ decreases rapidly (from $100\%$ to about $50\%$ when only $22$ channels are modified, from Fig.~\ref{fig:LRP_waveform}(b) to Fig.~\ref{fig:LRP_waveform}(d)). As channel modification progresses, channels with near-zero and positive valued $h'_i(p_6\to p_{10})$, i.e., the cyan/yellow/red-colored channels in Fig.~\ref{fig:LRP_heatmap_p6_p10}, start to be modified. Comparing Figs.~\ref{fig:LRP_waveform}(e) and \ref{fig:LRP_waveform}(f), the additional channels modified, roughly corresponding to the red-circled ones in Fig.~\ref{fig:LRP_waveform}(f), are evidence neutral or mildly supporting predicting $p_6$ (cyan/yellow in Fig.~\ref{fig:LRP_heatmap_p6_p6}) and supporting predicting $p_{10}$ (yellow/red in Fig.~\ref{fig:LRP_heatmap_p6_p10}). Modifying these channels not critically supporting predicting $p_6$ and against predicting $p_{10}$ results in a slower decrease in the percentage of correct classification (from about $50\%$ to $0\%$ when as many as $66$ channels are modified, from Fig.~\ref{fig:LRP_waveform}(d) to Fig.~\ref{fig:LRP_waveform}(f)). When all $120$ channels of location $p_6$ are modified (Fig.~\ref{fig:LRP_waveform}(g)), the resulting CSI pattern approaches that of location $p_{10}$ (Fig.~\ref{fig:LRP_waveform}(h)). \subsection{Subcarrier Importance} \label{sec:results_exp1_5} \begin{figure}[t] \begin{center} \includegraphics[width=1\columnwidth]{exp1_LRP_p6_p13_subcarrier} \caption{The percentage of correct classification (true class: $p_6$ (or $p_{13}$)) after progressive subcarrier nullification according to the subcarrier ordering sequences $\mathcal{O}_3(p_6\to p_6)$ and $\mathcal{O}_4(p_6\to p_6)$ (or $\mathcal{O}_3(p_{13}\to p_{13})$ and $\mathcal{O}_4(p_{13}\to p_{13})$).} \label{fig:LRP_p6_p13_subcarrier} \end{center} \end{figure} \begin{figure}[t] \begin{center} \includegraphics[width=1\columnwidth]{exp1_LRP_heatmap_p6_p6_subcarrier} \caption{Heatmaps of relevance scores $s'_i(p_6\to p_6)$ for $i=1,\ldots,30$, superimposed on the $200$ testing samples of CSI for four transmit-receive antenna pairings of location $p_6$.} \label{fig:LRP_heatmap_p6_p6_subcarrier} \end{center} \end{figure} From a wireless perspective, the logical $120$ channels comprise $30$ physical subcarriers in $2\times 2$ MIMO wireless links. By breaking down the $120$ channels in view of wireless links and by defining the relevance scores of subcarriers and subcarrier ordering sequences, the subcarrier importance can be examined. Fig.~\ref{fig:LRP_p6_p13_subcarrier} plots the results of progressive subcarrier nullification according to the subcarrier ordering sequences $\mathcal{O}_3$ and $\mathcal{O}_4$ on the DNN prediction for the same two locations as in Fig.~\ref{fig:LRP_p6_p13}. Similar conclusions can be drawn here. Fig.~\ref{fig:LRP_heatmap_p6_p6_subcarrier} shows the heatmaps of subcarrier relevance scores $s'_i(p_6\to p_6)$ on top of the CSI of $2\times 2$ MIMO links for location $p_6$. Two observations can be made. First, the CSI amplitude for a specific subcarrier varies greatly in $2\times 2$ MIMO links, because the four links are independent of each other. Second, the subcarrier relevance scores are more temperate (no extreme values near $1$ or $-1$) than the channel relevance scores in Fig.~\ref{fig:LRP_heatmap_p6_p6}. This suggests that the logical channels, i.e., the $i$th, $(i+30)$th, $(i+60)$th, and $(i+90)$th CSI channels, which all correspond to the same physical subcarrier $i$, do not have relevance scores that are simultaneously high or low (otherwise, it would have led to extreme values after the averaging operation in \eqref{eq:subcarrier_relevance_score}). In other words, the same physical subcarriers at different MIMO links provide distinct information to the DNN prediction. The DNN treats the $120$ logical channels as individual features irrespective of their wireless origins or implications. \section{Analysis and Visualization of Experimental Results: Experiment 2 (Lounge)} \label{sec:results_exp2} \begin{figure*}[t] \begin{center} \includegraphics[width=2\columnwidth]{exp2_tSNE_training} \caption{The 2D visualization of (a) the raw CSI samples, (b) the last DNN hidden layer activations before training (with random initializations), and (c) the last DNN hidden layer activations after training. For each location, the training samples are shown with a darker shade to distinguish from the testing samples with a lighter shade of the same color. The silhouette scores (calculated for the training samples only) for (a)--(c) are $-0.18$, $-0.21$, and $0.09$, respectively. The rectangular boxes in (a) and (b) enclose all the training samples for locations $p_1$ and $p_4$. Black location markers refer to training samples and colored location markers (in colors corresponding to respective locations) refer to testing samples collected at the respective locations.} \label{fig:exp2_tsne_training} \end{center} \end{figure*} \begin{figure*}[t] \begin{center} \includegraphics[width=2\columnwidth]{exp2_tSNE_testing} \caption{Same plots as Fig.~\ref{fig:exp2_tsne_training}, but here, for each location, the testing samples are shown with a darker shade to distinguish from the training samples with a lighter shade of the same color. The silhouette scores (calculated for the testing samples only) for (a)--(c) are $-0.22$, $-0.23$, and $-0.15$, respectively. The rectangular boxes in (a) and (b) enclose the testing samples for locations $p_1$ and $p_4$. Black location markers refer to training samples and colored location markers (in colors corresponding to respective locations) refer to testing samples collected at the respective locations.} \label{fig:exp2_tsne_testing} \end{center} \end{figure*} The dataset collected in the lounge experiment is more challenging for classification than the dataset collected in the conference room experiment. The lounge environment has more obstructions that produce more disturbance to the wireless signals and drastically different multipath profiles. Specifically, the CSI is more noisy/dispersive across different samples, and each sample exhibits more strongly varying CSI across different subcarriers as a result of richer multipath effects in this environment. \subsection{Training Effects} \label{sec:results_exp2_1} The 2D visualization of raw CSI samples shows poor visual separation between classes in Fig.~\ref{fig:exp2_tsne_training}(a), with a silhouette score of $-0.18$. Comparing Figs.~\ref{fig:exp2_tsne_training}(b) and \ref{fig:exp2_tsne_training}(c), the trained DNN yields improved visual separation than the untrained DNN (silhouette scores $-0.21$ vs. $0.09$). The improvement, albeit much smaller as compared to the counterpart in the conference room experiment, suggests that DNN still manages to learn distinctive patterns in this more noisy environment, which leads to better classification results in the testing. Consider locations $p_1$ and $p_4$ as an example, as marked in Figs.~\ref{fig:exp2_tsne_training}(a)--(c). It is seen that before training the samples of the same location are more scattered (as enclosed by the rectangular box) while after training they become better clustered. This leads to reduced misclassification as locations $p_1$ and $p_4$ in the testing, as reflected by a higher precision in the DNN scheme as compared to the $k$-NN scheme for locations $p_1$ and $p_4$, as shown in Table~\ref{tab:exp2_Precision and Recall}. Overall, DNN yields a higher macro-average precision as compared to $k$-NN ($73.29\%$ vs. $62.29\%$). \subsection{Testing Performance} \label{sec:results_exp2_2} The poorer visual separation for the raw testing samples, as shown in Fig.~\ref{fig:exp2_tsne_testing}(a), results in a much lower macro-average recall for $k$-NN in the lounge experiment as compared to in the conference room experiment ($47.5\%$ vs. $70.88\%$). After DNN training, it is observed that a better clustering is achieved in Fig.~\ref{fig:exp2_tsne_testing}(c). For example, the raw testing samples for locations $p_1$ and $p_4$, as enclosed by the rectangular box in Fig.~\ref{fig:exp2_tsne_testing}(a), are highly scattered, resulting in a high misclassification rate of the testing samples of location $p_1$ ($p_4$) to other locations. In comparison, after DNN training, as shown in Fig.~\ref{fig:exp2_tsne_testing}(c), the testing samples are better clustered and closer to the training samples of the same class. As a result, DNN yields a higher recall than $k$-NN for locations $p_1$ and $p_4$ from Table~\ref{tab:exp2_Precision and Recall}. The macro-average recall for DNN is higher than for $k$-NN ($63.71\%$ vs. $47.5\%$ in Table~\ref{tab:exp2_Precision and Recall}). The improvement in silhouette scores between untrained and trained DNN at the last DNN hidden layer (Figs.~\ref{fig:exp2_tsne_testing}(b) and \ref{fig:exp2_tsne_testing}(c)) is smaller in the lounge experiment than in the conference room experiment. This is because there are still testing samples that cannot be well-clustered by DNN (e.g., those located in the lower left corner in Fig.~\ref{fig:exp2_tsne_testing}(c)) in this more noisy environment. However, DNN training still has significant contribution to the classification accuracy, where the difference in the macro-average recall between $k$-NN and DNN is greater in the lounge experiment than in the conference room experiment ($16.21\%$ vs. $8.49\%$). \subsection{Discriminative Features} \label{sec:results_exp2_3} \begin{figure}[t] \begin{center} \includegraphics[width=1\columnwidth]{exp2_LRP_p12_p1} \caption{The percentage of correct classification (true class: $p_{12}$ (or $p_1$)) after progressive channel nullification according to the channel ordering sequences $\mathcal{O}_3(p_{12}\to p_{12})$ and $\mathcal{O}_4(p_{12}\to p_{12})$ (or $\mathcal{O}_3(p_1\to p_1)$ and $\mathcal{O}_4(p_1\to p_1)$).} \label{fig:exp2_LRP_p12_p1} \end{center} \end{figure} \begin{figure}[t] \begin{center} \includegraphics[width=1\columnwidth]{exp2_LRP_p12_p13} \caption{The percentage of classification as $p_{12}$ and $p_{13}$ (true class: $p_{12}$) after progressive channel modification according to the channel ordering sequence $\mathcal{O}_2(p_{12}\to p_{13})$, in comparison with the same setting but after progressive channel nullification.} \label{fig:exp2_LRP_p12_p13} \end{center} \end{figure} \begin{figure}[t] \begin{center} \subfigure[]{ \label{fig:exp2_LRP_heatmap_p12_p12} \includegraphics[width=0.47\columnwidth,height=1.13in]{exp2_LRP_heatmap_p12_p12}} \hspace*{-0.06in} \subfigure[]{ \label{fig:exp2_LRP_heatmap_p12_p13} \includegraphics[width=0.47\columnwidth,height=1.13in]{exp2_LRP_heatmap_p12_p13}} \caption{Heatmaps of relevance scores (a) $h'_i(p_{12}\to p_{12})$ and (b) $h'_i(p_{12}\to p_{13})$ for $i=1,\ldots,120$, superimposed on the $184$ testing samples of CSI of location $p_{12}$.} \label{fig:exp2_LRP_heatmap} \end{center} \end{figure} \begin{figure}[t] \begin{center} \includegraphics[width=\columnwidth]{exp2_LRP_waveform_p12_p13} \caption{$184$ testing samples of CSI of location $p_{12}$ (in (a)) progressively modified toward $184$ testing samples of CSI of location $p_{13}$ (in (h)) according to the channel ordering sequence $\mathcal{O}_2(p_{12}\to p_{13})$. The unmodified/modified channels are color-coded by the CSI of $p_{12}$/$p_{13}$ (in (b)--(g)). The percentages of correct classification as $p_{12}$ and the numbers of channels modified ($t$) are shown.} \label{fig:exp2_LRP_waveform} \end{center} \end{figure} Similar to the conference room experiment, we show the results of progressive channel nullification for a location near the LoS ($p_{12}$) with a high recall ($96\%$) and a location away from the LoS ($p_1$) with a low recall ($43\%$), in Fig.~\ref{fig:exp2_LRP_p12_p1}. The general observations agree with those in the conference room experiment. Fig.~\ref{fig:exp2_LRP_p12_p13} shows the effect of progressive channel modification from $p_{12}$ toward $p_{13}$. It is observed that, again, the decrease in classification as the true class ($p_{12}$) generally leads to the increase in classification as $p_{13}$. However, even when all channels are such modified, the percentage of classification as $p_{13}$ does not reach $100\%$. This is because the CSI samples are apparently more noisy/dispersive in this lounge experiment than in the conference room experiment (the waveforms of different CSI samples collectively appear ``thicker'' in Fig.~\ref{fig:exp2_LRP_waveform} than in Fig.~\ref{fig:LRP_waveform}), and thus there is a higher discrepancy between the modified CSI patterns toward $p_{13}$ and the actual CSI patterns of $p_{13}$ (comparing Figs.~\ref{fig:exp2_LRP_waveform}(g) and \ref{fig:exp2_LRP_waveform}(h)). The cross-comparison between channel modification and nullification concludes similarly as in the conference room experiment. Figs.~\ref{fig:exp2_LRP_heatmap} and \ref{fig:exp2_LRP_waveform} examine the specific channels progressively modified which lead to the results in Fig.~\ref{fig:exp2_LRP_p12_p13}. Channel modification is more sensitive in this lounge experiment, as the percentage of predicting $p_{12}$ declines rapidly as channels are modified. By modifying only six channels for each sample, the percentage of classifying as $p_{12}$ decreases to $73.9\%$ while the percentage of classifying as $p_{13}$ increases to $18.48\%$. These channels initially modified, roughly corresponding to the black-circled ones in Fig.~\ref{fig:exp2_LRP_waveform}(b), represent evidence in support of predicting $p_{12}$ (yellow/red in Fig.~\ref{fig:exp2_LRP_heatmap_p12_p12}) but neutral or against predicting $p_{13}$ (cyan/blue in Fig.~\ref{fig:exp2_LRP_heatmap_p12_p13}). Comparing Figs.~\ref{fig:exp2_LRP_waveform}(d) and \ref{fig:exp2_LRP_waveform}(e), the additional $51$ channels modified, roughly corresponding to the black-circled ones in Fig.~\ref{fig:exp2_LRP_waveform}(e), are evidence neutral for predicting both $p_{12}$ and $p_{13}$, leading to a slow decrease and increase in the percentages of predicting $p_{12}$ and $p_{13}$, respectively. Comparing Figs.~\ref{fig:exp2_LRP_waveform}(g) and \ref{fig:exp2_LRP_waveform}(h), there is a more pronounced discrepancy between the modified CSI toward the mean of CSI of $p_{13}$ and the actual CSI of $p_{13}$, due to a larger variation in the testing CSI samples in the lounge experiment. \subsection{Subcarrier Importance} \label{sec:results_exp2_4} \begin{figure}[t] \begin{center} \includegraphics[width=1\columnwidth]{exp2_LRP_p12_p1_subcarrier} \caption{The percentage of correct classification (true class: $p_{12}$ (or $p_1$)) after progressive subcarrier nullification according to the subcarrier ordering sequences $\mathcal{O}_3(p_{12}\to p_{12})$ and $\mathcal{O}_4(p_{12}\to p_{12})$ (or $\mathcal{O}_3(p_1\to p_1)$ and $\mathcal{O}_4(p_1\to p_1)$).} \label{fig:exp2_LRP_p12_p1_subcarrier} \end{center} \end{figure} \begin{figure}[t] \begin{center} \includegraphics[width=1\columnwidth]{exp2_LRP_heatmap_p12_p12_subcarrier} \caption{Heatmaps of relevance scores $s'_i(p_{12}\to p_{12})$ for $i=1,\ldots,30$, superimposed on the $184$ testing samples of CSI for four transmit-receive antenna pairings of location $p_{12}$.} \label{fig:exp2_LRP_heatmap_p12_p12_subcarrier} \end{center} \end{figure} Figs.~\ref{fig:exp2_LRP_p12_p1_subcarrier} and \ref{fig:exp2_LRP_heatmap_p12_p12_subcarrier} present results related to subcarrier importance. There is a richer multipath effect (larger delay spread) in the lounge environment than in the conference room environment, as shown by the generally smaller correlation coefficients between two adjacent subcarriers in the lounge experiment (comparing the same pairs of adjacent subcarriers, the lounge environment yields smaller correlation coefficients in $26$ out of the total $29$ pairs of adjacent subcarriers). In the lounge experiment, the logical channels that correspond to the same physical subcarriers have even more greatly varying relevance scores. Thus, progressively nullifying a specific subcarrier in four wireless links simultaneously translates to channel nullification in neither the channel ordering sequence of $\mathcal{O}_3$ nor $\mathcal{O}_4$. Thus, Fig.~\ref{fig:exp2_LRP_p12_p1_subcarrier} exhibits a slightly different trend as compared to Fig.~\ref{fig:exp2_LRP_p12_p1}. The richer multipath effect, which, in theory, provides more degrees of freedom which could aid feature selection for classification, may have led to a greater performance improvement of DNN over $k$-NN in the macro-average recall and precision in the lounge experiment (see Tables~\ref{tab:exp1_Precision and Recall} and \ref{tab:exp2_Precision and Recall}). Yet, in the meantime, the same environment induces more noisy CSI across different samples, which deteriorates the performance of DNN (as well as $k$-NN and SVM) in absolute terms in the lounge experiment. \section{Conclusion} \label{sec:conclusion} In this paper, we have performed a detailed analysis of the DNN in device-free Wi-Fi fingerprinting indoor localization through visual analytics techniques. By projecting the last DNN hidden layer activations to visualizable 2D representations via the t-SNE dimensionality reduction technique, we observed better clustering and visual separation among different classes after DNN training. The more concentrated distribution of the testing samples matches the reduced misclassification in the testing for DNN. DNN generally yields higher precision results as compared to $k$-NN based on the raw data, suggesting that DNN training is effective in learning discriminative features from the noisy wireless signals. The LRP visual analytics technique, coupled with the channel nullification/modification procedures, revealed critical channels or features in wireless signals learned by the DNN which cannot be well interpreted by human perceptions. The relevance scores, determined by LRP, provided analyzable, interpretable, and reliable measures of how and why the percentages of classification change as specific channels or features are manipulated, and thereby allow for a better understanding of the mechanism of DNN-based device-free wireless indoor localization. \bibliographystyle{IEEEtran}
{'timestamp': '2019-05-23T02:11:18', 'yymm': '1904', 'arxiv_id': '1904.10154', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.10154'}
arxiv
\section{Introduction} In a binary classification problem, if all the class $C_+$ examples are concentrated in a single convex region with the class $C_-$ examples being all around that region, then the region of class $C_+$ can be well captured by a polyhedral set. A polyhedral set is a convex set which is formed by an intersection of a finite number of closed halfspaces \cite{Rockafellar}. An essential property of polyhedral sets is that they can be used to approximate any convex connected subset of $\mathbb{R}^d$. This property of polyhedral sets makes the learning of polyhedral regions an interesting problem in pattern recognition. Polyhedral classifiers are useful in many real-world applications, e.g., text classification \citep{SatiO18}, cancer detection \citep{Murat2008}, visual object detection, and classification \citep{Cevikalp2017PolyhedralCC} etc. To learn a classifier in this case, we need to find a closed connected set (e.g., an enclosing ball) which contain all positive examples leaving all the negative examples outside the set. Support vector data description method \cite{Tax2004} does this task by fitting a minimum enclosing hypersphere in the feature space to include most of the class $C_+$ examples inside the hypersphere while considering all the class $C_-$ examples as outliers. In such techniques, the nonlinearity in the data is captured by choosing an appropriate kernel function. With a non-linear kernel function, the final classifier may not provide good geometric insight on the class boundaries in the original feature space. Such insights are useful to understand the local behavior of the classifier in different regions of the feature space. A well-known approach to learn polyhedral sets is the top-down decision tree method. In a binary classification problem, a top-down decision tree represents each class region as a union of polyhedral sets \cite{Breiman1984, Duda, Naresh11}. Here all positive examples belong to a single polyhedral set. However, top-down decision tree algorithms, due to greedy nature, may not learn a single polyhedral set well. Neither SVM nor top-down decision trees (CART) can learn classifier as a polyhedral set. Even when we want a classifier for general data, neither CART nor SVM can learn a classifier representable as compactly as that by PLUME. In the context of explainable AI, a classifier whose decision is based on two hyperplanes in the original feature space is certainly more understandable than a large decision tree or a classifier that is a linear combination of many kernel functions. Unlike such general purpose approaches, there are many specialized approaches for learning polyhedral classifiers. In such methods, we first fix the structure of the polyhedral classifier and determine the optimal parameters of this fixed structure. In the case of polyhedral classifiers, we can adjust the structure by choosing the number of hyperplanes. One can formulate a constrained optimization problem to learn polyhedral classifiers \cite{Astorino,Murat2008,Carlotta, SatiO18}. This optimization problem minimizes the sum of classification errors over the training set subject to the separability conditions. Conceptually, learning a polyhedral set requires learning each of the hyperplanes constituting it. But we cannot solve these linear problems (of learning individual hyperplanes) separately because the available training set cannot be easily transformed into training sets for learning individual hyperplanes. While points of $C_+$ would be positive examples for each of the linear problems, it is not known apriori which points of $C_-$ are negative examples for learning which hyperplane. In \cite{Astorino}, this problem is solved by first enumerating all possibilities for misclassified negative examples (e.g., which hyperplane is responsible for a negative example to get misclassified and for each negative example there could be many such hyperplanes) and then solving a linear program for each possibility to find descent direction. This approach becomes computationally very expensive. \cite{Murat2008} assume that for every linear subproblem, a small subset of negative examples is known and propose a cyclic optimization algorithm. Their assumption of knowing a subset of negative examples corresponding to every linear subproblem is not realistic in many practical applications. \citet{Zhou:2016} propose a method in which the positive class is enclosed using the intersection of non-linear surfaces using kernel methods. By using linear kernels it becomes same as polyhedral learning. However, they use the same objective function as other constrained optimization problems. \citet{Naresh10} propose a logistic function based posterior probability model for polyhedral learning. They learn the parameters using alternating minimization. The method is shown to perform well experimentally though there are no theoretical guarantees about convergence or generalization errors. A large margin framework for polyhedral learning is discussed in \cite{NIPS2014_5511} using stochastic gradient descent. In this paper, we propose a mixture of experts model for learning polyhedral classifiers. The mixture of experts \citep{Nowlan1} model contains several linear experts (classifiers) and each of the expert champions one of the regions of the feature space. It also includes a gating function which decides which expert to use for a particular example. Even though mixture of experts is a generic approach, in the context of learning polyhedral classifiers it carries a unique structure which requires a lesser number of parameters. We see that it does not need separate parameters to model the gating function. It uses experts parameters themselves for modeling the gating function. As far as our knowledge is concerned, this is the first attempt in this direction. We make the following contributions in this paper. \begin{enumerate} \item We propose a novel mixture of experts architecture to model polyhedral classifiers. We propose an expectation maximization (EM) algorithm using this model to learn the parameters of the polyhedral classifiers. \item We derive data dependent generalization error bounds for the proposed model with specific constraints that the gating function uses the same parameters as experts. \item We do extensive simulations on various datasets and compare with state of the art approaches to show that our approach learns polyhedral classifiers efficiently. \end{enumerate} The rest of the paper is organized as follows. In Section \ref{Sec:polyhedral classifier}, we state the definitions of polyhedral separability and polyhedral classifiers. We describe the mixture of experts model in Section~\ref{Sec:model} and corresponding EM algorithm in Section~\ref{sec:EM}. We derive the generalization error bounds for the proposed model in Section~\ref{sec:GEB} We describe the experimental results in Section~\ref{sec:Exp}. We conclude the paper with some remarks in Section~\ref{conclusions} \section{Polyhedral Classification}\label{Sec:polyhedral classifier} Let $S=\{(\mathbf{x}_1 , y_1),\ldots,(\mathbf{x}_N,y_N)\}$ be the training dataset, where $(\mathbf{x}_n,y_n)\in \mathbb{R}^d\times\{+1,-1\},\forall n$. Let $C_+$ be the set of points for which $y_n=1$ and let $C_-$ be the set of points for which $y_n=-1$. \subsection{Polyhedral Separability} Two sets $C_+$ and $C_-$ in $\mathbb{R}^d$ are said to be $K$-polyhedral separable if there exists a set of $K$ hyperplanes having parameters, $(\mathbf{w}_k,b_k),\;k=1\ldots K$ ($\mathbf{w}_k \in \mathbb{R}^d,\;b_k \in \mathbb{R}$), such that \begin{enumerate} \item $\forall \; \mathbf{x} \in C_+: \;\;\mathbf{w}_k^T\mathbf{x}+b_k \geq 0,\;\forall\; k\in\{1,\ldots, K\}$ \item $\forall \; \mathbf{x} \in C_-: \;\;\exists k\in \{1,\ldots, K\},\;\text{s.t.}\;\mathbf{w}_k^T\mathbf{x}+b_k < 0$ \end{enumerate} This means that two sets $C_+$ and $C_-$ are $K$-polyhedral separable if $C_+$ is contained in a convex polyhedral set which is formed by intersection of $K$ half spaces and the points of set $C_-$ are outside this polyhedral set. Here all the positive examples satisfy each of a given set of linear inequalities (that defines the half spaces whose intersection is the polyhedral set). However, each of the negative examples fail to satisfy one (or more) of these inequalities and we do not know apriori which inequality each negative example fails to satisfy. Thus constraint on each of the negative examples is logical `OR' of the linear constraints which makes the optimization problem non-convex. \subsection{Polyhedral Classifier} Let $(\mathbf{w}_k,b_k),\;k=1\ldots K$ be the parameters of the $K$ hyperplanes which form the polyhedral set. Here $\mathbf{w} \in \mathbb{R}^d,b_k \in \mathbb{R},\;k=1\ldots K$. Let $h:\mathbb{R}^d\rightarrow \mathbb{R}$ be defined as: \begin{equation}\label{eq:modelfunction} h(\mathbf{x})=\min_{k\in \{1,\ldots, K\}}(\mathbf{w}_k^T\mathbf{x}+b_k) \end{equation} Clearly if $h(\mathbf{x})\geq 0$, then the condition $\mathbf{w}_k^T\mathbf{x}+b_k \geq 0$ is satisfied for all $k\in\{1,\ldots, K\}$ and the point $\mathbf{x}$ can be assigned to set $C_+$. Similarly, if $h(\mathbf{x})< 0$, there exists at least one $k\in\{1,\ldots,K\}$, for which $\mathbf{w}_k^T\mathbf{x}+b_k <0$ and the point $\mathbf{x}$ can be assigned to set $C_-$. Thus, the polyhedral classifier can be expressed as \begin{equation}\label{eq:poly-classifier} f(\mathbf{x})=\text{sign}(h(\mathbf{x}))=\text{sign}\big{[}\min_{k\in \{1,\ldots, K\}}(\mathbf{w}_k^T\mathbf{x}+b_k)\big{]} \end{equation} Let $\tilde{\mathbf{w}}_k =[\mathbf{w}_k^T~b_k]^T$ and $\tilde{\mathbf{x}}_n=[\mathbf{x}_n^T~1]^T$. Now on, we will express $\mathbf{w}_k^T\mathbf{x}+b_k$ as $\tilde{\mathbf{w}}_k^T\tilde{\mathbf{x}}$. \section{Mixture of Experts Model for Polyhedral Classifier}\label{Sec:model} We propose a new mixture of experts architecture for learning polyhedral classifiers. We model the posterior probability as a mixture of $K$ logistic functions where $K$ is the number of hyperplanes associated with the polyhedral classifier. We write the posterior probability of the class labels as \begin{align} p_{\Theta}(y|\mathbf{x})=\sum_{k=1}^K p(k|\mathbf{x})p(y|\mathbf{x},k)=\sum_{k=1}^Kg_k(\mathbf{x},\Theta)\sigma(y\tilde{\mathbf{w}}_k^T\tilde{\mathbf{x}})\label{eq:posterior} \end{align} where $\Theta =[\tilde{\mathbf{w}}_1^T\;\tilde{\mathbf{w}}_2^T\;\ldots\;\tilde{\mathbf{w}}_K^T]^T$ and $\sigma(a)=(1+e^{-a})^{-1}$. Each expert models the posterior probability using the logistic regression. The parameter vector associated with the $k^{th}$ expert is $\tilde{\mathbf{w}}_k$. $g_k(\mathbf{x},\Theta)$ is the gating function which decides how much weightage should be given to $k^{th}$ expert for an example $\mathbf{x}$. To ensure that eq.(\ref{eq:posterior}) describes a valid posterior probability model, we choose $g_k(\mathbf{x},\Theta)$ such that $\sum_{k=1}^K g_k(\mathbf{x},\Theta) =1$ and $g_k(\mathbf{x},\Theta)\geq 0,\;\forall k=1\ldots K$. For learning polyhedral classifiers, we construct the gating function using softmax function as follows: \begin{equation} g_k(\mathbf{x},\Theta) = \frac{e^{-\gamma \tilde{\mathbf{w}}_k^T\tilde{\mathbf{x}}}}{\sum_{j=1}^K e^{-\gamma \tilde{\mathbf{w}}_j^T\tilde{\mathbf{x}}}} \label{eq:soft-gating-model} \end{equation} where $\gamma >0$ is a user defined parameter which decides how fast $g_k(\mathbf{x},\Theta)$ goes to 0 or 1. Note that the proposed gating function depends on experts parameters only. Moreover, $$\lim_{\gamma \rightarrow \infty}g_k(\mathbf{x},\Theta) = \mathbb{I}_{\left\{k=\underset{j\in\{1,\ldots,K\}}{\arg\min}\tilde{\mathbf{w}}_j^T\tilde{\mathbf{x}}\right\}}$$ and hence $$\lim_{\gamma \rightarrow \infty}p_{\Theta}(y|\mathbf{x}) = \frac{1}{1+e^{-y\;\underset{j\in\{1,\ldots,K\}}{\min}\;\tilde{\mathbf{w}}_j^T\tilde{\mathbf{x}}}}.$$ For a polyhedrally separable data, we know that $y\min_{j\in\{1,\ldots,K\}}\tilde{\mathbf{w}}_j^T\tilde{\mathbf{x}} \geq 0$. Thus, $p_\Theta(y=1|\mathbf{x})$ will be close to 1 if $\mathbf{x} \in C_+$. Similarly, $p_\Theta(y=0|\mathbf{x})$ will be close to 1 if $\mathbf{x} \in C_-$. Thus, $p_{\Theta}(y|\mathbf{x})$ described in eq.(\ref{eq:posterior}) is a valid probability model for polyhedral learning. Note that the model proposed in \citep{Naresh10} is a limiting case of the model proposed in eq.(\ref{eq:posterior}). The advantage with the proposed model are twofold. As the proposed posterior probability function is a smooth function, the resulting EM formulation will satisfy smoothness conditions required for convergence. This is in contrast to the hard partitioning model in \citet{Naresh10}. The second advantage that we will see is that the proposed model is also better suited for capturing smooth convex boundaries. \section{EM Algorithm for Learning Polyhedral Classifier} \label{sec:EM} As the posterior probability model is a mixture model, we propose an EM approach for learning the parameters. Recall that $S=\{(\mathbf{x}_1,y_1),\ldots,(\mathbf{x}_N,y_N)\}$ is the training data set, where $(\mathbf{x}_n,y_n)\in \mathbb{R}^d\times\{-1,+1\},\;\forall n$. In the EM framework, we think of $S$ as incomplete data and have $p(y|\mathbf{x},\Theta)$ (given by equation (\ref{eq:posterior})) as the model for incomplete data. In this problem, we don't know which expert should be used to classify example $\mathbf{x}_n$. This is the missing information. We represent the missing information corresponding to example $\mathbf{x}_n$ as $\mathbf{z}_n=[z_{n1}~\ldots~z_{nK}]^T$, where each $z_{nk}\in \{0,1\},k=1\ldots K$, such that $\sum_{k=1}^K z_{nk}=1,\;\forall n$. Moreover, \begin{equation}\label{eq:model4} P(z_{nk}=1|\mathbf{x}_n,\Theta)=g_k(\mathbf{x}_n,\Theta)=\frac{e^{-\gamma\tilde{\mathbf{w}}_k^T\tilde{\mathbf{x}}_n}}{\sum_{j=1}^Ke^{-\gamma\tilde{\mathbf{w}}_j^T\tilde{\mathbf{x}}_n}}. \end{equation} Let $\bar{S}=\{(\mathbf{x}_1,y_1,\mathbf{z}_1),\ldots,(\mathbf{x}_N,y_N,\mathbf{z}_N)\}$ be the complete data. The complete-data log likelihood is given as follows. \begin{align*} l_{\text{complete}}&(\Theta;\bar{S})=\ln \big{[} \prod_{n=1}^N \prod_{k=1}^K [P(y_n,z_{nk}|\mathbf{x}_n,\Theta)]^{z_{nk}}\big{]}\\ &=\sum_{n=1}^N \sum_{k=1}^K z_{nk} \big{[}\ln g_k(\mathbf{x}_n,\Theta)+\ln \sigma(y_n\tilde{\mathbf{w}}_k^T\tilde{\mathbf{x}}_n)\big{]} \end{align*} \textbf{E-Step: } In the E-step, we find $Q(\Theta,\Theta^c)$ which is the expectation of complete-data log likelihood. \begin{align*} \mathcal{Q}_N(\Theta,\Theta^c)={\mathbb E}_{\{\mathbf{z}_1,\ldots,\mathbf{z}_N\}} \big{[}l_{\text{complete}}(\Theta;\bar{S})|\Theta^c\big{]}\\ = \sum_{n=1}^N \sum_{k=1}^K \big{[}\ln g_k(\mathbf{x}_n,\Theta)+\ln \sigma(y_n\tilde{\mathbf{w}}_k^T\tilde{\mathbf{x}}_n)\big{]} \pi_k(\mathbf{x}_n,\Theta^c) \end{align*} where $\pi_k(\mathbf{x}_n,\Theta)=P(z_{nk}=1|\mathbf{x}_n,y_n,\Theta)$ found as follows. \begin{align}\label{eq:postprob} \nonumber \pi_k(\mathbf{x}_n,\Theta) &= \frac{g_k(\mathbf{x}_n,\Theta)\sigma(y_n\tilde{\mathbf{x}}_n^T\tilde{\mathbf{w}}_k)}{\sum_{j=1}^K g_j(\mathbf{x}_n,\Theta)\sigma(y_n\tilde{\mathbf{x}}_n^T\tilde{\mathbf{w}}_j)}\\ &= \frac{e^{-\gamma\tilde{\mathbf{x}}_n^T\tilde{\mathbf{w}}_k}\sigma(y_n\tilde{\mathbf{x}}_n^T\tilde{\mathbf{w}}_k)}{\sum_{j=1}^K e^{-\gamma\tilde{\mathbf{x}}_n^T\tilde{\mathbf{w}}_j^c}\sigma(y_n\tilde{\mathbf{x}}_n^T\tilde{\mathbf{w}}_j)} \end{align} It is easy to see that $\mathcal{Q}_N(\Theta,\Theta^c)$ is a concave function of $\Theta$. \textbf{M-Step: }In the M-step, we maximize $\mathcal{Q}_{N}(\Theta,\Theta^c)$ with respect to $\Theta$ to find the new parameter set $\Theta^{c+1}$. Since $\mathcal{Q}_N(\Theta,\Theta^c)$ is a concave function of $\Theta$, there exists a unique maxima of it. However, we do not get the closed form solution for the maximization with respect to $\Theta$. Thus, we find $\Theta^{c+1}$ by moving in ascent direction of $\mathcal{Q}_{N}(\Theta,\Theta^c)$ starting from $\Theta^c$. We can use one of the following approaches. \begin{itemize} \item \textbf{Gradient Ascent: }The gradient ascent update equation is as follows. \begin{eqnarray} \label{eq:gradient_ascent} \Theta^{c+1} = \Theta^c+\alpha^c \nabla \mathbf{g}^c \end{eqnarray} where $\alpha^c$ is step size at iteration $c$ and $\mathbf{g}^c$ is $dK$-dimensional gradient vector at $c^{th}$ iteration. $$\mathbf{g}= \begin{pmatrix} \frac{\partial \mathcal{Q}_{N}(\Theta,\Theta^c)}{\partial \tilde{\mathbf{w}}_1}^T\;\; \frac{\partial \mathcal{Q}_{N}(\Theta,\Theta^c)}{\partial \tilde{\mathbf{w}}_2}^T \ldots \frac{\partial \mathcal{Q}_{N}(\Theta,\Theta^c)}{\partial \tilde{\mathbf{w}}_K}^T \end{pmatrix}^T$$ $\frac{\mathcal{Q}_{N}(\Theta,\Theta^c)}{\partial \tilde{\mathbf{w}}_k}$ can be found as follows. \begin{align} \nonumber &\frac{\partial \mathcal{Q}_{N}(\Theta,\Theta^c)}{\partial \tilde{\mathbf{w}}_k} = -\sum_{n=1}^N \Big{[} \gamma \big{\{}\pi_k(\mathbf{x}_n,\Theta^c)-g_k(\mathbf{x}_n,\Theta)\big{\}}\\ &-\big{\{}y_n \pi_k(\mathbf{x}_n,\Theta^c) (1-\sigma(y_n\tilde{\mathbf{x}}_n^T\tilde{\mathbf{w}}_k))\big{\}}\Big{]}\tilde{\mathbf{x}}_n \label{Q-Grad} \end{align} \item \textbf{Newton Method: }The Newton method updates the parameters as follows. \begin{align} \label{eq:Newton} \Theta^{c+1} = \Theta^c+\alpha^c (H^c)^{-1} \mathbf{g}^c \end{align} where $H^c$ is $dK\times dK $ Hessian matrix at $c^{th}$ iteration. $H$ is defined as follows. \begin{equation*} H = \begin{pmatrix} \frac{\partial^2 \mathcal{Q}_{N}(\Theta,\Theta^c)}{\partial \tilde{\mathbf{w}}_1^2} & \frac{\partial^2 \mathcal{Q}_{N}(\Theta,\Theta^c)}{\partial \tilde{\mathbf{w}}_1\tilde{\mathbf{w}}_2} &\hdots & \frac{\partial^2 \mathcal{Q}_{N}(\Theta,\Theta^c)}{\partial \tilde{\mathbf{w}}_1\tilde{\mathbf{w}}_K}\\ \frac{\partial^2 \mathcal{Q}_{N}(\Theta,\Theta^c)}{\partial \tilde{\mathbf{w}}_2\tilde{\mathbf{w}}_1} & \frac{\partial^2 \mathcal{Q}_{N}(\Theta,\Theta^c)}{\partial \tilde{\mathbf{w}}_2^2} &\hdots & \frac{\partial^2 \mathcal{Q}_{N}(\Theta,\Theta^c)}{\partial \tilde{\mathbf{w}}_2\tilde{\mathbf{w}}_K}\\ \vdots & \vdots & \ddots & \vdots \\ \frac{\partial^2 \mathcal{Q}_{N}(\Theta,\Theta^c)}{\partial \tilde{\mathbf{w}}_K\tilde{\mathbf{w}}_1} & \frac{\partial^2 \mathcal{Q}_{N}(\Theta,\Theta^c)}{\partial \tilde{\mathbf{w}}_K\tilde{\mathbf{w}}_2} & \hdots & \frac{\partial^2 \mathcal{Q}_{N}(\Theta,\Theta^c)}{\partial \tilde{\mathbf{w}}_K^2}\end{pmatrix} \end{equation*} $\mathbf{g}^c$ is as given earlier. Also, \begin{align*} H_{kk}&=\frac{\partial^2 \mathcal{Q}_{N}(\Theta,\Theta^c)}{\partial \tilde{\mathbf{w}}_k^2}\\ &=-\sum_{n=1}^N \gamma^2g_k(\mathbf{x}_n,\Theta)(1-g_k(\mathbf{x}_n,\Theta)\tilde{\mathbf{x}}_n\tilde{\mathbf{x}}_n^T\\ & -\sum_{n=1}^N\pi_k(\mathbf{x}_n,\Theta^c) \sigma(\tilde{\mathbf{w}}_k^T\tilde{\mathbf{x}}_n)(1-\sigma(\tilde{\mathbf{w}}_k^T\tilde{\mathbf{x}}_n))\tilde{\mathbf{x}}_n\tilde{\mathbf{x}}_n^T\\ H_{kr}&= \frac{\partial^2 \mathcal{Q}_{N}(\Theta,\Theta^c)}{\partial \tilde{\mathbf{w}}_k\tilde{\mathbf{w}}_r}\\ &=\gamma^2\sum_{n=1}^N g_k(\mathbf{x}_n,\Theta)g_r(\mathbf{x}_n,\Theta)\tilde{\mathbf{x}}_n\tilde{\mathbf{x}}_n^T,\; \forall r\neq k \end{align*} \item \textbf{The BFGS Algorithm:} In the BFGS method \cite{chong2013}, the Hessian matrix is not evaluated directly and its inverse is approximated using rank-two updates specified by gradient evaluations. Let $H^{-1}=B$, then \begin{flalign*} \nonumber B^{c+1}&=B^{c} +\left(1+\frac{\Delta {\mathbf{g}^{c}}^T B^{c}\Delta \mathbf{g}^{c}}{\Delta {\mathbf{g}^{c}}^T \Delta \Theta^{c}}\right) \frac{\Delta \Theta^{c} {\Delta \Theta^{c}}^T}{{\Delta \Theta^{c}}^T\Delta \mathbf{g}^{c}}\\ &\;\;\;-\frac{B^{c}\Delta \mathbf{g}^{c} {\Delta \Theta^{c}}^T + \Theta^{c}{\Delta \mathbf{g}^{c}}^T{B^{c}}^T} {{\Delta \mathbf{g}^{c}}^T\Delta \Theta^{c}} \end{flalign*} where $\Delta {\mathbf{g}^{c}}= \mathbf{g}^{c+1}-\mathbf{g}^{c}$ and $\Delta {\Theta^{c}}= \Theta^{c+1}-\Theta^{c}$. Then the update equation for weight vectors is as follows: \begin{equation} \label{eq:bfgs} \Theta^{c+1}=\Theta^{c} + \alpha^c B^{c}\mathbf{g}^{c} \end{equation} where $\alpha^c$ is the step size. \end{itemize} In the above mentioned iterative optimization approaches, we need to choose the step size appropriately to ensure the convergence of our approach. There are many ways to find the step size. For our work, we use the backtracking line search to find the step size. \begin{algorithm} \caption{{\bf P}olyhedral {\bf L}earning {\bf U}sing {\bf M}ixture of {\bf E}xperts (PLUME)} \label{algo:algo1} \KwIn{$S=\{(\mathbf{x}_1,y_1),\ldots,(\mathbf{x}_N,y_N)\}$, $K$, $\epsilon$} \KwOut{$\{\tilde{\mathbf{w}}_1,\ldots,\tilde{\mathbf{w}}_k\}$} \Begin { \begin{itemize} \item {\bf Initialize} $\tilde{\mathbf{w}}_k^0,\;\forall k=1\ldots K$. Set $c=0$. \item {\bf E-Step} For $k=1\ldots K$ and $n=1\ldots N$, find $\pi_k(\mathbf{x}_n,\Theta^c)$ using eq.(\ref{eq:postprob}) \item {\bf M-Step} For $k=1\ldots K$, find $\tilde{\mathbf{w}}_k^{c+1}$ as \begin{equation*} \Theta^{c+1}=\Theta^c + \alpha^c \mathbf{d}^c \end{equation*} we use one of eq.(\ref{eq:gradient_ascent}), (\ref{eq:Newton}), (\ref{eq:bfgs}). \item {\bf Termination}\\ \lIf{$\mathcal{L}(\Theta^{c+1})-\mathcal{L}(\Theta^c)< \epsilon$}{ stop } \lElse{ $c=c+1$\; go to E-Step } \end{itemize} } \end{algorithm} \section{Data Dependent Generalization Error Bounds} \label{sec:GEB} In this section, we will prove data dependent generalization error bounds. The generalization bounds show the utility of our formulation modelling the posterior probability function as a smooth function. These bounds shows that the method has proper asymptotic properties. In this problem, we are finding the parameters by maximizing the likelihood which is equivalent to minimizing empirical risk under cross entropy loss $\phi (.,.)$ specified as below. \begin{equation*} \phi(y, f(\mathbf{x})) = - y \ln p_{\Theta}( y | \mathbf{x} ) - (1-y) \ln ( 1 - p_{\Theta}(y | \mathbf{x}) ) \end{equation*} where $p_{\Theta}(y | \mathbf{x})$ is specified in eq.(\ref{eq:posterior}). Define $\phi$-risk as \begin{equation} \mathcal{R}_{\phi}(f) = \mathbb{E}\big[ \phi(y, f(\mathbf{x})) \big] \end{equation} Define empirical $\phi-$risk as \begin{equation*} \hat{\mathcal{R}}_{\phi} (f) = \frac{1}{N} \sum_{n=1}^N \phi (y_{n} , f( \mathbf{x}_{n}) ) \end{equation*} Let $\mathcal{F}$ be a class of real-valued functions with domain $\mathbb{R}^d$. Here, we derive data dependent error bounds using Rademacher complexity. The empirical Rademacher complexity is defined as \begin{equation*} \hat{R}_{N}(\mathcal{F}) = \mathbb{E}_{\mathbf{\epsilon}} \left\{ \sup_{f \in \mathcal{F}} \frac{1}{N} \sum_{n=1}^N \epsilon_{n} f(\mathbf{x}_{n}) \right\} \end{equation*} where $\mathbf{\epsilon} = (\epsilon_{1}, \epsilon_{2}, ..., \epsilon_{N})$ is a vector of independent Rademacher random variable. The Rademacher complexity is the expected value of the empirical Rademacher complexity over all training sets of size $N$ i.e., $R_{N}(\mathcal{F}) = \mathbb{E}_{S} \big[ \hat{R}_{N}(\mathcal{F}) \big]$. \\[7pt] We formalize our assumption as below to prove data dependent error bound. \begin{assumption} \label{assumption} Let $\| \mathbf{w}_{k} \| \leq \mathbf{W}_{k}^{\max} \;\; \forall k \in \{1,...,K\}$ and $\| \mathbf{x} \| \leq \mathbf{R},\;\forall \mathbf{x}$. \end{assumption} To simplify the notation, we introduce $\mathbf{W}^{\max}, \mathbf{W}^{\min}$ as $\mathbf{W}^{\max} = \max_{k} \; \mathbf{W}_{k}^{\max}$ and $\mathbf{W}^{\min} = \min_{k} \; \mathbf{W}_{k}^{\max}$. We start our discussion regarding data dependent error bounds with the following result from \cite{Bartlett:2003:RGC:944919.944944}. \begin{result} \label{lemma:error-bound} For every $\delta \in (0,1)$ and positive integer $N$, every $f \in \mathcal{F}$ satisfies \begin{equation} \label{eq:risk-bound} \mathcal{R}_{\phi}(f) \leq \hat{ \mathcal{R} }_{\phi} (f) + 2L_{\phi} \hat{R}_{N}(\mathcal{F}) + 3\phi_{\max} \sqrt{ \frac{ \text{ln} \frac{2}{\delta} }{2N} } \end{equation} with probability at least $1 - \delta$. \end{result} In Result 2, we will first upper bound $\hat{R}_{N} ( \mathcal{F} )$ where $\mathcal{F} = \{ f:f(\mathbf{x}) = \sum_{k=1}^K g_{k}(\mathbf{x}, \Theta) \sigma(y \tilde{\mathbf{w}}^T_{k} \tilde{\mathbf{x}} ) \}$ . \begin{lemma} \label{lemma:rh-rhk-bound} Let $\mathcal{F}_{k} = \{ \; g_{k}(\mathbf{x}, \Theta) \; \sigma(y \tilde{\mathbf{w}}_{k}^T \tilde{\mathbf{x}}) \; | \; \| \mathbf{w}_{k} \| < \mathbf{W}_{k}^{\max} \}$. Then, $\hat{R}_{N}(\mathcal{F}) \leq \sum_{k=1}^K \hat{R}_{N}(\mathcal{F}_{k})$. \end{lemma} \begin{proof} To simplify the notation, we write $\sup_{\mathbf{w}_{1},...,\mathbf{w}_{k}}$ as $\sup_{\mathbf{w}}$. \begin{equation*} \begin{aligned} \hat{R}_{N}(\mathcal{F}) &= \mathbb{E}_{\epsilon} \left\{ \sup_{\Theta} \frac{1}{N} \sum_{n=1}^N \epsilon_{n} \sum_{k=1}^{K} g_{k}(\mathbf{x}_{n}, \Theta) \sigma(y_n \tilde{\mathbf{w}}_{k}^T \tilde{\mathbf{x}}_n ) \right\} \\ &\leq \mathbb{E}_{\epsilon} \left\{ \sum_{k=1}^{K} \sup_{\Theta} \frac{1}{N} \sum_{n=1}^N \epsilon_{n} g_{k}(\mathbf{x}_{n}, \Theta) \sigma(y_n \tilde{\mathbf{w}}_{k}^T \tilde{\mathbf{x}}_n) \right\} \\ &= \sum_{k=1}^{K} \mathbb{E}_{\epsilon} \left\{ \sup_{\Theta} \frac{1}{N} \sum_{n=1}^N \epsilon_{n} g_{k}(\mathbf{x}_{n}, \Theta) \sigma(y_n \tilde{\mathbf{w}}_{k}^T \tilde{\mathbf{x}}_n) \right\} \\ &= \sum_{k=1}^{K} \hat{R}_{N} (\mathcal{F}_{k}) \end{aligned} \end{equation*} \end{proof} Now, in order to bound $\hat{R}_{N}(\mathcal{F})$, using Lemma~\ref{lemma:rh-rhk-bound}, we will bound each of $\hat{R}_N(\mathcal{F}_{k})$ individually. \begin{lemma} \label{lemma:fk-bound} Suppose Assumption \ref{assumption} holds then \begin{align*} \hat{R}_{N}(\mathcal{F}_{k}) \leq \frac{ 3\sqrt{(K-1)} }{K \sqrt{2}} \sum_{k=1}^K \frac{\mathbf{W}_{k}^{\max} {\mathbf{R}}}{\sqrt{N}} + \frac{\mathbf{W}_{k}^{\max} {\mathbf{R}}}{\sqrt{N}} \end{align*} \end{lemma} \begin{proof} we decompose $\hat{R}_{N}(\mathcal{F}_{k})$ as follows. \begin{equation*} \begin{aligned} \hat{R}_{N}(\mathcal{F}_{k}) &= \mathbb{E}_{\epsilon} \left\{ \sup_{\Theta} \frac{1}{N} \sum_{n=1}^N \epsilon_{n} g_{k}(\mathbf{x}_{n}, \Theta) \sigma(y_{n}\tilde{\mathbf{w}}_{k}^T\tilde{\mathbf{x}}_{n}) \right\} \\ = & \; \mathbb{E}_{\epsilon} \left\{ \sup_{\Theta} \frac{1}{N} \sum_{n=1}^N \epsilon_{n} g_{k}(\mathbf{x}_{n}, \Theta) (\sigma(y_{n}\tilde{\mathbf{w}}_{k}^T\tilde{\mathbf{x}}_{n}) - 0.5) \right. \\ & \left. \;\;\;\;\;\; + \frac{1}{N} \sum_{n=1}^N 0.5 \epsilon_{n} g_{k}(\mathbf{x}_{n}, \Theta) \right\} \\ \leq & \; \mathbb{E}_{\epsilon} \left\{ \sup_{\Theta} \frac{1}{N} \sum_{n=1}^N \epsilon_{n} g_{k}(\mathbf{x}_{n}, \Theta) (\sigma(y_{n}\tilde{\mathbf{w}}_{k}^T\tilde{\mathbf{x}}_{n}) - 0.5) \right\} \\ & \;\;\;\;\;\; + \mathbb{E}_{\epsilon} \left\{ \sup_{\Theta} \frac{1}{N} \sum_{n=1}^N 0.5 \epsilon_{n} g_{k}(\mathbf{x}_{n}, \Theta) \right\} \end{aligned} \end{equation*} We define $\mathcal{G}_{k}^1 := \{ g_{k}(\mathbf{x}, \Theta) \;\; | \;\; \| \mathbf{w}_{k} \| \leq \mathbf{W}_{k}^{\max} \}$ and $\mathcal{G}_{k}^2 := \{ \sigma(y\tilde{\mathbf{w}}_{k}^T\tilde{\mathbf{x}}) \;\; | \;\; \| \mathbf{w}_{k} \| \leq \mathbf{W}_{k}^{\max} \}$. We further define $\tilde{\mathcal{G}}_{k}^{2} = \{ (\sigma(y\tilde{\mathbf{w}}_{k}^T\tilde{\mathbf{x}}) - 0.5) \;\; | \;\; \| \mathbf{w}_{k} \| \leq \mathbf{W}_{k}^{\max} \}$. We can easily check that $\tilde{\mathcal{G}}_{k}^{2}$ is closed under negation. Define the class $\mathcal{G}_{k}^{3} := \{ g : g(x_{1}, x_{2}) = g_{1}(x_{1}) g_{2}(x_{2}), g_{1} \in \mathcal{G}_{k}^{1}, g_{2} \in \tilde{\mathcal{G}}_{k}^{2} \}$. Thus, \begin{equation*} \hat{R}_{N}(\mathcal{F}_{k}) \leq \hat{R}_{N}(\mathcal{G}_{k}^{3}) + 0.5\hat{R}_{N}( \mathcal{G}_{k}^{1} ) \end{equation*} Using Lemma~2 from \cite{mixture-of-experts} we observe that \begin{align*} \hat{R}_{N}(\mathcal{G}_{k}^{3}) \leq \mathcal{M}_{1}\hat{R}_{N}(\mathcal{G}_{k}^{1}) + \mathcal{M}_{2}\hat{R}_{N}( \tilde{\mathcal{G}}_{k}^{2} ) \end{align*} where $\mathcal{M}_{1} = \sup_{g_{1} \in \mathcal{G}_{k}^{1}} | g_{1}(\mathbf{x}) |=1$ and $\mathcal{M}_{2} = \sup_{g_{2} \in \mathcal{G}_{k}^{2}} | g_{2}(\mathbf{x}) |=0.5$. Thus, \begin{equation*} \begin{aligned} \hat{R}_{N}(\mathcal{F}_{k}) &\leq \hat{R}_{N}(\mathcal{G}_{k}^{1}) + 0.5 \hat{R}_{N}( \tilde{\mathcal{G}}_{k}^{2} ) + 0.5\hat{R}_{N}( \mathcal{G}_{k}^{1} ) \\ & = 1.5 \hat{R}_{N}(\mathcal{G}_{k}^{1}) + 0.5 \hat{R}_{N}( \tilde{\mathcal{G}}_{k}^{2} ) \\ \end{aligned} \end{equation*} As $\hat{R}_{N}(\tilde{\mathcal{G}}_{k}^{2})$ is the same as $\hat{R}_{N}(\mathcal{G}_{k}^{2})$, we can rewrite above equation as follows. \begin{equation} \label{eq:Rhf-Rhs-Rhg} \hat{R}_{N}(\mathcal{F}_{k}) \leq 1.5 \hat{R}_{N}(\mathcal{G}_{k}^{1}) + 0.5 \hat{R}_{N}( \mathcal{G}_{k}^{2} ) \end{equation} To bound $\hat{R}_{N}(\mathcal{F}_{k})$, we will first bound $\hat{R}_{N}(\mathcal{G}_{k}^{1})$ using vector contraction inequality from \cite{maurer2016vector}. One can verify that Lipschitz constant of $g_{k}(\mathbf{x}, \Theta)$ with respect to $[\tilde{\mathbf{w}}_{k}^{T} \tilde{\mathbf{x}}]_{k=1}^{k=K}$ vector is $\frac{ \sqrt{K-1}}{K}$. Using vector contraction inequality from \cite{maurer2016vector}, we can write $\hat{R}_{N}(\mathcal{G}_{k}^{1})$ as \begin{equation*} \begin{aligned} &\hat{R}_{N}(\mathcal{G}_{k}^{1}) \leq \sqrt{2} \Big( \frac{\sqrt{K-1}}{K} \Big) \mathbb{E}_{\epsilon} \left\{ \sup_{\Theta} \frac{1}{N} \sum_{n=1}^N \sum_{k=1}^K \epsilon_{nk} (\mathbf{w}_{k}^T \mathbf{x}_n +b_k) \right\} \\ & \leq \frac{\sqrt{2(K-1)}}{K} \mathbb{E}_{\epsilon} \left\{ \sum_{k=1}^K \Big\{ \sup_{\mathbf{w}_k,b_k} \; \frac{1}{N} \sum_{n=1}^N \epsilon_{nk} (\mathbf{w}_{k}^T\mathbf{x}_n +b_k) \Big\} \right\} \\ & = \frac{\sqrt{2(K-1)}}{K} \mathbb{E}_{\epsilon} \left\{ \sum_{k=1}^K \Big\{ \sup_{\mathbf{w}_k} \; \frac{1}{N} \mathbf{w}_{k}^T \sum_{n=1}^N \epsilon_{nk} \mathbf{x}_n \Big\} \right\} \\ \end{aligned} \end{equation*} where $\epsilon_{nk}$ is an independent Rademacher sequence. Using the Cauchy-Schwartz and Jensen inequalities, \begin{align} \label{eq:Rgk-bound} \nonumber \hat{R}_{N}( \mathcal{G}_{k}^{1} ) &\leq \frac{\sqrt{2(K-1)}}{K} \sum_{k=1}^K \mathbb{E}_{\epsilon} \left\{ \frac{1}{N} \mathbf{W}_{k}^{\max} \left\| \sum_{n=1}^N \epsilon_{nk} \mathbf{x}_{n} \right\| \right\} \\ & \leq \frac{ \sqrt{2(K-1)} }{K} \sum_{k=1}^K \frac{\mathbf{W}_{k}^{\max} {\mathbf{R}}}{\sqrt{N}} \end{align} Now, we will bound second term $\hat{R}_{N}(\mathcal{G}_{k}^{2})$ of eq.(\ref{eq:Rhf-Rhs-Rhg}). \begin{equation*} \begin{aligned} \hat{R}_{N}( \mathcal{G}_{k}^{2} ) &= \mathbb{E}_{\epsilon} \left\{ \sup_{\mathbf{w}_k} \frac{1}{N} \sum_{n=1}^N \epsilon_{n} \sigma (y_{n} \tilde{\mathbf{w}}_{k}^T \tilde{\mathbf{x}}_{n}) \right\} \end{aligned} \end{equation*} The Lipschitz constant of sigmoid function is 1. Using Theorem 12 of \cite{Bartlett:2003:RGC:944919.944944}, we can write above equation as \begin{equation*} \begin{aligned} \hat{R}_{N}(\mathcal{G}_{k}^{2}) &\leq \mathbb{E}_{\epsilon} \left\{ \sup_{\mathbf{w}_k,b_k} \frac{1}{N} \sum_{n=1}^N \epsilon_{n} y_{n} (\mathbf{w}_{k}^T \mathbf{x}_{n}+b_k) \right\} \\ &= \mathbb{E}_{\epsilon} \left\{ \sup_{\mathbf{w}_k} \frac{1}{N} \sum_{n=1}^N \epsilon_{n} y_{n} \mathbf{w}_{k}^T \mathbf{x}_{n} \right\} \\ \end{aligned} \end{equation*} As $y_{n} \in \{+1, -1\}$, we can redefine $\epsilon_{n} = \epsilon_{n}y_{n}, \; \forall n$. Using new definition of $\epsilon_{n}$, we can rewrite above equation as \begin{equation*} \begin{aligned} \hat{R}_{N}(\mathcal{G}_{k}^{2}) &\leq \mathbb{E}_{\epsilon} \left\{ \sup_{\mathbf{w}_k} \frac{1}{N} \sum_{n=1}^N \epsilon_{n} \mathbf{w}_{k}^T \mathbf{x}_{n} \right\} \\ &= \mathbb{E}_{\epsilon} \left\{ \sup_{\mathbf{w}_k} \frac{1}{N} \mathbf{w}_{k}^T \sum_{n=1}^N \epsilon_{n} \mathbf{x}_{n} \right\} \\ \end{aligned} \end{equation*} Using the Cauchy-Schwartz and Jensen inequalities, \begin{align} \label{eq:Rsk-bound} \hat{R}_{N}(\mathcal{G}_{k}^{2}) \leq \frac{1}{N} \mathbb{E}_{\epsilon} \left\{ \mathbf{W}_{k}^{\max} \left\| \sum_{n=1}^N \epsilon_{n} \mathbf{x}_{n} \right\| \right\} \leq \frac{\mathbf{W}_{k}^{\max} {\mathbf{R}}}{\sqrt{N}} \end{align} Putting values of $\hat{R}_{N}(\mathcal{G}_{k}^{1})$ and $\hat{R}_{N}(\mathcal{G}_{k}^{2})$ from eq.(\ref{eq:Rgk-bound}) and (\ref{eq:Rsk-bound}) in eq.(\ref{eq:Rhf-Rhs-Rhg}), we will get desired result for Lemma \ref{lemma:fk-bound}. \begin{equation*} \begin{aligned} \hat{R}_{N}(\mathcal{F}_{k}) \leq \frac{ 3\sqrt{(K-1)} }{K \sqrt{2}} \sum_{k=1}^K \frac{\mathbf{W}_{k}^{\max} {\mathbf{R}}}{\sqrt{N}} + \frac{\mathbf{W}_{k}^{\max} {\mathbf{R}}}{\sqrt{N}} \end{aligned} \end{equation*} \end{proof} Now, we will present main theorem containing data dependent generalization error bounds for our approach. \begin{theorem} \label{thm-data-dependent-bound} Suppose assumption \ref{assumption} holds. Then, for any function $f$, there holds \begin{equation*} \begin{aligned} \mathcal{R}(f) \leq \hat{\mathcal{R}}_{\phi}(f, S) + c_{1} \sum_{k=1}^K \frac{ \mathbf{W}_{k}^{\max} \mathbf{R} }{ \sqrt{N} } + c_{2} \sqrt{ \frac{ \text{ln} \frac{2}{\delta}}{ 2N } } \end{aligned} \end{equation*} with probability at least $1-\delta$ where $c_{1} = (1+e^{ \mathbf{W}^{\max} \mathbf{R}}) e^{ \gamma (\mathbf{W}^{\max} + \mathbf{W}^{\min}) \mathbf{R} } \left( \frac{3 \sqrt{K-1}}{\sqrt{2}} + 1 \right)$ and $c_{2} = 3(1+e^{ \mathbf{W}^{\max} \mathbf{R}}) e^{ \gamma (\mathbf{W}^{\max} + \mathbf{W}^{\min}) \mathbf{R} }$. \end{theorem} \begin{proof} Using results of Lemma \ref{lemma:rh-rhk-bound} and Lemma \ref{lemma:fk-bound}, we can bound $\hat{R}_{N}( \mathcal{F} )$ as follows. \begin{equation*} \begin{aligned} \hat{R}_{N}( \mathcal{F} ) &\leq \sum_{k=1}^K \hat{R}_{N}( \mathcal{F}_{k} ) \\ &\leq \frac{ 3\sqrt{(K-1)} }{\sqrt{2}} \sum_{k=1}^K \frac{\mathbf{W}_{k}^{\max} {\mathbf{R}}}{\sqrt{N}} + \sum_{k=1}^K \frac{\mathbf{W}_{k}^{\max} {\mathbf{R}}}{\sqrt{N}} \\ &\leq \left( \frac{ 3\sqrt{(K-1)} }{\sqrt{2}} + 1 \right) \sum_{k=1}^K \frac{\mathbf{W}_{k}^{\max} {\mathbf{R}}}{\sqrt{N}} \end{aligned} \end{equation*} If assumption \ref{assumption} holds then the Lipschitz constant of cross-entropy loss is bounded by $ (1+e^{ \mathbf{W}^{\max} \mathbf{R}}) e^{ \gamma (\mathbf{W}^{\max} + \mathbf{W}^{\min}) \mathbf{R} }$. When assumption \ref{assumption} holds, the maximum value of cross-entropy loss will be bounded by $(1+e^{ \mathbf{W}^{\max} \mathbf{R}}) e^{ \gamma (\mathbf{W}^{\max} + \mathbf{W}^{\min}) \mathbf{R} }$. Putting $\hat{R}_{N}(\mathcal{F})$ bound in eq.(\ref{eq:risk-bound}), we will get the following generalization error bound for our approach. \begin{equation*} \begin{aligned} \mathcal{R}(f) \leq \hat{\mathcal{R}}_{\phi}(f, S) + c_{1} \sum_{k=1}^K \frac{ \mathbf{W}_{k}^{\max} \mathbf{R} }{ \sqrt{N} } + c_{2} \sqrt{ \frac{ \text{ln} \frac{2}{\delta}}{ 2N } } \end{aligned} \end{equation*} where $c_{1} = (1+e^{ \mathbf{W}^{\max} \mathbf{R}}) e^{ \gamma (\mathbf{W}^{\max} + \mathbf{W}^{\min}) \mathbf{R} } \left( \frac{3 \sqrt{K-1}}{\sqrt{2}} + 1 \right)$ and $c_{2} = 3(1+e^{ \mathbf{W}^{\max} \mathbf{R}}) e^{ \gamma (\mathbf{W}^{\max} + \mathbf{W}^{\min}) \mathbf{R} }$. \end{proof} Thus, the bound decreases as $O(N^{-1/2})$. \section{Experiments}\label{sec:Exp} To show the effectiveness of the proposed approach PLUME (given in Algorithm~\ref{algo:algo1}), we compare it with several state of the art approaches. We compare our approach with CART (classification and regression trees), which is a top-down oblique decision tree algorithm. We also compare with two fixed structure approaches: (a) SPLA1 (single polyhedral learning algorithm), the algorithm proposed in \citet{Naresh10} and (b) CPM (convex polytope machine) for learning polyhedral classifiers discussed in \cite{NIPS2014_5511}. We also present comparison with SVM which is a generic pattern recognition methods. We test the performance of our approach on several real world datasets downloaded from UCI ML repository \cite{Asuncion+Newman:2007}. We show results on "Ionosphere", "Heart", "ILPD", "Pima Indian" and "Adult" datasets. \iffalse The datasets that we use are described in Table~\ref{Table:Dataset}. \begin{table}[h] \label{Table:Dataset} \begin{center} \begin{tabular}{|p{.8in}|p{0.5in}|p{0.4in}|p{0.7in}|} \hline \hline Dataset & \# Points & \# Dim. & Class Ratio \\ \hline Ionosphere & 351 & 34 & 225 / 166 \\ \hline Heart & 270 & 13 & 120 / 150\\ \hline ILPD & 583 & 10 & 416 / 167\\ \hline Pima Indian & 768 & 8 & 268 / 500\\ \hline Adult & 3042 & 14 & 2298 / 744 \\ \hline \hline \end{tabular} \caption{Datasets Description} \end{center} \end{table} \fi We implemented our proposed approach PLUME (Algorithm~\ref{algo:algo1}) using gradient ascent, Newton method and BFGS in Python. We also implemented SPLA1 \citep{Naresh10} in Python. For CPM (convex polytope machine) we used the package made available by the authors \citep{Alkant2014}. For SVM and CART, we used Scikit-learn library \citep{scikit-learn} in Python. \begin{table*}[h!] \begin{center} \begin{tabular}{| c | c | c | c | c|} \hline Dataset & Method & Accuracy & Time(Sec.) & \#hyp. \\ \hline Ionosphere & SPLA1 (GA) & 90.78 $\pm$ 1.48 & 0.19 $\pm$ 0.008 & 3\\ & SPLA1 (Newton) & 88.36 $\pm$ 1.24 & 0.20 $\pm$ 0.03 & 2\\ & SPLA1 (BFGS) & 88.97 $\pm$ 1.51 & 0.09 $\pm$ 0.004 & 2\\ & PLUME (GA) & 89.86 $\pm$ 1.14 & 1.89 $\pm$ 1.06 & 3\\ & PLUME (Newton) & 88.92 $\pm$ 1.33 & 5.91 $\pm$ 2.32 & 3\\ & PLUME (BFGS) & 88.10 $\pm$ 1.65 & 0.027 $\pm$ 0.002 & 2\\ & CPM & 85.61 $\pm$ 1.79 & 29.35 $\pm$ 16.54 & 2\\ & CART & 88.39 $\pm$ 1.18 & 0.006 $\pm$ 0.0004 & \\ & SVM & 94.31 $\pm$ 0.88 & 0.006 & \\ \hline Heart & SPLA1 (GA) & 83.78 $\pm$ 1.50 & 0.14 $\pm$ 0.04 & 2\\ & SPLA1 (Newton) & 83.70 $\pm$ 1.72 & 0.04 $\pm$ 0.0004 & 2\\ & SPLA1 (BFGS) & 83.63 $\pm$ 1.30 & 0.09 $\pm$ 0.0008 & 2\\ & PLUME (GA) & 83.25 $\pm$ 2.19 & 0.72 $\pm$ 0.31 & 2\\ & PLUME (Newton) & {\bf 84.07} $\pm$ 2.32 & 1.09 $\pm$ 0.23 & 2\\ & PLUME (BFGS) & 83.05 $\pm$ 2.13 & 0.02 $\pm$ 0.001 & 2 \\ & CPM & 77.44 $\pm$ 4.29 & 23.28 $\pm$ 0.66 & 4 \\ & CART & 73.53 $\pm$ 2.89 & 0.001 $\pm$ 0.0001 &\\ & SVM & 78.93 $\pm$ 1.88 & 0.009 $\pm$ 0.0002 &\\ \hline ILPD & SPLA1 (GA) & 72.32 $\pm$ 1.38 & 0.97 $\pm$ 0.11 & 3\\ & SPLA1 (Newton) & 71.19 $\pm$ 1.61 & 0.23 $\pm$ 0.11 & 2\\ & SPLA1 (BFGS) & 71.12 $\pm$ 1.54 & 0.18 $\pm$ 0.002 & 2\\ & PLUME (GA) & {\bf 72.45} $\pm$ 1.51 & 0.57 $\pm$ 0.38 & 2 \\ & PLUME (Newton) & 70.93 $\pm$ 1.32 & 5.87 $\pm$ 0.10 & 2\\ & PLUME (BFGS) & 70.90 $\pm$ 2.21 & 0.0403 $\pm$ 0.001 & 2\\ & CPM & 67.71 $\pm$ 2.38 & 21.17 $\pm$ 18.27 & 2\\ & CART & 65.07 $\pm$ 1.73 & 0.003 $\pm$ 0.0001 &\\ & SVM & 69.59 $\pm$ 1.34 & 0.03 $\pm$ 0.0006 & \\ \hline Pima & SPLA1 (GA) & 76.77 $\pm$ 1.44 & 0.16 $\pm$ 0.12 & 3\\ Indian & SPLA1 (Newton) & 77.40 $\pm$ 1.04 & 0.17 $\pm$ 0.04 & 2\\ & SPLA1 (BFGS) & 76.77 $\pm$ 0.97 & 0.28 $\pm$ 0.01 & 2\\ & PLUME (GA) & {\bf 77.95} $\pm$ 1.29 & 3.09 $\pm$ 0.70 & 2\\ & PLUME (Newton) & 77.30 $\pm$ 1.17 & 0.39 $\pm$ 0.005 & 2 \\ & PLUME (BFGS) & 77.04 $\pm$ 1.91 & 0.053 $\pm$ 0.002 & 2 \\ & CPM & 69.44 $\pm$ 1.11 & 26.24 $\pm$ 0.55 & 8\\ & CART & 69.74 $\pm$ 1.66 & 0.004 $\pm$ 0.0001 &\\ & SVM & 75.80 $\pm$ 1.45 & 0.03 $\pm$ 0.0007 &\\ \hline Adult & SPLA1 (GA) & 77.13 $\pm$ 0.64 & 4.75 $\pm$ 1.17 & 2\\ & SPLA1 (Newton) & 82.89 $\pm$ 0.74 & 9.96 $\pm$ 1.13 & 2\\ & SPLA1 (BFGS) & 75.59 $\pm$ 0.61 & 0.52 $\pm$ 0.005 & 2\\ & PLUME (GA) & 76.92 $\pm$ 0.97 & 11.62 $\pm$ 1.82 & 2\\ & PLUME (Newton) & 80.53 $\pm$ 0.73 & 1.79 $\pm$ 0.02 & 2\\ & PLUME (BFGS) & 81.01 $\pm$ 0.75 & 0.402 $\pm$ 0.004 & 2\\ & CPM & 72.4 $\pm$ 6.47 & 29.03 $\pm$ 0.27 & 16\\ & CART & 80.84 $\pm$ 0.75 & 0.012 $\pm$ 0.0002 & \\ & SVM & 75.67 $\pm$ 0.66 & 0.75 $\pm$ 0.009 &\\ \hline \end{tabular} \caption{Comparison results of PLUME with other approach} \label{Table:results} \end{center} \end{table*} \iffalse \begin{figure*} \begin{center} \begin{tabular}{cc} \includegraphics[scale=0.37]{adult_accuracy.eps} &\includegraphics[scale=0.37]{adult_time.eps}\\ \includegraphics[scale=0.37]{heart_accuracy.eps} &\includegraphics[scale=0.37]{heart_time.eps}\\ \includegraphics[scale=0.37]{ilpd_accuracy.eps} &\includegraphics[scale=0.37]{ilpd_time.eps}\\ \includegraphics[scale=0.37]{ionosphere_accuracy.eps} &\includegraphics[scale=0.37]{ionosphere_time.eps}\\ \includegraphics[scale=0.37]{pima_accuracy.eps} &\includegraphics[scale=0.37]{pima_time.eps} \end{tabular} \caption{Comparison Results between PLUME and other approaches. Interpret as follows. a= SPLA1(GA), b=SPLA1(Newton), c=SPLA1(BFGS), d=PLUME(GA), e=PLUME(Newton), f=PLUME(BFGS), g=CPM, h=CART, i=SVM} \end{center} \end{figure*} \fi \subsection*{Simulation Results} We use following acronyms for different approaches. GA stands for gradient ascent, Newton stands for Newton method, BFGS is quasi-Newton approach. All the results were generated by repeating 10-fold cross validation tests 10 times. We report the average accuracy and standard deviation over 10 runs. Also, to find the best parameters for every algorithm, we used 10-fold cross validation. For example, number of hyperplanes in all the polyhedral learning approach, kernel parameters in SVM were found using cross validation. For SVM, we used Gaussian kernel for all the datasets. Comparison results are given in Table~\ref{Table:results}. We see that except for the Ionosphere dataset, our approach performs with a significantly better accuracy than SVM. As compared to CART, PLUME performs better accuracy wise on Heart, ILPD and Pima datasets. On Ionosphere and Adult datasets, PLUME accuracy is comparable to CART. Thus, PLUME performs better or comparable to the generic methods whenever the best classifier is close to the polyhedral classifier. With respect to CPM, PLUME always performs better in terms of accuracy with significant margins. Moreover, CPM always require more number of hyperplanes to achieve these accuracies compared to PLUME. Thus, PLUME always learn less complex classifiers compared to CPM. Compared to SPLA1, PLUME performs eqally good on all the datasets. Except for the Adult dataset, one of the PLUME variant (GA, Newton or BFGS) achieves better accuracy than all the SPLA1 variants. Thus, PLUME performs at par compared to other state of the art polyhedral learning approaches. Now we will now discuss the comparison results on training time. We can clearly see that CPM takes significantly more time compared PLUME for all the datasets. As compared to SPLA1, PLUME takes slightly more training time. This happens because PLUME does soft partitioning of the training set. Which means, every example participates in classifier learning corresponding to each expert (with different probabilities defined by $\pi(\mathbf{x},\Theta)$). As compared to SVM, PLUME takes more time to train, which is clearly understandable from the modeling. SVM solves convex while we do not and so we expect SVM to do well in terms of time. But PLUME learns the polyhedral set as an intersection of half spaces and this gives a much better geometric insight in the original feature space. \section{Conclusions}\label{conclusions} We have proposed a novel approach PLUME for learning polyhedral classifiers using mixture of experts. We have proposed an EM based learning algorithm to find the parameters of the classifier. We have also derived the data dependent generalized error bound for the proposed model. We have also shown experimentally that the proposed approach performs comparable to the state of the art polyhedral learning approaches as well as generic approaches (SVM, CART etc.) on various datasets.
{'timestamp': '2019-04-23T02:28:25', 'yymm': '1904', 'arxiv_id': '1904.09948', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.09948'}
arxiv
\section{Introduction} \label{sec:intro} \begin{figure}[t!] \centering \begin{subfigure}[b]{1.0\linewidth} \centering \includegraphics[width=0.3\linewidth]{teaser_image_aeroplane_gt_cr} \hfill \includegraphics[width=0.26\linewidth]{teaser_image_chair_gt_cr} \hfill \includegraphics[width=0.3\linewidth]{teaser_image_bunny_gt_cr} \caption{Input Mesh} \label{fig:teaser_input} \end{subfigure}\vspace{0.1cm} \vspace{-0.7em} \begin{subfigure}[b]{1.0\linewidth} \centering \includegraphics[width=0.3\linewidth]{teaser_image_aeroplane_c_cr} \hfill \includegraphics[width=0.3\linewidth]{teaser_image_chair_c_cr} \hfill \includegraphics[width=0.3\linewidth]{teaser_image_bunny_c_cr} \caption{Inferred Cuboid Representation \cite{Tulsiani2017CVPRa}} \label{fig:teaser_cuboid} \end{subfigure}\vspace{0.1cm} \begin{subfigure}[b]{1.0\linewidth} \vspace{0.4em} \centering \includegraphics[width=0.3\linewidth]{teaser_image_aeroplane_sq_cr} \hfill \includegraphics[width=0.28\linewidth]{teaser_image_chair_sq_cr} \hfill \includegraphics[width=0.3\linewidth]{teaser_image_bunny_sq_cr} \caption{Inferred Superquadric Representation (Ours)} \label{fig:teaser_ours} \end{subfigure} \caption{\textbf{3D Shape Parsing.} We consider the problem of learning to parse unstructured 3D data (e.g\onedot} \def\Eg{E.g\onedot, meshes or point clouds) into compact part-based representations. % % Prior work \cite{Tulsiani2017CVPRa, Zou2017ICCV, Niu2018CVPR} has considered cuboid representations (\subref{fig:teaser_cuboid}) which capture the overall object structure, but lack expressiveness. In this work, we propose an unsupervised model for superquadrics (\subref{fig:teaser_ours}), which allows us to capture details such as the body of the airplane and the ears of the rabbit. % } \label{fig:teaser} \vspace{-1.2em} \end{figure} Evolution has developed a remarkable visual system that allows humans to robustly perceive their 3D environment. It has long been hypothesized \cite{Biederman1986Human} that the human visual system processes the vast amount of raw visual input into compact parsimonious representations, where complex objects are decomposed into a small number of shape primitives that can each be represented using low-dimensional descriptions. Indeed, experiments show that humans can understand complex scenes from renderings of simple shape primitives such as cuboids or geons~\cite{Biederman1987PsychologicalReview}. Likewise, machines would tremendously benefit from being able to parse 3D data into compact low-dimensional representations. Such representations would provide useful cues for recognition, detection, shape manipulation and physical reasoning such as path planning and grasping. In the early days of computer vision, researchers explored shape primitives such as 3D polyhedral shapes \cite{Roberts1963PhD}, generalized cylinders \cite{Binford1971Visual}, geons \cite{Biederman1986Human} and superquadrics~\cite{Pentland1986AAAI}. However, it proved very difficult to extract such representations from images due to the lack of computation power and data at the time. Thus, the research community shifted their focus away from the shape primitive paradigm. In the last decade, major breakthroughs in shape extraction were due to deep neural networks coupled with the abundance of visual data. Recent works focus on learning 3D reconstruction using 2.5D \cite{Hartmann2017ICCV, Paschalidou2018CVPR, Pohan2018CVPR, Yao2018ECCV}, volumetric \cite{Choy2016ECCV, Girdhar2016ECCV, Wu2016NIPS, Ji2017ICCV, Haene2017ARXIV, Riegler2017CVPR}, mesh \cite{Groueix2018CVPR, Liao2018CVPR} and point cloud \cite{Fan2017CVPR, Qi2017NIPS} representations. However, none of the above are sufficiently parsimonious or interpretable to allow for higher-level 3D scene understanding as required by intelligent systems. Very recently, shape primitives have been revisited in the context of deep learning. % In particular, \cite{Tulsiani2017CVPRa, Zou2017ICCV, Niu2018CVPR} have demonstrated that deep neural networks enable to reliably extract 3D cuboids from meshes and even RGB images. Inspired by these works, we propose a novel deep neural network to efficiently extract parsimonious 3D representations in an unsupervised fashion, conditioned on a 3D shape or 2D image as input. In particular, this paper makes the following \textbf{contributions}: First, we note that 3D cuboid representations used in prior works~\cite{Tulsiani2017CVPRa, Zou2017ICCV, Niu2018CVPR} are not sufficiently expressive to model many natural and man-made shapes as illustrated in \figref{fig:teaser}. Thus, cuboid-based representation may require a large number of primitives to accurately represent common shapes. Instead, in this paper, we propose to utilize superquadrics, which have been successfully used in computer graphics~\cite{Barr1981CGA} and classical computer vision~\cite{Pentland1986AAAI, Solina1990PAMI, Terzopoulos1990ICCV}. Superquadrics are able to represent a diverse class of shapes such as cylinders, spheres, cuboids, ellipsoids \emph{in a single continuous parameter space} (see \figref{fig:teaser}+\ref{fig:superquadrics}). Moreover, their continuous parametrization is particularly amenable to deep learning, as their shape is smooth and varies continuously with their parameters. This allows for faster optimization, and hence faster and more stable training as evidenced by our experiments. Second, we provide an analytical closed-form solution to the Chamfer distance function which can be evaluated in linear time wrt\onedot the number of primitives. This allows us to compute gradients wrt\onedot the model parameters using standard error backpropagation \cite{Rumelhart1986NATURE} without resorting to computational expensive reinforcement learning techniques as required by prior work~\cite{Tulsiani2017CVPRa}. We consequently mitigate the need for designing an auxiliary reward function. Instead, we formulate a simple parsimony loss to favor configurations with a small number of primitives. We demonstrate the strengths of our model by learning to parse 3D shapes from the ShapeNet \cite{Chang2015ARXIV} and the SURREAL \cite{Varol2017CVPR}. We observe that our model converges faster than \cite{Tulsiani2017CVPRa} and leads to more accurate reconstructions. Our code is publicly available\footnote{\url{https://github.com/paschalidoud/superquadric_parsing}}. \section{Related Work} \label{sec:related} In this section, we discuss the most relevant work on deep learning-based 3D shape modeling approaches and review the origins of superquadric representations. \subsection{3D Reconstruction} The simplest representation for 3D reconstruction from one or more images are 2.5D depth maps as they can be inferred using standard 2D convolutional neural networks ~\cite{Hartmann2017ICCV, Paschalidou2018CVPR, Ji2017ICCV, Yao2018ECCV}. Since depth maps are view-based, these methods require additional post-processing algorithms to fuse information from multiple viewpoints in order to capture the entire object geometry. As opposed to depth maps, volumetric representations~\cite{Girdhar2016ECCV, Haene2017ARXIV, Choy2016ECCV, Riegler2017CVPR, Tatarchenko2017ICCV} naturally capture the entire 3D shape. While, hierarchical 3D data structures such as octrees accelerate 3D convolutions, the high memory requirements remain a limitation of existing volumetric methods. An alternative line of work \cite{Fan2017CVPR, Qi2007CVPR} focuses on learning to reconstruct 3D point sets. A natural limitation of these approaches is the lack of surface connectivity in the representation. To address this limitation, \cite{Liao2018CVPR, Groueix2018CVPR, Wang2018ECCV,Rezende2016NIPS} proposed to directly learn 3D meshes. While some of the aforementioned models are able to capture fine surface details, none of them lends itself to parsimonious, semantic interpretations. In this work, we utilize superquadrics which provide a concise and yet accurate representation with significantly less parameters. \subsection{Constructive Solid Geometry} Towards the goal of concise representations, researchers exploited constructive solid geometry (CSG) \cite{Laidlaw1986SIGGRAPH} for shape modeling~\cite{Sharma2018CVPR, Ellis2018NIPS}. Sharma et~al\onedot \cite{Sharma2018CVPR} leverage an encoder-decoder architecture to generate a sequence of simple boolean operations to act on a set of primitives that can be either squares, circles or triangles. In a similar line of work, Ellis et~al\onedot \cite{Ellis2018NIPS} learn a programmatic representation of a hand-written drawing, by first extracting simple primitives, such as lines, circles and rectangles and a set of drawing commands that is used to synthesize a \LaTeX~program. In contrast to \cite{Sharma2018CVPR, Ellis2018NIPS}, our goal is not to obtain accurate 3D geometry by iteratively applying boolean operations on shapes. Instead, we aim to decompose the depicted object into a parsimonious interpretable representation where each part has a semantic meaning associated with it. Besides, we do not suffer from ambiguities of an iterative construction process, where different executions lead to the same result. \subsection{Learning-based Scene Parsing} Recently, shape primitives have been revisited in the context of deep learning \cite{Tulsiani2017CVPRa, Zou2017ICCV, Niu2018CVPR}. Niu et~al\onedot \cite{Niu2018CVPR} propose to use a recurrent neural network (RNN) to iteratively predict cuboid primitives as well as symmetry relationships from RGB images. They first train an encoder which encodes the input image and its segmentation into a 80-dimensional latent code. Starting from this root feature, they iteratively decode the structure into cuboids, splitting nodes based on adjacency and symmetry relationships. In related work, Zou et~al\onedot \cite{Zou2017ICCV} utilize LSTMs in combination with mixture density networks to generate cuboid representations from depth maps encoded by a 32-dimensional feature vector. However, both works \cite{Niu2018CVPR,Zou2017ICCV} require supervision in terms of the primitive parameters as well as the sequence of predictions. This supervision must either be provided by manual annotation or using greedy heuristics as in \cite{Niu2018CVPR,Zou2017ICCV}. In contrast, our approach is unsupervised and does not suffer from ambiguities caused by different possible prediction sequences that lead to the same cuboid assembly. Furthermore, \cite{Niu2018CVPR,Zou2017ICCV} exploit simple cuboid representations which do not capture more complex shapes that are common in natural and man-made scenes (e.g\onedot} \def\Eg{E.g\onedot, curved objects, spheres). In this work, we propose to use superquadrics~\cite{Barr1981CGA} which yield a more diverse shape vocabulary and hence lead to more expressive scene abstractions as illustrated in \figref{fig:teaser}. A primary inspiration for this paper is the seminal work by Tulsiani et~al\onedot \cite{Tulsiani2017CVPRa}, who proposed a method for 3D shape abstraction using a non-iterative approach which does not require supervision. Instead, they use a convolutional network architecture for predicting the shape and pose parameters of 3D cuboids as well as their probability of existence. They demonstrate that learning shape abstraction from data allows for obtaining consistent parses across different instances in an unsupervised fashion. In this paper, we extend the model of Tulsiani et~al\onedot \cite{Tulsiani2017CVPRa} in the following directions. First, we utilize superquadrics, instead of cuboids, which leads to more accurate scene abstractions. Second, we demonstrate that the bi-directional Chamfer distance is tractable and doesn't require reinforcement learning \cite{Williams1992ML} or specification of rewards \cite{Tulsiani2017CVPRa}. In particular, we show that there exists an analytical closed-form solution which can be evaluated in linear time. % This allows us to compute gradients wrt\onedot the model parameters using standard error propagation \cite{Rumelhart1986NATURE} which facilitates learning. In addition, we add a new simple parsimony loss to favor configurations with a small number of primitives. \subsection{Superquadrics} \begin{figure} \centering \includegraphics[width=1.0\linewidth]{sqs_2} \caption{\textbf{Superquadrics Shape Vocabulary.} Due to their ability to model various shapes with little parameters, superquadrics are a natural choice for geometric primitives.} \label{fig:superquadrics} \vspace{-1.2em} \end{figure} Superquadrics are a parametric family of surfaces that can be used to describe cubes, cylinders, spheres, octahedra, ellipsoids etc\onedot ~\cite{Barr1981CGA}. In contrast to geons~\cite{Biederman1986Human}, superquadric surfaces can be described using a fairly simple parameterization. In contrast to generalized cylinders~ \cite{Biederman1986Human}, superquadrics are able to represent a larger variety of shapes. See \figref{fig:superquadrics} for an illustration of the shape space. In 1986, Pentland introduced superquadrics to the computer vision community~ \cite{Pentland1986AAAI}. Solina et~al\onedot \cite{Solina1990PAMI} formulated the task of fitting superquadrics to a point cloud as a least-squares minimization problem. Chevalier et~al\onedot \cite{Chevalier2003WSCG} followed a two-stage approach, where the point cloud is first partitioned into regions and then each region is fit with a superquadric. As a thorough survey on superquadrics is beyond the scope of this paper, we refer to \cite{Jaklic2000, Solina1994JCIT} for details. In contrast to these classical works on superquadric fitting using non-linear least squares, we present the first approach to train a deep network to predict superquadrics directly from 2D or 3D inputs. This allows our network to distill statistical dependencies wrt\onedot the arrangement and geometry of the primitives from data, leading to semantically meaningful parts at inference time. Towards this goal, we utilize a convolutional network that predicts superquadric poses and attributes, and develop a novel loss function that allow us to train this network efficiently from data. Our model is able to directly learn superquadric surfaces from an unordered 3D point cloud without any supervision on the primitive parameters nor a 3D segmentation as input. \section{Method} \label{sec:method} We now describe our model. We start by introducing the model parameters, followed by the loss functions and the superquadric parametrization we employ. Given an input $\bI$ (e.g\onedot} \def\Eg{E.g\onedot, image, volume, point cloud) and an oriented point cloud $\bX$ of the target object, our goal is to estimate the parameters $\theta$ of a neural network $\phi_{\theta}(\bI)$ that predicts a set of $M$ primitives that best describe the target object. Every primitive is fully described by a set of parameters $\lambda_m$ that define its shape, size and its position and orientation in the 3D space. For details about the parameterization of the superquadric representation, we refer the reader to \secref{subsec:sq_parametrization}. Since not all objects and scenes require the same number of primitives, we enable our model to predict a variable number of primitives, hence allowing it to decide whether a primitive should be part of the assembled object or not. To achieve this, we follow \cite{Tulsiani2017CVPRa} and associate every primitive with a binary random variable $z_m \in \{0, 1\}$ which follows a Bernoulli distribution $p(z_m)=\gamma_m^{z_m}(1-\gamma_m)^{1-z_m}$ with parameter $\gamma_m$. The random variable $z_m$ indicates whether the $m^{th}$ primitive is part of the scene $(z_m = 1)$ or not $(z_m = 0)$. We refer to these variables as \emph{existence variables} and denote the set of all existence variables as $\mathbf{z}}\newcommand{\bZ}{\mathbf{Z} = \{z_1, \dots, z_M\}$. Our goal is to learn a neural network \begin{equation} \phi_{\theta}: \bI \mapsto \bP \end{equation} which maps an input $\bI$ to a primitive representation $\bP$ where $\bP=\{(\lambda_m,\gamma_m)\}_{m=1}^M$ comprises the primitive parameters $\lambda_m$ and the existence probability $\gamma_m$ for $M$ primitives. Note that $M$ is only an upper bound on the number of predicted primitives. The final primitive representation is obtained by sampling the existence of each primitive, $z_m \sim \text{Bernoulli}(\gamma_m)$. One of the key challenges when training such models is related to the lack of direct supervision in the form of primitive annotations. However, despite the absence of supervision, one can still measure the discrepancy between the predicted object and the target object. Towards this goal, we formulate a bi-directional reconstruction objective $\mathcal{L}_{D}(\bP , \bX)$ and incorporate a Minimum Description Length (MDL) prior $\mathcal{L}_{\gamma}(\bP)$, which favors parsimony, i.e\onedot} \def\Ie{I.e\onedot a small number of primitives. Our overall loss function is given as: \begin{equation} \mathcal{L}(\bP , \bX) = \mathcal{L}_{D}(\bP , \bX) + \mathcal{L}_{\gamma}(\bP) \end{equation} We now describe both losses functions in detail. \subsection{Reconstruction Loss} \label{sec:reconstruction_loss} The reconstruction loss measures the discrepancy between the predicted shape and the target shape. While we experimented with the truncated bi-directional loss of Tulsiani et~al\onedot \cite{Tulsiani2017CVPRa}, we empirically found that the standard Chamfer distance \cite{Fan2017CVPR} works better in practice and results in less local minima. An empirical analysis on this is provided in our supplementary material. Thus, we use the Chamfer distance in our experiments \begin{equation} \mathcal{L}_{D}(\bP , \bX) = \mathcal{L}_{P\rightarrow X}(\bP, \bX) + \mathcal{L}_{X\rightarrow P}(\bX, \bP) \label{eq:loss_distance} \end{equation} where $\mathcal{L}_{P\rightarrow X}$ measures the distance from the predicted primitives $\bP$ to the point cloud $\bX$ and $\mathcal{L}_{X\rightarrow P}$ measures the distance from the point cloud $\bX$ to the primitives $\bP$. We weight the two distance measures in \eqref{eq:loss_distance} with $1.2$ and $0.8$, respectively, which empirically led to good results. \boldparagraph{Primitive-to-Pointcloud} We represent the target point cloud as a set of 3D points $\bX = \{\mathbf{x}}\newcommand{\bX}{\mathbf{X}_i \}_{i=1}^N$. Similarly, we approximate the continuous surface of primitive $m$ by a set of points $\bY_m = \{\mathbf{y}}\newcommand{\bY}{\mathbf{Y}_k^m \}_{k=1}^K$. Details of our sampling strategy are provided in~\secref{subsec:implementation}. This discretization allows us to express the distance between a superquadric and the target point cloud in a convenient form. In particular, for each point on the primitive $\mathbf{y}}\newcommand{\bY}{\mathbf{Y}_k^m$, we compute its closest point on the target point cloud $\mathbf{x}}\newcommand{\bX}{\mathbf{X}_i$, and average this distance across all points in $\bY_m$ as follows: \begin{equation} \mathcal{L}^m_{P\rightarrow X}(\bP, \bX) = \frac{1}{K} \sum_{k=1}^K ~\Delta^m_k \label{eq:loss_1_m} \end{equation} where \begin{equation} \Delta^m_k = \min_{i=1,..,N} \, {\Vert\mathcal{T}_m(\mathbf{x}}\newcommand{\bX}{\mathbf{X}_i) - \mathbf{y}}\newcommand{\bY}{\mathbf{Y}_k^m \Vert}_2 \label{eq:delta_k} \end{equation} denotes the minimal distance from the $k$'th point $\mathbf{y}}\newcommand{\bY}{\mathbf{Y}_k^m$ on the $m$'th primitive to the target point cloud $\bX$. Here, $\mathcal{T}_m(\mathbf{x}}\newcommand{\bX}{\mathbf{X})=\bR(\lambda_m)\,\mathbf{x}}\newcommand{\bX}{\mathbf{X} + \mathbf{t}}\newcommand{\bT}{\mathbf{T}(\lambda_m)$ is a function that transforms a 3D point $\mathbf{x}}\newcommand{\bX}{\mathbf{X}_i$ in world coordinates into the local coordinate system of the $m^{th}$ primitive. Note that both $\mathbf{R}$ and $\mathbf{t}$ depend on $\lambda_m$ and are hence estimated by our network. By taking the expectation wrt\onedot the existence variables $\mathbf{z}}\newcommand{\bZ}{\mathbf{Z}$ and assuming independence of the existence variables: $p(\mathbf{z}}\newcommand{\bZ}{\mathbf{Z}) = \prod_m p(z_m)$, we obtain the joint loss over all primitives as \begin{equation} \begin{aligned} \mathcal{L}_{P\rightarrow X}(\bP, \bX) &= \mathbb{E}_{p(\mathbf{z}}\newcommand{\bZ}{\mathbf{Z})} \left[ \sum_{m=1}^M \mathcal{L}^m_{P\rightarrow X}(\bP, \bX) \right] \\ &= \sum_{m=1}^M \gamma_m \, \mathcal{L}^m_{P\rightarrow X}(\bP, \bX) \end{aligned} \label{eq:loss_1} \end{equation} Note that this loss encourages the predicted primitives to stay close to the target point cloud. \boldparagraph{Pointcloud-to-Primitive} While $\mathcal{L}_{P\rightarrow X}$ measures the distance from the primitives to the point cloud, $\mathcal{L}_{X\rightarrow P}$ measures the distance from the point cloud to the primitives to ensure that each observation is explained by at least one primitive. We start by defining $\Delta^m_i$ as the minimal distance from point $\mathbf{x}}\newcommand{\bX}{\mathbf{X}_i$ to the surface of the $m$'th primitive: \begin{equation} \Delta^m_i = \min_{k=1,..,K} {\Vert \mathcal{T}_m(\mathbf{x}}\newcommand{\bX}{\mathbf{X}_i) - \mathbf{y}}\newcommand{\bY}{\mathbf{Y}_k^m \Vert}_2 \label{eq:delta_i} \end{equation} Note that in contrast to \eqref{eq:delta_k}, we minimize over the $K$ points from the estimated primitive. Similarly to \eqref{eq:loss_1}, we take the expectation of $\Delta^m_i$ over $p(\mathbf{z}}\newcommand{\bZ}{\mathbf{Z})$. In contrast to \eqref{eq:loss_1}, we sum over each point in the target point cloud $\bX$ and retrieve the distance to the closest primitive $m$ that exists ($z_m=1$): \begin{equation} \begin{aligned} &\mathcal{L}_{X\rightarrow P}(\bX,\bP) = \mathbb{E}_{p(\mathbf{z}}\newcommand{\bZ}{\mathbf{Z})} \left[\sum_{\mathbf{x}}\newcommand{\bX}{\mathbf{X}_i \in \bX} ~\min_{\substack{m | z_m=1}} \, \Delta^m_i \right] \end{aligned} \label{eq:loss_2} \end{equation} Note that na\"ive computation of Eq.~\ref{eq:loss_2} becomes very slow for a large number of primitives $M$ as it requires evaluating the quantity inside the expectation $2^M$ times. In this work, we propose a novel approach to simplify this computation that results in a linear number of evaluations. Without loss of generality, let us assume that the $\Delta^m_i$'s are sorted in ascending order: \begin{equation} \begin{aligned} \Delta^1_i \leq \Delta^2_i \leq \dots \leq \Delta^M_i \end{aligned} \label{eq:ordering} \end{equation} Assuming this ordering, we can state the following: if the first primitive exists, the first primitive will be the one closest to point $\mathbf{x}}\newcommand{\bX}{\mathbf{X}_i$ of the target point, if the first primitive does not exist and the second does, then the second primitive is closest to point $\mathbf{x}}\newcommand{\bX}{\mathbf{X}_i$ and so on and so forth. More formally, this property can be stated as follows: \begin{equation} \begin{aligned} &\min_{\substack{m | z_m=1}} \Delta^m_i = &\begin{cases} \Delta^1_i , & \text{if}\ z_1=1 \\ \Delta^2_i, & \text{if}\ z_1=0, z_2=1 \\ \vdots \\ \Delta^M_i, & \text{if}\ z_m=0, \dots, z_M=1 \\ \end{cases} \end{aligned} \label{eq:minimum_distances} \end{equation} This allows us to simplify Eq.~\ref{eq:loss_2} as follows \begin{equation} \mathcal{L}_{X\rightarrow P}(\bX,\bP) = \sum_{\mathbf{x}}\newcommand{\bX}{\mathbf{X}_i \in \bX} \sum_{m=1}^M \Delta^m_i \, \gamma_m \prod_{\bar{m}=1}^{m-1}(1 - \gamma_{\bar{m}}) \label{eq:loss_2_simplified} \end{equation} where $\gamma_{\bar{m}}$ is a shorthand notation which denotes the existence probability of a primitive closer than primitive $m$. Note that this function requires only $M$, instead of $2^M$, evaluations of the function $\Delta^m_i$ which is one of the main results of this paper. For a detailed derivation of \eqref{eq:loss_2_simplified}, we refer the reader to the supplementary material. \subsection{Parsimony Loss} \label{sec:mdl_loss} Despite the bidirectional loss formulation above, our model suffers from the trivial solution $\mathcal{L}_{D}(\bP,\bX)=0$ which is attained for $\gamma_1=\cdots=\gamma_m=0$. Moreover, multiple primitives with identical parameters yield the same loss function as a single primitive by dispersing their existence probability. We thus introduce a regularizer loss on the existence probabilities $\gamma$ which alleviates both problems: \begin{equation} \mathcal{L}_{\gamma}(\bP) = \max\left(\alpha-\alpha\sum_{m=1}^M \gamma_m, 0\right) + \beta \sqrt{\sum_{m=1}^M \gamma_m} \label{eq:loss_gamma} \end{equation} The first term of \eqref{eq:loss_gamma} makes sure that the aggregate existence probability over all primitives is at least one (i.e\onedot} \def\Ie{I.e\onedot, we expect at least one primitive to be present) and the second term enforces a parsimonious scene parse by exploiting a loss function sub-linear in $\sum_m \gamma_m$ which encourages sparsity. $\alpha$ and $\beta$ are weighting factors which are set to $1.0$ and $10^{-3}$ respectively. \subsection{Superquadric Parametrization} \label{subsec:sq_parametrization} Having specified our network and the loss function, we now provide details about the superquadric representation and its parameterization $\lambda$. Note that, in this section, we omit the primitive index $m$ for clarity. Superquadrics define a family of parametric surfaces that can be fully described by a set of $11$ parameters~\cite{Barr1981CGA}. The explicit superquadric equation defines the surface vector $\mathbf{r}}\newcommand{\bR}{\mathbf{R}$ as \begin{equation} \mathbf{r}(\eta, \omega) = \begin{bmatrix} \alpha_{1}\cos^{\epsilon_{1}}\eta \cos^{\epsilon_{2}}\omega \\ \alpha_{2}\cos^{\epsilon_{1}}\eta \sin^{\epsilon_{2}}\omega \\ \alpha_{3}\sin^{\epsilon_{1}}\eta \end{bmatrix} \quad \begin{aligned} -\pi/2 &\leq \eta \leq \pi/2\\ -\pi &\leq \omega \leq \pi \end{aligned} \label{eq:parametric_eq} \end{equation} where $\mathbf{\alpha} = [\alpha_{1}, \alpha_{2}, \alpha_{3}]$ determine the size and $\mathbf{\epsilon} = [\epsilon_{1}, \epsilon_{2}]$ determine the global shape of the superquadric, see supplementary material for examples. Following common practice \cite{Vaskevicius2017PAMI}, we bound the values $\epsilon_{1}$ and $\epsilon_{2}$ to the range $[0.1, 1.9]$ so as to prevent non-convex shapes which are less likely to occur in practice. Eq.~\ref{eq:parametric_eq} produces a superquadric in a canonical pose. In order to allow any position and orientation, we augment the primitive parameter $\lambda$ with an additional rigid body motion represented by a translation vector $\mathbf{t} = [t_{x}, t_{y}, t_{z}]$ and a quaternion $\mathbf{q} = [q_{0}, q_{1}, q_{2}, q_{3}]$ which determine the coordinate system transformation $\mathcal{T}(\mathbf{x}}\newcommand{\bX}{\mathbf{X})=\bR(\lambda)\,\mathbf{x}}\newcommand{\bX}{\mathbf{X} + \mathbf{t}}\newcommand{\bT}{\mathbf{T}(\lambda)$ above. \begin{figure} \centering \includegraphics[width=\linewidth]{comparison_sq_with_cubes} \caption{{\bf{Reconstruction Loss wrt\onedot \#Primitives.}} We illustrate the reconstruction loss on the test set of the ShapeNet \textit{animal} category for a different number of primitives. Superquadrics ({\color{orange}{orange}}) consistently outperform cuboid primitives ({\color{blue}{blue}}) due to their diverse shape vocabulary that allows them to better capture fine details of the input shapes.} \label{fig:reconstruction_loss} \vspace{-1.2em} \end{figure} \subsection{Implementation} \label{subsec:implementation} Our network architecture comprises an encoder and a set of linear layers followed by non-linearities that independently predict the pose, shape and size of the superquadric surfaces. The encoder architecture is chosen based on the input type (e.g\onedot} \def\Eg{E.g\onedot image, voxelized input, etc\onedot). In our experiments, for a binary occupancy grid as input, our encoder consists of five blocks of 3D convolution layers, followed by batch normalization and Leaky ReLU non-linearities. The result is passed to five independent heads that regress translation $\bf{t}$, rotation $\bf{q}$, size $\bf{\alpha}$, shape $\bf{\epsilon}$ and probability of existence $\bf{\gamma}$ for each primitive. Additional details about our network architecture as well as results using an image-based encoder are provided in the supplementary material. For evaluating our loss \eqref{eq:loss_distance}, we sample points on the superquadric surface. To achieve a uniform point distribution, we sample $\eta$ and $\omega$ as proposed in \cite{Pilu1995BMVC}. During training, we uniformly sample $1000$ points, from the surface of the target object, as well as $200$ points from the surface of every superquadric. Note that sampling points on the surface of the objects results in a stochastic approximator of the expected loss. The variance of this approximator is inversely proportional to the number of sampled points. We experimentally observe that our model is not sensitive to the number of sampled points. For optimization, we use ADAM \cite{Kingma2015ICLR} with learning rate $0.001$ and a batch size of $32$ for $40$k iterations. To further increase parsimony, we then fix all parameters except $\bf{\gamma}$ for additional $5$k iterations. This step removes remaining overlapping primitives as also observed in \cite{Tulsiani2017CVPRa}. \section{Experimental Evaluation} \label{sec:results} \begin{figure} % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % \centering \includegraphics[width=\linewidth]{cubes_vs_sqs_primitives_evolution_improved_cubes_vs_sqs_evolution.pdf} \vspace{-0.2em} \caption{{\bf{Training Evolution.}} We visualize the qualitative evolution of superquadrics (top) and cuboids (bottom) during training. Superquadrics converge faster to more accurate representations, whereas cuboids cannot capture details such as the open mouth of the dog, even after convergence.} \label{fig:training_evolution} \vspace{-1.2em} \end{figure} In this section, we present a set of experiments to evaluate the performance of our network in terms of parsing an input 3D shape into a set of superquadric surfaces. \begin{figure}[t!] \centering % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % \includegraphics[width=\linewidth, height=1.1\linewidth]{humans_experiment_humans.pdf} \caption{\textbf{Qualitative Results on SURREAL.} Our network learns semantic mappings of body parts across different body shapes and articulations. For instance, the network uses the same primitive for the left forearm across instances.} \label{fig:surreal} \vspace{-1.2em} \end{figure} \begin{figure*}[t!] \centering \begin{subfigure}[b]{0.10\textwidth} \centering \includegraphics[width=0.7\textwidth]{shapenet_comparison_dog_66_cr.png} \end{subfigure} \hfill \begin{subfigure}[b]{0.10\textwidth} \centering \includegraphics[width=0.9\textwidth]{shapenet_comparison_reindeer_44_cr.png} \end{subfigure} \hfill \begin{subfigure}[b]{0.10\textwidth} \centering \includegraphics[width=\textwidth]{shapenet_comparison_cat_2_cr.png} \end{subfigure} \hfill \begin{subfigure}[b]{0.10\textwidth} \centering \includegraphics[width=0.55\textwidth]{shapenet_comparison_60167ae64899f8ae966a40fb39b34846_gt.png} \end{subfigure} \hfill \begin{subfigure}[b]{0.10\textwidth} \centering \includegraphics[width=\textwidth]{shapenet_comparison_chair_2a28_gt} \end{subfigure} \hfill \begin{subfigure}[b]{0.10\textwidth} \centering \includegraphics[width=0.55\textwidth]{shapenet_comparison_dac4af24e2facd7d3000ca4b04fcd6ac_gt.png} \end{subfigure} \hfill \begin{subfigure}[b]{0.10\textwidth} \centering \includegraphics[width=\textwidth]{shapenet_comparison_improved_ff28d_gt.png} \end{subfigure} \hfill \begin{subfigure}[b]{0.10\textwidth} \centering \includegraphics[width=\textwidth]{shapenet_comparison_improved_ff29f_gt_2.png} \end{subfigure} \hfill \begin{subfigure}[b]{0.10\textwidth} \centering \includegraphics[width=\textwidth]{shapenet_comparison_improved_7b134_gt_2.png} \end{subfigure} \vskip\baselineskip \vspace{-1.5em} \begin{subfigure}[b]{0.10\textwidth} \centering \includegraphics[width=\textwidth]{shapenet_comparison_dog_66_tulsiani.png} \end{subfigure} \hfill \begin{subfigure}[b]{0.10\textwidth} \centering \includegraphics[width=\textwidth]{shapenet_comparison_reindeer_44_tulsiani.png} \end{subfigure} \hfill \begin{subfigure}[b]{0.10\textwidth} \centering \includegraphics[width=\textwidth]{shapenet_comparison_cat_2_tulsiani.png} \end{subfigure} \hfill \begin{subfigure}[b]{0.10\textwidth} \centering \includegraphics[width=0.55\textwidth]{shapenet_comparison_60167ae64899f8ae966a40fb39b34846_pred.png} \end{subfigure} \hfill \begin{subfigure}[b]{0.10\textwidth} \centering \includegraphics[width=0.6\textwidth]{shapenet_comparison_chair_2a28_tulsiani.png} \end{subfigure} \hfill \begin{subfigure}[b]{0.10\textwidth} \centering \includegraphics[width=0.95\textwidth]{shapenet_comparison_dac4af24e2facd7d3000ca4b04fcd6ac_tulsiani.png} \end{subfigure} \hfill \begin{subfigure}[b]{0.10\textwidth} \centering \includegraphics[width=\textwidth]{shapenet_comparison_improved_ff28d_tulsiani.png} \end{subfigure} \hfill \begin{subfigure}[b]{0.10\textwidth} \centering \includegraphics[width=\textwidth]{shapenet_comparison_improved_ff29f_tulsiani.png} \end{subfigure} \hfill \begin{subfigure}[b]{0.099\textwidth} \centering \includegraphics[width=\textwidth]{shapenet_comparison_improved_7b134_tulsiani.png} \end{subfigure} \vskip\baselineskip \vspace{-1.5em} \begin{subfigure}[b]{0.099\textwidth} \centering \includegraphics[width=0.8\textwidth]{shapenet_comparison_dog_66_sq_cr.png} \end{subfigure} \hfill \begin{subfigure}[b]{0.10\textwidth} \centering \includegraphics[width=\textwidth]{shapenet_comparison_reindeer_44_sq_cr.png} \end{subfigure} \hfill \begin{subfigure}[b]{0.10\textwidth} \centering \includegraphics[width=\textwidth]{shapenet_comparison_cat_2_sq_cr.png} \end{subfigure} \hfill \begin{subfigure}[b]{0.10\textwidth} \centering \includegraphics[width=\textwidth]{shapenet_comparison_60167ae64899f8ae966a40fb39b34846_sq.png} \end{subfigure} \hfill \begin{subfigure}[b]{0.10\textwidth} \centering \includegraphics[width=\textwidth]{shapenet_comparison_2a87cf850dca72a4a886e56ff3d54c4_sq_3.png} \end{subfigure} \hfill \begin{subfigure}[b]{0.10\textwidth} \centering \includegraphics[width=\textwidth]{shapenet_comparison_chair_dac4af24e2facd7d3000ca4b04fcd6ac_sq.png} \end{subfigure} \hfill \begin{subfigure}[b]{0.10\textwidth} \centering \includegraphics[width=\textwidth]{shapenet_comparison_improved_ff28d_sq.png} \end{subfigure} \hfill \begin{subfigure}[b]{0.10\textwidth} \centering \includegraphics[width=\textwidth]{shapenet_comparison_improved_ff29f_sq.png} \end{subfigure} \hfill \begin{subfigure}[b]{0.10\textwidth} \centering \includegraphics[width=\textwidth]{shapenet_comparison_improved_7b134_sq_2.png} \end{subfigure} \caption{{\bf Qualitative Results on ShapeNet.} We visualize predictions for the object categories \textit{animals}, \textit{aeroplane} and \textit{chairs} from the ShapeNet dataset. The top row illustrates the ground-truth meshes from every object. The middle row depicts the corresponding predictions using the cuboidal primitives estimated by \cite{Tulsiani2017CVPRa}. The bottom row shows the corresponding predictions using our learned superquadric surfaces. Similarly to \cite{Tulsiani2017CVPRa}, we observe that the predicted primitive representations are consistent across instances. For example, the primitive depicted in green describes the right wing of the aeroplane, while for the animals class, the yellow primitive describes the front legs of the animal.} \label{fig:shapenet_results} \vspace{-1.0em} \end{figure*} \begin{figure}[t!] \centering \includegraphics[width=\linewidth]{attention_in_details_details_improved.pdf} \caption{\textbf{Attention to Details.} Superquadrics allow for modeling fine details such as the tails and ears of animals as well as the wings and the body of the airplanes and wheels of the motorbikes which are hard to capture using cuboids.} \label{fig:attention_in_details} \vspace{-1.2em} \end{figure}% \boldparagraph{Datasets} We provide results on two 3D datasets. First, we use the \textit{aeroplane}, \textit{chair} and \textit{animals} categories from ShapeNet~\cite{Chang2015ARXIV}. Following \cite{Tulsiani2017CVPRa}, we train one model per object category using a voxelized binary occupancy grid of size $32\times 32 \times 32$ as input. Second, we use the SURREAL dataset from Varol et~al\onedot \cite{Varol2017CVPR} which comprises humans in various poses (e.g\onedot} \def\Eg{E.g\onedot, standing, walking, sitting). Using the SMPL model~\cite{Loper2015SIGGRAPH}, we rendered $5000$ meshes, from which $4500$ are used for training and $500$ for testing. For additional qualitative results on both datasets, we refer the reader to our supplementary material. \boldparagraph{Baselines} Most related to ours is the cuboid parsing approach of Tulsiani et~al\onedot~\cite{Tulsiani2017CVPRa}. Other approaches to cuboid-based scene parsing \cite{Niu2018CVPR,Zou2017ICCV} require ground-truth shape annotations and thus cannot be fairly compared to unsupervised techniques. We thus compare to Tulsiani et~al\onedot~\cite{Tulsiani2017CVPRa}, using their publicly available code\footnote{\url{https://github.com/shubhtuls/volumetricPrimitives}}. \subsection{Superquadrics vs. Cuboids} \label{sec:sq_vs_cubes} We first compare the modeling accuracy of superquadric surfaces wrt\onedot cuboidal shapes which have been extensively used in related work~\cite{Tulsiani2017CVPRa, Zou2017ICCV, Niu2018CVPR}. Towards this goal, we fit \textit{animal} shapes from ShapeNet by optimizing the distance loss function in \eqref{eq:loss_distance} while varying the maximum number of allowed primitives $M$. To ensure a fair comparison, we use the proposed model for both cases. Note that this is trivially possible as cuboids are a special case of superquadrics. To minimize the effects of network initialization and local minima in the optimization, we repeat the experiment three times with random initializations and visualize the average loss in \figref{fig:reconstruction_loss}. The results show that for any given number of primitives, superquadrics consistently achieve a lower loss, and hence higher modeling fidelity. We further visualize the qualitative evolution of the network during training in \figref{fig:training_evolution}. This figure demonstrates that compared to cuboids, superquadrics better model the object shape, and more importantly that the network is able to converge faster. \subsection{Results on ShapeNet} \label{sec:eval_shapenet} We evaluate the quality of the predicted primitives using our reconstruction loss from \eqref{eq:loss_distance} on the ShapeNet dataset and compare to the cuboidal primitives as estimated by Tulsiani et~al\onedot \cite{Tulsiani2017CVPRa}. We associate every primitive with a unique color, thus primitives illustrated with the same color correspond to the same object part. For both approaches we set the maximal number of primitives to $M=20$. From \figref{fig:shapenet_results}, we observe that our predictions consistently capture both the structure as well as fine details (e.g\onedot} \def\Eg{E.g\onedot, body, tails, head), whereas the corresponding cuboidal primitives from \cite{Tulsiani2017CVPRa} focus mainly on the structure of the predicted object. \figref{fig:attention_in_details} shows additional results in which our model successfully predicts animals, airplanes and also more complicated motorbike parts. For instance, we observe that our model is able to capture the open mouth of the dog using two superquadrics as shown in \figref{fig:attention_in_details} (left-most animal in third row). In addition, we notice that our model dynamically allocates a variable number of primitives depending on the complexity of the input shape. For example, the left-most airplane in \figref{fig:shapenet_results}, is modelled with $6$ primitives whereas the jetfighter (right-most) that has a more complicated shape is modelled with $9$ primitives. This can also be observed for the animal category, where our model chooses a single primitive for the body of the cat (rightmost animal in \figref{fig:shapenet_results}) while for all the rest it uses two. We remark that our expressive shape abstractions allow for differentiating between different types of objects such as scooter/chopper/racebike or airliner/fighter by truthfully capturing the shape of the individual object parts. \figref{fig:primitives_evolution} visualizes the training evolution of the predicted superquadrics for three object categories. While initially, the model focuses on the overall structure of the object using mostly blob-shaped superquadrics ($\epsilon_1$ and $\epsilon_2$ close to $1.0$), as training progresses it starts attending to details. After convergence, the predicted superquadrics closely match the shape of the corresponding (unknown) object parts. \begin{figure}[t!] \centering \includegraphics[width=\linewidth]{primitives_evolution.pdf} \caption{{\bf{Evolution of Primitives.}} We illustrate the evolution of superquadrics during training. Note how our model first focuses on the overall structure of the object and starts to attend to finer details at later iterations.} \label{fig:primitives_evolution} \vspace{-1.5em} \end{figure} \begin{figure*}[t!] \centering \begin{subfigure}[t]{0.5\textwidth} \centering \includegraphics[width=\linewidth]{gradient_time.pdf} \caption{\textbf{Gradient Variance and Iteration Time.}} \label{fig:gradient_time} \end{subfigure}% ~ \begin{subfigure}[t]{0.5\textwidth} \centering \includegraphics[width=\linewidth]{us_against_tulsiani.pdf} \caption{\textbf{Evolution of Training Loss.}} \label{fig:evolution_of_training_loss} \end{subfigure} \vspace{-0.3em} \caption{\figref{fig:gradient_time} depicts the variance of the gradient estimates for $\gamma$ over 300 iterations (solid) as well as the computation time per iteration (dashed) for \cite{Tulsiani2017CVPRa} ({\color{blue}{blue}}) and our method ({\color{orange}{orange}}). Our analytical loss function provides gradients with orders of magnitude less variance while at the same time decreasing runtime. In \figref{fig:evolution_of_training_loss}, we compare the training loss evolution of \cite{Tulsiani2017CVPRa} ({\color{blue}{blue}}) to ours ({\color{orange}{orange}}). The sampling based approach of \cite{Tulsiani2017CVPRa} leads to large oscillations while ours converges smoothly. } \vspace{-1.2em} \end{figure*}% \subsection{Results on SURREAL} In addition to ShapeNet, we also demonstrate results on the SURREAL human body dataset in \figref{fig:surreal}. The benefits of superquadrics over simpler shape abstractions are accentuated in this dataset due to the complicated shapes of the human body. Note that our model successfully captures details that require modeling beyond cuboids: For instance, our model predicts pointy octahedral shapes for the feet, ellipsoid shapes for the head and a flattened elongated superellipsoid for the main body without any supervision on the primitive parameters. Another interesting aspect of our model is the consistency of the predicted primitives, i.e\onedot} \def\Ie{I.e\onedot, the same primitives (highlighted with the same color) consistently represent feet, legs, arms etc\onedot across different poses. For more complicated poses, correspondences are sometimes mirrored. We speculate that this behavior is caused by symmetries of the human body. \subsection{Analytical Loss Formulation} In this section, we compare the evolution of our training loss in Equation \eqref{eq:loss_distance} to the evolution of the training loss proposed by Tulsiani et~al\onedot \cite{Tulsiani2017CVPRa} in \figref{fig:evolution_of_training_loss}. While it is important to mention that the absolute values are not comparable due to the slightly different loss formulations, we observe that our loss converges faster with less oscillations. Note that at iteration 20k, \cite{Tulsiani2017CVPRa} starts updating the existence probabilities using reinforcement learning \cite{Williams1992ML} which further increases oscillations. In contrast, our loss function decays smoothly and does not require sampling-based gradient estimation. To further analyze the advantages of our analytical loss formulation, we calculate the variance of the gradient estimates for the existence probabilities $\gamma$ over 300 training iterations. \figref{fig:gradient_time} compares the variance of the gradients of \cite{Tulsiani2017CVPRa} to the variance of the gradients of the proposed analytical loss (solid lines). Note that the variance in our gradient is orders of magnitude lower compared to \cite{Tulsiani2017CVPRa} as we do not require sampling \cite{Williams1992ML} for approximating the gradients. Simultaneously, we obtain a lower runtime per iteration (dashed lines). While using more samples lowers the variance of gradients approximated using Monte Carlo estimation \cite{Tulsiani2017CVPRa}, runtime per iteration increases linearly with the number of samples. In contrast, our method does not require sampling and outperforms \cite{Tulsiani2017CVPRa} in terms of runtime even for the case of gradient estimates based on a single sample. We remark that in both cases the runtime is computed for the entire iteration, considering both, the forward and the backward pass. A quantitative comparison is provided in \tabref{tab:quantitative_shapenet}. Note that in contrast to \cite{Tulsiani2017CVPRa} we optimize for the Chamfer distance. \begin{table} \centering \resizebox{\columnwidth}{!}{ % \begin{tabular}{@{}l cccccc@{}} & \multicolumn{3}{c}{Chamfer Distance} & \multicolumn{3}{c}{Volumetric IoU}\\ \toprule & Chairs & Aeroplanes & Animals & Chairs & Aeroplanes & Animals \\ \midrule \cite{Tulsiani2017CVPRa} & 0.0121& 0.0153& 0.0110 & 0.1288 & 0.0650& 0.3339\\ Ours & \textbf{0.0006}& \textbf{0.0003} & \textbf{0.0003} & \textbf{0.1408}& \textbf{0.1808} & \textbf{0.7506}\\ \bottomrule \end{tabular}} \caption{{\bf Quantitative evaluation.} We report the mean Chamfer distance (smaller is better) and the mean Volumetric IoU (larger is better) for our model compared to \cite{Tulsiani2017CVPRa}.} \label{tab:quantitative_shapenet} \vspace{-1.4em} \end{table} \section{Conclusion and Future Work} \label{sec:conclusion} We propose the first learning-based approach for parsing 3D objects into consistent superquadric representations. Our model successfully captures both the structure as well as the details of the target objects by accurately learning to predict superquadrics in an unsupervised fashion from data. % In future work, we plan to extend our model by including parameters for global deformations such as tapering and bending. We anticipate that this will significantly benefit the fitting process as the available shape vocabulary will be further increased. Finally, we also plan to extend our model to large-scale scenes. We believe that developing novel hierarchical strategies as in \cite{Zou2017ICCV} is key for unsupervised 3D scene parsing at room-, building- or even city-level scales. \section*{Acknowledgments} We thank Michael Black for early discussions on superquadrics. This research was supported by the Max Planck ETH Center for Learning Systems. {\small \bibliographystyle{ieee}
{'timestamp': '2019-04-23T02:28:52', 'yymm': '1904', 'arxiv_id': '1904.09970', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.09970'}
arxiv
\section{Bipartite Online Caching}\label{sec:bipartite} We extend now our study to a network of caches reachable by the user population via a weighted bipartite graph. Bipartite caching was first used for small cell networks (see the seminal femtocaching model \cite{golrezaei2012femtocaching}), and subsequently also to model a variety of wired and wireless caching problems where the bipartite graph links represent delay, cost or other QoS metrics when users accessing different caches \cite{paschos-jsac}. \subsection{Bipartite Caching Model} Our caching network (CN) comprises a set of user locations ${\cal I}=\{1,2,\dots, I\}$ served by a set of caches ${\cal J}=\{1,2,\dots, J\}$, each with capacity $C_j$, $j\!\in \!{\cal J}$. We use parameters: \begin{equation} \bm{\ell}=\big(\ell_{ij}\in \{0,1\}: i\in\mathcal{I}, j\in\mathcal{J} \big), \notag \end{equation} to denote whether cache $j$ is reachable from location $i$, or not ($\ell_{ij}=0$). This includes the general case where a location is connected to multiple caches (e.g., consider base stations with overlapping coverage). We also maintain the origin server as a special node (indexed with $j\!=\!0$), which contains the entire library, and serves the requests for files not found in the caches. The request process is a sequence of vectors with element $x_t^{n,i}\!=\!1$ if a request for file $n$ arrives at $i\in\cal I$ in slot $t$. At each slot $t$ there is only one request $\sum_{n,i}x_t^{n,i}\!=\!1$. We perform caching using the standard model of \emph{Maximum Distance Separable} (MDS) codes \cite{golrezaei2012femtocaching}, where each stored chunk is a pseudo-random linear combination of original file chunks, and a user requires a fixed number of such chunks to decode the file. Furthermore, we will populate the caches with different random chunks such that, following from the MDS properties, the collected chunks will be linearly independent with high probability (and therefore complement each other for decoding). This results in the following model: the caching decision vector $y_t$ has $N\!\times\!J$ elements, and each element $y_t^{n,j}\in [0,1]$ denotes the amount of random equations of file $n$ stored at $j$. The set of eligible caching vectors is convex: \[ {\cal Y}_{\cal J}=\left\{y\in [0,1]^{N\times J} ~\Bigg|~ \sum_{n=1}^{N}y^{n,j}\leq C_j, ~j\in J\right\}. \] The caching policy $\sigma$ can be defined as follows: \begin{equation} \sigma: (x_1, x_2, \ldots, x_{t-1}, y_1, y_2, \ldots, y_{t-1})\longrightarrow y_{t}\in {\cal Y}_{\cal J}\,. \end{equation} Since each location $i$ might be connected to multiple caches, we use \emph{routing variables} $z^{n,i,j}_t$ to describe how a request is served at each location. The caching and routing decisions are coupled and constrained: \emph{(i)} a request cannot be routed to an unreachable cache, \emph{(ii)} we cannot route from a cache more data than it has, and \emph{(iii)} each request must be fully routed. Hence, the eligible routing decisions under $y_t$ are: \[ {\cal Z}(y_t)=\left\{z\in [0,1]^{N\!\times\! I\!\times \!J} \Bigg| \begin{array}{c} \sum_{j\in {\cal J}\cup\{0\}}z^{n,i,j}_t=x^{n,i}_t,~\forall n,i \\ z^{n,i,j}_t\leq \ell_{ij}y^{n,j}, ~\forall n,i,j\in \mathcal{J} \end{array} \right\}, \] where $z^{n,i,0}_t$ (the routing to origin) is unconstrained, and hence the set ${\cal Z}(y_t)$ is non-empty for all $y_t\!\in\! \mathcal{Y}_{\cal J}$ (i.e. $\sum_{j\in {\cal J}\cup\{0\}}z^{n,i,j}_t\!=\! x^{n,i}_t$ can always be satisfied). Naturally, we assume that $z_t\!\in\! {\cal Z}(y_t)$ is decided after the requests arrive, and hence also after the caching policy. Finally, we introduce utility weights $w^{n,i,j}$ to denote the obtained benefit by retrieving a unit fraction of a file from cache $j$ instead of the origin, and trivially $w^{n,i,0}\equiv 0$. Apart from file importance, these weights also model the locality of caches within the geography of user locations--for example a cache might have higher benefit for certain locations and lower for others. In sum, the total utility accrued in slot $t$ is: \begin{equation}\label{eq:biput} f_t(y_t)=\max_{z\in {\cal Z}(y_t)} \sum_{n=1}^N\sum_{i=1}^{I}\sum_{j=1}^{J} w^{n,i,j} x_t^{n,i}z^{n,i,j}_t, \end{equation} where the index $t$ is used to remind us that $f_t$ is affected by the adversary's decision $x_t^{n,i}$. The regret of policy $\sigma$ is: \[ R_T(\sigma)=\max_{P(x_1,\dots,x_T)}\mean{\sum_{t=1}^T f_t(y^*)-\sum_{t=1}^T f_t(y_t(\sigma))}, \] where $y^*$ is the best static configuration in hindsight (factoring the associated routing). Next we establish the concavity of our objective function $f_t(y)$ for each slot $t$. {Since} there is only one request at each slot $t$, we can simplify the form of $f_t(y)$. Let $\hat{n}, \hat{i}$ be the file and location where the request in $t$ arrives. Then $f_t( y_t)$ is zero except for $x_{t}^{\hat{n}, \hat{i}}$. Denoting with ${\cal J}^*$ the set of reachable caches from $\hat{i}$, and simplifying the notation, \eqref{eq:biput} reduces to: \vspace{-0.08in} \begin{align} f( y )=\max_{z\geq 0 } \,\,\,&\sum_{j\in {\cal J}^*} w^jz^j \label{eq:opt_zb1}\\ \text{s.t. }& \sum_{j\in \mathcal{J}^*} z^j\leq1 \label{eq:opt_zs}\\ & z^j\leq \left\{\begin{array}{ll} y^j & j\in {\cal J}^* \\ 0 & j\notin {\cal J}^*. \end{array}\right. \label{eq:opt_zc}. \end{align} \begin{lemma}\label{lem:convx} The function $f(y)$ is concave in its domain ${\cal Y}_{\mathcal{J}}$. \end{lemma} \emph{Proof:} Let us consider two feasible caching vectors $y_1,y_2\in{\cal Y}_{\mathcal{J}}$, our goal is to show that: \[ f(\lambda y_1+(1-\lambda)y_2)\geq \lambda f(y_1)+(1-\lambda) f(y_2),~\forall \lambda \in [0,1]. \] We begin by denoting with $z_1$ and $z_2$ the routing maximizers of \eqref{eq:opt_zb1} for vectors $y_1,y_2$ respectively. Immediately, it is $f(y_i)=\sum_j w^jz_i^j, ~i=1,2$. Next, consider a candidate vector $y_3=\lambda y_1+(1-\lambda)y_2$ for some $\lambda\in [0,1]$. We first show that the routing $z_3=\lambda z_1+(1-\lambda) z_2$ is a feasible routing for $y_3$, i.e., that $z_3\in \mathcal{Z}(y_3)$; by the feasibility of $z_1,z_2$, we have: \begin{align} \sum_j z_3^j\!=\!\sum_j (\lambda z_1^j\!+\!(1\!-\!\lambda) z_2^j)\! =\! \lambda \sum_j z_1^j+(1\!-\!\lambda) \sum_j z_2^j\!=\!1, \nonumber \end{align} which proves $z_3$ satisfies \eqref{eq:opt_zs}. Further, for all $j$, it is: \begin{align*} z_3^j&=\lambda z_1^j+(1-\lambda) z_2^j \leq \lambda y_1^j+(1-\lambda) y_2^j=y_3^j, \end{align*} which proves that $z_3$ also satisfies \eqref{eq:opt_zc}; hence $z_3\in \mathcal{Z}(y_3)$. It follows that $f(y_3)\equiv \max_{z\in \mathcal{Z}(y_3)}\sum_j w^j z^j\geq \sum_j w^j z^j_3$. Combining: \begin{align} &f(\lambda y_1+(1-\lambda)y_2)=f(y_3)\geq \sum_j w^j z^j_3= \\ &\lambda \sum_j w^j z^j_1+(1\!-\! \lambda) \sum_j w^j z^j_2\! =\!\lambda f(y_1)+(1\!-\!\lambda) f(y_2).\, \blacksquare \nonumber \end{align} \vspace{1mm} \subsection{Bipartite Subgradient Algorithm (BSA)} Since $f(y)$ is concave, our plan is to design a universal online bipartite caching policy by extending OGA. Note, however, that $f(y)$ is not necessarily differentiable everywhere (hence the gradient might not exist at $y_t$), and hence we need to find a subgradient direction at each slot, as explained next. Consider the partial Lagrangian of \eqref{eq:opt_zb1}: \begin{align*} L(y,z,\alpha,\beta)&=\sum_jw^jz^j+\alpha\big(\sum_j z^j-1\big)+\sum_{j}\beta^j(z^j-y^j), \end{align*} and define the function $\Lambda (y,\beta)\!=\!L(y,z^*,\alpha^*,\beta)\!\equiv\! \min_{\alpha\geq 0}\max_{z\geq 0} L(y,z,\alpha,\beta)$. From strong duality we obtain: \begin{equation}\label{eq:strdual} f(y)=\min_{\beta \geq 0}\Lambda (y,\beta). \end{equation} \begin{lemma}[Supergradient]\label{lem:subgradient} Let $\beta^*(y)\triangleq \arg\min_{\beta\geq 0}\Lambda (y,\beta)$ be the vector of optimal multipliers of \eqref{eq:opt_zc}. Define: \[ g^j=\left\{\begin{array}{ll} \beta^{j,*}(y) & j\in {\cal J}^* \\ 0 & j\notin {\cal J}^*, \end{array}\right. \] The vector $g$ is a supergradient of $f$ at $y$, i.e., it holds $f(y)\geq f(y')-g^T(y'-y),~\forall y'\in {\cal Y}_{\cal J}$. \end{lemma} \begin{IEEEproof} We have \begin{align*} f(y)&\stackrel{\eqref{eq:strdual}}{=}\min_{\beta \geq 0}\Lambda (y,\beta)\equiv\Lambda (y,\beta^*(y))\\ & \stackrel{(a)}{=}\Lambda (y',\beta^*(y))-\beta^*(y)^T(y'-y)\\ & \stackrel{(b)}{\geq} \Lambda (y',\beta^*(y'))-\beta^*(y)^T(y'-y) \\ &=f(y')-\beta^*(y)^T(y'-y) \end{align*} where $(a)$ is obtained directly by the form of the Lagrangian $L(\cdot)$ where only one term depends on $y$, and in (b) we have used that $y'$ minimizes $\Lambda(;,\beta^*(y'))$. \end{IEEEproof} {Now that we have found a method to calculate the supergradient, we can extend OGA as follows:} \begin{definition}[BSA] The {Bipartite Subgradient Algorithm} caching policy adjusts the decisions with the supergradient: \[ y_{t+1}=\Pi_{\mathcal{Y}_{\cal J}}\left(y_t+\eta_t g_t\right), \] where $\eta_t$ is the step, $g_t$ is given in Lemma~\ref{lem:subgradient}, and $\Pi_{\mathcal{Y}_{\cal J}}\left(z\right)\triangleq \arg\min_{y\in{\cal Y}_{\cal J}}\|z-y \|$ is the Euclidean projection of the argument vector $z$ onto $\mathcal{Y}_{\cal J}$, performed with Algorithm 1. \end{definition} \vspace{0.06in} \begin{tcolorbox}[boxrule=0.7pt,arc=0.6em] \begin{theorem}[Regret of BSA]\label{th:3} Let $C_j=C<N/2$. The regret of \textup{BSA} satisfies:\vspace{-0.1in} \[ R_T(\textup{BSA})\leq w^{(1)}\sqrt{2\textup{deg} J CT}. \] \end{theorem} \end{tcolorbox} \vspace{0.06in} \begin{IEEEproof} Replacing the gradient with the supergradient and repeating the steps of Theorem \ref{th:2} proof, we arrive at: \begin{equation}\label{eq:telesub} \sum_{t=1}^Tg^T_t(y^*-y_t)\leq \frac{\textit{diam}({\cal Y}_{\cal J})^2}{2\eta} +\frac{\eta TL^2}2, \end{equation} where it holds $f_t(y_t)\geq f_t(y)+ g^T_t(y_t-y)$, $\forall y\in\mathcal{Y}_{\cal J}$. Plugging these in the BSA regret expression we get: \begin{align* R_T(\textup{BSA})&=\sum_{t=1}^T(f_t(y^*)-f_t(y_t)) =\sum_{t=1}^Tg^T_t(y_t-y^*)\\ &\stackrel{\eqref{eq:telesub}}{\leq} \frac{\textit{diam}({\cal Y}_{\cal J})^2}{2\eta} +\frac{\eta TL^2}2, \end{align*} where, $\textit{diam}(\mathcal{Y}_{\cal J})=\sqrt{\sum_{j\in \mathcal{J}}C_j}=\sqrt{2CJ}$ (for $C_j=C<N/2$) and $L$ is an upper bound on the supergradient norm: \[ \|g\|\leq \sqrt{\sum_{j:\ell_{ij}=1}(w^{(1)}-w^{(J)})^2}=w^{(1)}\sqrt{\text{deg}}\triangleq L, \] where $\text{deg}$ is the maximum right degree and $w^{(1)}$ the maximum utility, and we used the optimal constant stepsize. \end{IEEEproof} The functionality of BSA is similar to OGA. In a slot where file $n'$ has been requested from location $i'$, BSA will increase variables $y^{n',j}$, where $j$ is reachable by $i'$, and then each cache $j$ will perform a local projection step, decreasing all other variables $y^{n,j}>0$ until the local cache constraint is satisfied. The difference from OGA lies only in how we compute the $y^{n',j}$ increase. This now depends on the corresponding subgradient element, which is proportional to the hypothetical utility gain if we would increase $y^{n',j}$ by $\delta y$ and we would launch another request for $n'$ from the same location $i'$. We have performed extensive simulations of BSA and selected to present a representative scenario in Fig.~\ref{Fig:bsa1}. The bipartite graph is composed of 3 caches with $C=10$, and 4 user locations. The caches have utilities (1,2,100), and a good caching policy should place popular content on cache 3. The network is fed with stationary Zipf requests from a catalogue of 100 files, and each request arrives at a user location uniformly at random. We compare BSA to the best static policy in hindsight (we may verify BSA has no regret), and literature heuristics mLRU from \cite{giovanidis-mLRU} and $q$-LRU with the lazy rule from \cite{leonardi-implicit} (for $q=1$). Over time, BSA learns what files are popular and increases their cache allocation at the high utility cache, while adjusting accordingly the less popular files in other caches. {Doing so, BSA outperforms lazy-LRU, which was the best heuristic in our simulations, by $45.8\%$. \begin{figure}[!t] \centering \subfigure[Bipartite scenario] {\includegraphics[width=1.5in]{femto-network}\label{Fig:bsa1}}\,\,\,\,\,\, \subfigure[Simulation results]{\includegraphics[width=1.7in]{MyFemto_v3} \label{Fig:bsa2}} \caption{(a) A bipartite caching example with 3 caches and 4 user locations. (b) Average utility of different caching policies. \vspace{-0.2in} } \label{Fig:bipartite} \end{figure} \section{Conclusions}\label{sec:conclusions} We established a connection between caching policies such as LRU, LFU and their variants, and the framework of OLO. Our analysis sheds light from a different angle to these established (but based on intuition) policies, and hence allows us not only to characterize their performance but also to re-design them. To this end, we proposed the online gradient caching algorithm and proved that it has universally optimal performance; and followed a similar OLO-based approach for bipartite caching networks where routing decisions are also considered. We believe our work opens a very exciting area, paving the road for the principled analysis and design of dynamic caching policies for single or networks of caches. \section{Online Gradient Ascent}\label{sec:gradient} Gradient-based algorithms are widely used in resource allocation mechanisms due to their attractive scalability properties. Here, we focus on the online variant and show that, despite its simplicity, it achieves the best possible regret. \subsection{Algorithm Design and Properties} Recall that the utility in slot $t$ is described by the linear function $f_t(y_t)=\sum_{n=1}^Nw^nx_t^ny_t^n$. The gradient $\nabla f_t$ at $y_t$ is an $N$-dimensional vector with coordinates: \[ \frac{\partial f_t}{\partial y_t^n}=w^n x^n_t,~n=1,\dots,N. \] \begin{definition}[OGA] The \emph{Online Gradient Ascent} (OGA) caching policy adjusts the decisions ascending in the direction of the gradient:\vspace{-0.15in} \[ y_{t+1}=\Pi_{\mathcal{Y}}\left(y_t+\eta_t \nabla f_t\right), \] where $\eta_t$ is the stepsize, and $\Pi_{\mathcal{Y}}\left(z\right)\triangleq \arg\min_{y\in{\cal Y}}\|z-y \|$ is the Euclidean projection of the argument vector $z$ onto $\mathcal{Y}$, and $\|.\|$ the Euclidean norm. \end{definition} The projection step is discussed in detail next. We emphasize that OGA bases the decision $y_{t+1}$ on the caching configuration $y_t$ and the most recent request $x_t$. Therefore, it is a very simple causal policy that does not require memory for storing the entire state (full history of $x$ and $y$). Let us now discuss the regret performance of OGA. We define first the set diameter $\textit{diam}(\mathcal{S})$ to be the largest Euclidean distance between any two elements of set $\mathcal{S}$. To determine the diameter, we inspect two vectors $y_1,y_2\in {\cal Y}$ which cache entire and totally different files and obtain: \[ \textit{diam}(\mathcal{Y})=\left\{ \begin{array}{ll} \sqrt{2C} & \text{if } 0<C\leq N/2,\\ \sqrt{2(N-C)} & \text{if } N/2<C\leq N. \end{array} \right. \] Also, let $L$ be an upper bound of $\|\nabla f_t\|$, we have $L\leq\max_n(\sum_n w^nx_t^n)\leq \max_n(w^n)\equiv w^{(1)}$. \begin{tcolorbox}[boxrule=0.7pt,arc=0.6em] \begin{theorem}[Regret of OGA]\label{th:2} Fix stepsize $\eta_t=\frac{\textit{diam}(\mathcal{Y})}{L\sqrt{T}}$, the regret of \textup{OGA} satisfies: \[ R_T(\textup{OGA})\leq \textit{diam}(\mathcal{Y})L{\sqrt{T}}. \] \end{theorem} \end{tcolorbox} \begin{IEEEproof} Using the non-expansiveness property of the Euclidean projection \cite{Ber99book} we can bound the distance of the algorithm iteration from the best static policy in hindsight: \begin{align*} \|y^{t+1}\!-\!y^*\|^2&\triangleq\|\Pi_{\mathcal{Y}}\left(y_t\!+\!\eta_t \nabla f_t\right)\!-\!y^*\|^2\!\leq\! \|y_{t}\!+\!\eta_t\nabla f_t\!-\!y^*\|^2\notag\\ &= \|y_t-y^*\|^2+2\eta_t{\nabla f_t}^T(y_t-y^*)+\eta_t^2\|\nabla f_t\|^2, \end{align*} where we expanded the norm. If we fix $\eta^t=\eta$ and sum telescopically over horizon $T$, we obtain: \begin{equation*} \|y_{T}-y^*\|^2\!\!\leq\! \|y_1-y^*\|^2+2\eta\sum_{t=1}^T{\nabla f_t}^T(y_t-y^*)+\eta^2\sum_{t=1}^T\!\|\nabla f_t\|^2. \end{equation*} Since $\|y_{T}-y^*\|^2\geq 0$, rearranging terms and using $\|y_1-y^*\|\leq \textit{diam}({\cal Y})$ and $\|\nabla f_t\|\leq L$: \begin{equation}\label{eq:teleonl} \sum_{t=1}^T{\nabla f_t}^T(y^*-y_t)\leq \frac{\textit{diam}({\cal Y})^2}{2\eta} +\frac{\eta TL^2}2. \end{equation} For $f_t$ convex it holds $f_t(y_t)\geq f_t(y)+ {\nabla f_t}^T(y_t-y)$, $\forall y\in\mathcal{Y}$, and with equality if $f_t$ is linear. Plugging these in the OGA regret expression ($\max$ operator is removed) we get: \begin{align*} R_T(OGA)&=\sum_{t=1}^T(f_t(y^*)-f_t(y_t)) =\sum_{t=1}^T{\nabla f_t}^T(y_t-y^*)\\ &\stackrel{\eqref{eq:teleonl}}{\leq} \frac{\textit{diam}({\cal Y})^2}{2\eta} +\frac{\eta TL^2}2, \end{align*} and for $\eta=\textit{diam}({\cal Y})/L\sqrt{T}$ we obtain the result. \end{IEEEproof} Using the above values of $L$ and $\textit{diam}(\mathcal{Y})$ we obtain: \[ R_T(OGA)\leq {w^{(1)}\sqrt{2CT}},\,\,\,\,\text{for}\,\, C<N/2\,. \] \begin{tcolorbox}[boxrule=0.7pt,arc=0.6em] \begin{corollary}[Regret of Online Caching]\label{cor:2} Fix $C/N=\gamma$, $w^n=w$, for all $n$, and assume $C<N/2$, the regret of online caching satisfies \[ w\sqrt{\frac{\gamma}{\pi}} \sqrt{CT}\leq \min_{\sigma}R_T(\sigma) \leq w\sqrt{2}\sqrt{CT}~~~\text{as}~T\to\infty. \] \end{corollary} \end{tcolorbox} \noindent Corollary \ref{cor:2} follows from Corol. \ref{cor:lbound1} and Theorem \ref{th:2}. We conclude that disregarding $\sqrt{2\pi/\gamma}$ (amortized by $T$) OGA achieves the best possible regret and thus fastest learning rate. \subsection{Projection Algorithm} We explain next the Euclidean projection $\Pi_{\mathcal{Y}}$ used in OGA, which can be written as a constrained quadratic program: \begin{align} \Pi_{\mathcal{Y}}\left(z\right)\triangleq \arg\min_{y\geq \bm{0}} & \sum_{n=1}^N (z^n-y^n)^2 \label{eq:projection}\\ \text{s.t. }& \sum_{n=1}^N y^n \leq C~\text{ and}~y^n\leq 1,~\forall n\in\mathcal{N}.\notag \end{align} In practice $N$ is expected to be large, and hence we require a fast algorithm. Let us introduce the Lagrangian: \begin{align} L(y, \rho, \mu, \kappa )&=\sum_{n=1}^N(z^n-y^n)^2+\rho(\sum_{n=1}^Ny^n-C)\nonumber \\ &+\sum_{n=1}^N\mu_n(y^n-1) - \sum_{n=1}^N\kappa_ny_n,\nonumber \end{align} where $\rho,\mu,\kappa$ are the Lagrangian multipliers. The KKT conditions of \eqref{eq:projection} ensure that the values of $y^n$ at optimality will be partitioned into three sets ${\cal M}_1, {\cal M}_2, {\cal M}_3$: \begin{align} &{\cal M}_1=\{n\in\mathcal{N}: y^n\!=\!1 \},\,\,\, {\cal M}_2\!=\!\{n\in\mathcal{N}:\! y^n=z^n\!-\!\rho/2\},\nonumber\\ &{\cal M}_3\!=\!\{n\in\mathcal{N}:\! y^n\!=\!0 \},\label{eq:proj2} \end{align} where $\rho=2\big(|{\cal M}_1|-C+\sum_{n\in {\cal M}_2} z^n\big)/|{\cal M}_2|$ follows from the tightness of the simplex constraint. It suffices for the projection to determine a partition of files into these sets. Note that given a candidate partition, we can check in linear time whether it satisfies all KKT conditions (and only the unique optimal partition does). Additionally, one can show that the ordering of files in $z$ is preserved at optimal $y$, hence a known approach is to search exhaustively over all possible ordered partitions, which takes $O(N^2)$ steps \cite{wang2015projection}. For our problem, we propose Algorithm 1, which exploits the property that all elements of $z$ satisfy $z^n\leq 1$ except at most one (hence also $|\mathcal{M}_1|\in \{0,1\}$), and computes the projection in $O(N\log N)$ steps (where the term $\log N$ comes from sorting $z$). In our simulations each loop is visited at most two times, and the OGA simulation takes comparable time with LRU. Finally, the projection algorithm provides insight into OGA functionality. In a slot where file $n'$ has been requested, OGA will increase $y^{n'}$ according to the stepsize, and then decrease all other variables $y_n>0, n\neq n'$ symmetrically until the simplex constraint is satisfied. \begin{algorithm}[t] \caption{Projection on Capped Simplex} \label{alg1} \begin{algorithmic}[1] \REQUIRE $C$; sorted $z^{(1)}\geq\dots\geq z^{(N)}$ \ENSURE $y = \Pi_{\mathcal{Y}}\left(z\right)$ \STATE ${\cal M}_1\leftarrow \emptyset,{\cal M}_2\leftarrow \{1,\dots,N\},{\cal M}_3 \leftarrow \emptyset$ \REPEAT \STATE $\rho\leftarrow 2({|{\cal M}_1|-C+\sum_{n\in {\cal M}_2} z^n})/{|{\cal M}_2|}$ \STATE $y^n\leftarrow\left\{\begin{array}{ll} 1 & n\in {\cal M}_1, \\ z^n-\rho/2 & n\in {\cal M}_2, \\ 0 & n\in {\cal M}_3 \end{array}\right.$ \STATE ${\cal S} \leftarrow \left\{n\in\mathcal{N}: y^n<0\right\}$ \STATE ${\cal M}_2 \leftarrow {\cal M}_2\setminus {\cal S}$, ${\cal M}_3 \leftarrow {\cal M}_3\cup {\cal S}$ \UNTIL{${\cal S}=\emptyset$} \IF{$y^1 >1$} \STATE ${\cal M}_1\leftarrow \{1\},{\cal M}_2\leftarrow \{2,\dots,N\},{\cal M}_3 \leftarrow \emptyset$ \STATE Repeat 2-7 \ENDIF \,\,\,\,\,\,\% KKT conditions are satisfied. \end{algorithmic} \end{algorithm} \subsection{Performance and Relation to Other Policies}\label{sec:FoLreg} Fig.~\ref{Fig:step1} showcases the hit ratio of OGA for different choices of fixed step sizes, where it can be seen that larger steps lead to faster but more inaccurate convergence. The horizon-optimal step is given in Theorem \ref{th:2} as $\eta^*\!=\!w{\sqrt{2C/T}}$, and plugging in $C\!=\!{1000}$, $w\!=\!1$ and $T\!=\!2\cdot10^5$, we obtain $\eta^*\!=\!0.1$; indeed we see that our experiments verify this. The online gradient descent (similar to OGA) is identical to the {well-known} \emph{Follow-the-Leader} (FtL) policy with a Euclidean regularizer $\frac{1}{2\eta_t}\|y\|$, cf.~\cite{Shalev12}, where FtL chooses in slot $t$ the configuration that maximizes the average utility in slots $1,2,\dots,t-1$. We may observe that FtL {applied here} would cache the files with the highest frequencies, hence it is identical to LFU (when the frequency starts counting from $t\!=\!0$). Hence, OGA can be seen as a regularized version of a utility-LFU policy, where additionally to largest frequencies we smoothen the decisions by a Euclidean regularizer. \begin{figure}[t!] \centering \subfigure[Fixed stepsize]{\includegraphics[width=1.72in]{stepsize.pdf}\label{Fig:step1}} \subfigure[Sorted based on LRU]{\includegraphics[width=1.72in]{sorted1.pdf}\label{Fig:step4}} \vspace{-3mm} \caption{{Single cache with $N\!=\!10^4$, $C\!=\!10^3$.} (a) Smaller stepsizes converge slower, but more accurately. (b) For each file in the LRU cache, we show the respective OGA caching variable.\vspace{-0.1in}} \label{Fig:stepsize} \end{figure} \begin{figure*}[!t] \centering \subfigure[CDN aggregation (IRM model)] {\includegraphics[width=1.7in] {MyFig1.pdf} \label{Fig:Fig1}} \subfigure[Youtube videos (model \cite{snm})]{\includegraphics[width=1.7in] {MyFig3.pdf} \label{Fig:Fig2}} \subfigure[Web browsing (trace \cite{Kurose08})]{\includegraphics[width=1.7in] {MyFig2.pdf} \label{Fig:Fig3}} \subfigure[Ephemeral Torrents (model \cite{Elayoubi2015})]{\includegraphics[width=1.7in] {MyFig4.pdf} \label{Fig:Fig4}} \vspace{-3mm} \caption{Average hits under different request models \cite{fricker2012impact}; (a) i.i.d. Zipf, (b) Poisson Shot Noise \cite{snm}, (c) web browsing dataset \cite{Kurose08}, (d) random replacement \cite{Elayoubi2015}; Parameters: $\gamma=0.3, T=2\times 10^5, \eta=0.1$.\vspace{-0.0051in}} \label{Fig:perf2} \end{figure*} Furthermore, OGA for $\eta\!=\!1$, $w^n\!=\!w$ bears similarities to LRU, since recent requests enter the cache at the expense of older requests. Since the Euclidean projection drops some chunks from each file, we expect least recent requests to drop first in OGA. The difference is that OGA evicts files gradually, chunk by chunk, and not in one shot. Fig.~\ref{Fig:step4} shows the values $y^n(OGA)$ for all files in the LRU cache ({the $C\!=\!1K$ most recently used}). This reveals that the two policies make strongly correlated decisions, but OGA additionally ``remembers'' which of the {recent requests are also infrequent (e.g., see point (A) in Fig. \ref{Fig:step4}), and decreases accordingly the $y^n$ values (as LFU would have done)}. Finally, in Fig.~\ref{Fig:perf2} we compare the performance of OGA to LRU, LFU, and the best in hindsight static configuration. We perform the comparison for catalogues of $10$K files, with a cache that fits $3$K files, and we use four different request models: \emph{(a)} an i.i.d. Zipf model that represents requests in a CDN aggregation point \cite{fricker2012impact}; \emph{(b)} a Poisson shot noise model that represents ephemeral YouTube video requests \cite{snm}; \emph{(c)} a dataset from \cite{Kurose08} {with actual web browsing requests} at a university campus; and \emph{(d)} a random replacement model from \cite{Elayoubi2015} that represents ephemeral torrent requests. We observe that OGA performance is always close to the best among LFU and LRU. The benefits from the second best policy here is as high as 16$\%$ over LRU and 20$\%$ over LFU. \section{Introduction} We study the performance of caching systems from a new perspective: \emph{we seek a caching policy that optimizes the system's performance under any distribution of file request sequence}. This not only has huge practical significance as it tackles the caching policy design problem in its most general form, but also reveals a novel connection between caching and online linear optimization \cite{zinkevich2003online,Shalev12,Mert18}. This, in turn, paves the way for a new mathematical framework enabling the principled design of caching policies with performance guarantees. \subsection{Background and Related Work} Due to its finite capacity a cache can typically host only a small subset of the file library, and hence a \emph{caching policy} must decide which files should be stored. The main performance criterion for a caching policy is the so-called \emph{cache hit ratio}, i.e., the portion of file requests the cache can satisfy locally. Several policies have been proposed in the past with the aim to maximize the cache hit ratio. For instance, the Least-Recently-Used (LRU) policy inserts in the cache the newly requested file and evicts the one that has not been requested for the longest time period; while the Least-Frequently-Used (LFU) policy evicts the file that is least frequently requested. These policies (and variants) were designed empirically, and one might ask: \emph{under what conditions do they achieve high hit ratios}? The answer depends on the properties of the file request sequence. For instance, we know that \emph{(i)} for stationary requests, LFU achieves the highest hit ratio \cite{Fricker12}; \emph{(ii)} a more sophisticated \emph{age-based-threshold} policy maximizes the hit ratio when the requests follow the Poisson Shot Noise model \cite{snm}; and \emph{(iii)} LRU has the highest competitive hit ratio \cite{Sleator85} for the adversarial model \cite{Belady66, Mattson70} which assumes that the requests are set by an \emph{adversary} aiming to degrade the system's performance. However, the highest competitive hit ratio is achieved by any \emph{marking} policy \cite{Borodin98} -- including FIFO -- suggesting that this metric is perhaps ``too strong'' to allow a good policy classification. Evidently, to decide which policy to use, it is necessary to know the underlying file request model, which in practice is \emph{a priori} unknown and, possibly, time-varying. \emph{This renders imperative the design of a {universal} caching policy that will work provably well for all request models. } \begin{figure \centering \includegraphics[width=3.3in]{eviction3.pdf} \vspace{-0.12in}\caption{File requests must be served by a local cache (hit) or the origin server (miss). A caching policy observes past requests and decides which files to cache in order to increase the hit ratio. \vspace{-0.15in} } \label{Fig:motivation} \end{figure} This is even more important in the emerging edge caching architectures that use small local servers or caches attached to wireless stations. These caches receive a low number of requests and therefore, inevitably, ``see'' request processes with highly non-stationary popularity \cite{snm, mathieu, Elayoubi2015}. Prior works employ {random replacement models \cite{Elayoubi2015} or inhomogeneous Poisson processes \cite{snm,kauffman} to model the requests in these systems. However, such multi-parametric models are challenging to fit and rely on strong assumptions about the popularity evolution}. Other notable approaches learn the instantaneous popularity model with no prior assumptions. For instance \cite{gunduz-reinforcement,giannakis-q-learning} employ \emph{Q-learning}, and \cite{mihaela-video-caching} leverages a scalable prediction method; but contrary to our approach, they assume the popularity evolution is stationary across time. The design of adaptive paging policies is systematically studied in \cite{geulen2010regret,englert2013economical, lykouris-ML} as an online learning problem. These works, however, consider only the basic paging problem, i.e., hit ratio maximization when caching entire files in a single cache. Caching networks (CNs) on the other hand, are hitherto under-explored; yet very important as most often caches are organized in networks. In CNs one needs to jointly decide which cache will satisfy a request (routing) and which files will be evicted (caching). The works \cite{ioannidis_icn17, Poularakis2014Approximation} proposed joint routing and caching policies for bipartite and general network graphs, respectively, and \cite{jungho-wiopt} extended them to CNs with elastic storage. However all these works assume that file popularity is stationary. On the other hand, \cite{giovanidis-mLRU} proposed the multi-LRU (mLRU) strategy, and \cite{leonardi-implicit} proposed the ``lazy rule'' extending $q$-LRU to provide local optimality guarantees under stationary requests. \emph{It transpires that we currently lack a principled method to design caching policies with provable performance guarantees, under general popularity conditions, for single or networks of caches. This is exactly our focus.} \vspace{-0.5mm} \subsection{Methodology and Contributions} We introduce a model-free caching policy along the lines of Online Linear Optimization (OLO). For the single cache case we obtain matching lower and upper regret bounds, proving that the online gradient ascent achieves order optimal performance, and we then extend these results to CNs. We assume that file requests are drawn from a general distribution, which is equivalent to caching versus an adversary selecting the requests. At each slot, in order, \emph{(i)} the caching policy decides which file parts to cache; \emph{(ii)} the adversary introduces the new request; and \emph{(iii)} a file-dependent utility is obtained proportional to the fraction of the request that was served by the cache. This generalizes the criterion of cache hit ratio and allows us to build policies that, e.g., optimize delay or provide preferential treatment to files. In this setting, we seek to find a caching policy with minimum \emph{regret}, {i.e., minimum utility loss over an horizon $T$, compared to the best cache configuration when the request sample path is known}. We {prove} that well-known caching policies such as LRU and LFU have $\Omega (T)$ regret, hence there exist request patterns for which these policies fail to learn a good caching configuration (losses increase with time). In contrast, we propose the \emph{Online Gradient Ascent} (OGA) policy, and prove its regret is at most $O(\sqrt{CT})$, for a cache that can store $C$ out of the $N$ total files. This shows that OGA eventually (as $T\to\infty$) amortizes the losses under any request model, even under denial-of-service attacks. Additionally we prove a \emph{novel lower bound} which is tighter than the general OLO lower bound. For the case of online hit ratio maximization, we find that any policy must have at least $\Omega(\sqrt{CT})$ regret. Combining the two results we conclude that \emph{(i)} the regret of online caching is exactly $\Theta(\sqrt{CT})$, and \emph{(ii)} OGA is a universally optimal policy. Interestingly, OGA can be seen as a regularized LFU, or a slightly modified LRU as we explain in Section \ref{sec:FoLreg}. We extend our model to a network of caches, arranged in the form of a bipartite graph -- a setting known as femtocaching \cite{golrezaei2012femtocaching}. We provide the \emph{Bipartite Subgradient Algorithm} (BSA) caching strategy that achieves a regret $O(\sqrt{\text{deg }JCT})$, where $J$ is the number of caches and $\text{deg}$ the maximum network node degree. Our contributions can be summarized as follows: \begin{itemize}[leftmargin=3.5mm] \item \emph{Machine Learning (ML) approach}: we provide a fresh ML angle into caching policy design and performance analysis. To the best of our knowledge this is the first time OLO is used to provide optimality bounds in caching problem. Moreover, we reverse-engineer the standard caching LRU/LFU-type of policies, by drawing connections with OLO, and provide directions for improving them. \item \emph{Universal single-cache policy}: The proposed OGA policy is universally optimal, i.e., provides zero loss versus the best caching configuration under any request model. An important projection algorithm is provided to reduce complexity and enable operation in large caches. \item \emph{Universal bipartite caching}: We consider a general bipartite CN and design the \emph{online joint caching and routing BSA policy}. Our approach hits the sweet spot of complexity versus utility for CNs: offers rigorous performance results, while it is applicable to fairly complicated settings. \item \emph{Trace-driven Evaluation}: We employ a battery of tests evaluating our policies with several request patterns. We find that OGA outperforms LRU/LFU by 20$\%$ in different scenarios, while BSA beats lazy-LRU by 45.8$\%$. \end{itemize} \section{Regret Lower Bound}\label{sec:regret-bound} A regret lower bound is a powerful theoretical result that provides the fundamental limits of how fast any algorithm can learn to cache, much like the upper bound of the channel capacity. Regret lower bounds in OLO have been previously derived for different action sets: for $N$-dimensional unit ball centered at the origin in \cite{Abernethy08}, and $N$-dimensional hypercube in \cite{Hazan06}. In our case, however, the above results do not apply since ${\cal Y}$ in \eqref{eq:capped} is a capped simplex, i.e., the intersection of a box and a simplex inequality. Therefore, we need the following new regret lower bound tailored to the online caching problem. \begin{tcolorbox}[boxrule=0.7pt,arc=0.6em, left=1mm, right=1mm] \begin{theorem}[Regret Lower Bound]\label{th:lowerBoundRegret} The regret of any caching policy $\sigma$ satisfies: \vspace{-0.1in} \[ R_T(\sigma) > \sum_{i=1}^C\mean{Z_{(i)}}\sqrt{T},\quad \text{ as } T\to\infty, \vspace{-0.051in} \] where $Z_{(i)}$ is the $i$-th maximum element of a Gaussian random vector with zero mean and covariance matrix $\hbox{\boldmath$\Sigma$}(w)$ given by \eqref{eq:covarianceMatrix}. Furthermore, assume $C<N/2$ and define $\phi$ any permutation of $\mathcal{N}$ and $\Phi$ the set of all such permutations: \[ R_T(\sigma)>\frac{\max_{\phi\in\Phi}\sum_{k=1}^C\sqrt{w^{\phi(2(k-1) +1)}+ w^{\phi(2k)}}}{\sqrt{2\pi\sum_{n=1}^N1/w^n}}\sqrt{T} \] \end{theorem} \end{tcolorbox} In the important special case of hit rate maximization, where each file $n$ is $w^n\!=\!w$, the above bound simplifies to: \begin{tcolorbox}[boxrule=0.7pt,arc=0.6em, colback=gray!3] \begin{corollary}\label{cor:lbound1} Fix $\gamma\triangleq C/N$, $w^n=w,~\forall n$, and $C<N/2$. Then, the regret of any caching policy $\sigma$ satisfies: \[ R_T(\sigma) > w\sqrt{\frac{\gamma}{\pi}}\sqrt{CT}, \quad \text{ as } T\to\infty. \] \end{corollary} \end{tcolorbox} Before providing the proof, a few remarks are in order. Our bound is tighter than the classical $\Omega(\sqrt{(\log N) T})$ of OLO in the literature \cite{Hazan06,Abernethy08}, which is attributed to the difference of sets ${\cal X},{\cal Y}$. In our proof we provide technical lemmas that are also useful, beyond caching, for the regret analysis of capped simplex sets. In next section we will design a caching policy that achieves regret $O(\sqrt{CT})$, establishing that the regret of online caching is in fact $\Theta(\sqrt{CT})$. \begin{IEEEproof}[Proof of Theorem \ref{th:lowerBoundRegret}] To find a lower bound, we will analyze a specific adversary $x_t$. In particular, we will consider an i.i.d. $x_t$ such that file $n$ is requested with probability \[ \prob{x_t={\bf e}_n}=\frac{1/w^n}{\sum_{i=1}^N1/w^i}, ~~\forall n,t, \] where ${\bf e}_n$ is a vector with element $n$ equal to $1$ and the rest zero. With such a choice of $x_t$, any causal caching policy yields an expected utility at most $CT/\sum_{n=1}^N(1/w^n)$, since \begin{align} \mean{\sum_{t=1}^T f_t(y_t(\sigma))} &=\sum_{t=1}^T\sum_{n=1}^Nw^n\prob{x_t={\bf e}_n}y_t^n(\sigma)\label{eq:util}\\ &\hspace{-0.2in}=\sum_{t=1}^T\frac{1}{\sum_n 1/w^n}\sum_{n=1}^Ny_t^n(\sigma) \leq\frac{CT}{\sum_n 1/w^n}, \notag \end{align} independently of $\sigma$. To obtain a regret lower bound we show that a static policy with hindsight can exploit the knowledge of the sample path $x_1,\dots,x_T$ to achieve a higher utility than \eqref{eq:util}. Specifically, defining $\nu^n_t$ the number of times file $n$ is requested in slots $1,\dots,t$, the best static policy will cache the $C$ files with highest products $w^n\nu^n_T$. In the following, we characterize how this compares against the average utility of \eqref{eq:util} by analyzing the order statistics of an Gaussian vector. { For i.i.d. $x_t$ we may rewrite regret as the expected difference between the best static policy in hindsight and \eqref{eq:util}: \begin{equation}\label{eq:regretIID} R_T =\mean{ \max_{y\in{\cal Y}}y^T\sum_{t=1}^T w \odot x_t }- \frac{CT}{\sum_n 1/w^n} ,\end{equation} where $w \odot x_t=[w^1x^1_t, w^2x^2_t,...,w^Nx^N_t]^T$ is the Hadamard product between the weights and request vector. Further, \eqref{eq:regretIID} can be rewritten as a function: \[ R_T=\mean{g_{N,C}(\overline{z}_T)} = \mean{\max_{b\in \stackrel{\circ}{{\cal Y}}}\left[b^T\overline{z}_T\right]}, \] where, \emph{(i)} $\stackrel{\circ}{{\cal Y}}$ is the set of all possible integer caching configurations (and therefore $g_{N,C}(.)$ is the sum of the maximum $C$ elements of its argument); and \emph{(ii)} the process $\overline{z}_T$ is the vector of utility obtained by each file after the first $T$ rounds, centered around its mean: \begin{align} \nonumber \overline{z}_T & = \sum_{t=1}^{T}w \odot x_t - w \odot\frac{T}{\sum_{n=1}^N1/w^n}w^{-1} \\ \label{eq:centeredDemandVector} & = \sum_{t=1}^{T}\left(z_t - \frac{1}{\sum_{n=1}^N1/w^n}\mathbf{1}_N\right) \end{align} where $z_t = w \odot x_t$ are i.i.d. random vectors, with distribution \[ \mathbb{P}\left(z_t = w^i {\bf e}_i\right) = \frac{1/w^i}{\sum_{n=1}^N1/w^n}, \forall t, \forall i, \] and, therefore, mean $\mean{z_t}=\frac{1}{\sum_{n=1}^N1/w^n}\mathbf{1}_N$.\footnote{Above we have used the notation $w^{-1} = \left[1/w^1, 1/w^2,...,1/w^N\right]^T.$} } A key ingredient in our proof is the limiting behavior of $g_{N,C}(\overline{z}_T)$: \begin{lemma}\label{lem:regretConvDistribution} Let ${Z}$ be a Gaussian vector ${\cal N}\left(\mathbf{0}, {\hbox{\boldmath$\Sigma$}}(w)\right)$, where ${\hbox{\boldmath$\Sigma$}}(w)$ is given in \eqref{eq:covarianceMatrix}, and ${Z}_{(i)}$ its $i-$th largest element. Then \[ \frac{g_{N,C}(\overline{z}_T)}{\sqrt{T}} \xrightarrow[T\rightarrow\infty]{\text{distr.}} \sum_{i=1}^C{Z}_{(i)} .\] \end{lemma} \begin{IEEEproof} Observe that $\overline{z}_T$ is the sum of $T$ uniform i.i.d. zero-mean random vectors, where the covariance matrix can be calculated using \eqref{eq:centeredDemandVector}: ${\hbox{\boldmath$\Sigma$}}(w) =$ \begin{align}\nonumber &=\mean{\left(z_1 - \frac{1}{\sum_{n=1}^N1/w^n}\mathbf{1}_N\right)\left(z_1 - \frac{1}{\sum_{n=1}^N1/w^n}\mathbf{1}_N\right)^T}\\ \label{eq:covarianceMatrix} &= \frac{1}{\sum_{n=1}^N1/w^n}\begin{cases} w_i -\frac{1}{\sum_{n=1}^N1/w^n}, i=j\\ -\frac{1}{\sum_{n=1}^N1/w^n}, i\neq j \end{cases} ,\end{align} where the second equality follows from the distribution of $z_t$ and some calculations.\footnote{For the benefit of the reader, we note that $Z$ has no well-defined density (since ${\hbox{\boldmath$\Sigma$}}(w)$ is singular). For the proof, we only use its distribution.} Due to the Central Limit Theorem: \begin{equation}\label{eq:convCenteredX} \frac{\overline{z}_T}{\sqrt{T}} \xrightarrow[T\rightarrow\infty]{\text{distr.}} {Z}.\end{equation} Since $g_{N,C}(x)$ is continuous, \eqref{eq:convCenteredX} and the Continuous Mapping Theorem \cite{Billingsley99} imply \[ \frac{g_{N,C}\left({\overline{z}_T}\right)}{\sqrt{T}} = g_{N,C}\left(\frac{\overline{z}_T}{\sqrt{T}}\right) \xrightarrow[T\rightarrow\infty]{\text{distr.}} g_{N,C}\left({Z}\right) ,\] and the proof is completed by noticing that $g_{N,C}(x)$ is the sum of the maximum $C$ elements of its argument. \end{IEEEproof} An immediate consequence of Lemma \ref{lem:regretConvDistribution}, is that \begin{equation}\label{eq:convExpectations} \frac{R_T}{\sqrt{T}}=\frac{\mean{g_{N,C}(\overline{z}_T)}}{\sqrt{T}}\xrightarrow{T\rightarrow\infty}\mean{\sum_{i=1}^C{Z}_{(i)}} = \sum_{i=1}^{C}\mean{{Z}_{(i)}} \end{equation} and the first part of the Theorem is proved. To prove the second part, we remark that the RHS of \eqref{eq:convExpectations} is the expected sum of $C$ maximal elements of vector $Z$, and hence larger than the expected sum of any $C$ elements of $Z$. In particular, we will compare with the following: Fix a permutation $\bar{\phi}$ over all $N$ elements, partition the first $2C$ elements in pairs by combining 1-st with 2-nd, ..., $i$-th with $i$+1-th, $2C$-1-th with $2C$-th, and then from each pair choose the maximum element and return the sum. We then obtain: \begin{align}\nonumber \mean{\sum_{i=1}^C{Z}_{(i)}} &\geq \mean{\sum_{i=1}^C\max\left[Z^{\bar{\phi}(2(i-1)+1)}, Z^{\bar{\phi}(2i)}\right]} \\ \nonumber & = \sum_{i=1}^C\mean{\max\left[Z^{\bar{\phi}((2(i-1)+1)}, Z^{\bar{\phi}(2i)}\right]} ,\end{align} where the second step follows from the linearity of the expectation, and the expectation is taken over the marginal distribution of a vector with two elements of $Z$. We now focus on $\max\left[Z^{k}, Z^{\ell}\right]$ for (any) two fixed $k,\ell$. We have that \[ (Z^{k}, Z^{\ell})^T \sim {\cal N}\left(\mathbf{0}, \hbox{\boldmath$\Sigma$}(w_k, w_{\ell})\right) \] where \vspace{-0.25in} \begin{align*} &\hspace{0.3in}\hbox{\boldmath$\Sigma$}(w^k, w^{\ell})= \\&= \frac{1}{\sum_{n=1}^N1/w^n}\begin{bmatrix} w^k-\frac{1}{\sum_{n=1}^N1/w^n} & -\frac{1}{\sum_{n=1}^N1/w^n}\\ -\frac{1}{\sum_{n=1}^N1/w^n} & w^{\ell}-\frac{1}{\sum_{n=1}^N1/w^n} \end{bmatrix} .\end{align*} From \cite{Clark1961} we then have: \[ \mean{\max\left[Z^{k}, Z^{\ell}\right]} = \sqrt{\frac{1}{\sum_{n=1}^N1/w^n}}\frac{1}{\sqrt{2\pi}}\sqrt{w^{k}+w^{\ell}} ,\] therefore: \begin{equation}\label{eq:orderStatTransformed} \mean{\sum_{i=1}^C{Z}_{(i)}} \geq \frac{1}{\sqrt{2\pi}}\frac{\sum_{i=1}^C\sqrt{w^{\bar{\phi}((2(i-1)+1)}+w^{\bar{\phi}(2i)}}}{\sqrt{\sum_{n=1}^N1/w^n}}, \end{equation} for all $\bar{\phi}$. The result follows noticing that the tightest bound is obtained by maximizing \eqref{eq:orderStatTransformed} over all permutations. \end{IEEEproof} \section{System model}\label{sec:model} We study a system with a library of files $\mathcal{N}\!=\!\{1,2,\dots, N\}$ of equal size and a cache that fits $C<N$ of them. The system evolves in time slots, and in each slot $t$ a single request is made for $n\!\in\!\mathcal{N}$, denoted with the event $x_{t}^{n}\!=\!1$. Vector $x_t\!=\!(x_{t}^n, n\!\in\!\mathcal{N})$ represents the $t$-slot request, chosen from the set: \[ \mathcal{X}=\left\{x\in \{0,1\}^N ~\bigg |~ \sum_{n=1}^N x^n=1\right\}. \] The instantaneous file popularity is determined by the probability distribution $P(x_t)$ (with support ${\cal X}$), which is allowed to be unknown and arbitrary; and the same holds for the joint distribution $P(x_1,\dots,x_T)$ that describes the file popularity evolution. This generic model captures all studied request sequences in the literature, including stationary (i.i.d. or otherwise), non-stationary, and adversarial models. The cache is managed with the caching configuration variable $y_t\in [0,1]^N$, that denotes the fraction of file $n$ cached in slot $t$.\footnote{Why caching of file fractions makes sense? Large video files are composed of chunks stored independently, see literature of \emph{partial caching} \cite{maggi}. Also, the fractional variables may represent caching probabilities \cite{Shalev12,Blaszczyszyn2014Geographic}, or coded equations of chunks \cite{golrezaei2012femtocaching}. For practical systems, the fractional $y_t^n$ should be rounded, which will induce a small application-specific error.} Taking into account the cache size $C$, the set $\mathcal{Y}$ of admissible caching configurations is: \begin{equation}\label{eq:capped} \mathcal{Y}=\left\{y\in [0,1]^N ~\bigg |~ \sum_{n=1}^Ny^n\leq C\right\}. \end{equation} \begin{definition}[Caching Policy] A caching policy $\sigma$ is a (possibly randomized) rule that at slot $t=1,\dots,T$ maps past observations $x_1,\dots,x_{t-1}$ and configurations $y_1,\dots,y_{t-1}$ to the configuration $y_t(\sigma)\in \mathcal{Y}$ of slot $t$. \end{definition} We denote with $w^n$ the utility obtained when file $n$ is requested and found in the cache (also called a \emph{hit}). This file-dependent utility can be used to model bandwidth economization from cache hits \cite{maggi}, QoS improvement \cite{golrezaei2012femtocaching}, or any other cache-related benefit. We will also be concerned with the special case $w^n=w, n\!\in\!\mathcal{N}$, i.e., the \emph{cache hit ratio} maximization. A cache configuration $y_t$ accrues in slot $t$ a utility $f\big(x_t,y_t\big)$ determined as follows: \[ f\big(x_t,y_t\big)=\sum_{n=1}^N w^n x_t^ny^n_t. \] Let us now cast caching as an online linear optimization problem. This requires the following conceptual innovations. Since we allow the request sequence to follow any arbitrary probability distribution, we may equivalently think of $x_t$ as being set by an \emph{adversary} that aims to degrade the performance of the policy. Going a step further, we can equivalently interpret that the adversary selects at each slot $t$ the utility function of the system $f_t(y)$ from a family of linear functions, $f_t(y)\equiv f(x_t,y)$. Finally, note that $y_t$ is set at the beginning of slot $t$, before the adversary selects $x_t$, Fig.~\ref{fig:model}. The above place our problem squarely in the OLO framework. \begin{figure}[!t] \centering \includegraphics[width=3.5in]{yolo-model}\vspace{-5mm} \caption{A caching decision is taken; the adversary selects the request; the caching utility is realized; and the system state is updated for next $t$.\vspace{-3mm}} \label{fig:model} \end{figure} Given the adversarial nature of our model, the ability to extract useful conclusions depends crucially on the selected performance metric. Differently from the competitive ratio approach of \cite{Sleator85}, we introduce a new metric that compares how our caching policy fares against the \emph{best static policy in hindsight}. This metric is often used in the literature of machine learning \cite{Shalev12,Mert18} with the name {worst-case static regret}. In particular, we define the \emph{regret of policy $\sigma$} as: \begin{align*} R_T(\sigma)&=\max_{P(x_1,\dots,x_T)} \mean{\sum_{t=1}^T f_t\big(y^*\big)-\sum_{t=1}^T f_t\big(y_t(\sigma)\big)} \end{align*} where $T$ is the horizon; the maximization is over the admissible adversary distributions; the expectation is taken w.r.t. the possibly randomized $x_t$ and $y_t(\sigma)$; and $y^*\in\arg\max_{y\in {\cal Y}}\sum_{t=1}^T f_t(y)$ is the best static configuration in hindsight, i.e., a benchmark policy that knows the sample path $x_1,\dots,x_T$. Intuitively, measuring the utility loss of $\sigma$ over $y^*$ constrains the power of the adversary: radical request pattern changes will challenge $\sigma$ but also induce huge losses in $y^*$. This comparison allows us to discern policies that can learn good caching configurations from those that fail. We seek a caching policy that minimizes the regret by solving the problem $\inf_{\sigma}R_T(\sigma)$, known as \emph{Online Linear Optimization} (OLO) \cite{Shalev12}. The analysis in OLO aims to discover how the regret scales with horizon $T$. A caching policy with sublinear regret $o(T)$ produces average losses $R_T(\sigma)/T\!\to\! 0$ with respect to the best configuration with hindsight, hence it learns to adapt the cache configuration without any prior knowledge about the request distribution. Our problem is further compounded due to the cache size dimension. Namely, apart from optimizing the regret w.r.t. $T$, it is of practical importance to consider also the dependence on $N$ (or $C$). \textbf{Regret of Standard Policies}. Having introduced this new caching optimization formulation, it is interesting to characterize the worst case performance of LRU and LFU policies. Recall that LRU caches the $C$ most recently requested files, while LFU calculates for each file the request frequency $h^n_t=\frac{1}{t-\tau^n}\sum_{i=\tau^n}^tx_i^n$, where $\tau^n$ is the slot when file $n$ was requested for the first time, and caches the $C$ most frequent files. The following proposition describes their performance under arbitrary requests where, for simplicity, we assumed $w^n=w,\forall n$ (hit ratio maximization). \begin{tcolorbox}[boxrule=0.7pt,arc=0.6em, left=1.5mm, right=1.5mm] \begin{proposition} The regret of \textup{LRU}, \textup{LFU} satisfies: \begin{align*} &R_T(\textup{LRU})=R_T(\textup{LFU})\geq wC\left(\frac{T}{C+1}-1\right)\,. \end{align*} \end{proposition} \end{tcolorbox} \begin{IEEEproof} Assume that the adversary chooses the periodic request sequence $\{1,2,\dots,C+1,1,2,\dots\}$. For any $t>C$, since the requested file is the $C+1$ least recent file, it is not in the LRU cache, and no utility is received. Hence, LRU can achieve at most $wC$ utility from the first $C$ slots. However, a static policy with hindsight achieves at least $wTC/(C+1)$ by caching the first $C$ files. The same rationale can be used for LFU by noticing that due to the structure of the periodic arrivals, the least frequent file is also the least recent one. \end{IEEEproof} The $\Omega(T)$ performance of standard caching policies is poor, yet this is rather expected since they are designed to perform well only under certain models (LRU for requests with temporal locality; LFU for stationary requests), and they are known to under-perform in other cases, e.g., LRU in stationary, and LFU in decreasing popularity patterns. Low regret performance means that there exist request distributions for which the policy fails to ``learn'' what is the best configuration. \emph{Remarkably, we show below that there exist universal caching policies which ensure low regret under any request model.}
{'timestamp': '2019-04-23T02:25:37', 'yymm': '1904', 'arxiv_id': '1904.09849', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.09849'}
arxiv
\section*{Introduction} Sea level rise (SLR) will affect millions of people living in coastal areas. According to the IPCC Fifth Assessment Report, in the ``worst-case'' Representative Concentration Pathways (RCP) scenario, RCP 8.5, where greenhouse gas emissions continue to rise throughout the 21st century, a global mean sea level (GMSL) rise between 0.52 to 0.98 meters (m) is \textit{likely} by 2100~\cite{church01ipcc}. Other estimates, using statistical instead of process based models of GMSL, project a rise in the range of 0.75 m to 1.9 m by 2100~\cite{vermeer2009global}. Recent research from the National Oceanic and Atmospheric Administration (NOAA), however, has suggested a 2.5 m upper bound of GMSL rise by 2100 for an `extreme' sea level rise scenario, and a 2 m GMSL rise for a `high' scenario~\cite{sweet2017global}. The impacts of sea level rise are potentially catastrophic. About 30\% of the urban land on earth was located in high-frequency flood zones in 2000, and it is projected to increase to 40\% by 2030 taking urban growth and sea level rise into account~\cite{guneralp2015changing}. In the United States alone, 123.3 million people, or 39\% of the total population, lived in coastal counties in 2010, with a predicted 8\% increase by the year 2020~\cite{crossett2014national}. By the year 2100, a projected 13.1 million people in the United States alone would be living on land that will be considered flooded with a SLR of 6 feet (1.8 m)~\cite{hauer2016millions}. Human migration is a natural response to this climatic pressure, and is one of many adaptation measures that people will take in response to climate change~\cite{mcleman2006migration, feng2010linkages, wilby2012adapting,kahn2013climatopolis}. As oceans expand and encroach into previously habitable land, affected people - climate migrants - will move towards locations further inland, looking for food and shelter in areas that are less susceptible to increased flooding or extreme weather events. In this paper, we argue that the comprehensive impacts of sea level rise on human populations, when considering migration, expand far beyond the coastal areas. Sea level rise impacts are a combination of two effects. The \textit{direct} effects of SLR capture the amount of land that will be flooded and the number of people that will be displaced and forced to relocate as an ultimate result of the loss of habitable land. The \textit{indirect} effects of SLR are more nuanced and are the results of aggregate changes in population distributions across the land. These indirect effects will cause accelerated changes for inland areas, particularly urban areas, that will observe much higher levels of incoming migrants than they would have absent SLR. These changes can in turn take the form of tighter labor markets~\cite{borjas2016labor} and increased housing prices~\cite{business2014economic}, with broader effects on income inequality in the coastal areas~\cite{shayegh2017outward}. Of course, migration to other cities can also have positive impacts; new migrants can improve productivity as they bring with them human capital accumulated elsewhere~\cite{kahn2013climatopolis}. Discussions regarding sea level rise impacts on human populations are often constrained to regions \textit{directly} experiencing SLR-driven flooding~\cite{nicholls2002analysis,willekens2016international,hauer2016millions}. Several theoretical frameworks use qualitative case studies to motivate models that might represent the reasoning behind migration choices due to sea level rise, but are not grounded in statistical methods~\cite{mcleman2006migration,black2011effect,piguet2010linking}. There are many complex interactions between demographic driven migration and climate change driven migration, and the scope and scale of the impacts of climate change on migration will be significant~\cite{feng2010linkages, hugo2011future}. One example of these impacts that has been studied considers the political ramifications that will come with the eventual migrants from Pacific island of Kiribati, which will most likely become completely flooded under a 3 meter SLR in the coming centuries~\cite{wyett2014escaping}. Another example is the projected widening demographic differentials in countries that will be especially impacted by sea level rise~\cite{hugo2011future, curtis2011understanding}, similar to demographic consequences seen after the 1970s droughts in Africa~\cite{caldwell1975sahelian,adamo2012impact}. The foundation of both of these concerns is in people's destination locations, therefore it is prudent to weigh the question of `where' people will go equally with `how many' people will be initially affected~\cite{findlay2011migrant}. There are few empirical studies that link climate change with human migration patterns. Feng et al. show that the negative impacts of climate change on crop-yields has driven increased emigration from Mexico to the United States~\cite{feng2010linkages}, while Thiede and Gray examine the effects of changing climate variables on the timing of migration in Indonesia~\cite{thiede2017heterogeneous}. The only empirical works that examine the \textit{effects of SLR on human migration} do so by coupling population projections with sea level rise and migration models to estimate how population distributions might change in future scenarios~\cite{hauer2017migration, davis2018universal}. In the US, small area population projections for the year 2100 have been combined with spatially explicit estimates of SLR~\cite{hauer2016millions} and an unobserved component regression model to estimate the destinations of populations that could be forced to migrate through coastal flooding. In \cite{hauer2017migration}, approximately 56\% of counties in the US are found to be affected by larger migrant influxes under 1.8 m of SLR. Similarly, in Bangladesh, gridded population projections have been combined with a \textit{bathtub} type model of SLR and the radiation model of human migration to estimate how population distributions may change~\cite{davis2018universal}. This coupled model has minimal data requirements, forecasts large quantities of immigrations to the division of Dhaka in Bangladesh, and highlights the broader potential impacts of these migrants including an increased demand for housing, food, and jobs. These empirical studies make the critical simplifying assumption that climate driven migration will follow the same patterns as historic migration. Additionally, ~\cite{hauer2017migration} assumes that migrations will happen only between locations for which there are historically observed migrations. However, human migration is a function of push and pull factors, and where increased climate stress will affect both~\cite{black2011effect}. As such, the patterns of climate migrants will not necessarily follow patterns observed in historical migration data. Indeed, ``climate migrants resulting from press stressors will probably constitute `enhanced', or extra, normal out-migration.''~\cite{hauer2017migration}. In this work we aim to address the simplifying assumptions made in previous empirical analyzes. First, we \textbf{derive a general framework for coupling models of sea level rise with dynamic models of human migration} so that future innovations in both human migration modeling and sea level rise modeling can easily be coupled to produce more precise estimates of changing population distributions. Second, we \textbf{design our framework with separate human migration models for affected and unaffected populations} in order to capture the different dynamics of these processes. Specifically we implement our framework with small area population projections~\cite{hauer2016millions}, the NOAA's Digital Coast Sea Level Rise estimates~\cite{marcy2011new}, and a recent machine learning (ML) method for modeling human migration~\cite{robinson2018machine}. We model migrations made from \textit{flooded} areas and from \textit{unflooded} areas separately by fitting one ML migration model using ``business-as-usual'' migration data and one model with migration data following Hurricanes Katrina and Rita. Furthermore, our general framework also separates flooded and unflooded zones at a conceptual level to ensure simulated migrations will not end in flooded areas. In our analysis, we compare simulated migration patterns under two sea level rise scenarios (1.8m SLR in 2100, and 0.9m SLR in 2100) to the baseline scenario of no SLR. We examine the aforementioned \textit{direct} and \textit{indirect} effects of SLR through its impact on human migration, and show results that highlight the importance of treating the dynamics of climate-induced migrants separately from business-as-usual migrations. Our analysis aims to answer the question of how the population distribution will change under different amounts of SLR, i.e. ``where'' populations displaced by SLR will go, and further, how SLR will affect the broader dynamics of human migration. \section*{Modeling Framework} \subsection*{Conceptual Challenges} Current state-of-the-art models of human migration include the family of radiation models~\cite{simini2012universal,yang2014limits}, gravity models~\cite{lenormand2012universal,lenormand2016systematic}, and machine learning models~\cite{robinson2018machine}. Yet, SLR-driven human migration poses some specific challenges to traditional strategies for modelling human migration: First, human migration induced by SLR might not follow historic migration patterns. In fact, using one year of county-to-county migration data from the IRS U.S. migration data sets, Simini et al.~\cite{simini2012universal} showed that a fixed proportion (~3\%) of the population of a U.S. county will migrate under normal circumstances. This will not hold under sea level rise, as the entire population in flooded areas will have to move or adapt in other ways. Importantly, in addition to direct inundation due to sea level rise, climate migrants will be forced to move as climate change effects become more pronounced, directly through the exposure to ``high-magnitude events'' such as large scale flooding from hurricanes, or indirectly through the ``cumulative contribution of ongoing localized events across regions''~\cite{mcleman2013developments}. The dynamics of these environmentally induced migrations will not necessarily follow those of previously observed migrations. We expect that as social scientists gather more data and knowledge, more refined and informed models of human migration will emerge. Second, the spatial resolution of the migration model must be carefully considered. Climate migrants will not necessarily move large distances as they adapt to changing conditions in inundated areas. Indeed most migrations are made to nearby locations. This phenomenon can be seen in the migrations following Hurricane Katrina in the US, where a majority of destinations were within Louisiana~\cite{fussell2014recovery}. Joint SLR/migration models must capture the situations whereby migrants can choose to move to the unflooded portions of partially flooded zones, and must guarantee that no migrants are assigned to a flooded area. Finally, SLR will not happen instantaneously and population projections need to account for the cumulative effects of SLR induced migration. The SLR influenced population distribution of a location will diverge from that of a ``business as usual'' scenario as the indirect effects of SLR compound; as more climate migrants settle inland, they will change the migrations patterns of future migrants and so on. Current population projections account for the \textit{direct} effects of SLR where projected populations are made with respect to potentially flooded land~\cite{hauer2016millions}, however these \textit{indirect} effects must also be considered. \subsection*{General Modeling Framework} Consider an amount of SLR in meters, $x$, a list of $n$ spatial zones, and $\boldsymbol{\theta} = [\theta_1, \ldots, \theta_n]$, which includes the spatial distribution of population in each zone, and, optionally, other features associated with each zone. Using this information, we want to compute a \textit{migration matrix} $\boldsymbol{T}$, where an entry $T_{ij}$ represents the number of migrants that travel from zone $i$ to $j$ under the given amount of SLR. We propose a general modeling framework for handling this problem which consists of two modules, shown in Fig \ref{fig:flowChart}: a \texttt{SLR} module and a \texttt{MIGRATION} module. \begin{figure}[t] \centering \includegraphics[width=\linewidth]{Fig1.jpg} \caption{\textbf{Joint sea level rise and human migration modeling process.} The joint model takes a list of spatial zones $\boldsymbol{\theta}$ and amount of SLR $x$ as input, and outputs a \textit{migration matrix} $\boldsymbol{T}$, where an entry $T_{ij}$ represents the number of migrants that travel from zone $i$ to $j$ under the given amount of SLR.} \label{fig:flowChart} \end{figure} \textbf{\texttt{SLR} module}. This module uses a sea level rise model $SLR(\boldsymbol{\theta},x)$ to partition each input zone into two new zones: the flooded portion and the unflooded portion. Using the best available data, this module should divide the features from the original zone ($\theta_i$) between the flooded-portion zone ($\theta^A_i$) and the unflooded-portion zone ($\theta^U_i$). For example, if we have high-resolution spatial population data, then we can split population between the two partitions based on the spatial extent of the flooding. Using this module, we estimate the \textit{direct} effects of SLR in terms of flooded area and number of people living in such an area. \textbf{\texttt{MIGRATION} module}. This module calculates $\boldsymbol{T}$ using the two sets of zones from the \texttt{SLR} module. Specifically, this module uses two migration models: 1.) a model for migrations from flooded zones $\boldsymbol{\theta}^A$ to unflooded zones $\boldsymbol{\theta}^U$ with the function $MIGRATION_C(\boldsymbol{\theta}^A,\boldsymbol{\theta}^U) = \mathbf{T'}$, where migration is a forced process; and 2.) a model of migrations from unflooded zones to unflooded zones with the function $MIGRATION_S(\boldsymbol{\theta}^U,\boldsymbol{\theta}^U) = \mathbf{T''}$, where migration happens due to usual drivers. Finally, this module should aggregate migrant flows from the two migration functions, $\mathbf{T} = \mathbf{T'} + \mathbf{T''}$. Using this module, we estimate the \textit{indirect} effects of SLR in terms of how the population distribution changes relative to no SLR. By separating SLR driven migration from standard migrations, our framework forces these dynamics to be considered independently, explicitly bringing up the issue from the first conceptual challenge mentioned in the previous section. Implementations of our framework can use different models for these dynamics if available, or, if such models are not available, fall back to using a simpler model where the simplifying assumption is clear. Our framework also addresses the second conceptual challenge by excluding flooded areas as destinations for all migrants by simply not considering migrant flows with destinations in the set of flooded portions. Note that within-zone migrations in partially flooded zones are handled by presenting the neighboring unflooded portions of those zones as possible destinations. Furthermore, by separating the functionality of the \texttt{SLR} module from that of the \texttt{MIGRATION} module, the framework allows ablation studies to measure how much results depend on the specific behaviors of each. The third conceptual challenge revolves around how SLR and migration are both temporal processes that form a feedback loop (i.e. SLR will affect migration decisions, which will in turn affect how many people are affected by further SLR, etc.). This is not explicitly taken into account in our framework, however should be addressed in further research as each process is further understood. In Section 5 of the Supplementary Information we provide a more formal definition of our Joint Model. \subsection*{Implementation of Joint SLR/Migration Model} We implement our proposed framework with 1.) small area population projections for 2100 under different amounts of SLR, following the methodology in~\cite{hauer2016millions} - which uses the NOAA's Digital Coast Sea Level Rise estimates~\cite{marcy2011new} - and 2.) a recent machine learning (ML) approach for modeling human migration~\cite{robinson2018machine}. An implementation of the Joint Model requires us to define the \texttt{SLR} function, the manner in which the \texttt{SLR} function splits features associated with the zones that are affected by SLR, and the two \texttt{MIGRATION} functions. All three of these steps are discussed in the next two sections. In Section 2 of the Supplementary Information we show a similar implementation using the Extended Radiation Model~\cite{yang2014limits} to implement the \texttt{MIGRATION} functions. In Section 3 of the Supplementary Information we describe our ML model and give validation results comparing it to other human migration models on the task of predicting inter-county migrations in the US. \subsubsection*{Sea Level Rise Modeling} First, we follow the methodology proposed in Hauer 2016~\cite{hauer2016millions} to create population projections for \textit{every} Census Block Group in the US ($n=216,330$) for two SLR scenarios, \textbf{medium}, where 0.9m (3ft) of SLR is experienced by 2100, and \textbf{high}, where 1.8m (6ft) of SLR is experienced by 2100. These SLR scenarios are also proposed in Hauer 2016, based on methods from the US National Climate Assessment, and use the NOAA's Digital Coast spatial estimates of areas affected by SLR in 1ft (0.3m) increments~\cite{marcy2011new,digitalCoastReport}. The medium SLR scenario expects SLR to reach the 0.3m, 0.6m, and 0.9m thresholds in the years 2055, 2080, and 2100 respectively. The high scenario reaches similar increasing 0.3m SLR increments in the years 2042, 2059, 2071, 2082, 2091, and 2100. The Digital Coast model provides SLR estimates that address many of the shortcomings of a naive \textit{bathtub} calculation of SLR (i.e. thresholding a digital elevation map with expected SLR amounts) by taking tidal variability, hydroconnectivity, probable flooding, and federal leveed areas into account. With this data, we define the $SLR(\theta_i,x_t)$ function as taking an input \textit{county}, $\theta_i$, and amount of SLR under either the medium or high SLR scenario, $x_t$. A given county corresponds to a set of census block groups while a given SLR amount, under either scenario, corresponds to population projections for the census block groups, including an estimate of the number of people \textit{affected} by flooding in each block group. We split the county population into the affected and unaffected block groups, which directly results in $\theta^U_i$ and $\theta^A_i$. Here, $\theta^U_i$ is a ``new'' county equivalent zone, for the purposes of modeling migration, with a population equal to the sum of the unaffected populations over all the associated block groups. Similarly, $\theta^A_i$, represents the innundated portion of the original county, and will contain a population equal to the sum of affected populations in the associated block groups. We can run $SLR(\theta_i,x_t)$ for all $i$ to get the $\boldsymbol{\theta}^U$ and $\boldsymbol{\theta}^A$ sets. Population is the only feature required by the \texttt{MIGRATION} module, however a similar splitting technique could be used for other block group level features if they can be reliably projected into future scenarios. \begin{figure}[ph] \centering \includegraphics[width=0.85\linewidth]{Fig2.jpg} \caption{\textbf{Spatial distribution of the direct and indirect effects of SLR on human migration.} The \textbf{top} panel shows all counties that experience flooding under 1.8m of SLR by 2100 in blue and colors the remaining counties based on the number of additional incoming migrants per county that there are in the SLR scenario over the baseline. The \textbf{bottom left} map shows the number of additional incoming migrants per county in the SLR scenario from only flooded counties. The \textbf{bottom right} map shows the number of additional incoming migrants per county in the SLR scenario from only unflooded counties. Color gradients are implemented in a log scale.} \label{fig:2} \end{figure} \subsubsection*{Human Migration Modeling} We model human migration between counties in the USA with a recently proposed artificial neural network (ANN) based method~\cite{robinson2018machine} that is fit with historic county-to-county migration data from the IRS~\cite{irsData}. This method is similar in functionality to traditional models of human mobility and migration, such as the radiation or gravity models~\cite{simini2012universal,erlander1990gravity,lenormand2012universal}, as it will estimate the probability of a migration between a given origin and destination based on population and distance features~\cite{simini2012universal}. More specifically, our ANN models estimate $P_{ij}$, the probability that a migrant which leaves an origin county, $i$, will travel to a destination county, $j$, using the following input features: origin population, $m_i$, destination population, $m_j$, distance between the two, $d_{ij}$, and the ``intervening opprtunities'' between the two, $s_{ij}$ (this is the total population in the circle centered at $i$ with radius $d_{ij}$, not including $m_i$ or $m_j$). These features are the same features used by traditional radiation and gravity models, and depend solely on population and distance. To compute $T_{ij}$, the number of migrants that travel from $i$ to $j$, we need to know the number of migrants that are attempting to leave $i$. If we say that the number of migrants leaving zone $i$ is of the form $g(m_i) = \alpha m_i$, where $\alpha$ is some coefficient that specifies the fraction of the total population that will migrate, then $T_{ij} = g(m_i) P_{ij}$. This function $g$ is called the production function. Now we can define the \texttt{MIGRATION} functions, $MIGRATION_C$ and $MIGRATION_S$, which represent the climate migrants and standard migrants respectively, by training two instances of our ANN model, and forming respective production functions $g_C(m_i)$ and $g_S(m_i)$ by choosing $\alpha_C$ and $\alpha_S$. We fit the $MIGRATION_C$ model by finding hurricane affected counties from the IRS migration data from 2004-2011 and 2011-2014. Specifically, we search for migration data points (i.e. pairs of counties) in which the origin county was a coastal county that observed an over 100\% \textit{increase} in outgoing migrations with over 1,000 total outgoing migrations\footnote{The reporting methodology in the IRS migration dataset changed between the 2010-2011 data and 2011-2012 data, therefore we cannot measure percent increase in outgoing migrations between them.}. This ``filter'' highlights counties that have potentially been affected by hurricanes or other natural disasters and indeed finds seven counties from 2005 that were heavily impacted by hurricanes Katrina and Rita: St Bernard, Orleans, Cameron, Plaquemines, Hancock, Jefferson, and Harrison (which matches literature estimates of the most damaged counties~\cite{fussell2014recovery}), as well as Liberty County, GA from 2006. The only historical explanation we can find for a sudden increase in outgoing migration in Liberty County is the deactivation of a large US military division stationed within the county that year. Considering this, we fit our $MIGRATION_C$ model using the data from the seven counties that were most seriously affected by hurricanes Katrina and Rita. As background, Hurricane Katrina struck the city of New Orleans and the broader Louisiana and Mississippi coastline on August 29, 2005 causing widespread flooding and wind damage. Less than a month later, on September 25, Hurricane Rita also struck the Louisiana coast, exacerbating damage in New Orleans and causing extensive damage to counties in the western portions of the state. Over 1500 people were killed and over 80\% of the city of New Orleans was flooded as a result of these hurricanes. Followup studies and Census estimates showed that New Orleans only contained around half of its pre-hurricane population within a year of the storms. By training our ANN with these counties we allow the model to pick up on the dynamics of migrations after extreme flooding events. We train an ANN, $MIGRATION_C(\theta^A_i, \theta^U_j) = P'_{ij}$, using all $7 \times 3099$ pairs of counties from the 2005-2006 IRS data that include one of the seven previously mentioned \textit{affected} counties as an origin and an \textit{unaffected} county as a destination. Similarly, we fit another ANN using the rest of the IRS migration data, $MIGRATION_S(\theta^U_i, \theta^U_j) = P''_{ij}$. Due to our assumption that all people in flooded areas will have to migrate, the production function for climate migrants is given as the identity, $g_C(m_i) = m_i$. This forces the entire population of the affected portions of counties to become migrants. For standard migrants, we use the production function, $g_S(m_i) = 0.03 m_i$, due to the observation by Simini et al.~\cite{simini2012universal} that 3\% of a county's population will migrate under normal conditions each year. Given these: $T'_{ij} = g_C(m_i) MIGRATION_C(\theta^A_i, \theta^U_j)$, and $T''_{ij} = g_S(m_i) MIGRATION_S(\theta^U_i, \theta^U_j)$. With these definitions we can build $\mathbf{T'}$ and $\mathbf{T''}$ by running the climate migration ANN and standard migration ANN for all pairs of counties. In Section 3 of the Supplementary Information we evaluate the performance of these models compared to other migration models in a cross validation experimental setup. \section*{Results} \begin{figure}[ph] \centering \includegraphics[width=0.85\linewidth]{Fig3.jpg} \caption{\textbf{Impacts of SLR due to flooding and human migration for a range of SLR scenarios.} We say that a county is indirectly affected by SLR if the difference between the number of incoming migrants to the county in the SLR scenario and the number of incoming migrants in the baseline scenario, i.e. the number of \textit{extra} migrants in the SLR scenario, is greater than some percentage, $d$, of that county's population. In the \textbf{top} panel we show the spatial distribution of counties that are considered indirectly affected at different threshold values of $d$ for the 1.8m SLR case in the southeast portion of the United States. In the \textbf{bottom} panel we show the number of people that are directly and indirectly affected under the same threshold values of $d$ for the entire United States. For both plots we show aggregate impacts for five different values of $d$: 0.5\%, 1\%, 3\%, 6\%, and 9\%.} \label{fig:3} \end{figure} We categorize the effects of SLR into two types: \textit{direct effects}, which are a direct consequence of SLR, and \textit{indirect effects}, which are a consequence of changing migration patterns due to SLR. We present the spatial distribution and magnitude of these effects in Figs \ref{fig:2} and \ref{fig:3}. People that live on flooded land who will have to move away are accounted for in the \textit{direct effects} of SLR. People that live in counties that experience a larger number of incoming migrants in the flooding scenario relative to the baseline scenario with no SLR are accounted for in the \textit{indirect effects} of SLR. In Fig \ref{fig:2} we show the spatial distribution of changes in migration patterns. In the top panel, counties experiencing any flooding (i.e. that are directly affected by SLR) are highlighted in blue, while the remaining counties are colored according to how many additional migrants they receive in the 1.8m SLR scenario. The bottom two panels of Fig \ref{fig:2} show the difference in the number of incoming migrants between the SLR scenario and the baseline scenario for incoming migrants from \textit{unaffected} counties and \textit{affected} counties. The top panel is the sum of these two maps, and shows this difference for incoming migrants from \textit{all} counties. From these maps we can see that the primary destination of climate migrants are counties just inland of their origin, but climate migrants also move farther towards large cities that offer more opportunities. In Fig \ref{fig:3} we show the magnitude of the \textit{direct} and \textit{indirect} effects as well as the spatial distribution of the indirectly affected counties. Formally, a county is marked as indirectly affected if the difference between the number of incoming migrants in the SLR scenario and the baseline scenario is greater than a percentage $d\%$ of the population of that county. By varying $d$ we can see different intensities of indirect effects. On average, 3\% of a county's population migrates each year~\cite{simini2012universal}. Thus, if $d=3\%$, we would observe twice as much migration into a particular county than the average migration rate of the US. We assume that as $d$ increases, the effects will be stronger as there will be a significant strain on the resources in that particular county. The graph in the bottom panel of Fig \ref{fig:3} shows the direct and indirect effects of SLR in terms of number of people affected for amounts of SLR in the range from 0.3m to 1.8m in 0.3m increments. The map in the top panel shows which counties in the United States are indirectly affected at different threshold values of $d$. In both plots the indirect effects are shown for five different values of $d$: 0.5\% 1\%, 3\%, 6\%, and 9\%. From the graph in Fig \ref{fig:3} we can see that the \textit{indirect} impacts of SLR grow at much faster rate than the \textit{direct} impacts. In the high SLR scenario by the year 2100 there are $\approx$ 13 million people \textit{directly} affected, in $\approx$ 50 thousand km$^2$ of flooded land, however there are almost twice as many, $\approx$ 25 million people, \textit{indirectly} affected at the 9\% threshold due to changing migration patterns and magnitudes. This 9\% threshold indicates that these people live in areas which will experience three times as many migrants as they would compared to a baseline scenario. Even under the moderate assumption of 0.9m SLR by 2100 there will be 24 million people that live in counties considered indirectly affected at a 3\% threshold. Under the same threshold with a SLR of 1.8m by 2100, there will be 120 million people, over $\approx 1/3$ of the population of US, living in counties that will see a doubling in the number of annual incoming migrants. The map in Fig \ref{fig:3} shows that these \textit{indirect} effects relative to county population will be distributed unevenly over the US. Most effects are seen in the Eastern US, where there are more vulnerable coastal populations. Of particular note are southern Mississippi and southeastern Georgia, where large groups of counties are estimated to see indirect effects in the $>9\%$ category. The Midwest is also projected to see large indirect effects, even though the magnitudes of incoming migrants are smaller than counties closer to the coast. This can be explained by the relatively small populations and baseline levels of incoming migrants. The greater magnitudes of migrations from higher population areas causes \textit{some} migrants to select these midwestern areas as destination, which could cause disproportionally larger \textit{indirect} effects. \section*{Discussion} Our results show that the effect of SLR on human populations could be more pervasive and widespread than anticipated, with almost all counties receiving some number of additional migrants due to SLR induced flooding. We identified two possible channels through which SLR can affect migration. First, the ``direct effect'' shows the amount of people that are forced to migrate away from flooded areas. The ``indirect effect'' consists of changes in the magnitude and pattern of migration across all populated areas due to the impact of SLR. The areas immediately adjacent to coastal counties will experience the most dramatic impacts as many migrants will simply move slightly further inland. These counties are predominantly rural and may not have the infrastructure capacity to serve several times the number of average annual incoming migrants. Increased competition for scarce resources, tighter housing and labor markets and more congested roads and diminished access to amenities can deteriorate the living conditions in the counties that receive more migrants. It is of course possible that the new influx of migrants could stimulate the economy thus creating new opportunities for growth in the local economy. This can be the case, not only if migrants flow from more affluent communities, but also because of increased human capital that can spur innovation and improve productivity. The purpose of our study is not to determine whether or not new influx of people are good or bad for a local economy, but to highlight the range of migration changes that can occur because of sea level rise. The overall socio-economic impacts of climate driven migration, of which our results are the first piece, need to be further studied as more data becomes available. In general, we find that previously ``unpopular'' destinations would be more popular solely due to their close proximity to counties that experience ``direct effects''. The East Coast will experience larger effects than the West coast because of the large coastal population centers and shallower coastlines. Existing urban areas will receive the largest magnitudes of migrants, as they represent the most attractive destinations, which will accelerate the existing trends of urbanization. We find that the southeast portion of the United States will experience disproportionately high effects from SLR-driven flooding due to the large vulnerable populations in New Orleans and Miami. These results show that by driving human migration, the impacts of SLR have the potential to be much farther reaching than the coastal areas which they will flood. We find similar conclusions to previously published estimates of human migration under SLR in the USA~\cite{hauer2017migration} - inland areas immediately adjacent to the coast, and urban areas in the southeast US will observe the largest effects from SLR driven migration. Our method for modeling human migration reveals several notable differences. According to Hauer 2017, the Austin, Texas Core Based Statistical Area is expected to observe the largest effects out of all destinations, with over 800 thousand incoming migrants due to SLR. This result happens because Austin has consistently been one of the fastest growing US cities over the past decade, which is captured and projected by a time series based migration model. Our migration model instead captures the dynamics of human migration between US counties based on population and distance features, and uses this to predict flows between counties without regard to potential short term historic trends. This approach has the benefit of allowing our model to predict flows between pairs of counties for which there are no historical flows, but can also result in potentially underpredicting flows to areas growing at faster-than-average rates. Indeed, in Texas, our results show more incoming migrants to Houston and Dallas - two larger cities closer to affected coastal areas. Our analysis extends to how ``standard'' migration patterns between unaffected counties can change due to changes in viable destinations. The bottom right panel of Fig \ref{fig:2} shows how the incoming migrant distribution from \textit{unaffected} counties changes in the High 2100 scenario. We observe that migrants from unaffected areas, that would previously move to coastal areas, will especially relocate to larger population centers. The counties surrounding Los Angeles in particular could see tens of thousands of migrants that are not coming from affected areas, but must choose a different location as a result of coastal flooding. Because we rely on machine learning techniques, we forfeit the explanatory power of our model in favor of a more accurate prediction. This approach is suitable for the purposes of our research question and conceives a much more flexible methodology to analyze future migration. This black-box approach can be further calibrated as more data on similar temporal and spatial scales for empirical studies to explain migration behaviors becomes available~\cite{piguet2010linking}. In the meantime, as various aspects of human migration are better understood, especially ones related to environmental pressures, and better models of human migration are created, our flexible analytical framework will easily support new improved implementations and produce more accurate results. Similarly, as SLR flooding estimates are improved - with finer resolution population projections, uncertainty estimates, and models of the potential spatial effects of SLR such as expected flood frequency - the results given by our framework can be refined. \section*{Acknowledgements} J.M-C was supported in part by the National Science Foundation of the United States of America (Grant no. 1510510) and the Canada Research Chairs program. B.D. was supported in part by NSF grants CCF-1522054 (COMPUSTNET: Expanding Horizons of Computational Sustainability) and BCS-1638268 (CRISP: Sustainable and Resilient Design of Interdependent Water and Energy Systems at the Infrastructure-Human-Resource Nexus). \bibliographystyle{ieeetr} \section{Code and reproducibility} We have published open source code for reproducing the results in this paper at \url{https://github.com/calebrob6/migration-slr}. This effort includes scripts for processing the Digital Coast SLR data, reproducing the block group population estimates from Hauer et al. 2016~\cite{hauer2016millions}, training and running the artificial neural network (ANN) migration models described in Robinson and Dilkina~\cite{robinson2018machine}, and creating all results and figures in the paper. We hope that this effort will encourage further study into the effects of sea level rise (SLR) on human migration and in other salient aspects of society. \subsection{Population projections} The population projections in this paper are reproduced from the methodology described in Hauer et al. 2016~\cite{hauer2016millions}. This methodology involves modeling the growth (or decline) of housing units, $h^t_i$, for each census block group in the US based on historical data from 1940-2010, then projecting the number of housing units per census block group out to 2100. The population per housing unit, $d_i$, and the group quarters population, $g_i$, for each block group is assumed to stay constant at their 2010 values. Now, the total population for a particular block group, $i$, at some time, $t$, is given as $p^t_i = h^t_i * d_i + g_i$. We find our estimates of affected county level populations in 2100 under both the medium and high SLR scenarios are similar to those reported in the the Supplementary Information of Hauer et al. 2016. These estimates can be downloaded in the accompanying code repository. \section{Implementation and results using the Extended Radiation model} We implement our proposed framework using the extended radiation model~\cite{yang2014limits} as a human migration model instead of the ANN model proposed in the main text. The extended radiation model is a rederivation of the original radiation model~\cite{simini2012universal} under a survival analysis framework that includes the addition of a parameter which controls the influence of scale of the region and the degree of heterogeneity in the distribution of destination locations. Other human mobility models such as the gravity model~\cite{zipf1946p, erlander1990gravity, lenormand2012universal, lenormand2016systematic}, and Schneider's intervening opportunities model~\cite{schneider1959gravity} provide alternate ways to estimate the number of people that migrate between different locations. The extended radiation model is given in Equation~\ref{equ:extendedRadiationModel}, where the variables are as follows: $P_{ij}$ is the probability that a migrant who leaves zone $i$ will travel to zone $j$, $T_{ij}$ is the number of migrants that travel from zone $i$ to $j$, $m_i$ is the population of zone $i$, $\beta$ is a parameter of the extended radiation model that controls the influence of scale of the region on trips, $d_{ij}$ is the distance between zones $i$ and $j$, and $s_{ij}$ is the population in the circle centered at $i$ with radius $d_{ij}$ (which does not include $m_i$ or $m_j$). \begin{equation} \label{equ:extendedRadiationModel} P_{ij} = \frac{[(m_i + m_j + s_{ij})^\beta - (m_i + s_{ij})^\beta] (m_i^\beta + 1)}{[(m_i + s_{ij})^\beta + 1][(m_i + m_j + s_{ij})^\beta + 1]}, \;\;\;\; i \neq j \end{equation} As in the main text, we use two ``versions'' of the extended radiation model to model migrations from flooded areas and unflooded areas separately. We calculate $\beta_C$ and $\beta_S$, the parameters for the models $MIGRATION_C$ and $MIGRATION_S$ respectively, by minimizing the \textit{Common Part of Commuters} (CPC) metric~\cite{lenormand2016systematic} over the same sets of migration data that were used to train the previous ANN model. Here $\beta_C = 0.13$ and $\beta_S = 0.33$. We compare the fit of the ANN and Extended Radiation model in Section \ref{sec:validation}. Figures \ref{fig:rad_quantities} and \ref{fig:rad_proportions} show the results from using these extended radiation models and are in the same format as the results figures from the main text. The general patterns match those from main text (which use an ANN model) - higher concentrations of migrants move to urban areas and counties immediately inland from coastal counties have higher percentages of incoming migrants by population. Figure \ref{fig:rad_proportions} shows the severity of indirect effects degrading with distance from the East coast of the US, while showing that counties that are adjacent to the West coast will not experience similar effects. This result is a combination of the larger displaced populations along the East coast, and the relatively higher density of populations of counties in the Eastern US. The extended radiation model describes the probability of migration between two counties as decaying as a function of the intervening opportunities between them. The intervening opportunities between counties are fewer in the less dense counties of the Western US, meaning longer migrations will be more probable, while shorter migrations will be likely in the more dense Eastern US. Therefore, affected migrants leaving large populations centers along the east coast, such as Miami-Dade in Florida, will diffuse across the available opportunities at a rate roughly proportional to the distance from their origin - giving the observed pattern. The results given by the extended radiation model predict larger amounts of indirect effects at the higher values of $d$ than the ANN models do, i.e. that there will be larger numbers of people that are indirectly effected by SLR. This is a direct consequence of the diffusion pattern described in the previous paragraph, more population mass is dispersed over larger numbers of rural counties in the southeast US, thus counting the entire populations of these counties as being affected under higher values of $d$. \begin{figure*}[!th] \centering \includegraphics[width=0.7\linewidth]{extrad_difference_both_high_2100.jpg} \includegraphics[width=0.49\linewidth]{extrad_difference_affected_high_2100.jpg} \includegraphics[width=0.49\linewidth]{extrad_difference_unaffected_high_2100.jpg} \caption{\textbf{Extended Radiation Model.} Spatial distribution of the direct and indirect effects of SLR on human migration. The \textbf{top} panel shows all counties that experience flooding under 1.8m of SLR by 2100 in blue and colors the remaining counties based on the number of additional incoming migrants per county that there are in the SLR scenario over the baseline. The \textbf{bottom left} map shows the number of additional incoming migrants per county in the SLR scenario from only flooded counties. The \textbf{bottom right} map shows the number of additional incoming migrants per county in the SLR scenario from only unflooded counties. Color gradients are implemented in a log scale.} \label{fig:rad_quantities} \end{figure*} \begin{figure}[!th] \centering \includegraphics[width=0.75\linewidth]{extrad_direct_indirect_high_2100.jpg} \includegraphics[width=0.75\linewidth]{extrad_direct_indirect_high_plot.jpg} \caption{\textbf{Extended Radiation Model.} Impacts of SLR due to flooding and human migration for a range of SLR scenarios. In the \textbf{top} panel we show the spatial distribution of counties that are considered indirectly affected at different threshold values of $d$ for the 1.8m SLR case in the southeast portion of the United States. In the \textbf{bottom} panel we show the number of people that are directly and indirectly affected under the same threshold values of $d$ for the entire United States. We show the same impacts from Figure 3 in the main text.} \label{fig:rad_proportions} \end{figure} \section{Migration model training and validation} \label{sec:validation} Our implementation of the Joint Model relies on ANN models of human migration to estimate migrations from affected and unaffected counties. We fit these models using historical county-to-county migration data from 2004-2014 from the IRS~\cite{irsData}. In this section, we evaluate the performance of our ANN models against the Extended Radiation~\cite{yang2014limits}, Radiation~\cite{simini2012universal}, and two types of Gravity models~\cite{lenormand2012universal,lenormand2016systematic}. We have three sets of counties: \textbf{all counties} which consists of every county from \textit{all} years of migration data, \textbf{affected counties} which consist of the 7 counties most heavily impacted by Hurricanes Katrina and Rita in 2005 (discussed in the main text), and \textbf{unaffected counties} which consists of the set difference \textbf{all counties} - \textbf{affected counties}. We evaluate each model's average cross-validated performance in three tasks: estimating migrations from \textbf{all counties} to \textbf{all counties}, from \textbf{unaffected counties} to \textbf{unaffected counties}, and from \textbf{affected counties} to \textbf{unaffected counties}. In all of these cross-validation experiments we split on origin counties, i.e. we select a set of training counties and use all migration observations originating in that set of counties (different rows of $\mathbf{T}$) to fit our models, then test on the migration observations originating in the remaining counties. In the \textbf{affected counties} to \textbf{unaffected counties} estimation task we use leave-one-out cross-validation as we only have 7 origin counties, while in the other two tasks we use 5-folds cross-validation. In each cross-validation fold we fit a model for every year of training data and average the results. This fitting procedure involves: training the ANN models using the parameters/architecture described in~\cite{robinson2018machine}, estimating the single parameter, $\beta$, of the extended radiation or gravity models, and estimating the production function coefficient $\alpha$. We estimate the $\beta$ parameters by maximizing the $CPC$ metric (described below) between the training migration data and modeled migration data. Finally, we estimate the $\alpha$ parameter by calculating the slope of the best fit line through all ($m_i$, $\sum_{j=1}^n T_{ij}$) points, i.e. computing the average fraction of the population of a county that migrates away in a given year. All parameter fitting is done only within a fold's training data, and the average and standard deviations of the $\alpha$ and best $\beta$ parameters for each task is reported in Table \ref{tbl:all_results}. To measure model performance we record the Common Part of Commuters ($CPC$)~\cite{lenormand2012universal}, Common Part of Commuters distance variant ($CPC_d$)~\cite{lenormand2016systematic}, mean absolute error ($MAE$), and coefficient of determination ($r^2$) between the ground truth migrations, $\mathbf{T}$, and the model estimated migrations, $\mathbf{\hat{T}}$. These metrics are calculated on the origin destination migration matrices, hence we refer to them as ``metrics on full matrix'' in Table \ref{tbl:all_results}. \begin{description} % \item[Common Part of Commuters ($CPC$)] This metric directly compares numbers of travelers between the predicted and ground truth matrices. It will be $0$ when the two matrices have no entries in common, and $1$ when they are identical. \begin{equation} CPC(\mathbf{T},\mathbf{\hat{T}}) = \frac{2 \sum_{i,j=1}^{n} min(T_{ij}, \hat{T}_{ij})}{\sum_{i,j=1}^{n} T_{ij} + \sum_{i,j=1}^{n} \hat{T}_{ij}} \end{equation} \item[Common Part of Commuters Distance Variant ($CPC_d$)] This metric measures how well a predicted migration matrix recreates trips at the same distances as the ground truth data. In this definition, $N$ is a histogram where a bin $N_k$ contains the number of migrants that travel between $2k-2$ and $2k$ kilometers. It will be $0$ when the two matrices do not have any migrations at the same distance, and $1$ when all fall within the same distances. \begin{equation} CPC_d(\mathbf{T},\mathbf{\hat{T}}) = \frac{2 \sum_{k=1}^\infty min(N_k, \hat{N}_k)}{\sum_{k=1}^\infty N_k + \sum_{k=1}^\infty \hat{N}_k} \end{equation} \item[Mean absolute error ($MAE$)] This is a standard error measure, the average absolute difference between the predicted and ground truth values. Here, smaller values represent smaller errors in terms of number of migrants. \begin{equation} MAE(\mathbf{T},\mathbf{\hat{T}}) = \frac{1}{n}\sum_{i,j=1}^{n} (T_{ij} - \hat{T}_{ij}) \end{equation} \item[Coefficient of determination ($r^2$)] This score measures the goodness of fit between a set of predictions and the ground truth values. This score ranges from $1$, in a perfect fit, to arbitrarily negative values as a fit becomes worse, and is $0$ when the predictions are equivalent to the expectation of the ground truth values. \begin{equation} r^2(\mathbf{T},\mathbf{\hat{T}}) = 1 - \frac{\sum_{i,j=1}^n (T_{ij} - \hat{T}_{ij})^2}{\sum_{i,j=1}^n (T_{ij} - \bar{T})^2} \end{equation} \end{description} We also measure the aggregate model performance of predicting the aggregate incoming migrants per county. We calculate the $MAE$ and $r^2$ between $T_{:i} = \sum_{j=1}^n T_{ji}$ and $\hat{T}_{:i} = \sum_{j=1}^n \hat{T}_{ji}$ and call them ``metrics on incoming migrants vector'' in Table \ref{tbl:all_results}. The results of these experiments are shown in Table \ref{tbl:all_results}. Here, the ANN model outperforms the other models in the large \textbf{unaffected counties} to \textbf{unaffected counties} task and \textbf{all counties} to \textbf{all counties} tasks. In these two tasks the ANN model has a large amount of training data to exploit, and performs best in the matrix $MAE$, matrix $r^2$, and incoming migrants $MAE$ metrics, and second best in the remaining metrics. The gravity model with power law decay performs best in terms of $CPC$ and $CPC_d$ on both tasks, however fails to appropriately model the pairwise flows with a matrix $r^2$ score of near 0. Similarly, the extended radiation model performs slightly better than the ANN model in terms of incoming migrants $r^2$ (and is indeed the only traditional migration model with a positive matrix $r^2$ metric), but performs significantly worse than the ANN model in all other dimensions. In the \textbf{affected counties} to \textbf{unaffected counties} task, the best performing model is not obvious. Here, the matrix $MAE$ and $r^2$ values are identical to the incoming migrants $MAE$ and $r^2$ values due to the leave-one-out cross validation method - the test set in each split are all possible migrations originating from a single county. We observe that the extended radiation model performs the best in terms of $CPC$ and $r^2$ scores, however with wildly different best parameter values between cross-validation splits (shown in the large standard deviation of the best $\beta$ value). The ANN model is performing best in terms of $CPC_d$ and $MAE$, but poorly on average considering the average $r^2$ score near 0. In the testing splits where the model is performing poorly it has overfit to the longer distance migrations observed in 6 out of the 7 \textbf{affected counties} and is unable to capture the shorter distance migrations from the held out county. As the extended radiation model captures the \textit{general} behavior of human migration (with a single parameter), it does not overfit in this case. The best $\beta$ parameters in the \textbf{affected counties} to \textbf{unaffected counties} task are significantly different than in the other two tasks, showing how the structure of migration may be different under extreme flooding events. \begin{table}[tp] \centering \resizebox{\textwidth}{!}{% \begin{tabular}{@{}l|r|rrrr|rr@{}} \toprule & \multicolumn{1}{l|}{} & \multicolumn{4}{c|}{\textbf{Metrics on full matrix}} & \multicolumn{2}{c}{\begin{tabular}[c]{@{}c@{}}\textbf{Metrics on incoming} \\ \textbf{migrants vector}\end{tabular}} \\ \midrule \multicolumn{1}{c|}{\begin{tabular}[c]{@{}c@{}}\textbf{Unaffected to Unaffected}\\ Best $\alpha$ = 0.0325 (0.0017)\end{tabular}} & \multicolumn{1}{c|}{Best $\beta$} & \multicolumn{1}{c}{CPC} & \multicolumn{1}{c}{CPC$_d$} & \multicolumn{1}{c}{MAE} & \multicolumn{1}{c|}{R2} & \multicolumn{1}{c}{MAE} & \multicolumn{1}{c}{R2} \\ \midrule \multicolumn{1}{l|}{Extended Radiation} & \multicolumn{1}{r|}{\begin{tabular}[c]{@{}r@{}}0.3537\\ (0.0172)\end{tabular}} & \begin{tabular}[c]{@{}r@{}}0.4926\\ (0.0027)\end{tabular} & \begin{tabular}[c]{@{}r@{}}0.7134\\ (0.0436)\end{tabular} & \begin{tabular}[c]{@{}r@{}}1.0495\\ (0.3343)\end{tabular} & \multicolumn{1}{r|}{\begin{tabular}[c]{@{}r@{}}0.1493\\ (0.1027)\end{tabular}} & \begin{tabular}[c]{@{}r@{}}287.7557\\ (84.2073)\end{tabular} & \textbf{\begin{tabular}[c]{@{}r@{}}0.8588\\ (0.0328)\end{tabular}} \\ \multicolumn{1}{l|}{Radiation} & \multicolumn{1}{r|}{n/a} & \begin{tabular}[c]{@{}r@{}}0.4327\\ (0.0109)\end{tabular} & \begin{tabular}[c]{@{}r@{}}0.6426\\ (0.0611)\end{tabular} & \begin{tabular}[c]{@{}r@{}}1.1816\\ (0.3992)\end{tabular} & \multicolumn{1}{r|}{\begin{tabular}[c]{@{}r@{}}-0.6345\\ (0.1548)\end{tabular}} & \begin{tabular}[c]{@{}r@{}}326.2592\\ (89.5871)\end{tabular} & \begin{tabular}[c]{@{}r@{}}0.7773\\ (0.0647)\end{tabular} \\ \multicolumn{1}{l|}{Gravity Exponential Decay} & \multicolumn{1}{r|}{\begin{tabular}[c]{@{}r@{}}0.2124\\ (0.3938)\end{tabular}} & \begin{tabular}[c]{@{}r@{}}0.3058\\ (0.1549)\end{tabular} & \begin{tabular}[c]{@{}r@{}}0.3988\\ (0.2089)\end{tabular} & \begin{tabular}[c]{@{}r@{}}1.4387\\ (0.5281)\end{tabular} & \multicolumn{1}{r|}{\begin{tabular}[c]{@{}r@{}}-3.7014\\ (4.3919)\end{tabular}} & \begin{tabular}[c]{@{}r@{}}373.4170\\ (109.4751)\end{tabular} & \begin{tabular}[c]{@{}r@{}}0.5119\\ (0.1897)\end{tabular} \\ \multicolumn{1}{l|}{Gravity Power Law Decay} & \multicolumn{1}{r|}{\begin{tabular}[c]{@{}r@{}}2.6955\\ (0.0829)\end{tabular}} & \textbf{\begin{tabular}[c]{@{}r@{}}0.5530\\ (0.0244)\end{tabular}} & \textbf{\begin{tabular}[c]{@{}r@{}}0.8000\\ (0.0867)\end{tabular}} & \begin{tabular}[c]{@{}r@{}}0.9421\\ (0.3589)\end{tabular} & \multicolumn{1}{r|}{\begin{tabular}[c]{@{}r@{}}-0.0928\\ (0.8651)\end{tabular}} & \begin{tabular}[c]{@{}r@{}}341.2711\\ (128.2462)\end{tabular} & \begin{tabular}[c]{@{}r@{}}0.5883\\ (0.1862)\end{tabular} \\ \midrule \multicolumn{1}{l|}{ANN Model} & \multicolumn{1}{r|}{n/a} & \begin{tabular}[c]{@{}r@{}}0.5406\\ (0.0244)\end{tabular} & \begin{tabular}[c]{@{}r@{}}0.7321\\ (0.0500)\end{tabular} & \textbf{\begin{tabular}[c]{@{}r@{}}0.9272\\ (0.3413)\end{tabular}} & \multicolumn{1}{r|}{\textbf{\begin{tabular}[c]{@{}r@{}}0.3687\\ (0.0587)\end{tabular}}} & \textbf{\begin{tabular}[c]{@{}r@{}}265.3275\\ (86.9390)\end{tabular}} & \begin{tabular}[c]{@{}r@{}}0.8435\\ (0.0360)\end{tabular} \\ \midrule \multicolumn{1}{c|}{\begin{tabular}[c]{@{}c@{}}\textbf{Affected to Unaffected}\\ Best $\alpha$ = 0.1674 (0.0326)\end{tabular}} & \multicolumn{1}{c|}{Best $\beta$} & \multicolumn{1}{c}{CPC} & \multicolumn{1}{c}{CPC$_d$} & \multicolumn{1}{c}{MAE} & \multicolumn{1}{c|}{R2} & \multicolumn{1}{c}{MAE} & \multicolumn{1}{c}{R2} \\ \midrule \multicolumn{1}{l|}{Extended Radiation} & \multicolumn{1}{r|}{\begin{tabular}[c]{@{}r@{}}0.2403\\ (0.2478)\end{tabular}} & \textbf{\begin{tabular}[c]{@{}r@{}}0.4882\\ (0.0790)\end{tabular}} & \begin{tabular}[c]{@{}r@{}}0.5149\\ (0.0820)\end{tabular} & \begin{tabular}[c]{@{}r@{}}9.2474\\ (12.5452)\end{tabular} & \multicolumn{1}{r|}{\textbf{\begin{tabular}[c]{@{}r@{}}0.5719\\ (0.1355)\end{tabular}}} & - & - \\ \multicolumn{1}{l|}{Radiation} & \multicolumn{1}{r|}{n/a} & \begin{tabular}[c]{@{}r@{}}0.4692\\ (0.1104)\end{tabular} & \begin{tabular}[c]{@{}r@{}}0.4820\\ (0.1087)\end{tabular} & \begin{tabular}[c]{@{}r@{}}11.7799\\ (16.6184)\end{tabular} & \multicolumn{1}{r|}{\begin{tabular}[c]{@{}r@{}}-0.2258\\ (0.7936)\end{tabular}} & - & - \\ \multicolumn{1}{l|}{Gravity Exponential Decay} & \multicolumn{1}{r|}{\begin{tabular}[c]{@{}r@{}}0.0047\\ (0.0002)\end{tabular}} & \begin{tabular}[c]{@{}r@{}}0.3889\\ (0.1446)\end{tabular} & \begin{tabular}[c]{@{}r@{}}0.4184\\ (0.1544)\end{tabular} & \begin{tabular}[c]{@{}r@{}}9.7246\\ (12.4281)\end{tabular} & \multicolumn{1}{r|}{\begin{tabular}[c]{@{}r@{}}0.3068\\ (0.1964)\end{tabular}} & - & - \\ \multicolumn{1}{l|}{Gravity Power Law Decay} & \multicolumn{1}{r|}{\begin{tabular}[c]{@{}r@{}}1.6250\\ (0.0772)\end{tabular}} & \begin{tabular}[c]{@{}r@{}}0.3742\\ (0.1288)\end{tabular} & \begin{tabular}[c]{@{}r@{}}0.4038\\ (0.1414)\end{tabular} & \begin{tabular}[c]{@{}r@{}}10.3996\\ (13.7485)\end{tabular} & \multicolumn{1}{r|}{\begin{tabular}[c]{@{}r@{}}0.3081\\ (0.1584)\end{tabular}} & - & - \\ \midrule \multicolumn{1}{l|}{ANN Model} & \multicolumn{1}{r|}{n/a} & \begin{tabular}[c]{@{}r@{}}0.4231\\ (0.1275)\end{tabular} & \textbf{\begin{tabular}[c]{@{}r@{}}0.5366\\ (0.2240)\end{tabular}} & \textbf{\begin{tabular}[c]{@{}r@{}}9.0060\\ (10.0530)\end{tabular}} & \multicolumn{1}{r|}{\begin{tabular}[c]{@{}r@{}}-0.0640\\ (0.5563)\end{tabular}} & - & - \\ \midrule \multicolumn{1}{c|}{\begin{tabular}[c]{@{}c@{}}\textbf{All to All}\\ Best $\alpha$ = 0.0326 (0.0017)\end{tabular}} & \multicolumn{1}{c|}{Best $\beta$} & \multicolumn{1}{c}{CPC} & \multicolumn{1}{c}{CPC$_d$} & \multicolumn{1}{c}{MAE} & \multicolumn{1}{c|}{R2} & \multicolumn{1}{c}{MAE} & \multicolumn{1}{c}{R2} \\ \midrule \multicolumn{1}{l|}{Extended Radiation} & \multicolumn{1}{r|}{\begin{tabular}[c]{@{}r@{}}0.3544\\ (0.0169)\end{tabular}} & \begin{tabular}[c]{@{}r@{}}0.4923\\ (0.0031)\end{tabular} & \begin{tabular}[c]{@{}r@{}}0.7145\\ (0.0436)\end{tabular} & \begin{tabular}[c]{@{}r@{}}1.0551\\ (0.3254)\end{tabular} & \multicolumn{1}{r|}{\begin{tabular}[c]{@{}r@{}}0.1467\\ (0.1012)\end{tabular}} & \begin{tabular}[c]{@{}r@{}}290.3686\\ (81.5585)\end{tabular} & \textbf{\begin{tabular}[c]{@{}r@{}}0.8553\\ (0.0323)\end{tabular}} \\ \multicolumn{1}{l|}{Radiation} & \multicolumn{1}{r|}{n/a} & \begin{tabular}[c]{@{}r@{}}0.4326\\ (0.0107)\end{tabular} & \begin{tabular}[c]{@{}r@{}}0.6422\\ (0.0600)\end{tabular} & \begin{tabular}[c]{@{}r@{}}1.1875\\ (0.3895)\end{tabular} & \multicolumn{1}{r|}{\begin{tabular}[c]{@{}r@{}}-0.6341\\ (0.1644)\end{tabular}} & \begin{tabular}[c]{@{}r@{}}329.6186\\ (86.5392)\end{tabular} & \begin{tabular}[c]{@{}r@{}}0.7718\\ (0.0656)\end{tabular} \\ \multicolumn{1}{l|}{Gravity Exponential Decay} & \multicolumn{1}{r|}{\begin{tabular}[c]{@{}r@{}}0.2124\\ (0.3938)\end{tabular}} & \begin{tabular}[c]{@{}r@{}}0.3062\\ (0.1551)\end{tabular} & \begin{tabular}[c]{@{}r@{}}0.3997\\ (0.2091)\end{tabular} & \begin{tabular}[c]{@{}r@{}}1.4451\\ (0.5209)\end{tabular} & \multicolumn{1}{r|}{\begin{tabular}[c]{@{}r@{}}-3.7402\\ (4.4424)\end{tabular}} & \begin{tabular}[c]{@{}r@{}}376.9256\\ (107.9260)\end{tabular} & \begin{tabular}[c]{@{}r@{}}0.5066\\ (0.1895)\end{tabular} \\ \multicolumn{1}{l|}{Gravity Power Law Decay} & \multicolumn{1}{r|}{\begin{tabular}[c]{@{}r@{}}2.6936\\ (0.0816)\end{tabular}} & \textbf{\begin{tabular}[c]{@{}r@{}}0.5522\\ (0.0240)\end{tabular}} & \textbf{\begin{tabular}[c]{@{}r@{}}0.7997\\ (0.0863)\end{tabular}} & \begin{tabular}[c]{@{}r@{}}0.9479\\ (0.3511)\end{tabular} & \multicolumn{1}{r|}{\begin{tabular}[c]{@{}r@{}}-0.1035\\ (0.8609)\end{tabular}} & \begin{tabular}[c]{@{}r@{}}343.9989\\ (125.8610)\end{tabular} & \begin{tabular}[c]{@{}r@{}}0.5822\\ (0.1836)\end{tabular} \\ \midrule \multicolumn{1}{l|}{ANN Model} & \multicolumn{1}{r|}{n/a} & \begin{tabular}[c]{@{}r@{}}0.5445\\ (0.0237)\end{tabular} & \begin{tabular}[c]{@{}r@{}}0.7367\\ (0.0556)\end{tabular} & \textbf{\begin{tabular}[c]{@{}r@{}}0.9461\\ (0.3451)\end{tabular}} & \multicolumn{1}{r|}{\textbf{\begin{tabular}[c]{@{}r@{}}0.3632\\ (0.0633)\end{tabular}}} & \textbf{\begin{tabular}[c]{@{}r@{}}275.1929\\ (90.9055)\end{tabular}} & \begin{tabular}[c]{@{}r@{}}0.8357\\ (0.0440)\end{tabular} \\ \bottomrule \end{tabular}% } \caption{Comparison of different models in predicting three different classes of migrations. Averaged cross-validation results are shown with standard deviations in parenthesis. In all columns except $MAE$, higher values represent better performance. Best performing number is bolded in each column, independently for each class of migration.} \label{tbl:all_results} \end{table} \section{Effects of modeling climate migrants separately} \begin{figure}[thp] \centering \includegraphics[width=0.8\textwidth]{dl_difference_ablation_high_2100.jpg} \includegraphics[width=0.8\textwidth]{extrad_difference_ablation_high_2100.jpg} \caption{Difference in incoming migrants per county between migrations generated with separately trained models for affected and unaffected migrant behavior and migrations generated with a single model for both. The \textbf{top} panel shows ANN results, and the \textbf{bottom} panel shows Extended radiation model results. All results are for the High 2100 sea level rise/population scenario. In both sets of results the model that \textit{does not} separately capture affected and unaffected migrant behavior predicts more incoming migrants to coastal counties.} \label{fig:ablation} \end{figure} In the main text we argue that persons living in areas that will be affected by SLR will be exposed to increased climatic pressures and will be forced to migrate elsewhere. Furthermore, we train an ANN model to separately model these migrations based on historic migration patterns from counties that were especially affected by Hurricanes Katrina and Rita. Here, we show the effect that separately modeling these migrations has on our results by simulating the same set of conditions with a single migration model for both types of migrants under both the ANN and Extended Radiation migration models. Figure \ref{fig:ablation} shows the difference in number of incoming migrants per county between the results using separate migration models and the results using a single migration model for the 1.8m SLR scenario. Notably, in both sets of results, when climate driven migrations are \textit{not} modeled separately, then more migrations to coastal areas are predicted. One explanation for this pattern is that the probability of migration for climate driven migrations does not decay as strongly with distance as in standard migrations (e.g. the calibrated scale parameter in the Extended Radiation model is lower for climate migrants, which decreases the impact of intervening opportunities), therefore displaced migrants ``see'' distant population centers as attractive of a destination as nearby coastal destinations (which will usually be more populated than surrounding areas). One discrepancy between the two sets of results is how, in the Extended radiation model results, separately modeled affected and unaffected migration behavior results in more predicted migrations to urban centers, while the corresponding ANN results show fewer predicted migrations to urban centers. This could also be due to the different emphasis on distance in predicting migration probabilities. \section{Algorithmic description of the Joint Model} In the main text we give a high-level outline of our joint migration/SLR modeling framework and provide a detailed implementation using small-area population projections, Digital Coast SLR estimates, and ANN based migration models. Here we describe the steps necessary for implementing the joint model from an algorithmic standpoint. Our joint model consists of two modules: the sea level rise module and the migration module, which use the \texttt{SLR} and \texttt{MIGRATION} functions respectively. The joint model is independent from the specific implementation of these two functions, and method used to partition features between the affected and unaffected areas in a zone. A sea level rise model, $SLR(\theta_i, x)$, is a function that takes as input a spatial zone, $\theta_i$, and an amount of SLR, $x$, and outputs the portion of the zone that is flooded under the given amount of SLR. This model should also be used to inform a \textit{splitting} procedure that is needed to partition the zone into flooded and unflooded areas. This procedure can be done with accessory sub-zone resolution data. For example, in our implementation we use spatially explicit flooding data intersected with census block groups in order to partition counties into flooded and unflooded areas. We describe a migration model, $MIGRATION(\boldsymbol{\theta^S}, \boldsymbol{\theta^D})$, as a function that takes as input a list of `source' zones of length $n$, $\boldsymbol{\theta^S}$, and list of `destination' zones of length $m$, $\boldsymbol{\theta^D}$, and outputs a migration matrix $\mathbf{T} \in \mathbb{N}_0^{n \times m}$, where an entry $T_{ij}$ represents the number of migrants that travel from $\theta_i^S$ to $\theta_j^D$. Our joint model requires two different migration models, $MIGRATION_C$ to handle climate migrations and $MIGRATION_S$, to handle standard migrations. Note that these models \textit{can} be the same in the absence of an appropriate model to handle climate migrations (with the added assumption that climate migrants will behave as standard migrants). Given a list of zones of length $n$, $\boldsymbol{\theta}$, where each individual zone $\theta_i$ has some number of features associated with it, and an amount of SLR, $x$, our modeling process is as follows: \begin{itemize} \item Create two empty lists, $\boldsymbol{\theta}^A$ and $\boldsymbol{\theta}^U$. $\boldsymbol{\theta}^A$ will contain an entry for each zone that represents the `affected' (or flooded) portion of that zone and $\boldsymbol{\theta}^U$ will contain an entry for each `unaffected' portion. Note that $|\boldsymbol{\theta}^A|$ will equal $|\boldsymbol{\theta}^U|$. \item For each zone, $\theta_i$, calculate $SLR(\theta_i, x)$, and `split' the zone into two separate areas accordingly: \begin{itemize} \item If $SLR(\theta_i, x) > 0$, then partition the zone into two areas, $\theta_i^A$ and $\theta_i^U$. $\theta_i^A$ will contain features of the land that is flooded in the zone, and $\theta_i^U$ will contain the remaining proportions. Append $\theta_i^A$ to $\boldsymbol{\theta}^A$, and append $\theta_i^U$ to $\boldsymbol{\theta}^U$. \item If $SLR(\theta_i, x) = 0$, then the zone is not affected by SLR. Append $\theta_i$ to $\boldsymbol{\theta}^U$, and append an entry representing a \texttt{null} area to $\boldsymbol{\theta}^A$ in order to keep the lists balanced. \end{itemize} \item Calculate the migration matrix $\mathbf{T'} = MIGRATION_C(\boldsymbol{\theta^A}, \boldsymbol{\theta^U})$. This migration matrix will have a size of $n \times n$ and will describe how the people from `flooded' areas will migrate to safe areas. \item Calculate the migration matrix $\mathbf{T''} = MIGRATION_S(\boldsymbol{\theta^U}, \boldsymbol{\theta^U})$. This migration matrix will also have a size of $n \times n$ and will give how the people from `unaffected' areas will migrate to other `unaffected' areas. Note that we do not consider the case where migrants destinations are in $\boldsymbol{\theta^A}$ because of the assumption that people can not migrate to flooded portions of zones. \item Output the final migration matrix $\mathbf{T} = \mathbf{T'} + \mathbf{T''}$ \end{itemize} \bibliographystyle{ieeetr}
{'timestamp': '2019-04-24T02:07:12', 'yymm': '1904', 'arxiv_id': '1904.10160', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.10160'}
arxiv
\section{Introduction} Wireless powered communication network (WPCN) is an emerging networking paradigm that attracts extensive research attentions recently \cite{2014:Ju,2015:Bi,2017:Niyato,2016:Bi}. Specifically, the communications of wireless devices (WDs) in WPCN are powered by means of wireless power transfer \cite{2016:Bi1}, which can effectively extend the battery lifetime of low-power WDs, such as sensors and radio frequency identification tags. Compared with the traditional battery-powered communication networks, WPCN does not require manual battery replacement/charging, and thus can achieve more stable throughput performance and lower network operating costs \cite{2015:Bi}. Therefore, WPCN has found extensive applications, such as sensor networks,internet of things system, unmanned aerial vehicles communications \cite{2018:Xie}, and mobile edge computing \cite{2018:Bi}, etc. Because of the scarcity of wireless spectrum, WPCNs often need to operate in the same bandwidth with conventional wireless communication system, which may cause strong interference to each other. To tackle this problem, cognitive radio technology \cite{2009:Goldsmith} has been introduced to WPCN. Specifically, a cognitive WPCN (CWPCN) enables the WPCN (as a secondary system) to transmit opportunistically in the licensed spectrum of conventional primary wireless system \cite{2013:Lee3} \cite{2014:Hoang}. For efficient utilization of spectrum resources, Lee \cite{2015:Lee1} considered a secondary WPCN both underlaid and overlaid with a primary system. In particular, in an underlay case, the secondary system is not aware of the channel state information (CSI) of the primary system, thus it can only restrict the interference power generated to the primary system, i.e., the interference temperature constraint (ITC). In comparison, in an overlay case, the secondary system knows the primary system's CSI, e.g., via primary system's feedback, so it can control its own transmission to meet the data rate requirement of the primary system, i.e., the primary rate constraint. Under the ITC, Cheng \cite{2017:Cheng} considered a CWPCN that uses a harvest-then-transmit protocol based on time division multiple access for secondary system and proposed an algorithm that optimizes the secondary system user throughput fairness. Yin \cite{2017:Yin} designed a cooperative spectrum sharing model of a CWPCN, which exploits the cooperation between primary and secondary systems to maximize the energy efficiency of secondary users. Xu \cite{2017:Xu} investigated cooperative resource allocation in a multi-carrier CWPCN, which the primary user harvests energy from the information signals transmitted by the secondary users. In WPCN, it is common to use hybrid access point (HAP) that transfers wireless energy to a cluster of low-power WDs and receives wireless information from them. It is well-known that a severe ``doubly-near-far" user unfairness problem exists in WPCN that the data rates of users that are farther away from HAP is significantly lower than that of the adjacent users \cite{2014:Ju}. User cooperation is a commonly used method to enhance the user fairness issue, which in fact can potentially benefit all the participating users. Intuitively, the remote users can improve the link quality to the HAP with the help from near users. While for near users, the data rate loss caused by helping the others can be made up from the longer energy transfer time allocated by the HAP, because now the far users need less time to harvest energy when cooperation is applied. A number of practical user cooperation has been proposed for WPCNs \cite{2017:Liang,2014:Ju1,2015:Chen,2017:Zhong,2017:Yuan}. For instance, a two-user cooperation WPCN was firstly investigated by Ju \cite{2014:Ju1}, where the authors showed that close-to-HAP user can improve its data rate by helping the far user, achieving a win-win situation. Subsequently, Zhong \cite {2017:Zhong} considered a pair of distributed end users first harvesting energy from an energy node, and then transmit jointly their information to a destination node using distributed space-time code. Further, Chen \cite{2015:Chen} first presented a harvest-then-cooperate protocol in WPCNs for a three-node reference model, and latter extended to a general multiple user cooperation scenario. In addition, Yuan \cite{2017:Yuan} proposed a multi-antenna enabled cluster-based cooperation, where one WD acts as the cluster head (CH), e.g., selecting the one nearest to the cluster center, to relay the information transmission of the other cluster members (CMs, the remaining ones except the CH) to the HAP. Meanwhile, energy beamforming (EB) technique \cite{2014:Liu} is used at the multi-antenna HAP to achieve directional energy transfer for balancing the energy consumptions of different WDs. It showed that the cluster-based cooperation can effectively enhance both the user fairness and spectral efficiency of WPCN, compared to some other representative benchmark cooperation methods. Therefore, we adopt the cluster-based cooperative WPCN in this paper. However, the use of cooperation and EB, although effective in enhancing the throughput of WPCN, may also cause strong interference to the primary link. The achievable throughput performance of cluster-based cooperation is not known when interference is taken into consideration. As shown in Fig. 1, we consider in this paper a WPCN underlaid to a primary communication link. The WDs in the WPCN use a cluster-based cooperation to transmit to the HAP. The detailed contributions of this paper are as follows. \begin{itemize} \item We consider a time division multiple access based protocol that firstly the HAP broadcasts energy to a cluster of WDs and then the WDs transmit their information back to the HAP using the harvested energy. Here, one of the WDs is selected as the CH that relays the messages of the other WDs. EB is applied at the HAP for both enhancing the energy transfer efficiency in the downlink and the spectral efficiency in the uplink information transmission. We derive the throughput of each individual WD under the interference from the primary communication link. Meanwhile, to control the interference to the primary link in the underlay scenario, we consider a peak ITC such that the interference generated by the WPCN is limited to a prescribed threshold. \item To improve the user fairness among the WDs, we jointly optimize the beamforming of the HAP, the transmit time allocation among the HAP and the WDs, and the transmit power allocation of the WDs to maximize the minimum data rate achievable among the overall WDs (the max-min throughput) under the peak ITC. We show that the non-convex joint optimization problem can be transformed to a convex one and subsequently solved using off-the-shelf convex algorithms. \item We simulate under practical network setups and show that the proposed method can significantly enhance the throughput fairness of the WPCN under the peak ITC compared to the representative benchmark method. In particular, the advantageous performance is most evident under stringent ITC requirement. Intuitively, this is because the cluster-based cooperation can effectively control its interference to the primary system by reducing the communication range, and thus the transmit power, when the secondary users transmit their information. \end{itemize} The rest of the paper is organized as follows. In Section II, we introduce the system model and the cluster-based cooperation method. We analyze the secondary throughput performance in Section III. In Section IV, we formulate the maxi-min throughput optimization problem and transform the non-convex problem into the convex one. In Section V, simulation results are provided to evaluate the performance of the proposed cooperation, followed by concluding remarks in Section VI. \begin{figure} \centering \includegraphics[width=3.4in]{1.eps}\\ \caption{A schematic of the considered cluster-based cooperation in an underlay CWPCN, where W$_0$ is the CH and the rest $(N-1)$ WDs are CMs.} \label{101} \end{figure} \section{System Model} \subsection{Channel Model} As shown in Fig.1, we consider a CWPCN coexisting with a primary link consisting of a pair of single-antenna primary transmitter (PT) and primary receiver (PR). The CWPCN consists of one HAP and $N$ WDs. The HAP is assumed to be equipped with $M$ antennas and the WDs each has a single antenna. The HAP can implement EB in the downlink for directional energy transfer and MRC in the uplink to enhance spectrum efficiency \cite{2014:Liu}. Specifically, the HAP broadcasts wireless energy and receives wireless information transmission (WIT) to/from the WDs. We assume that both the primary and secondary systems operate over the same frequency band. For the secondary system, a time division duplexing circuit is implemented at both the HAP and the WDs to separate the energy and information transmissions. Meanwhile, the primary communication link is active throughout the considered time interval. In this paper, one of the WDs is selected as the CH that helps relay the WIT of the other CMs, e.g., selecting the WD closest to the cluster center. The impact of CH selection method will be discussed in simulations. Without loss of generality, the CH is denoted by W$_0$, and the CMs are denoted by W$_1$, $\cdots$, W$_{N-1}$. All the channels are assumed to be independent and reciprocal and follow quasi-static flat-fading, such that all the channels coefficients remain constant during each block transmission time, denoted by $T$, but can vary in different blocks. The channel coefficient vector between the HAP and W$_{i}$ is denoted by $\mathbf{a}_{i} \in\mathcal{C}^{M\times1}$, where $\mathbf{a}_{i} \sim \mathcal{CN} (\mathbf{0}, \sigma_{i}^2 \mathbf{I})$ and $\sigma_i^2$ denotes the average channel gain, $i=0,1,\cdots, N-1$. Besides, the channel coefficients between the $j$-th CM and the CH are denoted by $c_j\sim \mathcal{CN} ( 0, \delta_{j}^2)$, $j=1,\cdots, N-1$. Meanwhile, the channel coefficients, between the PT and PR, and between the PT and HAP, are denoted by $l_{TR} \sim \mathcal{CN} ( 0, \delta_{TR}^2)$ and $l_{TH} \sim \mathcal{CN} ( 0, \delta_{TH}^2)$, respectively. Denote $\mathbf{b} \in\mathcal{C}^{M\times1}$ as the interference channel coefficients between the HAP and PR, where $\mathbf{b} \sim \mathcal{CN} (\mathbf{0}, \sigma^2 \mathbf{I})$. Let $l_{iR}\sim \mathcal{CN} (0, \delta_{iR}^2)$ and $l_{iD}\sim \mathcal{CN} (0, \delta_{iD}^2)$, $i=0,1,\cdots, N-1$, represent the interference channel coefficient vector between the PR and WDs, and between the PT and WDs, respectively. Here, we use $h_{i} \triangleq |\mathbf{a}_{i}|^2$, $g_i\triangleq |c_i|^2$, $h_{iR}\triangleq |l_{iR}|^2$, $h_{iD}\triangleq |l_{iD}|^2$, $h_{TR}\triangleq |l_{TR}|^2$, and $h_{TH}\triangleq |l_{TH}|^2$ to denote the corresponding channel gains, where $|\cdot|$ denotes the 2-norm operator. \begin{figure} \centering \includegraphics[width=3.5in]{2.eps}\\ \caption{The proposed cluster-based cooperation protocol in U-CWPCN.} \label{102} \end{figure} \subsection{Cluster-based Cooperation Protocol} The operation of the proposed cluster-based cooperation in a transmission time block is illustrated in Fig.~\ref{102}. At the beginning of a transmission block, channel estimation (CE) is performed within a fixed duration $\tau_{0}$. Through CE, we assume that the HAP has the knowledge of CSI inside the WPCN, i.e., $\mathbf{a}_i$'s, and $c_i$'s, which are acquired from pilot transmissions and CSI feedback from the WDs. Besides, we assume that the operating protocol of the primary system (including the transmit power of the PT and PR) is known, e.g., through a separate control channel. Therefore, the interference channels between the primary system and the secondary WPCN can be estimated by the HAP and WDs (like in \cite{2017:Cheng}), e.g., by estimating the pilot signals sent by the PT and PR. However, the channel between the PT and PR is private information in our underlay framework and unknown by the HAP. After the CE stage, the HAP coordinates the secondary WPCN to operate in three phases. In the first phase with time duration $\tau_{1}$, the HAP broadcasts wireless energy to the WDs. In the second phase, the $N-1$ CMs transmit its own information in turn to the CH, where the $i$-th CM transmits for $\tau_{2,i}$ amount of time, $i=1, \cdots, N-1$. In the third phase, the CH transmits the decoded messages of the $N-1$ CMs along with its own message to the HAP, where the time taken to transmit the $i$-th WD's message is denoted as $\tau_{3,i}$, $i=0,1,\cdots, N-1$. Evidently, the time allocations during a transmission block satisfy the following inequality \begin{equation} \label{1} \tau_0+\tau_1+\sum^{N-1}_{i=1}\tau_{2,i}+\sum^{N-1}_{i=0}\tau_{3,i} \leq T.\\ \end{equation} Notice that $\tau_0$ is a known parameter. Without loss of generality, we assume $T=1$ throughout this paper. \subsection{Cognitive Underlay Transmissions} All WDs are assumed to have no fixed power supplies, and thus need to replenish energy by harvesting RF energy from the HAP's wireless energy transmission in the downlink; the harvested energy at each WD is stored in a rechargeable battery and then used for its WIT in the uplink. The PT and the HAP are assumed to have stable power supplies. We assume that the PT transmits with constant power $P_p$, and the HAP's maximum transmit power is $P_{max}$. With the CSI knowledge at the HAP, it jointly optimizes the system resource allocation within the WPCN, e.g., transmission durations, power, and the beamforming design, and coordinate the transmissions of all the WDs. Specifically, we can maximize the throughput of the secondary WPCN, meanwhile guaranteeing that the resulting interference generated to the primary link is below a predefined threshold. In the following, we formulate the throughput maximization problem and propose an efficient method to solve it optimally. \section{Secondary Throughput Analysis} In this section, we derive the throughput of each secondary WD achieved by the proposed cluster-based cooperation protocol. The results will be used in the next section to optimize the throughput fairness of the U-CWPCN. \subsection{Phase I: Energy Transfer} During the WET phase, the HAP adopts EB to deliver different levels of wireless power to distributed WDs to balance their different energy consumptions. Specifically, in the first phase of time $\tau_1$, the HAP transmits $\mathbf{w}(t) \in C^{M\times 1}$ random energy signals on the $M$ antennas, where the transmit power of HAP is constrained by $P_H$ as \begin{equation} \label{2} E\left[|\mathbf{w}(t)|^2\right] = \text{tr}\left(E\left\{\mathbf{w}(t)\mathbf{w}(t)^H\right\}\right) \triangleq \text{tr}(\mathbf{Q}) \leq P_H, \end{equation} where $\text{tr}(\cdot)$ denotes the trace of a square matrix, $(\cdot)^H$ denotes the complex conjugate operator, and $\mathbf{Q}\succeq \mathbf{0}$ is the beamforming matrix. Then, the received energy by the $i$-th WD is \cite{2015:Lee1} \begin{equation} \label{3} H_{i}= \eta \tau_1 \cdot \text{tr}(\mathbf{A}_i\mathbf{Q}), \end{equation} here, $\mathbf{A}_i \triangleq \mathbf{a}_i\mathbf{a}_i^H$ and $\eta\in(0,1]$ denotes the energy harvesting efficiency, which is assumed equal for all the WDs. Accordingly, the residual energy of the $i$-th WD is \begin{equation} \label{4} E_{i} = \min\left\{E_{0,i} + H_i, E_{max}\right\}, \end{equation} where, $E_{0,i}$ is the known residual energy at the beginning of the current time slot, and $E_{max}$ is the battery capacity. In the meantime, the interference power to the primary receiver is $\text{tr}(\mathbf{bb}^H \mathbf{Q})\triangleq \text{tr}(\mathbf{H}_{HR} \mathbf{Q})$, where $\mathbf{H}_{HR} \triangleq \mathbf{bb}^H$. \subsection{Phase II: Intra-cluster Transmissions} In general, the CMs only use a part of the harvested energy to transmit to the CH. The transmit power of the $i$-th CM $P_{2, i}$ is restricted by \begin{equation} \label{5} \tau_{2,i} P_{2, i} + e_i \leq E_{i},\ i=1,\cdots,N-1, \end{equation} where $e_i$ denotes the fixed circuit energy consumption of the $i$-th CM within a transmission block, e.g., on performing sensing and data processing. The received signal at the CH is expressed as \begin{equation} \label{6} \begin{aligned} y_{0,i}^{(2)}(t)= c_i \sqrt{P_{2, i}}s_{i}^{(2)}(t)+ n_{i}^{(2)}(t), \end{aligned} \end{equation} where $n_{i}^{(2)}(t)$ includes the receiver noise $N_0$ and the interference signal generated from the primary link $h_{0D}P_p$. The total interference plus noise power $E\left[|n_{i}^{(2)}(t)|^2\right]=N_0+h_{0D}P_p$. In this paper, we consider the worst-case interference in terms of the achievable data rate given the noise power, where the interference distribution is cyclic symmetric complex Gaussian \cite{2006:Cover}. Then, the CH can decode the $i$-th CM's message at the minimum achievable rate given by \footnote{For simplicity of illustration in the following analysis, we use the term achievable data rate to represent the minimum achievable data rate by treating the interference signal as cyclic symmetric complex Gaussian.} \begin{equation} \label{7} \begin{aligned} R_{i}^{(2)}=\tau_{2,i} \log_{2}\left(1 + \frac{g_i P_{2,i}}{N_0 + h_{0D}P_p}\right),i=1,\cdots,N-1. \end{aligned} \end{equation} Meanwhile, the HAP can also overhear the transmission of the CMs, such that it receives \begin{equation} \label{8} \mathbf{y}_{H,i}^{(2)}(t) = \mathbf{a}_i \sqrt{P_{2, i}}s_{i}^{(2)}(t) + \mathbf{n}_{H,i}^{(2)}(t), \end{equation} during the $i$-th CM's transmission, where $i=1,\cdots,N-1$, and $\mathbf{n}_{H,i}^{(2)}(t) \sim \mathcal{CN}\left(\mathbf{0},(N_0+h_{TH}P_p)\mathbf{I}\right)$, $h_{TH} P_p$ is the interference power to the HAP from the primary link. Meanwhile, the interference power caused by the $i$-th WD to the primary system is $h_{iR} P_{2,i}$, $i=1,\cdots, N-1$. \subsection{Phase III: Cluster-to-HAP Transmission} After decoding the CMs' messages, the CH transmits the $(N-1)$ CMs' messages along with its own message one by one to the HAP. Let $P_{3,i}$ denote the power used to transmit the $i$-th WD's message. Then, the received signal of the $i$-th WD's message at the HAP is \begin{equation} \label{9} \mathbf{y}_{i}^{(3)}(t) = \mathbf{a}_0 \sqrt{P_{3,i}}s_{i}^{(3)}(t) + \mathbf{n}_{i}^{(3)}(t), \end{equation} where $\mathbf{n}_{i}^{(3)}(t) \sim \mathcal{CN}\left(\mathbf{0},(N_0+h_{TH}P_p)\mathbf{I}\right)$, and $i=0,1,\cdots, N-1$. The total energy consumed by CH is upper bounded by its harvested energy \begin{equation} \label{10} \sum^{N-1}_{i=0}\tau_{3,i} P_{3,i} + e_0 \leq E_{0}, \end{equation} where $e_0$ is the total energy consumed by the other modules of the CH within a transmission block, such as the central processing unit, and the passive power on circuitry. We assume that the HAP uses MRC to maximize the received signal to interference plus noise power ratio (SINR), where the combiner output SINR of the $i$-th WD is \begin{equation} \label{11} \begin{aligned} \gamma^{(3)}_{i} = \frac{|\mathbf{a}_0|^2 P_{3,i}}{N_0 + h_{TH} P_p}=\frac{h_0 P_{3,i}}{N_0 + h_{TH} P_p}, \ i=0,\cdots, N-1, \end{aligned} \end{equation} where the numerator denotes the useful signal power for the $i$-th user, and the denominator is the sum of the interference power generated by the primary link and the receiver noise power. At the same time, the interference from the CH to the PR is $h_{0R} P_{3,i}$, $i=0,\cdots, N-1$, owing to CH's WIT. We denote the time allocation as $\pmb{\tau}=[\tau_1, \tau_{2,1}, \cdots, \tau_{2,N-1}, \tau_{3,0}, \tau_{3,1}, \cdots, \tau_{3,N-1}]'$, and the transmit power as $\pmb{P}=[P_{2,1}, \cdots, P_{2,N-1}, P_{3,0}, P_{3,1}, \cdots, P_{3,N-1}]'$, where $[\cdot]'$ denotes the transpose operator. Then, the data rate of the CH at the HAP is \begin{equation} \label{12} \begin{aligned} R_{0}(\pmb{\tau}, \pmb{P})= \tau_{3,0} \log_{2}\left(1 + \frac{h_0 P_{3,0}}{N_0 + h_{TH} P_p}\right). \end{aligned} \end{equation} For each CM's message, however, is received in both the second and third phases. In this case, the HAP can jointly decode each CM's message across two phases at a rate given by \cite{2014:Ju} \begin{equation} \label{13} R_{i}(\pmb{\tau}, \pmb{P}) = \min\left\{R_{i}^{(2)}(\pmb{\tau}, \pmb{P}), V_{i}^{(2)}(\pmb{\tau}, \pmb{P}) + V_{i}^{(3)}(\pmb{\tau}, \pmb{P})\right\}, \end{equation} where $i=1, \cdots,N-1$, and $R_{i}^{(2)}(\pmb{\tau}, \pmb{P})$ is given in (\ref{7}). $V_{i}^{(2)}(\pmb{\tau}, \pmb{P})$ denotes the information that can be extracted by the HAP from the received signal in (\ref{6}) (in the second phase) using an optimal MRC receiver, which is given by \begin{equation} \label{14} \begin{aligned} V_{i}^{(2)}(\pmb{\tau}, \pmb{P})=\tau_{2,i} \log_{2}\left(1 + \frac{ h_i P_{2,i}}{N_0 + h_{TH}P_p}\right), \end{aligned} \end{equation} $V_{i}^{(3)}(\pmb{\tau}, \pmb{P})$ denotes the achievable rates of the transmissions from CH to the HAP, which are given by \begin{equation} \label{15} \begin{aligned} V_{i}^{(3)}(\pmb{\tau}, \pmb{P})=\tau_{3,i} \log_{2}\left(1+\frac{h_0 P_{3,i}}{N_0 + h_{TH} P_p}\right). \end{aligned} \end{equation} An important performance metric of an U-CWPCN is the minimum achievable secondary throughput among all the WDs (the max-min throughput), i.e., \begin{equation} \label{16} S = \min_{0 \leq i \leq N-1} R_i, \end{equation} which reflects the throughput fairness. The max-min throughput has important practical implication. For instance, the max-min throughput in a wireless sensor network reflects the accuracy of data reported by the ``bottleneck" sensor, which can directly affect the overall sensing accuracy of the network. In the next section, we formulate the max-min throughput optimization problem and solve it optimally. In fact, our proposed method in this paper can also be extended to maximize (weighted) sum throughput of the WDs, which is omitted for brevity. \section{Max-min Throughput Optimization Under the peak interference constraint} \subsection{Problem Formulation} In this subsection, we require that the interference power from the WPCN to the PR is no larger than a predefined threshold, denoted by $I_{max}$. Therefore, the interference constraints of the three phases are, respectively, \begin{equation} \label{17} \text{tr}(\mathbf{h}_{HR} \mathbf{Q}) \leq I_{max}. \end{equation} \begin{equation} \label{18} I^{CM}_i= h_{iD} P_{2,i} \leq I_{max}, \ i=1,\cdots, N-1. \end{equation} \begin{equation} \label{19} I^{CH}_i=h_{0D} P_{3,i} \leq I_{max}, \ i=0,\cdots, N-1. \end{equation} Under this setup, we are interested in maximizing the minimum (max-min) throughput of all WDs in each block, by jointly optimizing the EB $\mathbf{Q}$, the time allocation $\pmb {\tau}$, and the transmit power allocation $\pmb P$, i.e., \begin{equation} \label{20} \begin{aligned} (P1):\; &\max_{\pmb {\tau, P}, \mathbf{Q}}& &S= \min_{0 \leq i \leq N-1} R_i(\pmb {\tau, P})\\ &\text{\;\;s. t.}& & (1), (2),(4),(5),(10),(17),(18), \rm{and}\; (19), \\ & & & \tau_{1} \geq 0, \; \tau_{2,i} \geq 0, \;i=1,\cdots, N-1,\\ & & & \tau_{3,i} \geq 0,\;P_{3,i}\geq 0,\;i=0,1,\cdots, N-1,\\ & & & \mathbf{Q} \succeq \mathbf{0}.\\ \end{aligned} \end{equation} By introducing an auxiliary variable $\overline S$, problem (\ref{20}) can be equivalently transformed into its epigraphic form, \begin{equation} \small \label{21} \begin{aligned} (P2):\; &\max_{\pmb {\tau}, \pmb{P}, \mathbf{Q}, \overline S} & & \overline S\\ &\text{\;\;\;\;s. t.} & & (1), (2),(4),(5),(10),(17),(18), \rm{and}\; (19), \\ & & &\pmb {\tau} \geq \mathbf{0}, \; {\pmb {P} \geq \mathbf{0}},\; \mathbf{Q} \succeq \mathbf{0}, \;\overline S \geq 0,\\ & & & R_{0}(\pmb{\tau}, \pmb{P}) \geq \overline S,\\ & & &V_{i}^{(2)}(\pmb{\tau}, \pmb{P}) + V_{i}^{(3)}(\pmb{\tau}, \pmb{P}) \geq \overline S,\\ & & &R_{i}^{(2)}(\pmb{\tau}, \pmb{P}) \geq \overline S, i=1,\cdots, N-1.\\ \end{aligned} \end{equation} Notice that both the data rates expressions of intra-cluster communication (i.e., $R_{i}^{(2)}(\pmb{\tau}, \pmb{P})$ and $V_{i}^{(2)}(\pmb{\tau}, \pmb{P}))$ and cluster-to-HAP communication (i.e., $R_{0}(\pmb{\tau}, \pmb{P})$ and $V_{i}^{(3)}(\pmb{\tau}, \pmb{P})$) are not concave functions. Besides, the LHS of (\ref{5}) is also not a convex function. Therefore, (P2) is a non-convex problem in its current form, which lacks of efficient optimal algorithms. In the next subsection, we transform the above non-convex problem into a convex one through introducing some auxiliary variables, which can then be solved using some known convex optimization techniques, e.g., interior point method \cite{2004:Boyd}. \subsection{Convex Transformation of (P2)} The basic idea of the convex transformation is to introduce auxiliary variables to replace the multiplicative terms in (5) and (10). Specifically, we first define $\Psi_{2,i} \triangleq \frac{\tau_{2,i}P_{2,i}}{\eta}$, $i=1,\cdots, N-1$ and $\pmb {\Psi}=\left[\Psi_{2,1}, \cdots, \Psi_{2,N-1}\right]'$. Accordingly, (\ref{5}) can be re-written as a function of $\pmb {\Psi}$, \begin{equation} \small \label{22} {\Psi}_{2,i} + \frac{e_{i}}{\eta} \leq \frac{E_i}{\eta}, i=1,\cdots, N-1. \end{equation} Meanwhile, $R_{i}^{(2)}(\pmb{\tau}, \pmb{P})$ and $V_{i}^{(2)}(\pmb{\tau}, \pmb{P})$ in (\ref{7}) and (\ref{14}) can be re-expressed as functions of $\pmb {\tau}$ and $\pmb {\Psi}$, respectively, \begin{equation} \label{23} R_{i}^{(2)}(\pmb{\tau},\pmb {\Psi})=\tau_{2,i} \log_{2}\left(1+ \overline{\rho}_i \frac {{\Psi}_{2,i}}{\tau_{2,i}}\right), \end{equation} \begin{equation} \small \label{24} V_{i}^{(2)}(\pmb{\tau},\pmb {\Psi})=\tau_{2,i} \log_{2}\left(1+ \rho_i \frac {{\Psi}_{2,i}}{\tau_{2,i}}\right), \end{equation} where $\overline {\rho}_i\triangleq\eta \frac{g_i}{N_0 + h_{0D}P_p}$, $\rho_i\triangleq\eta \frac{h_i}{N_0 + h_{TH}P_p}$ are parameters, and $i=1,\cdots,N-1$. Subsequently, we define $\theta_{3,i}\triangleq\frac{\tau_{3,i} P_{3,i}}{\eta}$, $i=0,1,\cdots,N-1$, and $\pmb {\theta}=\left[\theta_{3,0}, \cdots, \theta_{3,N-1}\right]'$, then $R_{0}(\pmb{\tau}, \pmb{P})$ and $V_{i}^{(3)}(\pmb{\tau}, \pmb{P})$ in (\ref{12}) and (\ref{15}) can be reformulated as functions of $\pmb {\tau}$ and $\pmb {\theta}$, i.e., \begin{equation} \label{25} \begin{aligned} R_{0}(\pmb {\tau, \theta})= \tau_{3,0} \log_{2}\left(1 + \rho_0 \frac { \theta_{3,0}}{\tau_{3,0}}\right), \end{aligned} \end{equation} \begin{equation} \label{26} \begin{aligned} V_{i}^{(3)}(\pmb {\tau, \theta})=\tau_{3,i} \log_{2}\left(1+\rho_0 \frac { \theta_{3,i}}{\tau_{3,i}}\right), \end{aligned} \end{equation} where $i=1,\cdots,N-1$, and $\rho_0\triangleq\eta \frac{h_0}{N_0 + h_{TH} P_p}$. Next, we define $\mathbf{W} \triangleq \tau_1\mathbf{Q} \succeq \mathbf{0}$. With the sum transmit power constraint in (\ref{3}), we have \begin{equation} \label{27} \text{tr}\left(\mathbf{W}\right) = \text{tr}\left(\tau_1\mathbf{Q}\right) \leq \tau_1 P_H. \end{equation} Accordingly, we change the variables as \begin{equation} \label{28} z_i \triangleq \tau_1\text{tr}\left(\mathbf{A}_i\mathbf{Q}\right) = \text{tr}\left(\mathbf{A}_i\mathbf{W}\right), \end{equation} for $i=0,\cdots, N-1$. Thus, the power constraint given in (\ref{10}) can be re-expressed as \begin{equation} \label{29} \begin{aligned} \sum^{N-1}_{i=0}\theta_{3,i} + \frac{e_{0}}{\eta} \leq z_0. \end{aligned} \end{equation} At the same time, (\ref{17}), (\ref{18}), and (\ref{19}) can be reformed as, respectively, \begin{equation} \label{30} \text{tr}(\mathbf{h}_{HR} \mathbf{W}) \leq \tau_1 I_{max}, \end{equation} \begin{equation} \label{31} \begin{aligned} \Psi_{2,i} \leq \tau_{2,i} \frac{I_{max}}{\overline{\phi}_i}, i=1,\cdots,N-1, \end{aligned} \end{equation} \begin{equation} \label{32} \begin{aligned} \theta_{3,i} \leq \tau_{3,i} \frac{I_{max}}{\phi_0},i=0,1,\cdots,N-1, \end{aligned} \end{equation} where $\phi_0 = \eta h_{0D}$, and $\overline{\phi}_i = \eta h_{iD}$, $i=1,\cdots,N-1$. Accordingly, problem (\ref{21}) can be transformed into the following equivalent problem. \begin{equation*} \label{33} \begin{aligned} (P3): \\ \max_{\pmb {\tau}, \pmb{\theta}, \pmb {\Psi}, \pmb z, \overline S, \mathbf{W}\succeq \mathbf{0}} & \overline S\\ \text{s. t.\quad \quad \;} & (22), (28),(29),(30),(31),\rm{and}\;(32), \\ & \pmb {\tau} \geq \mathbf{0}, \; \pmb{\theta} \geq 0, \; \overline S \geq 0,\;\mathbf{W} \succeq \mathbf{0},\;\text{tr}(\mathbf{W}) \leq \tau_1 P_H,\\ & R_{0}(\pmb{\tau, \theta}) \geq \overline S,\;V_{i}^{(2)}(\pmb{\tau},\pmb {\Psi}) + V_{i}^{(3)}(\pmb{\tau, \theta}) \geq \overline S,\\ & R_{i}^{(2)}(\pmb{\tau},\pmb{\Psi}) \geq \overline S,\ i=1,\cdots, N-1,\\ & \tau_0+\tau_1+\sum^{N-1}_{i=1}\tau_{2,i}+\sum^{N-1}_{i=0}\tau_{3,i} \leq 1,\\ & E_i \leq E_{0,i} + \eta z_i, \ i=0,1,\cdots,N-1,\\ & E_i \leq E_{max}, \ i=0,1,\cdots,N-1.\\ \end{aligned} \end{equation*} Furthermore, our proposed method in this paper can also be extended to be under the average ITC, which is omitted for brevity. From \cite{2017:Yuan}, both $R^{(2)}_{i}$'s in (\ref{23}) and $V_{i}^{(2)}$'s in (\ref{24}) are concave functions in $(\pmb{\tau},\pmb{\Psi})'$. Besides, $R_{0}$ in (\ref{25}) and $V_{i}^{(3)}$'s in (\ref{26}) are also concave functions in $(\pmb {\pmb{\tau}, \theta})'$. Therefore, the first three sets of constraints in (P3) are convex constraints. Meanwhile, the rest of the constraints are affine. It follows that the objective and all the constraints of (P3) are convex, therefore (P3) is a convex optimization problem, which can be efficiently solved by off-the-shelf optimization algorithms, e.g., interior point method \cite{2004:Boyd}. Let's denote the optimal solution to (P3) as $\left\{\pmb {\tau}^*, \pmb{\theta}^*, \pmb {\Psi}^*, \pmb z^*, \overline S^*, \mathbf{W}^*\right\}$. Then, the optimal solution $\pmb {\tau}^*$ of (P1) is the same as that in (P3). The optimal $\mathbf{Q}^*$ and $\pmb{P}^*$ of (P1) can be restored by letting $\mathbf{Q}^* = \mathbf{W}^*/\tau_1^*$, $P_{2,i} = \eta \pmb {\Psi}^* / \tau_{2,i}^*$ ($\ i = 1,\cdots,N-1$), and $P_{3,i}^* = \eta\theta_{3,i}^*/\tau_{3,i}^*$ ($\ i = 0,\cdots,N-1$). \begin{figure} \centering \includegraphics[width=3.4in]{3.eps}\\ \caption{The deployment of HAP and WDs in C-WPCN, where $N=15$.} \label{106} \end{figure} \subsection{Benchmark Methods} For performance comparison, we consider two representative benchmark methods, i.e., independent transmission and hybrid transmission. For simplicity, we assume that the time spent on CE ($\tau_0$) is equal for all the schemes. \subsubsection{Independent transmission} In this case, all the WDs transmit independently to the HAP following the harvest-then-transmit protocol in \cite{2015:Chen}. Specifically, the HAP first uses EB to perform WET for $\tau_1'$ amount of time for the WDs to harvest. Then, the WDs take turns to transmit their messages to the HAP, where each WD's transmission takes $\tau_{2,i}'$ ($i'=0,1,\cdots, N-1$) amount of time. Meanwhile, the HAP uses MRC to decode the message of each user.\footnote{Spatial multiplexing is not used at the HAP as the number of WDs is often much larger than the number of antennas at the HAP. Otherwise, either strong interference or high computational complexity will be induced when the WDs transmit to the HAP simultaneously.} Then, the data rate of the $i$-th user is denoted by \begin{equation} \label{34} R_{i}'(\pmb{\tau}', \mathbf{P'}) = \tau_{2,i}' \log_{2}\left(1 + \frac{h_i P_{2,i}'}{N_0 + h_{TH}P_p}\right), \ \end{equation} where $i=0,\cdots,N-1$, $\pmb{\tau}' \triangleq[\tau_1', \tau_{2,0}', \cdots, \tau_{2,N-1}']'$, and $\pmb{P}' \triangleq[P_{2,0}', \cdots, P_{2,N-1}']'$. Then, the max-min throughput can be obtained by solving the following problem \begin{equation} \small \label{36} \begin{aligned} &\max_{\mathbf{\pmb {\tau}'}, \pmb{P}', \mathbf{Q}'}& &\min_{i=0,\cdots, N-1} R_{i}'(\pmb{\tau}', \pmb{P}')\\ &\text{s. t.}& & \tau_0'+\tau_1'+\sum^{N-1}_{i=0}\tau_{2,i}' \leq 1, \\ & & & \tau_{1}' \geq 0,\;\tau_{2,i}'\geq 0,\;\mathbf{Q}' \succeq \mathbf{0},\;\text{tr}(\mathbf{Q'}) \leq P_H,\\ & & & \text{tr}(\mathbf{h}_{HR} \mathbf{Q'}) \leq I_{max}, \; h_{iD} P_{2,i}' \leq I_{max}, \\ & & & \tau_{2,i}' P_{2,i}' + e_i \leq E_i', \; E_i' \leq E_{max}, \\ & & & E_i' \leq E_{0,i}' + \eta \tau_1'\text{tr}(\mathbf{A}_i \mathbf{Q'}),\; i=0,\cdots, N-1.\\ \end{aligned} \end{equation} The optimal solution to the above problem can be similarly obtained as (P3), where the detailed algorithm is omitted for simplicity. \begin{figure} \centering \subfigure[]{ \label{figa} \includegraphics[width=3.4in]{4a.eps}} \subfigure[]{ \label{fig:subfig:b} \includegraphics[width=3.4in]{4b.eps}} \subfigure[]{ \label{fig:subfig:c} \includegraphics[width=3.4in]{4c.eps}} \caption{Simulation setup. (a) Case 1. (b) Case 2. (c) Case 3.}\Large \label{107} \end{figure} \subsubsection{Hybrid transmission} In a hybrid transmission scheme, we separate the WDs into two groups. One group of WDs perform the cluster-based cooperation as proposed in this paper, while the WDs in the other group transmit independently to the HAP. In particular, we first determine the CH as the WD that is closest to the cluster center. Then, a WD chooses to transmit directly to the HAP if its channel to the HAP is better than that to the CH, otherwise, it operates under the previously proposed cooperation method. Specifically, the two groups transmit in orthogonal time to avoid interference. The transmission time and power of each WD, either transmitting independently to the HAP or cooperatively via the CH, is jointly optimized with those of the HAP. The detailed expressions are omitted here due to the page limit. \begin{figure} \centering \subfigure[]{ \label{figa} \includegraphics[width=3.4in]{5a1.eps}} \subfigure[]{ \label{fig:subfig:b} \includegraphics[width=3.4in]{5b1.eps}} \caption{The maxi-min and sum throughput performance versus the maximum HAP transmit power $P_{max}$ for Case 1. (a) Max-min throughput performance. (b) Sum throughput performance.}\Large \label{108} \end{figure} \begin{figure} \centering \subfigure[]{ \label{figa} \includegraphics[width=3.4in]{6a.eps}} \subfigure[]{ \label{fig:subfig:b} \includegraphics[width=3.4in]{6b.eps}} \caption{The maxi-min and sum throughput performance versus the maximum HAP transmit power $P_{max}$ for Case 2. (a) Max-min throughput performance. (b) Sum throughput performance.}\Large \label{109} \end{figure} \section{Simulation Results} In this section, we evaluate the performance of the proposed cooperation method. In all simulations, we set the noise power as $N_{0} = 10^{-12}$ W and the receiver energy harvesting efficiency as $\eta= 0.5$. Unless otherwise stated, it is assumed that the number of antennas at HAP is $M=5$ and the threshold of the peak interference temperature constraint is $I_{max} = -60$ dBm (three orders of magnitude larger than the noise power, and in fact, later we discuss the performance of the system with different thresholds as shown in Figure 8.) in the considered bandwidth $P_p=0.1$ W and $P_{max}=3$ W. The mean channel gain between any two nodes (HAP, WD, PT and PR) follows a path-loss model. Without loss of generality, we assume the circuit energy consumption of all the devices are zero, i.e., $e_i = 0$, $i=0,\cdots,N-1$. For instance, let $d_{H,i}$ denote the distance between the HAP and the $i$-th WD, then the average channel gain $\delta_{H,i}^2 = G_A(\frac{3\times 10^8}{4\pi d_{H,i}f_c})^{\alpha}$, where $G_A$ denotes the antenna gain, $\alpha$ denotes the path-loss factor and $f_{c}$ denotes the carrier frequency. Likewise, $d_{PT,i}$, $d_{PR,i}$, $d_{CH,i}$, $d_{PR,H}$, $d_{PT,H}$, and $d_{PT,PR}$ denote the distance between the PT and the $i$-th WD, the PR and the $i$-th WD, CH and the $i$-th CM, the PR and the HAP, PT and HAP, and PT and PR, respectively, and their corresponding average channel gain model is similar to the above. We set $G_A=4$, $\alpha =3$, and $f_{c}=915$ MHz. Besides, $15$ WDs are uniformly distributed within a circle with radius equal to $r=3$ meters, and the circle's center is $d=6$ meters away from the HAP as shown in Fig. 3. Each point in the figures of all the simulations is an average of $100$ independent WD placements, while the performance of each placement is averaged over 1000 Rayleigh fading realizations \cite{2016:Bi2}. For simplicity, we assume the coordinates of the circle's center is $(0,0)$. In all simulations, the WD that is closest to the cluster center is selected as the cluster head. The placements of the primary and secondary systems considered in this paper are shown in Fig. 4. We assume that the PT and PR are located 200 meters (m) apart. Meanwhile, we consider three different representative locations of the secondary WPCN. In Case 1, the C-WPCN is located much closer to the PR than PT (the HAP's coordinate of the C-WPCN is 202 m from the PT) as shown in Fig. 4(a); in Case 2, the distance from PT to C-WPCN and from PR to C-WPCN is equal (i.e., 100 m) as shown in Fig. 4(b); while in Case 3, the C-WPCN is located much closer to the PT (with a distance of 30 m from the PT) as shown in Fig. 4(c). \begin{figure} \centering \subfigure[]{ \label{figa} \includegraphics[width=3.4in]{7a.eps}} \hspace{1in} \subfigure[]{ \label{fig:subfig:b} \includegraphics[width=3.4in]{7b.eps}} \caption{The maxi-min and sum throughput performance versus the maximum HAP transmit power $P_{max}$ for Case 3. (a) Max-min throughput performance. (b) Sum throughput performance.}\Large \label{110} \end{figure} \begin{figure} \centering \subfigure[]{ \label{figa} \includegraphics[width=3.4in]{8a.eps}} \hspace{1in} \subfigure[]{ \label{fig:subfig:b} \includegraphics[width=3.4in]{8b.eps}} \caption{Performance comparison of the different transmission schemes when $I_{max}$ varies in Case 1. The figures above and below compare the max-min throughput and sum throughput, respectively.}\Large \label{111} \end{figure} \begin{figure} \centering \subfigure[]{ \label{figa} \includegraphics[width=3.4in]{9a.eps}} \hspace{1in} \subfigure[]{ \label{fig:subfig:b} \includegraphics[width=3.4in]{9b.eps}} \caption{Performance comparison of the different transmission schemes when the number of WDs $N$ varies in Case 1. The figures above and below compare the max-min throughput and sum throughput, respectively.}\Large \label{112} \end{figure} In Fig. 5, we compare the max-min throughput performance of four methods, i.e., the proposed cluster-based cooperation (CC) selecting the CH as the WD closest to the cluster center, the CC selecting the CH as the WD closest to the HAP, the hybrid transmission, and independent transmission (IT) when the maximum transmit power of the HAP ($P_{max}$) varies. Meanwhile, we also consider two different cases where the transmit power of the PT $P_p=0.1$ W and $P_p=1$ W, respectively. The max-min throughput performance under the placement of Case 1 is shown in Fig. 5(a). We see that under both $P_p=0.1$ and $1$ W, the performance of the proposed CC method with CH closest to the cluster center is the best. Particularly, with $P_p=0.1$ W and $P_p=1$ W, it achieve on average around 26\% and 21\% higher max-min throughput than those of the CC with CH closest to the HAP, around 35\% and 32\% higher max-min throughput than those of the hybrid transmission, and around 56\% and 50\% higher max-min throughput than those of IT, respectively. Furthermore, Fig. 5(b) shows the sum throughput comparison under different $P_p$ in Case 1. It is observed that the proposed CC with CH closest to the cluster center performs the best. Specifically, it has on average 26\% and 23\% higher sum throughput than CC with CH closest to the HAP, around 35\% and 32\% higher sum throughput than those of the hybrid transmission, and average 56\% and 50\% higher sum throughput than IT with $P_p=0.1$ W and $P_p=1$ W, respectively. For simplicity of illustration, in the following simulations, we compare only the performance of the proposed CC method with CH closest to the cluster center (simply referred to as the CC method in the following) and the IT method, which is one commonly considered multi-user transmission method in related literatures. In Fig. 6 and 7, we investigate the secondary max-min and sum throughput of CC and IT when $P_{max}$ changes for Case 2 and Case 3, respectively. Due to the closer distance between the primary and secondary systems, the secondary system suffers stronger interference from the primary network. Therefore, the data rates of the secondary network in Case 2 and 3 is worse than that in Case 1. In Case 3 when the two networks are only 30 meters apart, the achievable max-min throughput is only around 1/30 of that in Case 1. However, the proposed CC method still significantly outperforms the IT method in all simulation setups. Specifically, in Fig. 6(a), for Case 2 where the WPCN is equally distant from the PT and PR, the proposed CC method achieves on average around 56\% higher max-min throughput than the IT method when $P_p=0.1$ W and 58\% higher when $P_p = 1$ W. In terms of sum throughput performance in Fig. 6(b), the performance advantage of the proposed CC method is around 56\% and 58\% when $P_p=0.1$ W and 1 W, respectively. In Fig. 7, when the WPCN is closely located to the PT as in Case 3, the proposed CC method achieves on average around 61\% higher max-min throughput than the IT method when $P_p=0.1$ W and 68\% higher when $P_p = 1$ W. The sum throughput performance advantage is on average around 60\% and 68\% when $P_p=0.1$ and $1$ W, respectively. Overall, we can observe from Figs. 5-7 that the proposed CC method can achieve both higher user fairness and spectral efficiency in all the three representative network placements. In Fig. 8, we plot the max-min and sum throughput performance of the proposed CC and IT when the threshold of the peak interference temperature constraint $I_{max}$ varies. For simplicity of illustration, we consider only the network setups in Case 1, while similar performance comparisons are also observed for Case 2 and 3. Here we consider the number of WDs $N=15$. We can see from Fig. 8 that the maxi-min and sum throughput of both the proposed CC and IT increase with $I_{max}$, i.e., higher tolerance of interference. Besides, both the max-min throughput and the sum throughput performance of the proposed CC method greatly outperform those of the IT method. Specifically, in Fig. 8(a), the proposed CC method achieves on average around one time higher max-min throughput than that of IT. Furthermore, in Fig. 8(b), the proposed CC has on average one time higher sum throughput than IT. Meanwhile, we see that the cluster-based C-WPCN is most effective under stringent ITC requirement, i.e., low $I_{max}$. For example, the performance advantage is more than one time for max-min throughput and one time for sum throughput when $I_{max}= -70$ dBm. Intuitively, this is because the cluster-based cooperation can effectively control its interference to the primary system by reducing the communication range, and thus the transmit power, when the secondary users transmit their information. In addition, Fig. 9 evaluates the throughput performance when the number of WDs $N$ increases from 15 to 30 in Case 1. On one hand, we can see from Fig. 9(a) that the max-min throughput decreases with the number of WDs for both schemes. This is because in general each WD is allocated with shorter transmission time as $N$ increases, especially for the time allocated to the worst-performing WD due to the doubly-near-far unfairness issue. In an extreme case, when the number of the WDs approaches infinity, the transmission time allocated to the worst-performing WD approaches zero, thus resulting close-to-zero max-min throughput. Nonetheless, we see that the proposed CC method achieves around 100\% higher max-min throughput than the benchmark IT method. On the other hand, we can observe in Fig. 9(b) that the sum-throughput increases with $N$ due to the benefit of multi-user diversity, although the data rates of some individual WDs may decrease. In particular, the proposed CC method achieves on average around one time higher sum throughput than the IT method. This indicates that a tradeoff exists between each individual user's throughput and the aggregate network throughput. In practice, the number of WDs should be kept moderate, to guarantee satisfying per-user throughput performance. Nonetheless, we can still observe significant performance gain of the proposed method over the benchmark method. \vspace{-2ex} \section{Conclusions} In this paper, we have considered a cluster-based cooperation method in a WPCN underlaid to a primary communication link. Specifically, a CH user is appointed to relay the information transmission of the other cluster members to the HAP. Energy beamforming is applied at the multi-antenna HAP to balance the different energy consumption rates of the WDs. To control the potential severe interference, the secondary WPCN generates to the primary system, we optimize the system performance under an interference temperature constraint. By jointly optimizing the energy beamforming design, the transmit time allocation among the HAP and the WDs, and the transmit power allocation of the CH. Extensive simulations under practical network setups show that the proposed method can significantly enhance user fairness and spectrum efficiency compared to the benchmark method, meanwhile guaranteeing the quality of transmission in the primary network, especially under stringent ITC requirement.
{'timestamp': '2019-04-23T02:26:00', 'yymm': '1904', 'arxiv_id': '1904.09863', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.09863'}
arxiv
\subsection{Graph Learning} Quite a few approaches for semi-supervised node classification have been proposed in recent years, most of which fall into three categories: label-smoothness based methods, graph embedding based methods, and convolutional neural network methods. \textbf{Label-smoothness based methods.} This class of methods are based on the assumption that neighboring nodes tend to have the same labels. Belkin et al. \cite{belkin2006manifold} deploy a parameterized classifier in Reproducing Kernel Hilbert Space (RKHS), which is inductive and naturally handles unobserved instances. Weston et al. \cite{weston2012deep} propose a deep semi-supervised embedding approach, which extends the regularization and imposes stronger constraints on a neural network. \textbf{Graph embedding based methods.} This class of approaches are inspired by the skip-gram model \cite{mikolov2013distributed}. Perozzi et al. \cite{perozzi2014deepwalk} propose a DeepWalk model, which learns embeddings via the prediction of the local neighborhood of nodes, sampled from random walks on the graph. Yang et al. \cite{yang2016revisiting} alleviate the optimization step of DeepWalk by injecting label information in the process of learning embeddings. Tran et al. \cite{tran2018learning} present a novel autoencoder architecture (LoNGAE) capable of learning a joint representation of both local graph structure and available node features for the multitask learning of link prediction and node classification. \textbf{Convolutional neural network methods.} This family of approaches typically employ CNNs, GCNs, or their variants. Kipf et al. \cite{kipf2016semi} propose a simplified graph convolution model for semi-supervised learning by employing a first-order approximation of spectral filters. Monti et al. \cite{monti2017geometric} propose mixture model (MoNet) and provide a unified generalization of CNN architectures on graphs. Velickovic et al. \cite{velivckovic2018graph} present Graph Attention Networks (GATs) for semi-supervised learning by designing an attention layer. Xu et al. \cite{xu2018graph} present graph wavelet neural network (GWNN) to implement efficient convolution on graph data, which takes graph wavelets instead of the eigenvectors of the graph Laplacian as a set of basis. \subsection{Problem Formulation of Graph Learning} We propose to exploit the learning of the direct representation of the underlying graph, i.e., the adjacency matrix. In particular, we pose a MAP estimation of the adjacency matrix, which leads to graph learning from the GLR, sparsity constraint and properties of a valid adjacency matrix. \subsubsection{MAP Estimation of Graph Adjacency Matrices} We first formulate a MAP estimation problem for the optimal graph adjacency matrix $\mathbf{\hat{A}}$: given the observed graph signal $\vec{x}$, find the most probable graph $\mathbf{\hat{A}}$, \begin{equation} \vec{\tilde{A}}_\text{MAP}(\mathbf{x}) = \arg \max_{\mathbf{\hat{A}}} \ f(\vec{x} \mid \mathbf{\hat{A}})g(\mathbf{\hat{A}}), \label{eq:final_map} \end{equation} where $f(\vec{x} \mid \mathbf{\hat{A}})$ is the likelihood function, and $g(\mathbf{\hat{A}})$ is the prior probability distribution of $\mathbf{\hat{A}}$. The likelihood function $f(\vec{x} \mid \mathbf{\hat{A}})$ is the probability of obtaining the observed graph signal $\vec{x}$ given the graph $\mathbf{\hat{A}}$, while the prior probability distribution $g(\mathbf{\hat{A}})$ provides the prior knowledge of $\mathbf{\hat{A}}$. The likelihood and prior functions are discussed in order as follows. \begin{figure*}[t] \centering \includegraphics[width=\textwidth]{framework.pdf} \caption{\textbf{The architecture of the proposed GLNN for semi-supervised node classification.} Our proposed network takes a feature map and a ground-truth graph (optional) as the input in the training phase. We then employ the Graph Learning Layer to obtain an optimal graph, and feed the learned graph and feature map to Graph Convolution Layers to generate the output node classification scores. We add classification loss and the proposed graph learning loss together for backward propagation.} \label{fig:pipeline} \end{figure*} \subsubsection{Proposed Prior Probability Distribution} The prior probability distribution $g(\mathbf{\hat{A}})$ provides the prior knowledge of $\mathbf{\hat{A}}$. We propose the prior knowledge of an adjacency matrix from two aspects: 1) the sparsity constraint $g_s(\mathbf{\hat{A}})$; 2) the property constraint of a valid adjacency matrix $g_p(\mathbf{\hat{A}})$. Since the two prior constraints are independent, we have \begin{equation} g(\mathbf{\hat{A}}) = g_s(\mathbf{\hat{A}})g_p(\mathbf{\hat{A}}). \label{eq:prior_distribution} \end{equation} We elaborate on the sparsity constraint and property constraint separately as follows. \textbf{Sparsity Constraint.} We pose a sparsity constraint on $\mathbf{\hat{A}}$. This is based on the observation that the similarity relationship in real-world data is often sparse. Also, this constraint avoids data overfitting by capturing prominent similarities. Mathematically, we define the sparsity prior as \begin{equation} g_s(\mathbf{\hat{A}}) = \exp \left( -\lambda_1 \| \mathbf{\hat{A}} \|_1 \right), \label{eq:sparsity_constraint} \end{equation} where $\| \cdot \|_1$ denotes the $l_1$-norm of a matrix, and $\lambda_1$ is a weighting parameter. \textbf{Property Constraint.} The properties of a valid normalized adjacency matrix include: \begin{itemize} \item Symmetry. In our model, we only consider undirected graphs, in which any edge $(x_i, x_j) \in \mathcal{E}$ is identical to the edge $(x_j, x_i) \in \mathcal{E}$. Hence, the corresponding adjacency matrix $\mathbf{\hat{A}}$ is symmetric. The mathematical description is \begin{equation} \mathbf{\hat{A}}^\top = \mathbf{\hat{A}}. \end{equation} \item Normalized. We consider normalized adjacency matrices in order to avoid numerical instabilities and exploding or vanishing gradients when used in a deep neural network architecture. The mathematical description is \begin{equation} \mathbf{\hat{A}}\mathbf{1} = \mathbf{1}, \end{equation} where $\vec{1}$ denotes the vector with all the elements equal to one. \item Loopless. Since it is often unnecessary to link a node with itself such as in a citation network or social network, we consider graphs without self loop. The mathematical description is \begin{equation} \text{tr}(\mathbf{\hat{A}}) = 0, \end{equation} where $\text{tr}(\cdot)$ denotes the trace of a matrix. \end{itemize} Combining the above properties, we propose the following prior probabilistic distribution of $\mathbf{\hat{A}}$: \begin{equation} \begin{aligned} g_p(\mathbf{\hat{A}}) = \exp \left( \right. & -\lambda_2 \| \mathbf{\hat{A}}^\top - \mathbf{\hat{A}} \|_F^2 \\ & \left.-\lambda_3 \| \mathbf{\hat{A}}\mathbf{1} - \mathbf{1} \|_F^2 -\lambda_4 | \text{tr}(\mathbf{\hat{A}}) |^2 \right), \end{aligned} \label{eq:properties_constraints} \end{equation} where $\| \cdot \|_F$ is the Frobenius norm of a matrix, and $\lambda_2$, $\lambda_3$, and $\lambda_4$ are all weighting parameters. \subsubsection{Proposed Likelihood Function} Since GLR enforces the graph signal $\vec{x}$ to adapt to the topology of the graph described by $\mathbf{\hat{A}}$, we propose the likelihood function as \begin{equation} \begin{split} f(\vec{x} \mid \mathbf{\hat{A}}) & = \text{exp} \left(-\lambda_0 \vec{x}^\top \mathbf{L} \vec{x} \right)\\ & = \text{exp} \left(-\lambda_0 \vec{x}^\top ( \mathbf{I} - \mathbf{\hat{A}} ) \vec{x} \right), \label{eq:final_likelihood_func} \end{split} \end{equation} where $\lambda_0$ is a parameter. Since we assume $\mathbf{\hat{A}}$ is normalized, the degree matrix is an identity matrix as in \eqref{eq:final_likelihood_func}. This provides a structural assumption of data encoded in the adjacency matrix, which includes both graph connectivities and edge weights. \subsubsection{Final MAP Estimation} Having discussed the proposed likelihood function and prior, we arrive at our final MAP estimation of the graph adjacency matrix. Combining (\ref{eq:final_map}), (\ref{eq:prior_distribution}), (\ref{eq:sparsity_constraint}), (\ref{eq:properties_constraints}) and (\ref{eq:final_likelihood_func}), we have \begin{equation} \begin{split} \max_{\mathbf{\hat{A}}} \ \ & \exp\left(-\lambda_0 \vec{x}^\top(\mathbf{I} - \mathbf{\hat{A}}) \vec{x} \right) \cdot \exp\left( -\lambda_1 \| \mathbf{\hat{A}} \|_1 \right) \\ & \begin{aligned} \cdot \exp \left( \right. & -\lambda_2 \| \mathbf{\hat{A}}^\top - \mathbf{\hat{A}} \|_F^2 -\lambda_3 \| \mathbf{\hat{A}}\mathbf{1} - \mathbf{1} \|_F^2 \\ & \left. -\lambda_4 | \text{tr}(\mathbf{\hat{A}}) |^2 \right). \end{aligned} \label{eq:formulation} \end{split} \end{equation} Taking the logarithm of (\ref{eq:formulation}) and multiplying by $-1$, we have \begin{equation} \begin{split} \min_{\mathbf{\hat{A}}} \ \ & \lambda_0 \vec{x}^\top(\mathbf{I} - \mathbf{\hat{A}}) \vec{x} + \lambda_1 \| \mathbf{\hat{A}} \|_1 + \lambda_2 \| \mathbf{\hat{A}}^\top - \mathbf{\hat{A}} \|_F^2 \\ & + \lambda_3 \| \mathbf{\hat{A}}\mathbf{1} - \mathbf{1} \|_F^2 + \lambda_4 | \text{tr}(\mathbf{\hat{A}}) |^2, \label{eq:final_formulation} \end{split} \end{equation} where the first term is GLR, the second term is the sparsity constraint of the adjacency matrix, and the rest are the property constraints of a valid adjacency matrix. Hence, the above problem formulation is to learn such a valid and sparse adjacency matrix $\mathbf{\hat{A}}$ that the graph signal $\mathbf{\vec{x}}$ is adaptive to the learned graph. \subsection{Network Model Optimization} We propose to integrate the optimization objective in (\ref{eq:final_formulation}) into the loss function of the GCN, which seamlessly optimizes the network model with graph learning. Accordingly, the proposed overall loss in graph learning $\mathcal{L}_\text{GL}$ includes three components: the loss in GLR $\mathcal{L}_\text{GLR}$, the loss in sparsity $\mathcal{L}_\text{sparsity}$, and the loss in property constraints $\mathcal{L}_\text{properties}$: \begin{equation} \mathcal{L}_\text{GL} = \mathcal{L}_\text{GLR} + \mathcal{L}_\text{sparsity} + \mathcal{L}_\text{properties}. \label{eq:loss_gl} \end{equation} In accordance with (\ref{eq:final_formulation}), $\mathcal{L}_\text{GLR}$ is defined as \begin{equation} \mathcal{L}_\text{GLR} = \lambda_0 \| \mathbf{x}^\top (\mathbf{I} - \mathbf{\hat{A}}_\text{out}) \mathbf{x} \|_2^2. \end{equation} where $\mathbf{\hat{A}}_\text{out}$ is the final output adjacency matrix at each epoch. $\mathcal{L}_\text{GLR}$ is in a quadratic form, which is differentiable. $\mathcal{L}_\text{sparsity}$ is accordingly defined as \begin{equation} \mathcal{L}_\text{sparsity} = \lambda_1 \| \mathbf{\hat{A}}_\text{out} \|_1. \end{equation} The $l_1$-norm is non-differentiable since it is not continuous everywhere. In the backward propagation algorithm of machine learning, the gradient of the $l_1$ regularization is solved using the sub-gradient \cite{sra2012optimization}: \begin{equation} \frac{\partial \mathcal{L}_\text{sparsity}}{\partial \mathbf{\hat{A}}_\text{out}} = \text{sgn}(\mathbf{\hat{A}}_\text{out}), \end{equation} where \begin{equation} \text{sgn}(x)=\left\{ \begin{array}{lcl} -1 & & x < 0, \\ 0 & & x = 0, \\ 1 & & x > 0. \end{array} \right. \end{equation} Finally, we define $\mathcal{L}_\text{properties}$ as \begin{equation} \begin{split} \mathcal{L}_\text{properties} = & \lambda_2 \| \mathbf{\hat{A}}_\text{out}^\top - \mathbf{\hat{A}}_\text{out} \|_2^2 \\ & + \lambda_3 \| \mathbf{\hat{A}}_\text{out} \mathbf{1} - \mathbf{1} \|_2^2 + \lambda_4 | \text{tr}(\mathbf{\hat{A}}_\text{out}) |^2. \end{split} \label{eq:loss_properties} \end{equation} The three terms of this function are all $l_2$ norms, and thus the function is differentiable. Hence, we are able to compute the gradient of the proposed loss function for graph learning, which is suitable to guide the optimization of the network model. \subsection{Label Smoothness} Having discussed the proposed graph learning, we elaborate on its integration with GCN, which leads to the proposed GLNN architecture. As shown in Fig.~\ref{fig:pipeline}, given graph-structured networks as the input, GLNN consists of two major procedures: graph learning and graph convolution. The graph learning layer aims to produce an optimal adjacency matrix for the subsequent graph convolution. The graph convolution has two layers, with the same parameter settings as in \cite{kipf2016semi}. Besides, the classification loss measures the classification performance of our model, whose value is a probability between 0 and 1. The graph learning loss is for the optimization of the adjacency matrix during the network training. We train the entire network using gradient descent via the backward propagation of both the classification loss and graph learning loss. We discuss each module in detail as follows. \subsection{Graph Learning Layer} The graph learning layer aims to construct an optimal graph structure from the input graph signals. In this layer, we first randomly initialize the adjacency matrix before training the network, and then train the graph using gradient descent from the backward propagation of the proposed loss function introduced in (\ref{eq:loss_gl}). In order to further simplify the implementation, we perform the following symmetrization on the adjacency matrix $\mathbf{\hat{A}}$ before the output of the graph learning layer, which aims to ensure the symmetry property: \begin{equation} \mathbf{\hat{A}}_\text{out} = \frac{1}{2} \left(\mathbf{\hat{A}}^\top + \mathbf{\hat{A}} \right), \label{eq:symmetrization} \end{equation} where $\mathbf{\hat{A}}_\text{out} \in \mathbb{R}^{N \times N}$ is the final output adjacency matrix of the graph learning layer at each epoch. It is a real symmetric matrix by definition. Thus, we can remove the symmetric term in (\ref{eq:loss_properties}). The graph obtained from the graph learning layer is then fed into the GCN architecture for the subsequent semi-supervised node classification task. \subsection{Graph Convolution and Feature Transfer } As introduced in \cite{kipf2016semi}, the graph convolution to a signal $\mathbf{X} \in \mathbb{R}^{N \times C}$ with $C$ input channels (i.e., a $C$-dimensional feature vector for every node) and $F$ filters are defined as follows: \begin{equation} \mathbf{Z}=\sigma \left( \mathbf{\hat{A}}_\text{out} \mathbf{X}\mathbf{W} \right), \end{equation} where $\mathbf{W} \in \mathbb{R}^{C \times F}$ is a matrix of filter parameters, $\mathbf{Z} \in \mathbb{R}^{N \times F}$ is the convoluted signal matrix, and $\sigma(\cdot)$ is an activation function. We consider a two-layer GCN with the learned adjacency matrix $\mathbf{\hat{A}}_\text{out}$. The forward model takes the form: \begin{equation} \begin{split} \mathbf{Z} &= f(\mathbf{X}, \mathbf{\hat{A}}_\text{out}) \\ &= \text{softmax}\left(\mathbf{\hat{A}}_\text{out} \ \text{ReLU}\left(\mathbf{\hat{A}}_\text{out}\mathbf{X}\mathbf{W}^{(0)}\right)\mathbf{W}^{(1)}\right), \end{split} \end{equation} where $\mathbf{W}^{(0)} \in \mathbb{R}^{C \times H}$ is an input-to-hidden weight matrix for a hidden graph convolutional layer with $H$ output feature channels, and $\mathbf{W}^{(1)} \in \mathbb{R}^{H \times F}$ is a hidden-to-output weight matrix for an output layer with $F$ classes. The $\text{softmax}(\cdot)$ and $\text{ReLU}(\cdot)$ are two activation functions. \subsection{The Overall Loss Function} In semi-supervised node classification tasks, we need to evaluate the cross-entropy loss (the Classification Loss in Fig.~\ref{fig:pipeline}) over the labeled data: \begin{equation} \mathcal{L}_\text{GCN} = - \sum_{l \in \mathcal{Y}_L} \sum_{f=1}^{F} \mathbf{Y}_{lf} \ln{\mathbf{Z}_{lf}}, \end{equation} where $\mathcal{Y}_L$ is a set of labeled nodes, $\mathbf{Y}_{l \cdot}$ denotes the label for the $l^\text{th}$ labeled node, and $\mathbf{Z}_{l \cdot}$ is the predicted label for the $l^\text{th}$ node. Further, in cases where the ground truth graph of training samples is available, we add the following loss function to ensure the learned graph is closer to the ground truth: \begin{equation} \mathcal{L}_\text{gt} = \| \mathbf{\hat{A}}_\text{out} - \mathbf{A}_\text{gt} \|_2^2, \end{equation} where $\mathbf{A}_\text{gt}$ is a ground truth adjacency matrix. Hence, the overall loss function of our proposed GLNN framework is \begin{equation} \mathcal{L}_\text{overall} = \mathcal{L}_\text{GCN} + \mathcal{L}_\text{GL} + \alpha \mathcal{L}_\text{gt}. \label{eq:overall_loss} \end{equation} where $\alpha$ is a weighting parameter. \begin{figure*}[htbp] \centering \subfigure[TerroristsRel: GT]{\includegraphics[width=0.19\textwidth]{graphs/ter_gt.pdf}} \subfigure[Epoch 1]{\includegraphics[width=0.19\textwidth]{graphs/ter_1.pdf}} \subfigure[Epoch 5]{\includegraphics[width=0.19\textwidth]{graphs/ter_5.pdf}} \subfigure[Epoch 15]{\includegraphics[width=0.19\textwidth]{graphs/ter_15.pdf}} \subfigure[Epoch 50]{\includegraphics[width=0.19\textwidth]{graphs/ter_50.pdf}} \subfigure[Terror Attack: GT]{\includegraphics[width=0.19\textwidth]{graphs/attack_gt.pdf}} \subfigure[Epoch 1]{\includegraphics[width=0.19\textwidth]{graphs/attack_1.pdf}} \subfigure[Epoch 5]{\includegraphics[width=0.19\textwidth]{graphs/attack_5.pdf}} \subfigure[Epoch 15]{\includegraphics[width=0.19\textwidth]{graphs/attack_15.pdf}} \subfigure[Epoch 50]{\includegraphics[width=0.19\textwidth]{graphs/attack_50.pdf}} \subfigure[Cora: GT]{\includegraphics[width=0.19\textwidth]{graphs/cora_gt.pdf}} \subfigure[Epoch 1]{\includegraphics[width=0.19\textwidth]{graphs/cora_1.pdf}} \subfigure[Epoch 5]{\includegraphics[width=0.19\textwidth]{graphs/cora_5.pdf}} \subfigure[Epoch 15]{\includegraphics[width=0.19\textwidth]{graphs/cora_15.pdf}} \subfigure[Epoch 50]{\includegraphics[width=0.19\textwidth]{graphs/cora_50.pdf}} \vspace{-0.1in} \caption{\textbf{The learned graph adjacency matrix (submatrix with size $\mathbf{30 \times 30}$).} The columns from the left to the right are the ground truth (GT) adjacency matrix, the learned adjacency matrix after the $1^\text{st}$, $5^\text{th}$, $15^\text{th}$ and $50^\text{th}$ epoch, respectively. The rows from the top to the bottom are for the TerroristsRel, Terror Attack, and Cora datasets, respectively.} \label{fig:visual} \end{figure*} \subsection{Datasets} We consider two social networks: TerroristRel and Terror Attack \cite{zhao2006entity}, and three citation networks: Citeseer, Cora, and Pubmed \cite{sen2008collective}. The five datasets are available at https://linqs.soe.ucsc.edu/data. We represent the relationship between terrorists and citation links as undirected edges, and construct a binary and symmetric matrix as introduced in \cite{kipf2016semi} as the ground truth adjacency matrix. \textbf{TerroristRel.} This dataset contains information about terrorists and their relationships. We treat each terrorist as a node, and describe the relationship between each pair of terrorists via an edge in the graph. Further, we employ 160 nodes as labeled data to train our model, and leave the rest of 150 nodes for testing. \begin{table*}[ht] \caption{Results of node classification in terms of accuracy (\%). The asterisk indicates that we have downsampled the dataset.} \centering \begin{tabular}{rccccc} \hline \textbf{Method} & \textbf{TerroristsRel} & \textbf{Terror Attack} & \textbf{Citeseer} & \textbf{Cora} & \textbf{Pubmed*} \\ \hline Planetoid \cite{yang2016revisiting} & - & - & 64.7 & 75.7 & 74.5 \\ ChebNet \cite{defferrard2016convolutional} & 60.1 & 66.5 & 69.6 & 81.2 & 71.6 \\ MoNet \cite{monti2017geometric} & 59.2 & 62.4 & - & 81.7 & 73.5 \\ LoNGAE \cite{tran2018learning} & 63.5 & 66.0 & 71.8 & 79.0 & 74.7 \\ GAT \cite{velivckovic2018graph} & 63.5 & 65.5 & 71.0 & 82.3 & 72.3 \\ DGI \cite{velickovic2019deep} & 52.7 & 61.5 & 71.8 & 82.3 & 74.6 \\ GWNN \cite{xu2018graph} & 65.5 & 65.0 & 71.7 & 82.8 & 72.4 \\ \hline GCN \cite{kipf2016semi} & 62.2 & 68.0 & 70.3 & 81.5 & 73.8 \\ \textbf{GLNN} & \textbf{70.9} & \textbf{76.5} & \textbf{72.4} & \textbf{83.4} & \textbf{76.7} \\ \hline \end{tabular} \label{tab:results} \end{table*} \textbf{Terror Attack.} This dataset consists of 1,293 terrorist attacks, each of which is assigned one of 6 labels to indicate the attack type. We treat terror attacks as nodes, and describe their relationship via edges. We deploy 120 nodes for training and leave 200 nodes for testing. \textbf{Citation networks.} We consider three widely used citation network datasets: Citeseer, Cora, and Pubmed. In these datasets, nodes are documents and edges are citation links. In particular, we sample 3,000 nodes to evaluate our model for the Pubmed dataset. In addition, we select 60 nodes as labeled data to train each model and test the performance on 1,000 nodes. For the Citeseer and Cora dataset, we follow the experimental setup in (Yang et al. \cite{yang2016revisiting}). \vspace{-0.1in} \subsection{Implementation Details} We implemented the proposed model with the TensorFlow\footnote{https://tensorflow.google.cn} framework, and empolyed Adam \cite{kingma2014adam} to train the entire network with the learning rate 0.01. Before the first epoch of the training step in the graph learning layer, we generate a random matrix that follows a uniform distribution, which serves as the initial graph representation. This matrix is then optimized in the subsequent training epochs. In the graph learning loss function, we set $\lambda_1 = 0.1$, $\lambda_3 = 0.1$, and $\lambda_4 = 0.001$. Note that $\lambda_2$ is set to $0$ with the symmetrization operation introduced in (\ref{eq:symmetrization}). In the overall loss function (\ref{eq:overall_loss}), we set $\alpha = 10$. The settings of $\lambda_0$ are adaptive to each dataset, as will be discussed in the subsequent \textit{GLR Analysis} subsection. In the graph convolutional layers, we follow the same experimental settings in \cite{kipf2016semi}, i.e., two graph convolutional layers with 16 hidden units. \subsection{Node Classification Results} Table~\ref{tab:results} lists the comparison results on the five datasets. Reported numbers denote the classification accuracy in percentage, and the best results are marked in bold. Note that the underlying graphs of TerroristsRel and Terror Attack datasets are disconnected, so the Planetoid \cite{yang2016revisiting} cannot be executed properly. First, we see that our GLNN outperforms the baseline method GCN (Kipf et al. \cite{kipf2016semi}) on all the datasets. This validates the effectiveness of the proposed graph learning for semi-supervised classification. In addition, GLNN outperforms the recently proposed network GWNN \cite{xu2018graph}, which indicates the benefit of GLNN on graph data representation and learning. Further, GLNN achieves better performance than other semi-supervised learning methods, which demonstrates the superiority of our model on conducting semi-supervised classification tasks on graph data. \begin{table} \caption{Results of node classification in terms of accuracy with different $\lambda_0$.} \centering \begin{tabular}{c|p{0.5cm}<{\centering}p{0.63cm}<{\centering}p{0.63cm}<{\centering}p{0.63cm}<{\centering}p{0.63cm}<{\centering}p{0.5cm}<{\centering}} \hline \multirow{2}{*}{Dataset~} & \multicolumn{5}{c}{Values of $\lambda_0$} \\ \cline{2-7} & 1.0 & $10^{-1}$ & $10^{-2}$ & $10^{-3}$ & $10^{-4}$ & 0.0 \\ \hline TerroristsRel & 52.0 & \textbf{70.9} & \textbf{70.9} & 63.5 & 63.5 & 62.8 \\ Terror Attack & \textbf{76.5} & \textbf{76.5} & 67.5 & 51.5 & 57.5 & 57.0 \\ Citeseer & \textbf{72.4} & 71.2 & 72.2 & 70.4 & 70.4 & 69.8 \\ Cora & 76.7 & 80.0 & \textbf{83.4} & 82.0 & 82.1 & 82.1 \\ Pubmed* & \textbf{76.7} & 74.8 & 73.0 & 73.0 & 72.9 & 72.9 \\ \hline \end{tabular} \label{tab:para_analysis} \end{table} \subsection{Robustness Test} We test the robustness of our model on citation networks under low label rates. We adopt five different label rates in \{0.005, 0.010, 0.015, 0.020, 0.025\} to train our model and three representative baseline methods: ChebNet \cite{defferrard2016convolutional}, GCN \cite{kipf2016semi} and GWNN \cite{xu2018graph}. Fig.~\ref{fig:robustness} presents the classification accuracy under five different label rates for GCN, ChebNet, GWNN, and our method on the Citeseer and Cora datasets respectively. We see that while the performance of the other methods drops quickly with decreasing label rate, the proposed GLNN is much more robust, with the classification accuracy of $51.8\%$ and $58.0\%$ on the Citeseer and Cora datasets even when the label rate is lower than $0.01$. Further, to validate the necessity and effectiveness of our proposed GLR loss, we also compare with a \textbf{Baseline} scheme of our model, where the GLR loss term $\mathcal{L}_\text{GLR}$ is removed from (\ref{eq:loss_gl}). As shown in Fig.~\ref{fig:robustness}, we outperform the \textbf{Baseline} scheme by a large margin, which validates the superiority of our proposed GLR loss function. To sum up, the robustness of our proposed GLNN gives credits to the structure-adaptive regularization---\textit{Graph Laplacian Regularizer}---in the loss function. This prior is critical in practical applications, since graph data in real life are often unlabeled or have few accurate labels. \subsection{GLR Analysis} We evaluate the contribution of GLR via different assignments of the GLR weighting parameter $\lambda_0$. Table~\ref{tab:para_analysis} lists the classification results of five datasets with $\lambda_0 \in \{1.0, 10^{-1}, 10^{-2}, 10^{-3}, 10^{-4}, 0.0\}$. We see that when $\lambda_0$ is set to a small value, GLNN can produce reasonable results. The performance keeps improving with increasing value of $\lambda_0$ in general, finally achieving state-of-the-art performance. This shows that the GLR loss term with higher weights makes significant contribution to classification results, which demonstrates the superiority of GLR-based graph learning. \subsection{Visualization and Analysis} We also provide some visualization results of the learned graph adjacency matrix obtained from GLNN in Fig.~\ref{fig:visual}. From the left to right columns, we show the ground truth adjacency matrix, the learned adjacency matrix after the $1^\text{st}$, $5^\text{th}$, $15^\text{th}$ and $50^\text{th}$ epoch, respectively. Note that, the adjacency matrix at the $1^\text{st}$ epoch is an initialized random matrix that follows a uniform distribution. In order to ensure clear visualization, we select a sub-matrix with size $30 \times 30$ from the entire adjacency matrix. We see that for all the three datasets, as the epoch increases, the learned graph adjacency matrix becomes more and more similar with the ground truth one. At the $50^\text{th}$ epoch, the learned adjacency matrix is almost the same as the ground truth while introducing , thus validating the effectiveness of the proposed graph learning. Also, the learned adjacency matrix becomes sparser as the epoch increases, due to the sparsity constraint in the proposed graph learning loss. \begin{figure}[htbp] \centering \subfigure[Citeseer dataset.]{\includegraphics[width=0.45\textwidth]{robustness_citeseer.pdf}} \hspace{0.3in} \subfigure[Cora dataset.]{\includegraphics[width=0.45\textwidth]{robustness_cora.pdf}} \vspace{-0.1in} \caption{Classification accuracy comparison with different label rates.} \label{fig:robustness} \end{figure} \subsection{Graph Laplacian} We consider an undirected graph $ \mathcal{G}=\{\mathcal{V},\mathcal{E},\mathbf{A}\} $ composed of a node set $ \mathcal{V} $ of cardinality $|\mathcal{V}|=N$, an edge set $\mathcal{E}$ connecting nodes, and a weighted \textit{adjacency matrix} $\mathbf{A}$. $\mathbf{A}$ is a real symmetric $N \times N$ matrix, where $a_{i,j}$ is the weight assigned to the edge $(i,j)$ connecting nodes $i$ and $j$. The \textit{graph Laplacian} is defined from the adjacency matrix. Among different variants of Laplacian matrices, the commonly used \textit{combinatorial graph Laplacian} \cite{chung1997spectral} is defined as \begin{equation} \mathbf{L}=\mathbf{D}-\mathbf{A}, \label{eq:laplacian} \end{equation} where $ \mathbf{D} $ is the \textit{degree matrix}---a diagonal matrix where $ d_{i,i} = \sum_{j=1}^N a_{i,j} $. Considering the numerical stability in a deep neural network model, we employ the symmetric \textit{normalized} Laplacian \cite{chung1997spectral}, which is defined as \begin{equation} \mathcal{L} =\mathbf{D}^{-\frac{1}{2}}\mathbf{L}\mathbf{D}^{-\frac{1}{2}}=\mathbf{I}-\mathbf{D}^{-\frac{1}{2}}\mathbf{A}\mathbf{D}^{-\frac{1}{2}}, \label{eq:normailized_laplacian} \end{equation} where $\mathbf{I}$ is an identity matrix. \subsection{Graph Laplacian Regularizer} \textit{Graph signal} refers to data that resides on the nodes of a graph. In our context, we treat each person or paper as a node in a graph, and the relationship as the edge between each pair of nodes. Then we define the corresponding graph signal as the social feature or paper information of each node. A graph signal $ \vec{x} \in \mathbb{R}^N $ defined on a graph $ \mathcal{G} $ is \textit{smooth} with respect to $ \mathcal{G} $ \cite{Shuman2013The} if \begin{equation} \vec{x}^{\top} \mathbf{L} \vec{x} =\sum_{i=1}^{N} \sum_{j=1}^{N} w_{i,j}(x_i - x_j)^2 < \epsilon, \label{eq:glr} \end{equation} where $ \epsilon $ is a small positive scalar. To satisfy (\ref{eq:glr}), disconnected or weakly connected node pair $ x_i $ and $ x_j $ with significantly different values must correspond to a small edge weight $ a_{i,j} $; for strongly connected $x_i$ and $x_j$ with similar values, $ a_{i,j} $ can be large. Hence, (\ref{eq:glr}) forces $ \mathcal{G} $ to capture pairwise similarities in $ \vec{x} $, and is commonly called the \textit{graph Laplacian Regularizer} (GLR) \cite{Shuman2013The}. \section{Introduction} \label{sec:intro} \input{01_introduction.tex} \section{Related Work} \label{sec:related} \input{02_related_work.tex} \section{Background in Spectral Graph Theory} \label{sec:Laplacian} \input{Laplacian.tex} \section{The Proposed Graph Learning} \label{sec:graph} \input{03_graph_learning.tex} \section{The Proposed GLNN} \label{sec:method} \input{04_method.tex} \section{Experimental Results} \label{sec:results} \input{05_results.tex} \section{Conclusion} \label{sec:conclude} \input{06_conclusion.tex}
{'timestamp': '2019-09-17T02:22:25', 'yymm': '1904', 'arxiv_id': '1904.10146', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.10146'}
arxiv
\section{Background} \label{sec:background} Pangolin{} lets programmers build fault-tolerant, crash-consistent data structures in NVMM. This section first introduces NVMM and the DAX mechanism applications use to gain direct access to persistent data. Then, we describe the NVMM error handling mechanisms that Intel processors and Linux provide. Finally, we provide a brief primer on NVMM programming using \texttt{libpmemobj}{}~\cite{pmdk}, the library on which Pangolin{} is based. \subsection{Non-volatile Main Memory and DAX} Several technologies are poised to make NVMM common in computer systems. 3D XPoint~\cite{3dxpoint} is the closest to wide deployment. Phase change memory (PCM), resistive RAM (ReRAM), and spin-torque transfer RAM (STT-RAM) are also under active development by memory manufacturers. Flash-backed DRAM is already available and in wide use. Linux and Windows both have support for accessing NVMM and using it as storage media. The performance and cost parameters of NVMM lie between DRAM and SSD. Its write latency is longer than DRAM, but it will cost less per bit. From the storage perspective, NVMM is faster but more expensive than SSD. The most efficient way to access NVMM is via direct access (DAX)~\cite{intel2017intro} memory mapping (i.e., DAX-\texttt{mmap()}{}). To use DAX-\texttt{mmap()}{}, applications map pages of a file in an NVMM-aware file system into their address space, so the application can access persistent data from the user-space using load and store instructions, without the file system intervening. \subsection{Handling NVMM Media Errors} \label{sec:errmodel} To recover from data corruption, Pangolin{} relies on error detection and media management facilities that the processor and operating system provide together. Below, we describe these facilities available on Intel and Linux platforms. Windows provides similar mechanisms. \boldparagraph{Hardware Error Correction} Memory controllers for commercially available NVMMs (i.e., battery-backed DRAM and 3D~XPoint) implement error-correction code (ECC) in hardware to detect and correct media errors when they can, and they report uncorrectable (but detectable) errors with a machine check exception (MCE)~\cite{intel2017isa} that the operating system can catch and attempt to handle. Pangolin{} provides a layer of protection in addition to the ECC hardware provides, but it does not require hardware ECC. Pangolin{} uses checksums to detect errors that hardware cannot detect. This mechanism also catches software bugs (which are invisible to hardware ECC). ECC does, however, improve performance by transparently handling many media errors. Regardless of the ECC algorithm hardware provides, field studies of DRAM and SSDs~\cite{dram-errors-wild, cosmic, dram-errors-modern, sector-errors, flash-failures, ssd-failures} have shown that detectable but uncorrectable media errors occur frequently enough to warrant additional software protection. Furthermore, file systems~\cite{zhang2010end,novafortis,waflmetaprot} apply checksums to their data structures to protect against scribbles. \boldparagraph{Repairing Errors} When the hardware detects an uncorrectable error, the Linux kernel marks the region surrounding the failed load as ``poisoned,'' and future loads from the region will fail with a bus error. Pangolin{} assumes an error poisons a 4~KB page since Linux currently manages memory failures at page granularity. If a running application causes an MCE (by loading from a poisoned page), the kernel sends it a \texttt{SIGBUS}{} and the application can extract the affected address from the data structure describing the signal. The software can repair the poisoned page by writing new data to the region. In response, the operating system and NVDIMM firmware work together to remap the poisoned addresses to functioning memory cells. The details of this process are part of the Advanced Configuration and Power Interface (ACPI)~\cite{acpi62} for NVDIMMs. Recent kernel patches~\cite{libnvdimm412,libnvdimm413,lkml-mce,pagepoison} and NVMM library \cite{pmdk} provide utilities for user-space applications to restore lost data by re-writing affected pages with recovered contents (if available). \subsection{NVMM Programming} \label{sec:pmemobj} \cfigure[Figures/pmem-mmap.pdf,{ \figtitle{DAX-\texttt{mmap()}'d{} NVMM as an object store} \texttt{Libpmemobj}{} divides the mapped space into zones and chunks for memory management. The \texttt{val} field is a 64-bit integer and the \texttt{next} field is a persistent pointer (\texttt{PMEMoid}{}) pointing to the next node object in the pool. },fig:pmemobj] In this section, we describe \texttt{libpmemobj}{}'s programming model. \texttt{Libpmemobj}{} is a well-supported, open-source C library for programming with DAX-\texttt{mmap()}'d{} NVMM. It provides facilities for memory management and software transactions that let applications build a persistent object store. Pangolin{}'s interface and implementation are based on \texttt{libpmemobj}{} from PMDK v1.5. Linux exposes NVMM to the user-space as memory-mapped files (\reffig{fig:pmemobj}). \texttt{Libpmemobj}{} (and Pangolin{}) refer to the mapped file as a \emph{pool} of persistent objects. Each pool spans a continuous range of virtual addresses. \begin{lstlisting}[ style=cstyle, numbers=left, keywordstyle={[2]{\color{blue}}}, label={lst:pmemobj}, morekeywords={[2]{pmemobj_open, pmemobj_root, pmemobj_direct, pmemobj_persist, pmemobj_alloc, pmemobj_tx_add_range, pmemobj_tx_alloc, pmemobj_close, TX_BEGIN, TX_END, TX_ONABORT}}, caption={A \texttt{libpmemobj}{} program - First modify a node value in a linked list, and later allocate and link a new node from the pool. } ] PMEMobjpool *pool = pmemobj_open("/dax/pool"); ... struct node *n = pmemobj_direct(node_oid); n->val = value; pmemobj_persist(pool, &n->val, 8); ... TX_BEGIN(pool) { n = pmemobj_direct(node_oid); pmemobj_tx_add_range(node_oid, 0, sizeof(*n)); n->next = pmemobj_tx_alloc(...); } TX_ONABORT { /* handling transaction aborts */ } TX_END ... pmemobj_close(pool); \end{lstlisting} Within a pool, \texttt{libpmemobj}{} reserves a metadata region that contains information such as the pool's identification (64-bit UUID) and the offset to a ``root object'' from which all other live objects are reachable. Next, is an area reserved for transaction logs. \texttt{Libpmemobj}{} uses redo logging for its metadata updates and undo logging for application object updates. Transaction logs reside in one of two locations depending on their sizes. Small log entries live in the provisioned ``Log'' region, as shown in \reffig{fig:pmemobj}. Large ones overflow into the ``Heap'' storage area. The rest of the pool is the persistent heap. \texttt{Libpmemobj}{}'s NVMM allocator (a persistent variant of \texttt{malloc}/\texttt{free}) manages it. The allocator divides the heap's space into several ``zones'' as shown in \reffig{fig:pmemobj}. A zone contains metadata and a sequence of ``chunks.'' The allocator divides up a chunk for small objects and coalesces adjacent chunks for large objects. By default, a zone is 16~GB, and a chunk is 256~KB. \reflst{lst:pmemobj} presents an example to highlight the key concepts of NVMM programming. The code performs two independent operations on a persistent linked list: one is to modify a node's value, and another is to allocate and link a new node. This example demonstrates two styles of crash-consistent NVMM programming: \emph{atomic}-style (lines 3-5) for a simple modification that is 8 bytes or smaller, and \emph{transactional}-style (lines 7-13) for arbitrary-sized NVMM updates. Building data structures in NVMM using \texttt{libpmemobj}{} (or any other persistent object library) differs from conventional DRAM programming in several ways: \boldparagraph{Memory Allocation} \texttt{Libpmemobj}{} provides crash-consistent NVMM allocation and deallocation functions: \texttt{pmemobj\_tx\_alloc/pmemobj\_tx\_free}. They let the programmer specify object type and size to allocate and prevent orphaned regions in the case of poorly-time crashes. \boldparagraph{Addressing Scheme} Persistent pointers within a pool must remain valid regardless of at what virtual address the pool resides. \texttt{Libpmemobj}{} uses a \texttt{PMEMoid}{} data structure to address an object within a pool. It consists of a 64-bit file ID and a 64-bit byte offset relative to the start of the file. The \texttt{pmemobj\_direct()} function translates a \texttt{PMEMoid}{} into a native pointer for use in load or store instructions. \boldparagraph{Failure-atomic Updates} Modern x86 CPUs only guarantee that 8-byte, aligned stores atomically update NVMM~\cite{intel2017faq}. If applications need larger atomic updates, they must manually construct software transactions. \texttt{Libpmemobj}{} provides undo log-based transactions. The application executes stores to NVMM between the \texttt{TX\_BEGIN} and \texttt{TX\_END} macros, and snapshots (\texttt{pmemobj\_tx\_add\_range}) a range of object data before modifying it in-place. \boldparagraph{Persistence Ordering} Intel CPUs provide cache flush/write-back (e.g., \texttt{CLFLUSH(OPT)} and \texttt{CLWB}) and memory ordering (e.g., \texttt{SFENCE}) instructions to make guarantees about when stores become persistent. In \reflst{lst:pmemobj}, the \texttt{pmemobj\_persist} function and \texttt{TX} macros integrate these instructions to flush modified object ranges. \texttt{Libpmemobj}{} supports a replicated mode that requires a replica pool, doubling the storage the object store requires. \texttt{Libpmemobj}{} applies updates to both pools to keep them synchronized. Replicated \texttt{libpmemobj}{} can detect and recover from media errors only when the object store is offline, and it cannot detect or recover from data corruption caused by errant stores to NVMM -- so-called ``scribbles,'' that might result from a buffer overrun or dereferencing a wild pointer. \wfigure[Figures/layout.pdf,{ \figtitle{Data protection scheme in Pangolin{}} Pangolin{} protects pool metadata (PM), zone metadata (ZM), and chunk metadata (CM). In the highlighted range column, $P = A \oplus C \oplus D \oplus E$. One thread's transaction is modifying ranges $A$ and $C$ of two objects. Pangolin{} keeps modified data in redo log entries (checksummed and replicated) when the transaction commits. The DRAM part shows micro-buffer{}s for the two objects. },fig:layout] \section{Conclusion} \label{sec:conclusion} This work presents Pangolin{}, a fault-tolerant, DAX-\texttt{mmap()}'d{} NVMM programming library for applications to build complex data structures in NVMM. Pangolin{} uses a novel, space-efficient layout of data and parity to protect arbitrary-sized NVMM objects combined with per-object checksums to detect corruption. To maintain high performance, Pangolin{} uses micro-buffering{}, carefully-chosen parity and checksum updating algorithms. As a result, Pangolin{} provides stronger protection, better availability, and much lower storage overhead than existing NVMM programming libraries. \section{Pangolin{} Design} \label{sec:design} Pangolin{} allows programmers to build complex, crash-consistent persistent data structures that are also robust in the face of media errors and software ``scribbles'' that corrupt data. Pangolin{} satisfies all of the criteria listed in \refsec{sec:intro}. This section describes its architecture and highlights the key challenges that Pangolin{} addresses to meet those requirements. In particular, Pangolin{} provides the following features unseen in prior works. \begin{itemize} \item It provides fast, space-efficient recovery from media errors and scribbles. \item It uses checksums to protect object integrity and supports incremental checksum updates. \item It integrates parity and checksum updates into an NVMM transaction system. \item It periodically scrubs data to identify corruption. \item It detects and recovers from media errors and scribbles online. \end{itemize} Pangolin{} guarantees that it can recover from the loss of any single 4~KB page of data in a pool. In many cases, it can recover from the concurrent loss of multiple pages. We begin by describing how Pangolin{} organizes data to protect user objects, library metadata, and transaction logs using a combination of parity, replication, and checksums. Next, we describe micro-buffers{} and explain how they allow Pangolin{} to preserve a simple programming interface and protect against software scribbles. Then, we explain how Pangolin{} detects and prevents NVMM corruption and elaborate on Pangolin{}'s transaction implementation with support for efficient, concurrent updates of object parity. Finally, we discuss how Pangolin{} restores data integrity after corruption and crashes. \subsection{Pangolin{}'s Data Organization} \label{sec:data} Pangolin{} uses replication for its internal metadata and RAID-style parity for user objects to provide redundancy for corruption recovery. The MCE mechanism described in \refsec{sec:errmodel} and object checksums in Pangolin{} detect corruption. Pangolin{} views a zone's chunks as a two-dimensional array as shown in the middle of \reffig{fig:layout}. Each \emph{chunk row} contains multiple, contiguous chunks and the chunks ``wrap around'' so that the last chunk of a row and the first chunk of the next are adjacent. Pangolin{} reserves the last chunk row for parity. In our description of Pangolin{}, we define a \emph{page column} as a one page-wide, aligned column that cuts across the rows of a zone. A \emph{range column} is similar, but can be arbitrarily wide (no more than a chunk row's size). Initializing a parity-coded NVMM pool requires zeroing out all the bytes in the file. This is a one-time overhead when creating a pool file and does not affect run-time performance. We report this latency in \refsec{sec:eval}. To detect corruption in user objects, Pangolin{} adds a 32-bit checksum to the object's header. The header also contains the object's size (64-bit) and type (32-bit). The compiler determines type values according to user-defined object types. Pangolin{} inherits this design from \texttt{libpmemobj}{} and changes the type identifier from 64-bit to 32-bit for the checksum. Pangolin{}'s object placement is independent of chunk and row boundaries. Objects can be anywhere within a zone, and they can be of any size (up to the zone size). In addition to user objects, the library maintains metadata for the pool, zones, and chunks, including allocation bitmaps. Pangolin{} checksums these data structures to detect corruption and replicates the pool's and zones' metadata for fault tolerance. These structures are small (less than 0.1\% for pools larger than 1~GB), so replicating them is not expensive. Pangolin{} uses zone parity to support recovery of chunk metadata. Pangolin{} checksums transaction logs and replicates them for redundancy. It treats log entries in zone storage as zeros during parity calculations. This prevents parity update contention between log entries and user objects (see \refsec{sec:update}). \boldparagraph{Fault Tolerance Guarantees} Pangolin{} can tolerate a single 4~KB media error anywhere in the pool, regardless of whether it is a data page or a parity page. Based on the bad page's address Pangolin{} can locate its page column and restore its data using other healthy pages. Faults affecting two pages of the same page column may cause data loss if the corrupted ranges overlap. If an application demands more robust fault tolerance, it can increase the chunk row size, reducing the number of rows and, consequently, the likelihood that two corrupt pages overlap. Pangolin{} can recover from scribbles (contiguous overwrites caused by software errors) on NVMM data up to a chunk-row size. By default, Pangolin{} uses 100 chunk rows, and parity consumes $\sim$1\% of a pool's size (e.g., 1~GB for a 100~GB pool). \subsection{Micro-buffering{} for NVMM Objects} \label{sec:mbuf} \begin{table*} \centering \resizebox{\textwidth}{!}{ \begin{tabular}{ll} \toprule Function & Semantics\\ \midrule \texttt{pgl\_tx\_begin()/commit()/end(), etc.} & Control the lifetime of a Pangolin{} transaction.\\ \texttt{pgl\_tx\_alloc()/free()} & Allocate or deallocate an NVMM object.\\ \texttt{pgl\_tx\_open(PMEMoid oid, ...)} & Create a thread-local micro-buffer{} for an NVMM object. Verify (and restore)\\ & the object integrity, and return a pointer to the micro-buffered{} user object.\\ \texttt{pgl\_tx\_add\_range(PMEMoid oid, ...)} & Invoke \texttt{pgl\_tx\_open} and then mark a range of the object that will be modified.\\ \texttt{pgl\_get(PMEMoid oid)} & Get access to an object, either directly in NVMM or in its micro-buffer{},\\ & depending on the transaction context. By default, it does not verify the checksum.\\ \midrule \texttt{pgl\_open(PMEMoid oid, ...)} & Create a micro-buffer{} for an NVMM object without a transaction. Check the\\ & object integrity, and return a pointer to the micro-buffered{} user object.\\ \texttt{pgl\_commit(void *uobj)} & Automatically start a transaction and commit the modified user object in a\\ & micro-buffer{} to NVMM.\\ \bottomrule \end{tabular} } \caption{ The Pangolin{} API - Pangolin{}'s interface mirrors \texttt{libpmemobj}{}'s except that Pangolin{} does not allow direct writing to NVMM. Pangolin{} provides single-object transactions using \texttt{pgl\_open} and \texttt{pgl\_commit} to convert application code using \texttt{libpmemobj}{}'s atomic updates. } \label{tab:api} \end{table*} Pangolin{} introduces micro-buffering{} to hide the complexity of updating checksums and parity when modifying NVMM objects. Adding checksums to objects and protecting them with parity makes updates more complex, since all three -- object data, checksum, and parity -- must change at once to preserve consistency. This challenge is especially acute for the atomic programming model as shown in \reflst{lst:pmemobj} (line 3-5) because a single 8-byte NVMM write cannot host all these updates. Micro-buffer{}ing creates a shadow copy of an NVMM object in DRAM, which separates an object's transient and persistent versions (\reffig{fig:layout}). In \reflst{lst:ftlib}, \texttt{pgl\_open} creates a micro-buffer{} for the node object by allocating a DRAM buffer and copying the node's data from NVMM. It also verifies the object's checksum and performs corruption recovery if necessary. The application can modify the micro-buffered{} object without concern for its checksum, parity, and crash-consistency because changes exist only in the micro-buffer{}. When the updates finish, \texttt{pgl\_commit} starts a transaction that atomically updates the NVMM object, its checksum, and parity (described below). Compared to line 3-5 of \reflst{lst:pmemobj}, Pangolin{} retains the simple, atomic-style programming model for modifying a single NVMM object, and it supports updates within an object beyond 8 bytes. Each micro-buffer{}'s header contains information such as its NVMM address, modified ranges, and status flags (e.g., allocated or modified). We elaborate on Pangolin{}'s programming interface and how to construct complex transactions with micro-buffering{} in \refsec{sec:tx}. \begin{lstlisting}[ style=cstyle, numbers=left, label={lst:ftlib}, keywordstyle={[2]{\bfseries\color{teal}}}, morekeywords={[2]{pgl_open, pgl_commit, pgl_tx_begin, pgl_tx_alloc, pgl_tx_open, pgl_tx_add_range, pgl_tx_commit, pgl_tx_end, PGL_TX_BEGIN, PGL_TX_ONABORT, PGL_TX_END}}, caption={A Pangolin{} transaction for a single-object - This snippet corresponds to line 3-5 of \reflst{lst:pmemobj}. } ] struct node *n = pgl_open(node_oid); n->val = value; pgl_commit(pool, n); \end{lstlisting} Another important consideration for micro-buffering{} is to prevent misbehaving software from corrupting NVMM. If an application's code can directly write to NVMM, as \texttt{libpmemobj}{} allows to, software bugs such as buffer overflows and using dangling pointers can easily cause NVMM corruption. Conventional debugging tools for memory safety, such as Valgrind \cite{valgrind} and AddressSanitizer \cite{asan}, insert inaccessible bytes between objects as ``redzones'' to trap illegal accesses. This approach fails to work for directly accessed NVMM objects because once they are allocated, there is no guarantee for spacing between them, and thus, redzones may land on a nearby, accessible object. One viable approach to using these tools is to let the NVMM allocator insert redzones. However, the presence of redzone bytes will pollute the pool and may exacerbate fragmentation. Using micro-buffers{} isolates transient writes from persistent data, and since micro-buffer{}s are dynamically allocated using \texttt{malloc()}, they are compatible with existing memory debugging tools. Without using debugging tools, Pangolin{} also protects micro-buffer{}s by inserting a 64-bit ``canary'' word in each micro-buffer{}'s header and checks its integrity before writing back to NVMM. On transaction commit, if Pangolin{} detects a canary mismatch, it aborts the transaction to avoid propagating the corruption to NVMM. Pangolin uses checksums to detect corruptions that may bypass the canary protection. \subsection{Detecting NVMM Corruption} \label{sec:detecting} Pangolin{} uses three mechanisms to detect NVMM corruption. First, it installs a handler for \texttt{SIGBUS}{} (see \refsec{sec:errmodel}) that fires when the Linux kernel receives an MCE. A signal handler has access to the address the offending load accessed, and Pangolin{} can determine what kind of data (i.e., metadata or a user object) lives there and recover appropriately. This mechanism detects media failures, but it cannot discover corrupted data caused by software ``scribbles.'' To detect scribbles, Pangolin{} verifies the integrity of user objects using their checksums. Verifying checksums on every access can be expensive. To limit this cost, by default Pangolin{} only verifies checksums during micro-buffer{} creation before any object is modified in a transaction. This keeps Pangolin{} from recalculating a new checksum based on corrupt data. For read-only objects that are accessed by \texttt{pgl\_get} without micro-buffering{}, by default Pangolin{} does not verify checksums. To protect them, Pangolin{} provides two alternative operation modes: ``Scrub'' mode runs a scrubbing thread that verifies and restores the whole pool's data integrity when a preset number of transactions have completed, and ``Conservative'' mode verifies the checksum for every object access (including \texttt{pgl\_get}). We evaluate the impact of different checksum verification policies in \refsec{sec:eval}. Finally, Linux keeps track of known bad pages of NVMM across reboots. When opening a pool or during its scrubbing, Pangolin{} can extract this information and recover the data in the reported pages (not currently implemented). \ignore{ Both methods only perform checksum verification when there are no active transactions. In the future work, we also plan to provide a scrubbing function that executes periodically to verify object checksums, according to practical NVMM error statistics. Another way is that the error arises when an application is reading its affected memory range. In this case, Linux sends a \texttt{SIGBUS}{} to the reading thread, and the thread's normal execution flow is interrupted. Pangolin{} implements a specialized signal handler to intercept this event, avoiding crashing the application. In the signal handler Pangolin{} can learn about the faulty page address and repair the corrupted data. After returning from the signal handler, the program can resume execution from where it was interrupted. The process is conceptually similar to handle a page fault in the user-space. } \subsection{Fault-Tolerant Transactions} \label{sec:tx} Failure-atomic transactions are central to Pangolin{}'s interface, and they must include verification of data integrity and updates to the checksums and parity data that protect objects. \reftab{tab:api} summarizes Pangolin{}'s core functions. Pangolin{} supports arbitrary-sized transactions and we have made similar APIs and macros as \texttt{libpmemobj}{}'s. The program in \reflst{lst:pmemobj} can be easily transformed to Pangolin{} using equivalent functions. One subtle difference is in the handling of atomic-style updates, as shown in \reflst{lst:ftlib}. In Pangolin{}, each thread can execute one transaction or nested transactions (same as \texttt{libpmemobj}{}). Concurrent transactions can execute if each one is associated with a different thread. Currently, Pangolin{} does not allow concurrent transactions to modify the same NVMM object. Concurrently modifying a shared object may cause data inconsistency if one transaction has to abort. \texttt{Libpmemobj}{} has the same limitation~\cite{pmemcheck}. Each transaction manages its own micro-buffer{}s using a thread-local hashmap~\cite{cuckoo}, indexed by an NVMM object's \texttt{PMEMoid}{}. Therefore, in a transaction, calling \texttt{pgl\_tx\_open} for the same object either creates or retrieves its micro-buffer{}. Multiple micro-buffer{}s opened in one transaction form a linked list as shown in \reffig{fig:layout}. Micro-buffer{}s for one transaction are not visible in other transactions, providing isolation. If a transaction modifies an object, Pangolin{} copies it to a micro-buffer{}, performs the changes there, and then propagates the changes to NVMM during commit. Since changes occur in DRAM (which does not require undo information), Pangolin{} implements redo logging. At transaction commit, Pangolin{} recomputes the checksums for modified micro-buffers{}, creates and replicates redo log entries for the modified parts of the micro-buffers{} and writes these ranges back to NVMM objects. Then, it updates the affected parity bits (see \refsec{sec:update}) and marks the transaction committed. Finally, Pangolin{} garbage-collects its logs and closes thread-local micro-buffer{}s. If a transaction aborts, either due to unrecoverable data corruption or other run-time errors, Pangolin{} discards the transaction's micro-buffer{}s without touching NVMM. A transaction can also allocate and deallocate objects. Pangolin{} uses redo logging to record NVMM allocation and free operations, just as \texttt{libpmemobj}{} does. For read-only workloads, repeatedly creating micro-buffer{}s and verifying object checksums can be very expensive. Therefore, Pangolin{} provides \texttt{pgl\_get} to gain direct access to an NVMM object without verifying the object's checksum. The application can verify an object's integrity manually as needed or rely on Pangolin{}'s periodic scrubbing mechanism. Inside a transaction context, \texttt{pgl\_get} returns a pointer to the object's micro-buffer{} to preserve isolation. \subsection{Parity and Checksum Updates} \label{sec:update} Objects in different rows can share the same range of parity, and we say these objects \emph{overlap}. Object overlap leads to a challenge for updating the shared parity because updates from different transactions must serialize but naively locking the whole parity region sacrifices scalability. For instance, using $ObjA$ and $ObjC$ in \reffig{fig:layout}, suppose two different transactions modify them, replacing $A$ with $A'$ and $C$ with $C'$, respectively. After both transactions update $P$, the parity should have the value $P' = A' \oplus C' \oplus D \oplus E$ regardless of how the two transaction commits interleave. Pangolin{} uses a combination of two techniques that exploit the commutativity of XOR and fine-grained locking to preserve correctness and scalability. \boldparagraph{Atomic parity updates} \label{sec:atomic} The first approach uses the atomic XOR instruction (analogous to an atomic increment) that modern CPUs provide to perform incremental parity updates for changes to each overlapping object. In our example, we can compute two parity patches: $\Delta{}A = A \oplus A', ~ \Delta{}C = C \oplus C'$ and then rewrite $P'$ as $P \oplus \Delta{}A \oplus \Delta{}C$. Since XOR commutes and is a bit-wise operation, the two threads can perform their updates without synchronization. \ignore{ Because parity words are independent of each other, Pangolin{} can perform an efficient delta-based parity update only using modified ranges of objects. A \emph{range delta} is defined as the XOR result between the old data and new data of a modified object range, i.e., , and Pangolin{} can derive $P'_1$ using range deltas as $P' = P \oplus \Delta{}A \oplus \Delta{}C$, eliminating $D$ and $E$ from the computation. Since XOR computations are commutative, $\Delta{}A$ and $\Delta{}C$ can apply to $P$ in any order. We can leverage the byte-addressability of NVMM and CPU's atomic XOR instructions to perform a lock-free parity update. This is also correct even if the size of $\Delta{}A$ and $\Delta{}C$ are not equal or not aligned. Once the parity updates complete, Pangolin{} flushes the modified parity range to ensure the changes are persistent. } \boldparagraph{Hybrid parity updates} \label{sec:hybrid} Atomic XOR is slower than normal or vectorized XOR. For small updates, the latency difference between them is not significant, and Pangolin{} prefers atomic XOR instructions to update parity without the need for locks. But for large parity updates, atomic XOR can be inefficient. Therefore, Pangolin{}'s hybrid parity scheme switches to vectorized XOR for large transfers. To coordinate large and small parity updates, Pangolin{} uses \emph{parity range-locks}, that work similarly as reader/writer locks (or shared mutex): Small writes take shared ownership of a range lock and update parity with atomic XOR instructions. Large updates using vectorized XORs take exclusive ownership of a range-lock, and only one thread can modify parity in a locked range. If one update involves multiple range-locks, serialization happens on a per-range-lock basis. The managed size of a parity range-lock depends on the performance trade-off between Pangolin{}'s parity mode and \texttt{libpmemobj}{}'s replication mode. We discuss this in \refsec{sec:eval}. Pangolin{} refreshes an object's checksum in its micro-buffer{} before updating parity, and it considers the checksum field as one of the modified ranges of the object. Checksums like CRC32 requires recomputing the checksum using the whole object. This can become costly with large objects. Thus, Pangolin{} uses Adler32~\cite{waflmetaprot}, a checksum that allows incremental updates, to make the cost of updating an object's checksum proportional to the size of the modified range rather than the object size. We implement Pangolin{}'s parity and checksum updates using the Intelligent Storage Acceleration Library (ISA-L) \cite{isa-l}, which leverages SIMD instructions of modern CPUs for these data-intensive tasks. \boldparagraph{Protections for other transaction systems} Other NVMM persistent object systems could apply Pangolin{}'s techniques for parity and checksum updates. For example, consider an undo logging (as opposed to Pangolin{}'s redo logging) system that first stores a ``snapshot'' copy of an object in the log before modifying the original in-place. In this case, the system could compute a parity patch using the XOR result between the logged data (old) and the object's data (new). Then, it can apply the parity patch using the hybrid method we described in this section. \ignore{ updates, Pangolin{} can compute a new checksum value for each modified range of an object. The incremental updating algorithm~\cite{waflmetaprot} we use is conceptually similar to the delta-based parity update, but the delta value is the 2s-compliment difference, i.e., $|A - A'|$ or $|C - C'|$. A checksum value is associated with each object, and it does not introduce any concurrency challenges to compute and store. Pangolin{} modifies its corresponding parity bits using hybrid parity updating scheme. } \subsection{Recovering from Faults} \label{sec:recoverfaults} In this section, we discuss how Pangolin{} recovers data integrity from both NVMM corruption and system crashes. \boldparagraph{Corruption recovery} Pangolin{} uses the same algorithm to recover from errors regardless of how it detects them (i.e., via \texttt{SIGBUS}{} or a checksum mismatch). The first step is to pause the current thread's transaction, and to wait until all other outstanding transactions have completed. Meanwhile, Pangolin{} prevents the initialization of new transactions by setting the pool's ``freeze'' flag. This is necessary because, during transaction committing, parity data may be inconsistent. Once the pool is frozen, Pangolin{} uses the parity bits and the corresponding parts of each row in the page column to recover the missing data. Pangolin{} preserves crash-consistency during repair by making persistent records of the bad pages under recovery. Recovery is idempotent, so it can simply re-execute after a crash. Pangolin{}'s current implementation only allows one thread to perform any online corruption recovery, and if the thread is executing a transaction, online recovery only works if the thread has not started committing. If two threads encounter faults simultaneously, Pangolin{} kills the application and performs post-crash recovery (see below) when it restarts. Supporting multi-threaded online recovery, and allowing it to work when threads have partially written NVMM is possible, but it requires complex reasoning about how to restore the data and its parity to a consistent state. \boldparagraph{Crash recovery} Pangolin{} handles recovery from a crash using its redo logs. It must also protect against the possibility that the crash occurred during a parity update. To commit a transaction, Pangolin{} first ensures its redo logs are persistent and replicated, and then updates the NVMM objects and their parity. If a crash happens before redo logs are complete, Pangolin{} discards the redo logs on reboot without touching the objects or parity. If redo logs exist, Pangolin{} replays them to update the objects and then recomputes any affected parity ranges using the data written during replay (which is now known to be correct) and the data from the other rows. Pangolin{} does not log parity updates because it would double the cost of logging. This does raise the possibility of data loss if a crash occurs during a parity update and a media error then corrupts data of the same page column before recovery can complete. This scenario requires the simultaneous loss of two pages in the same page column due to corruption and a crash, which we expect to be rare. \section{Evaluation} \label{sec:eval} In this section, we evaluate Pangolin{}'s performance and the overheads it incurs by comparing it to normal \texttt{libpmemobj}{} and its replicated version. We start with our experimental setup and then consider its storage requirements, latency impact, scalability, application-level performance, and corruption recovery. \wfigure[Graphs/latency.pdf,{ \figtitle{Transaction performance} Each transaction allocates, overwrites, or frees one object of varying sizes. Pangolin{}'s latencies are similar to Pmemobj{}'s. Pangolin{}-MLP is mostly better than Pmemobj-R{} because updating parity using atomic XOR and \texttt{CLWB}{} instructions is faster than mirroring data in a separate file. },fig:latency] \subsection{Evaluation Setup} We perform our evaluation on a dual-socket platform with Intel's Optane DC Persistent Memory~\cite{optane-pmm}. The CPUs are 24-core engineering samples of the Cascade Lake generation. Each socket has 192~GB DDR4 DRAM and 1.5 TB NVMM. We configure the persistent memory modules in \emph{AppDirect} mode and run experiments on one socket using its local DRAM and NVMM. A recent report~\cite{izraelevitz2019basic} studying this platform provides more architectural details. The CPU provides the \texttt{CLWB}{} instruction for writing-back cache lines to NVMM, non-temporal store instructions to bypass caches, and the \texttt{SFENCE}{} instruction to ensure persistence and memory ordering. It also has atomic XOR and AVX instructions that our parity and checksum computations use. The evaluation machine runs Fedora 27 with a Linux kernel version 4.13 built from source with the NOVA~\cite{nova} file system. We run experiments with both Ext4-DAX~\cite{ext4dax} and NOVA, and applications use \texttt{mmap()} to access NVMM-resident files. The performance is similar on the two file systems because DAX-\texttt{mmap()} essentially bypasses them. On our evaluation machine, we found that updating parity with atomic XORs becomes worse than \texttt{libpmemobj}{}'s replication mode when the modified parity range is greater than 8~KB, so we set 8~KB as the threshold to switch between those parity calculation strategies (see \refsec{sec:hybrid}). \begin{table} \centering \resizebox{\columnwidth}{!} { \begin{tabular}{|l|l|}\hline Pmemobj{} & \texttt{libpmemobj} baseline from PMDK v1.5 \\\hline Pangolin{} & Pangolin{} baseline w/ micro-buffering{} only \\\hline Pangolin{}-ML & Pangolin{} + metadata and redo log replication \\\hline Pangolin{}-MLP & Pangolin{}-ML + object parity\\\hline Pangolin{}-MLPC & Pangolin{}-MLP + object checksums\\\hline Pmemobj-R{} & \texttt{libpmemobj} w/ one replication in another file \\\hline \end{tabular} } \caption{Library operation modes for evaluation - In the figures, we abbreviate Pangolin{} as \texttt{pgl}.} \label{tab:modes} \end{table} \reftab{tab:modes} describes the operation modes for our evaluations. The Pangolin{} baseline implements transactions with micro-buffering{}. It uses buffer canaries to prevent corruption from affecting NVMM, but it does not have parity or checksum for NVMM data. We evaluate versions of Pangolin{} that incrementally add metadata and log replication (``+ML''), object parity (``+MLP''), and checksums (``+MLPC''). We combine the impact of metadata updates with log replication because metadata updates are small and cheap in our evaluation. Pmemobj-R{} is the replication mode of \texttt{libpmemobj}{} that mirrors updates to a replica pool during transaction commit. Comparing Pangolin{}-MLP and Pmemobj-R{} is especially useful because the two configurations protect against the same types of data corruption: media errors but not scribbles. \subsection{Memory Requirements} We discuss and evaluate Pangolin{}'s memory requirements for both NVMM and DRAM. \boldparagraph{NVMM} All our Pangolin{} experiments use a single pool of 100~GB that contains 6$\times$ 16~GB zones. Pangolin{} replicates all the pool's metadata in the same file, which occupies a fixed $\sim$20~MB. The rest of the space is for user objects and their protection data. By default, Pangolin{} uses 100 chunk rows, so each zone has about 160~MB parity, and that totally occupies $\sim$1\% of the pool's capacity. Pmemobj-R{} uses a second 100~GB file as the replica, doubling the cost of NVMM space requirement. When using parity, Pangolin{} has to zero out the whole pool to ensure all zones are initially parity-coded. This takes about 130 seconds. It is a one-time overhead for creating the pool and excluded from the following evaluations. \boldparagraph{DRAM} Pangolin{} uses \texttt{malloc()}'d DRAM to construct micro-buffers{}. The required DRAM space is proportional to ongoing transaction sizes. \reftab{tab:tx-sizes} summarized the transaction sizes for the evaluated key-value store data structures. Pangolin{} automatically recycles them on transaction commits. In our evaluation experiments, micro-buffering{} never exceeds using 50~MB of DRAM. \subsection{Transaction Performance} \wfigure[Graphs/scaling.pdf,{ \figtitle{Scalability} Concurrent workloads randomly overwrite objects of varying sizes. Pangolin{}-MLP scales as well as Pmemobj-R{} or better for objects larger than 64~B. For 64~B objects, Pangolin{}-MLP is worse than Pmemobj-R{} by between 6\% and 25\% due to synchronization overhead for online recovery. },fig:scaling] \reffig{fig:latency} illustrates the transaction latencies for three basic operations on an NVMM object store: object allocation, overwrite, and deallocation. Each transaction operates on one object, and we vary the size of the object. For allocation, latency grows with object size for all five configurations, due to constructing the object and cache line write-back latency. Pangolin{} incurs 2\% - 13\% lower latencies than Pmemobj{} due to its use of non-temporal stores for write backs. An allocation operation does not involve object logging, so Pangolin{}-ML shows performance similar to Pangolin{}. Pangolin{}-MLP adds overhead to update the parity data. It outperforms Pmemobj-R{} by between 1.2$\times$ and 1.9$\times$. We found this is because updating parity using atomic XORs and \texttt{CLWB}{}s incurs less latency than mirroring data in a separate file, as Pmemobj-R{} does. Adding checksum (Pangolin{}-MLPC) incurs less than 7\% overhead compared to Pangolin{}-MLP. Parity's impact is larger than checksum's because updating a parity range demands values from three parts: the micro-buffer{}, the NVMM object, and the old parity data, while computing a checksum only needs data in a DRAM-based micro-buffer{}. Moreover, Pangolin{} needs to flush the modified parity range to persistence, which is the same size as the object. In contrary, updating a checksum only writes back a single cache line that contains the checksum value. Overwriting an NVMM object involves transaction logging for crash consistency. Pangolin{} and Pmemobj{} store the same amount of logging data in NVMM, although they use redo logging and undo logging for this purpose, respectively. Since log entry size is proportional to an object's modified size, which is the whole object in this evaluation, this cost grows with the object. With Pangolin{}, log replication accounts for between 7\% to 25\% of the latency. Parity updates consume between 8\% to 27\% of the extra latency, depending on object size, and checksum updates account for less than 5\%. Pangolin{}-MLP's performance for overwrites is 12\% worse than Pmemobj-R{} for 64~B object updates and is between 1.1$\times$ and 1.5$\times$ better than Pmemobj-R{} for objects larger than 64~B. Deallocation transactions only modify metadata, so their latencies do not change much. \subsection{Scalability} \label{sec:scaling} \begin{table*} \centering \begin{tabular}{rlrrrrrr}\hline & & ctree & rbtree & btree & skiplist & rtree & hashmap \\\hline \multicolumn{2}{r} {Object size} & 56 & 80 & 304 & 408 & 4136 & 10~M (table), 40 (entry) \\\hline \multirow{2}{*}{Insert} & New & 56 (1.00) & 80 (1.00) & 65.9 (0.22) & 408 (1.00) & 4502 (1.09) & 60.9 (1.00) \\ & Mod & 127.6 (3.28) & 330.2 (5.13) & 381.2 (1.47) & 33.9 (2.50) & 200.0 (5.05) & 331.1 (4.21) \\\hline \multirow{2}{*}{Remove} & New & 0 & 0 & 0 & 0 & 184.1 (0.05) & 10.5 (\num{1e-5}) \\ & Mod & 28.0 (0.50) & 202.8 (2.65) & 268.3 (0.90) & 16.9 (0.75) & 98.6 (2.52) & 254.3 (2.16) \\\hline \end{tabular} \caption{Data structure and transaction sizes - ``Insert'' and ``Remove'' show average transaction sizes for insertions and removals, respectively. ``New'' and ``Mod'' indicate average allocated and modified sizes. Value in parentheses is the average number of objects involved in the transaction. } \label{tab:tx-sizes} \end{table*} \reffig{fig:scaling} measures Pangolin{}'s scalability by randomly overwriting existing NVMM objects and varying the object sizes and the number of concurrent threads. Pangolin{} uses reader/writer locks to implement the hybrid parity update scheme described in \refsec{sec:update}. The number of rows in a zone and the zone size determine the granularity of these locks: For a fixed zone size, more rows means fewer columns and fewer parity range-locks. There is no lock contention in the results because the transactions use atomic XOR instructions and can execute concurrently (only taking the reader locks). Our configuration with 1\% parity (160~MB parity per 16~GB zone) has 20~K range-locks per zone, so the chance of lock contention is slim even with large updates (more than 8~KB) and many cores. The graphs also show how each Pangolin{}'s fault-tolerance mechanisms affect performance. Pangolin{}'s throughput is very close to Pmemobj{}. Pangolin{}-MLP mostly outperforms Pmemobj-R{} for object updates that are 256~B or larger, up to 1.5$\times$. But for 64~B object updates, it performs worse than Pmemobj-R{} by between 6\% and 25\%. This is because when enabling parity, every Pangolin{} transaction checks the pool freeze flag (an atomic variable), incurring synchronization overhead. This overhead is noticeable for short transactions with 64~B objects but becomes negligible for larger updates. Pangolin{}-MLPC only performs marginally worse than Pangolin{}-MLP. Scaling degrades for all configuration as update size and thread count grow because the sustainable bandwidth of the persistent memory modules becomes saturated. \subsection{Impacts on NVMM Applications} \wfigure[Graphs/mapbench.pdf,{ \figtitle{Key-value store performance} Each transaction either inserts or removes one key-value pair from the data store. Pangolin{} performs similarly to Pmemobj{} except for cases when a transaction's modified size is much less than an object's size (e.g., skiplist and rtree) due to micro-buffer{}ing overhead. Pangolin{}-MLP's performance is 95\% of Pmemobj-R{} on average. },fig:mapbench] \cfigure[Graphs/checksum.pdf,{ \figtitle{Checksum verification impact} Pangolin-MLPC bars are the same as those in \reffig{fig:mapbench} for 1M Inserts. The cost of different policies depends strongly on data structures. },fig:checksum] To evaluate Pangolin{} in more complex applications, we use six data structures included in the PMDK toolkit: crit-bit tree (ctree), red-black tree (rbtree), btree, skiplist, radix tree (rtree), and hashmap. They have a wide range of object sizes and use a diverse set of algorithms to insert, remove, and lookup values. We rewrite these benchmarks with Pangolin{}'s programming interface as described in \refsec{sec:tx}. \reftab{tab:tx-sizes} summarizes the object and transaction sizes for each workload. The tree structures and the skiplist have a single type of object, which is the tree or list node. Hashmap has two kinds of objects. One is the hash table that contains pointers to buckets. The hash table grows as the application inserts more key-value pairs. Each bucket is a linked list of fixed-sized entry objects. Each insertion or removal is a transaction processing a key-value pair. The workloads involve a mix of object allocations, overwrites, and deallocations. \reftab{tab:tx-sizes} shows, on average, the number of bytes and objects (in parentheses) involved in each data structure's transaction. Deallocated sizes are not shown because they marginally affect the performance differences (see \reffig{fig:latency}). An average allocation size (``New'' rows in the table) smaller than the object size means the data structure does not allocate a new object for every insert operation (e.g., btree). The average modified sizes (``Mod'' rows) determine the logging size and affect the performance drop between Pangolin{} and Pangolin{}-ML. Note that a transaction does not necessarily modify (and log) the whole range of an involved object. The performance difference between Pangolin{}-ML and Pangolin{}-MLP is a consequence of both allocated and modified sizes. For insert transactions, Pangolin{} is faster than Pmemobj{} for ctree and btree, but slower than Pmemobj{} for other data structures. This is because the slower applications have relatively small modified sizes compared to the object sizes, and Pangolin{}'s data movement from NVMM to micro-buffer{}s overshadows its advantage for whole-object updates, as shown in \reffig{fig:latency}. For remove transactions, Pangolin{} is marginally faster than Pmemobj{} except for the case of skiplist, which is also because of the data movement caused by micro-buffering{}. Pangolin{}-MLP's performance is 95\% of Pmemobj-R{} on average, and it saves orders of magnitude NVMM space by using parity data as redundancy. Pangolin{}-MLPC adds scribble detection and performance drops by between 1.5\% to 15\% relative to Pangolin{}-MLP. Adding object checksums impacts rtree's transactions the most because the allocated object size is large, which requires more checksum computing time. Pangolin{} does not impact the lookup performance because it performs direct NVMM reads without constantly verifying object checksums. Pangolin{} ensures data integrity with its checksum verification policy, as discussed in \refsec{sec:detecting}. \begin{table} \centering \resizebox{\columnwidth}{!}{ \begin{tabular}{lrrrrrr}\hline & ctree & rbtree & btree & sklist & rtree & hmap \\\hline Pmemobj & 1.0 & 1.0 & 1.0 & 1.0 & 1.0 & 1.0 \\ Pgl-MLPC & 0.92 & 0.84 & 0.87 & 0.96 & 0.42 & 0.42 \\ Scrub 100K & 0.10 & 0.09 & 0.09 & 0.10 & 0.04 & 0.05 \\ Scrub 50K & 0.05 & 0.04 & 0.05 & 0.05 & 0.02 & 0.02 \\ Conservative & 0 & 0 & 0 & 0 & 0 & 0 \\\hline \end{tabular} } \caption{Vulnerability evaluation - Each row shows object bytes (normalized to Pmemobj{}) accessed without checksum verification.} \label{tab:ftmodel} \end{table} \reffig{fig:checksum} illustrates the impact of different strategies for checksum verification. We compare Pangolin{}'s default mode (Pangolin{}-MLPC) with two ``Scrub'' modes and a ``Conservative'' mode. The default mode only verifies checksums for micro-buffered objects. In ``Scrub'' mode, a scrubbing thread verifies data integrity of the whole object pool when a preset number (indicated by legends in \reffig{fig:checksum}) of transactions have completed. The ``Conservative'' mode verifies the checksum for every object access (including those read by \texttt{pgl\_get} without micro-buffering{}). \reftab{tab:ftmodel} quantifies the vulnerability using the amount of object data that is accessed without checksum verification. The data accumulates across all transactions for Pmemobj{}, Pangolin{}-MLPC, and ``Conservative'' modes. For ``Scrub'' modes, we count the vulnerable data between two scrubbing runs. Numbers in \reftab{tab:ftmodel} are normalized to Pmemobj{}, which does not have any checksum protection for object data. The cost of verifying checksums for every object access depends strongly on the data structure size and its insertion algorithm. For small objects, such as ctree, rbtree, and hashmap, the cost is negligible. But for btree, skiplist, and rtree, due to their large object sizes, the cost is significant. Thus, a scrubbing-based policy could be faster, with more data subject to corruption between two successive runs. \subsection{Error Detection and Correction} Pangolin{} provides error injection functions to emulate both hardware-uncorrectable NVMM media errors and hardware-undetectable scribbles. We initially developed Pangolin{} using conventional DRAM machines that lack support for injecting NVMM errors at the hardware level. Therefore, we use \texttt{mprotect()} and \texttt{SIGSEGV} to emulate NVMM media errors and \texttt{SIGBUS}. When an NVMM file is DAX-\texttt{mmap()}'d{}, the injector can randomly choose a page that contains user-allocated objects, erase it, and call \texttt{mprotect(PROT\_NONE)} on the page. Later, when the application reads the corrupted page, Pangolin{} intercepts \texttt{SIGSEGV}, changes the page to read/write mode, and restores the page's data. The injector function can also randomly corrupt a metadata region or a victim object to emulate software-induced, scribble errors. In both test cases, we observe Pangolin{} can successfully repair a victim page or an object and resume normal program execution. In our evaluation using a 100~GB pool and 1~GB parity, we measured 180 $\mu$s to repair a page of a page column. We also intentionally introduce buffer overrun bugs in our applications and observe that Pangolin{} can successfully detect them using micro-buffer{} canaries. The transaction then aborts to prevent any NVMM corruption. We have also verified Pangolin{} is compatible with AddressSanitizer for detecting buffer overrun bugs (when updating a micro-buffered{} object exceeds its buffer's boundary), if both Pangolin{} and its application code are compiled with support. \section{Introduction} \label{sec:intro} Emerging non-volatile memory (NVM) technologies (e.g., battery-backed NVDIMMs \cite{micron-nvdimm} and 3D XPoint \cite{3dxpoint}) provide persistence with performance comparable to DRAM. Non-volatile main memory (NVMM), is byte-addressable, cache-coherent NVM that resides on the system's main memory bus. The combination of NVMM and DRAM enables hybrid memory systems that offer the promise of dramatic increases in storage performance and a more flexible programming model. A key feature of NVMM is support for direct access, or DAX, that lets applications perform loads and stores directly to a file that resides in NVMM. DAX offers the lowest-possible storage access latency and enables programmers to craft complex, customized data structures for specific applications. To support this model, researchers and industry have proposed various persistent object systems ~\cite{nvheaps,mnemosyne,pmdk,dudetm,lognvmm,kaminotx,justdo,romulus}. Building persistent data structures presents a host of challenges, particularly in the area of crash consistency and fault tolerance. Systems that use NVMM must preserve crash-consistency in the presence of volatile caches, out-of-order execution, software bugs, and system failures. To address these challenges, many groups have proposed crash-consistency solutions based on hardware~\cite{wsp,thynvm,whisper,hwundoredo}, file systems~\cite{bpfs,pmfs,nova,novafortis}, user-space data structures and libraries~ \cite{nvtree,slottedpaging,nvheaps,mnemosyne,pmdk,lognvmm,romulus}, and languages~\cite{pynvm,nvlc}. Fault tolerance has received less attention but is equally important: To be viable as an enterprise-ready storage medium, persistent data structures must include protection from data corruption. Intel processors report uncorrectable memory media errors via a machine-check exception and the kernel forwards it to user-space as a \texttt{SIGBUS}{} signal. To our knowledge, Xu~\textit{et al.}{}~\cite{novafortis} were the first to design an NVMM file system that detects and attempts to recover from these errors. Among programming libraries, only \texttt{libpmemobj}{} provides any support for fault tolerance, but it incurs 100\% space overhead, only protects against media errors (not software ``scribbles''), and cannot recover corrupted data without taking the object store offline. Xu~\textit{et al.}{} also highlighted a fundamental conflict between DAX-\texttt{mmap()}{} and file system-based fault tolerance: By design, DAX-\texttt{mmap()}{} leaves the file system unaware of updates made to the file, making it impossible for the file system to update the redundancy data for the file. Their solution is to disable file data protection while the file is mapped and restore it afterward. This provides well-defined protection guarantees but leaves file data unprotected when it is in use. Moving fault-tolerance to user-space NVMM libraries solves this problem, but presents challenges since it requires integrating fault tolerance into persistent object libraries that manage potentially millions of small, heterogeneous objects. To satisfy the competing requirements placed on NVMM-based, DAX-\texttt{mmap()}'d{} object store, a fault-tolerant persistent object library should provide at least the following characteristics: \begin{enumerate} \myitem{Crash-consistency}. The library should provide the means to ensure consistency in the face of both system failures and data corruption. \myitem{Protection against media and software errors}. Both types of errors are real threats to data stored to NVMM, so the library should provide protection against both. \myitem{Low storage overhead}. NVMM is expensive, so minimizing storage overhead of fault tolerance is important. \myitem{Online recovery}. For good availability, detection and recovery must proceed without taking the persistent object store offline. \myitem{High performance}. Speed is a key benefit of NVMM. If fault-tolerance incurs a large performance penalty, NVMM will be much less attractive. \myitem{Support for diverse objects}. A persistent object system must support objects of size ranging from a few cache lines to many megabytes. \end{enumerate} This paper describes \emph{Pangolin{}}, the first persistent object library to satisfy all these criteria. Pangolin{} uses a combination of parity, replication, and object-level checksums to provide space-efficient, high-performance fault tolerance for complex NVMM data structures. Pangolin{} also introduces a new technique for accessing NVMM called \emph{micro-buffering} that simplifies transactions and protects NVMM data structures from programming errors. We evaluate Pangolin{} using a suite of benchmarks and compare it to \texttt{libpmemobj}{}, a persistent object library that offers a simple replication mode for fault tolerance. Compared to \texttt{libpmemobj}{}, performance is similar, and Pangolin{} provides stronger protection, online recovery, and greatly reduced storage overhead (1\% instead of 100\%). The rest of the paper is organized as follows: \refsec{sec:background} provides a primer on NVMM programming and NVMM error handling in Linux. \refsec{sec:design} describes how Pangolin{} organizes data, manages transactions, and detects and repairs errors. \refsec{sec:eval} presents our evaluations. \refsec{sec:related} discusses related work. Finally, \refsec{sec:conclusion} concludes. \section{Related Work} \label{sec:related} In this section, we place Pangolin{} in context relative to previous projects that have explored how to use NVMM effectively. \boldparagraph{Transaction Support} All previous libraries for using NVMMs to build complex objects rely on transactions for crash consistency. Although we built Pangolin{} on \texttt{libpmemobj}{}, its techniques could be applied to another persistent object system. NV-Heaps~\cite{nvheaps}, Atlas~\cite{atlas}, DCT~\cite{dct}, and \texttt{libpmemobj}{}~\cite{pmdk} provide undo logging for applications to snapshot persistent objects before making in-place updates. Mnemosyne~\cite{mnemosyne}, SoftWrAp~\cite{softwrap}, and DUDETM~\cite{dudetm} use variations of redo logging. REWIND~\cite{rewind} implements both undo and redo logging for fine-grained, high-concurrent transactions. Log-structured NVMM~\cite{lognvmm} makes changes to objects via append-only logs, and it does not require extra logging for consistency. Romulus~\cite{romulus} uses a main-back mechanism to implement efficient redo log-based transactions. None of these systems provide fault tolerance for NVMM errors. We believe they can adopt Pangolin{}'s parity and checksum design to improve their resilience to NVMM errors at low storage overhead. In \refsec{sec:update} we described how to apply the hybrid parity updating scheme to an undo logging-based system. Log-structured and copy-on-write systems can adopt the techniques in similar ways. \boldparagraph{Fault Tolerance} Both Pangolin{} and \texttt{libpmemobj}{}'s replication mode protect against media errors, but Pangolin{} provides stronger protection and much lower space overhead. Furthermore, \texttt{libpmemobj}{} can only repair media errors offline, and it does not detect or repair software corruption to user objects. NVMalloc~\cite{nvmalloc} uses checksums to protect metadata. It does not specify whether application data is also checksum-protected, and it does not provide any form of redundancy to repair the corruption. NVMalloc uses \texttt{mprotect()} to protect NVMM pages while they are not mapped for writing. Pangolin{} could adopt this technique to prevent an application from scribbling its own persistent data structures. The NOVA file system~\cite{nova, novafortis} uses parity-based protection for file data. However, it must disable these features for NVMM pages that are DAX-\texttt{mmap()}'d{} for writing in user-space, since the page's contents can change without the file system's knowledge, making it impossible for NOVA to keep the parity information consistent if an application modifies DAX-\texttt{mmap()}'d{} data. As a result, Pangolin's and NOVA's fault tolerance mechanisms are complementary.
{'timestamp': '2019-07-26T02:15:03', 'yymm': '1904', 'arxiv_id': '1904.10083', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.10083'}
arxiv
\section{Introduction} Fix a set $X$ and denote by $\mathcal P (X)$ the collection of all subsets of $X$. A \emph{concept class}\footnote{We will also sometimes call $\mathcal C$ a set system on $X$} $\mathcal{C}$ on $X$ is a subset of $ \mathcal P (X)$. In the equivalence query (EQ) learning model, a learner attempts to identify a target set $A \in \mathcal{C}$ by means of a series of data requests called \emph{equivalence queries}. The learner has full knowledge of $\mathcal{C}$, as well as a hypothesis class $\mathcal H$ with $\mathcal C \subseteq \mathcal{H} \subseteq \mathcal P(X).$ An \emph{equivalence query} consists of the learner submitting a hypothesis $B \in \mathcal{H}$ to a teacher, who either returns \emph{yes} if $A = B$, or a counterexample $x \in A \triangle B$. In the former case, the learner has learned $A$, and in the latter case, the learner uses the new information to update and submit a new hypothesis. In sections \ref{basicEQ} and \ref{applications}, the teacher may be assumed to be adversarial and the worst case number of queries required to learn any concept is analyzed. In section \ref{randomeq}, we consider the case in which the teacher selects counterexamples randomly according to a fixed but arbitrary distribution. We will also consider learning with equivalence and membership queries (EQ+MQ). In a membership query, a learner submits a single element $x$ from the base set $X$ to the teacher, who returns the value $A(x)$, where $A$ is the target concept. In this setting, the learner may choose to make either type of query at any stage, submitting any $x \in X$ for a membership query or submitting any $B \in \mathcal{H}$ for an equivalence query. The learner learns the target concept $A$ when they submit $A$ as an equivalence query. With Theorems \ref{EQlearn} and \ref{EQMQalg}, we give upper bounds for the number of queries required for EQ and EQ+MQ learning a class $\mathcal C$ with hypotheses $\mathcal H$ in terms of the \emph{Littlestone dimension of $\mathcal C$}, denoted $\Ldim(\mathcal{C})$, and the \emph{consistency dimension of $\mathcal C$ with respect to $\mathcal H$}, denoted $\C(\mathcal{C}, \mathcal{H})$. We also give lower bounds for the number of required queries in terms of these quantities. In the EQ+MQ setting, the bounds are tight enough to completely characterize when a problem is efficiently learnable. Littlestone dimension is well-known in learning theory \cite{littlestone1988learning} and model theory.\footnote{In model theory, Littlestone dimension is called Shelah 2-rank, see \cite{MLMT} for additional details.} Consistency dimension and the related notion of strong consistency dimension are more subtle, which we detail in section \ref{basicEQ}. When $\mathcal H$ is taken to be $\mathcal P(X)$, $\C(\mathcal C, \mathcal H)=1$; for various examples of set systems with $\mathcal H = \mathcal C$, one has $\C(\mathcal C, \mathcal H) = \infty$. In \ref{obtainC}, we define a new invariant, the consistency threshold of $\mathcal C$, and provide a construction (for arbitrary $\mathcal C$) of a hypothesis class $\mathcal H$ which is not much more complicated than $\mathcal C$ (of the same Littlestone dimension as $\mathcal C$) such that $\C ( \mathcal C, \mathcal H) \leq \Ldim(\mathcal C)+1.$ In \ref{SCvsC}, we compare our bounds and invariants to those previously appearing in the literature. Theorems \ref{EQlearn} and \ref{EQMQalg} can be used to establish efficient learnability in specific applied settings \emph{if} one can obtain appropriate bounds on Littlestone dimension and consistency dimension. Let $(\mathcal C_n, \mathcal H_n)$ be a collection of concept and hypothesis classes which depends on some parameter $n$. Typically, we are thinking of finite classes which grow with $n$. We prove that whenever $\mathcal C_n$ can be learned by an algorithm using polynomially many membership queries and equivalence queries from $\mathcal{H}_n$, there must be polynomial bounds on Littlestone and consistency dimension. Moreover, whenever such an algorithm exists, the algorithm given in Theorem \ref{EQMQalg} accomplishes this. Finally, to close section \ref{basicEQ}, we explain the connection between strong consistency dimension and a model theoretic property called the finite cover property (fcp), or rather its negation, referred to henceforth as the nfcp. We show that if $\mathcal C$ is the set system given by uniform instances of a fixed first order formula $\phi$, and $\mathcal H$ is the collection of externally $\phi$-definable sets, then $(\mathcal C, \mathcal H)$ has finite strong consistency dimension if and only if $\phi$ has the nfcp. In section \ref{applications} we demonstrate the practicality of our approach by providing simple and fast proofs of the efficient learnability of regular languages and certain $\omega$-languages, reproving results of \cite{angluin1987learning,angluin2016learning,fisman2018families,fisman2018inferring}. Besides the conceptual simplicity of the approach, the bounds in learning complexity resulting from our algorithm have some novel aspects. For instance, our bounds have no dependence on the length of the strings provided to the learner as counterexamples, in contrast to existing algorithms. In section \ref{randomeq} we turn to a randomized variant of EQ-learning in which the teacher is required to choose counterexamples randomly from a known probability distribution on $X$. \cite{angluin2017power} show that for a concept class of size $n$, there is an algorithm in which the expected number of queries to learn any concept is at most $\log _2 (n).$ It is natural to wonder whether there is a notion of dimension which can be used to bound the expected number of queries. In fact, Angluin and Dohrn \cite[Theorem 25]{angluin2017power} already consider this, and show that the VC-dimension of the concept class is a lower bound on the number of expected queries. However, \cite[Theorem 26]{angluin2017power}, using an example of \cite{littlestone1988learning}, shows that the VC-dimension \emph{cannot} provide an upper bound for the number of queries. We show that the Littlestone dimension provides such an upper bound; we give an algorithm which yields a bound which is linear in the Littlestone dimension for the expected number of queries needed to learn any concept. In section \ref{compression}, we introduce compression schemes for concept classes. Specifically, the notion we work with is equivalent to $d$-compression with $b$ extra bits (of Floyd and Warmuth \cite{floyd1995sample}). In \cite{johnson2010compression}, Laskowski and Johnson proved that the concept class corresponding to a stable formula has an extended $d$-compression for some $d$. Later, a result of Laskowski appearing as \cite[Theorem 4.1.3]{guingonanip} in fact showed that one could take $d$ equal to the Shelah 2-rank (Littlestone dimension) and uses $2^d$ many reconstruction functions. We show that $d+1$ many reconstruction functions suffice. \section{A combinatorial characterization of EQ-learnability} \label{basicEQ} Often, one assumes that $X$ is finite, and the emphasis is placed on finding bounds on the number of queries it may take to learn any $A \in \mathcal{C}$. We also consider the case where $X$ is infinite, for which we give the following definition. \begin{defn} Let $\mathcal{C}$ and $\mathcal{H}$ be set systems on a set $X$. $\mathcal{C}$ is \emph{learnable with equivalence queries} from $\mathcal{H}$ if there exists some $n < \omega$ and some algorithm to submit hypotheses from $\mathcal{H}$ such that any concept $A \in \mathcal{C}$ is learnable in at most $n$ equivalence queries, given any teacher returning counterexamples. Let $\LC^{EQ}(\mathcal{C}, \mathcal{H})$ be the least such $n$ if $\mathcal{C}$ is learnable with equivalence queries from $\mathcal{H}$, and $\LC^{EQ}(\mathcal{C}, \mathcal{H}) = \infty$ otherwise. $\LC^{EQ}(\mathcal{C}, \mathcal{H})$ is called the \emph{learning complexity}, representing the optimal number of queries needed in the worst-case scenario. Similarly, $\mathcal{C}$ is learnable with equivalence queries from $\mathcal{H}$ and membership queries if there exists some $n < \omega$ and some algorithm to submit membership queries from $X$ or equivalence queries from $\mathcal{H}$ such that any concept $A \in \mathcal{C}$ is learnable in at most $n$ equivalence queries. The learning complexity is defined similarly and is denoted by $\LC^{EQ + MQ}(\mathcal{C}, \mathcal{H})$. \end{defn} \subsection{EQ-learnability from Littlestone and consistency dimension} \begin{prop} \cite[Theorems 5 and 6]{littlestone1988learning} \label{stableEQlearningeasy} If $\LC^{EQ}(\mathcal{C}, \mathcal{H}) \leq d+1$, then $\Ldim(\mathcal{C}) \leq d$. If $\mathcal{H} = \mathcal{P}(X)$, then the converse holds. \end{prop} \begin{proof} Suppose $\Ldim(\mathcal{C}) \geq d + 1$. We show that we can force the learner to use at least $d+2$ equivalence queries. Construct a binary element tree of height $d+1$ with proper labels from $\mathcal{C}$ witnessing $\Ldim(\mathcal{C}) \geq d + 1$. Given the first hypothesis $H_0$ from the learner, return the element on the 0th level on the tree as a counterexample. Continue this, returning the element on the $i$th level along the path consistent with previous counterexamples as the counterexample to hypothesis $H_i$. We will return $d+1$ counterexamples, and the learner still requires one more hypothesis to identify the concept. Since this will occur for one of the proper labels $A$ of the binary element tree, we have forced the learner to use at least $d+2$ equivalence queries for some $A \in \mathcal{C}$. \bigskip Suppose $\Ldim(\mathcal{C}) = d < \infty$. Let $\mathcal{C}_0 = \mathcal{C}$. Inductively define $\mathcal{C}_i$, $i = 1, \ldots, d$ as follows. Given $\mathcal{C}_i$, for any $x \in X$ and $j \in \{0,1\}$, let \[ \mathcal{C}_i^{(x, j)} := \{ A \in \mathcal{C}_i \, | \, \chi_A(x) = j \}, \] where $\chi_A$ is the characteristic function on $A$. Let \[ B_i := \{ x \in X \, | \, \Ldim(\mathcal{C}_i^{(x,1)}) \geq \Ldim(\mathcal{C}_i^{(x,0)}) \}. \] Submit $B_i$ as the hypothesis. If $B_i$ is correct, we are done. Otherwise, we receive a counterexample $x_i$. Set \[ \mathcal{C}_{i+1} := \{ A \in V_i \, | \, \chi_A(x_i) \neq \chi_{B_i}(x_i) \} \] to be the concepts which have the correct label for $x_i$. Observe that at each stage, $\Ldim(\mathcal{C}_{i+1}) < \Ldim(\mathcal{C}_i)$. Therefore, if we make $d$ queries without correctly identifying the target, then we must have $\Ldim(\mathcal{C}_d) = 0$. Then $V_d$ is a singleton, which must be the target concept. \end{proof} Notice in particular that if $\Ldim(\mathcal{C}) = \infty$, then $\mathcal{C}$ cannot be learned with equivalence queries, even with $\mathcal{H} = \mathcal{P}(X)$. The assumption that $\mathcal{H} = \mathcal{P}(X)$ makes learning straightforward, but this may be too strong for many settings. However, without some additional hypotheses on $\mathcal{H}$, learnability may already be hopeless, even for \emph{very simple} set systems. For instance, let $\mathcal{C}$ be the set of singletons. If $\mathcal{H} = \mathcal{C}$, then we may take as long as $|X|$ to learn if $X$ is finite, or never learn at all if $X$ is infinite. However, if the learner is allowed to guess $\emptyset$, this forces the teacher to identify the target singleton. The strategy of Proposition \ref{stableEQlearningeasy} permeates both learnability and non-learnability proofs; identifying a specific set amounts to reducing the Littlestone dimension of the family of possible concepts to 0; actually submitting the target concept before the Littlestone dimension reaches 0 can be thought of as a best-case scenario that we cannot rely on. Non-learnability then amounts to an inability to reduce the Littlestone dimension of the family of possible concepts to 0 through a series of finitely many equivalence queries. The main purpose of this section is to give precise conditions on $\mathcal{H}$ and $\mathcal{C}$ which \emph{characterize} learnability. \begin{defn} Given a set $X$, a \emph{partially specified subset} $A$ of $X$ is a partial function $A: X \rightarrow \{0, 1\}$. \begin{itemize} \item Say $x \in A$ if $A(x) = 1$, $x \notin A$ if $A(X) = 0$, and membership of $x$ is unspecified otherwise. The \emph{domain} of $A$, $\dom(A)$, is $A^{-1}(\{0,1\})$. Call $A$ \emph{total} if $\dom(A) = X$. We identify subsets $A \subseteq X$ with total partially specified subsets. The \emph{size} of $A$, $|A|$, is the cardinality of $\dom(A)$. \item Given two partially specified subsets $A$ and $B$, write $A \sqsubseteq B$ if $A$ and $B$ agree on $\dom(A)$; call $A$ a \emph{restriction} of $B$ and $B$ an \emph{extension} of $A$. \item Given a set $Y \subseteq \dom(A)$, the restriction $A|_Y$ of $A$ to $Y$ is the partial function where $A|_Y(x) = A(x)$ for all $x \in Y$, and is unspecified otherwise. \item Given a set system $\mathcal{C}$ on $X$, $A$ is \emph{$n$-consistent} with $\mathcal{C}$ if every size $n$ restriction of $A$ has an extension in $\mathcal{C}$. Otherwise, say $A$ is \emph{$n$-inconsistent}. $A$ is \emph{finitely consistent} with $\mathcal{C}$ if every restriction of $A$ of finite size has an extension in $\mathcal{C}$---that is, $A$ is $n$-consistent with $\mathcal{C}$ for all $n < \omega$. \end{itemize} \end{defn} The following definition is a translation into set systems of a definition that first appeared in \cite{balcazar2002consistencydimension}. \begin{defn} The \emph{consistency dimension} of $\mathcal{C}$ with respect to $\mathcal{H}$, denoted $\C(\mathcal{C}, \mathcal{H})$, is the least integer $n$ such that for every subset $A \subseteq X$ (viewed as a total partially specified subset), if $A$ is $n$-consistent with $\mathcal{C}$, then $A \in \mathcal{H}$. If no such $n$ exists, then say $\C(\mathcal{C}, \mathcal{H}) = \infty$. \end{defn} Observe that $\C(\mathcal{C}, \mathcal{H}) = 1$ iff $\mathcal{H}$ shatters\footnote{Recall that a set system $\mathcal{C}$ shatters a set $A$ if, for all $B \subseteq A$, there is $C \in \mathcal{C}$ such that $C \cap A = B$.} the set of all elements $x \in X$ such that there are $A_0$ and $A_1$ in $\mathcal{C}$ such that $x \notin A_0$ but $x \in A_1$. In this case, it is possible to learn any concept in $\mathcal{C}$ in at most $\Ldim(\mathcal{C}) + 1$ equivalence queries, using the method of Proposition \ref{stableEQlearningeasy}. So we may assume that $\C(\mathcal{C}, \mathcal{H}) > 1$. \begin{lem}\label{unionlemma} Suppose that for each $i < n$, $\mathcal{C}_i$ is a concept class on $X$ and $\mathcal{H}_i$ is a hypothesis class on $X$. Suppose that $\LC^{EQ}(\mathcal{C}_i, \mathcal{H}_i) = m_i$. Then $\LC^{EQ}(\mathcal{C}, \mathcal{H}) \leq \sum_{i < n} m_i$, where $\mathcal{C} := \cup_{i < n} \mathcal{C}_i$ and $\mathcal{H} := \cup_{i < n} \mathcal{H}_i$. \end{lem} \begin{proof} We give the proof for $n = 2$; then the result for $n > 2$ follows easily by induction. To learn a target concept $A \in \mathcal{C} = \mathcal{C}_0 \cup \mathcal{C}_1$ with hypotheses from $\mathcal{H} = \mathcal{H}_0 \cup \mathcal{H}_1$, begin by assuming that $A \in \mathcal{C}_0$. Attempt to learn $A$ by making guesses from $\mathcal{H}_0$, according to the procedure by which any concept in $\mathcal{C}_0$ is learnable in at most $m_0$ many queries. If, after making $m_0$ many queries, we have failed to learn $A$, then we conclude that $A \notin \mathcal{C}_0$, whence $A \in \mathcal{C}_1$. We can then learn $A$ in at most $m_1$ many additional queries with guesses from $\mathcal{H}_1$. \end{proof} We can now give an upper bound for the learning complexity in terms of Littlestone dimension and consistency dimension. \begin{thm}\label{EQlearn} Suppose $\Ldim(\mathcal{C}) = d < \infty$ and $1 < \C(\mathcal{C}, \mathcal{H}) = c < \infty$. Then $\LC^{EQ}(\mathcal{C}, \mathcal{H}) \leq c^d$. \end{thm} \begin{proof} We proceed by induction on $d$. The base case, $d = 0$, is trivial, as then $\mathcal{C}$ is a singleton. Suppose there is some element $x$ such that $\Ldim(\mathcal{C} \cap x) < d + 1$ and $\Ldim(\mathcal{C} \setminus x) < d + 1$, where $\mathcal{C} \cap x := \{ A \in \mathcal{C} \, | \, x \in A \}$ and $\mathcal{C} \setminus x := \{ A \in \mathcal{C} \, | \, x \notin A \}$. Then by induction, any concept in $\mathcal{C} \cap x$ can be learned in at most $c^d$ queries with guesses from $\mathcal{H}$, and the same is true for $\mathcal{C} \setminus x$. Then by Lemma \ref{unionlemma}, any concept in $\mathcal{C}$ can be learned in at most $2c^d \leq c^{d+1}$ equivalence queries. If no such $x$ exists, then for all $x$, either $\Ldim(\mathcal{C} \cap x) = d + 1$ or $\Ldim(\mathcal{C} \setminus x) = d + 1$. Let $B$ be such that $x \in B$ iff $\Ldim(\mathcal{C} \cap x) = d+1$. If $B \in \mathcal{H}$, then we submit $B$ as our query. If we are incorrect, then by choice of $B$, the class $\mathcal{C}'$ of concepts consistent with the counterexample $x_0$ will have Littlestone dimension $\leq d$. By induction, any concept in $\mathcal{C}'$ can be learned in at most $c^d$ many queries, and so we learn $a$ in at most $c^d + 1 \leq c^{d+1}$ queries. If $B \notin H$, then, since $\C(\mathcal{C}, \mathcal{H}) = c$, there are some $x_0, \ldots, x_{c-1}$ such that there is no $A \in \mathcal{C}$ such that $B|_{\{x_0, \ldots, x_{c-1}\}} \sqsubseteq A$. Then, with notation as in the proof of Proposition \ref{stableEQlearningeasy}, \[ \mathcal{C} = (\mathcal{C}^{(x_0, 1-B(x_0))}) \cup \ldots \cup (\mathcal{C}^{(x_{c-1}, 1-B(x_{c-1}))}), \] and $\Ldim(\mathcal{C}^{(x_i, 1-B(x_i))}) \leq d$ for each $i$. Then, by induction, for each $i$, any concept in $\mathcal{C}^{(x_i, 1-B(x_i))}$ can be learned in at most $c^d$ many queries with guesses from $\mathcal{H}$. By Lemma \ref{unionlemma}, any concept in $\mathcal{C}$ can be learned in at most $c^{d+1}$ many queries with guesses from $\mathcal{H}$. \end{proof} On the other hand, Proposition \ref{stableEQlearningeasy} gives a lower bound of $\Ldim(\mathcal{C}) + 1 \leq \LC^{EQ}(\mathcal{C}, \mathcal{H})$. There is also a lower bound for learning complexity in terms of consistency dimension: \begin{prop}\cite[Theorem 2]{balcazar2002consistencydimension}\label{prop:Clowerbound} Suppose there is some partially specified subset $A$ which is $n$-consistent with $\mathcal{C}$ but which does not have a total extension in $\mathcal{H}$. Then $n < \LC^{EQ}(\mathcal{C}, \mathcal{H})$. \end{prop} \begin{proof} By hypothesis, given any equivalence query $H$, the teacher can find some $x \in \dom(A)$ such that $H(x) \neq A(x)$. Moreover, since $A$ is $n$-consistent with $\mathcal{C}$, the teacher is able to return a counterexample of this form for the first $n$ equivalence queries. Thus $\mathcal{C}$ cannot be learned with fewer than $n + 1$ equivalence queries from $\mathcal{H}$. \end{proof} In particular, if $\C(\mathcal{C}, \mathcal{H}) \geq c$, then there is some subset $A$ which is $(c-1)$-consistent with $\mathcal{C}$ but which does not belong to $\mathcal{H}$. Then $c \leq \LC^{EQ}(\mathcal{C}, \mathcal{H})$. So $\C(\mathcal{C}, \mathcal{H}) \leq \LC^{EQ}(\mathcal{C}, \mathcal{H})$. In fact, we will obtain a stronger bound using strong consistency dimension in section \ref{SCvsC}. Furthermore, if $\C(\mathcal{C}, \mathcal{H}) = \infty$, then $\mathcal{C}$ cannot be learned with equivalence queries from $\mathcal{H}$. Combining Theorem \ref{EQlearn} and Propositions \ref{stableEQlearningeasy} and \ref{prop:Clowerbound}, we obtain the following: \begin{thm}\label{EQcategorization} $\mathcal{C}$ is learnable with equivalence queries from $\mathcal{H}$ iff $\Ldim(\mathcal{C}) < \infty$ and $\C(\mathcal{C}, \mathcal{H}) < \infty$. \end{thm} \subsection{Obtaining finite consistency dimension} \label{obtainC} We have established that finite consistency dimension is essential for EQ-learning. The central question we answer in this subsection is: given $\mathcal C$, can one obtain a hypothesis class $\mathcal H$ which is not much more complicated than $\mathcal C$ with the property that $\C(\mathcal C, \mathcal H)$ is finite? \begin{defn} Fix a set system $\mathcal{C}$ on a set $X$. $\mathcal{C}$ has \emph{consistency threshold} $n < \infty$ if, given any hypothesis class $\mathcal{H} \supset \mathcal{C}$, we have that \[ \C(\mathcal{C}, \mathcal{H}) < \infty \quad \text{iff} \quad \C(\mathcal{C}, \mathcal{H}) \leq n. \] \end{defn} \begin{lem} \label{lem:consistentextension} Suppose $A$ is a partially specified subset finitely consistent with $\mathcal{C}$. Then there is a total extension $A' \sqsupseteq A$ finitely consistent with $\mathcal{C}$. \end{lem} \begin{proof} Let $X = \{x_\alpha \, | \, \alpha < |X| \}$ be a well-ordering of $X$. Let $A_0 = A$. We inductively define a $\sqsubseteq$-chain of partially specified subsets $A_\alpha$, where each $A_\alpha$ is defined on $\dom(A) \cup \{x_\xi \, | \, \xi < \alpha \}$ and is finitely consistent with $\mathcal{C}$. For $\alpha$ a limit ordinal, set $A_\alpha = \cup_{\xi < \alpha} A_\xi$. It is clear that $A_\alpha$ is finitely consistent with $\mathcal{C}$ if all $A_\xi$ for $\xi < \alpha$ are. At any successor stage $\alpha + 1$, if $x_\alpha \in \dom(A_\alpha)$, set $A_{\alpha + 1} = A_\alpha$. Otherwise, we must extend $A_\alpha$ to $x_\alpha$ while remaining finitely consistent with $\mathcal{C}$. Assume for contradiction that neither $B_0 := A_\alpha \cup \{x_\alpha \mapsto 0 \}$ nor $B_1 := A_\alpha \cup \{x_\alpha \mapsto 1 \}$ are finitely consistent with $\mathcal{C}$. Then there are finite sets $Y_0, Y_1 \subseteq \dom(A_\alpha)$ such that $B_0 |_{Y_0 \cup \{a_\alpha\}}$ and $B_1 |_{Y_1 \cup \{a_\alpha \}}$ have no extension in $\mathcal{C}$. But $A_\alpha |_{Y_0 \cup Y_1}$ has an extension $B$ in $\mathcal{C}$, and $B$ must be an extension of either $B_0 |_{Y_0 \cup \{a_\alpha\}}$ or $B_1 |_{Y_1 \cup \{a_\alpha\}}$, a contradiction. So $A_\alpha$ has a finitely consistent extension to $x_\alpha$, and we set $A_{\alpha + 1}$ to be such an extension. We then take $A' = \cup_{\xi < |X|} A_\xi$. \end{proof} \begin{prop}\label{prop:needfincon} Let $\mathcal{C}, \mathcal H$ be a set systems and let $A$ be a partially specified subset. The following are equivalent: \begin{description} \item[(i)] $A$ is finitely consistent with $\mathcal{C}$. \item[(ii)] If $\C(\mathcal{C}, \mathcal{H}) < \infty$, then there is a total extension $A' \sqsupseteq A$ in $\mathcal{H}$. \end{description} \end{prop} \begin{proof} (i) $\Rightarrow$ (ii): Let $A' \sqsupseteq A$ be a total extension finitely consistent with $\mathcal{C}$. If $\C(\mathcal{C}, \mathcal{H}) < \infty$, then $A' \in \mathcal{H}$. (ii) $\Rightarrow$ (i): We show the contrapositive. Suppose that $A$ is not finitely consistent with $\mathcal{C}$, witnessed by some size $n$ restriction $A_0$, which is a $\sqsubseteq$-minimal such restriction. We find some $\mathcal{H}$ such that $\C(\mathcal{C}, \mathcal{H}) < \infty$ but $\mathcal{H}$ contains no total extension of $A$. Let $\mathcal{H}$ be the collection of all (total partially specified) subsets which are not extensions of $A_0$. So $A$ has no total extension in $\mathcal{H}$. We claim that $\C(\mathcal{C}, \mathcal{H}) \leq n$. Indeed, observe that given any (total partially specified) subset $B$ that is $n$-consistent with $\mathcal{C}$, we have $A_0 \not \sqsubseteq B$, and then $B \in \mathcal{H}$. \end{proof} In particular, if $\C(\mathcal{C}, \mathcal{H}) < \infty$, then $\mathcal{H}$ contains all finitely consistent subsets. That is, extensions of all finitely consistent partially specified subsets (equivalently, by Lemma \ref{lem:consistentextension}, all finitely consistent total partially specified subsets) are necessary to obtain $\C(\mathcal{C}, \mathcal{H}) < \infty$. Consistency threshold classifies when this is a sufficient condition. \begin{prop} \label{prop:SCproperties} The following are equivalent: \begin{description} \item[(i)] $\mathcal{C}$ has consistency threshold $\leq n < \infty$. \item[(ii)] For all (total partially specified) subsets $A$, if $A$ is $n$-consistent with $\mathcal{C}$, then $A$ is finitely consistent with $\mathcal{C}$. \item[(iii)] If $\mathcal{H}$ contains all finitely consistent (total partially specified) subsets, then $\C(\mathcal{C}, \mathcal{H}) \leq n$. \end{description} \end{prop} \begin{proof} (i) $\Rightarrow$ (ii): Assume for contradiction that there is some total $A$ which is $n$-consistent but not finitely consistent. Let $m$ be minimal such that $A$ is $m$-inconsistent. Then there is a size $m$ restriction $A' \sqsubseteq A$ that has no extension in $\mathcal{C}$. Then let $\mathcal{H}$ contain all subsets which do not extend $A'$. We claim that $\C(\mathcal{C}, \mathcal{H}) = m$. Note that $A$ witnesses that $\C(\mathcal{C}, \mathcal{H}) \geq m$. On the other hand, observe that given any partially specified subset $B$ that is $m$-consistent with $\mathcal{C}$, we have $A' \not \sqsubseteq B$, and then it is easy to see that $B$ has a total extension in $\mathcal{H}$. (ii) $\Rightarrow$ (iii): If $\mathcal{H}$ contains all finitely consistent subsets, and all $n$-consistent subsets are finitely consistent, then $\C(\mathcal{C}, \mathcal{H}) \leq n$ holds immediately. (iii) $\Rightarrow$ (i): By Proposition \ref{prop:needfincon}, if $\C(\mathcal{C}, \mathcal{H}) < \infty$, then $\mathcal{H}$ already has all finitely consistent subsets. Then $\C(\mathcal{C}, \mathcal{H}) \leq n$. \end{proof} In particular, if $\mathcal{C}$ has finite consistency threshold, then $\C(\mathcal{C}, \mathcal{H}) < \infty$ iff $\mathcal{H}$ contains all finitely consistent subsets. \begin{cor} \label{cor:largennothreshold} Suppose $\mathcal{C}$ does not have finite consistency threshold. Then for arbitrarily large $n$, there is some total subset $A_n$ which is $n$-consistent but not $(n+1)$-consistent with $\mathcal{C}$. \end{cor} Finite consistency threshold is not strictly necessary to provide a positive answer to the central question of this subsection; nevertheless, it does identify a clear qualitative dividing line. When $\mathcal{C}$ has finite consistency threshold, $\mathcal{H}$ only needs to contain all finitely consistent subsets; letting $\mathcal{H}_\infty$ be the set of all finitely consistent subsets, we obtain a minimum hypothesis class such that learning is possible. Where $\mathcal{C}$ does not have finite consistency threshold, more is required; we must add some hypotheses which are inconsistent with the concepts in $\mathcal{C}$, and there is no minimal $\mathcal{H}$ such that learning is possible. However, for each $m$, we can replace ``finitely consistent'' with ``$m$-consistent'' to obtain a class $\mathcal{H}_m$ such that $\C(\mathcal{C}, \mathcal{H}_m) \leq m$---let $\mathcal{H}_m$ be the collection of all subsets which are $m$-consistent with $\mathcal{C}$. Note that $\mathcal{H}_m$ is clearly the minimum hypothesis class such that $\C(\mathcal{C}, \mathcal{H}) \leq m$. Note that for all $m$, $\mathcal{H}_\infty \subseteq \mathcal{H}_m$. By Proposition \ref{prop:SCproperties}, if $\mathcal{C}$ has consistency threshold $n$, then for all $m \geq n$, $\mathcal{H}_m = \mathcal{H}_n = \mathcal{H}_\infty$. If $\mathcal{C}$ does not have finite consistency threshold, there is no minimal $\mathcal{H}$ such that $\C(\mathcal{C}, \mathcal{H}) < \infty$; by Corollary \ref{cor:largennothreshold}, if $\C(\mathcal{C}, \mathcal{H}) = m$, then there is $m' \geq m$ such that $\mathcal{H}_{m'} \subsetneq \mathcal{H}$. By choosing $m$ appropriately, given any $\mathcal{C}$, we can find a hypothesis class such that $\C(\mathcal{C}, \mathcal{H}) < \infty$ without increasing the Littlestone dimension; that is, $\Ldim(\mathcal{H}) = \Ldim(\mathcal{C})$. \begin{thm}\label{thm:fixedLdim} Suppose $\Ldim(\mathcal{C}) = d < \infty$. Then there is $\mathcal{H}$ such that $\C(\mathcal{C}, \mathcal{H}) < \infty$ and $\Ldim(\mathcal{H}) = \Ldim(\mathcal{C})$. Furthermore, we can find such an $\mathcal{H}$ such that $\C(\mathcal{C}, \mathcal{H}) \leq \Ldim(\mathcal{C}) + 1$. \end{thm} \begin{proof} Fix some $m > d = \Ldim(\mathcal{C})$. Let $\mathcal{H}_m$ be the collection of all subsets which are $m$-consistent with $\mathcal{C}$. It is immediate that $\C(\mathcal{C}, \mathcal{H}_m) \leq m < \infty$. Assume for contradiction that $\Ldim(\mathcal{H}_m) > \Ldim(\mathcal{C})$. Consider a binary element tree of height $d+1$ that can be properly labeled with elements of $\mathcal{H}_m$; in particular, there is some leaf which cannot be labeled with an element of $\mathcal{C}$. Consider such a leaf. The path through the binary element tree to this leaf defines a partially specified subset $A$ that is $(d+1)$-inconsistent with $\mathcal{C}$. In particular, any total extension is $(d+1)$-inconsistent, so $m$-inconsistent, and so does not belong to $\mathcal{H}_m$. This contradicts our ability to label the leaf with an element of $\mathcal{H}_m$. In particular, recall that when $\mathcal{C}$ has finite consistency threshold $n$, $A$ is $n$-consistent with $\mathcal{C}$ iff it is finitely consistent with $\mathcal{C}$. So setting $\mathcal{H}_m$ as above with $m$ at least the finite consistency threshold amounts to setting $\mathcal{H}_m$ to be the collection of all finitely consistent partially specified subsets. In this case, $\Ldim(\mathcal{H}_m) = \Ldim(\mathcal{C})$ even if $m \leq d$, as increasing the Littlestone dimension requires adding something inconsistent with $\mathcal{C}$. Regardless of whether $\mathcal{C}$ has finite consistency dimension, we can let $m = d+1$. Then $\C(\mathcal{C}, \mathcal{H}_m) \leq m = d+1$. \end{proof} \subsection{From consistency to strong consistency}\label{SCvsC} From an algorithms perspective, the result of Theorem \ref{EQlearn} is unsatisfactory, since it is exponential in $\Ldim(\mathcal{C})$. We give an example to show that, without modification, we cannot expect a significant improvement. \begin{exam}\label{example:exponential} Fix $c > 2$ and $d$. Let $\{a_\tau \, | \, \tau \in [c]^i,\, 1 \leq i \leq d \}$ be distinct elements indexed by finite nonempty sequences of length at most $d$ from $[c]$. For $\sigma \in [c]^d$, let $B_\sigma = \{a_\tau \, | \, \tau \subseteq \sigma \}$. Let $\mathcal{C} = \{B_\sigma \, | \, \sigma \in [c]^d \}$. Then $\Ldim(\mathcal{C}) = d$. If we take $\mathcal{C}$ to also be our hypothesis class, then $\C(\mathcal{C}, \mathcal{C}) = c+1$. Indeed, the (total partially specified) subset $A = \{a_0\}$ is $c$-consistent but not $(c+1)$ consistent with $\mathcal{C}$, witnessed by the restriction of $A$ to $\{a_0, a_{0,0}, \ldots, a_{0,c-1}\}$, so $\C(\mathcal{C}, \mathcal{C}) \geq c+1$. On the other hand, if $A$ is a subset $(c+1)$-consistent with $\mathcal{C}$, then, by induction on the length of $\tau$, for each $1 \leq i \leq d$, $A$ contains exactly one $a_\tau$ with $\tau = i$, so $A \in \mathcal{C}$. However, it may take as long as $c^d$ many equivalence queries to learn; if the teacher returns $a_\sigma$ as a counterexample to hypothesis $A_\sigma$, then the learner can only eliminate $A_\sigma$. \end{exam} The most promising modification is the following variant of consistency dimension, which also appeared in \cite{balcazar2002consistencydimension} in a slightly different form. \begin{defn} The \emph{strong consistency dimension} of $\mathcal{C}$ with respect to $\mathcal{H}$, denoted $\SC(\mathcal{C}, \mathcal{H})$, is the least integer $n$ such that for every partially specified subset $A$, if $A$ is $n$-consistent with $\mathcal{C}$, then $A$ has an extension in $\mathcal{H}$. If no such $n$ exists, then say $\SC(\mathcal{C}, \mathcal{H}) = \infty$. \end{defn} We therefore make the stronger requirement that all partially specified subsets that are $n$-consistent be consistent, rather than just all totally partially specified subsets. It is immediate from the definition that $\C(\mathcal{C}, \mathcal{H}) \leq \SC(\mathcal{C}, \mathcal{H})$. At the smallest levels, consistency dimension and strong consistency dimension are equal. \begin{prop} \label{prop:C-SC12equal} If $\C(\mathcal{C}, \mathcal{H}) = 1$, then $\SC(\mathcal{C}, \mathcal{H}) = 1$. If $\C(\mathcal{C}, \mathcal{H}) = 2$, then $\SC(\mathcal{C}, \mathcal{H}) = 2$. \end{prop} \begin{proof} Observe that $\C(\mathcal{C}, \mathcal{H}) = 1$ iff $\SC(\mathcal{C}, \mathcal{H}) = 1$ iff $\mathcal{H}$ shatters the set of all elements $x \in X$ such that there are $A_0$ and $A_1$ in $\mathcal{C}$ such that $x \notin A_0$ but $x \in A_1$. Suppose that $\C(\mathcal{C}, \mathcal{H}) = 2$. Let $A$ be a partially specified subset that is 2-consistent with $\mathcal{C}$. We wish to find a total extension of $A$ in $\mathcal{H}$. It suffices to find a total extension $B \sqsupseteq A$ that is 2-consistent with $\mathcal{C}$. Let $X = \{x_\alpha \, | \, \alpha < |X| \}$ be a well-ordering of $X$. Let $A_0 = A$. We inductively define a $\sqsubseteq$-chain of partially specified subsets $A_\alpha$, where each $A_\alpha$ is defined on $\dom(A) \cup \{x_\xi \, | \, \xi < \alpha \}$ and is 2-consistent with $\mathcal{C}$. For $\alpha$ a limit ordinal, set $A_\alpha = \cup_{\xi < \alpha} A_\xi$. It is clear that $A_\alpha$ is 2-consistent with $\mathcal{C}$ if all $A_\xi$ for $\xi < \alpha$ are. At any successor stage $\alpha + 1$, if $x_\alpha \in \dom(A_\alpha)$, set $A_{\alpha + 1} = A_\alpha$. Otherwise, we must extend $A_\alpha$ to $x_\alpha$ while remaining 2-consistent with $\mathcal{C}$. Assume for contradiction that neither $B_0 := A_\alpha \cup \{x_\alpha \mapsto 0 \}$ nor $B_1 := A_\alpha \cup \{x_\alpha \mapsto 1 \}$ are 2-consistent with $\mathcal{C}$. Then there are $y_0$, $y_1 \in \dom(A_\alpha)$ such that $B_0 |_{\{y_0, x_\alpha\}}$ and $B_1 |_{\{y_1, x_\alpha \}}$ have no extension in $\mathcal{C}$. But $A_\alpha |_{\{y_0, y_1\}}$ has an extension $B$ in $\mathcal{C}$, and $B$ must be an extension of either $B_0 |_{\{y_0, x_\alpha\}}$ or $B_1 |_{\{y_1, x_\alpha \}}$, a contradiction. So $A_\alpha$ has a 2-consistent extension to $x_\alpha$, and we set $A_{\alpha + 1}$ to be such an extension. We then take $\cup_{\xi < |X|} A_\xi$ to be our total extension. \end{proof} As the following examples show, consistency dimension and strong consistency dimension may differ when $\C(\mathcal{C}, \mathcal{H}) \geq 3$. \begin{exam} Let $X = \{a,b,c,d,e\}$. Let \[ \mathcal{C} = \mathcal{H} = \left\{ \{a,b,c\}, \{a,b,d\}, \{a,c,d,e\}, \{b,c,d,e\} \right\}. \] One can verify that $\C(\mathcal{C}, \mathcal{H}) = 3$, but the partially specified subset $\{a,b,c,d\}$ with $e$ unspecified witnesses that $\SC(\mathcal{C}, \mathcal{H}) > 3$. \end{exam} \begin{exam} \label{exam:exponential2} Continuing Example \ref{example:exponential}, observe that $\SC(\mathcal{C}, \mathcal{C}) = c^d$. In particular, the partially specified subset $A'$ given by \[ A'(a_\tau) = \begin{cases} 0 & |\tau| = d \\ \text{undefined} & \text{otherwise} \end{cases} \] witnesses that $\SC(\mathcal{C}, \mathcal{C}) > c^d - 1$. Then we learn in at most $SC(\mathcal{C}, \mathcal{C})$ many queries. Moreover, this demonstrates that consistency dimension and strong consistency dimension can differ by an arbitrarily large amount (allowing $\Ldim(\mathcal{C})$ to vary), and that strong consistency dimension may even be exponentially larger than consistency dimension. \end{exam} Strong consistency dimension, like consistency dimension, categorizes equivalence query learning: \begin{thm}\label{EQCharCon} $\mathcal{C}$ is learnable with equivalence queries from $\mathcal{H}$ iff $\Ldim(\mathcal{C}) \leq \infty$ and $\SC(\mathcal{C}, \mathcal{H}) < \infty$. In particular, $\SC(\mathcal{C}, \mathcal{H}) \leq \LC^{EQ}(\mathcal{C}, \mathcal{H})$. \end{thm} \begin{proof} For the reverse direction, use Theorem \ref{EQlearn} and the observation that $\C(\mathcal{C}, \mathcal{H}) \leq \SC(\mathcal{C}, \mathcal{H})$. For the forward direction, use Propositions \ref{stableEQlearningeasy} and \ref{prop:Clowerbound}. In particular, if $\SC(\mathcal{C}) \geq c$, then there is a partially specified subset $A$ that is $(c-1)$-consistent with $\mathcal{C}$ but which has no total extension in $\mathcal{H}$. Then, by Proposition \ref{prop:Clowerbound}, $c \leq \LC^{EQ}(\mathcal{C}, \mathcal{H})$. \end{proof} \begin{cor} \label{CandSC} Suppose $\Ldim(\mathcal{C}) < \infty$. Then $\C(\mathcal{C}, \mathcal{H}) < \infty$ iff $\SC(\mathcal{C}, \mathcal{H}) < \infty$. \end{cor} The distinction between consistency dimension and strong consistency dimension is subtle, and many previous results hold with little to no modification if one replaces consistency dimension with strong consistency dimension. On the other hand, our work in section \ref{applications} will reveal the practical difficulties associated with with strong consistency dimension in complicated concept classes. We have already seen in Theorem \ref{EQCharCon} that strong consistency dimension provides a better lower bound for learning complexity. It is also known in the finite case that strong consistency dimension also gives a stronger upper bound for learning complexity: \begin{thm}\cite[Theorem 2]{balcazar2002consistencydimension} \label{thmFiniteEQlearningBalcazar} Suppose $\mathcal{C}$ is finite. Then $\LC^{EQ}(\mathcal{C}, \mathcal{H}) \leq \lceil SC(\mathcal{C}, \mathcal{H}) \cdot \ln |\mathcal{C}| \rceil$. \end{thm} \begin{proof} As this was originally framed in the setting where concepts were represented by strings, we give an abbreviated translation of the original proof into the language of set systems. This proof demonstrates the utility of constructing a partial hypothesis and taking some complete extension. Let $c = \SC(\mathcal{C}, \mathcal{H})$. At stage $i$, let $\mathcal{C}_i \subseteq \mathcal{C}$ be the set of remaining possible target concepts. Let $A_i$ be the partially specified subset given by \[ A(x) = \begin{cases} 1 & x \text{ belongs to more than } \frac{c - 1}{c}|\mathcal{C}_i| \text{ many } C \in \mathcal{C}_i \\ 0 & x \text{ belongs to less than } \frac{1}{c}|\mathcal{C}_i| \text{ many } C \in \mathcal{C}_i \\ \text{undefined} & \text{otherwise.} \end{cases} \] Observe that $A$ is $c$-consistent with $\mathcal{C}$---given any $Y := \{x_0, \ldots, x_{c-1}\} \subseteq \dom(A)$, for each $j$, less than $\frac{1}{c}|\mathcal{C}_i|$ many remaining concepts disagree with $A$ on $x_j$, so less than $c\frac{1}{c}|\mathcal{C}_i| = |\mathcal{C}_i|$ many concepts disagree with $A$ on some $x_j$. So some concept agrees with $A$ on $Y$. So $A$ is $c$-consistent. So we can find some $B \in \mathcal{H}$ such that $B \sqsupseteq A$, and we submit $B$ as our hypothesis. By choice of $A$, if we receive a counterexample, we will have $|\mathcal{C}_{i+1}| \leq \frac{c-1}{c}|\mathcal{C}_i|$. Repeating this $\lceil c \cdot \ln |\mathcal{C}| \rceil$ many times is enough to identify and submit the target concept. \end{proof} In light of Example \ref{exam:exponential2}, one hopes that improved bounds on learning can be found in terms of strong consistency dimension and Littlestone dimension when $\mathcal{C}$ is infinite. We are unable to show this presently, but offer some evidence in this direction: \begin{prop}\label{EQlearnSC2} Suppose $\Ldim(\mathcal{C}) = d < \infty$ and $\SC(\mathcal{C}, \mathcal{H}) = 2 < \infty$. Then $\LC^{EQ}(\mathcal{C}, \mathcal{H}) = d + 1$. \end{prop} \begin{proof} We know by Proposition \ref{stableEQlearningeasy} that $d+1$ is a lower bound. We show that it is also an upper bound. Let $V_0 = \mathcal{C}$. Inductively define $V_i$, $i = 1, \ldots, d$ as follows. Given $V_i$, for any $x \in X$ and $j \in \{0,1\}$, let \[ V_i^{(x, j)} := \{ B \in V_i \, | \, \chi_B(x) = j \}, \] where $\chi_B$ is the characteristic function on $B$. Construct the partially specified subset $A_i$ where \begin{equation} A_i(x) = \begin{cases} 0 & \Ldim(V_i^{(x,0)}) = \Ldim(V_i) \\ 1 & \Ldim(V_i^{(x,1)}) = \Ldim(V_i) \\ \text{undefined} & \text{otherwise.} \end{cases} \label{eqn:EQ2} \end{equation} We claim that $A_i$ has an extension in $H$. By our assumption that $\SC(\mathcal{C}, \mathcal{H}) = 2$, it suffices to check that $A$ is 2-consistent with $V_i$. Suppose for contradiction that there are $a_0, a_1 \in \dom(A_i)$ such that, without loss of generality, $A_i(a_0) = A_i(a_1) = 0$, but there is no extension of $A_i|_{\{a_0, a_1\}}$ in $V_i$. Then observe that $V_i^{(x_0,0)} \subseteq V_i^{(x_1, 1)}$, whence \[ \Ldim(V_i) \geq \Ldim(V_i^{(x_1, 1)}) \geq \Ldim(V_i^{(x_0, 0)}) = \Ldim(V_i), \] so $\Ldim(V_i^{(x_1, 1)}) = \Ldim(V_i)$. But we also have $\Ldim(V_i^{(x_1, 0)}) = \Ldim(V_i)$, a contradiction, as we could then construct a binary element tree with proper labels from $V_i$ of height $\Ldim(V_i) + 1$ with $x_1$ at the root. Let $B_i \in \mathcal{H}$ be a total extension of $A_i$. Submit $B_i$ as the hypothesis. If $B_i$ is correct, we are done. Otherwise, we receive a counterexample $x_i$. Set \[ V_{i+1} := \{ B \in V_i \, | \, \chi_B(x_i) \neq \chi_{B_i}(x_i) \}. \] Observe that at each stage, $\Ldim(V_{i+1}) < \Ldim(V_i)$. Therefore, if we make $d$ queries without correctly identifying the target, then we must have $\Ldim(V_d) = 0$. Then $V_d$ is a singleton, which must be the target concept. \end{proof} The proof of Proposition \ref{EQlearnSC2} uses strong consistency in a key way, as the hypothesis is generated by extending a certain partially specified subset. Nevertheless, the conclusion holds under the assumption that $C(\mathcal{C}, \mathcal{H}) = 2$, due to Proposition \ref{prop:C-SC12equal}. \subsection{Adding membership queries and efficient learning of finite classes} \label{EQMQMQ} Consistency dimension was originally derived from the notion of polynomial certificates, which was used to characterize learning with equivalence and membership queries in the finite case by \cite{hellerstein1996queries}. The following is an improvement of the upper bound on EQ+MQ learning complexity of $\lceil \C(\mathcal{C}, \mathcal{H}) \log_2 |\mathcal{C}| \rceil$ implicit in the proof of Theorem 3.1.1 in \cite{hellerstein1996queries} (stated explicitly in \cite{balcazar2002consistencydimension}). Our bound replaces $\log_2|\mathcal{C}|$ with $\Ldim(\mathcal{C})$. \begin{thm} \label{EQMQalg} Suppose $\Ldim(\mathcal{C}) = d < \infty$ and $\C(\mathcal{C}, \mathcal{H}) = c < \infty$. Then $\LC^{EQ + MQ}(\mathcal{C}, \mathcal{H}) \leq c'd + 1$, where $c' = \max \{1, c-1\}$. \end{thm} \begin{proof} \footnote{The algorithm is similar to that of Theorem \ref{EQlearn}. However, the applications of Lemma \ref{unionlemma} are replaced with membership queries.} We proceed by induction on $d$. The base case, $d = 0$, is trivial, as then $\mathcal{C}$ is a singleton. Suppose there is some element $x$ such that $\Ldim(\mathcal{C} \cap x) < d + 1$ and $\Ldim(\mathcal{C} \setminus x) < d + 1$, where $\mathcal{C} \cap x := \{ A \in \mathcal{C} \, | \, x \in A \}$ and $\mathcal{C} \setminus x := \{ A \in \mathcal{C} \, | \, x \notin A \}$. Then by induction, any concept in $\mathcal{C} \cap x$ can be learned in at most $c'd + 1$ queries with guesses from $\mathcal{H}$, and the same is true for $\mathcal{C} \setminus x$. Submit $x$ as a membership query. This tells us whether the target concept lies in $\mathcal{C} \cap x$ or $\mathcal{C} \setminus x$, and then we require at most $c'd + 1$ many queries, for a total of $c'd + 2 \leq c'(d+1) + 1$ many queries. If no such $x$ exists, then for all $x$, either $\Ldim(\mathcal{C} \cap x) = d + 1$ or $\Ldim(\mathcal{C} \setminus x) = d + 1$. Let $B$ be such that $x \in B$ iff $\Ldim(\mathcal{C} \cap x) = d+1$. If $B \in \mathcal{H}$, then we submit $B$ as our query. If we are incorrect, then by choice of $B$, the class $\mathcal{C}'$ of concepts consistent with the counterexample $x_0$ will have Littlestone dimension $\leq d$. By induction, any concept in $\mathcal{C}'$ can be learned in at most $c'd + 1$ many queries, and so we learn the target in at most $c'd + 2 \leq c'(d+1) + 1$ queries. If $B \notin H$, then, since $\C(\mathcal{C}, \mathcal{H}) = c$, there are some $x_0, \ldots, x_{c-1}$ such that there is no $A \in \mathcal{C}$ such that $B|_{\{x_0, \ldots, x_{c-1}\}} \sqsubseteq A$. (Observe that this cannot happen when $c = 1$. In fact, Proposition \ref{prop:C-SC12equal} and the proof of Proposition \ref{EQlearnSC2} imply that this cannot even happen when $c = 2$. In particular, $c' = c-1$.) Then, with notation as in the proof of Proposition \ref{stableEQlearningeasy}, \[ \mathcal{C} = (\mathcal{C}^{(x_0, 1-B(x_0))}) \cup \ldots \cup (\mathcal{C}^{(x_{c-1}, 1-B(x_{c-1}))}), \] and $\Ldim(\mathcal{C}^{(x_i, 1-B(x_i))}) \leq d$ for each $i$. By induction, any concept in each $\mathcal{C}^{(x_i, 1-B(x_i))}$ can be learned in at most $c'd + 1$ many queries. By submitting $x_0, \ldots, x_{c-2}$ as membership queries, we can determine some $i$ such that the target belongs to $\mathcal{C}^{(x_i, 1-B(x_i))}$ (if the result of each membership query on $x_j$ is $B(x_j)$, then we know that $i = c-1$). We therefore learn in at most $c'd + 1 + (c-1) = c'(d+1) + 1$ many queries. \end{proof} We have a lower bound on learning complexity in terms of consistency dimension in this setting analogous to Proposition \ref{prop:Clowerbound}: \begin{prop} \label{goodlower} Suppose there is some (total) subset $A$ which is $n$-consistent with $\mathcal{C}$ but which does not have a total extension in $\mathcal{H}$. Then $n < \LC^{EQ+ MQ}(\mathcal{C}, \mathcal{H})$. In particular, $\C(\mathcal{C}, \mathcal{H}) \leq \LC^{EQ + MQ}(\mathcal{C}, \mathcal{H})$. \end{prop} \begin{proof} We first show that $n < \LC^{EQ+ MQ}(\mathcal{C}, \mathcal{H})$. If the learner submits $x$ as a membership query, the teacher returns $A(x)$ if possible, that is, if there is a concept $B \in \mathcal{C}$ which agrees with the previous data and satisfies $B(x) = A(x)$. By hypothesis, given any equivalence query $H$, the teacher can find some $x \in \dom(A)$ such that $H(x) \neq A(x)$, and the teacher returns a counterexample of this form if possible, that is, if there is a concept $B \in \mathcal{C}$ which agrees with the previous data and satisfies $B(x) = A(x)$. Moreover, since $A$ is $n$-consistent with $\mathcal{C}$, the teacher is able to return data of this form for the first $n$ queries. Thus $\mathcal{C}$ cannot be learned with fewer than $n + 1$ equivalence queries from $\mathcal{H}$. From this, it follows that $\C(\mathcal{C}, \mathcal{H}) \leq \LC^{EQ + MQ}(\mathcal{C}, \mathcal{H})$. \end{proof} Finally, putting together the various upper and lower bounds from this section we give a characterization of those problems efficiently learnable by equivalence and membership queries: \begin{thm} \label{polylowereqmq} Let $(\mathcal C_n, \mathcal H_n)_{n \in \mathbb{N}}$ be a family of concept classes and hypothesis classes, respectively. Let $c_n = \C( \mathcal C_n , \mathcal H_n ).$ Let $d_n = \Ldim (\mathcal C_n ).$ The following are equivalent: \begin{description} \item[(i)] $\LC^{EQ+MQ}(\mathcal{C}_n, \mathcal{H}_n)$ is bounded by a polynomial in $n$. \item[(ii)] $c_n$ and $d_n$ are bounded by a polynomial in $n$. \item[(iii)] The algorithm from Theorem \ref{EQMQalg} learns $\mathcal C_n$ in at most polynomially in $n$ many membership queries and equivalence queries in $\mathcal H_n$. \end{description} \end{thm} \begin{proof} (ii) $\Rightarrow$ (iii) follows immediately from Theorem \ref{EQMQalg}, and (iii) $\Rightarrow$ (i) follows by definition of learning complexity. (i) $\Rightarrow$ (ii): In Proposition \ref{goodlower}, we showed that $\LC^{EQ+MQ} ( \mathcal C , \mathcal H ) \geq \C(\mathcal C, \mathcal H),$ so it follows that if $c_n$ is not polynomially bounded then neither is $\LC^{EQ+MQ} ( \mathcal C _n , \mathcal H _n)$. Now suppose that $d_n$ is not polynomially bounded. By \cite[Theorem 2.1]{auer1994simulating} \footnote{The inequality of \cite{auer1994simulating} gives a lower bound for $\LC^{EQ+MQ}$ which improved on the lower bound of $\frac{\LC ^{EQ} (\mathcal C , \mathcal P(X))}{\log (1+\LC ^{EQ} (\mathcal C , \mathcal P(X)))}$ from \cite[Theorem 3]{maass1990complexity}. In fact, Theorem 3 of \cite{maass1990complexity} actually suffices for our purposes.} we have $$\LC^{EQ+MQ}( \mathcal C , \mathcal H ) \geq \LC^{EQ+MQ}( \mathcal C , \mathcal P(X)) \geq \log \left(\frac{4}{3} \right) \cdot \LC^{EQ} (\mathcal C , \mathcal P(X)).$$ By \cite[Theorems 5 and 6]{littlestone1988learning}, we can replace $\LC ^{EQ} (\mathcal C , \mathcal P(X))$ with $\Ldim(\mathcal C).$ Thus: \[ \LC^{EQ+MQ}( \mathcal C_n , \mathcal H_n ) \geq \log \left(\frac{4}{3} \right) \cdot d_n, \] from which it follows that $\LC^{EQ+MQ}( \mathcal C_n , \mathcal H_n )$ is not polynomially bounded. \end{proof} Finally, the upper and lower bounds of this section also yield a characterization of which infinite classes are learnable in finitely many equivalence and membership queries. \begin{cor} $\LC^{EQ+MQ}(\mathcal{C}, \mathcal{H}) < \infty$ iff $\Ldim(\mathcal{C}) < \infty$ and $\C(\mathcal{C}, \mathcal{H}) < \infty$. \end{cor} \subsection{The negation of the finite cover property} \label{NFCP} One can compare set systems with finite strong consistency dimension, to the model-theoretic classes of formulas and theories without the \emph{finite cover property}, which we define below. Informally, the negation of the finite cover property allows for a specific quantitative bound for applications of compactness. \begin{defn} Fix a first order theory $T$. A formula $\phi(x;y)$ in the language of $T$ \emph{does not have the finite cover property (ncfp)} if there is $n = n(\phi)$ such that for all $\mathcal{M} \models T$, and every $p \subseteq \{\phi(x;a), \neg \phi(x;a) \, | \, a \in M\}$, the following holds: if every $q \subseteq p$ of size $n$ is consistent, then $p$ is consistent. We let $n(\phi)$ denote the minimal such $n$. $T$ does not have the finite cover property if all formulas $\phi(x;y)$ do not have the finite cover property.\footnote{The definition of nfcp on the formula level given here is stronger than original formulation in \cite{shelah1990classification}, but it gives an equivalent characterization on the level of theories.} \end{defn} Consider the setting where $\mathcal{C}$ is generated by a formula $\phi(x; y)$, that is, $\mathcal{M} \models T$ and $$\mathcal{C} = \mathcal{C}_\phi = \{ \phi(M;b) \, | \, b \in M \} .$$ That is, $\mathcal{C}_\phi$ consists of the $\phi$-definable sets. Suppose $\phi^{opp}(y;x) = \phi(x;y)$ does not have the finite cover property, witnessed by some $n = n(\phi^{opp})$. Then, given any disjoint $A_0, A_1 \subseteq X$, if every size $n$ subset of \[ p(y) := \{\phi^{opp}(y;a) \, | \, a \in A_1 \} \cup \{\neg \phi^{opp}(y;a)\, | \, a \in A_0 \} \] is consistent, then $p(y)$ is consistent. We can identify this partial type with the partially specified subset $A$ where \[ A(x) = \begin{cases} 0 & x \in A_0 \\ 1 & x \in A_1 \\ \text{unspecified} & \text{otherwise.} \end{cases} \] By passing to an $|M|^+$-saturated extension $\mathcal{N} \succ \mathcal{M}$ to obtain a larger parameter set, we can find $b' \in \mathcal{N}$ satisfying $p(y)$. Then $\phi(M, b')$ is a total extension of $A$. Supposing we have passed to an $|\mathcal{M}|^+$ saturated extension $\mathcal{N}$, we can let $$\mathcal{H} = \mathcal{H}_\phi := \{ \phi(M;b') \, | \, b' \in N\} .$$ That is, $\mathcal{H}_\phi$ consists of all externally $\phi$-definable subsets of $M$, as $N$ contains realizations of all consistent partial $\phi^{opp}$-types over $M$. By the compactness theorem, this means that $N$ contains realizations of all finitely consistent partial $\phi^{opp}$-types over $M$. Having identified partially specified subsets of $M$ with their corresponding $\phi^{opp}$-type, this amounts to observing that $\mathcal{H}_\phi$ contains total extensions of all finitely consistent partially specified subsets, equivalently, contains all finitely consistent total subsets. This gives a model-theoretic motivation to the strategy suggested by Proposition \ref{prop:SCproperties}. Adding all finitely consistent subsets to $\mathcal{H}$ amounts to saturating $\mathcal{N}$ so as to realize all $\phi^{opp}$-types over $\mathcal{M}$. If $\phi^{opp}$ has nfcp with $n(\phi)=n$, then the finitely consistent partial types are exactly the $n$-consistent types. Then $\mathcal{H}_\phi$ contains total extensions of all $n$-consistent partially specified subsets, so $SC(\mathcal{C}_\phi, \mathcal{H}_\phi) = n$. Note that $\phi^{opp}$-types witnessing that $n$ is the minimal such $n$ at which $\phi^{opp}$ has nfcp give partially specified subsets witnessing that $\SC(\mathcal{C}_\phi, \mathcal{H}_\phi) \not < n$. This reflects a variant of Proposition \ref{prop:SCproperties} for strong consistency dimension. In particular, formulas $\phi$ such that $\phi^{opp}$ has nfcp provide a rich family of examples where $\mathcal{C}_\phi$ has finite (strong) consistency threshold. That is, for such $\phi$, it is necessary and sufficient for $\mathcal{H}$ to contain all externally $\phi$-definable subsets (that is, all total finitely consistent partially specified subsets) to obtain $\SC(\mathcal{C}, \mathcal{H}) < \infty$. On the other hand, when $\phi^{opp}$ has the finite cover property, the externally definable sets are no longer sufficient, and one must venture beyond the sets $\phi$ is capable of cutting out to obtain $\SC(\mathcal{C}, \mathcal{H}) < \infty$ (that is, by adding some sets which are inconsistent). Furthermore, Littlestone dimension of $\phi(x;y)$ (that is, the Littlestone dimension of $\mathcal{C}_\phi$) is expressible as a first-order property. So we will have $\Ldim(\mathcal{C}) = \Ldim(\mathcal{H})$. So when the context is a set system $\mathcal{C}$ generated by a stable formula $\phi(x;y)$ with $\phi^{opp}(y;x)$ nfcp, we can obtain a set system $\mathcal{H}$ such that $\SC(\mathcal{C}, \mathcal{H}) < \infty$, but $\mathcal{H}$ is not much more complicated than the original set system - $\mathcal H$ has the same Littlestone dimension as $\mathcal C$. This is essentially the content of Theorem \ref{thm:fixedLdim} when $\mathcal{C}$ has finite consistency threshold. We give an example from model theory where $\phi^{opp}$ has the fcp. \begin{exam} Let $\mathcal{M}$ be a structure in the language $\{E\}$, where $E$ is an equivalence relation with one class of size $n$ for each $n \in \mathbb{N}$, possibly with some infinite classes. Let \[ \phi(x;y) \quad \text{be} \quad E(x,y) \wedge x \neq y \] and let $\mathcal{C} = \mathcal{C}_\phi$. Suppose $a_1, \ldots, a_d$ are the elements belonging to the equivalence class of size $d$. Then the $\phi^{opp}$-type $\{\phi(a_i, y) \, | \, i \leq d \}$ $(d-1)$-consistent but $d$ inconsistent. Since there are equivalence classes of arbitrarily large size, these witness that $\phi^{opp}$ is not nfcp. One can check that $\Ldim(\mathcal{C}_\phi) = 2$. In any $|M|^+$-saturated elementary extension $\mathcal{N}$ of $\mathcal M$, no additional elements are added to the finite equivalence classes already present in $\mathcal M$, though $\mathcal{N}$ adds new infinite classes and new elements to any existing infinite classes. An attempt to learn $\mathcal{C}_\phi$ by equivalence queries following the strategy of Theorem \ref{EQlearn} would be as follows. We are attempting to identify some $c \in M$. Letting $a_0$ be an element in a new infinite equivalence class in $\mathcal{N}$, we guess $\phi(M, a_0) = \emptyset$. Then any counterexample will identify an element belonging to the equivalence class of $c$. If $c$ belongs to an infinite class, then we can find some $a_1 \in N$ which is a new element of this class. Then $\phi(M, a_1) = \{b \in M \, | \, E(b, c)\}$. Then $c$ is the only available counterexample, and we submit the correct concept $\phi(M, c)$ at our next turn. However, if $c$ belongs to the finite class of size $n$, then $N$ has no new elements in this class. Then the relevant queries, which are of the form $\phi(M, a)$ for $a$ in the class of $c$, are already present in $\mathcal{C}_\phi$. Then we are essentially attempting to identify a singleton from a set of size $n$, and it is clear that the process could take up to $n$ additional guesses. \end{exam} \section{Efficient learnability of regular languages} \label{applications} In a seminal paper, \cite{angluin1987learning} showed that regular languages are efficiently learnable with equivalence queries plus membership queries, and in this subsection, we will use Theorem \ref{EQMQalg} to give an alternate short proof of this fact.\footnote{In the following sections, we only make use of \emph{proper equivalence queries}, that is, $\mathcal{H} = \mathcal{C}$. We shall therefore let $\C(\mathcal{C}) := \C(\mathcal{C}, \mathcal{C})$, which we will call the consistency dimension of $\mathcal{C}$ (with analogous notation for strong consistency dimension).} Let $\mathcal L_{n,m}$ be the class of binary regular languages on strings of length at most $m$ specified by a deterministic finite automaton on at most $n$ nodes. The $\mathcal L^*$ algorithm of \cite{angluin1987learning} specifically uses $\mathcal O(n)$ equivalence queries and $\mathcal O(mn^2)$ membership queries. We let $DFA_2(n)$ denote the collection of (equivalence classes of) deterministic finite automata accepting binary strings and having at most $n$ nodes. The proof of the next proposition is straightforward. \begin{prop} \label{LDDFA} The Littlestone dimension of $DFA_2(n)$ is at most $ o (1) (n \log n)$. \end{prop} \begin{proof} In \cite[Proposition 1]{ishigami1997vc}, it is shown that $|DFA_2 (n)| \leq \frac{n^{2n} 2^n n }{n!} \leq 2^ { o (1)( n \log n) }.$ From this, it follows that the Littlestone dimension of $DFA_2 (n)$ is at most $ o(1) ( n \log n)$. \end{proof} The proof of the following proposition reveals the connection between consistency and the Myhill-Nerode theorem. \begin{prop} \label{CDDFA} $\C(DFA_2(n)) \leq 2\binom{n+1}{2} = n(n+1)$. \end{prop} \begin{proof} Fix a subset $C$ of binary strings and $x,y$ binary strings. We say that $z$ is a ($C$-) distinguishing extension of $x$ and $y$ if $x z \in C $ but $y z \notin C$ or vice versa. If $x$ and $y$ have no distinguishing extension, then we say $x$ and $y$ are $C$-equivalent, and write $x \sim_C y$. The Myhill-Nerode theorem \cite{nerode1958linear} says that a subset of binary strings of length $m$ is the accept set of a finite automaton with at most $n$ nodes if and only if the number of $\sim_C $ classes is at most $n$. Thus, given any subset $C$ of the binary strings of length $m$ which is not a regular language recognized by an automaton with at most $n$ nodes, there are at least $n+1$ $\sim _C $-classes of elements. Pick representatives $x_0, \ldots, x_n$ from $n+1$ classes, and for each $i < j$, pick some $z_{ij}$ that is a distinguishing extension of $x_i$ and $x_j$. Then restricting $C$ to the partial assignment on $\{ x_k z_{ij} \, | \, i < j, \, k = i, j \}$, a domain of size $2 \binom{n+1}{2} = n(n+1)$ that witnesses that $x_i \not \sim _C x_j$ for all $i \neq j$, we can see that this restriction is inconsistent with the class of regular languages recognized by automata with at most $n$ nodes. Therefore $\C(DFA_2(n)) \leq n(n+1)$. \footnote{Note that the same proof shows that the consistency dimension of $DFA_m (n)$ is also at most $n(n+1)$.} \end{proof} Now, by Theorem \ref{EQMQalg} and the previous two results, it follows that: \begin{thm} The class $\mathcal L_{n,m}$ is learnable in at most $o(1) n \log n$ equivalence queries and at most $o(1)\left( n \log n \right) (n(n+1))$ membership queries. \end{thm} It is interesting to note that contrary to $\mathcal L^*$, when using the algorithm from Theorem \ref{EQMQalg}, there is no dependence on $m$, the length of the binary strings which the teacher is allowed to provide as counterexamples\footnote{We should also note that $\mathcal L^*$ was improved by Schapire to give a better bound on membership queries (still depending on $m$). \cite{schapire1991design}.}. Theorem \ref{EQlearn} now implies that $\mathcal L_{n,m}$ is learnable in at most $( n(n+1) )^ {(o(1) n \log n)}$ equivalence queries. Theorem \ref{thmFiniteEQlearningBalcazar} shows that a finite class $\mathcal C$ is learnable in at most $\lceil \SC(\mathcal C) \cdot \ln|\mathcal C| \rceil$ equivalence queries. Since \cite{angluin1990negative} showed that $\mathcal L_{n,m}$ is not learnable in polynomially many equivalence queries, it follows that $\SC(\mathcal L_{n,m})$ cannot be polynomial in $n,m$. \subsection{Learning $\omega$-languages} \label{omegaLanguage} In this section, we consider the natural extension to languages on infinite strings indexed by $\omega$, called $\omega$-languages. For an alphabet $\Sigma$, we denote by $\Sigma ^ \omega$, the strings of symbols from $\Sigma$ of order type $\omega$. Similar to the previous section, we consider an automaton, which consists of the collection $\mathbb A = (\Sigma, Q, q_0, \delta),$ where $Q$ is a finite collection of states, $q_0$ is the initial state, and $\delta: Q \times \Sigma \rightarrow 2^Q$ is a transition rule. To form a language, an automaton is equipped with an acceptance criterion.\footnote{Numerous acceptance criteria have been extensively studied in the literature, and we refer the reader to \cite{angluin2016learning,fisman2018families,fisman2018inferring} for overviews.} Fix a subset $F \subseteq Q$. A run of a \emph{B\"uchi automaton} is accepting if and only if it visits the set $F$ infinitely often. An $\omega$-language is $\omega$-regular if it is recognized by a non-deterministic B\"uchi automaton. A run of a \emph{co-B\"uchi automaton} is accepting if and only if it visits $F$ only finitely often. Let $\psi: Q \rightarrow \{ 1, \ldots , k \}$ be a function, which we think of as a coloring of the states of the automaton. Let $c$ be the minimum color which is visited infinitely often. A run of a \emph{parity automaton} is accepting if and only if $c$ is odd. Two $\omega$-regular languages are equivalent if they agree on the set of periodic words \cite{mcnaughton1966testing}, which allows for the possibility of recognizing the $\omega$-language using finitary automata. This is the approach of \cite{angluin2016learning, fisman2018families}, whose notation we follow closely. A \emph{family of DFAs} (FDFA) $\mathcal F$ is a pair $(Q,P)$ where $Q$ is a DFA with $|Q|$ states and $P$ is a collection of $|Q|$ many DFAs, which we refer to as \emph{progress DFAs} - one DFA $P_q$ for each state $q$ of $Q$. Given a pair of finite words, $(u,v)$, a run of our family of DFAs consists of running $Q$ on $u$, then running $P_{Q(u)}$ on $v$ where $Q(u)$ is the ending state of $Q$ on $u$. The pair $(u,v)$ can be used to represent an infinite periodic word $uv^\omega$. Let $FDFA(n,m)$ be the class of families of deterministic finite automata where the leading automaton has at most $n$ nodes and the progress automata each have at most $m$ nodes. It is \emph{not} quite true that once an $\omega$-regular language has been reduced to an FDFA that one can use $\mathcal L^*$ directly to learn the various DFAs in the family \cite[section 4]{angluin2016learning}. It is also not completely obvious what the bounds for Littlestone and consistency dimension are in terms of the DFAs in the family, but the next two results give such bounds which imply the efficient learnability of $\omega$-regular languages. \begin{prop} \label{LDFDFA} The class $FDFA(n,m)$ has Littlestone dimension at most $ o(1) (n \log n + n m \log m ).$ \end{prop} \begin{proof} The number of FDFAs of size $(n,m)$ is clearly at most $|DFA_2(n)| \cdot |DFA_2(m)|^n.$ That is $$|FDFA (n,m) | \leq |DFA_2 (n) | \cdot |DFA_2(m)|^n.$$ It follows that $$\Ldim(FDFA(n,m)) \leq \log (|DFA_2 (n) | \cdot |DFA_2(m)|^n) $$ and using \cite[Proposition 1]{ishigami1997vc}, the desired bound follows. \end{proof} \begin{prop} \label{CDFDFA} $\C(FDFA(n,m)) \leq 2\binom{n(m+1)}{2} = \mathcal O(n^2m^2)$. \end{prop} \begin{proof} A run of an FDFA on $(u,v)$ can be simulated by the run of an appropriate automaton in the class $DFA_3 (n \cdot (m+1)).$ To see this, input word $u \$ v$ where $\$$ is a new symbol (recall we are assuming $u,v$ are binary) to a DFA which has the same diagram as the FDFA but with an edge labeled with $\$$ from each state of the leading automaton to the initial state of the corresponding progress DFA. Now it follows by Proposition \ref{CDDFA} that the consistency dimension of $FDFA(n,m)$ is at most $2\binom{n(m+1)}{2}.$ \end{proof} Using the previous two results together with Theorem \ref{EQMQalg}, one can deduce the efficient learnability of $FDFA(n,m)$: \begin{thm} The class $FDFA(n,m)$ is learnable in at most $o (1) (n \log n +n \cdot m \log m )$ equivalence queries and at most $o (1) (\log n + m \log m ) \cdot n^3m^2$ membership queries. \end{thm} We have formulated our bounds in terms of the number of states in the FDFA corresponding to a given $\omega$-language. In \cite{angluin2016learning,fisman2018families} bounds on the number of states of FDFAs in terms of the number of states of automata for $\omega$-languages with various acceptors are given. Specifically, the following bounds hold: \begin{enumerate} \item When $\mathcal A$ is a deterministic B\"uchi (DBA) or co-B\"uchi (DCA) automaton with $n$ states, there is an equivalent FDFA of size at most $(n,2n)$ \cite[5.3]{fisman2018families}. \item When $\mathcal A$ is a deterministic partiy automaton (DPA) with $n$ states and $k$ colors, there is an equivalent FDFA of size at most $(n, kn)$ \cite[5.4]{fisman2018families}. \item When $\mathcal A$ is an nondeterministic B\"uchi automaton (NBA) with $n$ states, there is an equivalent FDFA of size at most $(2 ^ {\mathcal O (n \log n ) }, 2 ^ {\mathcal O (n \log n)})$. \end{enumerate} Any NBA can be translated into a DPA, and so 2) yields the efficient learnability of $\omega $-regular languages \emph{in terms of the number of states in a DPA} (this translation also yields 3). However, the translation from NBA to DPA is known to require an exponential increase in the number of states in general \cite{piterman2006nondeterministic}. From an FDFA of size at most $(n,k)$ there is a translation into an NBA with at most $\mathcal O ( n^2 k^3)$ states \cite[Theorem 5.8]{fisman2018families}, and so it follows that the exponential increase in states in moving from NBAs to FDFAs is necessary \cite[Theorem 5.6]{fisman2018families}. Finally, we mention that \cite{angluin2018regular} define restricted classes of $\omega$-languages for which right-congruence is \emph{fully informative}, and isolate numerous classes (e.g. for each type of acceptor from the previous subsection) of $\omega$-languages for which an infinitary invariant of the Myhill-Nerode theorem holds. This variant of Myhill-Nerode is sufficient to bound the consistency dimension (and thus establish the learnability) of the classes in terms of the number of of right equivalence classes of $\sim _{\mathcal L}$ similar to the proof of Proposition \ref{CDDFA}. \section{Random counterexamples and EQ-learning} \label{randomeq} In section \ref{basicEQ} we characterized learnability by equivalence queries in terms of Littlestone dimension and strong consistency dimension. The setting of equivalence query learning \cite{angluin1988queries} as described in section \ref{basicEQ} deals with worst-case bounds for algorithmic identification of concepts by a learner. In this section, we follow \cite{angluin2017power} and analyze a slightly different situation, in which the teacher selects the counterexamples at random, and we seek to bound the \emph{expected} number of queries. \cite{angluin2017power} worked specifically with concept classes coming from boolean matrices, which was convenient for their notation. Our formulation is equivalent, but we use slightly different notation. Throughout this section, let $X$ be a finite set, let $\mathcal C$ be a set system on $X$, and let $\mu$ be a probability measure on $X$. For $A,B \in \mathcal C$, let $\Delta (A,B) = \{x \in X \, | \, A(x) \neq B(x) \}$ denote the symmetric difference of $A$ and $B$. \begin{defn} We denote, by $\mathcal C_{\bar x = \bar i}$ for $\bar x \in X^n$ and $\bar i \in \{0,1\}^n$, the set system $ \{A \in \mathcal C \, | \, A(x_j )= i_j , \, j=1, \ldots , n \}.$ For $A \in \mathcal C$ and $a \in X$, we let $$u(A,a) = \Ldim (\mathcal C) - \Ldim (\mathcal C _{a = A(a)} ).$$ \end{defn} For any $a \in X,$ either $\mathcal C_{a=1}$ or $\mathcal C_{a=0}$ has Littlestone dimension strictly less than that of $\mathcal C$ and so: \begin{lem} \label{ulemma} For $A, B \in \mathcal C$ and $a \in X$ with $A(a) \neq B(a),$ $$u(A,a ) + u (B, a) \geq 1.$$ \end{lem} Next, we define a directed graph which is similar to the \emph{elimination graph} of \cite{angluin2017power}. \begin{defn} We define the \emph{thicket query graph} $G_{TQ}(\mathcal C , \mu )$ to be the weighted directed graph on vertex set $\mathcal C$ such that the directed edge from $A$ to $B$ has weight $d(A,B)$ equal to the expected value of $\Ldim(\mathcal C)- \Ldim(\mathcal C _{x = B(x)}) $ over $x \in \Delta (A,B)$ with respect to the distribution $\mu |_{\Delta(A,B)}.$ \footnote{Here one should think of the query by the learner as being $A$, and the actual hypothesis being $B$. The teacher samples from $\Delta(A,B)$, and the learner now knows the value of the hypothesis on $x$.} \end{defn} \begin{defn} The \emph{query rank} of $A \in \mathcal C$ is defined as: $\inf _{B \in \mathcal C } (d(A,B)).$ \end{defn} \begin{lem} \label{Lem13} For any $A \neq B \in \mathcal C$, $d(A, B)+d(B,A) \geq 1.$ \end{lem} \begin{proof} Noting that $\Delta (A,B) = \Delta (B,A),$ and using Lemma \ref{ulemma}: \begin{eqnarray*} d(A,B) + d(B,A) & = & \sum _{a \in \Delta (A,B)} \frac{\mu(a)}{\mu (\Delta (A,B))} (u(A,a)+u(B,a)) \\ & \geq & \sum _{a \in \Delta (A,B)} \frac{\mu(a)}{\mu (\Delta (A,B))} = 1. \end{eqnarray*} \end{proof} \begin{defn} \cite[Definition 14]{angluin2017power} Let $G$ be a weighted directed graph and $ l \in \mathbb N, \, l >1.$ A \emph{deficient $l$-cycle} in $G$ is a sequence $v_0, \ldots v_{l-1}$ of distinct vertices such that for all $i \in [l]$, $d(v_i , v_{(i+1) \, (\mod l) } ) \leq \frac{1}{2}$ with strict inequality for at least one $i \in [l]$. \end{defn} The next result is similar to Theorems 16 (the case $l=3$) and Theorem 17 (the case $l >3$) of \cite{angluin2017power}, but our proof is rather different (note that the case $l=2$ follows easily from Lemma \ref{Lem13}). \begin{thm} \label{nocycles} The thicket query graph $G_{TQ} (\mathcal C , \mu)$ has no degenerate $l$-cycles for $l \geq 2.$ \end{thm} The analogue of Theorem 16 can be adapted in a very similar manner to the technique employed by \cite{angluin2017power}. However, the analogue of the proof of Theorem 17 falls apart in our context; the reason is that Lemma \ref{ulemma} is analogous to Lemma 6 of \cite{angluin2017power} (and Lemma \ref{Lem13} is analogous to Lemma 13 of \cite{angluin2017power}), but our lemmas involve inequalities instead of equations. The inductive technique of \cite[Theorem 17]{angluin2017power} is to shorten degenerate cycles by considering the weights of a particular edge in the elimination graph along with the weight of the edge in the opposite direction. Since one of those weights being large forces the other to be small (by the \emph{equalities} of their lemmas), the induction naturally separates into two useful cases. In our thicket query graph, things are much less tightly constrained - one weight of an edge being large does not force the weight of the edge in the opposite direction to be small. However, the technique employed in our proof seems to be flexible enough to adapt to prove Theorems 16 and 17 of \cite{angluin2017power}. \begin{proof} Suppose the vertices in the degenerate $l$-cycle are $A_0, \ldots , A_{l-1} $. By the definition of degenerate cycles and $d(-,-),$ we have, for each $i \in \mathbb Z / l \mathbb Z$, that $$\sum _{a \in \Delta (A_i, A_{i+1}) } \frac{\mu(a)}{\mu (\Delta (A_i ,A_{i+1}))} u(A_i,a) \leq \frac{1}{2},$$ so clearing the denominator we have \begin{equation} \label{firsteqn} \sum _{a \in \Delta (A_i,A_{i+1})} \mu(a) u(A_i,a) \leq \frac{1}{2} \mu (\Delta (A_i,A_{i+1})). \end{equation} \emph{Note that throughout this argument, the coefficients are being calculated modulo $l$.} Notice that for at least one value of $i$, the inequality in \ref{firsteqn} must be strict. Let $G, H$ be a partition of $$\mathcal X = \{ A_1, \ldots , A_l \}.$$ Now define $$D (G, H) := \left \{a \in X \, | \, \forall A_1,B_1 \in G, \, \forall A_2, B_2 \in H,\, A_1(a) = B_1 (a), \, A_2(a) = B_2 (a), A_1(a) \neq A_2 (a) \right \}.$$ The following fact follows from the definition of $\Delta (A, B) $ and $D(-,-)$. \begin{fact} \label{usefulfact} The set $\Delta (A_i , A_{i+1} )$ is the disjoint union, over all partitions of $\mathcal X$ into two pieces $G,H$ such that $A_i \in G$ and $A_{i+1} \in H$ of the sets $D(G,H).$ \end{fact} Now, take the sum of the inequalities \ref{firsteqn} as $i$ ranges from $1$ to $l$. On the LHS of the resulting sum, we obtain $$\sum _{i=1} ^ l \left( \sum _{G, H \text{ a partition of $\mathcal X$},\, A_i \in G, A_{i+1} \in H} \left( \sum_{a \in D(G,H)} \mu(a) u(A_i,a) \right) \right).$$ On the RHS of the resulting sum we obtain $$ \frac{1}{2} \sum _{i=1} ^ l \left( \sum _{G, H \text{ a partition of $\mathcal X$},\, A_i \in G, A_{i+1} \in H} \left( \sum_{a \in D(G,H)} \mu(a) \right) \right).$$ Given a partition $G,H$ of $\{ A_1, \ldots , A_l \}$ we note that the term $D(G,H) = D(H,G)$ appears exactly once as an element of the above sum for a fixed value of $i$ exactly when $A_i \in G$ and $A_{i+1} \in H$ or $A_i \in H$ and $A_{i+1} \in G.$ Consider the partition $G,H$ of $\mathcal X$. Suppose that $A_j , A_{j+1} , \ldots , A_k $ is a block of elements each contained in $G$, and that $A_{j-1}, A_{k+1} $ are in $H$. Now consider the terms $i=j-1$ and $i=k$ of the above sums (each of which where $D(G,H)$ appears). On the left hand side, we have $\sum _{a \in D(G,H) } \mu (a) u ( A_{j-1} ,a )) $ and $\sum _{a \in D(G,H) } \mu (a) u ( A_{k} ,a )) $. Note that for $a \in D(G,H)$, we have $a \in \Delta (A_{j-1}, A_k).$ So, by Lemma \ref{ulemma}, we have $$\sum _{a \in D(G,H) } \mu (a) u ( A_{j-1} ,a )) + \sum _{a \in D(G,H) } \mu (a) u ( A_{k} ,a )) \geq \sum _{a \in D(G,H) } \mu (a) .$$ On the RHS, we have $$\frac{1}{2} (\sum _{a \in D(G,H) } \mu (a) +\sum _{a \in D(G,H) } \mu (a) ) = \sum _{a \in D(G,H) } \mu (a) .$$ For each $G,H$ a partition of $X$, the terms appearing in the above sum occur in pairs as above by Fact \ref{usefulfact}, and so, we have the the LHS is at least as large as the RHS of the sum of inequalities \ref{firsteqn}, which is impossible, since one of the inequalities must have been strict by our degenerate cycle. \end{proof} \begin{thm} \label{qrlowbound} There is at least one element $A \in \mathcal C$ with query rank at least $\frac{1}{2}$. \end{thm} \begin{proof} If not, then for every element $A \in \mathcal C$, there is some element $B \in \mathcal C$ such that $d(A,B) < \frac{1}{2}$. So, pick, for each $A \in \mathcal C$, an element $f(A)$ such that $d(A,f(A)) < \frac{1}{2}.$ Now, fix $A \in \mathcal C$ and consider the sequence of elements of $\mathcal C$ given by $(f^i (A))$; since $\mathcal C$ is finite, at some point the sequence repeats itself. So, take a list of elements $B, f(B) , \ldots , f^n (B) = B$. By construction, this yields a bad cycle, contradicting Theorem \ref{nocycles}. \end{proof} \subsection{The thicket max-min algorithm}\label{app:Thicketminmax} In this subsection we show how to use the lower bound on query rank proved in Theorem \ref{qrlowbound} to give an algorithm which yields the correct concept in linearly (in the Littlestone dimension) many queries from $\mathcal{C}$. The approach is fairly straightforward---essentially the learner repeatedly queries the highest query rank concept. The approach is similar to that taken in \cite[Section 5]{angluin2017power} but with query rank in place of their notion of \emph{informative}. Now we informally describe the thicket max-min-algorithm. At stage $i$, the learner is given information of a concept class $\mathcal C_i .$ The learner picks the query $$A= \text{arg max} _ {A \in \mathcal C_i} \left( \text{min}_ {B \in \mathcal C_i} \, d_{\mathcal C_i}( A,B) \right).$$ The algorithm halts if the learner has picked the actual concept $C$. If not, the teacher returns a random element $a_i \in \Delta (A,C)$ at which point the learner knows the value of $C (a_i).$ Then $$\mathcal C_{i+1} = (\mathcal C_i) _{a_i= C(a_i)}.$$ Let $T(\mathcal C)$ be the expected number of queries before the learner correctly identifies the target concept. \begin{thm} The expected number of queries to learn a concept in a class $\mathcal C$ is less than or equal to $2 \Ldim (\mathcal C).$ \end{thm} \begin{proof} The expected drop in the Littlestone dimension of the concept class induced by any query before the algorithm terminates is at least $\frac{1}{2}$ by Theorem \ref{qrlowbound}; so the probability that the drop in the Littlestone dimension is positive is at least $\frac{1}{2} $ for any given query. So, from $2n$ queries, one expects at least $n$ drops in Littlestone dimension. \end{proof} We give a rough bound on the probability that the algorithm has not terminated after a certain number of queries. Since a query can reduce the Littlestone dimension of the induced concept class by at most $\Ldim(\mathcal{C})$ and the expected drop is at least $\frac{1}{2}$, the probability that a query reduces the Littlestone dimension is at least $\frac{1}{2\Ldim(\mathcal{C})}$. Then the probability that the Littlestone dimension of the induced concept class after $n$ queries is positive is at most the probability of fewer than $\Ldim(\mathcal C)$ many successes in the binomial distribution with probability $\frac{1}{2\Ldim(\mathcal{C})}$ and $n$ trials. It follows by Hoeffding's inequality that the probability that the algorithm has not terminated after $n$ steps is at most $$e^{-2\frac{\left(\frac{n}{2\Ldim(\mathcal{C})}-\Ldim(\mathcal C)\right)^2}{n}}.$$ \section{Compression schemes and stability} \label{compression} In this section, we follow the notation and definitions given in \cite{guingonanip} on \emph{compression schemes}, a notion due to Littlestone and Warmuth \cite{littlestone1986relating}. Roughly speaking, $\mathcal C$ admits a \emph{$d$-dimensional compression scheme} if, given any finite subset $F$ of $X$ and some $f\in \mathcal C$, there is a way of encoding the set $F$ with only $d$-many elements of $F$ in such a way that $F$ \emph{can be recovered}. We will give a formal definition, but we note that numerous variants of this idea appear throughout the literature. For instance: \begin{itemize} \item Size $d$-array compression \cite{ben1998combinatorial}. \item Extended compression schemes with $b$ extra bits \cite{floyd1995sample}. \end{itemize} The next definition, which is the notion of compression we will work with in this section is equivalent to the notion of a $d$-compression with $b$ extra bits (of Floyd and Warmuth) \cite[see Proposition 2.1]{johnson2010compression}. \begin{defn} We say that a concept class $\mathcal C$ has an \emph{$d$-compression} if there is a compression function $\kappa : \mathcal C_{fin} \rightarrow X^{ d}$ and a finite set $\mathcal R$ of reconstruction functions $\rho : X^d \rightarrow 2^X$ such that for any $f \in \mathcal C_{fin}$ \begin{enumerate} \item $\kappa (f) \subseteq dom(f)$ \item $f = \rho (\kappa (f))|_{dom(f)} $ for at least one $\rho \in \mathcal R.$ \end{enumerate} \end{defn} We work with the above notion mainly because it is the notion used in \cite{guingonanip}, and our goal is to improve a result of Laskowski appearing there \cite[Theorem 4.1.3]{guingonanip}. In \cite{johnson2010compression}, Laskowski and Johnson prove that the concept class corresponding to a stable formula has an extended $d$-compression for some $d$. The precise value of $d$ is not determined, but was conjectured to be the Littlestone dimension. A later unpublished result of Laskowski appearing as \cite[Theorem 4.1.3]{guingonanip} in fact showed that one could take $d$ equal to the Shelah 2-rank (Littlestone dimension) and uses $2^d$ many reconstruction functions. In Theorem \ref{JLbound}, we will show that $d+1$ many reconstruction functions suffice. The question of Johnson and Laskowski is the analogue (for Littlestone dimension) of a well-known open question from VC-theory \cite{floyd1995sample}: is there a bound $A(d)$ linear in $d$ such that every class of VC-dimension $d$ has a compression scheme of size at most $A(d)$? In general there is known to be bound which is at most exponential in $d$ \cite{moran2016sample}. \begin{defn} Suppose $\Ldim(\mathcal{C}) = d$. Given a partial function $f$, say that $f$ is \emph{exceptional} for $\mathcal{C}$ if for all $a \in \dom(f)$, \[ \mathcal{C}_{(a, f(a))} := \{ g \in \mathcal{C} \, | \, g(a) = f(a) \} \] has Littlestone dimension $d$. \end{defn} \begin{defn} Suppose $\Ldim(\mathcal{C}) = d$. Let $f_{\mathcal{C}}$ be the partial function given by \[ f_{\mathcal{C}}(x) = \begin{cases} 0 & \Ldim(\mathcal{C}_{(x,0)}) = d \\ 1 & \Ldim(\mathcal{C}_{(x,1)}) = d \\ \text{undefined} & \text{otherwise.} \end{cases} \] \end{defn} It is clear that $f_{\mathcal{C}}$ extends any partial function exceptional for $\mathcal{C}$. \begin{thm} \label{JLbound} Any concept class $\mathcal C$ of Littlestone dimension $d$ has an extended $d$-compression with $(d+1)$-many reconstruction functions. \end{thm} \begin{proof} If $d = 0$, then $\mathcal{C}$ is a singleton, and one reconstruction function suffices. So we may assume $d \geq 1$. Fix some $f \in \mathcal C_{fin}$ with domain $F$. We will run an algorithm to construct a tuple of length at most $d$ from $F$ by adding one element at each step of the algorithm. During each step of the algorithm, we also have a concept class $\mathcal C_i$, with $\mathcal C_0 = \mathcal C$ initially. If $f$ is exceptional in $\mathcal C_{i-1}$, then the algorithm halts. Otherwise, pick either: \begin{itemize} \item $a_i \in F$ such that $f(a_i)=1$ and \[ (\mathcal C_{i-1} )_{(a_i,1)} := \{g \,| \, g \in \mathcal C_{i-1}, \, g(a_i)=1 \} \] has Littlestone dimension less than $\Ldim(\mathcal{C}_{i-1})$. In this case, set $\mathcal C_i:= (\mathcal C_{i-1} )_{(a_i,1)}= \{g\,| \, g \in \mathcal C_{i-1}, \, g(a_i)=1 \}.$ \item $d_i \in F$ such that $f(d_i)=0$ and \[ (\mathcal C _{i-1})_{(d_i,0)} := \{g \,| \, g \in \mathcal C_{i-1}, \, g(d_i)=0 \} \] has Littlestone dimension less than $\Ldim(\mathcal{C}_{i-1})$. In this case, set $\mathcal C_i:= (\mathcal C_{i-1})_{(d_i,0)}.$ \end{itemize} We allow the algorithm to run for at most $d$ steps. There are two distinct cases. If our algorithm has run for $d$ steps, let $\kappa(f)$ be the tuple $(\bar a, \bar d)$ of all of the elements $a_i$ as above followed by all of the elements $d_i$ as above for $i=1, \ldots , d$. By choice of $a_i$ and $d_i$, this tuple consists of $d$ distinct elements. By construction the set \[ \mathcal C_{(\bar a , \bar d)} := \{ g \in \mathcal C | \, g(a_i ) = 1, \, g(d_i) =0 \} \] has Littlestone dimension $0$, that is, there is a unique concept in this class. So, given $(c_1, c_2, \ldots , c_n) \in X^d$ consisting of distinct elements, for $i=0, \ldots , d$, we let $\rho_i(c_1, \ldots, c_n)$ be some $g$ belonging to \[ \{g \in \mathcal C \, | \, g(c_j)=1 \text{ for } j\leq i, \, g(c_j )=0 \text{ for } j>i \}, \] if such a $g$ exists. By construction, for some $i$, the Littlestone dimension of the concept class $\{g \in \mathcal C \cap F \, | \, g(c_j)=1 \text{ for } j\leq i, \, g(c_j )=0 \text{ for } j>i \}$ is zero, and so $g$ is uniquely specified and will extend $f$. We handle cases where the algorithm halts early by augmenting two of the reconstruction functions $\rho_0$ and $\rho_1$ defined above. Because $\rho_0$ and $\rho_1$ have so far only been defined for tuples consisting of $d$ distinct elements, we can extend these to handle exceptional cases by generating tuples with duplicate elements. If the algorithm stops at some step $i>1$, then it has generated a tuple of length $i-1$ consisting of some elements $a_j$ and some elements $d_k$. Let $\bar a$ consist of the elements $a_j$ chosen during the algorithm, and let $\bar d$ consist of the elements $d_k$ chosen during the running of the algorithm. Observe that $f$ is exceptional for $\mathcal{C}_{(\bar{a}, \bar{d})}$. If $\bar{a}$ is not empty, with initial element $a'$, then let $\kappa(f) = (\bar a, a' , \bar d, a', \ldots , a') \in F^d$. From this tuple, one can recover $(\bar{a}, \bar{d})$ (assuming $\bar{a}$ is nonempty), so we let $\rho_1(\bar a, a' , \bar d, a', \ldots , a')$ be some total function extending $f_{\mathcal{C}_{(\bar{a}, \bar{d})}}$, which itself extends $f$. So $\rho_1(\bar{a}, \bar{d})$ extends $f$ whenever the algorithm halts before step $d$ is completed \emph{and} some $a_i$ was chosen at some point. If $\bar{a}$ is empty, then let $\kappa(f) = (\bar d , d', \ldots , d') \in F^d$, where $d'$ is the initial element of $\bar{d}$. From this tuple, one can recover $(\emptyset, \bar{d})$ (assuming $\bar{a}$ is empty), so we let $\rho_0(\bar d , d', \ldots , d')$ be total function extending $f_{\mathcal{C}_{(\emptyset, \bar{d})}}$, which itself extends $f$. Finally, if the algorithm terminates during step 1, then it has generated the empty tuple. In this case, let $\kappa(f) = (c, \ldots, c)$ for some $c \in F$. Then $\Ldim(\mathcal{C}) = \Ldim({\mathcal{C}}_{(c, l)})$ for some $l \in \{0,1\}$. In particular, if we have defined $\kappa(f') = (c, \ldots, c)$ above for some $f'$ where the algorithm only returns $c$ (rather than the empty tuple), then $1 - l = f'(c) \neq f(c)$, and so any such $f'$ is handled by $\rho_{1-l}$. So we may overwrite $\rho_l$ to set $\rho(c, \ldots, c)$ to be a total function extending $f_\mathcal{C}$, which itself extends $f$. For any tuple output by our algorithm, one of the reconstruction functions produces an extension of the original concept. \end{proof}
{'timestamp': '2019-04-24T02:05:39', 'yymm': '1904', 'arxiv_id': '1904.10122', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.10122'}
arxiv
\section{Introduction} Rapid growth in the air traffic expected for the coming years requires innovative applications and methodologies to guarantee efficiency of the transportation infrastructure and the safety for passengers and crew. In order to monitor and manage the increasingly congested airspace, the Automatic Dependent Surveillance-Broadcast (ADS-B) system is deployed as a key component of the Next Generation Air Transportation System \cite{nextgen}. The airborne ADS-B OUT devices (transmitters) allow aircraft to periodically broadcast their identifications and current positions, determined from global navigation satellite systems, to ground stations or other aircraft over the 1090 MHz band. \shaun{All aircraft will need to be equipped with ADS-B capabilities to be operated in the European and U.S. airspace by 2020, as per the EASA and FAA\footnote{EASA and FAA stand for the European Aviation Safety Agency and the Federal Aviation Administration, respectively.} regulations.} Despite of the advantages of ADS-B, its security vulnerabilities have been widely acknowledged \cite{sampigethaya2011security,mccallie2011security,strohmeier2015security,costin2012ghost,schafer2013experimental}. \shaun{In particular, the source of the problem is the lack of basic security mechanisms,} such as encryption and authentication. As a result, a variety of wireless attacks can be launched against the ADS-B system, such as eavesdropping, jamming, message injection (spoofing), message deletion, and message modification, as summarized in \cite{mccallie2011security}. The above security vulnerabilities of ADS-B are further exacerbated by the prevalence of low-cost Software Defined Radios (SDRs) (e.g., USRP \cite{usrp}). It has been demonstrated in \cite{schafer2013experimental,costin2012ghost} that the above attacks are easy and practically feasible to launch for a moderately sophisticated attacker with a SDR. In this work, we focus on the ADS-B message injection or spoofing attacks \shaun{that target} a ground station. As illustrated in Fig.~\ref{fig:main_figure}, the ADS-B receiver receives broadcast messages \shaun{broadcast by aircraft within signal range} and feeds them to the Air Traffic Control (ATC) system. We classify the ADS-B spoofing attacks into two categories: ground-based and aircraft-based. In the first attack, the ground-based attacker uses a SDR to retransmit previously recorded messages or transmit newly generated and correctly modulated fake messages, which are referred to as the replay attack and the ghost aircraft injection attack, respectively. The main objective is to fake the presence of non-existent (ghost) aircraft and confuse the ATC system. In the second attack, an aircraft-based attacker modifies the \rev{ICAO} address in the ADS-B messages transmitted by the airborne ADS-B transponder, masquerading itself as a known or trusted aircraft to bypass the surveillance. \begin{figure*}[t] \centering \includegraphics[width=0.9\textwidth]{./Figures/main_figure} \caption{Illustration of ADS-B message injection or spoofing attacks that target the ground station. The ground-based attacker uses a SDR device to replay previously recorded ADS-B messages or transmit \rev{newly generated and correctly modulated fake} ADS-B messages, whereas an aircraft-based attacker modifies the ICAO address of transmitted messages and masquerades as a known or trusted aircraft. SODA is deployed between the ADS-B receiver and the ATC system and flags suspicious messages based on the PHY-layer features using DNN. } \label{fig:main_figure} \end{figure*} Use of cryptographic primitives (e.g., Message Authentication Code) is one way to defend against ADS-B spoofing \cite{wesson2014can,finke2013enhancing,viggiano2010secure,schuchman2011automatic,feng2010data}, but it requires protocol modifications or overheads and \rev{shifts} the problems to the design of secure and scalable key management and distribution schemes. Alternative non-cryptographic approaches aim to identify and exploit unique characteristics of ADS-B transponders for fingerprinting. In \cite{strohmeier2015passive}, Strohmeier \textit{et al.} analyzed message transmission patterns (inter-arrival time distribution) and identified distinct \rev{patterns} between commercial ADS-B transponder types and their implementations. Nevertheless, an attacker with a SDR-based spoofer has the full control of inter-transmission times and can mimic the transmission pattern to evade detection. A malicious aircraft can also masquerade as another aircraft equipped with an ADS-B transponder of a similar implementation (e.g., from the same manufacturer) to avoid detection. In \cite{leonardi2017air}, Leonardi {\em et al.} proposed to fingerprint aircraft through phase patterns and applied neural networks for multi-class classification. Due to the limited number of predefined classes for phase patterns (seven in total), there will be a significant number of aircraft in each class (e.g., 100+ aircraft in the class of non-coherent phase patterns), leaving a lot of freedom to the attacker. In this work, we present SODA -- a Deep Neural Network (DNN)-based \underline{s}p\underline{o}ofing \underline{d}etector for \underline{A}DS-B. SODA takes PHY-layer features (e.g., IQ samples and phases) as input and performs two-stage detection to detect malicious messages and identify malicious aircraft. \vspace{0.1cm} \noindent \textbf{Contributions.} Throughout this paper, we make the following contributions: \begin{itemize} \item We introduce SODA, a DNN-based detector that consists of a message classifier and an aircraft classifier to detect the ground-based and aircraft-based spoofing attacks. \item We build a SDR-based spoofer and conduct Over-The-Air (OTA) experiments in an anechoic chamber to emulate realistic ground-based spoofing attacks. Our experimental results show that the message classifier detects malicious messages from a ground-based attacker with a detection probability of $99.34\%$ and a negligible false alarm rate (i.e., $0.43\%$). It outperforms baseline machine learning techniques including XGBoost, Logistic Regression, and Support Vector Machine. \item \shaun{We build an aircraft classifier that performs multi-class classification with each aircraft being its own class. Our experimental results show that a fine-tuned aircraft classifier classifies a total of 238 aircraft with an average F-score of $96.68\%$ and an accuracy of \shaun{$96.66\%$}, with a significant performance improvement over the state-of-the-art detector in \cite{leonardi2017air}.} \end{itemize} \noindent \textbf{Organization.} The remainder of this paper is organized as follows. Section~\ref{sec:related_work} reviews related work and Section~\ref{sec:background} provides relevant background on ADS-B and DNN. In Section~\ref{sec:system_adversary_model}, we describe our system and adversary models. Section~\ref{proposed_scheme} presents the proposed detection system, and Section~\ref{sec:evaluation} presents the experimental evaluation. This study is concluded in Section~\ref{sec:conclusion}. \section{Background}\label{sec:background} In this section, we provide relevant background on the ADS-B protocol (Section~\ref{sec:adsb_background}) and a brief introduction to DNN (Section~\ref{sec:ddn_background}). \subsection{ADS-B Background} \label{sec:adsb_background} Aircraft use the ADS-B technology to periodically transmit their identifications (ICAO addresses) and status data (e.g. position, speed, heading, etc.) to ground stations and nearby aircraft. There are two types of ADS-B devices: 1) ADS-B OUT devices for transmitting broadcasts to ADS-B receivers, and 2) ADS-B IN devices for receiving broadcasts, weather data, and ATC reports. The data link standards for ADS-B are the 987 MHz Universal Access Transceiver (UAT) and the 1090 MHz Extended Squitter (1090ES). The former was created specifically for aviation services such as ADS-B and requires new hardware, whereas the later integrates the ADS-B function to traditional Mode S transponders. In this work, we focus on the commercially used 1090ES data link. Fig.~\ref{fig:ads_b_message_structure} illustrates the ADS-B message structure. Each message contains a 8 $\mu$s preamble for synchronization and a 56-bit (short) or 112-bit (extended) data block. The first 5 bits of the data block contain the downlink format (the message type). The subsequent 3-bit capability field serves as an additional identifier. The 24-bit ICAO address is a unique identifier issued to each aircraft by the ICAO. The 56-bit extended ADS-B data field contains surveillance information such as identification, position, velocity, and emergency codes. The last field is a 24-bit parity check for receivers to validate the correctness of the preceding message. Within the 56-bit data field, the first 5 bits represent the Type Code (TC), indicating the type of information contained in the subsequent bits. While there are a total of 31 TCs, we focus on messages that include airborne position data with barometric altitude (TCs 9-18), and airborne velocities (TC 19). \begin{figure}[t] \centering \includegraphics[trim={0 0cm 0 -.3cm},clip,width=1\columnwidth]{./Figures/ads-b_message_structure} \caption{Illustration of ADS-B message structure. Each message consists of a 8 $\mu$s preamble and a $56~\mu$s or $112~\mu$s data block. } \label{fig:ads_b_message_structure} \end{figure} ADS-B messages are transmitted every $0.5$ s on average using the Pulse Position Modulation (PPM) scheme. Since the data rate is 1 Mbps, the total duration is 120 $\mu$s for an extended ADS-B message (including the preamble). \subsection{Deep Neural Network} \label{sec:ddn_background} DNN is a widely used supervised learning technique, which requires a large amount of labeled training data. It consists of input, hidden, and output layers. Each layer consists of a certain amount of nodes (neurons). The number of input nodes is equal to the number of features of a sample, and the number of output nodes usually correspond to the number of labels or classes. The number of hidden layers and nodes are considered as tuneable hyper-parameters. In a feed-forward DNN with multiple hidden layers, with $j$ hidden nodes, each node maps its input, $x_j$, to the output state $y_j$, through an activation function. In Eq.~(\ref{eq1}), $x_j$ is equal to $b_j$, the bias of node \(j\), plus the sum of \(y_iw_{ij}\), over all \(i\) nodes in the preceding layer, where \(y_i\) is the output state of node \(i\) in the previous layer, and \(w_{ij}\) is the connecting weight from node \(i\) to node \(j\). The sigmoid function is often used in binary classification models, whereas the softmax function is used for multi-class classification problems, and returns the probability of each class, \(p_j\), over \(k\) total classes. \begin{equation} \label{eq1} x_j = b_j + \sum_{i}y_iw_{ij}. \end{equation} A cost function (e.g., cross entropy) is defined to measure the discrepancy between the target outputs and the actual outputs produced for each training sample. The derivatives of the cost function are then back-propagated throughout the network to update the weights, thus training the DNN classifier. In order to increase the efficiency of back-propagation on large training sets, mini-batches, i.e., small random set of training cases, are used in place of the entire training data. The term epoch refers to a single forward and back-propagation of the training data. More details on DNN are available in literature such as \cite{hinton2012deep}. \section{\hl{Discussion (TODO, 0.5 page)}} \label{sec:discussion} \begin{itemize} \item Are features stable over the long term? \item How to perform multi-class classification for 70,000 different aircrafts? \cite{strohmeier2017large} From multi-class classification to binary-classification \item From per-message detection to multi-message detection: if we assume attack messages carry the same ICAO address. Then by combing results of multiple messages, we can further improve the accuracy. Considered as attack if 3 consecutive messages are considered as attack? Decrease both $P_{fa}$ and $P_d$ \item How to deal with confusion? Clustering? \item Features \item scalability \item what causes confusion? \end{itemize} \section{Proposed System -- SODA} \label{proposed_scheme} In this section, we first describe the architecture of SODA (Section~\ref{sec:system_architecture}). We then present the DNN-based message classifier (Section~\ref{sec:message_classification}) and aircraft classifier (Section~\ref{sec:aircraft_classification}). \subsection{System Architecture} \label{sec:system_architecture} Fig.~\ref{fig:system_architecture} illustrates the architecture of SODA, which consists of a message classifier and an aircraft classifier. The message classifier decides whether the message is malicious or not. If a message is considered non-malicious, it means that it is not transmitted by the SDR-based spoofer, but it may come from a malicious aircraft instead of the legitimate transmitter as indicated by the ICAO address in the message. Hence, the aircraft classifier aims to further determine the \shaun{transmitting aircraft} of the message and compare the output ICAO address against the claimed ICAO address to detect the aircraft spoofing attack. Since both message and aircraft classifiers are based on DNN, they need to be trained on a large labeled dataset. At runtime, the SODA takes each incoming ADS-B message (IQ data) as input and decides whether this message is suspicious or not. Since the SODA is a passive detection system that only flags possibly spoofed messages, it is up to the ATC system to take further actions (e.g., drop the flagged messages or display the ghost aircraft on the console). In the rest of this section, we describe the two stages in more detail. \begin{figure}[t] \centering \includegraphics[trim={0 0cm 0 -0.3cm},clip,width=1\columnwidth]{./Figures/system_architecture_draft3} \caption{Illustration of SODA Architecture. The message classifier determines whether the ADS-B message is malicious or not so as to detect ground-based spoofing attacks. A non-malicious message will be further passed into the aircraft classifer. By comparing the output ICAO address with the claimed ICAO address, the detector can detect the aircraft-based spoofing attack. } \label{fig:system_architecture} \end{figure} \subsection{Message Classification} \label{sec:message_classification} Message classification is \rev{considered as} a binary classification problem. In SODA, the raw IQ samples are used as features. Since each message lasts $120~\mu$s, a sampling rate of $R$ MHz will produce $240 R$ interleaving IQ samples. \vspace{0.1cm} \noindent \textbf{Data collection.} To successfully train the message classifier, a large amount of realistic ground-based spoofing attack data is needed. As illustrated in Fig.~\ref{fig:hardware_setup}(a), we constructed an ADS-B receiver (the ground station) that consists of a laptop, a RTL-SDR dongle \cite{rtlsdr}, a 1090 MHz bandpass filter, and an ADS-B antenna to collect real ADS-B messages in an open area. We then built a SDR-based ADS-B spoofer consisting of a USRP B210 \cite{usrp} and a 5-dBi 1090 MHz antenna (Fig.~\ref{fig:hardware_setup}(b)) to emulate ADS-B spoofing attacks. For the message replay attack, \rev{the spoofer transmits correctly modulated ADS-B signals using the message contents decoded from authentic ADS-B messages.} For the IQ data replay attack, the spoofer simply replays the IQ data of the recorded ADS-B messages. This represents the worst-case IQ data replay attack, because the replayed IQ data directly comes from the ground station, while in practice the attacker would record the IQ data using different hardware at a different location. In the ghost aircraft injection attack, a number of aircraft are simulated with random ICAO addresses, velocities, altitudes, and headings. For simplicity, we assume that each aircraft broadcasts an ADS-B message every second. \begin{figure}[t] \centering \includegraphics[trim={0 0cm 0 0},clip,width=1\columnwidth]{./Figures/hardware_setup} \caption{Illustration of data collection using the constructed ADS-B receiver and SDR-based spoofer. (a) The ADS-B receiver collects authentic messages in an open area at the coordinates of $(47.6534, -122.3076)$. (b) The same ADS-B receiver receives malicious messages transmitted by the SDR-based spoofer in an anechoic chamber.} \label{fig:hardware_setup} \end{figure} In order to simulate different received signal strengths of messages from the same aircraft when it is approaching or flying away from the receiver, attack messages are transmitted multiple times with different USRP gains. Since the attacker may be aware of the Doppler effect and the existence of carrier frequency offsets, the calculated or random Doppler shifts and frequency offsets are incorporated into the transmitted attack messages. More details are provided in Section~\ref{sec:evaluation}. \vspace{0.1cm} \noindent \textbf{Message classification example.} Fig.~\ref{fig:example_message_comparison} illustrates authentic and malicious messages under different attacks. \rev{Recall that both message and IQ data replay attacks reuse the original message contents, whereas the ghost aircraft injection attack generates fake message contents. Comparing Fig.~\ref{fig:example_message_comparison}(b) with Fig.~\ref{fig:example_message_comparison}(a), we notice that despite of the same message contents, the message replay attack leads to very different IQ samples. In contrast, the IQ data replay attack (Fig.~\ref{fig:example_message_comparison}(c)) can produce a very similar but shifted phase pattern, as compared to the original message (Fig.~\ref{fig:example_message_comparison}(a)).} \begin{figure}[t] \centering \subfloat[\label{fig:example_authentic}]{ \includegraphics[trim={.4cm .3cm 0.5cm .5cm},clip,width=.48\columnwidth]{./Figures/example_message_iq_authentic}} \hfill \subfloat[\label{fig:example_message_replay}]{ \includegraphics[trim={.4cm .3cm 0.5cm .5cm},clip,width=.48\columnwidth]{./Figures/example_message_iq_message_replay}} \hfill \subfloat[\label{fig:example_iq_replay}]{ \includegraphics[trim={.4cm .3cm 0.5cm .5cm},clip,width=.48\columnwidth]{./Figures/example_message_iq_iq_data_replay}} \hfill \subfloat[\label{fig:example_ghost}]{ \includegraphics[trim={.4cm .3cm 0.5cm .5cm},clip,width=.48\columnwidth]{./Figures/example_message_iq_ghost_aircraft_injection}} \caption{Examples of IQ samples of received ADS-B messages under different \rev{ground-based} ADS-B spoofing attacks. (a) No attack (authentic message). (b) Message replay attack. (c) IQ data replay attack. (d) Ghost aircraft injection attack. } \label{fig:example_message_comparison} \end{figure} \subsection{Aircraft Classification} \label{sec:aircraft_classification} The aircraft classifier predicts the source ICAO address of the received ADS-B message and compares it against the claimed ICAO address. Since there are many aircraft that transmit ADS-B messages, it then becomes a multi-class classification problem. It is worth noting that through aircraft classification, the SODA can not only detect the aircraft spoofing attack, but also identify the masquerading aircraft. \vspace{0.1cm} \noindent \textbf{Features.} Unlike message classification, the aircraft classifier does not use IQ samples or their magnitudes that encode the (possibly spoofed) ICAO address as features in order to avoid being deceived. Instead, it uses the phases that are independent of the claimed ICAO address as features. The phase of the $k$-th pair of IQ samples is computed as $$\phi[k] = \tan^{-1} \left(\frac{x_q[k]}{x_i[k]}\right).$$ From the communication theory \cite{madhow2008fundamentals}, we know that the phases encode the information about the TX and RX carrier frequency offsets and the Doppler shift. To see why, denote the passband ADS-B signal as $$x_p(t)=\text{Re} \left\{ \sqrt{2}x(t)e^{j 2\pi f_c t} \right\},$$ where $x(t)=x_i(t) + jx_q (t)$ is the complex baseband signal and $f_c$ is the carrier frequency ($1090$ MHz for ADS-B signals). With a carrier frequency offset of $\Delta f$ and a phase offset $\Delta \phi$, the resulting signal becomes \begin{align*} \tilde{x}_p(t) &= \text{Re} \left\{ \sqrt{2}x(t)e^{j 2\pi (f_c+\Delta f) t + \Delta \phi} \right\}\\ &= \text{Re} \left\{ \sqrt{2} \left(x(t) e^{j \phi(t)} \right) e^{j 2\pi f_c t} \right\}, \end{align*} where $\phi(t) = 2\pi \Delta f t + \Delta \phi$. Hence, the rate of the change in the phase indicates the carrier frequency offset, which is a sum of TX/RX frequency offsets and the Doppler shift\footnote{Since the ADS-B signal is a narrowband signal, the impact of the Doppler effect is equivalent to shifting the carrier frequency by a certain amount.} and also affected by the propagation channel. \rev{As a result, the phases encode rich information and thus can be used as features for classification.} \vspace{0.1cm} \noindent \textbf{Aircraft classification example.} A comparison of phase patterns of received messages from different aircraft is provided in Fig.~\ref{fig:example_aircraft_comparison_phase_over_time}. On one hand, we observe that aircraft \rev{could} have distinguishable phase patterns from \rev{each other}, which could be learned by the DNN-based aircraft classifier. On the other hand, it is \rev{possible} for two aircraft to have a similar phase pattern, such as Aircraft 7 and 8, which \rev{might} cause potential misclassifications. \begin{figure}[t] \centering \includegraphics[width=1\columnwidth]{./Figures/example_aircraft_comparison_phase} \caption{Comparison of message phase patterns of different aircraft. } \label{fig:example_aircraft_comparison_phase_over_time} \end{figure} \section{Experimental Evaluation} \label{sec:evaluation} In this section, we describe the procedure for data collection and then evaluate the performance of both message and aircraft classifiers of SODA \rev{implemented using} Keras \cite{chollet2015keras} using real-world datasets. \subsection{Datasets} The ADS-B receiver and SDR-based spoofer in Fig.~\ref{fig:hardware_setup} were used for data collection. The ADS-B antenna was mounted on a tripod and the overall height is about 1.5 meters. A modified version of dump1090 \cite{dump1090} was used to collect IQ samples with a gain of 49.6 and a sampling rate of 2 MHz. Both wired and OTA experiments were performed to collect realistic spoofing attack data. The former were conducted by directly wiring the transmitter and receiver. The latter were performed in an anechoic chamber located in the basement level of a building to avoid possible signal emission. \vspace{0.1cm} \noindent \textbf{Datasets for message classification.} Table~\ref{table:datasets} summarizes the collected datasets. A total of 18675 authentic ADS-B messages (extended, downlink format of 17) were collected in an open area within half an hour. The first 10000 messages were used for message and IQ data replay attacks. A total of $20$ ghost aircraft were simulated with a velocity randomly drawn from a normal distribution $N(230 \text{ m/s}, 10 \text{ m/s})$. The altitude follows $N(9000 \text{ m}, 500 \text{ m})$. The headings (in degree) are drawn from a uniform distribution $U[0, 360)$. The Doppler shift $\Delta f_d$ and the carrier frequency offset $\Delta f_c$ are simulated in four different cases: i) $\Delta f_d = \Delta f_c = 0 $, ii) calculated $\Delta f_d$ and $\Delta f_c=0$, iii) calculated $\Delta f_d$ and random $\Delta f_c$, iv) random $\Delta f_d$ and $\Delta f_c=0$, and v) random $\Delta f_d$ and random $\Delta f_c$. The distributions of random $\Delta f_d$ and $\Delta f_d$ are $U[-1\text{ kHz}, + 1 \text{ kHz}]$ and $U[-10\text{ kHz}, + 10 \text{ kHz}]$, respectively. \begin{table}[t] \caption{Collected datasets for message classification.}\label{table:datasets} \centering \begin{tabular}{|c|c|c|c|c|} \hline Dataset & Label & Wired & OTA & Total \\ \hline Authentic messages & A0 & N/A & 18675 & 18675 \\ \hline Message replay attack & A1 & 8101 & 8318 & 16419 \\ \hline IQ data replay attack & A2 & 5961 & 5806 & 11767 \\ \hline Ghost aircraft injection attack & A3 & 8770 & 8832 & 17602 \\ \hline \end{tabular} \normalsize \end{table} \vspace{0.1cm} \noindent \textbf{Datasets for aircraft classification.} In order to provide sufficient amount of data for aircraft classification, we collected additional data using the constructed ADS-B receiver on the rooftop of a building for two consecutive days. There are a total of 300,152 and 326,122 extended ADS-B messages from 157 and 210 aircraft in two days, respectively. \begin{table}[t!] \centering \caption{Basic DNN setup for SODA} \label{table:DNN_parameters} \begin{tabular}{|c|c|} \hline Description & Value \\ \hline Input Layer & Number of features \\ \hline Output Layer & Number of classes \\ \hline Weight Initialization & Xavier normal \\ \hline Weight Regularizer & L2 \\ \hline Activation Function & ReLU \\ \hline Output Activation Function & Softmax \\ \hline Cost Function & Cross entropy \\ \hline Optimizer & Adam \\ \hline Epochs, Batch Size & 50, 32 \\ \hline \end{tabular} \end{table} \subsection{Performance of Message Classification} \label{sec:message_classification_performance} In this experiment, we evaluate the performance of the DNN-based message classifier and compare it against three baseline classifiers: XGBoost \cite{chen2016xgboost}, Logistic Regression (LR) \cite{hosmer2013applied}, and Support Vector Machine (SVM) \cite{suykens1999least}. \vspace{0.1cm} \noindent \textbf{Setup.} We first consider all attacks and split the dataset into 60\%, 20\%, and 20\% for training, validation, and testing, respectively. The DNN parameters are summarized in Table~\ref{table:DNN_parameters}. We consider the following three DNN models: \begin{enumerate} \item D1: one hidden layer with 128 nodes, \item D2: one hidden layer with 256 nodes, and \item D3: two hidden layers with 128 nodes per layer. \end{enumerate} When training XGBoost/LR/SVM, the attack dataset is subsampled so that the attack and authentic datasets have the same number of messages, avoiding data imbalance. \vspace{0.1cm} \noindent \textbf{Metrics.} Since each classifier acts as a detector, we adopt the following two metrics: \begin{enumerate} \item \textit{Detection probability} (denoted as $P_d$): the percentage of malicious messages classified as malicious, and \item \textit{False alarm probability} (denoted as $P_{fa}$): the percentage of authentic messages classified as malicious. \end{enumerate} In practice, a classifier that achieves a higher $P_d$ and a lower $P_{fa}$ (that is within a given limit) is preferred. \vspace{0.1cm} \noindent \textbf{Results.} The results are provided in Table~\ref{table:model_comparison}. We first observe that a simple DNN model such as D1 can already achieve very good performance with $P_d = 99.39\%$ and $P_{fa}=2.60\%$, as compared to other machine learning techniques. In particular, LR and SVM do not perform well in this task, and XGBoost only achieves $P_d$ of $78.37\%$ with $P_{fa}=5.17\%$. If we increase the complexity of the DNN model by doubling the number of nodes, the message classifier (D2) achieves $P_d = 99.50\%$ and $P_{fa}=2.09\%$. Interestingly, if the hidden nodes of D2 are split equally into two hidden layers, the resulting classifier (D3) can further reduce $P_{fa}$ to $0.43\%$, while keeping $P_d=99.34\%$. \begin{table}[t] \centering \caption{Comparison of different models for message classification} \label{table:model_comparison} \begin{tabular}{|c|c|c|} \hline Model & $P_d$ & $P_{fa}$ \\ \hline D1 & 99.39\% & 2.60\% \\ \hline D2 & 99.50\% & 2.09\% \\ \hline D3 & 99.34\% & 0.43\% \\ \hline XGBoost & 78.37\% & 5.17\% \\ \hline LR & 54.83\% & 46.93\% \\ \hline SVM & 51.52\% & 43.64\% \\ \hline \end{tabular} \end{table} \vspace{0.1cm} \noindent \textbf{Impact of attack dataset diversity.} As shown in the previous experiment, the DNN model performs well when trained with all attack datasets. Then a natural question is that if the DNN model is trained on a subset of attack datasets, will it achieve good performance when tested with unknown attacks? In this experiment, we study the impact of attack dataset diversity on D3, and the results are provided in Table~\ref{table:attack_dataset_diversity}. As we can see, the performance of DNN depends on the attack datasets used for training. An interesting observation that when trained with A1, the classifier detects A3 with $P_d = 96.31\%$. In contrast, when trained with A3, the classifier only detects A1 with $P_d = 21.80\%$. In general, the model does not generalize to unknown attacks, suggesting the necessity of creating a diverse attack dataset for message classification. \begin{table}[t] \centering \caption{Detection performance of D3 \rev{message classifier} when trained with different combinations of attack datasets}\label{table:attack_dataset_diversity} \begin{tabular}{|c|c|c|c|c|} \hline \begin{tabular}[c]{@{}c@{}}Attack datasets\\ used for training\end{tabular} & $P_d$ of A1 & $P_d$ of A2 & $P_d$ of A3 & $P_{fa}$ \\ \hline \{A1\} & \textbf{99.67}\% & 11.68\% & 96.31\% & 0.35\% \\ \hline \{A2\} & 38.57\% & \textbf{99.07}\% &55.21\% & 0.40\% \\ \hline \{A3\} & 21.80\% & 0.30\% & \textbf{100.00}\% & 0.03\% \\ \hline \{A1, A2\} & \textbf{99.03}\% & \textbf{98.85}\% & 96.28\% & 0.59\% \\ \hline \{A1, A3\} & \textbf{99.88}\% & 13.59\% & \textbf{100.0}\% & 0.70\% \\ \hline \{A2, A3\} & 72.91\% & \textbf{98.94}\% & \textbf{99.97}\% & 0.27\% \\ \hline \{A1, A2, A3\} & \textbf{99.36}\% & \textbf{98.34}\% & \textbf{100.00}\% & 0.43\% \\ \hline \end{tabular} \end{table} \subsection{Performance of Aircraft Classification} In this section, we evaluate the DNN-based aircraft classifier. We then study the impact of the size of the training set and the number of aircraft on the classification performance. \vspace{0.1cm} \noindent \textbf{Setup.} We split the data into three portions: 60\% for training, 20\% for validation, and 20\% for testing. We post-processed the collected data and obtained a dataset that consists of 238 aircraft with 1000 messages for each aircraft, totalling 238,000 messages. Each message has a total of 240 phase values (features) computed from the IQ samples. Since DNN dominates other machine learning techniques (Section~\ref{sec:message_classification_performance}), we focus on DNN in this experiment. Specifically, we consider five DNN models with various complexity: \begin{enumerate} \item M1: one hidden layer with 512 nodes, \item M2: one advanced hidden layer with 1024 nodes, \item M3: two hidden layers with 512 nodes per layer, and \item M4: three hidden layers with 512 nodes per layer. \item \shaun{M5: a fine-tuned model with two hidden layers (512 and 256 nodes), batch normalization \cite{ioffe2015batch} and 200 epochs.} \end{enumerate} The parameters in Table~\ref{table:DNN_parameters} are used for constructing DNNs. \vspace{0.1cm} \noindent \textbf{Metrics.} We adopt the following standard metrics for multi-class classification: \textit{precision}, \textit{recall}, and \textit{F-score} \cite{sokolova2009systematic}. Let $\text{TP}_i$ be the \textit{true positive rate} at which Aircraft $i$'s messages are correctly identified from Aircraft $i$. Similarly, the \textit{false positive rate} $\text{FPR}_i$ and the \textit{false negative rate} $\text{FNR}_i$ are the rates of incorrectly accepted and incorrectly rejected identifications for Aircraft $i$, respectively. Hence, we have \begin{align*} \text{Precision: } \text{Pr}_i &= \frac{\text{TPR}_i}{\text{TPR}_i + \text{FPR}_i},\\ \text{Recall: } \text{Re}_i &= \frac{\text{TPR}_i}{\text{TPR}_i + \text{FNR}_i},\\ \text{F-Score: } \text{F-Score}_i &= \frac{2 \times \text{Pr}_i \times \text{Re}_i}{\text{Pr}_i + \text{Re}_i}. \end{align*} Note that high precision and high recall imply low FPR and low FNR, respectively. To further quantify the overall performance of the classifier, we compute the macro-averaging precision (AvgPr) and recall (AvgRe) by averaging the $\text{Pr}_i$'s and $\text{Re}_i$'s over all aircraft, and the average F-score as \begin{equation*} \text{AvgF-Score} = \frac{2 \times \text{AvgPr} \times \text{AvgRe}}{\text{AvgPr} + \text{AvgRe}}. \end{equation*} In addition, the accuracy metric is often used to measure the overall effectiveness of a classifier, defined as the percentage of messages that are correctly classified. \vspace{0.1cm} \noindent \textbf{Results.} The results are provided in Table~\ref{table:DNN_performance}. Compared to M1 that achieves an average F-score of $93.64\%$ and an accuracy of $93.60\%$, increasing the model complexity by adding more nodes or one more layer (e.g., M2 and M3) improves the overall performance. \shaun{Keeping adding more layers (e.g., M4) does not necessarily result in performance gain. But with careful tuning of hyper-parameters and longer training time, a fine-tuned model like M5 can achieve an average F-score of $96.68\%$ and an accuracy of $96.66\%$.} \begin{table}[t!] \centering \caption{Performance of DNN-based aircraft classifiers} \label{table:DNN_performance} \begin{tabular}{|c|c|c|c|c|} \hline Model & AvgPr & AvgRe & AvgF-Score & Accuracy \\ \hline M1 & 93.69\% & 93.60\% & 93.64\% & 93.60\% \\ \hline M2 & 94.62\% & 94.51\% & 94.57\% & 94.51\% \\ \hline M3 & 94.88\% & 94.68\% & 94.78\% & 94.68\% \\ \hline M4 & 94.52\% & 94.28\% & 94.40\% & 94.28\% \\ \hline M5 & \textbf{96.69}\% & \textbf{96.66}\% & \textbf{96.68}\% & \textbf{96.66}\% \\ \hline \end{tabular} \end{table} Fig.~\ref{fig:F_score_CDF} plots the empirical cumulative distribution function (CDF) of the F-scores. We can see that over $50\%$ of aircraft have a F-score of $95\%+$ for all models. In addition, increasing model complexity tends to improve the F-score of individual aircraft. For example, there are $23.53\%$ of aircraft with a F-score lower than $90\%$ with M1, and this ratio drops to $15.97\%$ and $13.87\%$ with M3 and M4, respectively. \shaun{For the fine-tuned model, this ratio is as low as $2.5\%$.} \begin{figure}[t!] \centering \includegraphics[width=1.0\columnwidth]{./Figures/F_score_CDF_v2} \caption{Empirical CDF of F-scores of DNN-based \rev{aircraft} classifiers. } \label{fig:F_score_CDF} \end{figure} Fig.~\ref{fig:confusion_matrix} plots the confusion matrix of M5, in which the $(i,j)$-th entry represents the probability of Aircraft $i$'s messages incorrectly classified as Aircraft $j$'s. With \shaun{$96.66\%$} messages correctly identified, there exist only \shaun{$33$} non-diagonal entries (out of $56644$) with a rate larger than or equal to $2\%$ ($4$ misclassified messages). The largest misclassification rate is \shaun{$8.0\%$} between Aircraft 91 and 92, suggesting similarity in their phase patterns. \begin{figure}[t] \centering \includegraphics[trim={.5cm 0cm 4cm 2.5cm},clip,width=1\columnwidth]{./Figures/confusion_matrix_fine-tuned_DNN_v2} \caption{Normalized confusion matrix of \shaun{the fine-tuned \rev{aircraft classifier} (M5)}. There are $33$ non-diagonal entries larger than or equal to $0.02$ (blue squares).} \label{fig:confusion_matrix} \end{figure} \vspace{0.1cm} \noindent \textbf{Impact of the size of the training set.} In order to understand how the size of the training set affects the DNN performance, we vary the training ratio from $0.2$ to $1.0$ with a step of $0.1$ and plot the average F-score and accuracy of M3. As shown in Fig.~\ref{fig:impact_of_training_size}, with only $20\%$ of the original training set (i.e., $120$ messages per aircraft), the classifier achieves an accuracy of over $80\%$. While the overall performance increases as the training ratio increases, the performance gain of more training samples tends to gradually decrease. \shaun{Similar trends are observed with other models and thus not reported due to the space limit.} \begin{figure}[t!] \centering \includegraphics[width=1.0\columnwidth]{./Figures/impact_of_training_size_v2} \caption{Performance \rev{of the aircraft classifier (M3)} in terms of average F-score and accuracy as a function of the training ratio. The performance improves with more training samples and tends to saturate after a certain point.} \label{fig:impact_of_training_size} \end{figure} \vspace{0.1cm} \noindent \textbf{Impact of the number of aircraft.} In this experiment, we vary the number of aircraft from $25$ to $238$ with a step of $25$ and plot the performance of M3, as shown in Fig.~\ref{fig:impact_of_num_of_aircraft}. With only $25$ aircraft, the classification accuracy is as high as $98.06\%$. With more aircraft, the performance drops and comes to a level of around $95\%$. \begin{figure}[t!] \centering \includegraphics[width=1.0\columnwidth]{./Figures/impact_of_num_of_aircraft_v2} \caption{Performance \rev{of the aircraft classifier (M3)} in terms of average F-score and accuracy as a function of the number of aircraft (classes). When the number of aircraft increases, the performance slightly drops to around $95\%$. } \label{fig:impact_of_num_of_aircraft} \end{figure} \section{Conclusion and Future Work} \label{sec:conclusion} In this paper, we proposed SODA to detect ADS-B spoofing attacks using DNN, which consists of a message classifier and an aircraft classifier. The message classifier takes IQ samples as input and detects malicious messages from the SDR-based ground attacker, including the message/IQ data replay attack and the ghost aircraft injection attack. The aircraft classifier takes the phases of received messages as input and detects spoofed messages by comparing the claimed ICAO address against the predicted ICAO address. We collected real-world ADS-B messages and generated realistic attack data using our ADS-B testbed through OTA experiments in an anechoic chamber. Our experimental results show that the SODA detects ground-based spoofing attacks with a detection probability of $99.34\%$ and a false alarm probability of $0.43\%$. It detects aircraft spoofing attacks with an average F-score of $96.68\%$ and an accuracy of $96.66\%$. \rev{As future work, we will study the scalability of SODA and explore the use of clustering to identify aircraft with similar features and detect ADS-B spoofing attacks launched by aircraft in different clusters. We will also perform post-processing of the IQ samples to extract more stable features (e.g., frequency offsets) to improve the robustness of SODA against various factors, including radio propagation, receiver characteristics, and measurement noise.} \section*{Acknowledgments} This work was supported in part by NSF grant CNS-1446866, ONR grants N00014-16-1-2710 and N00014-17-1-2946, and ARO grant W911NF-16-1-0485. Views and conclusions expressed are that of the authors and not be interpreted as that of the NSF, ONR or ARO. \rev{This work was also supported by a grant of the Italian Presidency of the Council of Ministers.} \section{Related Work}\label{sec:related_work} The security vulnerabilities of ADS-B have been analyzed in many studies \cite{sampigethaya2011security,mccallie2011security,strohmeier2015security,costin2012ghost,schafer2013experimental}. One way to secure wireless ADS-B communication is through cryptographic measures \cite{wesson2014can,finke2013enhancing,viggiano2010secure,schuchman2011automatic,feng2010data}. Finke \textit{et al.} compared various encryption schemes and supported a symmetric cipher using the FFX algorithm \cite{finke2013enhancing}. Nevertheless, it is acknowledged as a challenging task to perform secure key management and distribution. More recently, Wesson \textit{et al.} proposed the use Public Key Infrastructure (PKI) and ECDSA (Elliptic Curve Digital Signature Algorithm) signatures as the cryptographic solution. In \cite{feng2010data}, Feng \textit{et al.} presented a PKI solution for ADS-B message authentication based on Elliptic Curve Cipher and X.509 certificates. But the proposed scheme would require additional messages to carry the signature and timestamps, which is hardly scalable in practice, and efficient certification distribution remains an open question. Alternative non-cryptographic approaches can be deployed to mitigate the attacks on the ADS-B system. In \cite{leonardi2017ads}, the authors evaluated ADS-B jamming attacks and proposed a solution based on PHY-layer signal separation. In \cite{schafer2015secure}, Sch{\"a}fer \textit{et al.} proposed secure track verification based on timing. In \cite{ghose2015verifying}, Ghose and Lazos exploited the Doppler spread phenomenon to estimate actual velocities and crossed them with the claimed velocities. In \cite{schafer2016secure}, Sch{\"a}fer \textit{et al.} exploited the Doppler shift measurements from multiple ground stations (verifiers) to verify the motion of the aircraft (prover). \shaun{While it was implicitly assumed that an attacker could modify the transmission frequency to mimic the Doppler shift and deceive a single ground station, we show that it could be a challenging task for the attacker, if the detector leverages the PHY-layer features for detection as SODA does.} In \cite{kim2017ads}, the authors proposed an enhanced ADS-B protocol called ADS-BT, which embeds transmit timestamps in the ADS-B messages, but such approach would require protocol modifications. In the more recent study in \cite{leonardi2017air}, the authors identified 7 classes of phase patterns and exploited them for aircraft classification. They applied a neural network (one hidden layer with $10$ nodes) and reported an accuracy of $91.4\%$ for the 7-class classification task. While the results are promising, the effectiveness of the proposed detector is limited by the number of classes. In other words, more aircraft in one class imply the greater freedom for an attacker to launch the aircraft spoofing attack. In the ideal case, there should be only a single aircraft in each class. Moreover, a \shaun{ground-based} attacker in possession of a SDR-based spoofer can also mimic the phase pattern to evade the detection. In this work, we develop SODA -- a DNN-based two-stage spoofing detector. In the first stage, the message classifier examines each incoming message and labels it as malicious or non-malicious. For those that are considered non-malicious in the first stage, they are further processed by the aircraft classifier, which predicts the ICAO address based on the PHY-layer features and compares the prediction against the claimed address to detect aircraft spoofing attacks. \shaun{Our experimental results demonstrate the effectiveness of the proposed SODA with a detection probability of $99.34\%$ in the first stage and an accuracy of $96.66\%$ for a total of 238 aircraft (with each aircraft being its own class) in the second stage. } \subsection{Simulate Transmit Frequency Offset in IQ Samples} Each ADS-B message consists of $8\mu$s preamble and $112 \mu$s data block (112 bits in total). There are a total of $m=120$ pulses with different time positions to encode the information to be transmitted (i.e., Manchester coding). Hence, the transmitted passband signal $s_p(t)$ can be represented as follows \cite{leonardi2017air, madhow2008fundamentals}: \begin{equation} s_p(t) = Re[\sqrt{2} s(t) e^{j 2 \pi f_c t}] \end{equation} where \begin{equation} s(t) = \left[ \sum_{m=1}^{120} rect\left( \frac{t-2mT+c_mT + T/2}{T} \right) \right], \end{equation} is the baseband signal with a phase of zero. In general, we have $s(t)=s_c(t) + j s_s(t)$ and $s_p(t) = e(t) \cos (2\pi f_c t + \theta(t))$, where $e(t)=|s(t)|=\sqrt{s_c^2(t) + s_s^2(t)}$ is the envelope and $\theta(t)=\tan^{-1} \frac{s_c(t)}{s_s(t)}$ is the phase. In order to generate IQ samples that can be transmitted by the USRP, we first sample $s(t)$ with a sampling rate of $1/T_s$ where $T_s=T/2 =0.2\mu$s and obtain $s[k]=s(kT_s)$. Hence, each ADS-B message is represented by $\{s[k]\}$ with a total of $240$ samples. After that, we generate one I sample and one Q sample for each $s[k]$. IQ samples are then stored in the binary format as interleaving unsigned bytes. In the presence of a transmit frequency offset $\Delta f$, the transmitted signal with the embedded Doppler shift becomes \begin{align} s_p(t) &= Re[\sqrt{2} s(t) e^{j 2 \pi (f_c + \Delta f) t}] \\ &= Re[(\sqrt{2}s(t) e^{j 2 \pi \Delta f t}) e^{j 2 \pi f_c t}]. \end{align} Hence, in order to simulate the transmit freqeuency offset, we can introduce a phase change in the transmitted signal by multiplying each complex sample by $e^{j 2 \pi \Delta f t}$, where $t=kT_s$. \subsection{Simulate Doppler Shift} Let the baseband signal be $s(t)$ and its passband signal at a center frequency of $f_c$ be $s_p(t)=Re[\sqrt{2}s(t)e^{j2\pi f_c t}]$. Let their Fourier transform be $S(f)$ and $S_p(f)$, respectively. The relationship between $S(f)$ and $S_p(f)$ is \begin{equation} S(f) = \sqrt{2} S_p^+ (f+f_c), \end{equation} where $S_p^+(f)$ is the segment of $S_p(f)$ occupying positive frequencies. Due to the Doppler shift, the observed frequency $f_o$ is \begin{equation} f_o = \left(\frac{c+v_o}{c-v_s} \right) f = (1 + \alpha) f, \end{equation} where $\alpha = \frac{c+v_o}{c-v_s} - 1$. As a result, the observed passband signal becomes \begin{equation} S_p'(f) = S_p \left(\frac{1}{1+\alpha} f \right). \end{equation} Hence, we have \begin{align} s'_p(t) &= (1+\alpha) s_p((1+\alpha) t) \\ &=(1+\alpha) Re[\sqrt{2} s((1+\alpha)t) e^{j 2\pi f_c (1+\alpha) t}]. \end{align} For example, if $s_p(t) = \cos(2\pi f_c t)$ and $f_d=(1+\alpha) f_c$, then we have $s_p'(t) = \cos(2\pi f_d t) = s_p((1+\alpha) t)$. Note that since the bandwidth of ADS-B signal is about 50 kHz, it can be considered as a narrowband signal, as compared to the center frequency of 1090 MHz. As a result, the Doppler effect essentially results in a frequency shift \cite{matz2011fundamentals}. \section{System and Adversary Model}\label{sec:system_adversary_model} In this section, we present our system model (Section~\ref{sec:system_model}) and our adversary model (Section~\ref{sec:adversary_model}) for ADS-B spoofing attacks against a ground station. \subsection{System Model} \label{sec:system_model} We consider a ground station equipped with an ADS-B receiver that has access to the raw IQ data. We assume that the ground station has sufficient resources (e.g., processing power or storage) for various machine learning tasks. We also assume that the ground station has a database of previously received authentic ADS-B messages (including both message contents and IQ data) for each aircraft, which can be used to train a supervised learning-based detector. In practice, such a database may be created by a ground station equipped with secondary surveillance systems (e.g., the radar surveillance system) such that the authenticity of each message can be cross-validated. This database can be later shared among other ground stations. Attack messages can be collected by emulating the spoofing attacks using various SDR-based spoofers. While a database created by a single ground station tends to be regional and does not cover all aircraft, multiple ground stations can collaborate and build a nation-wide dataset offline. \subsection{Adversary Model} \label{sec:adversary_model} As illustrated in Fig.~\ref{fig:main_figure}, we consider two types of attackers: 1) a \shaun{ground-based} attacker that uses a low-cost SDR-based spoofer, and 2) an \shaun{aircraft-based} attacker that uses its ADS-B transponder with modified ICAO address. \shaun{While it is possible for an onboard attacker to transmit spoofed messages with the SDR-based spoofer from the aircraft, the signal may not reach the ground station due to the low transmit power of SDRs. For example, the output power of USRP B210/B200 is +20 dBm (100 mW) max \cite{usrp}, whereas airborne ADS-B transponders are required to have a minimum transmission power of 75 W for smaller aircraft and 125 W or 200 W for larger aircraft \cite{rtca-260b}. Spoofing attacks launched by an on-board attacker against the aircraft is beyond the scope of this paper.} We assume that attackers have full knowledge of the ADS-B protocol and the location of the targeted ground station. Since SDR devices are highly flexible and configurable through software, the attacker will \rev{have control over} signal characteristics (e.g., power level, phase, transmitting frequency). In particular, we assume that the attacker is aware of the Doppler effect \rev{(caused by aircraft movements)} and mimic the Doppler shift by shifting the transmitting frequency of the generated signal (or equivalently, by modifying the phases of the transmitted IQ samples). In contrast, commercial ADS-B OUT devices have custom circuits and do not provide the flexibility for users to access its physical layer or modify the signal characteristics. Depending on the way the spoofed messages are generated, we further divide the ADS-B spoofing attacks into three types: 1) message or IQ data replay attack, 2) ghost aircraft injection attack, and 3) aircraft spoofing attack. The first two attacks can only be launched by a ground-based attacker, while the last one is launched by an aircraft-based attacker. Here we consider the replay attack as a special case of the spoofing attack, in which the attacker transmits previously recorded messages pretending to be the legitimate aircraft, without bothering to manipulate the message contents. We now describe each attack in detail. \vspace{0.1cm} \noindent \textbf{Message or IQ data replay attack.} In this attack, the ground-based attacker records the messages contents or the IQ data of the received authentic ADS-B messages using the SDR device, and then transmits the same messages at a later time without changing the message contents. Compared to the message replay attack, the IQ data replay attack is much stealthier, as the recorded IQ data incorporates a lot of information about the Doppler effect, the transmitter characteristics (e.g., carrier frequency offset), and the channel characteristics (e.g., multi-path and fading effects), which is difficult to mimic otherwise. \vspace{0.1cm} \noindent \textbf{Ghost aircraft injection attack.} Unlike the replay attacks, the ground-based attacker transmits fake ADS-B messages with arbitrary contents of its choice using the SDR device. In particular, the attacker can simulate the trajectories of non-existent aircraft and generate corresponding ADS-B messages with carefully chosen Doppler shifts, causing ghost aircrafts to appear on the console of the ground station. \vspace{0.1cm} \noindent \textbf{Aircraft spoofing attack.} In this attack, an aircraft-based attacker (malicious aircraft) attempts to masquerade as a known or trusted aircraft by spoofing the ICAO address and hide its true identity. Since the aircraft is physically present, the masquerading attack will not be detected even if the secondary radar surveillance system is deployed. \section{Localization} Multilateration is not possible. RSSI-based distancing can be very unreliable: \begin{itemize} \item Exact transmit power is unknown (at least 21 dBW, not more than 27 dBW). \item Transmit/receive antenna gain is unknown \item Accuracy of radio propagation model \item RSSI range can be up to 30 dB \cite{schafer2014bringing} \end{itemize}
{'timestamp': '2019-04-23T02:28:50', 'yymm': '1904', 'arxiv_id': '1904.09969', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.09969'}
arxiv
\section{Introduction}\label{sec:intro} Privacy-sensitive learning is important in many applications: examples include human health research, business informatics, and location-based services among others. Releasing any function of private data, even summary statistics and other aggregates, can reveal information about the underlying training data. Differential privacy (DP)~\cite{dwork2006} is a cryptographically motivated and mathematically rigorous framework for measuring the risk associated with performing computations on private data. More specifically, it measures the privacy risk in terms of the probability of identifying the presence of individual data points in a dataset from the results of computations performed on that data. As such, it has emerged as a de-facto standard for privacy-preserving technologies in research and practice~\cite{rappor,appleDP,UScensus}. Differential privacy is also useful when the private data is distributed over different locations (sites). For example, a consortium for medical research on a particular disease may consist of several healthcare centers/research labs, each with their own dataset of human subjects~\cite{enigma,coinstac}. Data holders may be reluctant or unable to directly share ``raw'' data to an aggregator due to ethical (privacy) and technical (bandwidth) reasons. From a statistical standpoint, the number of samples held locally is usually not large enough for meaningful feature learning. Consider training a deep neural network to detect Alzheimer's disease based on neuroimaging data from several studies~\cite{coinstac}: training locally at one site is infeasible as the number of subjects in each study is small. Decentralized algorithms can allow data owners to maintain local control of the data while passing messages to assist in a joint computation across many datasets. If these computations are differentially private, they can measure and control privacy risks. Differentially private algorithms introduce noise to guarantee privacy: conventional distributed DP algorithms often have poor utility due to excess noise compared to centralized analyses. In this paper we propose a Correlation Assisted Private Estimation ($\mathsf{CAPE}$) framework, which is a novel \emph{distributed and privacy-preserving} protocol that provides utility close to centralized case. We achieve this by inducing (anti) correlated noise in the differentially private messages. The $\mathsf{CAPE}$ protocol can be applied to computing loss functions that are separable across sites. This class includes optimization algorithms, such as empirical risk minimization (ERM) problems, common in machine learning (ML) applications. \noindent\textbf{Related Works.} There is a vast literature~\cite{boyd2011, molzahn2017, uribe2017, nedic2009, athans1986, huang2015, han2017, nozari2016, zhu2018} on solving optimization problems in distributed settings, both with and without privacy concerns. In the machine learning context, the most relevant ones to our current work are those using ERM and stochastic gradient descent (SGD)~\cite{Kamalika09, anand2011, anandSGD, abadi2016, Lipton14, DPonline18, bassily2014, Katrina17, Wang17}. Additionally, several works studied distributed differentially private learning for locally trained classifiers~\cite{Pathak10,Agarwal12,BassilyKobbi17}. One of the most common approaches for ensuring differential privacy in optimization problems is to employ randomized gradient computations~\cite{anandSGD, bassily2014}. Another common approach is to employ the output perturbation~\cite{anand2011}, which adds noise to the output of the optimization problem according to the sensitivity of the optimization variable. Note that, both of these approaches involve computing the sensitivity (of the gradient or the output variable) and then adding noise scaled to the sensitivity~\cite{dwork2006}. The problem with output perturbation is that the relation between the data and the parameter set is often hard to characterize. This is due to the complex nature of the optimization and as a result, the sensitivity is very difficult to compute. However, differentially-private gradient descent methods can circumvent this by bounding the gradients at the expense of slowing down the convergence process. Finally, one can employ the objective perturbation~\cite{anand2011, nozari2016}, where we need to perturb the objective function and find the minimizer of the perturbed objective function. However, the objective function has to satisfy some strict conditions, which are not met in many practical optimization problems~\cite{zhang2012}. In addition to optimization problems, Smith~\cite{smith2011} proposed a general approach for computing summary statistics using the \emph{sample-and-aggregate} framework and both the Laplace and Exponential mechanisms~\cite{mcsherry2007}. Jing~\cite{jing2011} proposed a unique approach that uses perturbed histograms for releasing a class of $M$-estimators in a non-interactive way. Differentially private algorithms provide different guarantees than Secure Multi-party Computation (SMC) based methods (see ~\cite{SlawomirMPC17, ShoukryPappas16, Eigner14, Kairouz2015smc, Suresh16, Bonawitz16} for thorough comparisons between SMC and differential privacy based methods). Gade and Vaidya~\cite{GadeSMC16} applied a combination of SMC and DP for distributed optimization in which each site adds and subtracts arbitrary functions to confuse the adversary. Bonawitz et al.~\cite{Bonawitz17} proposed a communication-efficient method for \emph{federated learning} over a large number of mobile devices. The most recent work in this line is that of Heikkil\"{a} et al.~\cite{Mikko17}, who also studied the relationship of additive noise and sample size in a distributed setting. In their model, $S$ data holders communicate their data to $M$ computation nodes to compute a function. Our work is inspired by the seminal work of Dwork et al.~\cite{Ourdata06} that proposed distributed noise generation for preserving privacy. We employ a similar principle as Anandan and Clifton~\cite{Clifton15} to \emph{reduce} the noise added for differential privacy. Our application to distributed DP function computation in this paper builds on the \emph{functional mechanism}~\cite{zhang2012}, which uses functional approximation~\cite{rudin1976} and the Laplace mechanism~\cite{dwork2006} to create DP approximations for any continuous and differentiable function. Zhang et al.'s approach~\cite{zhang2012} does not scale well to decentralized problems. We provide a better analysis of the sensitivity of their approximation and adapt the approach to the decentralized setting. \begin{figure}[t] \centering \includegraphics[width=0.8\columnwidth]{images/network_structure_new.pdf}\\ \vspace{-0.0in} \caption{The structure of the network: (a) conventional, (b) $\mathsf{CAPE}$} \label{fig:network_structure} \end{figure} \noindent\textbf{Our Contribution.} The goal of our work is to reduce the amount of noise in conventional distributed differentially private schemes for applications of machine learning to settings similar to those found in research consortia. We summarize our contributions here: \begin{itemize} \item We propose a novel distributed computation protocol, $\mathsf{CAPE}$, that improves upon the conventional distributed DP schemes and achieves the same level of utility as the pooled data scenario in certain regimes. $\mathsf{CAPE}$ can be employed in a wide range of computations that frequently appear in machine learning problems. \item We propose an improved functional mechanism (FM) using a tighter sensitivity analysis. We show analytically that it guarantees less noisy function computation for linear and logistic regression problems at the expense of an approximate DP guarantee. Empirical validation on real and synthetic data validates our approach. \item We extend the FM to decentralized settings and show that $\mathsf{CAPE}$ can achieve the same utility as the pooled data scenario in some regimes. To the best of our knowledge, this work proposes the first distributed functional mechanism. \item We demonstrate the effectiveness of our algorithms with varying privacy and dataset parameters. Our privacy analysis and empirical results on real and synthetic datasets show that the proposed algorithms can achieve much better utility than the existing state of the art algorithms. \end{itemize} Note that, we showed a preliminary version of the $\mathsf{CAPE}$ protocol in~\cite{imtiaz2018}. The protocol in this paper is more robust against site dropouts and does not require a trusted third-party. \section{Data and Privacy Model}\label{sec:problem_formulation} \noindent\textbf{Notation.} We denote vectors with bold lower case letters (e.g., $\mathbf{x}$), matrices with bold upper case letters (e.g. $\mathbf{X}$), scalars with regular letters (e.g., $M$) and indices with lower case letters (e.g., $m$). Indices typically run from 1 to their upper-case versions (e.g., $m \in \{1, 2, \ldots, M\} \triangleq [M]$). We denote the $n$-th column of the matrix $\mathbf{X}$ as $\mathbf{x}_n$. We use $\|\cdot\|_2$, $\|\cdot\|_F$ and $\mathop{\mathrm{tr}}\nolimits(\cdot)$ for the Euclidean (or $\mathcal{L}_2$) norm of a vector or spectral norm of a matrix, the Frobenius norm, and the trace operation, respectively. Finally, we denote the inner-product between two arrays as $\inprod{\cdot}{\cdot}$. For example, if $\mathbf{A}$ and $\mathbf{B}$ are two matrices then $\inprod{\mathbf{A}}{\mathbf{B}} = \mathop{\mathrm{tr}}\nolimits\left(\mathbf{A}^\top\mathbf{B}\right)$. \noindent\textbf{Distributed Data Setting.} We consider a distributed data setting with $S$ sites and a central aggregator node (see Figure \ref{fig:network_structure}). Each site $s \in [S]$ holds $N_s$ samples and the total number of samples across all sites is given by $N = \sum_{s=1}^S N_s$. We assume that all parties are ``honest but curious''. That is, the sites and the aggregator will follow the protocol but a subset may collude to learn another site's data/function output. Additionally, we assume that the data samples in the local sites are disjoint. We use the terms ``distributed'' and ``decentralized'' interchangeably in this paper. \begin{Def}[($\epsilon, \delta$)-Differential Privacy~\cite{dwork2006}] An algorithm $\mathcal{A}(\mathbb{D})$ taking values in a set $\mathbb{T}$ provides $(\epsilon,\delta)$-differential privacy if $\Pr[\mathcal{A}(\mathbb{D}) \in \mathbb{S}] \leq \exp(\epsilon) \Pr[\mathcal{A}(\mathbb{D'}) \in \mathbb{S}] + \delta$, for all measurable $\mathbb{S} \subseteq \mathbb{T}$ and all data sets $\mathbb{D}$ and $\mathbb{D'}$ differing in a single entry (neighboring datasets). \end{Def} \noindent This definition essentially states that the probability of the output of an algorithm is not changed significantly if the corresponding database input is changed by just one entry. Here, $\epsilon$ and $\delta$ are privacy parameters, where low $\epsilon$ and $\delta$ ensure more privacy. The parameter $\delta$ can be interpreted as the probability that the algorithm fails to provide privacy risk $\epsilon$. Several mechanisms can be employed to ensure that an algorithm satisfies differential privacy. Additive noise mechanisms such as the Gaussian or Laplace mechanisms~\cite{dwork2006, dwork2013algorithmic} and random sampling using the exponential mechanism~\cite{mcsherry2007} are among the most common ones. For additive noise mechanisms, the standard deviation of the noise is scaled to the \emph{sensitivity} of the computation. \begin{Def}[$\mathcal{L}_p$-sensitivity~\cite{dwork2006}] The $\mathcal{L}_p$-sensitivity of a vector-valued function $f(\mathbb{D})$ is $\Delta := \max_{ \mathbb{D}, \mathbb{D'} } \|f(\mathbb{D})-f(\mathbb{D'})\|_p$, where $\mathbb{D}$ and $\mathbb{D'}$ are neighboring datasets. \end{Def} \noindent We will focus on $p=1$ and $2$ in this paper. \begin{Def}[Gaussian Mechanism~\cite{dwork2013algorithmic}] Let $f: \mathbb{D} \mapsto \mathbb{R}^D$ be an arbitrary $D$-dimensional function with $\mathcal{L}_2$-sensitivity $\Delta$. The Gaussian Mechanism with parameter $\tau$ adds noise scaled to $\mathcal{N}(0, \tau^2)$ to each of the $D$ components of the output and satisfies $(\epsilon, \delta)$ differential privacy if \begin{align} \tau &\geq \frac{\Delta}{\epsilon}\sqrt{2\log\frac{1.25}{\delta}}. \label{eq:GaussMech} \end{align} \end{Def} \noindent Note that, for any given $(\epsilon, \delta)$ pair, we can calculate a noise variance $\tau^2$ such that addition of a noise term drawn from $\mathcal{N}(0, \tau^2)$ guarantees $(\epsilon, \delta)$-differential privacy. Since there are infinitely many $(\epsilon, \delta)$ pairs that yield the same $\tau^2$, we parameterize our methods using $\tau^2$~\cite{imtiaz2018} in this paper. \section{Correlation Assisted Private Estimation}\label{sec:cape} \subsection{Conventional Approach to Distributed DP Computations} \label{sec:dist_avg} We now describe the problem with conventional distributed DP and the $\mathsf{CAPE}$ approach to improve performance~\cite{imtiaz2018}. Suppose we want to compute the average of $N$ data samples. Each sample $x_n$ is a scalar with $x_n \in \left[0,1\right]$. We denote the vector of $N$ data samples as $\mathbf{x} = \left[x_1,\ldots, x_{N-1},\ x_N\right]^\top$. We are interested in computing the $(\epsilon, \delta)$-DP estimate of the mean function: $f(\mathbf{x}) = \frac{1}{N} \sum_{n = 1}^N x_n$. To compute the sensitivity~\cite{dwork2006} of the scalar-valued function $f(\mathbf{x})$, we consider a neighboring data vector $\mathbf{x'} = \left[x_1,\ldots, x_{N-1},\ x'_N\right]^\top$. We observe $\left|f(\mathbf{x}) - f(\mathbf{x'})\right| = \frac{1}{N}\left|x_N - x'_N\right| \leq \frac{1}{N}$, which follows from the assumption $x_n \in \left[0,1\right]$. Therefore, to compute the $(\epsilon, \delta)$-DP estimate of the average $a = f(\mathbf{x})$, we can employ the Gaussian mechanism~\cite{dwork2006, dwork2013algorithmic} to release $\hat{a} = a + e$, where $e \sim \mathcal{N}\left(0, \tau^2\right)$ and $\tau = \frac{1}{N\epsilon}\sqrt{2\log \frac{1.25}{\delta}}$. Each site $s$ holds $N_s$ samples $\mathbf{x}_s \in \mathbb{R}^{N_s}$ (see Figure \ref{fig:network_structure}(a)). We assume $N_s = \frac{N}{S}$ for simplicity. To compute the global average non-privately, the sites can send $a_s = f(\mathbf{x}_s)$ to the aggregator and the average computed by aggregator ($a_\mathrm{conv} = \frac{1}{S}\sum_{s=1}^S a_s$) is exactly equal to the average we would get if all the data samples were available in the aggregator node. However, with the privacy concern and considering that the aggregator is honest-but-curious, the sites can employ the conventional distributed DP computation technique. That is, the sites will release (send to the aggregator node) an $(\epsilon, \delta)$-DP estimate of the function $f(\mathbf{x}_s)$ of their local data $\mathbf{x}_s$. More specifically, each site will generate a noise $e_s \sim \mathcal{N}\left(0, \tau_s^2\right)$ and release/send $\hat{a}_s = f(\mathbf{x}_s) + e_s$ to the aggregator, where \begin{align*} \tau_s &= \frac{1}{N_s\epsilon}\sqrt{2\log \frac{1.25}{\delta}} = \frac{S}{N\epsilon}\sqrt{2\log \frac{1.25}{\delta}}. \end{align*} The aggregator can then compute the $(\epsilon, \delta)$-DP approximate average as $a_\mathrm{conv} = \frac{1}{S}\sum_{s=1}^S \hat{a}_s$. We observe \begin{align*} a_\mathrm{conv} &= \frac{1}{S}\sum_{s=1}^S \hat{a}_s = \frac{1}{S}\sum_{s=1}^S a_s + \frac{1}{S}\sum_{s=1}^S e_s. \end{align*} The variance of the estimator $a_\mathrm{conv}$ is $S \cdot \dfrac{\tau_s^2}{S^2} = \dfrac{\tau_s^2}{S} \triangleq \tau_\mathrm{conv}^2$. However, if we had all the data samples at the aggregator (pooled-data scenario), we could compute the $(\epsilon, \delta)$-DP estimate of the average as $a_\mathrm{pool} = \frac{1}{N}\sum_{n=1}^N x_n + e_\mathrm{pool}$, where $e_\mathrm{pool} \sim \mathcal{N}\left(0, \tau_\mathrm{pool}^2\right)$ and $\tau_\mathrm{pool} = \frac{1}{N\epsilon}\sqrt{2\log \frac{1.25}{\delta}} = \frac{\tau_s}{S}$. We observe the ratio \begin{align*} \frac{\tau_\mathrm{pool}^2}{\tau_\mathrm{conv}^2} &= \frac{\frac{\tau_s^2}{S^2}}{\frac{\tau_s^2}{S}} = \frac{1}{S}. \end{align*} That is, the distributed DP averaging scheme will always result in a worse performance than the DP pooled data case. \subsection{Proposed Scheme: $\mathsf{CAPE}$}\label{sec:cape_details} \begin{algorithm}[t] \caption{Generate zero-sum noise \label{alg:zero-sum-noise-generation}} \begin{algorithmic}[1] \Require Local noise variances $\{\tau_s^2\}$; security parameter $\lambda$, threshold value $t$ \State Each site generate $\hat{e}_s \sim \mathcal{N}(0, \tau_s^2)$ \State Aggregator computes $\sum_{s=1}^S \hat{e}_s$ according to $\mathsf{SecureAgg}(\lambda, t)$~\cite{Bonawitz17} \State Aggregator broadcasts $\sum_{s=1}^S \hat{e}_s$ to all sites $s \in \{1, \ldots, S\}$ \State Each site computes $e_s = \hat{e}_s - \frac{1}{S}\sum_{s'=1}^S \hat{e}_{s'}$\\ \Return $e_s$ \end{algorithmic} \end{algorithm} \noindent\textbf{Trust/Collusion Model. }In our proposed $\mathsf{CAPE}$ scheme, we assume that all of the $S$ sites and the central node follow the protocol honestly. However, up to $S_C = \ceil*{\frac{S}{3}} - 1$ sites can collude with an adversary to learn about some site's data/function output. The central node is also honest-but-curious (and therefore, can collude with an adversary). An adversary can observe the outputs from each site, as well as the output from the aggregator. Additionally, the adversary can know everything about the colluding sites (including their private data). We denote the number of non-colluding sites with $S_H$ such that $S = S_C + S_H$. Without loss of generality, we designate the non-colluding sites with $\{1, \ldots, S_H\}$ (see Figure \ref{fig:network_structure}(b)). \noindent\textbf{Correlated Noise. }We design the noise generation procedure such that: i) we can ensure $(\epsilon, \delta)$ differential privacy of the algorithm output from each site and ii) achieve the noise level of the pooled data scenario in the final output from the aggregator. We achieve that by employing a correlated noise addition scheme. Considering the same distributed averaging problem as Section \ref{sec:dist_avg}, we intend to release (and send to the aggregator) $\hat{a}_s = f(\mathbf{x}_s) + e_s + g_s$ from each site $s$, where $e_s$ and $g_s$ are two noise terms. The variances of $e_s$ and $g_s$ are chosen to ensure that the noise $e_s + g_s$ is sufficient to guarantee $(\epsilon, \delta)$-differential privacy to $f(\mathbf{x}_s)$. Here, each site generates the noise $g_s \sim \mathcal{N}(0, \tau_g^2)$ locally and the noise $e_s \sim \mathcal{N}(0, \tau_e^2)$ jointly with all other sites such that $\sum_{s=1}^S e_s = 0$. We employ the recently proposed secure aggregation protocol $(\mathsf{SecureAgg})$ by Bonawitz et al.~\cite{Bonawitz17} to generate $e_s$ that ensures $\sum_{s=1}^S e_s = 0$. The $\mathsf{SecureAgg}$ protocol utilizes Shamir's $t$-out-of-$n$ secret sharing~\cite{shamir1979} and is communication-efficient. \noindent\textbf{Detailed Description of $\mathsf{CAPE}$ Protocol. }In our proposed scheme, each site $s \in [S]$ generates a noise term $\hat{e}_s \sim \mathcal{N}(0, \tau_s^2)$ independently. The aggregator computes $\sum_{s=1}^S \hat{e}_s$ according to the $\mathsf{SecureAgg}$ protocol and broadcasts it to all the sites. Each site then sets $e_s = \hat{e}_s - \frac{1}{S}\sum_{s'=1}^S \hat{e}_{s'}$ to achieve $\sum_{s=1}^S e_s = 0$. We show the complete noise generation procedure in Algorithm \ref{alg:zero-sum-noise-generation}. Note that, the original $\mathsf{SecureAgg}$ protocol is intended for computing sum of $D$-dimensional vectors in a finite field $\mathbb{Z}^D_\lambda$. However, we need to perform the summation of Gaussian random variables over $\mathbb{R}$ or $\mathbb{R}^D$. To accomplish this, each site can employ a mapping $\mathrm{map}: \mathbb{R} \mapsto \mathbb{Z}_\lambda$ that performs a stochastic quantization~\cite{salman2019} for large-enough $\lambda$. The aggregator can compute the sum in the finite field according to $\mathsf{SecureAgg}$ and then invoke a reverse mapping $\mathrm{remap}: \mathbb{Z}_\lambda \mapsto \mathbb{R}$ before broadcasting $\sum_{s=1}^S \hat{e}_s$ to the sites. Algorithm \ref{alg:zero-sum-noise-generation} can be readily extended to generate array-valued zero-sum noise terms. We observe that the variance of $e_s$ is given by \begin{align}\label{eqn:cape_noise_variance_e} \tau_e^2 &= \mathbb{E}\left[\left(\hat{e}_s - \frac{1}{S}\sum_{s'=1}^S \hat{e}_{s'}\right)^2\right] = \left(1-\frac{1}{S}\right)\tau^2_s. \end{align} Additionally, we choose \begin{align}\label{eqn:cape_noise_variance_g} \tau_g^2 = \frac{\tau^2_s}{S}. \end{align} Each site then generates the noise $g_s \sim \mathcal{N}(0, \tau_g^2)$ independently and sends $\hat{a}_s = f(\mathbf{x}_s) + e_s + g_s$ to the aggregator. Note that neither of the terms $e_s$ and $g_s$ has large enough variance to provide $(\epsilon, \delta)$-DP guarantee to $f(\mathbf{x}_s)$. However, we chose the variances of $e_s$ and $g_s$ to ensure that the $e_s + g_s$ is sufficient to ensure a DP guarantee to $f(\mathbf{x}_s)$ at site $s$. The chosen variance of $g_s$ also ensures that the output from the aggregator would have the same noise variance as the differentially private pooled-data scenario. To see this, observe that we compute the following at the aggregator (in Step \ref{alg:dp_avg:step_a_ag} of Algorithm \ref{alg:dp_avg}): \begin{align*} a_\mathrm{cape} &= \frac{1}{S} \sum_{s=1}^S \hat{a}_s = \frac{1}{S} \sum_{s=1}^S f(\mathbf{x}_s) + \frac{1}{S} \sum_{s=1}^S g_s, \end{align*} where we used $\sum_s e_s = 0$. The variance of the estimator $a_\mathrm{cape}$ is $\tau^2_\mathrm{cape} = S \cdot \frac{\tau_g^2}{S^2} = \tau^2_\mathrm{pool}$, which is the exactly the same as if all the data were present at the aggregator. This claim is formalized in Lemma~\ref{lemma:cape}. We show the complete algorithm in Algorithm \ref{alg:dp_avg}. The privacy of Algorithm \ref{alg:dp_avg} is given by Theorem \ref{thm:cape}. The communication cost of the $\mathsf{CAPE}$ scheme is discussed in Appendix~\ref{appendix:cape_comm} in the Supplement. \begin{algorithm}[t] \caption{Correlation Assisted Private Estimation ($\mathsf{CAPE}$)\label{alg:dp_avg}} \begin{algorithmic}[1] \Require Data samples $\{\mathbf{x}_s\}$, local noise variances $\{\tau_s^2\}$ \For{$s = 1,\ \ldots,\ S$} \Comment{at each site} \State Generate $e_s$ according to Algorithm \ref{alg:zero-sum-noise-generation} \State Generate $g_s \sim \mathcal{N}(0, \tau_g^2)$ with $\tau_g^2 = \frac{\tau_s^2}{S}$ \State Compute and send $\hat{a}_s \gets f(\mathbf{x}_s) + e_s + g_s$ \label{alg:dp_avg:step_as_hat} \EndFor \State Compute $a_\mathrm{cape} \gets \frac{1}{S} \sum_{s=1}^S \hat{a}_s$ \label{alg:dp_avg:step_a_ag} \Comment{at the aggregator}\\ \Return $a_\mathrm{cape}$ \end{algorithmic} \end{algorithm} \begin{theorem}[Privacy of $\mathsf{CAPE}$ Algorithm (Algorithm \ref{alg:dp_avg})]\label{thm:cape} Consider Algorithm \ref{alg:dp_avg} in the distributed data setting of Section \ref{sec:problem_formulation} with $N_s = \frac{N}{S}$ and $\tau_s^2 = \tau^2$ for all sites $s \in [S]$. Suppose that at most $S_C = \ceil*{\frac{S}{3}} - 1$ sites can collude after execution. Then Algorithm \ref{alg:dp_avg} guarantees $(\epsilon, \delta)$-differential privacy for each site, where $(\epsilon,\delta)$ satisfy the relation $\delta = 2\frac{\sigma_z}{\epsilon - \mu_z}\phi\left(\frac{\epsilon - \mu_z}{\sigma_z}\right)$, $\phi(\cdot)$ is the density for standard Normal random variable and $(\mu_z, \sigma_z)$ are given by \begin{align} \mu_z &= \frac{S^3}{2\tau^2 N^2 (1+S)} \left(\frac{S - S_C + 2}{S - S_C} + \frac{\frac{9}{S - S_C}S_C^2}{S(1+S) - 3S_C^2}\right), \label{eq:CAPEmu} \\ \sigma_z^2 &= \frac{S^3}{\tau^2 N^2 (1+S)} \left(\frac{S - S_C + 2}{S - S_C} + \frac{\frac{9}{S - S_C}S_C^2}{S(1+S) - 3S_C^2}\right). \label{eq:CAPEsigma} \end{align} \end{theorem} \begin{Rem} Theorem~\ref{thm:cape} is stated for the symmetric setting: $N_s = \frac{N}{S}$ and $\tau_s^2 = \tau^2\ \forall s \in [S]$. As with many algorithms using the approximate differential privacy, the guarantee holds for a range of $(\epsilon,\delta)$ pairs subject to a tradeoff constraint between $\epsilon$ and $\delta$, as in the simple case in \eqref{eq:GaussMech}. \end{Rem} \begin{proof} As mentioned before, we identify the $S_H$ non-colluding sites with $s \in \{1, \ldots, S_H\} \triangleq \mathbb{S}_H$ and the $S_C$ colluding sites with $s \in \{S_H + 1, \ldots, S\} \triangleq \mathbb{S}_C$. The adversary can observe the outputs from each site (including the aggregator). Additionally, the colluding sites can share their private data and the noise terms, $\hat{e}_s$ and $g_s$ for $s \in \mathbb{S}_C$, with the adversary. For simplicity, we assume that all sites have equal number of samples (i.e., $N_s = \frac{N}{S}$) and $\tau_s^2 = \tau^2$. To infer the private data of the sites $s \in \mathbb{S}_H$, the adversary can observe $\hat{\mathbf{a}} = \left[\hat{a}_1, \ldots, \hat{a}_{S_H}\right]^\top \in \mathbb{R}^{S_H}$ and $\hat{e} = \sum_{s \in \mathbb{S}_H} \hat{e}_s$. Note that the adversary can learn the partial sum $\hat{e}$ because they can get the sum $\sum_s \hat{e}_s$ from the aggregator and the noise terms $\{\hat{e}_{S_H + 1}, \ldots, \hat{e}_S\}$ from the colluding sites. Therefore, the vector $\mathbf{y} = \left[\hat{\mathbf{a}}^\top, \hat{e}\right]^\top \in \mathbb{R}^{S_H + 1}$ is what the adversary can observe to make inference about the non-colluding sites. To prove differential privacy guarantee, we must show that $\left|\log\frac{g(\mathbf{y} | \mathbf{a})}{g(\mathbf{y} | \mathbf{a}')}\right| \leq \epsilon$ holds with probability (over the randomness of the mechanism) at least $1-\delta$. Here, $\mathbf{a} = \left[f(\mathbf{x}_1), \ldots, f(\mathbf{x}_{S_H})\right]^\top$ and $g(\cdot | \mathbf{a})$ and $g(\cdot | \mathbf{a}')$ are the probability density functions of $\mathbf{y}$ under $\mathbf{a}$ and $\mathbf{a}'$, respectively. The vectors $\mathbf{a}$ and $\mathbf{a}'$ differ in only one coordinate (neighboring). Without loss of generality, we assume that $\mathbf{a}$ and $\mathbf{a}'$ differ in the first coordinate. We note that the maximum difference is $\frac{1}{N_s}$ as the sensitivity of the function $f(\mathbf{x_s})$ is $\frac{1}{N_s}$. Recall that we release $\hat{a}_s = f(\mathbf{x}_s) + e_s + g_s$ from each site. We observe $\forall s \in [S]$: $\mathbb{E}(\hat{a}_s) = f(\mathbf{x}_s),\ \mathrm{var}(\hat{a}_s) = \tau^2$. Additionally, $\forall s_1 \neq s_2 \in [S]$, we have: $\mathbb{E}(\hat{a}_{s_1} \hat{a}_{s_2}) = f(\mathbf{x}_{s_1}) f(\mathbf{x}_{s_2}) - \frac{\tau^2}{S}$. That is, the random variable $\hat{\mathbf{a}}$ is $\mathcal{N}(\mathbf{a}, \Sigma_{\hat{\mathbf{a}}})$, where $\Sigma_{\hat{\mathbf{a}}} = (1+\frac{1}{S})\tau^2 \mathbf{I} - \mathbf{1}\mathbf{1}^\top \frac{\tau^2}{S} \in \mathbb{R}^{S_H \times S_H}$ and $\mathbf{1}$ is a vector of all ones. Without loss of generality, we can assume~\cite{dwork2013algorithmic} that $\mathbf{a} = \mathbf{0}$ and $\mathbf{a}' = \mathbf{a} - \mathbf{v}$, where $\mathbf{v} = \left[\frac{1}{N_s},0, \ldots, 0\right]^\top$. Additionally, the random variable $\hat{e}$ is $\mathcal{N}(0, \tau^2_{\hat{e}})$, where $\tau^2_{\hat{e}} = S_H \tau^2$. Therefore, $g(\mathbf{y} | \mathbf{a})$ is the density of $\mathcal{N}(\mathbf{0}, \Sigma)$, where \[ \Sigma = \begin{bmatrix} \Sigma_{\hat{\mathbf{a}}} & \Sigma_{\hat{\mathbf{a}}\hat{e}} \\ \Sigma_{\hat{\mathbf{a}}\hat{e}}^\top & \tau^2_{\hat{e}} \end{bmatrix} \in \mathbb{R}^{(S_H + 1) \times (S_H + 1)}. \] With some simple algebra, we can find the expression for $\Sigma_{\hat{\mathbf{a}}\hat{e}}$: $\Sigma_{\hat{\mathbf{a}}\hat{e}} = \left(1-\frac{S_H}{S}\right)\tau^2 \mathbf{1} \in \mathbb{R}^{S_H}$. If we denote $\tilde{\mathbf{v}} = \left[\mathbf{v}^\top, 0\right]^\top \in \mathbb{R}^{S_H+1}$ then we observe \begin{align*} \left|\log\frac{g(\mathbf{y} | \mathbf{a})}{g(\mathbf{y} | \mathbf{a}')}\right| &= \left|-\frac{1}{2}\left( \mathbf{y}^\top\Sigma^{-1}\mathbf{y} - \left(\mathbf{y} + \tilde{\mathbf{v}}\right)^\top\Sigma^{-1}\left(\mathbf{y} + \tilde{\mathbf{v}}\right)\right)\right| \\ &= \left|\frac{1}{2}\left( 2\mathbf{y}^\top\Sigma^{-1}\tilde{\mathbf{v}} + \tilde{\mathbf{v}}^\top\Sigma^{-1}\tilde{\mathbf{v}}\right)\right| \\ &= \left|\mathbf{y}^\top\Sigma^{-1}\tilde{\mathbf{v}} + \frac{1}{2}\tilde{\mathbf{v}}^\top\Sigma^{-1}\tilde{\mathbf{v}}\right| = |z|, \end{align*} where $z = \mathbf{y}^\top\Sigma^{-1}\tilde{\mathbf{v}} + \frac{1}{2}\tilde{\mathbf{v}}^\top\Sigma^{-1}\tilde{\mathbf{v}}$. Using the matrix inversion lemma for block matrices~\cite[Section 0.7.3]{horn2012} and some algebra, we have \[ \Sigma^{-1} = \begin{bmatrix} \Sigma_{\hat{\mathbf{a}}}^{-1} + \frac{1}{K} \Sigma_{\hat{\mathbf{a}}}^{-1} \Sigma_{\hat{\mathbf{a}}\hat{e}} \Sigma_{\hat{\mathbf{a}}\hat{e}}^\top\Sigma_{\hat{\mathbf{a}}}^{-1} & -\frac{1}{K} \Sigma_{\hat{\mathbf{a}}}^{-1} \Sigma_{\hat{\mathbf{a}}\hat{e}} \\ -\frac{1}{K}\Sigma_{\hat{\mathbf{a}}\hat{e}}^\top\Sigma_{\hat{\mathbf{a}}}^{-1} & \frac{1}{K} \end{bmatrix}, \] where $\Sigma_{\hat{\mathbf{a}}}^{-1} = \frac{S}{(1+S)\tau^2}\left(\mathbf{I} + \frac{2}{S_H}\mathbf{1}\mathbf{1}^\top\right)$ and $K = \tau^2_{\hat{e}} - \Sigma_{\hat{\mathbf{a}}\hat{e}}^\top\Sigma_{\hat{\mathbf{a}}}^{-1}\Sigma_{\hat{\mathbf{a}}\hat{e}}$. Note that $z$ is a Gaussian random variable $\mathcal{N}(\mu_z, \sigma_z^2)$ with parameters $\mu_z = \frac{1}{2}\tilde{\mathbf{v}}^\top\Sigma^{-1}\tilde{\mathbf{v}}$ and $\sigma_z^2 = \tilde{\mathbf{v}}^\top\Sigma^{-1}\tilde{\mathbf{v}}$ given by \eqref{eq:CAPEmu} and \eqref{eq:CAPEsigma}, respectively. Now, we observe \begin{align*} \Pr\left[\left|\log\frac{g(\mathbf{y} | \mathbf{a})}{g(\mathbf{y} | \mathbf{a}')}\right| \leq \epsilon\right] &= \Pr\left[\left|z\right| \leq \epsilon\right] = 1 - 2 \Pr\left[z > \epsilon\right] \\ &= 1 - 2Q\left(\frac{\epsilon - \mu_z}{\sigma_z}\right)\\ &> 1 - 2\frac{\sigma_z}{\epsilon - \mu_z}\phi\left(\frac{\epsilon - \mu_z}{\sigma_z}\right), \end{align*} where $Q(\cdot)$ is the Q-function~\cite{qfunc} and $\phi(\cdot)$ is the density for standard Normal random variable. The last inequality follows from the bound $Q(x) < \frac{\phi(x)}{x}$~\cite{qfunc}. Therefore, the proposed $\mathsf{CAPE}$ ensures $(\epsilon, \delta)$-DP with $\delta = 2\frac{\sigma_z}{\epsilon - \mu_z}\phi\left(\frac{\epsilon - \mu_z}{\sigma_z}\right)$ for each site, assuming that the number of colluding sites is at-most $\ceil*{\frac{S}{3}} - 1$. As the local datasets are disjoint and differential privacy is invariant under post processing, the release of $a_\mathrm{cape}$ also satisfies $(\epsilon, \delta)$-DP. \end{proof} \begin{Rem} We use the $\mathsf{SecureAgg}$ protocol~\cite{Bonawitz17} to generate the zero-sum noise terms by mapping floating point numbers to a finite field. Such mappings are shown to be vulnerable to certain attacks~\cite{mironov2012}. However, the floating point implementation issues are out of scope for this paper. We refer the reader to the work of Balcer and Vadhan~\cite{balcer2018} for possible remedies. We believe a very interesting direction of future work would be to address the issue in our distributed data setting. \end{Rem} \subsection{Utility Analysis}\label{sec:cape_utility} The goal is to ensure $(\epsilon, \delta)$-DP for each site and achieve $\tau_\mathrm{cape}^2 = \tau_\mathrm{pool}^2$ at the aggregator (see Lemma~\ref{lemma:cape}). The $\mathsf{CAPE}$ protocol guarantees $(\epsilon, \delta)$-DP with $\delta = 2\frac{\sigma_z}{\epsilon - \mu_z}\phi\left(\frac{\epsilon - \mu_z}{\sigma_z}\right)$. We claim that this $\delta$ guarantee is much better than the $\delta$ guarantee in the conventional distributed DP scheme. We empirically validate this claim by comparing $\delta$ with $\delta_\mathrm{conv}$ in Appendix~\ref{appendix:eff_delta} in the Supplement. Here, $\delta_\mathrm{conv}$ is the smallest $\delta$ guarantee we can afford in the conventional distributed DP scheme to achieve the same noise variance as the pooled-data scenario for a given $\epsilon$. Additionally, we empirically compare $\delta$ and $\delta_\mathrm{conv}$ for weaker collusion assumptions in Appendix~\ref{appendix:fewer_colluding_sites} in the Supplement. In both cases, we observe that $\delta$ is always smaller than $\delta_\mathrm{conv}$. That is, for achieving the same noise level at the aggregator output (and therefore the same utility) as the pooled data scenario, we are ensuring a much better privacy guarantee by employing the $\mathsf{CAPE}$ scheme over the conventional approach. \begin{lemma}\label{lemma:cape} Consider the symmetric setting: $N_s = \frac{N}{S}$ and $\tau_s^2 = \tau^2$ for all sites $s \in [S]$. Let the variances of the noise terms $e_s$ and $g_s$ (Step \ref{alg:dp_avg:step_as_hat} of Algorithm \ref{alg:dp_avg}) be $\tau_e^2 = \left(1-\frac{1}{S}\right)\tau^2$ and $\tau_g^2 = \frac{\tau^2}{S}$, respectively. If we denote the variance of the additive noise (for preserving privacy) in the pooled data scenario by $\tau_\mathrm{pool}^2$ and the variance of the estimator $a_\mathrm{cape}$ (Step \ref{alg:dp_avg:step_a_ag} of Algorithm \ref{alg:dp_avg}) by $\tau_\mathrm{cape}^2$ then Algorithm \ref{alg:dp_avg} achieves the same expected error as the pooled-data scenario (i.e., $\tau_\mathrm{pool}^2 = \tau_\mathrm{cape}^2$). \end{lemma} \begin{proof} The proof is given in Appendix \ref{appendix:cape_lemma} in the Supplement. \end{proof} \begin{prop}\label{prop:gain}(Performance gain) If the local noise variances are $\{\tau_s^2\}$ for $s \in [S]$ then the $\mathsf{CAPE}$ algorithm achieves a gain of $G = \frac{\tau_\mathrm{conv}^2}{\tau_\mathrm{cape}^2} = S$, where $\tau_\mathrm{conv}^2$ and $\tau_\mathrm{cape}^2$ are the noise variances of the final estimate at the aggregator in the conventional distributed DP scheme and the $\mathsf{CAPE}$ scheme, respectively. \end{prop} \begin{proof} The proof is given in Appendix \ref{appendix:perf_gain} in the Supplement. \end{proof} Note that, even in the case of site drop-out, we achieve $\sum_s e_s = 0$, as long as the number of active sites is above some threshold (see Bonawitz et al.~\cite{Bonawitz17} for details). Therefore, the performance gain of $\mathsf{CAPE}$ remains the same irrespective of the number of dropped-out sites. \begin{Rem}[Unequal Sample Sizes at Sites] Note that the $\mathsf{CAPE}$ algorithm achieves the same noise variance as the pooled-data scenario (i.e., $\tau_\mathrm{cape}^2 = \tau_\mathrm{pool}^2$) in the symmetric setting: $N_s = \frac{N}{S}$ and $\tau_s^2 = \tau^2$ for all sites $s \in [S]$. In general, the ratio $H(\mathbf{n}) = \frac{\tau_\mathrm{cape}^2}{\tau_\mathrm{pool}^2}$, where $\mathbf{n} \triangleq [N_1,\ N_2,\ \ldots, N_S]$, is a function of the sample sizes in the sites. We observe: $H(\mathbf{n}) = \frac{N^2}{S^3} \sum_{s=1}^S \frac{1}{N_s^2}$. As $H(\mathbf{n})$ is a Schur-convex function, it can be shown using majorization theory~\cite{majorization} that $1 \leq H(\mathbf{n}) \leq \frac{N^2}{S^3}\left(\frac{1}{\left(N - S + 1\right)^2} + S - 1\right)$, where the minimum is achieved for the symmetric setting. That is, $\mathsf{CAPE}$ achieves the smallest noise variance at the aggregator in the symmetric setting. For distributed systems with unequal sample sizes at the sites and/or different $N_s$ and $\tau_s$ at each site, we compute the weighted sum $a_\mathrm{cape} = \sum_{s=1}^S w_s \hat{a}_s$ at the aggregator. In order to achieve the same noise level as the pooled data scenario, we need to ensure $\sum_{s=1}^S w_s e_s = 0$ and $\text{var}\left[\sum_{s=1}^s w_s g_s\right] = \tau_\mathrm{pool}^2$. A scheme for doing so is shown in~\cite{imtiaz2018}. In this paper, we keep the analysis for the case $N_s = \frac{N}{S}, \forall s\in [S]$ for simplicity. \end{Rem} \subsection{Scope of $\mathsf{CAPE}$}\label{sec:cape_scope} $\mathsf{CAPE}$ is motivated by scientific research collaborations that are common in medicine and biology. Privacy regulations prevent sites from sharing the local raw data. Additionally, the data is often high dimensional (e.g., in neuroimaging) and sites have small sample sizes. Joint learning across datasets can yield discoveries that are impossible to obtain from a single site. $\mathsf{CAPE}$ can benefit functions $f$ with sensitivities satisfying some conditions (see Proposition \ref{prop:low_sensitivity}). In addition to the averaging function, many functions of interest have sensitivities that satisfy such conditions. Examples include the empirical average loss functions used in machine learning and deep neural networks. Additionally, we can use the Stone-Weierstrass theorem~\cite{rudin1976} to approximate a loss function $f$ and apply $\mathsf{CAPE}$, as we show in Section \ref{sec:capefm}. Furthermore, we can use the nomographic representation of functions to approximate a desired function in a decentralized manner~\cite{Kolmogoro57:rep1,Sprecher65representation,buck1982nomographic,Sprecher14representation} (for applications in communications~\cite{Nazer07,LimmerMS:15nomographic,Goldenbaum13tcom,Goldenbaum13tsp}), while keeping the data differentially private. More common applications include gradient based optimization algorithms, $k$-means clustering and estimating probability distributions. \begin{prop}\label{prop:low_sensitivity} Consider a distributed setting with $S > 1$ sites in which site $s \in [S]$ has a dataset $\mathbb{D}_s$ of $N_s$ samples and $\sum_{s=1}^S N_s = N$. Suppose the sites are computing a function $f(\mathbb{D})$ with $\mathcal{L}_p$ sensitivity $\Delta(N)$ employing the $\mathsf{CAPE}$ scheme. Denote $\mathbf{n} = [N_1,\ N_2,\ \ldots, N_S]$ and observe the ratio $H(\mathbf{n}) = \frac{\tau_\mathrm{cape}^2}{\tau_\mathrm{pool}^2} = \frac{\sum_{s=1}^S \Delta^2(N_s)}{S^3 \Delta^2(N)}$. Then the $\mathsf{CAPE}$ protocol achieves $H(\mathbf{n}) = 1$, if \begin{itemize} \item for convex $\Delta (N)$ we have: $\Delta\left(\frac{N}{S}\right) = S \Delta (N)$ \item for general $\Delta (N)$ we have: $S^3 \Delta^2(N) = \sum_{s=1}^S \Delta^2(N_s)$. \end{itemize} \end{prop} \begin{proof} We review some definitions and lemmas~\cite[Proposition C.2]{majorization} necessary for the proof in Appendix~\ref{appendix:low_sensitivity} in the Supplement. As the sites are computing the function $f$ with $\mathcal{L}_p$ sensitivity $\Delta(N)$, the local noise standard deviation for preserving privacy is proportional to $\Delta(N_s)$ by Gaussian mechanism~\cite{dwork2006}. It can be written as: $\tau_s = \Delta(N_s) C$, where $C$ is a constant for a given $(\epsilon, \delta)$ pair. Similarly, the noise standard deviation in the pooled data scenario can be written as: $\tau_\mathrm{pool} = \Delta(N) C$. Now, the final noise variance at the aggregator for $\mathsf{CAPE}$ protocol is: $\tau^2_\mathrm{cape} = \sum_{s=1}^S \frac{\tau_g^2}{S^2} = \frac{1}{S^3} \sum_{s=1}^S \Delta^2(N_s) C^2$. Now, we observe the ratio: $H(\mathbf{n}) = \frac{\tau_\mathrm{cape}^2}{\tau_\mathrm{pool}^2} = \frac{\sum_{s=1}^S \Delta^2(N_s)}{S^3 \Delta^2(N)}$. As we want to achieve the same noise variance as the pooled-data scenario, we need $S^3 \Delta^2(N) = \sum_{s=1}^S \Delta^2(N_s)$, which proves the case for general sensitivity function $\Delta(N)$. Now, if $\Delta^2(N)$ is convex then the by Lemma~\ref{lem: schurconx} (Supplement) the function $K(\mathbf{n}) = \sum_{s=1}^S \Delta^2(N_s)$ is Schur-convex. Thus the minimum of $K(\mathbf{n})$ is obtained when $\mathbf{n} = \mathbf{n}_\mathrm{sym}$. We observe: $K_{\min}(\mathbf{n}) = \sum_{s=1}^S \Delta^2\left(\frac{N}{S}\right) = S \cdot \Delta^2\left(\frac{N}{S}\right)$. Therefore, when $\Delta(N)$ is convex, we achieve $H(\mathbf{n}) = 1$ if $\Delta(\frac{N}{S}) = S \Delta(N)$. \end{proof} \section{Application of $\mathsf{CAPE}$: Distributed Computation of Functions} As mentioned before, the $\mathsf{CAPE}$ framework can benefit any distributed differentially private function computation, as long as the sensitivity of the function satisfies the conditions outlined in Proposition \ref{prop:low_sensitivity}. In this section, we propose an algorithm that is specifically suited for privacy-preserving computation of cost functions in distributed settings. Let us consider a cost function $f_D(\mathbf{w}): \mathbb{R}^D \mapsto \mathbb{R}$ that depends on private data distributed across $S$ sites. A central aggregator (see Figure \ref{fig:network_structure}) wishes find the minimizer $\mathbf{w}^*$ of $f_D(\mathbf{w})$. This is a common scenario in distributed machine learning. Now, the aggregator is not trusted and the sites may collude with an adversary to learn information about the other sites. Since computing the $\mathbf{w}^*$ by minimizing the expected cost/loss involves the sensitive information of the local datasets, we need to ensure that $\mathbf{w}^*$ is computed in a privacy-preserving way. In particular, we want to develop an algorithm to compute the $(\epsilon, \delta)$ differentially private approximate to $\mathbf{w}^*$, denoted $\hat{\mathbf{w}}^*$, in a distributed setting that produces a result as close as possible to the non-private pooled $\mathbf{w}^*$. Inline with our discussions in the previous sections, let us assume that each site $s \in [S]$ holds a dataset $\mathbb{D}_s$ of $N_s$ samples $\mathbf{x}_{s, n} \in \mathbb{R}^D$. The total sample size across all sites is $N = \sum_{s=1}^S N_s$. The cost incurred by a $\mathbf{w} \in \mathbb{R}^D$ due to one data sample $\mathbf{x}_{s, n}$ is $f(\mathbf{x}_{s, n}; \mathbf{w}) : \mathbb{R}^D \times \mathbb{R}^D \mapsto \mathbb{R}$. We need to minimize the average cost to find the optimal $\mathbf{w}^*$. The empirical average cost for a particular $\mathbf{w}$ over all the samples is expressed as \begin{align}\label{eqn:empirical_avg_cost} f_D(\mathbf{w}) &= \frac{1}{N} \sum_{s=1}^S \sum_{n=1}^{N_s} f(\mathbf{x}_{s,n}; \mathbf{w}). \end{align} Therefore, we have \begin{align*} \mathbf{w}^* &= \argmin_\mathbf{w} f_D(\mathbf{w}) = \argmin_\mathbf{w} \frac{1}{N} \sum_{s=1}^S \sum_{n=1}^{N_s} f(\mathbf{x}_{s,n}; \mathbf{w}). \end{align*} For centralized optimization, we can find a differentially-private approximate to $\mathbf{w}^*$ using output perturbation~\cite{anand2011} or objective perturbation~\cite{anand2011,nozari2016}. We propose using the \emph{functional mechanism}~\cite{zhang2012}, which is a form of objective perturbation and is more amenable to distributed implementation. It uses a polynomial representation of the cost function and can be used for any differentiable and continuous cost function. We perturb each term in the polynomial representation of $f_D(\mathbf{w})$ to get modified cost function $\hat{f}_D(\mathbf{w})$. The minimizer $\hat{\mathbf{w}}^* = \argmin_\mathbf{w} \hat{f}_D(\mathbf{w})$ guarantees differential privacy. \subsection{Functional Mechanism} We first review the functional mechanism~\cite{zhang2012} in the pooled data case. Suppose $\phi(\mathbf{w})$ is a monomial function of the entries of $\mathbf{w}$: $\phi(\mathbf{w}) = w_1^{c_1} w_2^{c_2} \ldots w_D^{c_D}$, for some set of exponents $\{c_d : d \in [D]\} \subseteq \mathbb{N}$. Let us define the set $\Phi_j$ of all $\phi(\mathbf{w})$ with degree $j$ as \begin{align*} \Phi_j &= \left\{w_1^{c_1} w_2^{c_2} \ldots w_D^{c_D} : \sum_{d=1}^D c_d = j \right\}. \end{align*} For example, $\Phi_0 = \{1\}$, $\Phi_1 = \{w_1,\ w_2,\ \ldots,\ w_D\}$, $\Phi_2 = \{w_{d_1} w_{d_2} : d_1, d_2 \in [D]\}$, etc. Now, from the Stone-Weierstrass Theorem~\cite{rudin1976}, any differentiable and continuous cost function $f(\mathbf{x}_n; \mathbf{w})$ can be written as a (potentially infinite) sum of monomials of $\{w_d\}$: \begin{align*} f(\mathbf{x}_n; \mathbf{w}) &= \sum_{j=0}^J \sum_{\phi \in \Phi_j}\lambda_{n\phi}\phi(\mathbf{w}), \end{align*} for some $J \in [0,\infty]$. Here, $\lambda_{n\phi}$ denotes the coefficient of $\phi(\mathbf{w})$ in the polynomial and is a function of the $n$-th data sample. Plugging the expression of $f(\mathbf{x}_n; \mathbf{w})$ in \eqref{eqn:empirical_avg_cost}, we can express the empirical average cost over all $N$ samples as \begin{align}\label{eqn:empirical_cost} f_D(\mathbf{w}) &= \sum_{j=0}^J \sum_{\phi \in \Phi_j}\left(\frac{1}{N} \sum_{n=1}^N \lambda_{n\phi}\right)\phi(\mathbf{w}). \end{align} The function $f_D(\mathbf{w})$ depends on the data samples only through $\{\lambda_{n\phi}\}$. As the goal is to approximate $f_D(\mathbf{w})$ in a differentially-private way, one can compute these $\lambda_{n\phi}$ to satisfy differential privacy~\cite{zhang2012}. Let us consider two ``neighboring'' datasets: $\mathbb{D} = \{\mathbf{x}_1,\ \ldots,\ \mathbf{x}_{N-1},\ \mathbf{x}_N\}$ and $\mathbb{D}' = \{\mathbf{x}_1,\ \ldots,\ \mathbf{x}_{N-1},\ \mathbf{x'}_N\}$, differing in a single data point (i.e., the last one). Zhang et al.~\cite{zhang2012} computed the $\mathcal{L}_1$ sensitivity $\Delta^\mathrm{dp-fm}$ as \begin{align*} \left\|\sum_{j=0}^J \sum_{\phi \in \Phi_j} \frac{1}{N} \left(\sum_{\mathbb{D}} \lambda_{n\phi} - \sum_{\mathbb{D}'} \lambda_{n\phi}\right)\right\|_1 \\ \leq \frac{2}{N} \max_n \sum_{j=0}^J \sum_{\phi \in \Phi_j} \|\lambda_{n\phi}\|_1 \triangleq \Delta^\mathrm{dp-fm}, \end{align*} and proposed an $\epsilon$-differentially private method that adds Laplace noise with variance $2\left(\frac{\Delta^\mathrm{dp-fm}}{\epsilon}\right)^2$ to each $\sum_\mathbb{D} \lambda_{n\phi}$ for all $\phi \in \Phi_j$ and for all $j \in \{0,\ldots,J\}$. In the following, we propose an improved functional mechanism that employs a tighter characterization of the sensitivities and can be extended to incorporate the $\mathsf{CAPE}$ protocol for the distributed settings. \subsection{Improved Functional Mechanism}\label{sec:improved_fm} \begin{algorithm}[t] \caption{Improved Functional Mechanism \label{alg:fm}} \begin{algorithmic}[1] \Require Data samples $\{\mathbf{x}_{n}\}$; cost function $f_D(\mathbf{w})$ as in \eqref{eqn:f_D_with_Lambda_j}; privacy parameters $\epsilon$, $\delta$ \For{$j = 0,\ 1,\ \ldots,\ J$} \State Compute $\Lambda_j$ as shown in Section \ref{sec:improved_fm} \State Compute $\Delta_j \gets \max_{\mathbb{D}, \mathbb{D}'} \|\Lambda_j^\mathbb{D} - \Lambda_j^{\mathbb{D}'}\|_F$ \State Compute $\tau_j = \frac{\Delta_j}{\epsilon}\sqrt{2\log\frac{1.25}{\delta}}$ \State Compute $\hat{\Lambda}_j \gets \Lambda_j + e_j$, where $e_j$ have same dimensions as $\Lambda_j$ and entries of $e_j$ are i.i.d. $\sim \mathcal{N}(0, \tau_j^2)$ \EndFor \State Compute $\hat{f}_D(\mathbf{w}) = \sum_{j=0}^J \inprod{\hat{\Lambda}_j}{\bar{\phi}_j}$\\ \Return $\hat{f}_D(\mathbf{w})$ \end{algorithmic} \end{algorithm} Our method is an improved version of the functional mechanism~\cite{zhang2012}. We use the Gaussian mechanism~\cite{dwork2013algorithmic} for computing the $(\epsilon, \delta)$-DP approximate of $f_D(\mathbf{w})$. This gives a weaker privacy guarantee than the original functional mechanism~\cite{zhang2012}, which used Laplace noise for $\epsilon$-DP. Our distributed function computation method (described in Section \ref{sec:capefm}) benefits from the fact that linear combinations of Gaussians are Gaussian. In other words, the proposed $\mathsf{CAPE}$ and the distributed functional mechanism rely on the Gaussianity of the noise. Now, instead of computing the $\mathcal{L}_2$-sensitivity of $\lambda_{n\phi}$, we define an \emph{array} $\Lambda_j$ that contains $\frac{1}{N}\sum_{n=1}^N \lambda_{n\phi}$ as its entries for all $\phi(\mathbf{w}) \in \Phi_j$. We used the term ``array'' instead of vector or matrix or tensor because the dimension of $\Lambda_j$ depends on the cardinality $|\Phi_j|$ of the set $\Phi_j$. We can represent $\Lambda_j$ as a scalar for $j = 0$ (because $\Phi_0 = \{1\}$), as a $D$-dimensional vector for $j = 1$ (because $\Phi_1 = \{w_d : d \in [D]\}$), and as a $D\times D$ matrix for $j = 2$ (because $\Phi_2 = \{w_{d_1} w_{d_2} : d_1, d_2 \in [D]\}$). Additionally, we use $\bar{\phi}_j$ to denote the array containing all $\phi(\mathbf{w}) \in \Phi_j$ as its entries. The arrays $\bar{\phi}_j$ and $\Lambda_j$ have the same dimensions and number of elements. Rewriting the objective, we observe \begin{align} f_D(\mathbf{w}) &= \sum_{j=0}^J \sum_{\phi \in \Phi_j}\left(\frac{1}{N} \sum_{n=1}^N \lambda_{n\phi}\right)\phi(\mathbf{w})= \sum_{j=0}^J \inprod{\Lambda_j}{\bar{\phi}_j}\label{eqn:f_D_with_Lambda_j}. \end{align} We define the $\mathcal{L}_2$-sensitivity of $\Lambda_j$ as \begin{align}\label{eqn:sensitivity_Lambda} \Delta_j &= \max_{\mathbb{D}, \mathbb{D}'} \|\Lambda_j^\mathbb{D} - \Lambda_j^{\mathbb{D}'}\|_F, \end{align} where $\Lambda_j^\mathbb{D}$ and $\Lambda_j^{\mathbb{D}'}$ are computed on neighboring datasets $\mathbb{D}$ and $\mathbb{D}'$, respectively. Now, we use the Gaussian mechanism to get an $(\epsilon, \delta)$-DP approximation to $\Lambda_j$ as: $\hat{\Lambda}_j = \Lambda_j + e_j$, where $e_j$ is a noise array with the same dimensions as $\Lambda_j$ and its entries are drawn i.i.d. $\sim \mathcal{N}(0, \tau_j^2)$. Here $\tau_j = \frac{\Delta_j}{\epsilon}\sqrt{2\log\frac{1.25}{\delta}}$. As the function $f_D(\mathbf{w})$ depends on the data only through $\{\Lambda_j\}$, the computation \begin{align}\label{eqn:hat_f_D_with_hat_Lambda_j} \hat{f}_D(\mathbf{w}) &= \sum_{j=0}^J \inprod{\hat{\Lambda}_j}{\bar{\phi}_j} \end{align} satisfies $(\epsilon, \delta)$ differential privacy. We show the proposed improved functional mechanism in Algorithm \ref{alg:fm}. \begin{theorem}\label{thm:fm} Consider Algorithm \ref{alg:fm} with input parameters $(\epsilon, \delta)$ and the function $f_D(\mathbf{w})$ represented as \eqref{eqn:f_D_with_Lambda_j}. Then Algorithm \ref{alg:fm} computes an $(\epsilon, \delta)$ differentially private approximation $\hat{f}_D(\mathbf{w})$ to $f_D(\mathbf{w})$. Consequently, the minimizer $\hat{\mathbf{w}}^* = \argmin_\mathbf{w} \hat{f}_D(\mathbf{w})$ satisfies $(\epsilon, \delta)$-differential privacy. \end{theorem} \begin{proof} The proof is given in Appendix~\ref{appendix:thm:fm} in the Supplement. \end{proof} \subsection{Example -- Linear Regression}\label{sec:fm_example} In this section, we demonstrate the proposed improved functional mechanism in the centralized setting using a linear regression problem. We show that Algorithm \ref{alg:fm} achieves much better utility at the price of a weaker privacy guarantee ($(\epsilon, \delta)$-DP vs $\epsilon$-DP). The main reason for this performance improvement is due to defining the sensitivities of $\Lambda_j$ separately for each $j$, instead of using an uniform conservative upper-bound $\Delta^\mathrm{dp-fm}$ (as in~\cite{zhang2012}). We demonstrate the proposed improved functional mechanism for a logistic regression problem in Appendix~\ref{appendix:log_reg} in the Supplement. We have a dataset $\mathbb{D}$ with $N$ samples of the form $(\mathbf{x}_n, y_n)$, where $\mathbf{x}_n \in \mathbb{R}^D$ is the feature vector and $y_n \in \mathbb{R}$ is the response. Without loss of generality, we assume that $\|\mathbf{x}_n\|_2 \leq 1$ and $y_n \in [-1, 1]$. We want to find a vector $\mathbf{w} \in \mathbb{R}^D$ such that $\mathbf{x}_n^\top\mathbf{w} \approx y_n$ for all $n\in [N]$. The cost function $f:\mathbb{R}^D \times \mathbb{R}^D \mapsto \mathbb{R}^+$ due to each sample and a particular $\mathbf{w}$ is the squared loss: $f(\mathbf{x}_n, \mathbf{w}) = \left(y_n - \mathbf{x}_n^\top\mathbf{w}\right)^2$. The empirical average cost function is defined as \begin{align}\label{eqn:loss_avg} f_D(\mathbf{w}) &= \frac{1}{N} \sum_{n=1}^N f(\mathbf{x}_n, \mathbf{w}) = \frac{1}{N} \left\|\mathbf{y} - \mathbf{X}\mathbf{w}\right\|_F^2, \end{align} where $\mathbf{y} \in \mathbb{R}^N$ contains all $y_n$ and $\mathbf{X} \in \mathbb{R}^{N\times D}$ contains $\mathbf{x}_n^\top$ as its rows. By simple algebra, it can be shown that \begin{align*} f_D(\mathbf{w}) &= \left(\frac{1}{N} \sum_{n=1}^N y_n^2\right) + \sum_{d=1}^D\left(-\frac{2}{N}\sum_{n=1}^N y_n x_{nd}\right)w_d \\ &\qquad + \sum_{d_1 = 1}^D\sum_{d_2 = 1}^D \left(\frac{1}{N}\sum_{n=1}^N x_{nd_1} x_{nd_2}\right)w_{d_1}w_{d_2}, \end{align*} where $x_{pq}$ is the $q$-th element of the $p$-th sample vector or $x_{pq} = [\mathbf{X}]_{pq}$. Now, we have \begin{align*} \Lambda_0 &= \frac{1}{N} \sum_{n=1}^N y_n^2 = \frac{1}{N}\|\mathbf{y}\|_2^2\\ \Lambda_1 &= -\frac{2}{N} \begin{bmatrix} \sum_{n=1}^N y_n x_{n1} \\ \vdots \\ \sum_{n=1}^N y_n x_{nD} \end{bmatrix} = -\frac{2}{N} \left(\mathbf{1}^\top \mathrm{diag}(\mathbf{y}) \mathbf{X}\right)^\top\\ \Lambda_2 &= \frac{1}{N} \begin{bmatrix} \sum_{n=1}^N x_{n1}^2 & \cdots & \sum_{n=1}^N x_{n1}x_{nD}\\ \vdots & \ddots & \vdots \\ \sum_{n=1}^N x_{nD}x_{n1} & \cdots & \sum_{n=1}^N x_{nD}^2 \end{bmatrix} = \frac{\mathbf{X}^\top\mathbf{X}}{N}, \end{align*} where $\mathbf{1}$ is an $N$-dimensional vector of all 1's and $\mathrm{diag}(\mathbf{y})$ is an $N\times N$ diagonal matrix with the elements of $\mathbf{y}$ as diagonal entries. Additionally, we write out the $\{\bar{\phi}_j\}$ for completeness \begin{align*} \bar{\phi}_0 &= 1,\ \bar{\phi}_1 = \begin{bmatrix} w_1 \\ \vdots \\ w_D \end{bmatrix},\ \mbox{and} \\ \bar{\phi}_2 &= \begin{bmatrix} w_1^2 & w_1w_2 & \cdots & w_1w_D \\ \vdots & \vdots & \ddots & \vdots \\ w_Dw_1 & w_Dw_2 & \cdots & w_D^2 \end{bmatrix}. \end{align*} Therefore, we can express $f_D(\mathbf{w})$ as $f_D(\mathbf{w}) = \sum_{j=0}^2 \inprod{\Lambda_j}{\bar{\phi}_j}$. Now, we focus on finding the sensitivities of $\{\Lambda_j\}$. Let us consider a neighboring dataset $\mathbb{D}'$ which contains the same tuples as $\mathbb{D}$, except for the last one, i.e. $(\mathbf{x}_N', y_N')$. We have \begin{align*} \left|\Lambda_0^\mathbb{D} - \Lambda_0^{\mathbb{D}'}\right| &= \frac{1}{N} \left(y_N^2 - {y_N'}^2\right) \leq \frac{1}{N} \triangleq \Delta_0, \end{align*} where the inequality follows from the fact that $y_n \in [-1, 1]$. Next, we observe \begin{align*} \left\|\Lambda_1^\mathbb{D} - \Lambda_1^{\mathbb{D}'}\right\|_2 &= \frac{2}{N} \|\mathbf{a} - \mathbf{a}'\|_2 \leq \frac{4}{N} \triangleq \Delta_1, \end{align*} where $\mathbf{a} = y_N\mathbf{x}_N$ and $\mathbf{a}' = y_N' \mathbf{x}_N'$. Here, we used the inequality $\|\mathbf{a}\|_2 \leq 1$ as $-1 \leq y_n \leq 1$, $\|\mathbf{x}_n\|_2 \leq 1$. Similarly, $\|\mathbf{a}'\|_2 \leq 1$. Finally, we observe \begin{align*} \left\|\Lambda_2^\mathbb{D} - \Lambda_2^{\mathbb{D}'}\right\|_F &= \frac{1}{N}\left\|\mathbf{X}^\top\mathbf{X} - {\mathbf{X}'}^\top\mathbf{X}'\right\|_F \\ &= \frac{1}{N}\left\|\mathbf{x}_N\mathbf{x}_N^\top - \mathbf{x}_N'{\mathbf{x}_N'}^\top\right\|_F\\ &\leq \frac{\sqrt{2}}{N} \triangleq \Delta_2, \end{align*} where the last inequality follows from realizing that the $D\times D$ symmetric matrix $\mathbf{x}_N\mathbf{x}_N^\top - \mathbf{x}_N'{\mathbf{x}_N'}^\top$ is at most rank-2. Therefore, we can write its eigen-decomposition as: \begin{align*} \left\|\mathbf{x}_N\mathbf{x}_N^\top - \mathbf{x}_N'{\mathbf{x}_N'}^\top\right\|_F &= \left\|\mathbf{U}\mathbf{\Sigma}\mathbf{U}^\top\right\|_F \\ &\leq \|\mathbf{U}\|_F^2\|\mathbf{\Sigma}\|_F = \|\mathbf{\Sigma}\|_F \leq \sqrt{2}. \end{align*} Now that we have computed the $\mathcal{L}_2$-sensitivities of $\{\Lambda_j\}$, we can compute $\{\hat{\Lambda}_j\}$ and thus, the $(\epsilon, \delta)$-DP approximation $\hat{f}_D(\mathbf{w})$ following Algorithm \ref{alg:fm}. Note that if we employed the sensitivity computation technique as in~\cite{zhang2012}, the sensitivity for each entry of $\Lambda_j$ would be $\Delta^\mathrm{dp-fm} = \frac{2(D+1)^2}{N}$, which is orders of magnitude larger than $\Delta_j$ for any meaningful $D > 1$ and for all $j \in \{0,\ldots,J\}$. Therefore, with the sensitivity computation proposed in this work, we can achieve $\hat{f}_D(\mathbf{w})$ with much less noise. This results in a more accurate privacy-preserving estimate of the optimal $\hat{\mathbf{w}}^* = \argmin_\mathbf{w}\hat{f}_D(\mathbf{w})$, which we demonstrate empirically in Section \ref{sec:experimental_results}. \subsection{Distributed Functional Mechanism}\label{sec:convdistfm} In this section, we first we describe a conventional approach. Inline with Section \ref{sec:dist_avg}, we show that the conventional approach would always result in sub-optimal performance due to larger noise added to the cost function. Then we present the proposed algorithm ($\mathsf{capeFM}$) in detail (see Algorithm \ref{alg:capefm}). \noindent\textbf{Conventional Approach. }Recall the distributed setting, where we have $S$ different sites and a central aggregator, as depicted in Figure \ref{fig:network_structure}. The aggregator is not trusted. The goal is to compute the differentially private minimizer $\hat{\mathbf{w}}^*$ in this distributed setting. We assume that the datasets in the sites ($\mathbb{D}_s$ for $s \in [S]$) are disjoint and $N_s = \frac{N}{S}$. Recall that the cost function $f_D(\mathbf{w})$ depends on the data only through the $\{\Lambda_j\}$ for $j \in \{0,\ldots,J\}$. One na\"ive way to compute $\hat{\mathbf{w}}^*$ at the aggregator is the following: the sites use local data to compute and send the $(\epsilon, \delta)$ differentially-private approximates of $\{\Lambda_j^s\}$, denoted $\{\hat{\Lambda}_j^s\}$, to the aggregator. The aggregator combines these quantities to compute $\{\hat{\Lambda}_j\}$ and hence $\hat{f}_D(\mathbf{w})$. The aggregator can then compute and release $\hat{\mathbf{w}}^* = \argmin_\mathbf{w} \hat{f}_D(\mathbf{w})$. More specifically, each site $s$ computes $\hat{\Lambda}_j^s = \Lambda_j^s + e_j^s$, where $e_j^s$ is an array with the same dimensions as $\Lambda_j^s$ and the entries are drawn i.i.d. $\sim \mathcal{N}(0, {\tau_j^s}^2)$. Here, \begin{align*} \tau_j^s &= \frac{\Delta_j^s}{\epsilon}\sqrt{2\log\frac{1.25}{\delta}}, \end{align*} and $\Delta_j^s = \max_{\mathbb{D}_s, \mathbb{D}_s'} \|\Lambda_j^{s,\mathbb{D}_s} - \Lambda_j^{s,\mathbb{D}_s'}\|_F$, where $\Lambda_j^{s,\mathbb{D}_s}$ and $\Lambda_j^{s,\mathbb{D}'_s}$ are computed on neighboring datasets $\mathbb{D}_s$ and $\mathbb{D}_s'$, respectively. Recall that $\Lambda_j^{s,\mathbb{D}_s}$ (and similarly $\Lambda_j^{s,\mathbb{D}'_s}$) is an array of $|\Phi_j|$ elements containing $\frac{1}{N_s}\sum_{n=1}^{N_s}\lambda_{n\phi}$ as its entries for all $\phi(\mathbf{w}) \in \Phi_j$. The sites send these $\{\hat{\Lambda}_j^s\}$ to the aggregator. The aggregator then computes \begin{align*} \hat{\Lambda}_j^\mathrm{conv} &= \frac{1}{S} \sum_{s=1}^S \hat{\Lambda}_j^s = \frac{1}{S} \sum_{s=1}^S \Lambda_j^s + \frac{1}{S} \sum_{s=1}^S e_j^s. \end{align*} The variance of the estimator $\hat{\Lambda}_j^\mathrm{conv}$ is $S\cdot \frac{{\tau_j^s}^2}{S^2} = \frac{{\tau_j^s}^2}{S} \triangleq {\tau_j^\mathrm{conv}}^2$. However, if we had all the data samples at the aggregator (centralized/pooled data scenario), we could compute the $(\epsilon, \delta)$-DP approximates of $\{\Lambda_j\}$ as $\hat{\Lambda}_j = \Lambda_j + e_j$, where $e_j$ is an array with the same dimensions as $\Lambda_j$ and the entries are drawn i.i.d. $\sim \mathcal{N}(0, {\tau_j^\mathrm{pool}}^2)$. The noise standard deviation $\tau_j^\mathrm{pool}$ is given by: \begin{align*} \tau_j^\mathrm{pool} &= \frac{\Delta_j^\mathrm{pool}}{\epsilon}\sqrt{2\log\frac{1.25}{\delta}}, \end{align*} where $\Delta_j^\mathrm{pool} = \max_{\mathbb{D}, \mathbb{D}'} \|\Lambda_j^\mathbb{D} - \Lambda_j^{\mathbb{D}'}\|_F$. Now, $\Lambda_j^\mathbb{D}$ is an $|\Phi_j|$-dimensional array with entries $\frac{1}{N}\sum_{n=1}^{N}\lambda_{n\phi}$ for all $\phi(\mathbf{w}) \in \Phi_j$. Clearly $\frac{\Delta_j^\mathrm{pool}}{\Delta_j^s} = \frac{1/N}{1/N_s} = \frac{1}{S}$, which implies $\tau_j^\mathrm{pool} = \frac{\tau_j^s}{S}$. For this case, we observe the ratio $\frac{{\tau_j^\mathrm{pool}}^2}{{\tau_j^\mathrm{conv}}^2} = \frac{{\tau_j^s}^2 / S^2}{{\tau_j^s}^2 / S} = \frac{1}{S}$, which is exactly the same as the distributed problem of Section \ref{sec:dist_avg}. \subsection{Proposed Distributed Functional Mechanism $(\mathsf{capeFM})$}\label{sec:capefm} \begin{algorithm}[t] \caption{Proposed Distributed Functional Mechanism ($\mathsf{capeFM}$)\label{alg:capefm}} \begin{algorithmic}[1] \Require Data samples $\{\mathbf{x}_{s,n}\}$; cost function $f_D(\mathbf{w})$ as in \eqref{eqn:f_D_with_Lambda_j}; local noise variances $\{\tau_j^s\}$ for all $j \in \{0,\ldots,J\}$ \For{$s = 1,\ \ldots,\ S$} \For{$j = 0,\ 1,\ \ldots,\ J$} \State Compute $\Lambda_j$ as described in Section \ref{sec:improved_fm} \State Generate $e_j^s$ according to Algorithm \ref{alg:zero-sum-noise-generation} (entrywise) \State Compute ${\tau_{jg}^s}^2 \gets \frac{{\tau_j^s}^2}{S}$ \State Generate $g_j^s$ with entries i.i.d. $\sim \mathcal{N}(0, {\tau_{jg}^s}^2)$ \State Compute $\hat{\Lambda}_j^s \gets \Lambda_j^s + e_j^s + g_j^s$ \label{alg:capefm:step_lambda_hat} \EndFor \EndFor \State At the central aggregator, compute for all $j \in \{0,\ldots,J\}$: $\hat{\Lambda}_j \gets \frac{1}{S} \sum_{s=1}^S \hat{\Lambda}_j^s$ \label{alg:capefm:step_lambda_ag} \State Compute $\hat{f}_D(\mathbf{w}) \gets \sum_{j=0}^J \inprod{\hat{\Lambda}_j}{\bar{\phi}_j}$\\ \Return $\hat{f}_D(\mathbf{w})$ \end{algorithmic} \end{algorithm} Our proposed method, $\mathsf{capeFM}$, is described in Algorithm \ref{alg:capefm} and is based on the $\mathsf{CAPE}$ scheme described in Section \ref{sec:cape_details}. We exploit the correlated noise to achieve the same performance of the pooled data case (Lemma \ref{lemma:cape}) in the symmetric decentralized setting under the honest-but-curious model for the sites. Recall our assumption that all parties follow the protocol and the number of colluding sites is not more than $\ceil*{S/3} - 1$. The sites collectively generate the noise $e_j^s$ with entries i.i.d. $\sim \mathcal{N}(0, {\tau_{je}^s}^2)$, according to Algorithm \ref{alg:zero-sum-noise-generation}, such that $\sum_{s=1}^S e_j^s = 0$ holds for all $j \in \{0,\ldots,J\}$. The local sites also generate noise $g_j^s$ with entries i.i.d. $\sim \mathcal{N}(0, {\tau_{jg}^s}^2)$. From each site $s$, we release (or send to the central aggregator): $\hat{\Lambda}_j^s = \Lambda_j^s + e_j^s + g_j^s$ for all $j \in \{0,\ldots,J\}$. Note that $e_j^s$ and $g_j^s$ are arrays of the same dimension as $\Lambda_j^s$. As described in Section \ref{sec:cape_details}, we have \begin{align}\label{eqn:capefm_noise_variance} {\tau_{je}^s}^2 &= \left(1-\frac{1}{S}\right){\tau_j^s}^2,\mbox{ and } {\tau_{jg}^s}^2 = \frac{{\tau_j^s}^2}{S}. \end{align} Now, at the aggregator we compute the following quantity \begin{align*} \hat{\Lambda}_j &= \frac{1}{S} \sum_{s=1}^S \hat{\Lambda}_j^s = \frac{1}{S} \sum_{s=1}^S \Lambda_j^s + \frac{1}{S} \sum_{s=1}^S g_j^s, \end{align*} because $\sum_s e_j^s = 0$. The aggregator then uses these $\{\hat{\Lambda}_j\}$ to compute $\hat{f}_D(\mathbf{w})$ and release $\hat{\mathbf{w}}^* = \argmin_\mathbf{w}\hat{f}_D(\mathbf{w})$. Privacy of $\mathsf{capeFM}$ follows directly from Theorem \ref{thm:cape}. In the symmetric setting (i.e., $N_s = \frac{N}{S}$ and $\tau_j^s = \tau_j$ for all sites $s \in [S]$ and all $j \in \{0, 1, \ldots, J\}$), the noise variance at the aggregator is exactly the same as that of the pooled data scenario (see Lemma \ref{lemma:cape} and Proposition~\ref{prop:low_sensitivity}). Additionally, the performance gain of $\mathsf{capeFM}$ over any conventional distributed functional mechanism is given by Proposition~\ref{prop:gain}. \section{Experimental Results}\label{sec:experimental_results} In this section, we empirically show the effectiveness of the proposed $\mathsf{CAPE}$ and $\mathsf{capeFM}$ algorithms with applications in a neural network based classifier and a linear regression problem in distributed settings. Our $\mathsf{CAPE}$ algorithm can improve a distributed computation if the target function has sensitivity satisfying the conditions of Proposition \ref{prop:low_sensitivity}. Additionally, the proposed $\mathsf{capeFM}$ algorithm is well-suited for distributed optimization, as we can compute the DP approximate $\hat{f}_D(\mathbf{w})$ of the loss function and then use any off-the-shelf optimizer. If the function can be represented as \eqref{eqn:f_D_with_Lambda_j}, we can employ the $\mathsf{capeFM}$ algorithm for an even better utility. However, finding such a representation may be challenging for large neural networks. We first demonstrate the effectiveness of the $\mathsf{CAPE}$ algorithm for a neural network based classifier with varying $\epsilon$ and total sample size by comparing against the non-privacy-preserving pooled-data approach $(\mathsf{Non-priv.})$ and the conventional approach ($\mathsf{conv}$) of distributed DP gradient descent~\cite{abadi2016}. Then we demonstrate the effectiveness of the $\mathsf{capeFM}$ algorithm using a distributed linear regression problem. We present experimental results to show empirical comparison of performance of the proposed $\mathsf{capeFM}$ with the existing $\mathsf{dp-fm}$~\cite{zhang2012}, objective perturbation $(\mathsf{objPert})$~\cite{anand2011} and non-private linear regression $(\mathsf{Non-priv.})$ on pooled-data. Note that both $\mathsf{dp-fm}$ and $\mathsf{objPert}$ offer the stronger $\epsilon$-DP and are applied to the pooled-data scenario. We also included the performance variation of a conventional DP distributed scheme with no correlated noise $(\mathsf{conv})$ and a DP linear regression on local (single site) data $(\mathsf{local})$. For both the neural network based classifier and the linear regression problem, we consider the symmetric setting (i.e., $N_s = \frac{N}{S}$ and $\tau_s = \tau$) and show the average performance over 10 independent runs. \subsection{Distributed Neural Network-based Classifier}\label{sec:exp_dist_nn} \begin{figure*}[t] \centering \includegraphics[width=1\textwidth]{images/all_vs_nn.pdf}\\ \vspace{-0.0in} \caption{Variation of performance of NN based classifier on synthetic data: (a)--(b) with $\epsilon$ per iteration; (c)--(d) with $N$. Fixed parameter: $S = 4$.} \label{fig:all_vs_nn} \end{figure*} We evaluate the performance of the proposed $\mathsf{CAPE}$ scheme on a neural network based classifier to classify between the two classes on a synthetic dataset. The samples from the two classes are random Gaussian vectors with unit variance and the means are separated by 1. We have the same distributed setup as mentioned before: data samples are distributed across $S$ sites. Let $\mathbf{X}_s \in \mathbb{R}^{D \times N_s}$ be the sample matrix at site $s$ with $N_s$ samples in $D$ dimensions. Let $\mathbf{y}_s \in \{0, 1\}^{N_s}$ contain the labels for each sample. The global sample matrix and labels vector are given as $\mathbf{X} = \left[\mathbf{X}_1, \ldots, \mathbf{X}_S\right] \in \mathbb{R}^{D\times N}$ and $\mathbf{y} = \left[\mathbf{y}_1^\top, \ldots, \mathbf{y}_S^\top\right]^\top \in \mathbb{R}^N$, where $N = \sum_{s=1}^S N_s$. We consider an $L = 2$ layer neural network and $D=50$, $N = 10k$, $S = 4$. The number of units in layer $l \in \{0, 1, \ldots, L\}$ is denoted by $D^{[l]}$ with $D^{[0]} = D$. We use Rectified Linear Unit (ReLU) activation in the hidden layer and sigmoid activation in the output layer. Our goal is to find the following parameters of the neural network: $\mathbf{W}^{[1]} \in \mathbb{R}^{D^{[1]} \times D^{[0]}}$, $\mathbf{b}^{[1]} \in \mathbb{R}^{D^{[1]}}$, $\mathbf{W}^{[2]} \in \mathbb{R}^{D^{[2]} \times D^{[1]}}$ and $\mathbf{b}^{[2]}\in \mathbb{R}^{D^{[2]}}$, such that $\texttt{round}\left(\hat{\mathbf{y}}\right)$ gives the labels of the samples with minimum deviation from $\mathbf{y}$, where $\hat{\mathbf{y}} = \texttt{sigmoid}\left(\mathbf{W}^{[2]}\mathbf{A}^{[1]} + \mathbf{b}^{[2]}\right) \mbox{ and } \mathbf{A}^{[1]} = \texttt{ReLU}\left(\mathbf{W}^{[1]}\mathbf{X} + \mathbf{b}^{[1]}\right)$. We use distributed gradient descent to minimize the empirical average cross-entropy loss. The cross-entropy loss for the $n$-th sample $\mathbf{x}_n$ is: \begin{align}\label{eqn:xentropy_loss} l(\hat{y}_n, y_n) &= -y_n\log \hat{y}_n - (1-y_n)\log(1-\hat{y}_n). \end{align} Each site evaluates the gradients on the local data and sends privacy-preserving approximates of the gradients to the aggregator according to a $\mathsf{Non-priv.}$, $\mathsf{CAPE}$ or $\mathsf{conv}$ schemes. The aggregator then combines the gradient contributions and updates the parameters. For $\mathsf{CAPE}$, we set $\tau_s = \frac{\Delta}{\epsilon}\sqrt{2\log \frac{1.25}{0.01}}$ for all experiments, where $\Delta$ is the $\mathcal{L}_2$ sensitivity of the corresponding gradient. To measure the utility of the estimated parameters, we use the percent accuracy $\mathrm{acc} = \frac{1}{N_{test}} \sum_{n = 1}^{N_{test}} \mathcal{I}\left(\texttt{round}(\hat{\mathbf{y}}_{test, n}) = \mathbf{y}_{test, n}\right) \times 100$, where $\mathcal{I}(\cdot)$ is the indicator function and $\texttt{round}\left(\mathbf{y}_{test}\right) \in \mathbb{R}^{N_{test}}$ contains the labels of the test-set samples. \noindent\textbf{Performance Variation with $\epsilon$ and $N$. }We consider the privacy-utility tradeoff first. In Figure \ref{fig:all_vs_nn}(a)--(b), we show the variation of $\mathrm{acc}$ with $\epsilon$ per iteration on the train and test sets for the synthetic dataset, while keeping $N$ and $S$ fixed. We observe that both of the privacy preserving algorithms: $\mathsf{CAPE}$ and $\mathsf{conv}$, perform better as we increase $\epsilon$. The proposed $\mathsf{CAPE}$ algorithm performs better than $\mathsf{conv}$ and reaches the performance of $\mathsf{Non-priv.}$ even for moderate $\epsilon$ values. Next, we consider the variation of $\mathrm{acc}$ with total sample size $N$, while keeping $\epsilon$ per iteration and $S$ fixed. In Figure \ref{fig:all_vs_nn}(c)--(d), we show the variation of $\mathrm{acc}$ on the train and test sets. As in the case of varying $\epsilon$, we observe that increasing $N$ (hence increasing $N_s$) improves $\mathrm{acc}$ for the privacy-preserving algorithms. We recall that the variance of the noise added for privacy is inversely proportional to $N^2$ -- therefore, availability of more samples results in better accuracy for the same privacy level. Again, we observe that the proposed $\mathsf{CAPE}$ algorithm outperforms the $\mathsf{conv}$ algorithm. However, when $N$ is quite small, the performance gap between $\mathsf{CAPE}$ and $\mathsf{conv}$ is less pronounced. In practice, we observe that the gradient descent converges much faster under $\mathsf{CAPE}$ than the $\mathsf{conv}$, matching the performance of $\mathsf{Non-priv.}$ This can be explained by recalling the fact that the $\mathsf{CAPE}$ algorithm offers the benefit of much less additive noise at the aggregator. \subsection{Distributed Linear Regression}\label{sec:exp_dist_lr} \begin{figure*}[t] \centering \includegraphics[width=1\textwidth]{images/loss_vs_synth_new.pdf}\\ \vspace{-0.0in} \caption{Variation of loss $f_D(\mathbf{w})$ at $\mathbf{w}^*$ for synthetic datasets. (a)--(b): with $\epsilon$. (c)--(d): with total samples $N$. (e)--(f): with $\delta$. Fixed param.: $S = 5$.} \vspace{-0.0in} \label{fig:loss_vs_all_synth} \end{figure*} \begin{figure*}[t] \centering \includegraphics[width=1\textwidth]{images/loss_vs_real_new.pdf}\\ \vspace{-0.0in} \caption{Variation of loss $f_D(\mathbf{w})$ at $\mathbf{w}^*$ for two real datasets. (a)--(b): with $\epsilon$. (c)--(d): with total samples $N$. (e)--(f): with $\delta$. Fixed param.: $S = 5$.} \vspace{-0.1in} \label{fig:loss_vs_all_real} \end{figure*} To demonstrate the effectiveness of $\mathsf{capeFM}$, we performed experiments on three datasets: a \textit{synthetic} dataset ($D = 20$ or $D = 50$) (Synth) generated with a random $\mathbf{w}^*$ and random samples $\mathbf{X}$, the \textit{Communities and Crime} dataset ($D = 101$)~\cite{Lichman:2013} (Crime) and the \textit{Buzz in social media} dataset ($D = 77$)~\cite{Lichman:2013} (Twitter). We refer the reader to~\cite{Lichman:2013} for a detailed description of these real datasets. Now, for each of the datasets, we normalized each feature across the samples to ensure that each feature lies in the range $[-1, 1]$. We also normalized the samples with the maximum $\mathcal{L}_2$ norm in each dataset to ensure $\|\mathbf{x}_n\|_2 \le 1 \ \ \forall n$. This preprocessing step is not differentially private but can be modified to satisfy privacy at the cost of some utility. For $\mathsf{capeFM}$, we set $\tau_j^s = \frac{\Delta_j^s}{\epsilon}\sqrt{2\log \frac{1.25}{10^{-5}}}$ for experiments on the synthetic datasets and $\tau_j^s = \frac{\Delta_j^s}{\epsilon}\sqrt{2\log \frac{1.25}{10^{-3}}}$ for experiments on the real datasets, where $\Delta_j^s$ is the $\mathcal{L}_2$ sensitivity of the corresponding $\Lambda_j$. We use two performance indices for the synthetic dataset. The first one is the empirical loss \begin{align} f_D(\mathbf{w}) &= \frac{1}{N}\|\mathbf{y} - \mathbf{X}\mathbf{w}\|_2^2, \end{align} where $\mathbf{X}$ and $\mathbf{y}$ contains all data tuples $(\mathbf{X}_s, \mathbf{y}_s)$ from $s \in [S]$. We compute $f_D(\mathbf{w})$ at the final $\mathbf{w}$, which is found from minimizing the output function of the algorithm. The second one is closeness to the true $\mathbf{w}^*$. If the final $\mathbf{w}$ achieved by minimizing the output function of the algorithm is denoted by $\hat{\mathbf{w}}^*$ then we define: $\mathrm{err}_w = \frac{1}{D} \|\mathbf{w}^* - \hat{\mathbf{w}}^*\|_2$. As the true $\mathbf{w}^*$ is unknown for the real datasets, we only use $f_D(\mathbf{w})$ as the performance index for Crime and Twitter datasets. The variation of $\mathrm{err}_w$ with several parameters on synthetic datasets is shown in Figure~\ref{fig:err_vs_all_synth} in Appendix~\ref{appendix:err_vs_all_synth} in the Supplement. \noindent\textbf{Dependence on Privacy Parameter $\epsilon$. }First, we explore the trade-off between privacy and utility. We note that, as we employ the Gaussian mechanism, the standard deviation of the added noise is inversely proportional to $\epsilon$ -- bigger $\epsilon$ means higher privacy risk but less noise and thus, better utility. We observe this in our experiments as well. In Figure \ref{fig:loss_vs_all_synth}(a)--(b), we show the variation of $f_D(\mathbf{w})$ of different algorithms for different values of $\epsilon$ on synthetic data. For this experiment, we kept the number of total samples $N$ and the number of sites $S$ fixed. We show the plots for two different feature dimensions: $D=20$ and $D=50$. For both of the synthetic datasets, we observe that as $\epsilon$ increases (higher privacy risk), the loss $f_D(\mathbf{w})$ decreases. The proposed $\mathsf{capeFM}$ reaches very small $f_D(\mathbf{w})$ for some parameter choices and clearly outperforms the $\mathsf{dp-fm}$, $\mathsf{objPert}$, $\mathsf{conv}$ and $\mathsf{local}$. One of the reasons that $\mathsf{capeFM}$ outperforms $\mathsf{conv}$ is the smaller noise variance at the aggregator that we can achieve due to the correlated noise scheme. Moreover, $\mathsf{capeFM}$ outperforms $\mathsf{dp-fm}$ because $\mathsf{dp-fm}$ suffers from a much larger variance at the aggregator (due to the conservative sensitivity computation of $\lambda_{n\phi}$). On the other hand, $\mathsf{objPert}$ also entails addition of noise with large variance as the sensitivity of the optimal $\mathbf{w}^*$ is large (to be exact, the sensitivity is 2). Achieving better performance than $\mathsf{local}$ is intuitive because including the information from multiple sites to estimate a population parameter always results in better performance than using the data from a single site only. Additionally, we observe that for datasets with lower dimensional samples, we can use smaller $\epsilon$ (i.e., to guarantee lower privacy risk) for the same utility. In Figure \ref{fig:loss_vs_all_real}(a)--(b), we show the variation of $f_D(\mathbf{w})$ with $\epsilon$ for the Crime and the Twitter datasets. We observe similar variation characteristic of $f_D(\mathbf{w})$ for the real datasets as we observed for the synthetic datasets. Note that, for real datasets, we chose larger $\tau_s$ values than synthetic datasets to achieve the similar utility. \noindent\textbf{Dependence on Total Sample Size $N$. }Next, we investigate the variation in performance with the total sample size $N$. Intuitively, it should be easier to guarantee smaller privacy risk $\epsilon$ and higher utility, when $N$ is large. Figure \ref{fig:loss_vs_all_synth}(c)--(d) show how $f_D(\mathbf{w})$ decreases as a function of $N$ on synthetic data. The variation with $N$ reinforces the results seen earlier with variation of $\epsilon$. For a fixed $\epsilon$ and $S$, the $f_D(\mathbf{w})$ decreases as we increase $N$. For sufficiently large $N$ and $\epsilon$, $f_D(\mathbf{w})$ will reach that of the non-private pooled case $(\mathsf{Non-priv.})$. We observe a sharper decrease in $f_D(\mathbf{w})$ for lower-dimensional datasets. In Figure \ref{fig:loss_vs_all_real}(c)--(d), we show the variation of $f_D(\mathbf{w})$ with $N$ for the Crime and the Twitter datasets. Again, we observe similar variation of $f_D(\mathbf{w})$ for the real datasets as we observed for the synthetic datasets. \noindent\textbf{Dependence on Privacy Parameter $\delta$. }Note that, the proposed $\mathsf{capeFM}$ algorithm guarantees $(\epsilon, \delta)$ differential privacy where $(\epsilon, \delta)$ satisfy the relation $\delta = 2\frac{\sigma_z}{\epsilon - \mu_z}\phi\left(\frac{\epsilon - \mu_z}{\sigma_z}\right)$. Recall that $\delta$ can be considered as the probability that the algorithm releases the private information without guaranteeing privacy. Therefore, we want this to be as small as possible. However, smaller $\delta$ also dictates larger noise variance. We explore the variation of performance with different $\delta$ with a fixed number of colluding sites $S_C = \ceil*{\frac{S}{3}} - 1$. In Figure \ref{fig:loss_vs_all_synth}(e)--(f), we show how $f_D(\mathbf{w})$ varies with varying $\delta$ on synthetic data. We observe that if $N$ and $\delta$ are too small, the proposed $\mathsf{capeFM}$, $\mathsf{conv}$ and $\mathsf{local}$ algorithms perform poorly. However, our $\mathsf{capeFM}$ algorithm can achieve very good utility for moderate $N$ and $\delta$ values, easily outperforming the other DP algorithms. We observe in Figure \ref{fig:loss_vs_all_real}(e)--(f) similar characteristic for the two real datasets, although the variation of $f_D(\mathbf{w})$ is not as pronounced as for the synthetic datasets. Recall that the $\mathsf{dp-fm}$ and the $\mathsf{objPert}$ algorithms offer pure $\epsilon$-DP guarantee and, therefore, do not vary with $\delta$. \section{Conclusions}\label{sec:conclusion} This paper proposes a novel protocol, $\mathsf{CAPE}$, for distributed differentially private computations. $\mathsf{CAPE}$ is best suited for applications in which private data must be held locally, e.g. in health care research with legal and ethical limitations on the degree of sharing the ``raw'' data. $\mathsf{CAPE}$ can greatly improve the privacy-utility tradeoff when (a) all parties follow the protocol and (b) the number of colluding sites is not more than $\ceil*{S/3} - 1$. Our proposed $\mathsf{CAPE}$ protocol is based on an estimation-theoretic analysis of the noise addition process for differential privacy and therefore, provides different guarantees than cryptographic approaches such as SMC. In addition to $\mathsf{CAPE}$, we proposed a new algorithm for differentially private computation of functions in distributed settings. Our $\mathsf{capeFM}$ algorithm can be employed to compute any continuous and differentiable function. As mentioned before, approximation of the empirical average cost is required in many distributed optimization problems. We proposed an improved functional mechanism with a new way to compute the associated sensitivities. We analytically showed that the proposed approach for computing the sensitivities offers much less additive noise for two common regression problems -- linear regression and logistic regression. Our proposed $\mathsf{capeFM}$ can approximate the privacy-preserving empirical average cost such that we can achieve the same utility level as the pooled data scenario in certain regimes. We achieve this by employing the $\mathsf{CAPE}$ protocol. We empirically compared the performance of the proposed algorithms with those of existing and conventional algorithms for a neural-network based classification problem and a distributed linear regression problem. We varied privacy parameters and relevant dataset (synthetic and real) parameters and showed that the proposed algorithms outperformed the existing and conventional algorithms comfortably -- matching the performance of the non-private algorithm for some parameter choices. In general, the proposed algorithms offered very good utility indicating that meaningful privacy can be attained without losing much performance by the virtue of algorithm design. A very interesting future work could be to extend the $\mathsf{CAPE}$ framework to fit the optimal Staircase Mechanism~\cite{geng2015} for differential privacy. Another possible direction is to extend $\mathsf{CAPE}$ to be employable in arbitrary tree-structured networks. \section*{Acknowledgements} The work of the authors was supported by the the NIH under award 1R01DA040487-01A1, the NSF under award CCF-1453432, and by DARPA and SSC Pacific under contract No. N66001-15-C-4070.
{'timestamp': '2021-02-24T02:09:16', 'yymm': '1904', 'arxiv_id': '1904.10059', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.10059'}
arxiv
\section{Introduction} In a well-known paper \cite{Gandy}, Gandy sets out principles which aim to characterize the possible behaviours of a discrete, deterministic mechanical computing device which could be realized in the physical world. Although in Gandy's detailed axiomatization there are four principles, they can be summarized by two conceptual insights (as emphasized by, for instance, \cite{ArrighiCausalGraphs,SiegAbstractParallel}): first, that states of computation should be finite objects with a bounded amount of local detail; second, that changes should only propagate with a bounded velocity, and thus their effects on a given location should be determined by a neighbourhood of finite size. Gandy's technical realization of these principles uses axioms which are set-theoretic in nature, the idea being that every mathematical description of a computing machine ought to correspond to a set-theoretical one. As long as this is done sensibly, and the original model satisfies Gandy's conceptual principles, the resulting formalization will satisfy Gandy's axioms. Although some later studies keep within this set-theoretic framework \cite{SiegAbstractParallel}, other work inspired by Gandy's principles replaces his arbitrary hereditarily finite sets with mathematical objects for which one has more direct spatial intuitions, such as graphs \cite{ArrighiCausalGraphs,ObtulowiczGPRmachines,SiegKgraphs} or simplicial surfaces \cite{ArrighiCausalSurfaces}. Indeed, when one has a concrete model of computation in mind, it is often easier to conduct detailed investigations into the operation of Gandy's principles by working with the models directly, in an environment which respects their extra structure, rather than their set-theoretic encodings. In many of these models the dynamics are given in terms of a colimit of updated versions of certain neighbourhoods of a state. This is explicit in \cite{Maignan,ObtulowiczGPRmachines}, and suggested by the use of unions in \cite{ArrighiCausalGraphs,ArrighiCausalSurfaces}. In \cite{Maignan} the colimit to be taken is strikingly similar to the one implied by Proposition 1 of this paper. It is interesting that two quite different intuitions about the meaning of local determinism lead naturally to some of the same categorical structures. Indeed, if one heuristically reads Gandy's notion of restriction of a state to a part of a state as analogous to a set of morphisms, then Gandy's own description strongly suggests a colimit. This is evidence that the ambient categorical structure can play an explanatory role. Rather than describing specific categories whose objects can serve as states of computation, one might ask what kinds of category could serve as a setting for Gandy-like models. We know that objects like graphs and simplicial complexes are characterized by being colimits of a set of generating objects. We might wonder whether the colimit description of the dynamics follows from this, given some more direct axiomatization of local determinism. In this paper, we attempt to give just such a description of a class of categories suitable for describing states of computation in the style of Gandy, along with a categorical description of locally deterministic dynamics. We came to this axiomatization in an attempt to better understand the phenomena of information flow in cellular automata as described in the first author's thesis \cite{RazaviPhdThesis}. For this purpose, they seem to be useful for getting at the relevant aspects of the causal structure, and we hope, therefore, that they may be of use to workers engaged in similar enquiry. \section{Preliminaries: Comma Categories and Kan Extensions} In this section we briefly sketch some category theoretic background, loosely following \cite{LehnerKanExtensions,StreetFibrationsYoneda}; the reader interested in a more comprehensive overview of category theory is directed to \cite{MaclaneCategoriesWork}. In order to talk about things happening locally, as is required to model Gandy's ideas, it is useful to think of a morphism $\fctl{p}{A}{X}$ in $\cat{C}$ as a `shape $A$ located at position $p$ in $X$'. More generally, one often wants to restrict attention to the case where the source and target of the morphisms are the output of two functors $\fctl{F}{\cat{X}}{\cat{C}}$ and $\fctl{G}{\cat{Y}}{\cat{C}}$. In this paper, we study such morphisms in the standard setting: the \definiendum{comma category}~$\commaCat{F}{G}$. The objects of $\commaCat{F}{G}$ are triples $(X,p,Y)$ where $X$ is an object of $\cat{X}$, $Y$ is an object of $\cat{Y}$, and $\fctl{p}{FX}{GY}$ in~$\cat{C}$. A morphism from $(X,p,Y)$ to $(X',p',Y')$ is a pair $(f,g)$ such that~$Gg\mathbin{\circ} p=p'\mathbin{\circ} Ff$. We may think of such an equation as telling us that the way the shape $FX$ is located at position $p$ in $GY$ is compatible with that of $FX'$ at $p'$ in $GY'$ via $Ff$ and $Gg$. The definition of objects of the comma category as triples allows us to define two functors, \(\commaDomain\) and \(\commaCodomain\), to \(\cat{X}\) and \(\cat{Y}\) respectively, by projecting onto the first and last components. The morphisms in the middle components of these triples assemble themselves into a natural transformation \[ \begin{tikzcd}[row sep=small] \commaCat{F}{G}\arrow{r}{\commaDomain}\arrow[swap]{d}{\commaCodomain} & \cat{X}\arrow{d}{F} \arrow[Rightarrow, shorten <= 2ex, shorten >= 4ex,pos=0.3]{ld}{\commaArrowTrans} \\ \cat{Y}\arrow[swap]{r}{G}& \cat{C}, \end{tikzcd} \] and this square has a universal property which defines the comma category up to isomorphism. When giving a comma category, if we have a subcategory $\cat{G}$ of $\cat{C}$, we often write $\cat{G}$ to mean its inclusion into $\cat{C}$, writing for example $\commaCat{\cat{G}}{\cat{C}}$ to mean the comma category from the inclusion of $\cat{G}$ to the identity on $\cat{C}$. Similarly, if $A$ is an object of $\cat{C}$, we may write $A$ to mean the constant functor from the one-object category to $A$. As a first approximation, one can think of a comma category $\commaCat{F}{G}$ as a sort of asymmetric pullback, asking not what $F$ and $G$ have in common, but what the result of probing $G$ with $F$ is. Certain properties are then unsurprising. The domain and codomain functors on $\commaCat{\cat{C}}{\cat{C}}$ both have a section, given by sending each object to its identity morphism. Moreover, if $F$ has a section, then so does the codomain functor of~$\commaCat{F}{G}$. In the introduction, we mentioned that in many examples we encounter functors which can be calculated by colimits. This may indicate the presence of a Kan extension, which is defined as follows. Suppose we have functors $\fctl{F}{\cat{X}}{\cat{D}}$ and $\fctl{G}{\cat{X}}{\cat{C}}$. A \definiendum{(left) Kan extension} of $G$ along $F$ is a functor $\fctl{L}{\cat{D}}{\cat{C}}$ equipped with a natural transformation $\fctl{\kappa}{G}{L \mathbin{\circ} F}$ which is universal in the sense that for every $\fctl{K}{\cat{D}}{\cat{C}}$ with $\fctl{\alpha}{G}{K \mathbin{\circ} F}$ there exists a unique mediator $\fctl{\mu}{L}{K}$ such that $\alpha$ is equal to the pasting \[ \begin{tikzcd}[row sep=small] \cat{X} \arrow{r}{G} \arrow{d}{F} & \cat{C}\arrow[equal]{d}\arrow[Rightarrow, shorten <= 1.7ex, shorten >=3ex,pos=0.3]{ld}{\kappa}\\ \cat{D}\arrow{r}{L}\arrow[equal]{d} &\cat{C}\arrow[equal]{d}\arrow[Rightarrow, shorten <= 1.7ex, shorten >= 3ex,pos=0.3]{ld}{\mu}\\ \cat{D}\arrow[swap]{r}{K} &\cat{C}. \end{tikzcd} \] On first encountering the definition, it is common to wonder whether when $G = L\mathbin{\circ} F$, the identity transformation exhibits L as a Kan extension. One soon realizes, however, that far away from the image of $F$, the values of $L$ may have little to do with $G$; this will preclude having the universal property. A natural thing to demand to improve this situation is that $F$ have a section; one easily verifies that in this case every functor that post-composes with $F$ to give $G$ is a Kan extension of the latter along the former. We are interested in Kan extensions with additional properties. A (left) Kan extension $L$ of $G$ along $F$ as below is called \definiendum{absolute} if for all $\fctl{H}{\cat{C}}{\cat{E}}$ the pasting \[ \begin{tikzcd}[row sep=small] \cat{X}\arrow[swap]{d}{F}\arrow{r}{G} &\cat{C}\arrow[equal]{d} \arrow{r}{H}\arrow[Rightarrow, shorten <= 1.5ex, shorten >=3ex,pos=0.3]{ld}{\kappa} &\cat{E}\arrow[equal]{d}\\ \cat{D}\arrow[swap]{r}{L} &\cat{C}\arrow{r}{H} &\cat{E} \end{tikzcd} \] is a Kan extension. This means that having a Kan extension for $G$ gives us a Kan extension for any composite of~$G$. For example, suppose $\fctl{F}{\cat{C}}{\cat{D}}$, $\fctl{U}{\cat{D}}{\cat{C}}$ with a natural transformation $\fctl{\eta}{1_{\cat{C}}}{U \mathbin{\circ} F}$. Then $\eta$ is the unit of an adjunction with left adjoint $F$ and right adjoint $U$ if and only if it exhibits $U$ as the Kan extension of the identity along $F$ and this extension is absolute. A Kan extension $L$ of $G$ along $F$ as above is called \definiendum{pointwise} if whenever we have a functor $\fctl{J}{\cat{Y}}{\cat{D}}$ and we consider the comma category $\commaCat{F}{J}$, the pasting \[ \begin{tikzcd}[row sep=small] \commaCat{F}{J} \arrow[swap]{d}{\commaCodomain}\arrow{r}{\commaDomain} & \cat{X} \arrow{d}{F}\arrow{r}{G}\arrow[Rightarrow, shorten <= 1.5ex, shorten >=4ex,pos=0.3]{ld}{\commaArrowTrans} & \cat{C}\arrow[equal]{d}\arrow[Rightarrow, shorten <= 1.5ex, shorten >=3ex,pos=0.3]{ld}{\kappa} \\ \cat{Y}\arrow{r}{J}&\cat{D}\arrow{r}{L} &\cat{C} \end{tikzcd} \] is a Kan extension. We can think of a pointwise Kan extension as being `locally a Kan extension' in that whenever we `probe' $L$ with a functor $J$ as above, we still get a Kan extension. One reason pointwise Kan extensions are useful is that for any object $D$ of $\cat{D}$ we can compute $LD$ as the colimit of the functor given by precomposing $G$ with $\fctl{\operatorname{dom}}{\commaCat{F}{D}}{\cat{X}}$, which means that if we take the big diagram with one copy of each object $X$ of $\cat{X}$ for every morphism from $\fromto{FX}{D}$, and arrows between them making commuting triangles, then $D$ is the colimit. One family of examples is given by the fact that every absolute Kan extension is pointwise. Another example which one frequently encounters is the idea of a \definiendum{dense subcategory}. A subcategory $\cat{G}$ of $\cat{C}$ is called \definiendum{dense} if and only if the identity on $\cat{C}$ is the pointwise Kan extension of the inclusion of $\cat{G}$ into $\cat{C}$ along itself, meaning that every object of $\cat{C}$ is the colimit of all ways of mapping objects of $\cat{G}$ into it. We think of objects in $\cat{C}$ as regions generated by the shapes in the dense subcategory~$\cat{G}$. In the sequel, this is used to capture the notion of `finite detail'. Since every morphism out of a colimit is uniquely determined by suitable morphisms out of the constituent parts this also characterizes the morphisms in $\cat{C}$, which are determined by the way they act on morphisms out of $\cat{G}$ by postcomposition. Similar reasoning shows that the domain of every object of $\commaCat{\cat{C}}{\cat{C}}$ is the colimit of all the domains of morphisms of $\commaCat{\cat{G}}{\cat{C}}$ into it (to see that one does not end up with spurious extra copies of objects of $\cat{G}$, the important observation is that every morphism in $\commaCat{\cat{C}}{\cat{C}}$ factors as a morphism with an identity of $\cat{C}$ in its domain, followed by one with an identity of $\cat{C}$ in its codomain). This implies that the identity natural transformation corresponding to the commuting diagram \[ \begin{tikzcd}[row sep=small] \commaCat{\cat{G}}{\cat{C}} \arrow[hookrightarrow]{r}\arrow[hookrightarrow]{d} &\commaCat{\cat{C}}{\cat{C}} \arrow[equal]{d}\arrow{r}{\commaDomain} &\cat{C}\arrow[equal]{d}\\ \commaCat{\cat{C}}{\cat{C}}\arrow[equal]{r} &\commaCat{\cat{C}}{\cat{C}}\arrow{r}{\commaDomain} &\cat{C} \end{tikzcd} \] is a pointwise Kan extension. The codomains of morphisms play little role in this argument, and indeed one can replace $\commaCat{\cat{G}}{\cat{C}}$ and $\commaCat{\cat{C}}{\cat{C}}$ in the above with $\commaCat{\cat{G}}{U}$ and $\commaCat{\cat{G}}{U}$ respectively, for any functor $U$ into $\cat{C}$. Kan extensions enjoy the property that if one vertically composes a collection of Kan extension squares, the result is again a Kan extension. Moreover, if every component of the pasting is absolute or pointwise, so is the result. \section{Finite Objects and Local Determinism} Suppose one has in mind a collection of spatially extended states, and incomplete parts of states, for a `mechanical' model of computation, along with a notion for how the various parts fit together to form larger parts and complete states. These constitute a category $\cat{C}$. Following Gandy, we stipulate that, if the model is to be truly mechanical, these states must be finitely big and have a finite amount of possible local detail. Let us first consider the restriction on $\cat{C}$ corresponding to the objects being `finitely big'. Given two finite combinatorial objects, we expect that the number of ways in which one fits into the other to be finite. This means that all hom-sets in $\cat{C}$ should be finite; one says that $\cat{C}$ is `locally finite'. Only slightly more subtle is the issue of finite local detail. The idea is that there should be a finite set of objects such that any object $X$ is determined by the ways in which these objects map into $X$. This is exactly the condition described above for a dense sub-category, so this is the notion we use here. One example of a locally finite category with a finite dense subcategory is the category of finite graphs: there are finitely many graph homomorphisms between any two graphs, and every graph can be constructed as a colimit of nodes and edges. This is, however, a somewhat unnatural example for our purposes, since allowing nodes of arbitrarily high degree means that the notion of `locally finitely detailed' can not mean `locally' in the usual sense for graphs. It is more natural to take graphs with a fixed bound on the degree. Another example, which we return to below, is the category $\mathord{\mathsf{Tape}}$ whose objects are strings over the alphabet $\{\blacksquare,\square\}$, and where a morphism from $A$ to $B$ is a position in $B$ at which $A$ occurs as a substring. For example, there are two morphisms from $\mathord{\blacksquare\kern-0.1em\square\kern-0.02em\kern-0.072em\blacksquare\cellb}$ to $\mathord{\blacksquare\kern-0.1em\square\kern-0.02em\kern-0.072em\blacksquare\cellb\kern-0.1em\square\kern-0.02em\kern-0.072em\blacksquare\cellb}$, since it occurs at positions $0$ and $3$. For technical reasons, it is useful to assume that the empty string is an initial object, occurring just once in every string. The full subcategory on the objects $\{\blacksquare,\square,\blacksquare\kern-0.072em\blacksquare,\blacksquare\kern-0.1em\square\kern-0.02em,\square\kern-0.072em\blacksquare,\square\kern-0.1em\square\kern-0.02em\}$ is dense, because any string is determined by knowing its consecutive pairs of letters, and which pairs share individual letters. In a similar vein, one might think of objects made of a finite number of tiles (even of, say, a Penrose tiling), generated by gluing together neighbourhoods where they share tiles. The issue of local determinism is more interesting. First, we suppose that the way in which states are updated by the dynamics is given by a functor $\fctl{U}{\cat{C}}{\cat{C}}$. Functoriality is a reasonable requirement, meaning that the updated versions of the parts of a state should fit together in the updated version of that state. It loosely corresponds to Gandy's idea that the update function in his model should be `structural', able only to observe the way atomic parts of the state fit together, not the names we have given them. As an example, let us consider the one dimensional cellular automaton on the alphabet $\{\blacksquare,\square\}$ in which a white cell becomes black if any of its neighbours is black. We can model this as a functor $\fctl{U}{\mathord{\mathsf{Tape}}}{\mathord{\mathsf{Tape}}}$ which removes the two outer cells in a string (returning the empty string if there are too few cells) and updates those in the middle according to the rule. For example $U(\mathord{\blacksquare\kern-0.1em\square\kern-0.02em\cellw\kern-0.1em\square\kern-0.02em\kern-0.072em\blacksquare\kern-0.1em\square\kern-0.02em}) = \mathord{\blacksquare\kern-0.1em\square\kern-0.02em\kern-0.072em\blacksquare\cellb}$ Functoriality of $U$ corresponds roughly to the fact that the update can not make use of, for example, the position of a cell in the sequence to determine its new colour. Now we come to local determinism itself. Suppose we update a state, and then look at a part of the updated situation. This amounts to considering a map $\fctl{p}{A}{UX}$ for some $A$ and $X$ in $\cat{C}$. We want to remember the state $X$ we are updating, so it is best to consider $p$ as an object of $\commaCat{\cat{C}}{U}$. Since we postulate that the action of $U$ is locally deterministic, this local effect must have had some local cause $\fctl{f}{N}{Y}$, for some $N$ and $Y$ in $\cat{C}$, which explains why $p$ occurs in $UX$ in the following sense. If we update $f$ to get $\fctl{Uf}{UN}{U}Y$, we should find $p$ inside the result via a morphism $\fctl{\eta}{p}{Uf}$ in $\commaCat{\cat{C}}{U}$. Because of the way the comma category is defined, this implies that there is a morphism $\fctl{\operatorname{cod}(\eta)}{X}{Y}$ in $\cat{C}$. We think of $f$ as a `causal neighbourhood' of $p$. Although we could, if we wished, choose any causal neighbourhood, it is best to choose one which comes with a reasoning principle. Since we are supposing that `changes propagate with a bounded velocity', there ought to be a minimal causal neighbourhood such that any sequence of changes which could have contributed to the updated state $p$ must have passed into it. This amounts to saying that for every other causal neighbourhood, that is for every $\fctl{g}{M}{Z}$ in $\cat{C}$ with a morphism $\fctl{\gamma}{p}{Ug}$ in $\commaCat{\cat{C}}{U}$, there is a unique $\fctl{\hat{\gamma}}{f}{g}$ in $\commaCat{\cat{C}}{\cat{C}}$ such that $\gamma = U\hat{\gamma} \mathbin{\circ} \eta$. Since we want this assignment of a causal neighbourhood to vary naturally as we vary $p$, it amounts to an adjunction; but an adjunction where? The simplest option is to consider the functor $\fctl{\commaLift{U}}{\commaCat{\cat{C}}{\cat{C}}}{\commaCat{\cat{C}}{U}}$ which takes an object $(X,\fctl{f}{X}{Y},Y)$ of $\commaCat{\cat{C}}{\cat{C}}$ to $(UX,Uf,Y)$ in $\commaCat{\cat{C}}{U}$. Note that the target component $Y$ is unchanged. It is for this functor that we demand a left adjoint, say $\localAdjoint{F}$. What does this all mean in our example? Consider the occurrence of $\mathord{\blacksquare\kern-0.072em\blacksquare}$ at position $2$ in $\mathord{\blacksquare\kern-0.1em\square\kern-0.02em\kern-0.072em\blacksquare\cellb}$. We must find a causal neighbourhood which explains why it occurs. We choose the occurrence of $\square\kern-0.1em\square\kern-0.02em\kern-0.072em\blacksquare\kern-0.1em\square\kern-0.02em$ at the end of $\mathord{\blacksquare\kern-0.1em\square\kern-0.02em\cellw\kern-0.1em\square\kern-0.02em\kern-0.072em\blacksquare\kern-0.1em\square\kern-0.02em}$. This updates precisely to the part we wanted, and it must be the universal explanation since anything smaller would only be updated to a single cell. Now the reader may be troubled by a subtle point: one might have expected that the explanation for the above should be the occurrence of $\mathord{\square\kern-0.072em\blacksquare}$ at position $3$ in the input, since we know intuitively that its left-hand square will turn black. If we had defined $U$ to make use of this knowledge, however, then we could not have defined $\localAdjoint{F}$ in a functorial manner, since we would have had $U(\mathord{\blacksquare\kern-0.1em\square\kern-0.02em\kern-0.072em\blacksquare}) = \mathord{\blacksquare\kern-0.072em\blacksquare\cellb}$. But then the middle $\blacksquare$ could be explained just as well by $\blacksquare\kern-0.1em\square\kern-0.02em$ on the left as by $\square\kern-0.072em\blacksquare$ on the right. This is why we think in terms of neighbourhoods through which \emph{all} causal influences on an updated part must have passed. This issue is related to the problem of `overdetermination' familiar to philosophers (see e.g. \cite{SchafferOverdetermination}). To enforce the bounded speed of propagation, we need to stipulate that $\localAdjoint{F}$ have a certain finiteness property. For any given object $A$, there are many possible shapes of causal neighbourhood for parts of shape $A$, depending on the context in which we find them. However, since there is a bound on the size of these, and there can only be finitely many objects of this size, we know that any part $\fctl{p}{A}{UX}$ has only finitely many different shapes of possible causal neighbourhoods. Therefore we demand whenever we have a subcategory $\cat{S}$ of $\commaCat{\cat{C}}{U}$ whose image under the domain functor, $\operatorname{dom}[\cat{S}]$, is finite, the domain of its image under $\localAdjoint{{F}}$, which is $(\operatorname{dom} \mathbin{\circ} \localAdjoint{F})[\cat{S}]$, is also finite. In our example, consider all morphisms out of the object $\blacksquare$ into outputs of $U$. Although this is an infinite set of morphisms (because there are an infinite number of strings containing $\blacksquare$), each of these occurrences is explained by a substring in the input of one of the forms $\mathord{\blacksquare\kern-0.072em\blacksquare\cellb}$, $\mathord{\blacksquare\kern-0.072em\blacksquare\kern-0.1em\square\kern-0.02em}$, $\mathord{\blacksquare\kern-0.1em\square\kern-0.02em\kern-0.072em\blacksquare}$, $\mathord{\blacksquare\kern-0.1em\square\kern-0.02em\cellw}$, $\mathord{\square\kern-0.072em\blacksquare\cellb}$, $\mathord{\square\kern-0.072em\blacksquare\kern-0.1em\square\kern-0.02em}$, or $\mathord{\square\kern-0.1em\square\kern-0.02em\kern-0.072em\blacksquare}$. If we did not stipulate that this collection be finite, then different occurrences of $\blacksquare$ in different outputs of $U$ could have been explained by substrings of arbitrary length in the input. This would allow such behaviour as outputting a single cell which is black if and only if the input codes a halting Turing machine! The example we have given is somewhat restrictive, since the partial states we mention always shrink, and otherwise do not change shape very much. This is not a necessary limitation. For instance, we could introduce special `blank' cells on the ends of the strings which, rather than being removed by $U$, are duplicated to allow the working area to grow. More radical changes to the intuitive shape of parts are possible, but harder to describe. Putting all our conditions together we get the following. \begin{definition} A \definiendum{categorical Gandy machine} is an endofunctor $\fctl{U }{\cat{C}}{\cat{C}}$ where $\cat{C}$ is a locally finite category with a finite dense subcategory, such that: \begin{itemize} \item the induced functor $\fctl{\commaLift{U}}{\commaCat{\cat{C}}{\cat{C}}}{\commaCat{\cat{C}}{U}}$ has a left adjoint $\localAdjoint{F}$, and \item for all subcategories $\cat{S}$ of $\commaCat{\cat{C}}{U}$ such that $\operatorname{dom}[\cat{S}]$, is finite, we have that $(\operatorname{dom} \mathbin{\circ} \localAdjoint{F})[\cat{S}]$ is also finite. \end{itemize} \end{definition} We are now in a position to prove that every $U$ satisfying these conditions is computable. We do this in two steps. \begin{proposition} Let $\fctl{U}{\cat{C}}{\cat{C}}$ be a categorical Gandy machine. Let $\cat{G}$ be a dense subcategory of $\cat{C}$ which gives an induced inclusion $\begin{tikzcd}\commaCat{\cat{G}}{U}\arrow[hookrightarrow]{r}&\commaCat{\cat{C}}{U} \end{tikzcd}$. Then $U$ is the pointwise (left) Kan extension of $\operatorname{dom}$ along $(\operatorname{dom} \mathbin{\circ} \localAdjoint{F})$ when both are precomposed with this inclusion. \end{proposition} \begin{proof} Let \(\eta\) be the unit of the adjunction between \(\commaLift{U}\) and \(\localAdjoint{F}\), and consider the diagram \[ \begin{tikzcd}[row sep=small] \commaCat{\cat{G}}{U} \arrow[hookrightarrow]{d} \arrow[hookrightarrow]{r} &\commaCat{\cat{C}}{U} \arrow{r}{\commaDomain}\arrow[equal]{d} &\cat{C}\arrow[equal]{d}\\ \commaCat{\cat{C}}{U}\arrow{d}{\localAdjoint{F}} \arrow[equal]{r} &\commaCat{\cat{C}}{U}\arrow[Rightarrow, shorten <= 1ex, shorten >=3ex,pos=0.2]{ld}{\eta}\arrow[equal]{d}\arrow{r}{\commaDomain} &\cat{C}\arrow[equal]{d}\\ \commaCat{\cat{C}}{\cat{C}}\arrow{d}{\commaDomain}\arrow{r}{\commaLift{U}} &\commaCat{\cat{C}}{U}\arrow{r}{\commaDomain} &\cat{C}\arrow[equal]{d}\\ \cat{C}\arrow{rr}{U} &&\cat{C}. \end{tikzcd} \] The top row is a pointwise Kan extension by density of $\cat{G}$. The middle row is a pointwise Kan extension since its left-hand square comes from an adjunction. It is thus an absolute Kan extension, preserved by $\operatorname{dom}$. The bottom row is a pointwise Kan extension since it commutes and $\operatorname{dom}$ has a section. Then the result follows by pasting of pointwise Kan extensions. \end{proof} \begin{corollary} Let $\fctl{U}{\cat{C}}{\cat{C}}$ be a categorical Gandy machine. Suppose that objects of $\cat{C}$ are represented by diagrams in the finite dense subcategory for which they are the colimit. Then $U$ is computable. \end{corollary} \begin{proof} Suppose for some object $X$ of $\cat{C}$, we want to compute $UX$. The above Proposition implies that $UX$ is the colimit of all objects which can occur as the domain of an object $g$ of $\commaCat{\cat{G}}{U}$ such that the domain of $\localAdjoint{F}g$ admits a morphism into $X$. Since $\cat{G}$ is finite, $\operatorname{dom}[\commaCat{\cat{G}}{U}] = \cat{G}$ is finite. Hence, $\operatorname{dom}[\localAdjoint{F}[\commaCat{\cat{G}}{U}]]$ is finite. This is the category in which the diagram whose colimit is $UX$ must take its values. Note that, in addition to being finite, it is independent of $X$. Therefore, it can be `precomputed' for use in evaluating $U$. In order to evaluate $UX$, all commuting triangles with one side in this precomputed category and apex $X$ must be computed. Since $\cat{C}$ is locally finite, this is a finite diagram (and it can actually be computed Since a morphism into $X$ is determined by its action on morphisms in $\cat{G}$, and one can `try all possibilities' for such actions; if desired, a similar idea can be used to ensure we have the `standard' diagram whose colimit~is~$X$). \end{proof} \section{Discussion and Future Work} The present work is the first step in a programme to study spatial models of computation from a categorical perspective. Our original motivation was to study the flow of information in such models along the lines of \cite{RazaviPhdThesis}. We are particularly interested in the question of where in the spatially extended state is stored which piece of information about the computation. In previous work we lacked a good axiomatization of suitable structures which we now provide. We believe this framework to be quite robust, and in this paper we show how its definition may be thought to arise from Gandy's principles. A natural next step is to strengthen the connections with these principles by investigating whether every example satisfying Gandy's original axioms can be interpreted in this framework. One obvious hurdle to overcome is that one has to choose a sensible category of states. This can not always have Gandy's set of states as objects. For example, Gandy points out that the set of finite structures for a first-order logical signature satisfies his axioms. However, if the signature contains function symbols, then the category of structures, while locally finite, does not have a finite dense subcategory. For example, consider a signature with a single function symbol, and interpret this by successor taken \emph{modulo} $n$ on the set $\{0,...,n-1\}$. These structures each admit no incoming morphisms from any other structure, and form an infinite family. The solution is to consider some notion of partial structure. This corresponds to adding objects not only for Gandy's states, but also enough parts to cover at least the ones important for the structure of the machine. It may also happen that the definition we give corresponds to a well-behaved subclass of Gandy's machines (and perhaps to well-behaved classes of examples of the other models inspired by Gandy). An example of the limitations of the present model is given by the functor on the category of finite directed graphs which, wherever it finds a path of length two $x \to y \to z$ in its input, adds a direct edge $x \to z$, taking a single step carried out by the obvious algorithm for transitive closure. This is not an instance of the present framework, since it will add the diagonal to a rectangle like \[ \begin{tikzcd}[row sep=small] \bullet \arrow{d}\arrow{r} &\bullet\arrow{d}\\ \bullet\arrow{r}&\bullet \end{tikzcd} \] but there is no unique smallest causal neighbourhood. This is related to the problem of overdetermination mentioned above. This operation is, intuitively, locally deterministic for the usual notion of `locally' in a graph. However, as we discussed earlier, if nodes of arbitrarily high degree are allowed, then our definition takes a strange view of the meaning of `local'. Comparisons with later models, especially \cite{Maignan}, may be more direct. In \cite{ArrighiCausalGraphs}, a definition of local determinism is given in which a phenomenon in an updated graph is explained by a sub-graph of bounded radius around an `antecedent' in the previous state. This is shown to be equivalent to taking a union of local updates. The analogy between this result and Proposition 1 above raises the question whether the other results of \cite{ArrighiCausalGraphs} have counterparts in the present abstract setting. A different abstract perspective on this idea, based on topology, is presented in \cite{ArrighiCayley1,ArrighiCayley2}; this may aid the comparison with \cite{ArrighiCausalGraphs}. To facilitate this study, a full version of the present work containing more detailed proofs and examples will be presented in a forthcoming paper. Other important questions are suggested by the key role played by finite categories in Definition 1. It would be interesting if the present extrinsic notion of finite category could be replaced by a more intrinsic condition. In \cite{HaeuslerFiniteness}, the impact on models of computation of varying the notion of finiteness is discussed. Beyond this, in future work we plan to return to our original aims, and put this axiomatization to use to give a cleaner account of \cite{RazaviPhdThesis}, and the flow of information in spatial models.\\ \textbf{Acknolwedgements.} We would like to thank Pouya Adrom for a timely pointer to Kan extensions and Francisco Lobo for a number of very fruitful discussions about the structures we use. \nocite{*} \bibliographystyle{eptcs}
{'timestamp': '2019-04-24T02:04:43', 'yymm': '1904', 'arxiv_id': '1904.10109', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.10109'}
arxiv
\section{Introduction} Understanding and predicting physical phenomena in daily life is an important component of human intelligence. This ability enables us to effortlessly manipulate objects in previously unseen conditions. It is an open question how this kind of knowledge can be represented and what kind of models could explain human manipulation behavior~\citep{yildirim2017physical}. In this work, we explore potential frameworks for the robot to learn manipulation with respect to the corresponding physics constraints underneath the task. Behind the human's physics reasoning in everyday life, the \textit{intuitive physics} \citep{Smith1994, mccloskey1983intuitive} plays an important role in the process, representing \textit{raw} knowledge for human to understand the physical environment and interactions. Albeit sometimes erroneous, it works well enough for most situations in daily life. It has been an ongoing research in cognitive science and psychology, among others, to understand computational models~\citep{battaglia2012computational} and explain such a mechanism. It has not yet been shown how to equip machines with a similar set of physics commonsense---thereby bypassing a model-based representation and a physical simulation. In fact, it has been argued that such an approach is unlikely due to e.g., the complexity of the problem~\citep{battaglia2013simulation}. Only recently, several works have revived this idea and reattempted a fully data driven approach to capturing the essence of physical events via machine learning methods \citep{mottaghi2015newtonian,wu2015galileo,fragkiadaki2015learning,apratim16ariv}. In the first part of this work, we draw inspiration from the studies in developmental psychology~\citep{baillargeon1994infants,baillargeon2008innate} where the infants acquire the knowledge of physical events gradually through the observation of various event instances. In this context, we revisit the classical setup of Tenenbaum and colleagues~\citep{battaglia2013simulation} and explore to which extent machines can predict physical stability events directly from appearance cues. We approach this problem by synthetically generating a large set of wood block towers under a range of conditions, including varying number of blocks, varying block sizes, planar vs.\ multi-layered configurations. We run those configurations through a simulator ({\em only at training time!}) in order to generate labels whether a tower would fall or not. We show for the first time that the aforementioned stability test can be learned and predicted in a purely data driven way---bypassing traditional model-based simulation approaches. Further, we accompany our experimental study with human judgments on the same stimuli. Then we utilize this framework to guide the robot to stably stack a single block onto the existing block-structure based on the stability prediction. To circumvent the domain shift between the synthesized images and the real world scene images, we extract the foreground masks for both synthesized and captured images. Given a real world block structure, the robot uses the model trained on the synthesized data to predict the stability outcome across possible candidate placements, and performs stacking on the feasible locations afterwards. We evaluate both the prediction and manipulation performance on the very task. \begin{figure} \centering \includegraphics[width=0.68\linewidth]{./teaser_rev.pdf} \caption{Given a wood block structure, our visual stability classifier predicts the stability for future placements, and the robot then stacks a block among the predicted stable placements.} \label{fig:teaser} \end{figure} In the second part of this work, we further tackle a more challenging stacking task (target stacking). The goal for the task is to reproduce a shape shown in an image by consecutively stacking multiple blocks while retaining physical stability and avoiding pre-mature collisions with the existing structure. We explore an alternative modeling to learn the block stacking through trial-and-error, bypassing the need to explicitly model the corresponding physics knowledge as in the former part of this work. For this purpose, we build a synthetic environment with physics simulation, where the agent can move and stack blocks and observe the different outcomes of its actions. We apply deep reinforcement learning to directly acquire the block stacking skill in an end-to-end fashion. By introducing the goal-parameterized policies, we learn a single model to guide the agent to build different shapes on request. We first validated this model on a toy example where the agent has to navigate in a grid-world where both the location of the start and end point are randomized for each episode and then the target stacking. On both experiments, we observe generalization across different goals. We tackle the block stacking task, by focusing the manipulation learning with respect to the corresponding physics constraints underneath the task. The first part of the work emphasizes the visual stability prediction formalism and its application to single block stacking task that was initially presented in~\cite{li2017visual}. The second part of the work features an extension to goal-parametrized deep reinforcement learning framework and its application to target stacking task. In addition, we now include a discussion of the simulation environment implemented for both tasks. While simulation engines and game engines, such as Panda3D \citep{goslin2004panda3d}, provide a generic platform to devise environment to different needs, it is still very time-consuming and remains non-trivial to customize one for a specific tasks such as the target stacking in this work. Hence, we briefly recap our design for the environments to provide readers more insights for further practice. \section{Related Work} \subsection{Physics Understanding} Humans possess the amazing ability to perceive and understand ubiquitous physical phenomena occurring in their daily life. This gives rise to the concept of intuitive physics, aiming to describe the knowledge which enables humans to understand physical environment and interact accordingly. In particular, the ``intuitive'' part emphasizes knowledge which is considered commonsense to ordinary people not reliant on specialized training in physics. Intuitive physics is ubiquitous in guiding humans' actions in daily life, such as where to put a cup stably and how to catch a ball. Along the years, research on intuitive physics has been conducted from many different perspectives across psychology, cognitive science and artificial intelligence. In developmental psychology, researchers seek to understand how this ability develops. \cite{baillargeon2002acquisition} suggest that infants acquire the knowledge of physical events at a very young age by observing those events, including support events and others. Interestingly, in a recent work \cite{denil2016learning}, the authors introduce a basic set of tasks that require the learning agent to estimate physical properties (mass and cohesion combinations) of objects in an interactive simulated environment and find that it can learn to perform the experiments strategically to discover such hidden properties in analogy to human's development of physics knowledge. Another interesting question that has been explored in psychology is how knowledge about physical events affects and guides human's actual interaction with objects \cite{yildirim2017physical}. Yet it is not clear how a machine model trained for physics understanding can directly be applied to real-world interactions with objects and accomplish manipulation tasks. In cognitive science, \cite{battaglia2013simulation} proposes an intuitive physics simulation engine as an internal mechanism for such type of ability and found close correlation between its behavior patterns and human subjects' on several psychological tasks. More recently, there has been renewed interest in physics understanding in computer vision and machine learning communities. For instance, understanding physical events plays an important role in scene understanding in computer vision. By including additional clues from physical constraints into the inference mechanism, mostly from the support event, it has further improved results in segmentation of surfaces \cite{gupta2010blocks}, scenes \cite{silberman2012indoor} from image data, and object segmentation in 3D point cloud data \cite{zheng2013beyond}. Another research direction is to equip artificial agents with such an ability by letting them learn physical concepts from visual data. \cite{mottaghi2015newtonian} aim at understanding dynamic events governed by laws of Newtonian physics and use proto-typical motion scenarios as exemplars. \cite{fragkiadaki2015learning} analyze billiard table scenarios and learn dynamics from observation with explicit object notion. An alternative approach based on boundary extrapolation \cite{apratim16ariv} addresses similar settings without imposing any object notion. \cite{wu2015galileo} aims to understand physical properties of objects based on explicit physical simulation. \cite{mottaghi2017see} proposes to reason about containers and the behavior of the liquids inside them from a single RGB image. A most related work is done by \cite{fergus16blocsarxiv}, where the authors propose using a visual model to predict stability and falling trajectories for simple 4 block scenes. In the first part of this work, we investigate if and how the prediction performance of such image-based models changes when trained on block stacking scenes with larger variety and further examine how the human's prediction adapts to the variation in the generated scenes and compare to the learned visual model. Each work requires significant amounts of simulated, physically-realistic data to train the large-capacity, deep models. \subsection{Learning from Synthetic Data and Simulation} Learning from synthetic data has a long tradition in computer vision and has recently gained increasing interest \citep{li12eccv,kostas14cvpr,peng2015learning,rematas16cvpr} due to data hungry deep-learning approaches. In the first part of this work, we use a game engine to render scene images and a built-in physics simulator to simulate the scenes' stability behavior. The data generation procedure is based on the platform used in \cite{battaglia2013simulation}, however as discussed before, their work hypothesized a simulation engine as an internal mechanism for human to understand the physics in the external world while we are interested in finding an image-based model to directly predict the physical behavior from visual channel. In reinforcement learning domain, it is a common practice to utilize simulation environment to train the reinforcement agent, such as the Atari Games~\citep{bellemare13arcade} and ViZDoom~\citep{kempka2016vizdoom}. However, there is no off-the-shelf environment supporting trial-and-error interaction for block stacking. Hence, in the second part of this work, we build on existing game engine and create our interactive environment with physics simulation to allow the learning agent to learn stacking skills through interactions. \subsection{Blocks-based Manipulation Tasks} To shed more light on the capabilities of our model, in the first part of this work, we explore how the visual stability prediction model can be used in a robotic manipulation task, i.e., stably stacking a wood block given a block structure. In the past, we have seen researchers perform tasks with wood blocks, like playing Jenga from different perspectives. \cite{kroger2006demonstration} demonstrated multi-sensor integration by using a marker-based system with multiple cameras and sensors: a random block is first chosen in the tower, then the robot arm will try to pull the very block, if the force sensor detects large counter force or the CCD cameras detect large motion of tower, then it will stop pulling and try other block. \cite{wang2009robot} improved on \cite{kroger2006demonstration} by further incorporating a physics engine to initialize the candidates for pulling test. In comparison, we do not fit 3D models or run physics simulation at test time for the given scene but instead use the scene image as input to directly predict the physics of the structure. A different line of research is \cite{kimura2010force} where physical force is explicitly formulated with respect to the tower structure for planning. In our work, we do not do explicit formation of contact force as in \cite{kimura2010force}, nor do we perform trials on-site for evaluating the robot's operation. We only use physics engine to acquire synthesized data for training the visual-physics model. At test time, the planning system for our robot mainly exploits the knowledge encoded in the visual-physics model to evaluate the feasibility of individual candidates and performs operations accordingly. \subsection{Reinforcement Learning} In the second part of this work, reinforcement learning is used to learn an end-to-end model directly from the experience collected during interaction with a physically-realistic environment. The majority of work in reinforcement learning focuses on solving task with a single goal. However, there are also tasks where the goal may change for every trial. It is not obvious how to directly apply the model learned towards a specific goal to a different one. An early idea has been proposed by \cite{kaelbling1993learning} for a maze navigation problem in which the goal changes. The author introduces an analogous formulation to the Q-learning by using shortest path in replacement of the value functions. Yet there are two major limitations for the framework: 1) it is only formulated in tabular form which is not practical for application with complex states 2) the introduced shortest path is very specific to the maze navigation setting and hence cannot be easily adapt to handle task like target stacking. In contrast, we propose a goal-parameterized model to integrate goal information into a general learning-based framework that facilitates generalization across different goals. The model has been shown to work on both a navigation task and target stacking. A few other works also explored the idea of integrating goal information into learning. \cite{schaul2015universal} propose the universal value function approximators (UVFAs) to integrate goal information into learning. \cite{oh2017zero} proposes zero-shot task generation with explicit modeling of skills and subtasks where our approach is end-to-end and thereby bypasses this kind of modeling. \cite{dosovitskiy2016learning} use the terms ``goal'' and ``target''. However, their notion is different from ours. Their framework is using auxiliary information (intermediate measurements as goal module) to improve learning to maximize gaming score in visually-richer task like vizDoom. There is no specific goal to enforce the agent to reach certain state which is exactly what our approach facilitates. The metacontroller \citep{hamrick2017metacontrol}, the imagination strategy \citep{pascanu2017learning} and the I2A model \citep{weber2017imagination} are all appealing generic frameworks to boost overall performance over existing RL methods. While these approaches -- similar to some of the Atari games -- have a goal encoded in the observation/state, this goal remains implicit. This is applicable in many robotic scenarios, where goals are specified externally. Therefore, we explore an approach for target stacking that has an explicit notion and model of goals. Our work is the first to bring this concept to bear towards manipulation and planing under physical constraints -- breaking with more conventional simulation and planning approaches (e.g. \cite{yildirim2017physical}). \section{Simulation Environment} Modern machine learning techniques build on data. With the rise of deep learning models, the need of data becomes even more prominent. One of the key elements for the recent success of deep learning model in domains like generic image and speech recognition is the abundance of data in related fields. However, when it comes to a specific domain, it often runs short of data and in reality, collecting data is still an expensive process. One remedy for this issue is to exploit the domain knowledge to synthesize data and utilize the generated data for learning. This is also the case for our study as there is no obvious source of clean and sufficient data to learn physics from. Hence, we make use of the Panda3D~\footnote{\url{https://www.panda3d.org/}} to create both simulation environments in our work. Panda3D is an open source game engine for Python and C++ programs. It was originally developed by the Disney's VR studio to be ``flexible enough to support everything from realtime graphics applications to the development of high-end virtual reality theme park attractions or video games'' \citep{goslin2004panda3d} and it has evolved significantly along the years. As a game engine, the Panda3D provides additional capabilities besides 3D rendering including the physics system with integration of different physics engines. Asides from its own built-in basic physics engine, it also supports more advanced ones including the Open Dynamics Engine (ODE) \footnote{\url{http://www.ode.org/}} \citep{smith2005open} and the Bullet \footnote{\url{http://bulletphysics.org/wordpress/}} \citep{coumans2010bullet} for physics simulation back-end. We used the Bullet in both of our simulation environments. The workflow of Panda3D builds on the concept of scene graph. The \textbf{Scene graph} is a general data structure to represent and organize a graphical scene. In Panda3D, the scene graph is maintained as a tree of objects to be rendered. The tree consists of objects of class \texttt{PandaNode}. As shown in Figure~\ref{fig:sim:panda3d_sceneGraph}, the root node is called the \texttt{render} and the rest define different perspectives of the scene with various attributes. For example, the \texttt{LensNode} controls the camera such as the perspective, the \texttt{LightNode} manages the lighting in the scene such as the color and type of the lighting and the \texttt{ModelNode} encodes the 3D object in the frame. \begin{figure} \centering \includegraphics[width=0.97\linewidth,keepaspectratio]{./panda3d_sceneGraph.pdf} \caption{An example of scene graph in Panda3D.} \label{fig:sim:panda3d_sceneGraph} \end{figure} Another important concept is the \textbf{task}. Tasks are functions called by Panda3D at every frame or for every specified amount of time. Together with \textbf{event handler} which is called upon special conditions (\textbf{events}) occur, update can be made to the scene in Panda3D between rendering steps as shown in Figure~\ref{fig:sim:panda3d_render}. For instance, the task can be the simulation subroutine that updates the states of objects in the scene caused by physics. \begin{figure} \centering \includegraphics[width=0.78\linewidth,keepaspectratio]{./panda3d_render.pdf} \caption{The render process in Panda3D.} \label{fig:sim:panda3d_render} \end{figure} \section{Part I: From Visual Stability Prediction to Single Block Stacking} \subsection{Stability Prediction from Still Images} \paragraph{Inspiration from Human Studies} Research in \cite{hamrick2011internal,battaglia2013simulation} suggests the combinations of the most salient features in the scenes are insufficient to capture people's judgments, however, contemporary study reveals human's perception of visual information, in particular some geometric feature, like critical angle \cite{cholewiak2013visual,cholewiak2015perception} plays an important role in the process. Regardless of the actual inner mechanism for humans to parse the visual input, it is clear there is a mapping $f$ involving visual input $I$ to the stability prediction $P$. \begin{gather*} \begin{aligned} f: I,\ast \rightarrow P \end{aligned} \end{gather*} Here, $\ast$ denotes other possible information, i.e., the mapping can be inclusive, as in \cite{hamrick2011internal} using it along with other aspects, like physical constraint to make judgment or the mapping is exclusive, as in \cite{cholewiak2013visual} using visual cues alone to decide. \paragraph{Image Classifier for Stability Prediction} In our work, we are interested in the mapping $f$ exclusive to visual input and directly predicts the physical stability (visual stability test). To this end, we use deep convolutional neural networks as it has shown great success on image classification tasks~\citep{krizhevsky2012imagenet}. Such networks have been shown to be able to adapt to a wide range of classification and prediction task \citep{razavian2014cnn} through re-training or adaptation by fine-tuning. Therefore, these approaches seem to be adequate methods to study visual prediction on this challenging task with the motivation that by changing conventional image classes labels to stability labels the network can learn ``physical stability salient'' features. By setting up a data generation process that allows us to control various degrees of freedom induced by the problem as well as generation of large quantities of data in a repeatable setting, we can then validate our approach. An overview of our approach is shown in Figure~\ref{fig:overview_recog}. \begin{figure} \centering \includegraphics[width=0.95\linewidth]{./recog_pipe.pdf} \caption{An overview of our approach for learning visual stability. Note that physics engine is only used during training time to get the ground truth to train the deep neural network while at test time, only rendered scene images are given to the learned model to predict the physical stability of the scenes.} \label{fig:overview_recog} \end{figure} \subsection{Data Generator for Visual Stability Prediction} Based on the scene simulation framework used in \citep{hamrick2011internal,battaglia2013simulation}, we build a data generator to synthesize data for visual stability tests. Figure~\ref{fig:sim:stability_data_pippeline} gives an overview of the data generator. The first key component is the \textbf{tower generation}. It automatically generate a large number of different blocks structures (tower) under the \textit{scene parameters}, including the number of blocks, stacking depth and block size (We will elaborate on this later). These towers are recorded as scene files which only track all the locations of blocks in the scene. The next component is the \textbf{stability simulation}. It loads the stored scene files and simulates their stability with physics engine. The images for the towers before running the physics engine are captured as the scene images, the stability labels from the simulation are automatically determined and recorded for the corresponding towers. Both the scene images and the obtained stability labels are later put into the deep convolutional neural network to learn the visual stability classifier. \begin{figure} \centering \includegraphics[width=1.\linewidth,keepaspectratio]{./stability_data_pipeline.pdf} \caption{Overview of the data generator for visual stability prediction. The scene images and their corresponding stability labels are collected.} \label{fig:sim:stability_data_pippeline} \end{figure} \subsubsection{Tower Generation} An example of the scene setup is shown Figure~\ref{fig:sim:stability_data_setup}. The tower is placed on a plane, and a camera is positioned at the front-facing location of which the elevation is adjusted for the towers of different heights. For different scenes, the towers are generated differently, and the scene images are captured through the camera. To make the scene images more realistic, wood texture is added to all the blocks. \begin{figure} \centering \includegraphics[width=0.65\linewidth,keepaspectratio]{./stability_data_setup.pdf} \caption{Example set-up of the scene for the data generator.} \label{fig:sim:stability_data_setup} \end{figure} The basic tower generation system is based on the framework by \cite{battaglia2013simulation}. Given a specified number of total blocks in the tower, the blocks are sequentially added into the scene under the geometrical constraints, such as no collision between blocks. Some examples of obtained scene images are shown in Figure~\ref{fig:sim:stability_example}. \begin{figure} \centering \begin{subfigure}[b]{0.23\linewidth} \centering \includegraphics[width=0.98\linewidth]{./tower_34_04.jpg} \caption{4 Blocks} \end{subfigure} \begin{subfigure}[b]{0.23\linewidth} \centering \includegraphics[width=0.98\linewidth]{./tower_64_06.jpg} \caption{6 Blocks} \end{subfigure} \begin{subfigure}[b]{0.23\linewidth} \centering \includegraphics[width=0.98\linewidth]{./tower_72_10.jpg} \caption{10 Blocks} \end{subfigure} \begin{subfigure}[b]{0.23\linewidth} \centering \includegraphics[width=0.98\linewidth]{./tower_410_14.jpg} \caption{14 Blocks} \end{subfigure} \caption{Example of generated scene images with different total number of blocks.} \label{fig:sim:stability_example} \end{figure} \subsubsection{Stability Simulation} During the stability simulation, we set the simulation time universally to 2 seconds at $1000{\text Hz}$ for all the scenes. Surface friction and gravity are enabled in the simulation. The system records the configuration of a scene of $N$ blocks at time $t$ as $(p_1,p_2,...,p_N)_t$, where $p_i$ is the location for block $i$. The stability is then automatically decided as a Boolean variable: \begin{gather*} \begin{aligned} S = \bigvee\limits_{i=1}^N (\Delta((p_i)_{t=T} - (p_i)_{t=0}) > \tau) \end{aligned} \end{gather*} where $T$ is the end time of simulation, $\delta$ measures the displacement for the blocks between the starting point and end time, $\tau$ is the displacement threshold, $\bigvee$ denotes the logical ${\text{Or}}$ operator, that is to say it counts as unstable $S={\text{True}}$ if any block in the scene moved in simulation, otherwise as stable $S={\text {False}}$. This is necessary as the blocks in stable towers can generate small displacement during the simulation process, simply using zero displacement to determine the stability can lead to lots of erroneous cases where the stable towers are labeled as unstable. In practice, we picked the threshold based on the evaluation of a small set of towers. \subsection{Synthetic Data} The number of blocks, blocks' size and stacking depth are varied in the generated scenes, to which we will refer as {\it scene parameters}. \paragraph{Numbers of Blocks} We expect that varying the size of the towers will influence the difficulty and challenge the competence of ``eye-balling'' the stability of a tower in humans and machine. While evidently the appearance becomes more complex with the increasing number of blocks, the number of contact surfaces and interactions equally make the problem richer. Therefore, we include scenes with four different number of blocks, i.e., 4 blocks, 6 blocks, 10 blocks and 14 blocks as $\{{\text 4B}, {\text 6B}, {\text 10B}, {\text 14B}\}$. \paragraph{Stacking Depth} As we focus our investigations on judging stability from a monocular input, we vary the depth of the tower from a one layer setting which we call ${\text 2D}$ to a multi-layer setting which we call ${\text 3D}$. The first one only allows a single block along the image plane at all height levels while the other does not enforce such constraint and can expand in the image plane. Visually, the former results in a single-layer stacking similar to Tetris while the latter ends in a multiple-layer structure as shown in Table~\ref{tab:scene_param}. The latter most likely requires the observer to pick up on more subtle visual cues, as many of its layers are heavily occluded. \paragraph{Block Size} We include two groups of block size settings. In the first one, the towers are constructed of blocks that have all the same size of $1 \times 1 \times 3$ as in the \cite{battaglia2013simulation}. The second one introduces varying block sizes where two of the three dimensions are randomly scaled with respect to a truncated Normal distribution $N(1,\sigma^2)$ around $[1 - \delta,1 + \delta]$, $\sigma$ and $\delta$ are small values. These two settings are referred to as $\{{\text Uni}, {\text NonUni}\}$. The setting with non-uniform blocks introduces small visual cues where stability hinges on small gaps between differently sized blocks that are challenging even for human observers. \paragraph{Scenes} Combining these three scene parameters, we define $16$ different scene groups. For example, group 10B-2D-Uni is for scenes stacked with 10 Blocks of same size, stacked within a single layer. For each group, $1000$ candidate scenes are generated where each scene is constructed with non-overlapping geometrical constraint in a bottom-up manner. There are $16 {\text K}$ scenes in total. For prediction experiments, half of the images in each group are for training and the other half for test, the split is fixed across the experiments. \paragraph{Rendering} While we keep the rendering basic, we like to point out that we deliberately decided against colored bricks as in \cite{battaglia2013simulation} in order to challenge perception and make identifying brick outlines and configurations more challenging. The lighting is fixed across scenes and the camera is automatically adjusted so that the whole tower is centered in the captured image. Images are rendered at resolution of $800 \times 800$ in color. \begin{table*} \begin{tabular}{cccc|cc|cc} \hline\hline \multicolumn{4}{c}{Block Numbers} & \multicolumn{2}{c}{Stacking Depth} &\multicolumn{2}{c}{Block Size}\\ \hline & & & & & & & \\ \begin{subfigure}{0.101\textwidth}\centering\includegraphics[width=0.96\columnwidth]{./tower_34_04.jpg}\caption{\scriptsize4 Blocks}\end{subfigure}& \begin{subfigure}{0.101\textwidth}\centering\includegraphics[width=0.96\columnwidth]{./tower_64_06.jpg}\caption{\scriptsize6 Blocks}\end{subfigure}& \begin{subfigure}{0.101\textwidth}\centering\includegraphics[width=0.96\columnwidth]{./tower_72_10.jpg}\caption{\scriptsize10 Blocks}\end{subfigure}& \begin{subfigure}{0.101\textwidth}\centering\includegraphics[width=0.96\columnwidth]{./tower_410_14.jpg}\caption{\scriptsize14 Blocks}\end{subfigure}& \begin{subfigure}{0.101\textwidth}\centering\includegraphics[width=0.96\columnwidth]{./6b2d_side.jpg}\caption{\scriptsize2D-stack}\end{subfigure}& \begin{subfigure}{0.101\textwidth}\centering\includegraphics[width=0.96\columnwidth]{./6b3d_side.jpg}\caption{\scriptsize3D-stack}\end{subfigure}& \begin{subfigure}{0.101\textwidth}\centering\includegraphics[width=0.96\columnwidth]{./tower_235_04.jpg}\caption{\scriptsize size-fix}\end{subfigure} & \begin{subfigure}{0.101\textwidth}\centering\includegraphics[width=0.96\columnwidth]{./tower_301_04.jpg}\caption{\scriptsize size-vary}\end{subfigure}\\ \hline \end{tabular} \caption{Overview of the scene parameters in our rendered scenes. There are 3 groups of scene parameters across number of blocks, stacking depth and block size.} \label{tab:scene_param} \end{table*} \subsection{Prediction Performance} In this part of the experiments, the images are captured before the physics engine is enabled, and the stability labels are recorded from the simulation engine as described before. At the training time, the model has access to the images and the stability labels. At test time, the learned model predicts the stability results against the results generated by the simulator. In a pilot study, we tested on a subset of the generated data with LeNet~\citep{lecun1995comparison}, a relatively small network designed for digit recognition, AlexNet~\citep{krizhevsky2012imagenet}, a large network and VGG Net~\citep{simonyan2014very}, an even larger network than AlexNet. We trained from scratch for the LeNet and fine-tuned for the large network pre-trained on ImageNet \cite{deng2009imagenet}. VGG Net consistently outperforms the other two, hence we use it across our experiment. We use the Caffe framework~\citep{jia2014caffe} in all our experiments. We divide the experiment design into 3 sets: the intra-group, cross-group and generalization. The first set investigates influence on the model's performance from an individual scene parameter, the other two sets explore generalization properties under different settings. \subsubsection{Intra-Group Experiment} In this set of experiments, we train and test on the scenes with the same scene parameters in order to assess the feasibility of our task. \paragraph{Number of Blocks (4B, 6B, 10B, 14B)} In this group of experiment, we fix the stacking depth and keep the all blocks in the same size but vary the number of blocks in the scene to observe how it affects the prediction rates from the image trained model, which approximates the relative recognition difficulty from this scene parameter alone. The results are shown in Table~\ref{tab:intra_group}. A consistent drop of performance can be observed with increasing number of blocks in the scene under various block sizes and stacking depth conditions. More blocks in the scene generally leads to higher scene structure and hence higher difficulty in perception. \paragraph{Block Size (Uni. vs. NonUni.)} In this group of experiment, we aim to explore how same size and varied blocks sizes affect the prediction rates from the image trained model. We compare the results at different number of blocks to the previous group, in the most obvious case, scenes happened to have similar stacking patterns and same number of blocks can result in changes visual appearance. To further eliminate the influence from the stacking depth, we fix all the scenes in this group to be 2D stacking only. As can be seen from Table~\ref{tab:intra_group}, the performance decreases when moving from 2D stacking to 3D. The additional variety introduced by the block size indeed makes the task more challenging. \paragraph{Stacking Depth (2D vs. 3D)} In this group of experiment, we investigate how stacking depth affects the prediction rates. With increasing stacking depth, it naturally introduces ambiguity in the perception of the scene structure, namely some parts of the scene can be occluded or partially occluded by other parts. Similar to the experiments in previous groups, we want to minimize the influences from other scene parameters, we fix the block size to be the same and only observe the performance across different number of blocks. The results in Table~\ref{tab:intra_group} show a little inconsistent behaviors between relative simple scenes (4 blocks and 6 blocks) and difficult scenes (10 blocks and 14 blocks). For simple scenes, prediction accuracy increases when moving from $2D$ stacking to $3D$ while it is the other way around for the complex scene. Naturally relaxing the constraint in stacking depth can introduce additional challenge for perception of depth information, yet given a fixed number of blocks in the scene, the condition change is also more likely to make the scene structure lower which reduces the difficulty in perception. A combination of these two factors decides the final difficulty of the task, for simple scenes, the height factor has stronger influence and hence exhibits better prediction accuracy for $3D$ over $2D$ stacking while for complex scenes, the stacking depth dominates the influence as the significant higher number of blocks can retain a reasonable height of the structure, hence receives decreased performance when moving from $2D$ stacking to $3D$. \begin{table} \centering \ra{1.4} \begin{tabular*}{0.7\linewidth}{@{ }ccccc@{ }}\toprule \# Blks & \multicolumn{2}{c}{Uni.} & \phantom{ab}& \multicolumn{1}{c}{NonUni.}\\ \cmidrule{2-3} \cmidrule{5-5} & $2D$ & $3D$ && $2D$\\ \midrule $4B$ & 93.0 & 99.2 && 93.2\\ $6B$ & 88.8& 91.6&& 88.0\\ $10B$ & 76.4& 68.4&& 69.8\\ $14B$ & 71.2& 57.0&& 74.8\\ \bottomrule \end{tabular*} \caption{Intra-group experiment by varying scene parameters.} \label{tab:intra_group} \end{table} \subsubsection{Cross-Group Experiment} In this set of experiment, we want to see how the learned model transfers across scenes with different complexity, so we further divide the scene groups into two large groups by the number of blocks, where a {\it simple scene} group for all the scenes with $4$ and $6$ blocks and a {\it complex scene} for the rest of scenes with $10$ and $14$ blocks. We investigate in two-direction classification, shown in the figure in Table~\ref{tab:cross_group}: \begin{enumerate} \item Train on simple scenes and predict on complex scenes: Train on 4 and 6 blocks and test on 10 and 14 blocks \item Train on complex scenes and predict on simple scenes: Train on 10 and 14 blocks and test on 4 and 6 blocks \end{enumerate} As shown in Table~\ref{tab:cross_group}, when trained on simple scenes and predicting on complex scenes, it gets $69.9\%$, which is significantly better than random guess at $50\%$. This is understandable as the learned visual feature can transfer across different scene. Further we observe significant performance boost when trained on complex scenes and tested on simple scene. This can be explained by the richer feature learned from the complex scenes with better generalization. \begin{table} \addtolength{\tabcolsep}{-3pt} \centering \ra{1.4} \begin{tabular*}{0.95\linewidth}{l c c} \multicolumn{3}{c}{\includegraphics[width=0.8\linewidth]{./pltCrossGroup.pdf}}\\ \toprule Setting & \scriptsize Simple $\rightarrow$ Complex & \scriptsize Complex $\rightarrow$ Simple\\ \hline Accuracy (\%)& 69.9 & 86.9\\ \bottomrule \end{tabular*} \addtolength{\tabcolsep}{3pt} \caption{The upper figure shows the experiment settings for Cross-group classification where we train on simpler scenes and test on more complex scenes. The lower table shows the results.} \label{tab:cross_group} \end{table} \subsubsection{Generalization Experiment} In this set of experiment, we want to explore if we can train a general model to predict stability for scenes with any scene parameters, which is very similar to human's prediction in the task. We use training images from all different scene groups and test on any groups. The Result is shown in Table~\ref{tab:general}. While the performance exhibits similar trend to the one in the intra-group with respect to the complexity of the scenes, namely increasing recognition rate for simpler settings and decreasing rate for more complex settings, there is a consistent improvement over the intra-group experiment for individual groups. Together with the result in the cross-group experiment, it suggests a strong generalization capability of the image trained model. \begin{table} \centering \ra{1.4} \begin{tabular*}{0.75\linewidth}{@{ }cccccc@{ }}\toprule \# Blks & \multicolumn{2}{c}{Uni.} & \phantom{ab}& \multicolumn{2}{c}{NonUni.}\\ \cmidrule{2-3} \cmidrule{5-6} & $2D$ & $3D$ && $2D$ & $3D$\\ \midrule 4B &93.2 &99.0 &&95.4 &99.8 \\ 6B &89.0 &94.8 &&87.8 &93.0 \\ 10B &83.4 &76.0 &&77.2 &74.8 \\ 14B &82.4 &67.2 &&78.4 &66.2 \\ \bottomrule \end{tabular*} \caption{Results for generalization experiments.} \label{tab:general} \end{table} \begin{table} \addtolength{\tabcolsep}{-3pt} \centering \ra{1.3} \begin{tabular*}{0.88\linewidth}{@{ }cccccc@{ }}\toprule \# Blks & \multicolumn{2}{c}{Uni.} & \phantom{a}& \multicolumn{2}{c}{NonUni.}\\ \cmidrule{2-3} \cmidrule{5-6} & $2D$ & $3D$ && $2D$ & $3D$\\ \midrule 4B &\tiny79.1/\tiny{\bf91.7} &\tiny93.8/\tiny{\bf 100.0} &&\tiny72.9/\tiny{\bf 93.8} &\tiny92.7/\tiny{\bf 100.0} \\ 6B &\tiny78.1/\tiny{\bf 91.7} &\tiny83.3/\tiny{\bf 93.8} &&\tiny71.9/\tiny{\bf 87.5} &\tiny89.6/\tiny{\bf 93.8} \\ 10B &\tiny67.7/\tiny{\bf 87.5} &\tiny72.9/\tiny72.9 &&\tiny66.7/\tiny{\bf 72.9} &\tiny71.9/\tiny68.8 \\ 14B &\tiny71.9/\tiny{\bf 79.2} &\tiny68.8/\tiny66.7 &&\tiny71.9/\tiny{\bf 81.3} &\tiny59.3/\tiny{\bf 60.4} \\ \bottomrule \end{tabular*} \addtolength{\tabcolsep}{3pt} \caption{Results from human subject test $a$ and corresponded accuracies from image-based model $b$ in format $a/b$ for the sampled data.} \label{tab:human_test} \end{table} \subsubsection{Discussion} Overall, we can conclude that direct stability prediction is possible and in fact fairly accurate at recognition rates over $80\%$ for moderate difficulty levels. As expected, the 3D setting adds difficulties to the prediction from appearance due to significant occlusion for towers of more than 10 blocks. Surprisingly, little effect was observed for small tower sizes switching from uniform to non-uniform blocks - although the appearance difference can be quite small. To better understand our results, we further discuss the following two questions: \begin{figure*} \centering \begin{subfigure}[c]{0.6\linewidth} \centering \includegraphics[width=1.\linewidth]{./gap_pipe.pdf} \caption{By introducing the GAP layer directly connected to the final output, the learned weights can be backprojected to the feature map for each category to construct the CAM. The CAM can be used to visualize the discriminative image regions for individual category.} \label{fig:gap_pipe} \end{subfigure} \begin{subfigure}[c]{0.34\linewidth} \centering \includegraphics[width=1.\linewidth]{./gap_example.pdf} \caption{Examples of CAM showing the discriminative regions for unstable prediction in comparison to the flow magnitude indicating where the collapse motion begins. For each example, from left to right are original image, CAM and flow magnitude map.} \label{fig:gap_example} \end{subfigure} \caption{We use CAM to visualize the results for model interpretation.} \label{fig:gap} \end{figure*} \textbf{How does the model performs compared to human?} To answer this, we conduct a human subject test. We recruit human subjects to predict stability for give scene images. Due to large number of test data, we sample images from different scene groups for human subject test. 8 subjects are recruited for the test. Each subject is presented with a set of captured images from the test split. Each set includes $96$ images where images cover all $16$ scene groups with $6$ scene instances per group. For each scene image, subject is required to rate the stability on a scale from $1-5$ without any constraint for response time: \begin{enumerate} \item Definitely unstable: definitely at least one block will move/fall \item Probably unstable: probably at least one block will move/fall \item Cannot tell: the subject is not sure about the stability \item Probably stable: probably no block will move/fall \item Definitely stable: definitely no block will move/fall \end{enumerate} The predictions are binarized, namely 1) and 2) are treated as unstable prediction, 4) and 5) as stable prediction, ``Cannot tell'' will be counted as $0.5$ correct prediction. The results are shown in Table~\ref{tab:human_test}. For simple scenes with few blocks, human can reach close to perfect performance while for complex scenes, the performance drops significantly to around $60\%$. Compared to human prediction in the same test data, the image-based model outperforms human in most scene groups. While showing similar trends in performance with respect to different scene parameters, the image-based model is less affected by a more difficult scene parameter setting, for example, given the same block size and stacking depth condition, the prediction accuracy decreases more slowly than the counter part in human prediction. We interpret this as image-based model possesses better generalization capability than human in the very task. \textbf{ Does the model learn something explicitly interpretable?} Here we apply the technique from \cite{zhou2015cnnlocalization} to visualize the learned discriminative image regions from CNN for individual category. The approach is illustrated in Figure~\ref{fig:gap_pipe}. With Global Average Pooling (GAP), the resulted spatial average of the feature maps from previous convolutional layers forms fully-connected layer to directly decides the final output. By back-projecting the weights from the fully-connected layer from each category, we can hence obtain Class Activation Map (CAM) to visualize the discriminative image regions. In our case, we investigate discriminative regions for unstable predictions to see if the model can spot the weakness in the structure. We use deep flow\cite{weinzaepfel2013deepflow} to compute the optical flow magnitude between the frame before the physics engine is enabled and the one afterwards to serve as a coarse ground truth for the structural weakness where we assume the collapse motion starts from such weakness in the structure. Though not universal among the unstable cases, we do find significant positive cases showing high correlation between the activation regions in CAM for unstable output and the regions where the collapse motion begins. Some examples are shown in Figure~\ref{fig:gap_example}. In the previous section, we have shown that an appereance-based model can predict physical stability relatively well on the synthetic data. Now we want to further explore if and how the synthetic data trained model can be utilized for a real world application, especially for robotic manipulation. Hence, we decide to set up a testbed where a Baxter robot's task is to stack one wood block on a given block structure without breaking the structure's stability as shown in Figure~\ref{fig:teaser}. The overview of our system is illustrated in Figure~\ref{fig:manip}. In our experiment, we use Kapla blocks as basic unit, and tape 6 blocks into a bigger one as shown in Figure~\ref{fig:blks}. To simplify the task, adjustments were made to the free-style stacking: \begin{itemize} \item The given block structure is restricted to be single layer as the ${\text 2D}$ case in the previous section. For the final test, we report results on the 6 scenes as shown in Table~\ref{tab:real_task}. \item The block to be put on top of the given structure is limited two canonical configurations \{vertical, horizontal\} as shown in Figure~\ref{fig:blk_config}. and assumed to be held in hand of robot before the placement. \item The block is constrained to be placed on the top-most horizontal surface (stacking surface) in the given structure. \item The depth of the structure (perpendicular distance to the robot) is calibrated so that we only need to decide the horizontal and vertical displacements with respect to the stacking surface. \end{itemize} \subsection{Prediction on Real World Data} Considering there are significant difference between the synthesized data and real world captured data, including factors (not limited to) as texture, illumination condition, size of blocks and accuracy of the render, we performed a pilot study to directly apply the model trained on the RGB images to predict stability on the real data, but only got results on par with random guessing. Hence we decided to train the visual-stability model on the binary-valued foreground mask on the synthesized data and deal with the masks at test time also for the real scenes. In this way, we significantly reduce the effect from the aforementioned factors. Observing comparable results when using the RGB images, we continue to the approach on real world data. At test time, a background image is first captured for the empty scene. Then for each test scene (shown in Table~\ref{tab:real_task}), an image is captured and converted to foreground mask via background subtraction. The top-most horizontal boundary is detected as the stacking surface and then used to generate candidate placements: the surface is divided evenly into 9 horizontal candidates and 5 vertical candidates, resulting in 84 candidates. The process is shown in Figure~\ref{fig:candidates}. Afterwards, these candidates are put to the visual-stability model for stability prediction. Each generated candidate's actual stability is manually tested and recorded as ground truth. The final recognition result is shown in Table~\ref{tab:real_task}. The model trained with synthetic data is able to predict with overall accuracy of $78.6\%$ across different candidates in real world. \begin{figure} \centering \includegraphics[width=0.7\linewidth]{./manip.pdf} \caption{An overview of our manipulation system. Our visual-stability classifier is integrated to recognize feasible candidate placement to guide manipulation.} \label{fig:manip} \end{figure} \begin{figure} \centering \begin{subfigure}[b]{0.55\linewidth}\includegraphics[width=1\linewidth]{./blks.pdf} \caption{Kapla block (left), block in test (right).} \label{fig:blks}\end{subfigure} \begin{subfigure}[b]{0.34\linewidth}\includegraphics[width=1\linewidth]{./blk_config.pdf} \caption{Allowed configurations in test.} \label{fig:blk_config}\end{subfigure} \caption{Blocks used in our experiment.} \label{fig:overview_manip} \end{figure} \begin{figure} \centering \includegraphics[width=1\linewidth]{./candidates.pdf} \caption{The procedure to generate candidates placement images for a give scene in our experiment.} \label{fig:candidates} \end{figure} \subsection{Manipulation Test} At test time, when the model predicts a give candidate placement as stable, the robot will execute routine to place the block with 3 attempts. We count the execution as a success if any of the attempt works. The manipulation success rate is defined as: \begin{gather*} \begin{aligned} \frac{\text{\#\{successful placements\}}}{\text{\#\{all stable placements\}}} \end{aligned} \end{gather*} where $\text{\#\{successful placements\}}$ is the number of successful placements made by the robot, and $\text{\#\{all stable placements\}}$ is the number of all ground truth stable placements. \begin{table*} \addtolength{\tabcolsep}{-4.3pt} \centering \ra{1.4} \begin{tabular*}{1.\linewidth}{crrrrrrrrrrrr \hline Id. & \multicolumn{2}{c}{1} & \multicolumn{2}{c}{2} & \multicolumn{2}{c}{3} & \multicolumn{2}{c}{4} &\multicolumn{2}{c}{5} &\multicolumn{2}{c}{6}\\ \hline Scene & \multicolumn{2}{c}{\includegraphics[width=0.1\linewidth]{./tc_1.png}} & \multicolumn{2}{c}{\includegraphics[width=0.1\linewidth]{./tc_2.png}} & \multicolumn{2}{c}{\includegraphics[width=0.1\linewidth]{./tc_3.png}} & \multicolumn{2}{c}{\includegraphics[width=0.1\linewidth]{./tc_4.png}} & \multicolumn{2}{c}{\includegraphics[width=0.1\linewidth]{./tc_5.png}} & \multicolumn{2}{c}{\includegraphics[width=0.1\linewidth]{./tc_6.png}} \\ \hline Pred.($\%$)& \footnotesize66.7& \footnotesize100.0& \footnotesize66.7& \footnotesize60.0& \footnotesize88.9& \footnotesize100.0& \footnotesize77.8& \footnotesize80.0& \footnotesize100.0& \footnotesize40.0& \footnotesize66.7& \footnotesize60.0\\ Mani.($\%$)& \footnotesize80.0\tiny(4/5)& \footnotesize100.0\tiny(5/5)& \footnotesize66.7\tiny(2/3)& \footnotesize100.0\tiny(3/3)& \footnotesize66.7\tiny(2/3)& \footnotesize100.0\tiny(1/1)& \footnotesize66.7\tiny(2/2)& \footnotesize66.7\tiny(2/3)& \footnotesize100.0\tiny(3/3)& \footnotesize25.0\tiny(1/4)& \footnotesize0.0\tiny(0/3)& \footnotesize0.0\tiny(0/1)\\ \bottomrule Placement& H& V& H& V& H& V& H& V& H& V& H& V\\ \hline \end{tabular*} \addtolength{\tabcolsep}{6pt} \caption{Results for real world test. ``Pred.'' is the prediction accuracy. ``Mani.'' is the manipulation success rate with counts for successful placements/all possible stable placements for each scene. ``H/V'' refer to horizontal/vertical placement.} \label{tab:real_task} \end{table*} As shown in Table~\ref{tab:real_task}, the manipulation performance is good across most of the scenes for both horizontal and vertical placements except for the 6-th scene where the classifier predicts all candidates as unstable hence no attempts have been made by the robot. \subsection{Discussion} Simply putting the block along the center of mass (COM) of the given structure may often be a feasible option, yet, there are two limitations to this approach: first, it is nontrivial to compute the COM of a given structure; second, it only gives one possible stable solution (assuming it actually stay stable). In comparison, our method does not rely the COM of the structure and provide a search over multiple possible solutions. So far, we have successfully applied our visual stability prediction model to guide the stable placement of a single block onto the existing structure. However, this approach has its own limitations. Firstly, it only deals with one manipulation step and does not take into account the interaction process which is also under physics constraint. For instance, the block can collide with existing structure before its placement. Secondly, it is also not obvious how to extend the approach to plan a consecutive stacking of multiple blocks. In part II, we will explore an alternative approach to overcome these limitations. \section{Part II: Beyond Single Block Stacking --- Target Stacking} In this part, we look at a manipulation task beyond the single block placement as discussed in part I. We now seek solutions to plan the placement of multiple blocks and consider more complex interactions in physical environment. In particular, just like children stack blocks towards a certain blueprint, we further introduce the "target" into the stacking task so that the sequence of manipulations are planned to a achieve the target --- similar to planning. Yet we want to stay fully in an end-to-end learning approach -- concerning the perception, physics as well as the plan, where intuitive physics as well as plan execution is learned jointly. The extended block stacking task is called {\em target stacking\/}. In this task, an image of a target structure made of stacked blocks is provided. Given the same number of blocks as in the target structure, the goal is to reproduce the structure shown in the image. The manipulation primitives in this task include moving and placing blocks. This is inspired by the scenario where young children learn to stack blocks to different shapes given an example structure. We want to explore how an artificial agent can acquire such a skill through trial and error. \subsection{Task Description} For each task instance, a target structure is generated and its image is provided to the agent along with the number of blocks. Each of these blocks has a fixed orientation. The sequence of block orientations is such that reproducing the target is feasible. The agent attempts to construct the target structure by placing the blocks in the given sequence. The spawning location for each block is randomized along the top boundary of the environment. A illustrative sample for the task is shown in Figure~\ref{fig:tstack_demo}. \begin{figure} \centering \includegraphics[width=0.95\linewidth]{./t_stack_eg.pdf} \caption{Target stacking: Given a target shape image, the agent is required to move and stack blocks to reproduce it.} \label{fig:tstack_demo} \end{figure} \subsection{Task Distinction} The following characteristics distinguish this task from other tasks commonly used in the literature. \paragraph{Goal-Specific} A widely-used benchmark for deep reinforcement learning algorithm are the Atari games \citep{bellemare13arcade} that were made popular by \cite{mnih2013playing}. While this game collection has a large variety, the games are defined by a single goal or no specific goal is enforced at a particular point in time. For example in Breakout, the player tries to bounce off as many bricks as possible. In Enduro, the player tries to pass as many cars as possible while simultaneously avoiding cars. In the target stacking task, each task instance differs in the specific goal (the target structure), and all the moves are planned towards this goal. Given the same state, moves that were optimal in one task instance are unlikely to be optimal in another task instance with a different target structure. This is in contrast to games where one type of move will most likely work in similar scenes. This argument also applies to AI research platforms with richer visuals like VizDoom \citep{kempka2016vizdoom}. \paragraph{Longer sequences} Target stacking requires looking ahead over a longer time horizon to simultaneously ensure stability and similarity to the target structure. This is different from learning to poke \citep{agrawal2016learning} where the objective is to select a motion primitive that is the optimal next action. It is also different from the work by \cite{li2017visual} that reasons about the placement of one block. \paragraph{Rich Physics Bounded} Besides stacking to the assigned target shape the agent needs to learn to move the block without colliding with the environment and existing structure and to choose the block's placement wisely not to collapse the current structure. The agent has no prior knowledge of this. It needs to learn everything from scratch by observing the consequence (collision, collapse) of its actions. \subsection{Target Stacking Environment} Compared to the environment for visual stability prediction as a data generator, we now need more a more capable task environment supports the learning process with which the agent can interact. This requires us to significantly extend the implementation. The environment now implements a more dynamic system where different moves from the agent can lead to different consequences: when a block (not the last one for the episode) is placed stably in the scene, a new block should be spawned into the environment whereas if the block collapses the existing structure, the current episode is terminated so that a new one can be started. The key to react correctly under these different conditions is to detect them effectively. While we keep the essential parts of the task, at its current stage the simulated environment remains an abstraction of a real-world robotics scenario. This generally requires an integration of multiple modules for a full-fledged working system, such as \cite{toussaint2010integrated}, which is out of scope of this paper. An overview of the stacking environment is shown in Figure~\ref{fig:sim:targetStack_pipeline}. The environment is again implemented in Panda3D as the data generator described in the previous part. The block size follows a ratio of $l:w:h = 5:2:1$, where $l$,$w$,$h$ denote length, width and height respectively. For each episode, a target structure is randomly picked from a pool of structures and then the blocks are spawned according to the target. The agent moves the spawned block in the scene until the placement is done. During this process, if the agent's move causes the block to (1) move out over the boundary of the scene or (2) collide with existing structure (3) collapse the structure with the placement, the episode is terminated and a new episode can start. A new block is spawned upon the previous one is placed successfully till reaching the total number of blocks in the target. When all the blocks are placed in the scene, the environment determines if the agent achieves the assigned target structure. We ignore the impact during block placement and focus on the resulting stability of the entire structure. Once the block makes contact with the existing structure, it is treated as releasing the block for a placement. The physics simulation runs at $60Hz$. However considering the cost of simulation we only use it when there is contact between the moving block and the boundary or the existing structure. Otherwise, the current block is moving without actual physics simulation. \begin{figure} \centering \includegraphics[width=0.95\linewidth,keepaspectratio]{./targetStack_pipeline.pdf} \caption{Overview of design for the target stacking environment.} \label{fig:sim:targetStack_pipeline} \end{figure} \subsubsection{State Representation} To further reduce the appearance difference caused by varying perspective, the state in the stacking environment is rendered using orthographic projection. It is implemented by the \texttt{OrthographicLens} in Panda3D where parallel lines stay parallel and don't converge as shown in Figure~\ref{fig:sim:panda3d_orthographic}. This is in contrast with regular perspective camera used in the visual stability prediction environment as shown in Figure~\ref{fig:sim:panda3d_perspective}. \begin{figure} \centering \begin{subfigure}[b]{0.45\linewidth} \centering \includegraphics[width=1.\linewidth]{./panda3d_perspective.pdf} \caption{} \label{fig:sim:panda3d_perspective} \end{subfigure} \begin{subfigure}[b]{0.5\linewidth} \centering \includegraphics[width=1.\linewidth]{./panda3d_orthographic.pdf} \caption{} \label{fig:sim:panda3d_orthographic} \end{subfigure} \caption{Different perspective lens used in this thesis.(\protect\subref{fig:sim:panda3d_perspective}): Perspective projection. (\protect\subref{fig:sim:panda3d_orthographic}): Orthographic projection.} \label{fig:sim:lense} \end{figure} Additionally, as we consider the action in discrete space, namely \{left,right,down\} for the task, the state representation can also be formalized correspondingly as shown in Figure~\ref{fig:sim:targetStack_state}. The individual block size follows a ratio of $l:w:h = 5:2:1$, where $l$,$w$,$h$ denote length, width and height respectively. With the aforementioned orthographic camera, only length and height are preserved on the projected image with a ratio of $l:h=5:1$. Each action moves the block by a displacement of the block's height along its direction. Hence the state can be represented in a grid map of unit square cells with length of the block's height ($u$ in the image space). In actual implementation, the blocks have to be set with coordinates in continuous values, so a separate binary matrix is used to maintain the discrete representation of the state where $1$ denotes the block presence in the cell and $0$ otherwise. \begin{figure}[h] \centering \includegraphics[width=1.\linewidth,keepaspectratio]{./targetStack_state.pdf} \caption{State representation in the stacking environment} \label{fig:sim:targetStack_state} \end{figure} The environment can query both the rendered image from the camera and the grid map for the state's representation, though in our current experiments, we use mostly the grid map for a simplified representation. Another benefit from the grid map representation is that it can be used as a occupancy map which is crucial for our implemented collision detection mechanism discussed in the next subsection. \subsubsection{Collision and Stability Detection} As the block is maneuvered in the environment, it will eventually make contact with the scene. The occurrence of contact marks an important transition of the state for the environment. As shown in Figure~\ref{fig:sim:targetStack_detection}: \begin{figure}[h] \centering \includegraphics[width=.9\linewidth,keepaspectratio]{./targetStack_detection.pdf} \caption{Process of collision and stability detection} \label{fig:sim:targetStack_detection} \end{figure} If the contact is made by a block from above (vertical), it suggests a placement \footnote{In our environment, we simplify the release movement from the real world block placement, i.e. the block is deemed to be released once it makes vertical contact with the scene, either the ground or the structure in the scene.}, then physics simulation is called to obtain the stability. The stability detection is implemented the same way as the one used in the data generator for visual stability prediction. Here the simulation only activates upon vertical contact is detected to save runtime. If the block remains stable in the scene and is not the last block for the episode, a new block is then spawned at the top of the scene with random horizontal location. If the block is the final one and remains stable or it collapses the structure in the scene, then the current episode is terminated and a new episode can be started. If the contact is made by a horizontal movement, it will not directly affect the current episode. If an additional move causes the collision, then the episode will be terminated, otherwise the block can be moved further until either vertical contact happens, it goes into the simulation and stability-detection branch or collision and terminated. Note if the block is about to move out of the view of the camera, it is also considered a sub-type of collision. This is implemented straightforwardly by comparing the block's incoming location with the boundary of the scene. The contact and collision detection are implemented with the grid map representation described in the previous subsection as shown in Figure~\ref{fig:sim:targetStack_detection_detail}. We keep two grid map for each episode, one for the existing structure in the scene (\textbf{background map}) and the other for the moving block (\textbf{foreground map}). A state (grid map) is internally represented as the summation of the background map and foreground map. Given a state and a specified action, the system will compute the incoming foreground map after the action, if the incoming foreground map overlaps with the background map, then collision is detected as shown in Figure~\ref{fig:sim:targetStack_collisionDetect}; if any of the adjacent cells below the block in the incoming foreground map is non-empty in the incoming grid map, then a vertical contact is detected as shown in Figure~\ref{fig:sim:targetStack_contactDetect}. \begin{figure} \centering \begin{subfigure}{0.98\linewidth} \centering \includegraphics[width=1.\linewidth]{./targetStack_contactDetect.pdf} \caption{} \label{fig:sim:targetStack_contactDetect} \end{subfigure} \begin{subfigure}{0.98\linewidth} \centering \includegraphics[width=1.\linewidth]{./targetStack_collisionDetect.pdf} \caption{} \label{fig:sim:targetStack_collisionDetect} \end{subfigure} \caption{Internal representation to detect contact and collision conditions: (\protect\subref{fig:sim:targetStack_contactDetect}) Detect vertical contact. (\protect\subref{fig:sim:targetStack_collisionDetect}) Detect collision.} \label{fig:sim:targetStack_detection_detail} \end{figure} \subsubsection{Interface Design} \begin{figure} \centering \includegraphics[width=.98\linewidth,keepaspectratio]{./targetStack_oop.pdf} \caption{Interface design for the environment with interaction of the agent.} \label{fig:sim:targetStack_oop} \end{figure} With recent progress in reinforcement learning, there is an increasing need for the standardized benchmarks for different learning agents. To this end, OpenAI recently introduced Gym \citep{brockman2016openai} to provide access to a standardized set of environments, such as Atari games and board games. By encapsulating the environment's internal mechanism from the agent, different agents can be evaluated on the environment with minimal modification. We also adopt a similar design in our environment. The diagram in Figure~\ref{fig:sim:targetStack_oop} shows part of the design of the environment with interactions with an agent. The agent's \texttt{act} method takes the current state from the environment, decides its action and pass the decision to the environment. The \texttt{step} method receives the action from the agent and updates the environment's state. The \texttt{reward\_shape} method evaluates the current state and transforms the reward with specific designs. Then the pair of states before and after the action, together with the reward, are input to the \texttt{update} method of the agent to update its parameter depending on different learning algorithms. \subsection{Goal-Parameterized Deep Q Networks (GDQN)} As one major characteristic of this task is that it requires goal-specific planning: given the same or similar states under different objectives, the optimal move can be different. To this end, we extend the typical reinforcement learning formulation to incorporate additional goal information. \subsubsection{Learning Framework} In a typical reinforcement learning setting, the agent interacts with the environment at time $t$, observes the state $s_t$, takes action $a_t$, receives reward $r_t$ and transits to a new state $s_{t+1}$. A common goal for a reinforcement learning agent is to maximize the cumulative reward. This is commonly formalized in form of a value function as the expected sum of rewards from a state $s$, $\mathbf{E}[\sum\limits_{i=0}^T \gamma^i r_{t+i+1}|s_t = s,\pi]$ when actions are taken with respect to a policy $\pi(a|s)$, with $0\leq\gamma\leq 1$ being the discount factor, T for the final time step. The alternative formulation to this is the action-value function $Q^\pi(s,a)=\mathbf{E}[\sum\limits_{i=0}^T \gamma^i r_{t+i+1}|s_t=s,a_t=a]$. Value-based reinforcement learning algorithms, such as Q-learning \citep{watkins1992q} directly search for optimal Q-value function. Recently by incorporating deep neural network as a function approximator for $Q$-function, the DQN \citep{mnih2015human} has shown impressive results across a variety of Atari games. \paragraph{DQN} For our task, we apply a {\em Deep Q Network\/} (DQN) which uses a deep neural network for approximating the action-value function $Q(s,a;\theta)$, mapping from an input state $s$ and action $a$ to Q values. In particular, two important improvements have been proposed by \cite{mnih2015human} for the learning process, including (1) experience replay, the agent stores observed transitions in a memory buffer for some time, and uniformly samples from the memory to update the network (2) the target network, agent maintains two networks for the loss function --- one for the current estimator of Q function and one for the surrogate of the true Q function. For the current estimator, the parameters are constantly updated. For the surrogate, the parameters are only updated for every certain number of steps from the current estimator network otherwise kept fixed. \paragraph{Learning Goal-Parameterized Policies} To plan with respect to the specific goal, we can parametrize the agent's policy $\pi$ by the goal $g$: \begin{equation} \pi(s,g,a) \end{equation} Since in this work, we applies DQN as value-based method, this corresponds to the update to original Q function with the additional goal information. The new Q-value function is hence defined as: \begin{equation} Q^\pi(s,g,a) = \mathbf{E}[\sum\limits_{i=0}^T \gamma^i r_{t+i+1}|s_t=s,g,a_t=a] \end{equation} As shown in Figure~\ref{fig:goal_net}, in contrast to the original DQN model, where state and action are used to estimate Q-value, the new model further include the current goal into the network to produce the estimate. We call this model as Goal-Parametrized Q Network (GDQN). The resulted loss function is as: \begin{equation} L_Q = \mathbf{E}[(R + \gamma \text{max}_a' Q^\pi(s',g,a';\theta^-) - Q(s,g,a;\theta))^2 ] \end{equation} where $\theta^-$ are the previous parameters and the optimization is with respect to $\theta$. \begin{figure} \centering \includegraphics[width=0.85\linewidth]{./qg-net_rev.pdf} \caption{Our proposed model GDQN which extends the $Q$-function approximator to integrate goal information.} \label{fig:goal_net} \end{figure} \subsubsection{Implementation Details} The DQN agent is implemented in Theano and Keras to adapt to the settings in our experiment, while we use a $2$ hidden layer (each with $64$ hidden units and rectified linear activation) multilayer perceptron (MLP) for most cases, we additionally swap the MLP with the CNN and follow the reported parameter settings as in the original paper \citep{mnih2015human} to ensure our implementation can reach similar performance. Note we don't apply the frame-skipping technique \citep{bellemare2012investigating} used for Atari games \citep{mnih2015human} allowing the agent sees and selects actions on every $k$th frame where its last action is repeated on skipped frames. It does not suit our task, in particular when the moving block is getting close to the existing structure, simply repeating action decided from previous frame can cause unintended collision or collapse. \paragraph{Reward} In the target stacking task, the agent gets reward $+1$ when the episode ends with complete reproduction of the target structure, otherwise $0$ reward. Further, we explore reward shaping \citep{ng1999policy} in the task providing more prompt intermediate reward. Two types of reward shaping are included: overlap ratio and distance transform. For the overlap ratio, for each state $s_t$ under the same target $g_i$, an overlap ratio is counted as the ratio between the intersected foreground region (of the current state and the target state) and the target foreground region (shown in Figure~\ref{fig:overlap_ratio}): \begin{equation}\label{eq:ovl} o(s_t,g_i) = \frac{s_t \cap g_i}{g_i} \end{equation} For each transition $(s_t, a_t, s_{t+1})$, the reward is defined by the change of overlap ratio before and after the action: \begin{equation} r_t = \begin{cases} 1, & \text{if}\ \Delta o_{t\rightarrow t+1} = o(s_{t+1}) - o(s_t) > 0 \\ -1, & \text{if}\ \Delta o_{t\rightarrow t+1} = o(s_{t+1}) - o(s_t) < 0\\ 0, & \text{otherwise} \end{cases} \end{equation} The intuition is that actions increasing the current state to become more overlapped with the target scene should be encouraged. For the distance transform \citep{fabbri20082d}, it generates a map $D$ whose value in each pixel $p$ is the smallest distance from it to a target object $O$: \begin{equation} D(p) = \text{min}\{\text{dist}(p,q)|q\in O\} \end{equation} where $\text{dist}$ can be any valid distance metric, like Euclidean or Manhattan distance. For each state $s_t$ under the same target $g_i$, a distance to the goal is the sum of all the element-wise distance in $s_t$ to $g_i$ under $D_{g_i}$ (shown in Figure~\ref{fig:dist_transform}) as: \begin{equation} d(s_t,g_i) = \sum_j D_{g_i}(s_t^j), s_t^j \in s_t \end{equation} For each transition $(s_t, a_t, s_{t+1})$, the reward is defined as: \begin{equation} r_t = \begin{cases} 1, & \text{if}\ \Delta d_{t\rightarrow t+1} = d(s_{t+1}) - d(s_t) < 0 \\ -1, & \text{if}\ \Delta d_{t\rightarrow t+1} = d(s_{t+1}) - d(s_t) > 0\\ 0, & \text{otherwise} \end{cases} \end{equation} The intuition behind this is that action decreasing the distance between the current state and the target scene should be encouraged. \begin{figure} \centering \begin{subfigure}{0.47\linewidth} \includegraphics[width=\textwidth]{./ovl_ratio.pdf} \caption{} \label{fig:overlap_ratio} \end{subfigure} ~ \begin{subfigure}{0.47\linewidth} \includegraphics[width=\textwidth]{./dist_transform.pdf} \caption{} \label{fig:dist_transform} \end{subfigure} \caption{Reward shaping used in target stacking. (\protect\subref{fig:overlap_ratio}): overlap ratio to the target. The gray area in the middle figure denotes the intersected foreground region between current and target scene, and the overlap ratio is the ratio between the areas of the two. (\protect\subref{fig:dist_transform}): distance under the distance transform of the target. The middle figure denotes the distance transform under the target shown in the left. The distance from current scene to the target is the sum of distances masked by the current scene in the distance transform.} \label{fig:reward_shape} \end{figure} \subsubsection{Toy Example with Goal Integration} \begin{figure} \centering \begin{subfigure}[b]{0.25\linewidth} \centering \includegraphics[height=2.6cm]{./gridworld.pdf} \caption{} \label{fig:nav_sample} \end{subfigure \begin{subfigure}[b]{0.75\linewidth} \centering \begin{tabular}{c|cc} \toprule Grid Size & DQN & GDQN \\ \midrule $5\times 5$ & 0.67 & 0.97 \\ $7\times 7$ & 0.67 & 0.95 \\ \bottomrule \end{tabular} \caption{} \label{tab:gridworld_result} \end{subfigure} \caption{\protect\subref{fig:nav_sample}: Navigation task, each color denotes a different episode, per episode, a random pair of starting and goal location are generated, the agent needs to reach the goal. \protect\subref{tab:gridworld_result}: Results from navigation task. } \label{fig:nav} \end{figure} At first, we introduce a type of navigation task in the classic gridworld environment. As shown in Figure~\ref{fig:nav_sample}, for each episode, we generate a random start and goal point in the grid world whereas the start and the goal have to be different from each other, the agent has to find the way to this randomly generated goal. The agent is rewarded only when it reaches it. The agent needs to reach the goal with four possible actions $\{\text{left},\text{right},\text{up},\text{down}\}$. Action that will make the agent go off the grid will leave it stay in the same location. The episode only terminates once the agent reaches the goal. The agent only receive reward $+1$ when reaching the current goal. Two different sizes of gridworld are tested at $5\times5$ and $7\times7$. We learn a single model for each size of the mazes. The training epoch size is $1000$ in steps for the smaller gridworld and $3000$ for the larger one, the test sizes are the same for both at $100$. All the agents run for $100$ epochs and the $\epsilon$ for $\epsilon$-greedy anneals linearly from $1.0$ to $0.1$ over the first $20$ epochs, and fixed at $0.1$ thereafter. The memory buffer size is set the same to the annealing length, i.e. for the smaller gridworld, the buffer size equals to the length $20$ epochs in training with $20000$ steps whereas for the larger one, the buffer size is $30000$ steps. We measure the proportion of episodes in the test epoch that reaches the goal in shortest distance as the success ratio. The results are shown in Table~\ref{tab:gridworld_result} for the best agents throughout the training process. As in this simple task with relative small state space, DQN gets some performance due to running an average policy across all the the goals, but this is not addressing the task we set out to do. In contrast, GDQN parametrized specifically to include goal information achieves significant better results on both sizes of the environment. \subsubsection{Target Stacking} \begin{table*} \centering \begin{tabular}{@{}clccccccccccc@{}} \toprule \multicolumn{2}{c}{\multirow{2}{*}{Num. of Blks.}} & \multicolumn{2}{c}{DQN} & & \multicolumn{2}{c}{GDQN} & & \multicolumn{2}{c}{GDQN + OR} & & \multicolumn{2}{c}{GDQN + DT} \\ \cmidrule(lr){3-4} \cmidrule(lr){6-7} \cmidrule(lr){9-10} \cmidrule(l){12-13} \multicolumn{2}{c}{} & OR & SR & & OR & SR & & OR & SR & & OR & SR \\ \midrule \multicolumn{2}{c}{2} & 0.70 & 0.70 & & 0.82 & 0.72 & & 0.84 & 0.77 & & {\bf 0.88} & {\bf 0.78} \\ \multicolumn{2}{c}{3} & 0.43 & 0.43 & & 0.76 & {\bf 0.67} & & {\bf 0.86} & 0.63 & & 0.83 & 0.65 \\ \multicolumn{2}{c}{4} & 0.03 & 0.0 & & 0.41 & 0.17 & & 0.73 & 0.55 & & {\bf 0.79} & {\bf 0.56} \\ \bottomrule \end{tabular} \caption{Results for target stacking. For ``GDQN + X'', X denotes different ways for reward shaping as described in previous section, OR for overlap ratio, DT for distance transform. For metrics, OR stands for average overlap ratio, SR for average success rate.} \label{tab:tgt_stack} \end{table*} We set up $3$ groups of target structures consisted of different number of blocks $\{2,3,4\}$ in the scene as shown in Figure~\ref{fig:tgt_stack}. Within each group of target shapes, a random target (with the accompanied orientation order) is first picked at the very beginning for individual episode and then each block is spawned at randomized location as described earlier in the target stacking environment. Each training epoch consists of $10000$ steps and each test epoch with $1000$ steps. Similar to the setting in the toy example, all the agents run for $100$ epochs and the $\epsilon$ anneals for the first $20$ epochs, and the memory buffer size is set as long as the annealing steps at $200K$ steps. \begin{figure} \centering \begin{subfigure}[b]{0.42\linewidth} \includegraphics[width=\textwidth]{./2blks_stack_targets.pdf} \caption{} \label{fig:2blks_tgt_stack} \end{subfigure} ~ \begin{subfigure}[b]{0.42\linewidth} \includegraphics[width=\textwidth]{./3blks_stack_targets.pdf} \caption{} \label{fig:3blks_tgt_stack} \end{subfigure} ~ \begin{subfigure}[b]{0.42\linewidth} \includegraphics[width=\textwidth]{./4blks_stack_targets.pdf} \caption{} \label{fig:4blks_tgt_stack} \end{subfigure} \caption{\protect\subref{fig:2blks_tgt_stack}: Targets for $2$ blocks.\protect\subref{fig:3blks_tgt_stack}: Targets for $3$ blocks. \protect\subref{fig:4blks_tgt_stack}: Targets for $4$ blocks.} \label{fig:tgt_stack} \end{figure} We computed both average overlap ratio (OR) and success rate (SR) for the finished stacking episodes in each test epoch. Here overlap ratio is the same as defined in the reward shaping in Equation~\ref{eq:ovl}, but simply measures the end scene over the assigned target scene. This tells the relative completion of the stacked structure in comparison to the assigned target structure, the higher the value is, the better completion it is to the target. At the maximum of $1$, it suggests completely reproduction of the target. The success rate counts the ratio how many episodes complete the exact same shape as assigned over the total number of episodes finished in the test epoch. This is the absolute metric counting overall successful stacking. The results are shown in Table~\ref{tab:tgt_stack} for the best agents throughout the training process. Over all groups on both metrics, we observe GDQN outperforms DQN, showing the importance of integrating goal information. In general, the more blocks in the task, the more difficult it becomes. When there are only small number of blocks ($2$ blocks and $3$ blocks) in the scene, the single policy learned by DQN averages over the few target shapes can still work to some extent. However when introducing more blocks into the scene, it becomes more and more difficult for this averaged model to handle. As we can see from the result, there is already a significant decrease of performance (success rate drops from $0.70$ to $0.43$) when increasing the blocks number from $2$ to $3$, whereas GDQN's performance only decreases slightly from $0.72$ to $0.67$. In $4$ blocks scene, the DQN can no longer reproduce any single target ($0.0$ for success rate, $0.03$ for overlap ratio) while GDQN parametrized specifically to include goal information can still do. Though the success rate (absolute completion to the target) for the basic GDQN is relatively low at $0.17$ but the average overlap ratio (relative completion to the target) still holds up pretty well at $0.41$. Also we see reward shaping can further improves GDQN model, in particular distance transform can boost the performance more than overlap ratio. \begin{figure} \addtolength{\tabcolsep}{-3.5pt} \begin{center}$ \begin{tabular}{cccc} \label{fig:hstack1}\includegraphics[width=0.17\linewidth]{./hstack_1.png}& \label{fig:hstack2}\includegraphics[width=0.17\linewidth]{./hstack_2.png}& \label{fig:hstack3}\includegraphics[width=0.17\linewidth]{./hstack_3.png}& \label{fig:hstack4}\includegraphics[width=0.17\linewidth]{./hstack_4.png}\\ \end{tabular}$ \end{center} \addtolength{\tabcolsep}{3.5pt} \vspace{-0.4cm} \caption{Example scenes constructed by the agent.} \label{fig:scene_sample} \end{figure} \vspace{-0.4cm} \section{Conclusion} In this work, we answer the question if and how well we can build up a machinery to learn a manipulation task under physics constraints with visual perception. In particular, We focus on a wood block stacking problem and explored frameworks from two inter-related but different perspectives. In the first part of the work, we aim to guide the robot to stably place a single block in the scene. To achieve this, we envision a mechanism of explicit physics understanding to predict physical stability directly from visual input, bypassing explicit 3D representations and physical simulation. We initially evaluate our model on a synthetic dataset, covering a range of conditions including variations in number of blocks, size of blocks and 3D structure of the overall tower. The results reflect the challenges of inference with growing complexity of the structure. To further understand the results, we conduct a human subject study on a subset of our synthetic data and show that our model achieves comparable or even better results than humans in the same setting. Moreover, we investigate the discriminative image regions found by the model and spot correlation between such regions and initial collapse area in the structure. Finally, We apply our approach to a block stacking setting and show that our model successfully guide a robot for placements of new blocks by predicting the stability of future states. In the following part of the work, we explore further on a more challenging target stacking task where the agent stacks blocks to reproduces a tower shown in an image. It presents a distinct type of challenge requiring the agent to reach a given goal state that may be different for every new trial. To this end, we propose an alternative framework where the manipulation is learned end-to-end through pure trial and error, bypassing the explicitly modeling for the corresponding physics knowledge as we did in the previous task. We create a synthetic block stacking environment with physics simulation in which the agent can interactively stack the block. In particular, we propose a goal-parametrized GDQN model to plan with respect to the specific goal, allowing better generalization across different goals. We validate the model on both a navigation task in a classic gridworld environment with different start and goal positions and the block stacking task itself with different target structures.
{'timestamp': '2019-04-23T02:25:57', 'yymm': '1904', 'arxiv_id': '1904.09860', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.09860'}
arxiv
\section{Introduction}\label{sect.intro} Due to the potential large bandwidth and no electromagnetic radiation, optical wireless communication shows great promise for the future wireless communications \cite{gagliardi1976optical}. On some specific occasions where the conventional RF is prohibited and direct link transmission cannot be guaranteed, non-line-of-sight (NLOS) optical scattering communication, typically in the ultra-violet spectrum, can be adopted to guarantee communications requirement \cite{xu2008ultraviolet}. For the NLOS communication, the transmitter and receiver are not required to be perfectly aligned, which expands the application range beyond the LOS links. Hence, it is difficult to to detect the received signals using a conventional continuous waveform receiver, such as photondiode (PD) and avalanche photondiode (APD). Instead, a photon-counting receiver is widely deployed, including photomultiplier tube (PMT) as well as single photon avalanche diode (SPAD). Poisson channel, whereby the arrival of photons is recorded by photon-sensitive devices incorporated in the receivers, is often used to model free-space optical (FSO) and optical scattering communication. For perfect photon-counting receiver, recent works mainly focus on point-to-point capacity under various scenarios, such as single transmitter \cite{wyner1988capacity,frey1991information}, multiple transmitters \cite{chakraborty2008outage} in continuous-time \cite{shamai1993bounds} and discrete-time \cite{lapidoth2009capacity,lapidoth2011discrete,wang2014refined}. For multiple users scenario, recent works focus on the Poisson broadcast channel \cite{lapidoth2003wide}, the Poisson multiple-access channel (MAC) \cite{lapidoth1998poisson}, and the Poisson interference channel capacity \cite{lai2015capacity}. Moreover, the communication system optimization and corresponding signal processing \cite{el2012binary,jiang2019clipping,gong2015non,ardakani2017performance} have also been extensively studied. Considering the practical characterization of photon-counting devices, perfect photon-counting receiver assumption is impractical. For example, a typical photon-counting receiver applied in many optical communication scenarios \cite{chitnis2014spad} includes a photomultiplier tube (PMT) as well as the subsequent sampling and processing blocks \cite{becker2005advanced} or single photon avalanche diode (SPAD) with quenching circuit. Specifically, when a photon is captured by receiver, the square pulses subsequently generated by pulse-holding circuits typically have positive width that incurs dead time effect \cite{cherry2012physics}, where a photon arriving during the pulse duration of the previous photon cannot be detected due to the merge of two pulses.The longest time difference of two unrecognized photons is defined as dead time. The photon-counting system with dead time effect for infinite sampling rate and finite sampling rate with shot noise have been investigated in optical wireless communication \cite{sarbazi2018statistical,zou2018characterization}, which shows sub-Poisson distribution of photon counting. In addition, the achievable rate for on-off keying (OOK) modulation and capacity with non-perfect photon-counting receiver are investigated in \cite{jiang2019achievable,jiang2019achievablecapa}. However, The multiuser capacity with non-perfect receiver is still unknown. In this paper, we investigate the sum-rate capacity of multiple input single output (MISO) multiple access channel (MAC) with non-perfect receiver, assuming negligible electrical thermal noise and shot noise. We first study two-user single-transmitter nonsymmetric sum-rate capacity, which the peak power of two users are not necessary the same, and show that the optimal input signal is two-level piece-wise constant waveform. This scenario naturally arises in multiuser optical communications when the transmitters have different distances to the receiver or have different transmission powers. Similar to work \cite{lai2017sum}, we resort to Karush-Kuhn-Tucker (KKT) condition to solve the non-convex duty cycle optimization problem and obtain at most four candidate solutions wherein two candidate solutions corresponds to the cases of only one active user. We further investigate the optimal transmission strategy, corresponding to different possible solutions, for different peak power of each user and give the sufficient condition of each transmission strategy. In particular, we investigate two-user symmetric Poisson channel by two methods based on KKT condition and majorization, both demonstrating that the optimal duty cycle of two users are the same and unique. The last method based on majorization maybe can extend to the case of multiple symmetric users. We then extend the study to Poisson MAC with multiple transmitters at each user. Similarly to the Poisson SISO-MAC, the complex continuous-input discrete-output Poisson MAC can be converted to a discrete-time binary-input binary-output Poisson MAC. However, the joint distribution problem is still challenging since the exponential parameters $2^{J_1}+2^{J_2}$, where $J_1$ and $J_2$ are the total number of transmitters for user $1$ and $2$, respectively. We show that Poisson MISO-MAC capacity equals to Poisson SISO-MAC capacity under certain condition by two steps. The first step is to optimize joint distribution of each user given duty cycle of each transmitter and reduce the dimension from $2^{J_1}+2^{J_2}$ to $J_1+J_2$. The last step is to optimize duty cycle of each transmitter and further reduce the dimension from $J_1+J_2$ to $2$. The key ingredient is to show that, all antennas at each transmitter being simultaneously on or off achieve the optimality. The remainder of the paper is organized as follows. Section~\ref{sect.sysmodel} describes the model under consideration. Section~\ref{sect.sisomac} and Section~\ref{sect.sisomac2} analyzes the Poisson nonsymmetric and symmetric SISO-MAC capacity, respectively. Section~\ref{sect.misomac} analyzes the Poisson Poisson MISO-MAC. Numerical analysis is presented in Section~\ref{sect.numresult} and concluding remarks are presented in Section~\ref{sect.conclusion}. \section{System Model}\label{sect.sysmodel} We introduce the following notations that will be used throughout this paper. Random variables and vectors are denoted by upper-case letters and bold uppercase letters, respectively. We use notation $X_i^j$ to denote a sequence of random variables $\{X_i, X_{i+1},\cdots,X_j\}$; and for $i = 1$, we use $X_{[j]}=\{X_1,\cdots,X_j\}$. A continuous time random process $\{\Lambda(t),a\leq t\leq b\}$ is denoted in short by $\Lambda^b_a$; when $a = 0$, we use $\Lambda^b = \{X(t),0\leq t\leq b\}$. Realizations of random variables and random processes, denoted in lowercase letters, follow the same convention. Consider multiple users communicating to a single non-perfect receiver. Assume $M$ users, where user $m$, $m=1,\cdots,M$, is equipped with $J_m$ transmitters. Let $\Lambda_{mj}(t)$ denotes the $\mathbb{R}_0^+$-valued photon arrival rate at time $t$ from the $j^{th}$ transmitter of the $m^{th}$ user, and $Y(t)$ denote the Poisson photon arrival process observed at the receiver and \begin{eqnarray} Y(t)=\mathcal{P}\Big(\sum_{m=1}^{M}\sum_{j=1}^{J_m}\Lambda_{mj}(t)+\Lambda_0\Big), \end{eqnarray} where $\Lambda_0$ is the background radiation, and $\mathcal{P}(\cdot)$ is the Poisson process that records the timing instants and number of photon arrivals. In particular, for any time interval $[t-\tau, t]$, the probability of $k$ photons arriving at the receiver is given by \begin{eqnarray} \mathbb{P}\{Y(t)-Y(t-\tau)=k\}=\frac{1}{k!}e^{-X_t}(X_t)^k,\quad k=0,1,\cdots, \end{eqnarray} where $X_t=\sum_{m=1}^{M}\sum_{j=1}^{J_m}\int_{t-\tau}^{t}\Lambda_{mj}(t^{'})\mathrm{d}t^{'}$, the arrival rate $\Lambda$ is given by $\Lambda=\frac{P}{h\nu_0}$, where $P$, $h$ and $\nu_0$ denote the transmitted optical power, the Planck’s constant and the optical spectrum frequency, respectively, such that the energy per photon is given by $h\nu_0$. Thus, the photon arrival rate $\Lambda_{mj}(t)$ must satisfy the following peak power constraint: \begin{eqnarray}\label{eq.const1} 0\leq\Lambda_{mj}(t)\leq A_{mj}, \end{eqnarray} where $A_{mj}$ is related to the corresponding maximum power allowed by the $j^{th}$ transmitter of the $m^{th}$ user. In practice, LEDs or lasers are adopted as the transmitter, where the peak power is limited such that the peak constraint is more of interest than the average power constraint. Assuming perfect photon-counting receiver, each photon and the corresponding arrival time can be detected without error. However, perfect photon-counting receiver is difficult to realize and a practical receiver with finite sampling rate consisting of a PMT detector, an one-bit ADC, and a digital signal processor (DSP) unit is considered. When a photon arrives, the PMT detector generates a pulse with certain width, which causes pulses-merge if the interval of two photons arrival time is shorter than the pulse width. The threshold of arrival time interval where the two photons are not differentiable is called dead time, denoted as $\tau$. Denote $T_s$ as the ADC sampling interval and assume low to medium sampling rate such that $T_s\geq\tau$. Considering finite time input $\Lambda_{[MJ]}^T$, the PMT sampling sequence $\mathbf{Z}_{[L]}\stackrel{\triangle}{=}\{Z_1,\cdots,Z_L\}$, where $L\stackrel{\triangle}{=}\lfloor\frac{T}{T_s}\rfloor$. Note that for any $\tau>0$, the number of photon arrivals $N_{\tau}$ on $[0,\tau]$ together with the corresponding (ordered) arrival time instants $\mathbb{T}^{N_{\tau}}=(T_1,\cdots,T_{N_{\tau}})$ are sufficient statistic for $Y^{\tau}$ such that the random vector $(N_T,\mathbb{T}^{N_T})$ is a complete description of random process $Y^T$. For the practical photon-counting receiver under consideration, assume zero shot noise, thermal noise and finite dead time. For one or multiple photons arriving at the photon-counting receiver at $(iT_s-\tau,iT_s]$, the sampling value $Z_i$ is the same due to the self-sustaining avalanche in SPAD or the shaping circuit that converts bell-shaped response into rectangular response for photon-counting \cite{sarbazi2018statistical,zou2018characterization}. According to above statement, we have \begin{eqnarray} Z_i=\left\{\begin{array}{ll} 0,&T_j\notin(iT_s-\tau,iT_s],\forall j=1,\cdots,N_T; \\ 1,&otherwise; \end{array}\right. \end{eqnarray} where $\mathbb{P}(Z_i=1)=1-e^{-X_{iT_s}}$ and $Z_i$ and $Z_j$ are independent identically distributed for $i\neq j$ due to the property of independent increment for Poisson process. In other words, $Z_i$ is an indicator on whether one or more photons arrive within $\tau$ prior to the sampling instant. Based on above mentioned system model, the multi-user MISO Poisson channel capacity is defined as \begin{eqnarray} C_{MU-MISO}=\lim\limits_{T\to\infty}\max\limits_{\Lambda_{mj}^T\in[0,A_{mj}]}\frac{1}{T}I(\Lambda_{[MJ]}^T;\mathbf{Z}_{[L]}), \end{eqnarray} Since $\Lambda_{[MJ]}^T\rightarrow(N_T,\mathbf{T}^{N_T})\rightarrow\mathbf{Z}_{[n]}$ forms a Markov chain, we have $I(\Lambda_{[MJ]}^T;\mathbf{Z}_{[n]})\leq I(\Lambda_{[MJ]}^T;N_T,\mathbf{T}^{N_T})$, which shows that the multi-user MISO Poisson capacity with non-perfect receiver is not more than that of continuous-time multi-user MISO Poisson channel. According to the chain rule for mutual information, we have \begin{eqnarray} \frac{1}{T}I(\Lambda_{[MJ]}^T;\mathbf{Z}_{[L]})&=&\frac{1}{T}\sum_{l=1}^{L}I(\Lambda_{[MJ],(l-1)T_s}^{lT_s};Z_{l}|\Lambda_{[MJ]}^{(l-1)T_s};\mathbf{Z}_{[l-1]})\nonumber\\ &=&\frac{1}{T}\sum_{l=1}^{L}H(Z_{l}|\Lambda_{[MJ]}^{(l-1)T_s};\mathbf{Z}_{[l-1]})-H(Z_{l}|\Lambda_{[MJ]}^{lT_s};\mathbf{Z}_{[l-1]})\nonumber\\ &\overset{(a)}{=}&\frac{1}{T}\sum_{l=1}^{L}H(Z_{l}|\Lambda_{[MJ]}^{(l-1)T_s};\mathbf{Z}_{[l-1]})-H(Z_{l}|\Lambda_{[MJ],(l-1)T_s}^{lT_s})\nonumber\\ &\leq&\frac{1}{T}\sum_{l=1}^{L}H(Z_{l})-H(Z_{l}|\Lambda_{[MJ],(l-1)T_s}^{lT_s})=\frac{1}{T}\sum_{l=1}^{L}I(\Lambda_{[MJ],(l-1)T_s}^{lT_s};Z_{l}). \end{eqnarray} Where equality (a) holds since $Z_{l}$ is conditional independent of $(\Lambda_{[MJ]}^{(l-1)T_s};\mathbf{Z}_{[l-1]})$ given $\Lambda_{[MJ],(l-1)T_s}^{lT_s}$. Thus, we have $C_{MU-MISO}\leq\max\limits_{\Lambda_{mj}^{T_s}\in[0,A_{mj}]}\frac{1}{T_s}I(\Lambda_{[MJ]}^{T_s};\mathbf{Z}_{1}),$ where the equality holds if $\Lambda_{[MJ],(l-1)T_s}^{lT_s}$ is dependent of each other for different $l$. Consequently, the capacity-achieving distribution requires independent input signals for different sampling intervals, and the simplified capacity is given by, \begin{eqnarray}\label{eq.capacall} C_{MU-MISO}=\max\limits_{\Lambda_{mj}^{T_s}\in[0,A_{mj}]}\frac{1}{T_s}I(\Lambda_{[MJ]}^{T_s};\mathbf{Z}_{1}). \end{eqnarray} In the remainder of this paper, we omit subscript $l$ for simplicity since we focus the achievable rate within a symbol duration to obtain the exact capacity. \section{SISO Capacity for Two Users}\label{sect.sisomac} We focus on the case where each user has only one transmitter, i.e., $J_1 = 1$ and $J_2 = 1$. Hence for the sake of convenience, we drop subscript $j$ and use abbreviation $p_1=p(A_1+A_2+\Lambda_0)$, $p_2=p(A_2+\Lambda_0)$, $p_3=p(A_1+\Lambda_0)$, and $p_4=p(\Lambda_0)$. \subsection{Optimality Conditions} The sum-rate capacity is defined as $C_{SISO-MAC}\stackrel{\triangle}{=}\max\limits_{\Lambda^{\tau}_{m}\in[0,A]}\frac{1}{T_s}I(\Lambda^{T_s}_{[M]};Z)$. The following results show that the optimal distributions belongs to binary signal levels. \begin{theorem}\label{theo.sisomacbi} The sum-rate capacity of a Poisson MAC with non-perfect receiver is achieved if the input signal belongs to the set $\{0,A_m\}$ for each user $m$. \begin{proof} Please refer to Appendix \ref{appen.sisomacbi}. \end{proof} \end{theorem} Although focusing two-users MAC channel, Theorem \ref{theo.sisomacbi} can be extended to scenario of multiple users. Let $\mu_m$ be the duty cycle of the $m^{th}$ transmitter, $m=1,2$. The sum-rate Poisson MAC capacity is given by \begin{eqnarray}\label{eq.sisomaccapa} C_{SISO-MAC}=\max\limits_{0\leq\mu_1,\mu_2\leq1}\frac{1}{\tau}I_{X_1^2;Z}(\mu_1,\mu_2), \end{eqnarray} where \begin{eqnarray} I_{X_1^2;Z}(\mu_1,\mu_2)&=&h_b(\hat{p}(\mu_1,\mu_2))-\mu_1\mu_2h_b(p_1)-(1-\mu_1)\mu_2h_b(p_2)\nonumber\\&&-\mu_1(1-\mu_2)h_b(p_3)-(1-\mu_1)(1-\mu_2)h_b(p_4),\\ \hat{p}(\mu_1,\mu_2)&=&\mu_1\mu_2p_1+(1-\mu_1)\mu_2p_2+\mu_1(1-\mu_2)p_3+(1-\mu_1)(1-\mu_2)p_4, \end{eqnarray} For the problem (\ref{eq.sisomaccapa}), we have the following property. \begin{lemma}\label{lemmal.sisomacnonconacve} Assume that $\tau\leq\frac{\ln2}{A_1+A_2+\Lambda_0}$. For general values of $A_1,A_2$ and $\Lambda_0$, $I_{X_1^2;Z}(\mu_1,\mu_2)$ is not necessarily a concave function of $(\mu_1,\mu_2)$. In addition, the optimized joint distribution set is not convex. \begin{proof} Please refer to Appendix \ref{appen.sisomacconcave}. \end{proof} \end{lemma} According to Lemma \ref{lemmal.sisomacnonconacve}, Problem (\ref{eq.sisomaccapa}) is a non-convex optimization problem in general. We focus on solving such non-convex optimization problem. We start with the necessary KKT conditions (since the problem is not convex, these conditions are not sufficient for optimality). For convenience, we write $I_{X_1^2;Z}=I$, and thus the corresponding Lagrangian equation is given by, \begin{eqnarray} \mathcal{L}=-I+\eta_1(\mu_1-1)-\eta_2\mu_1+\eta_3(\mu_2-1)-\eta_4\mu_2. \end{eqnarray} The optimal solution $(\hat{\mu}_1,\hat{\mu}_2)$ must satisfy the following KKT constraints: \begin{eqnarray} \frac{\partial I}{\partial \mu_1}|_{(\hat{\mu}_1,\hat{\mu}_2)}-\eta_1+\eta_2=0,\label{eq.sisomackkt1}\\ \frac{\partial I}{\partial \mu_2}|_{(\hat{\mu}_1,\hat{\mu}_2)}-\eta_3+\eta_4=0,\label{eq.sisomackkt2}\\ \eta_1(\hat{\mu}_1-1)=0, \eta_2\hat{\mu}_1=0, \eta_3(\hat{\mu}_2-1)=0, \eta_4\hat{\mu}_2=0,\nonumber \end{eqnarray} where \begin{eqnarray} \frac{\partial I}{\partial \mu_1}&=&\big[\mu_2(p_1-p_2)+(1-\mu_2)(p_3-p_4)\big]\ln\frac{1-\hat{p}}{\hat{p}}\nonumber\\&&-\big[\mu_2\big(h_b(p_1)-h_b(p_2)\big)+(1-\mu_2)\big(h_b(p_3)-h_b(p_4)\big)\big],\label{eq.firstdI1}\\ \frac{\partial I}{\partial \mu_2}&=&\big[\mu_1(p_1-p_3)+(1-\mu_1)(p_2-p_4)\big]\ln\frac{1-\hat{p}}{\hat{p}}\label{eq.firstdI2}\nonumber\\&&-\big[\mu_1\big(h_b(p_1)-h_b(p_3)\big)+(1-\mu_1)\big(h_b(p_2)-h_b(p_4)\big)\big], \end{eqnarray} Note that $\eta_1\eta_2=0$ and $\eta_3\eta_4=0$, in order to further analyze the above KKT conditions, we need to consider $5$ cases corresponding to different combinations of active constraints. Similar to work \cite{lai2017sum}, we can show that two cases are non-optimal solutions. For example, if $\eta_1=0$, $\eta_2=0$, $\eta_3\neq0$, $\eta_4=0$, we have $I(\bar{\mu}_1,1)<I(\bar{\mu}_1,0)$ where $I(\bar{\mu}_1,0)$ corresponds to \textit{Scenario 2}. Therefore, the rest three possible scenarios need further investigation. \textit{Scenario 1:} $\eta_1=0$, $\eta_2=0$, $\eta_3=0$, and $\eta_4=0$. The KKT conditions can be simplified to $\frac{\partial I}{\partial \mu_1}|_{(\hat{\mu}_1,\hat{\mu}_2)}=0$ and $\frac{\partial I}{\partial \mu_2}|_{(\hat{\mu}_1,\hat{\mu}_2)}=0$. This scenario corresponds to the case where both users are active. As both $\frac{\partial I}{\partial \mu_1}|_{(\hat{\mu}_1,\hat{\mu}_2)}$ and $\frac{\partial I}{\partial \mu_2}|_{(\hat{\mu}_1,\hat{\mu}_2)}$ are nonlinear, there can be multiple possible $(\mu_1,\mu_2)$ pairs solution. However, we now show that there are at most $2$ possible $(\mu_1,\mu_2)$ pairs solution. By removing the common item $\ln\frac{1-\hat{p}}{\hat{p}}$ in equations (\ref{eq.sisomackkt1}) and (\ref{eq.sisomackkt2}), we have \begin{eqnarray}\label{eq.sisomacline} &&\mu_1U-\mu_2V+W=0, \end{eqnarray} where \begin{eqnarray} U&=&-h_{13}+h_{14}+h_{23}-h_{24}+h_{31}-h_{32}-h_{41}+h_{42},\\ V&=&-h_{12}+h_{14}+h_{21}-h_{23}+h_{32}-h_{34}-h_{41}+h_{43},\\ W&=&-h_{23}+h_{24}+h_{32}-h_{34}-h_{42}+h_{43}, \end{eqnarray} and $h_{ij}\stackrel{\triangle}{=} p_ih_b\big(p_j\big)$ for $i,j=1,2,3,4$. Regarding equation (\ref{eq.sisomacline}), we have the following property on $U,V,W$. \begin{lemma}\label{lemma.pnuvw} For any $A_1,A_2,\Lambda_0$, we have $U>0$ and $V>0$; and we have $W\lesseqqgtr0$ if and only if $A_1\gtreqqless A_2$. \begin{proof} Please refer to Appendix \ref{appen.pnuvw}. \end{proof} \end{lemma} Based on equation (\ref{eq.sisomacline}) and Lemma \ref{lemma.pnuvw}, we have \begin{eqnarray}\label{eq.sisomacf} \mu_2=\frac{U}{V}\mu_1+\frac{W}{V}\stackrel{\triangle}{=} f_{MAC}(\mu_1). \end{eqnarray} As $\frac{\partial I}{\partial \mu_2}=0$, we have \begin{eqnarray} \label{eq.sisomacg} \mu_2=\frac{(a_M+1)^{-1}-[\mu_1p_3+(1-\mu_1)p_4]}{\mu_1(p_1-p_3)+(1-\mu_1)(p_2-p_4)}\stackrel{\triangle}{=} g_{MAC}(\mu_1), \end{eqnarray} where $a_M=\exp\Big(\frac{\mu_1\big(h_b(p_1)-h_b(p_3)\big)+(1-\mu_1)\big(h_b(p_2)-h_b(p_4)\big)}{\mu_1(p_1-p_3)+(1-\mu_1)(p_2-p_4)}\Big)$. Hence, the $(\mu_1,\mu_2)$ pairs where $f_{MAC}(\mu_1)$ and $g_{MAC}(\mu_1)$ intersect with each other satisfy equations (\ref{eq.sisomacf}) and (\ref{eq.sisomacg}) simultaneously. For function $g_{MAC}(\mu_1)$, we have the following lemma \ref{lemma.sisomacconvexg}. \begin{lemma}\label{lemma.sisomacconvexg} Assume $\tau\leq\frac{\ln2}{A_1+A_2+\Lambda_0}$. Then, $g_{MAC}(\mu_1)$ is a strictly convex function with respect to $\mu_1$. \begin{proof} Please refer to Appendix \ref{appen.convexgmac}. \end{proof} \end{lemma} As $f_{MAC}(\mu_1)$ is a linear with respect to $\mu_1$, and $g_{MAC}(\mu_1)$ is a strictly convex function with respect to $\mu_1$ , there will be at most two intersection points, denoted as $(\hat{\mu}_1,\hat{\mu}_2)$ and $(\check{\mu}_1,\check{\mu}_2)$. We then need to check whether $(\hat{\mu_1},\hat{\mu_2})$ is in $[0,1]^2$ or not. If yes, we keep it. If not, then for the presentation convenience, we replace it with $(0,0)$. \textit{Scenario 2:} $\eta_1=0$,$\eta_2=0$,$\eta_3=0$, and $\eta_4\neq0$. Solving the corresponding KKT conditions, we obtain $\tilde{\mu}_1=\alpha_{\tau}(A_1,\Lambda_0)$ and $\tilde{\mu}_2=0$, where \begin{eqnarray} \alpha_{\tau}(A_1,\Lambda_0)=\frac{[1+\exp(\frac{h_b(p_3)-h_b(p_4)}{p_3-p_4})]^{-1}-p_4}{p_3-p_4}, \end{eqnarray} It is seen that $0 \leq \alpha_{\tau}(A_1, \Lambda_0) \leq 1$, since \begin{eqnarray} p_4=[1+\exp(h_b^{'}(p_4))]^{-1}\leq[1+\exp(\frac{h_b(p_3)-h_b(p_4)}{p_3-p_4})]^{-1}\leq[1+\exp(h_b^{'}(p_3))]^{-1}=p_3.\nonumber \end{eqnarray} This scenario corresponds to the case where only user $1$ is active. \textit{Scenario 3:} $\eta_1=0$, $\eta_2\neq0$, $\eta_3=0$, and $\eta_4=0$. Solving the corresponding KKT conditions, we obtain $\bar{\mu}_2=\alpha_{\tau}(A_2,\Lambda_0)$ and $\bar{\mu}_1=0$, where \begin{eqnarray} \alpha_{\tau}(A_2,\Lambda_0)=\frac{[1+\exp(\frac{h_b(p_2)-h_b(p_4)}{p_2-p_4})]^{-1}-p_4}{p_2-p_4}. \end{eqnarray} It is seen that $0 \leq \alpha_{\tau}(A_2, \Lambda_0) \leq 1$, since \begin{eqnarray} p_4=[1+\exp(h_b^{'}(p_4))]^{-1}\leq[1+\exp(\frac{h_b(p_2)-h_b(p_4)}{p_2-p_4})]^{-1}\leq[1+\exp(h_b^{'}(p_2))]^{-1}=p_2.\nonumber \end{eqnarray} This scenario corresponds to the case where only user $2$ is active. In summary, we have the following theorem. \begin{theorem}\label{theo.maccapa} Assume that $\tau\leq\frac{\ln2}{A_1+A_2+\Lambda_0}$. The sum-rate capacity of the Poisson MAC is given by \begin{eqnarray} C_{SISO-MAC}=\frac{1}{\tau}\max\{I_{X_1^2;Z}(\hat{\mu}_1,\hat{\mu}_2),I_{X_1^2;Z}(\check{\mu}_1,\check{\mu}_2),I_{X_1^2;Z}(\tilde{\mu}_1,\tilde{\mu}_2),I_{X_1^2;Z}(\bar{\mu}_1,\bar{\mu}_2)\}. \end{eqnarray} \end{theorem} Unlike the Gaussian MAC with an average power constraint, it can be optimal to allow only one user to transmit in order to achieve the sum-rate capacity for the Poisson MAC with a peak power constraint. More detailed discussions are presented in the following subsection. \subsection{Single-User or Two-User Transmission?}\label{subsect.stragety} We present sufficient conditions on the optimality of a single-user transmission and two-user transmission. Similar to work \cite{lai2017sum}, the following simple proposition characterize the sufficient conditions where there is no intersection between equations (\ref{eq.sisomacf}) and (\ref{eq.sisomacf}) in duty cycle feasible region $[0,1]^2$ and hence two-user transmission is not optimal. \begin{proposition}\label{prop.sisomacsingt} If $g_{MAC}(0)<f_{MAC}(0)$ and $g_{MAC}(1)<f_{MAC}(1)$, then single-user transmission is optimal to achieve the sum-rate capacity. \end{proposition} Even if the sufficient conditions in Proposition \ref{prop.sisomacsingt} are not satisfied, it is still possible for single-user transmission to be optimal if the corresponding rate is larger than that of the two-user transmission. We conclude that if certain $A_m$ is sufficiently large, single-user transmission is optimal. \begin{lemma}\label{lemma.sisomacstra1} Functions $f_{MAC}(\mu_1)$ and $g_{MAC}(\mu_1)$ have the following properties: \begin{eqnarray} \lim\limits_{A_2\to\infty}f_{MAC}(\mu_1)=\lim\limits_{A_2\to\infty}f_{MAC}(0)=\lim\limits_{A_2\to\infty}f_{MAC}(1)=1,\\ \lim\limits_{A_2\to\infty}g_{MAC}(\mu_1)=\frac{(a_{MI}+1)^{-1}-[\mu_1p_3+(1-\mu_1)p_4]}{\mu_1(p_1-p_3)+(1-\mu_1)(p_2-p_4)}<1,\text{ for any }\mu_1\in[0,1], \end{eqnarray} where $a_{MI}=\exp(-\frac{\mu_1h_b(p_3)+(1-\mu_1)h_b(p_4)}{\mu_1p_3+(1-\mu_1)p_4})$. \begin{proof} Please refer to Appendix \ref{appen.sisomacstra1}. \end{proof} \end{lemma} Lemma \ref{lemma.sisomacstra1} and Proposition \ref{prop.sisomacsingt} imply that a single active user is optimal for sufficient high peak power constraint of other user given peak power constraint of certain user. Furthermore, it is seen that the sum-rate capacity is achieved when only user $2$ is transmitting. We further discuss the conditions on the optimality of two-user transmission. The following proposition characterizes sufficient conditions where single-user transmission is not optimal. \begin{proposition}\label{prop.sisomacnec} Single user $1$ transmission is not optimal if $\frac{\partial I}{\partial \mu_2}|_{(\tilde{\mu}_1,0)}>0$. Similarly, single user $2$ transmission alone is not optimal if $\frac{\partial I}{\partial \mu_1}|_{(0,\bar{\mu}_2)}>0$. \begin{proof} Please refer to Appendix \ref{appen.sisomacnec}. \end{proof} \end{proposition} \subsection{Asymptotic Capacity Property for $\tau\to0$} We further investigate the asymptotic properties of the non-perfect receiver compared with the continuous Poisson channel, summarized in Theorem~\ref{theo.macasymp}. The main clue is to show the asymptotic properties of optimized objective function and optimal duty cycle. \begin{theorem}\label{theo.macasymp} The optimal duty cycle and MAC capacity of the non-perfect receiver approach those of continuous Poisson channel for any bounded $A_1$, $A_2$ and $\Lambda_0$, respectively, as $\tau\to0$. \begin{proof} Please refer to Appendix \ref{appen.macasymp}. \end{proof} \end{theorem} Theorem~\ref{theo.macasymp} studies the asymptotic property of the non-perfect receiver for $T_s=\tau\to0$. It shows that Theorem~\ref{theo.maccapa} extends the result of continuous MAC Poisson capacity \cite{lai2017sum}, and provides a more general and practical results. \section{SISO Capacity for Symmetric Two Users}\label{sect.sisomac2} Section~\ref{sect.sisomac} demonstrates SISO capacity for general two users based on KKT conditions. However, this method is hard to extend for multiple users since exponential number of Lagrangian multipliers. In this Section, we reduce the number of candidate optimal solutions from $4$ to $1$ for symmetric channel based on Section~\ref{sect.sisomac}, and provide another method to find optimal solution based on majorization. The notation in this section is similar to Section~\ref{sect.sisomac} and $p_2=p_3$ for symmetric channel. \subsection{KKT Conditions Perspective}\label{subsect.KKT} For symmetric channel, we prove that the optimal transmission strategy is two-user transmission with the same and unique duty cycle. The proof is given by the following three steps. \textit{Step 1:} We prove that two-user transmission is the optimal transmission strategy for $A_1=A_2$. When $(\mu_1,\mu_2)=(\tilde{\mu}_1,0)$, we have \begin{eqnarray} \hat{p}&=&\tilde{\mu}_1p_3+(1-\tilde{\mu}_1)p_4=[1+\exp(\frac{h_b(p_3)-h_b(p_4)}{p_3-p_4})]^{-1}, \end{eqnarray} Note that $\frac{h_b(p_1)-h_b(p_3)}{p_1-p_3}<\frac{h_b(p_2)-h_b(p_4)}{p_2-p_4}$, according to lemma \ref{appenAu.sisomacaux}, we have \begin{eqnarray} \frac{\mu_1\big(h_b(p_1)-h_b(p_3)\big)+(1-\mu_1)\big(h_b(p_2)-h_b(p_4)\big)}{\mu_1(p_1-p_3)+(1-\mu_1)(p_2-p_4)}\leq\frac{h_b(p_2)-h_b(p_4)}{p_2-p_4}=\ln\frac{1-\hat{p}}{\hat{p}}, \end{eqnarray} which implies $\frac{\partial I}{\partial \mu_2}|_{(0,\bar{\mu}_2)}>0$. Thus, single active user $1$ is not optimal. Similarly, single active user $2$ is not optimal. \textit{Step 2:} We prove that $\mu_1=\mu_2$ is optimal for both active users. Note that in such a scenario, $p_2=p_3$, $h_{2\cdot}=h_{3\cdot}$ and $h_{\cdot2}=h_{\cdot3}$. Thus, we have $W=0$ and $U=-V$, i.e., for the optimal $(\mu_1,\mu_2)$ we have $\mu_1=\mu_2$. \textit{Step 3:} We finally prove that there exists unique pair $(\mu_1,\mu_2)$ that satisfies equation (\ref{eq.sisomacf}) and (\ref{eq.sisomacg}). It is easy to check that $g_{MAC}(0)>0=f_{MAC}(0)$ and $g_{MAC}(1)<1=f_{MAC}(1)$. Thus, there exists a single intersection between $f_{MAC}(\mu)$ and $g_{MAC}(\mu)$ for $0\leq\mu_1\leq1$. \subsection{Majorization Perspective}\label{subsect.majorization} KKT-conditions-based method provides the necessary condition for the optimal solution, but it is hard to capture the specific property for the objective function and extend to multiple users. We investigate problem (\ref{eq.sisomaccapa}) based on majorization and obtain the same result as Section~\ref{subsect.KKT}. In addition, majorization-based method reveals more information about the problem (\ref{eq.sisomaccapa}) and maybe can be extended to the scenario of multiple users. Recall the sum-rate Poisson MAC capacity $C_{SISO-MAC}=\max\limits_{0\leq\mu_1,\mu_2\leq1}\frac{1}{\tau}I_{X_1^2;Z}(\mu_1,\mu_2)$, where $I_{X_1^2;Z}(\mu_1,\mu_2)=h_b(\hat{p}(\mu_1,\mu_2))-\mu_1\mu_2h_b(p_1)-(1-\mu_1)\mu_2h_b(p_2)-\mu_1(1-\mu_2)h_b(p_3)-(1-\mu_1)(1-\mu_2)h_b(p_4)$, $\hat{p}(\mu_1,\mu_2)=\mu_1\mu_2p_1+(1-\mu_1)\mu_2p_2+\mu_1(1-\mu_2)p_3+(1-\mu_1)(1-\mu_2)p_4$ and $p_2=p_3$. The solution based on majorization consists the following two steps corresponding to the inner and outer optimization as $C_{SISO-MAC}=\max\limits_{0\leq\mu_s\leq1}\frac{1}{\tau}I_2(\mu_s)$, where $I_2(\mu_s)=\max\limits_{{\begin{subarray}{c}(\mu_1,\mu_2):\\ \mu_1+\mu_2=2\mu_s\end{subarray}}}I_{X_1^2;Z}(\mu_1,\mu_2)$. \textit{Step 1:} Assume that $\tau\leq\frac{\ln2}{2A+\Lambda_0}$. We optimize $\mu_1$ and $\mu_2$ with the constraint $\mu_1+\mu_2=2\mu_{s}$ for any given $0\leq\mu_{s}\leq 1$. Firstly, we provide two critical Lemmas as follows, \begin{lemma}\label{lemma.sisomacsymLem} Assume that $\tau\leq\frac{\ln2}{2A+\Lambda_0}$. Define $G(A)=\frac{2h_b(p_2)-h_b(p_1)-h_b(p_4)}{2p_2-p_1-p_4}$, then we have $G(A)$ decreases with peak power $A$ and $G(A)\in(\ln(1-p_4)+\frac{p_4}{1-p_4}\ln p_4,\frac{1}{p_4}+\ln\frac{1-p_4}{p_4})$. \begin{proof} Please refer to Appendix~\ref{appen.sisomacsymLem}. \end{proof} \end{lemma} \begin{lemma}\label{lemma.sisomacsymLem2} The solution $\ln\frac{1-\hat{p}}{\hat{p}}=G(A)$ for $(\mu_1,\mu_2)\in[0,1]^2$ iff $A\geq A_{th}$, where $A_{th}$ is the unique solution on $\ln\frac{1-p_4}{p_4}=G(A)$. \begin{proof} Please refer to Appendix~\ref{appen.sisomacsymLem2}. \end{proof} \end{lemma} We focus on the region $\mu_1\geq\mu_2$ since the objective function in Equation (\ref{eq.sisomaccapa}) and the feasible region are symmetric for $\mu_1$ and $\mu_2$. Based on Equations (\ref{eq.firstdI1}) and (\ref{eq.firstdI2}), we have \begin{eqnarray} \label{eq.majori1} \frac{\partial I}{\partial \mu_1}-\frac{\partial I}{\partial \mu_2}&=&\Big\{[\mu_2(p_1-p_2)+(1-\mu_2)(p_3-p_4)]\ln\frac{1-\hat{p}}{\hat{p}}-[\mu_2\big(h_b(p_1)-h_b(p_2)\big)\nonumber\\&&+(1-\mu_2)\big(h_b(p_3)-h_b(p_4)\big)]\Big\}-\Big\{[\mu_1(p_1-p_3)+(1-\mu_1)(p_2-p_4)]\ln\frac{1-\hat{p}}{\hat{p}}\nonumber\\ &&-[\mu_1\big(h_b(p_1)-h_b(p_3)\big)+(1-\mu_1)\big(h_b(p_2)-h_b(p_4)\big)]\Big\}\nonumber\\ &\xlongequal{p_2=p_3}&(\mu_1-\mu_2)\Big\{\ln\frac{1-\hat{p}}{\hat{p}}(2p_2-p_1-p_4)-\big[2h_b(p_2)-h_b(p_1)-h_b(p_4)\big]\Big\}\nonumber\\ &=&(\mu_1-\mu_2)(2p_2-p_1-p_4)\big\{\ln\frac{1-\hat{p}}{\hat{p}}-G(A)\big\} \end{eqnarray} According to Lemma~\ref{lemma.sisomacsymLem2}, we can analysis Equation (\ref{eq.majori1}) by two cases. \textbf{Case 1:} $A<A_{th}$. According to Lemma~\ref{lemma.sisomacsymLem2}, we have $\ln\frac{1-\hat{p}}{\hat{p}}-G(A)<0$ and $(\mu_1-\mu_2)(\frac{\partial I}{\partial \mu_1}-\frac{\partial I}{\partial \mu_2})<0$ for $(\mu_1,\mu_2)\in[0,1]^2$. According to \cite[A.4. Theorem, p.84]{marshall1979inequalities}, we have that mapping $(\mu_1,\mu_2)\longmapsto I_{X_1^2;Z}(\mu_1,\mu_2)$ is Schur-concave for $(\mu_1,\mu_2)\in[0,1]^2$ and the optimal $(\mu_1,\mu_2)$ with the constraint $\mu_1+\mu_2=2\mu_{s}$ is $(\mu_s,\mu_s)$. \textbf{Case 2:} $A\geq A_{th}$. Define $\mathcal{C}\stackrel{\triangle}{=}\{(\mu_1,\mu_2):\ln\frac{1-\hat{p}}{\hat{p}}=G(A),\mu_1\geq\mu_2\}$ and $\mathcal{L}_{\mu_s}\stackrel{\triangle}{=}\{(\mu_1,\mu_2):\mu_1+\mu_2=2\mu_s,\mu_1\geq\mu_2\}$. According to Lemma~\ref{lemma.sisomacsymLem2}, we have $\mathcal{C}\neq\varnothing$. We further investigate the property of $\mathcal{C}$ as shown in Theorem~\ref{theo.sisomacsymBound}. \begin{theorem}\label{theo.sisomacsymBound} Assume that $\tau\leq\frac{\ln2}{2A+\Lambda_0}$. There exists differentiable function $f_B(\cdot)$ such that $\mathcal{C}=\{(\mu_1,\mu_2):\mu_1=f_B(\mu_2)\}$, where $0\geq f_B(0)<1$ and $f_B(\mu_2)<-1$ for $\mu_2\in[0,\frac{1}{2}]$. In addition, $|\mathcal{C}\cap\mathcal{L}_{\mu_s}|=1$ for $\mu_s^{'}\leq\mu_s\leq\mu_s^{*}$, and $|\mathcal{C}\cap\mathcal{L}_{\mu_s}|=0$ for $\mu_s\geq\mu_s^{*}$ and $\mu_s\leq\mu_s^{'}$, where $\mu_s^{'}=\frac{(p_2-p_4)-\sqrt{(p_2-p_4)^2-(2p_2-p_1-p_4)[\frac{1}{1+\exp(G(A))}-p_4]}}{2p_2-p_1-p_4}$ and $\mu_s^{*}=\frac{\frac{1}{1+\exp(G(A))}-p_4}{2(p_2-p_4)}<\frac{\tilde{\mu}_1}{2}$. \begin{proof} Please refer to Appendix~\ref{appen.sisomacsymBound}. \end{proof} \end{theorem} According to Theorem~\ref{theo.sisomacsymBound} and $\hat{p}$ increases with $\mu_1$ and $\mu_2$, define $\mathcal{C}^{+}=\{(\mu_1,\mu_2):\mu_1\geq f_B(\mu_2)\}$ and $\mathcal{C}^{-}=\{(\mu_1,\mu_2):\mu_1< f_B(\mu_2)\}$, we have that that mapping $(\mu_1,\mu_2)\longmapsto I_{X_1^2;Z}(\mu_1,\mu_2)$ is Schur-concave and Schur-convex for region $\mathcal{C}^{+}$ and $\mathcal{C}^{-}$, respectively. Thus, $I_2(\mu_s)$ is given by \begin{eqnarray} \label{eq.candidateI2} I_2(\mu_s)=\left\{\begin{array}{ll} I_{X_1^2;Z}(2\mu_s,0),&\mu_s\leq\mu_s^{'}, \\ \max\{I_{X_1^2;Z}(2\mu_s,0),I_{X_1^2;Z}(\mu_s,\mu_s)\},&\mu_s^{'}<\mu_s<\mu_s^{*}, \\ I_{X_1^2;Z}(\mu_s,\mu_s),&\mu_s\geq\mu_s^{*}. \end{array}\right. \end{eqnarray} \textit{Step 2:} We optimize $\mu_s$ to maximize $I_2(\mu_s)$ over $\mu_s\in[0,1]$. According to Equation (\ref{eq.candidateI2}), we have the candidate solution to maximize $I_{X_1^2;Z}(\mu_1,\mu_2)$ over $\mu_1\geq\mu_2$ are $(2\mu_s,0)$ for $0\leq\mu_s\leq\mu_s^{*}$, and $(\mu_s,\mu_s)$ for $1\geq\mu_s\geq\mu_s^{'}$. According to $\mu_s^{*}<\frac{\tilde{\mu}_1}{2}$ and \textit{Scenario 2} in Section~\ref{sect.sisomac}, we have $I_{X_1^2;Z}(2\mu_s,0)$ increases with $\mu_s$ over $\mu_s\leq\mu_s^{*}$. Note that \begin{eqnarray} \ln\frac{1-\hat{p}(2\mu_s^{*},0)}{\hat{p}(2\mu_s^{*},0)}&=&h_b^{'}(2\mu_s^{*}p_3+(1-2\mu_s^{*})p_4)=G(A)\nonumber\\&\overset{(a)}{>}&\frac{h_b(p_2)-h_b(p_4)}{p_2-p_4}\overset{(b)}{>}\frac{\mu\big(h_b(p_1)-h_b(p_3)\big)+(1-\mu)\big(h_b(p_2)-h_b(p_4)\big)}{\mu(p_1-p_3)+(1-\mu)(p_2-p_4)}, \end{eqnarray} where $(a)$ and $(b)$ hold according to Lemma~\ref{appenAu.last} and Lemma~\ref{appenAu.sisomacaux}, respectively. Thus, we have \begin{eqnarray} \frac{\partial I}{\partial \mu_2}\Big|_{(\mu_s^{*},0)}&=&[\mu_s^{*}(p_1-p_3)+(1-\mu_s^{*})(p_2-p_4)]\ln\frac{1-\hat{p}}{\hat{p}}\nonumber\\&&-[\mu_s^{*}\big(h_b(p_1)-h_b(p_3)\big)+(1-\mu_s^{*})\big(h_b(p_2)-h_b(p_4)\big)]>0. \end{eqnarray} and the optimal solution to maximize $I_{X_1^2;Z}(\mu_1,\mu_2)$ is not in $(2\mu_s,0)$ for $0\leq\mu_s\leq\mu_s^{*}$. For the rest candidate region $(\mu_s,\mu_s)$ for $1\geq\mu_s\geq\mu_s^{'}$, it is easy to check that $I_{X_1^2;Z}(\mu_s^{'},\mu_s^{'})=I_{X_1^2;Z}(2\mu_s^{*},0)$ and $I_{X_1^2;Z}(1,1)=0$. For the continuous objection function $I_{X_1^2;Z}(\mu_s,\mu_s)$ over $1\geq\mu_s\geq\mu_s^{'}$, the optimal solution must be a extreme point satisfying the following equation, \begin{eqnarray}\label{eq.firstdneces} 0&=&\frac{\partial I_{X_1^2;Z}(\mu_s,\mu_s)}{\partial \mu_s}=(\frac{\partial I_{X_1^2;Z}}{\partial \mu_1}-\frac{\partial I_{X_1^2;Z}}{\partial \mu_2})\Big|_{(\mu_s,\mu_s)}\nonumber\\&=&2\Big\{[\mu_s(p_1-p_2)+(1-\mu_s)(p_2-p_4)]\ln\frac{1-\hat{p}}{\hat{p}}\nonumber\\&&-[\mu_s\big(h_b(p_1)-h_b(p_2)\big)+(1-\mu_s)\big(h_b(p_2)-h_b(p_4)\big)]\big\}, \end{eqnarray} where $\hat{p}=\mu_s^2p_1+2\mu_s(1-\mu_s)p_2+(1-\mu_s)^2p_4$. It is easy to check that Equation (\ref{eq.firstdneces}) equals to $\mu_s=g_{MAC}(\mu_s)$ in Equation (\ref{eq.sisomacg}). According to Section~\ref{subsect.KKT}, we have that there exists unique solution on Equation (\ref{eq.firstdneces}). Section~\ref{subsect.majorization} shows that the optimal solution to maximize $I_{X_1^2;Z}(\mu_1,\mu_2)$ satisfies $\mu_1=\mu_2=\mu_s$ and $\mu_s$ is the unique solution on Equation (\ref{eq.firstdneces}), the same as the result in Section~\ref{subsect.KKT}. In addition, Work \cite{lapidoth1998poisson} shows that the mutual information function over $\mu_1$ and $\mu_2$ is schur-concave for continuous time Poisson channel, while does not hold for non-perfect receiver. Section~\ref{subsect.majorization} demonstrates that $I_{X_1^2;Z}(\mu_1,\mu_2)$ is schur-concave as $A<A_{th}$, and $I_{X_1^2;Z}(\mu_1,\mu_2)$ is schur-concave and schur-convex for $\mathcal{C}^{+}$ and $\mathcal{C}^{-}$, respectively, for $A\geq A_{th}$. Furthermore, we have that $I_{X_1^2;Z}(\mu_1,\mu_2)$ is schur-concave for any fixed peak power $A$ as $\tau\to0$, as shown in Lemma~\ref{lemma.sisomacsymLemAth}. \begin{lemma}\label{lemma.sisomacsymLemAth} For dead time $\tau\to0$, we have $\lim\limits_{\tau\to0}A_{th}=+\infty$, i.e., $I_{X_1^2;Z}(\mu_1,\mu_2)$ is schur-concave for any bounded peak power $A$. \begin{proof} Please refer to Appendix~\ref{appen.sisomacsymLemAth}. \end{proof} \end{lemma} The same behavior of mutual information function between continuous Poisson channel and non-perfect receiver with small enough dead time, schur-concavity over any peak power $A$ and background radiation $\Lambda_0$, aligns with the intuition since small enough dead time would not cause any photon-counting loss. \section{Sum-Rate MISO Capacity for Two Users}\label{sect.misomac} We extend the analysis to the case when the user $m$ is equipped with $J_m$ (more than one) transmitters. \subsection{Sum-Rate MISO-MAC Capacity Analysis} The sum-rate MISO-MAC capacity is defined as $C_{MISO-MAC}\stackrel{\triangle}{=}\max\limits_{\Lambda^{T_s}_{mj}\in[0,A]}\frac{1}{T_s}I(\Lambda^{T_s}_{[MJ]};Z)$. Similar to Section \ref{sect.sisomac}, the input waveform signal of each transmitter is piece-wise constant waveforms with two levels $\{0,A_{mj}\}$ for the $j^{th}$ transmitter of the $m^{th}$ user. Nevertheless, it is still needed to be investigated how the $J_m$ transmitters jointly work, which is addressed in the following result. \begin{theorem}\label{theo.misomacall} For $\tau\leq\frac{\ln2}{\sum_{m=1}^{2}\sum_{j=1}^{J}A_{mj}+\Lambda_0}$, the optimal solution is that all transmitters must have the same duty cycle and must be on or off simultaneously. \end{theorem} Theorem \ref{theo.misomacall} implies the equivalence between MISO-MAC and SISO-MAC, i.e., the sum-rate MISO-MAC capacity with peak constraints $(A_{1[J]},A_{2[J]})$ is equivalent to the SISO-MAC capacity with peak power constraint $(\sum_{j=1}^{J}A_{1j},\sum_{j=1}^{J}A_{1j})$. Therefore, further detailed investigations on the sum-rate MISO-MAC capacity is similar to that in Section \ref{sect.sisomac}, and thus omitted here. The proof of Theorem \ref{theo.misomacall} consists of the following two major steps. In \textbf{step 1}, given duty cycle $\mu_{[2J]}$, we show how each transmitter jointly work. \begin{proposition}\label{prop.misomacwork} For $\tau\leq\frac{\ln2}{\sum_{m=1}^{2}\sum_{j=1}^{J}A_{mj}+\Lambda_0}$, the optimal condition is that if the transmitter with a smaller duty cycle is on then all transmitters with a larger duty cycle must also be on. \begin{proof} Please refer to Appendix \ref{appen.misomacwork}. \end{proof} \end{proposition} This proposition shows that the capacity-achieving transmitted signals through $J_{m}$ transmitter are correlated but i.i.d. in each time interval for user $m$, $m=1,2$.The possible PMF value can be reduced from $2^{J_1}+2^{J_2}$ to $J_1+J_2+2$. Similarly, for a given duty cycle, there could be infinite number of possible joint distribution. The main idea is to show that, if the transmitter with lower duty cycle is on, then the transmitter with higher duty cycle must be also on to achieve optimality. In addition, the objective function is concave and the optimization is performed over a convex compact set, such that the optimal solution clearly exists. In \textbf{step 2}, we show the following proposition that characterizes the optimal duty cycle. \begin{proposition}\label{prop.misomacwork2} For the optimal solution, all transmitters of user $m$ must have the same duty cycle, and according to Proposition \ref{prop.misomacwork} they must be on and off simultaneously. \begin{proof} Please refer to Appendix \ref{appen.misomacwork2}. \end{proof} \end{proposition} This proposition shows that for the optimal solution, the transmitters of each user must have the same duty cycle (i.e., $\mu_{m1}=\cdots=\mu_{mJ_m}$) and must be aligned. Hence, the dimension of the optimization problem can be reduced from $J_1+J_2$ to $2$. The main idea is to show that all transmitters are simultaneously on and off. Hence, from the receiver perspective, two users with multiple transmitters can be viewed as two users each with a single transmitter with peak power constraint $(\sum_{j=1}^{J_1}A_{1j},\sum_{j=1}^{J_2}A_{2j})$. \section{Numerical Results}\label{sect.numresult} In this section, we provide numerical examples to illustrate results obtained in this paper. As shown in the paper, the MISO-MAC Poisson capacity can be converted to that of SISO-MAC . Hence, in the following, we provide only example related to the SISO-MAC case. Figure~\ref{fig.MACfgnonf} and Figure~\ref{fig.MACfgone} show the case of no intersection and one intersection in $0\leq\mu_1\leq1$ and $0\leq\mu_2\leq1$, respectively. The dead time is set to $0.02$; The peak power $(A_1,A_2)$ of transmitters $1$ and $2$ are set to $(1,20)$ and $(10,12)$, respectively, in Figures~\ref{fig.MACfgnonf} and \ref{fig.MACfgone} and satisfies the condition $\tau\leq\frac{\ln2}{A_1+A_2+\Lambda_0}$. Lemma~\ref{lemma.sisomacconvexg} implies at most two intersection points between function $f_{MAC}(\cdot)$ and $g_{MAC}(\cdot)$, while can not find the case of two intersection points by brute-force search. Figure~\ref{fig.MACmucomb} illustrates the optimal $\mu_1$ and $\mu_2$ against peak power of user 2 $A_2$ for different dead time $\tau$ given $A_1=12.5$. $\tau=0$ represents continuous Poisson channel. It is seen that $\tau\leq\frac{\ln2}{A_1+A_2+\Lambda_0}$ is satisfied and the optimal $\mu_1$ and $\mu_2$ close to that of continuous Poisson channel as $\tau\to0$ and the optimal $\mu_1^{*}=\mu_2^{*}$ as $A_1=A_2$ for any dead time $\tau$, aligned with the result of Section~\ref{sect.sisomac2}. Figure~\ref{fig.MACcapa} shows the MAC Poisson capacity with respect to peak power $A_2$ for different dead time and it is seen that the optimal MAC Poisson capacity with non-perfect receiver approaches that of continuous Poisson channel as $\tau\to0$, aligned with Theorem~\ref{theo.macasymp}. Figure~\ref{fig.macregion} shows the optimal transmission strategy region of $A_1$ and $A_2$. ``Black'', ``red'', and ``Blue'' regions represents the optimal transmission strategy region of only active user $2$, both two active users and only active user $1$, respectively. It is seen that the boundary of these three regions are almost two lines through the origin with different slope, and the optimal transmission strategy are only user $2$-active, both two-user-active and only user $1$-active for the case of $A_1\ll A_2$, $A_1= A_2$, $A_1\gg A_2$, respectively, aligned with Section~\ref{subsect.stragety} and Section~\ref{sect.sisomac2}. \section{Conclusion}\label{sect.conclusion} In this paper, we have characterized the two-user asymmetric sum-rate Poisson capacity for both SISO and MISO cases. We demonstrate the equivalence of these two cases under certain condition. For both two cases, the optimal input signal of each transmitter and user must be two-level piece-wise constant and there are three possible transmission strategies, including only one active user and both active users. We provide the sufficient condition of these three strategies. In addition, we investigate the two-user symmetric sum-rate Poisson capacity based on above result and majorization method, both demonstrating that the optimal duty cycle must be the same and unique, and the majorization method maybe can be extend to multiple users case. \begin{figure} \setlength{\abovecaptionskip}{-0.1cm} \centering {\includegraphics[angle=0, width=0.8\textwidth]{MACfgnonf.eps}} \caption{$f_{MAC}(\mu_1)$ and $g_{MAC}(\mu_1)$ have no intersection in $0\leq\mu_1\leq1$ and $0\leq\mu_2\leq1$.} \label{fig.MACfgnonf} \end{figure} \begin{figure} \centering {\includegraphics[angle=0, width=0.8\textwidth]{MACfgone.eps}} \caption{$f_{MAC}(\mu_1)$ and $g_{MAC}(\mu_1)$ have one intersection in $0\leq\mu_1\leq1$ and $0\leq\mu_2\leq1$.} \label{fig.MACfgone} \end{figure} \begin{figure} \centering {\includegraphics[angle=0, width=0.8\textwidth]{MACmucomb.eps}} \caption{The optimal $\mu_1$ and $\mu_2$ versus peak power of user 2 $A_2$ for different dead time $\tau$.} \label{fig.MACmucomb} \end{figure} \begin{figure} \centering {\includegraphics[angle=0, width=0.8\textwidth]{MACcapa.eps}} \caption{The MAC Poisson capacity versus peak power $A_2$ for different dead time.} \label{fig.MACcapa} \end{figure} \begin{figure} \centering {\includegraphics[angle=0, width=0.8\textwidth]{macregion.eps}} \caption{Optimal transmission strategy for different peak power $A_1$ and $A_2$.} \label{fig.macregion} \end{figure} \appendices \renewcommand{\baselinestretch}{1.4} \section{The proof of main results on MISO-MAC Capacity} \subsection{Proof of Theorem \ref{theo.sisomacbi}}\label{appen.sisomacbi} \textbf{Converse part}: Note that $\Lambda^{T_s}_{[M]}\rightarrow X_{[M]}\rightarrow Z$ forms a Markov chain, according to DPI, we have $I(\Lambda^{T_s}_{[M]};Z)\leq I(X_{[M]};Z)$. The mutual information $I(X,Z)$ is as follow, \begin{eqnarray} I(X,Z)=h_b(\hat{p})-\int h_b(p(\sum_{m=1}^{M}X_m+\Lambda_0))\mathrm{d}\mu(X_{[M]}), \end{eqnarray} where $\hat{p}=\mathbb{E}[p(\sum_{m=1}^{M}X_m+\Lambda_0)]$. Define $S_1=p(X_1+\Lambda_0)$, note that the mapping $X\rightarrow S$ is a one-to-one mapping and $p(x_1+x_2)=p(x_2)+(1-p(x_2))p(x_1)$, hence we have \begin{eqnarray} I(X_{[M]};Z)=I(X_{2}^M,S_1;Z)=h_b(\hat{p})+\mathbb{E}_{X_{2}^M}\Big[\mathbb{E}_{S_1}[-h_b\big(p(X_{2}^M)+(1-p(X_{2}^M))S_1\big)]\Big], \end{eqnarray} and the following equation holds, \begin{eqnarray} &&\max\limits_{\mu(X_{[M]})}I(X_{[M]},Z)=\max\limits_{\mu(,X_{2}^M,S_1)}I(X_{2}^M,S_1;Z)\nonumber\\&&=\max\limits_{p(\Lambda_0)\leq\hat{p}\leq p(A+\Lambda_0)}\hat{p}+\max\limits_{\mu(X_{2}^M)}\mathbb{E}_{X_{2}^M}\Big[\max\limits_{\mu(S_1)\in\mathcal{S}_{M}(\hat{p},\mu(X_2^M))}\mathbb{E}_{S_1}[-h_b\big(p(X_{2}^M)+(1-p(X_{2}^M))S_1\big)]\Big], \end{eqnarray} where \begin{eqnarray} \mathcal{S}_M(\hat{p},\mu(X_2^M))=\Big\{\mu(S_1):\mathbb{E}[S]=\frac{\hat{p}-\mathbb{E}[p(\sum_{m=2}^{M}A_m)]}{1-\mathbb{E}[p(\sum_{m=2}^{M}A_m)]}\Big\}, \end{eqnarray} where the inner optimization is performed over the class of distributions of $S_1$ with a finite support $[0,A_1]$ and fixed conditional mean set. Note that convex function $-h_b(\cdot)$ compounded linear function is still a convex function, the inner maximum is achieved if and only if $S_1$ is two-levels. Then we see that the optimal marginal PMF of $X_1$ is given by \begin{eqnarray} \mathbb{P}(X_1=A_1)=\mathbb{P}\big(S_1=p(A_1+\Lambda_0)\big)\stackrel{\triangle}{=}\mu_1. \end{eqnarray} By symmetry, the optimal marginal PMF of $X_m$ is $\{0,A_m\}$-valued with $\mathbb{P}(X_m=A_m)\stackrel{\triangle}{=}\mu_m$, where $m=2,\cdots,M$. \textbf{Achievability part:} Let waveform $\Lambda_m^{T_s}$ in $[0,T_s]$ randomly selected from waveform set $\{0,A_m*(u(t)-u(t-T_s))\}$ with probability $\mu_m^{*}=\mathbb{P}\{\Lambda_m^{T_s}=A_m*(u(t)-u(t-T_s))\}$, where $u(t)$ denotes as a step function, then we have the upper bound in converse part is achievable. \subsection{Proof of Lemma \ref{lemmal.sisomacnonconacve}}\label{appen.sisomacconcave} \textbf{Non-convex optimized joint distribution set}: The joint distribution of two independent variable is not closed under the linear weighted operation, i.e., \begin{eqnarray} \mu f_{X^{'}_{[2]}}(x_1,x_2)+(1-\mu)\mu f_{X^{''}_{[2]}}(x_1,x_2)&\neq&\int\mu f_{X^{'}_{[2]}}(x_1,x_2)+(1-\mu)\mu f_{X^{''}_{[2]}}(x_1,x_2)\mathrm{d}x_1\nonumber\\&&\cdot\int\mu f_{X^{'}_{[2]}}(x_1,x_2)+(1-\mu)\mu f_{X^{''}_{[2]}}(x_1,x_2)\mathrm{d}x_2, \end{eqnarray} where $f_{X_{[2]}}(x_1,x_2)$ denotes as the joint distribution of $X_{[2]}$. \textbf{Non-concavity of $I_{X_1^2;Z}(\mu_1,\mu_2)$}: Prove by contradiction. Assume $I_{X_1^2;Z}(\mu_1,\mu_2)$ is concave, $\nabla^2 I$ needs to be negative semi-definite. By calculating, we have \begin{eqnarray} \frac{\partial I}{\partial \mu_1}&=&\ln\frac{1-\hat{p}}{\hat{p}}\big(\mu_2(p_1-p_2)+(1-\mu_2)(p_3-p_4)\big)\nonumber\\&&-\big(\mu_2(h_b(p_1)-h_b(p_2))+(1-\mu_2)(h_b(p_3)-h_b(p_4))\big),\\ \frac{\partial I^2}{\partial^2 \mu_1}&=&-\frac{\big(\mu_2(p_1-p_2)+(1-\mu_2)(p_3-p_4)\big)^2}{\hat{p}(1-\hat{p})}<0,\\ \frac{\partial I^2}{\partial^2 \mu_1\mu_2}&=&-\underbrace{\frac{1}{\hat{p}(1-\hat{p})}\big(\mu_1(p_1-p_3)+(1-\mu_1)(p_2-p_4)\big)\big(\mu_2(p_1-p_2)+(1-\mu_2)(p_3-p_4)\big)}_{I_{a}}\nonumber\\&&+\underbrace{\ln\frac{1-\hat{p}}{\hat{p}}(p_1-p_2-p_3+p_4)-\big(h_b(p_1)-h_b(p_2)-h_b(p_3)+h_b(p_4)\big)}_{I_{b}},\\ \frac{\partial I^2}{\partial^2 \mu_2}&=&-\frac{\big(\mu_1(p_1-p_3)+(1-\mu_1)(p_2-p_4)\big)^2}{\hat{p}(1-\hat{p})}<0, \end{eqnarray} Thus $|\nabla^2 I|$ is given by \begin{eqnarray} |\nabla^2 I|&=&\frac{\partial I^2}{\partial^2 \mu_1} \frac{\partial I^2}{\partial^2 \mu_2}-(\frac{\partial I^2}{\partial \mu_1\partial \mu_2})^2\nonumber\\&=&\Big[\ln\frac{1-\hat{p}}{\hat{p}}(p_1-p_2-p_3+p_4)-\big(h_b(p_1)-h_b(p_2)-h_b(p_3)+h_b(p_4)\big)-\frac{\partial I^2}{\partial^2 \mu_1\mu_2}\Big]^2\nonumber\\&&-(\frac{\partial I^2}{\partial^2 \mu_1\mu_2})^2=I_{b}(2I_{a}-I_{b}), \end{eqnarray} Note that \begin{eqnarray} \lim\limits_{(\mu_1,\mu_2)\to\mathbf{0}}I_{b}(2I_{a}-I_{b})&=&(p_1-p_2-p_3+p_4)\Big(\ln\frac{1-p_4}{p_4}-\bar{G}(A_1,A_2)\Big)\Big(2\frac{(p_2-p_4)(p_3-p_4)}{p_4(1-p_4)}\nonumber\\&&-(p_1-p_2-p_3+p_4)\big(\ln\frac{1-p_4}{p_4}-\bar{G}(A_1,A_2)\big)\Big)\nonumber\\ &\overset{(a)}{=}&(p_1-p_2-p_3+p_4)^2\big(\ln\frac{1-p_4}{p_4}-\bar{G}(A_1,A_2)\big)\Big(\bar{G}(A_1,A_2)+\frac{2}{p_4}-\ln\frac{1-p_4}{p_4}\Big). \end{eqnarray} where $\bar{G}(A_1,A_2)\stackrel{\triangle}{=}\frac{h_b(p_1)-h_b(p_2)-h_b(p_3)+h_b(p_4)}{p_1-p_2-p_3+p_4}>0$, equality $(a)$ holds since $(p_2-p_4)(p_3-p_4)=-(p_2-p_4)(1-p_4)p(A_1)=-(1-p_4)(p_1-p_2-p_3+p_4)=$, $\bar{G}(A_1,A_2)+\frac{2}{p_4}-\ln\frac{1-p_4}{p_4}>0$ since $\frac{1}{p_4}>\frac{1}{p_4}>\frac{1-p_4}{p_4}$. Set $\tau=0.02$, $\Lambda_0=0.001$ and $A_1=A_2=10$, we have $\tau=0.02\leq\frac{\ln2}{A_1+A_2+\Lambda_0}\simeq0.0347$ and $\bar{G}(10,10)\simeq9.51<\ln\frac{1-p_4}{p_4}\simeq10.8198$, i,e., there exists certain $(A_1,A_2,\Lambda_0)$ such that $\lim\limits_{(\mu_1,\mu_2)\to\mathbf{0}}I_{b}(2I_{a}-I_{b})>0$. Thus, there exists $\epsilon>0$ so that for $(\mu_1,\mu_2)\in \mathcal{C}_{\epsilon}=\{(\mu_1,\mu_2):\sqrt{\mu_1^2+\mu_2^2}\leq\epsilon\}$, we have $|\nabla^2 I|>0$, contradicted with assumption of negative semi-definite $\nabla^2 I$. \subsection{Proof of Lemma \ref{lemma.pnuvw}}\label{appen.pnuvw} According to Lemma \ref{appenAu.convex} and $h_b(\cdot)$ is concave, we have \begin{eqnarray} \frac{h_b(p_1)-h_b(p_2)}{p_1-p_2}>\frac{h_b(p_1)-h_b(p_4)}{p_1-p_4}>\frac{h_b(p_3)-h_b(p_4)}{p_3-p_4},\\ \frac{h_b(p_2)-h_b(p_3)}{p_2-p_3}>\frac{h_b(p_2)-h_b(p_4)}{p_2-p_4}. \end{eqnarray} By calculating, we can have \begin{eqnarray} U=(p_1-p_2)(p_3-p_4)[\frac{h_b(p_1)-h_b(p_2)}{p_1-p_2}-\frac{h_b(p_3)-h_b(p_4)}{p_3-p_4}]>0, \end{eqnarray} similarly, we can have $V>0$. As for $W$, if $A_2>A_1$, we have $p_2>p_3$ and \begin{eqnarray} W&=&p_2p_3\frac{h_b(p_2)-h_b(p_3)}{p_2-p_3}-p_2p_4\frac{h_b(p_2)-h_b(p_4)}{p_2-p_4}+p_3p_4\frac{h_b(p_2)-h_b(p_4)}{p_2-p_4}\nonumber\\ &>&p_2p_4[\frac{h_b(p_2)-h_b(p_3)}{p_2-p_3}-\frac{h_b(p_2)-h_b(p_4)}{p_2-p_4}]+p_3p_4\frac{h_b(p_2)-h_b(p_4)}{p_2-p_4}>0 \end{eqnarray} Similarly, we have $W\lesseqqgtr0$ if and only if $A_1\gtreqqless A_2$. \subsection{Proof of Convexity of $g_{MAC}(\mu_1)$}\label{appen.convexgmac} Define $d_0\stackrel{\triangle}{=} p_2-p_4>0$, $d_1\stackrel{\triangle}{=} p_1-p_2-p_3+p_4<0$, $d_2\stackrel{\triangle}{=} h_b(p_1)-h_b(p_2)-h_b(p_3)+h_b(p_4)<0$, and $d_3\stackrel{\triangle}{=} h_b(p_2)-h_b(p_4)$. Note that $\frac{h_b(p_2)-h_b(p_4)}{p_2-p_4}>\frac{h_b(p_1)-h_b(p_3)}{p_1-p_3}$ and $p_2-p_4>p_1-p_3>0$, we have \begin{eqnarray} \frac{d_2}{d_1}=\frac{[h_b(p_2)-h_b(p_4)]-[h_b(p_1)-h_b(p_3)]}{(p_2-p_4)-(p_1-p_3)}>\frac{h_b(p_2)-h_b(p_4)}{p_2-p_4}=\frac{d_3}{d_0}, \end{eqnarray} which implies $d_2d_0-d_1d_3=d_0d_1(\frac{d_2}{d_1}-\frac{d_3}{d_0})<0$. Note that $a_M=\exp(\frac{\mu_1d_2+d_3}{\mu_1d_1+d_0})$ and $d_0+d_1>0$, we have \begin{eqnarray} a_M^{'}&=&\exp(\frac{\mu_1d_2+d_3}{\mu_1d_1+d_0})\frac{d_2d_0-d_1d_3}{\mu_1d_1+d_0}<0,\label{eq.firstdaM}\\ a_M^{''}&=&a_M^{'}(\mu_1d_1+d_0)^{-2}[(d_2d_0-d_1d_3)-2d_1(\mu_1d_1+d_0)], \end{eqnarray} Note that $\mu_1(p_1-p_3)+(1-\mu_1)(p_2-p_4)=\big(1-(1-p(A_1))\mu_1\big)(p_2-p_4)$, after rearrangement of $g_{MAC}(\mu_1)$, we have \begin{eqnarray}\label{eq.gmac} g_{MAC}(\mu_1)=\frac{1}{F(\mu_1)}-\frac{\mu_1(p_3-p_4)+p_4}{\big(1-(1-p(A_1))\mu_1\big)(p_2-p_4)}, \end{eqnarray} where $F(\mu_1)\stackrel{\triangle}{=} (a_M+1)\big(1-(1-p(A_1))\mu_1\big)(p_2-p_4)>0$. It is easy to check \begin{eqnarray} F^{'}(\mu_1)&=&(p_2-p_4)\{a_M^{'}\big(1-(1-p(A_1))\mu_1\big)-(1-p(A_1))(a_M+1)\}<0,\\ F^{''}(\mu_1)&=&a_M^{'}(\mu_1d_1+d_0)^{-2}\big\{[(d_2d_0-d_1d_3)-2d_1(\mu_1d_1+d_0)]\big(1-\mu_1(1-p(A_1))\big)\nonumber\\&&-2(1-p(A_1))(\mu_1d_1+d_0)^2\}\stackrel{\triangle}{=} a_M^{'}(\mu_1d_1+d_0)^{-2}l(\mu_1) \end{eqnarray} It is easy to check that $l(\mu_1)$ is a linear function. Note that $d_1=-d_0(1-p(A_1))$, we have \begin{eqnarray} l(1)&=&[(d_2d_0-d_1d_3)-2d_1(d_1+d_0)]p(A_1)-2(1-p(A_1))(d_1+d_0)^2\nonumber\\&=&(d_2d_0-d_1d_3)p(A_1)<0,\\ l(0)&=&(d_2d_0-d_1d_3-2d_1d_0)-2(1-p(A_1))d_0^2=d_2d_0-d_1d_3<0, \end{eqnarray} therefore, we have $l(\mu_1)<0$ and $F^{''}(\mu_1)<0$ for $\mu_1\in[0,1]$ and $[\frac{1}{F(\mu_1)}]^{''}=\frac{2}{F^3(\mu_1)}[F^{'}(\mu_1)]^2-\frac{1}{F^2(\mu_1)}F^{''}(\mu_1)>0$. For the last fraction in Equation (\ref{eq.gmac}), we have its derivation as follows, \begin{eqnarray} [-\frac{\mu_1(p_3-p_4)+p_4}{\big(1-(1-p(A_1))\mu_1\big)(p_2-p_4)}]^{''}&=&\frac{-2(1-p(A_1))[(p_3-p_4)+p_4(1-p(A_1))]}{\big(1-(1-p(A_1))\mu_1\big)^3(p_2-p_4)}\nonumber\\&=&\frac{-2(a_M+1)^3(p_2-p_4)^2(1-p(A_1))[p_3-p_4p(A_1)]}{F^3(\mu_1)},\nonumber \end{eqnarray} Based on Equation (\ref{eq.gmac}), $g_{MAC}^{''}$ is given by \begin{eqnarray} g_{MAC}^{''}&=&[\frac{1}{F(\mu_1)}]^{''}+[-\frac{\mu_1(p_3-p_4)+p_4}{\big(1-(1-p(A_1))\mu_1\big)(p_2-p_4)}]^{''}\nonumber\\ &\overset{(a)}{>}&\frac{2}{F^3(\mu_1)}+[F^{'}(\mu_1)]^2\frac{-2(a_M+1)^3(p_2-p_4)^2(1-p(A_1))[p_3-p_4p(A_1)]}{F^3(\mu_1)}\nonumber\\ &=&\frac{2(p_2-p_4)^2}{F^3(\mu_1)}\Big\{\Big[a_M^{'}\big(1-(1-p(A_1))\mu_1\big)-(1-p(A_1))(a_M+1)\Big]^2\nonumber\\&&-(a_M+1)^3(1-p(A_1))[p_3-p_4p(A_1)]\Big\}\nonumber\\ &\overset{(b)}{>}&\frac{2(p_2-p_4)^2(a_M+1)^2(1-p(A_1))}{F^3(\mu_1)}\Big\{(1-p(A_1))-(a_M+1)[p_3-p_4p(A_1)]\Big\}\nonumber\\ &\overset{(c)}{>}&\frac{2(p_2-p_4)^2(a_M+1)^2(1-p(A_1))}{F^3(\mu_1)}\Big\{(1-p(A_1))\nonumber\\&&-\Big(\exp\big(\frac{h_b(p_2)-h_b(p_4)}{p_2-p_4}\big)+1\Big)[p_3-p_4p(A_1)]\Big\}\nonumber\\ &\overset{(d)}{>}&\frac{2(p_2-p_4)^2(a_M+1)^2(1-p(A_1))}{F^3(\mu_1)}\Big\{(1-p(A_1))-(p_2+1)p_3\Big\}\nonumber\\ &\overset{(e)}{>}&\frac{2(p_2-p_4)^2(a_M+1)^2(1-p(A_1))}{F^3(\mu_1)}\big[(1-p(A_1)-p_3)p_2+(1-p_3)p(A_1)\big]>0 \end{eqnarray} where $(a)$ holds by dropping out positive terms $-\frac{1}{F^2(\mu_1)}F^{''}(\mu_1)$; $(b)$ holds since the term $\Big[a_M^{'}\big(1-(1-p(A_1))\mu_1\big)<0$ based on Equation (\ref{eq.firstdaM}), and $(1-p(A_1))(a_M+1)>0$; $(c)$ holds since $a_M\leq a_M(0)=\exp\big(\frac{h_b(p_2)-h_b(p_4)}{p_2-p_4}\big)$ based on Equation (\ref{eq.firstdaM}); $(d)$ holds since $\exp\big(\frac{h_b(p_2)-h_b(p_4)}{p_2-p_4}\big)>\exp\big(h_b^{'}(p_2)\big)=p_2$, and $(e)$ holds since $\tau\leq\frac{\ln2}{A_1+A_2+\Lambda_0}$, $p_1\leq\frac{1}{2}$, $p_1-p(A_1)=(1-p(A_1))p_2$ and $p_1-p_3=(1-p_3)p(A_1)$. Thus, we have function $g_{MAC}(\mu_1)$ is a strictly convex function as $\tau\leq\frac{\ln2}{A_1+A_2+\Lambda_0}$. \subsection{Proof of Lemma \ref{lemma.sisomacstra1}}\label{appen.sisomacstra1} Note that $\lim\limits_{A_2\to\infty}p_1=\lim\limits_{A_2\to\infty}p_2=1$, and $\lim\limits_{A_2\to\infty}h_b(p_1)=\lim\limits_{A_2\to\infty}h_b(p_2)=0$, we have $\lim\limits_{A_2\to\infty}U=0$, and \begin{eqnarray} \lim\limits_{A_2\to\infty}V=-\lim\limits_{A_2\to\infty}W=-h_b(p_4)+h_b(p_3)+p_3h_b(p_4)-p_4h_b(p_3), \end{eqnarray} thus $\lim\limits_{A_2\to\infty}f_{MAC}(\mu_1)\equiv1$. As for $\lim\limits_{A_2\to\infty}g_{MAC}$, it is straightforward that $(1+a_{MI})^{-1}<1$, thus we have $\lim\limits_{A_2\to\infty}g_{MAC}<1$ for any $\mu_1\in[0,1]$. \subsection{Proof of Proposition \ref{prop.sisomacnec}}\label{appen.sisomacnec} The main proof is based on continuity of $I_{X_1^2;Z}(\mu_1,\mu_2)$. When $\frac{\partial I}{\partial \mu_2}|_{(\tilde{\mu}_1,0)}>0$, for any $\epsilon$, there exists $0\mu_2<\epsilon$ so that $I_{X_1^2;Z}(\tilde{\mu}_1,0)<I_{X_1^2;Z}(\tilde{\mu}_1,\mu_2)$. Therefore, single user $1$ transmission is not optimal. Similarly, we have single user $2$ transmission is not optimal if $\frac{\partial I}{\partial \mu_2}|_{(0,\bar{\mu}_1)}>0$. \subsection{Proof of Theorem \ref{theo.macasymp}}\label{appen.macasymp} Similar to \cite{lai2017sum}, define $\phi(x)\stackrel{\triangle}{=} x\ln x$ and $\alpha(x)\stackrel{\triangle}{=}\frac{1}{x}\Big(e^{-1}(1+x)^{1+\frac{1}{x}}-1\Big)$. We first focus on the candidate optimal duty cycle for $3$ scenarios. For \textit{Scenario 2} of only active user $1$, since $h_b(x)=-x\ln(x)-(1-x)\ln(1-x)=x-x\ln(x)+o(x)$ and $\ln\frac{p(x)}{\tau}=\ln(x)+o(\tau)$, we have \begin{eqnarray}\label{eq.prea1} &&\frac{h_b(p_3)-h_b(p_4)}{p_3-p_4}+\ln\tau=\frac{A_1\tau-A_1\tau\frac{p_3}{\tau}+p_4\ln\frac{p_4}{\tau}+o(\tau)}{p_3-p_4} \\&=&1+\frac{\Lambda_0\ln\Lambda_0-(A_1+\Lambda_0)\ln(A_1+\Lambda_0)}{A_1}+o(1)=1-\ln(A_1+\Lambda_0)+s_1\ln\frac{s_1}{1+s_1}+o(1),\nonumber \end{eqnarray} where $s_1=\frac{\Lambda_0}{A_1}$. Thus, we have \begin{eqnarray} \label{eq.optmu2} &&\lim\limits_{\tau\to0}\tilde{\mu}_1=\lim\limits_{\tau\to0}\alpha_{\tau}(A_1,\Lambda_0)=\lim\limits_{\tau\to0}\frac{[1+\exp(\frac{h_b(p_3)-h_b(p_4)}{p_3-p_4})]^{-1}-p_4}{p_3-p_4}\nonumber\\ &=&\lim\limits_{\tau\to0}\frac{[\tau+\exp(\frac{h_b(p_3)-h_b(p_4)}{p_3-p_4}+\ln\tau)]^{-1}-\Lambda_0}{A_1}=\frac{1+s_1}{e}(\frac{s_1}{1+s_1})^{-s_1}-s_1=\alpha(s_1^{-1}). \end{eqnarray} Equation (\ref{eq.optmu2}) implies that optimal duty cycle for \textit{Scenario 2} approaches that of continuous time as $\tau\to0$ \cite[Equation (22)]{lai2017sum}. Similar to \textit{Scenario 2}, the optimal duty cycle for \textit{Scenario 3} also approaches that of continuous time as $\tau\to0$. For \textit{Scenario 1} of both active users, we focus on the asymptotic property of functions $g_{MAC}(\cdot)$ and $f_{MAC}(\cdot)$. Similar to Equation (\ref{eq.prea1}), we have \begin{eqnarray} &&\frac{\mu_1\big(h_b(p_1)-h_b(p_3)\big)+(1-\mu_1)\big(h_b(p_2)-h_b(p_4)\big)}{\mu_1(p_1-p_3)+(1-\mu_1)(p_2-p_4)}+\ln\tau\\&=&\frac{\mu_1A_2\big(1+\phi(A_1+\Lambda_0)-\phi(A_1+A_2+\Lambda_0)\big)+(1-\mu_1)A_2\big(1+\phi(\Lambda_0)-\phi(A_2+\Lambda_0)\big)}{\mu_1A_2+(1-\mu_1)A_2}+o(1)\nonumber\\&=& 1+\mu_1A_2^{-1}\big(\phi(A_1+\Lambda_0)-\phi(A_1+A_2+\Lambda_0)\big)+(1-\mu_1)A_2^{-1}\big(\phi(\Lambda_0)-\phi(A_2+\Lambda_0)\big)+o(1),\nonumber \end{eqnarray} and the function $g_{MAC}(\cdot)$ is given by \begin{eqnarray} \label{eq.asymg1} &&\lim\limits_{\tau\to0}g_{MAC}(\mu_1)=\lim\limits_{\tau\to0}\frac{(a_M\tau+\tau)^{-1}-[\mu_1(A_1+\Lambda_0)+(1-\mu_1)\Lambda_0]}{\mu_1A_2+(1-\mu_1)A_2}\nonumber\\&=&\frac{1}{A_2}\Big\{\exp\Big(-1-\mu_1A_2^{-1}\big(\phi(A_1+\Lambda_0)-\phi(A_1+A_2+\Lambda_0)\big)\nonumber\\&&-(1-\mu_1)A_2^{-1}\big(\phi(\Lambda_0)-\phi(A_2+\Lambda_0)\big)\Big)\Big\}-\frac{\mu_1A_1+\Lambda_0}{A_2}. \end{eqnarray} which is aligned with \cite[Equation (19)]{lai2017sum}. For the function $f_{MAC}(\cdot)$, note that $(p_1-p_2)(p_3-p_4)=(1-p_2)(1-p_4)p^2(A_1)$ and $(p_1-p_3)(p_2-p_4)=(1-p_3)(1-p_4)p^2(A_2)$, we have \begin{eqnarray} \lim\limits_{\tau\to0}\frac{(p_1-p_2)(p_3-p_4)}{(p_1-p_3)(p_2-p_4)}=\lim\limits_{\tau\to0}\frac{(1-p_2)p^2(A_1)}{(1-p_3)p^2(A_2)}=\frac{A_1^2}{A_2^2}, \end{eqnarray} Based on Equation (\ref{eq.prea1}) , we have \begin{eqnarray}\label{eq.asymf1} &&\lim\limits_{\tau\to0}\frac{U}{V}=\lim\limits_{\tau\to0}\frac{(p_1-p_2)\big(h_b(p_3)-h_b(p_4)\big)-(p_3-p_4)\big(h_b(p_1)-h_b(p_2)\big)}{(p_1-p_3)\big(h_b(p_2)-h_b(p_4)\big)-(p_2-p_4)\big(h_b(p_1)-h_b(p_3)\big)}\nonumber\\&=& \frac{A_1^{-1}\Big(\phi(\Lambda_0)-\phi(A_2+\Lambda_0)-\phi(A_1+\Lambda_0)+\phi(A_1+A_2+\Lambda_0)\Big)}{A_2^{-1}\Big(\phi(\Lambda_0)-\phi(A_2+\Lambda_0)-\phi(A_1+\Lambda_0)+\phi(A_1+A_2+\Lambda_0)\Big)}\lim\limits_{\tau\to0}\frac{(p_1-p_2)(p_3-p_4)}{(p_1-p_3)(p_2-p_4)}\nonumber\\&=&\frac{A_1}{A_2}, \end{eqnarray} Note that $-W=p_2\big(h_b(p_3)-h_b(p_4)\big)-p_3\big(h_b(p_2)-h_b(p_4)\big)+p_4\big(h_b(p_2)-h_b(p_3)\big)=(p_2-p_4)\big(h_b(p_3)-h_b(p_4)\big)-(p_3-p_4)\big(h_b(p_2)-h_b(p_4)\big)$ and $\lim\limits_{\tau\to0}\frac{(p_2-p_4)(p_3-p_4)}{(p_1-p_3)(p_2-p_4)}=\lim\limits_{\tau\to0}\frac{p(A_2)p(A_1)}{p^2(A_2)}=\frac{A_1}{A_2}$, we have \begin{eqnarray} \label{eq.asymf2} &&\lim\limits_{\tau\to0}\frac{W}{V}=\lim\limits_{\tau\to0}\frac{(p_2-p_4)\big(h_b(p_3)-h_b(p_4)\big)-(p_3-p_4)\big(h_b(p_2)-h_b(p_4)\big)}{(p_1-p_3)\big(h_b(p_2)-h_b(p_4)\big)-(p_2-p_4)\big(h_b(p_1)-h_b(p_3)\big)}\nonumber\\&=& \frac{A_1^{-1}\Big(\phi(\Lambda_0)-\phi(A_1+\Lambda_0)\Big)-A_2^{-1}\Big(\phi(\Lambda_0)-\phi(A_2+\Lambda_0)\Big)}{A_2^{-1}\Big(\phi(\Lambda_0)-\phi(A_2+\Lambda_0)-\phi(A_1+\Lambda_0)+\phi(A_1+A_2+\Lambda_0)\Big)}\lim\limits_{\tau\to0}\frac{(p_1-p_2)(p_3-p_4)}{(p_1-p_3)(p_2-p_4)}\nonumber\\&=& \frac{\phi(\Lambda_0)-\phi(A_1+\Lambda_0)-\frac{A_1}{A_2}\Big(\phi(\Lambda_0)-\phi(A_2+\Lambda_0)\Big)}{\phi(\Lambda_0)-\phi(A_2+\Lambda_0)-\phi(A_1+\Lambda_0)+\phi(A_1+A_2+\Lambda_0)}, \end{eqnarray} which is aligned with \cite[Equation (16)]{lai2017sum}. Based on equations (\ref{eq.asymg1}), (\ref{eq.asymf1}) and (\ref{eq.asymf2}), all candidate optimal duty cycle approach to that of continuous time as $\tau\to0$. For demonstrating the asymptotic property, we just need to show the asymptotic property of optimized objective function. According to L'Hospital's rule, we have \begin{eqnarray} &&\lim\limits_{\tau\to0}\frac{I_{X_1^2;Z}(\mu_1,\mu_2)}{\tau}=\lim\limits_{\tau\to0}\frac{\partial I_{X_1^2;Z}(\mu_1,\mu_2)}{\partial \tau}\nonumber\\ &=&\lim\limits_{\tau\to0}\mu_1\mu_2(1-p_1)(A_1+A_2+\Lambda_0)\ln\frac{(1-\hat{p})p_1}{\hat{p}(1-p_1)}+(1-\mu_1)\mu_2(1-p_2)(A_2+\Lambda_0)\ln\frac{(1-\hat{p})p_2}{\hat{p}(1-p_2)}\nonumber\\ &&+\mu_1(1-\mu_2)(1-p_3)(A_1+\Lambda_0)\ln\frac{(1-\hat{p})p_3}{\hat{p}(1-p_3)}+(1-\mu_1)(1-\mu_2)(1-p_4)\Lambda_0\ln\frac{(1-\hat{p})p_4}{\hat{p}(1-p_4)}\nonumber\\ &=&\mu_1\mu_2\phi(A_1+A_2+\Lambda_0)+(1-\mu_1)\mu_2\phi(A_2+\Lambda_0)+\mu_1(1-\mu_2)\phi(A_1+\Lambda_0)\nonumber\\ &&+(1-\mu_1)(1-\mu_2)\phi(\Lambda_0)-\phi(\mu_1A_1+\mu_2A_2+\Lambda_0), \end{eqnarray} which is aligned with \cite[Equation (8)]{lai2017sum}. Thus, the MAC Poisson capacity with non-perfect receiver approaches to that of continuous time. \subsection{Proof of Lemma \ref{lemma.sisomacsymLem}}\label{appen.sisomacsymLem} Since $\frac{\partial p_1}{\partial A}=2\tau(1-p_1)$ and $\frac{\partial p_2}{\partial A}=\tau(1-p_2)$, the derivative of $G(A)$ is given by \begin{eqnarray} \label{eq.deriGA} G^{'}(A)&=&\frac{2\tau}{(2p_2-p_1-p_4)^2}\Big\{\underbrace{[h_b^{'}(p_2)(1-p_2)-h_b^{'}(p_1)(1-p_1)]}_{>0}\underbrace{(2p_2-p_1-p_4)}_{>0}\nonumber\\&&-\underbrace{(p_1-p_2)}_{>0}\underbrace{\big(2h_b(p_2)-h_b(p_1)-h_b(p_4)\big)}_{>0}\Big\}\nonumber\\ &\overset{(a)}{=}&\frac{2\tau(p_1-p_2)}{(2p_2-p_1-p_4)}\Big\{\frac{(\ln p_1-\ln p_2)+\big(h_b(p_1)-h_b(p_2)\big)}{p_1-p_2}-\frac{2h_b(p_2)-h_b(p_1)-h_b(p_4)}{2p_2-p_1-p_4}\Big\}\nonumber\\ &\overset{(b)}{=}&\frac{2\tau(p_1-p_2)}{(2p_2-p_1-p_4)(p_2-p_4)p(A)\big(1-p(A)\big)}\Big\{[(\ln p_1-\ln p_2)+\big(h_b(p_1)-h_b(p_2)\big)]p(A)\nonumber\\&&-[2h_b(p_2)-h_b(p_1)-h_b(p_4)]\big(1-p(A)\big)\Big\}\nonumber\\ &=&\frac{2\tau(p_1-p_2)}{(2p_2-p_1-p_4)(p_2-p_4)p(A)\big(1-p(A)\big)}\Big\{[(\ln p_1-\ln p_2)]p(A)+\big(h_b(p_1)-h_b(p_2)\big)\nonumber\\&&-[h_b(p_2)-h_b(p_4)]\big(1-p(A)\big)\Big\} \end{eqnarray} where $h_b^{'}(p_2)(1-p_2)-h_b^{'}(p_1)(1-p_1)<0$ holds since $\frac{\mathrm{d}}{\mathrm{d}x}(1-x)h_b^{'}(x)=-\frac{1}{x}-\ln\frac{1-x}{x}<0$, $2p_2-p_1-p_4>0$ holds due to concave function $p(\cdot)$ and $2h_b(p_2)-h_b(p_1)-h_b(p_4)>0$ holds according to Lemma~\ref{appenAu.hpconvex}; equality $(a)$ holds since $(1-x)h_b^{'}=-\ln x-h_b(x)$; inequality $(b)$ holds since $p_1-p_2=(p_2-p_4)\big(1-p(A)\big)$ and $2p_2-p_1-p_4=(p_2-p_4)p(A)$. Define $t=p(A)$, we have $p_1=p_4+(1-p_4)p(2A)=p_4+(1-p_4)(2t-t^2)$ and $p_2=p_4+(1-p_4)t$. For obtaining $(\ref{eq.deriGA})<0$, it is sufficient to show $\hat{G}(t,p_4)=[(\ln p_1-\ln p_2)]p(A)+\big(h_b(p_1)-h_b(p_2)\big)-[h_b(p_2)-h_b(p_4)]\big(1-p(A)\big)<0$, where $0\leq t\leq\frac{1}{2}$, and \begin{eqnarray} \hat{G}(t)&\stackrel{\triangle}{=}&t\ln\frac{p_4+(1-p_4)(2t-t^2)}{p_4+(1-p_4)t}+h_b\big(p_4+(1-p_4)(2t-t^2)\big)-h_b\big(p_4+(1-p_4)t\big)\nonumber\\&&-(1-t)\Big[h_b\big(p_4+(1-p_4)t\big)-h_b\big(p_4\big)\Big], \end{eqnarray} It is easy to check that $\hat{G}(0,p_4)=0$ for any $p_4$ and $\hat{G}(t,0)=t\ln(2-t)+h_b\big(t(2-t)\big)-(2-t)h_b(t)$. Thus, we have \begin{eqnarray} \frac{\partial \hat{G}(t,0)}{\partial t}&=&\ln(2-t)-\frac{t}{2-t}+h_b^{'}\big(t(2-t)\big)2(1-t)-(2-t)h_b^{'}(t)+h_b(t)\nonumber\\ &=&2(1-t)\big(\ln\frac{(1-t)^2}{t(2-t)}-\ln\frac{1-t}{t}\big)-\ln(1-t)+\ln(2-t)-\frac{t}{2-t}\nonumber\\ &=&(1-2t)\ln\frac{1-t}{2-t}-\frac{t}{2-t},\\ \frac{\partial^2 \hat{G}(t,0)}{\partial t^2}&=&-2\ln\frac{1-t}{2-t}-(1-2t)(\frac{1}{1-t}-\frac{1}{2-t})-\frac{2}{(2-t)^2}\nonumber\\ &=&2\ln(1+\frac{1}{1-t})-\frac{1-2t}{1-t}+\frac{t(2t-5)}{(2-t)^2}\\ &\overset{(c)}{\geq}&\frac{2}{2-t}-\frac{1-2t}{1-t}+\frac{t(2t-5)}{(2-t)^2}=\frac{t}{(1-t)(2-t)^2}>0. \end{eqnarray} Thus we have $\frac{\partial \hat{G}(t,0)}{\partial t}\leq\hat{G}(\frac{1}{2},0)=-\frac{1}{3}<0$ and $\hat{G}(t,0)\leq\hat{G}(0,0)=0$. Similarly, for $p_4>0$, we have \begin{eqnarray} \frac{\partial \hat{G}(t,p_4)}{\partial t}&=&\ln\frac{p_1}{p_2}+t(1-p_4)\underbrace{\big(\frac{2(1-t)}{p_1}-\frac{1}{p_2}\big)}_{<0}+2(1-t)(1-p_4)h_b^{'}(p_1)-(2-t)(1-p_4)h_b^{'}(p_2)\nonumber\\&&+\big(h_b(p_2)-h_b(p_4)\big)\nonumber\\ &<&2(1-t)(1-p_4)\ln\frac{(1-p_1)p_2}{p_1(1-p_2)}+\ln\frac{p_1}{p_2}-t(1-p_4)h_b^{'}(p_2)+\big(h_b(p_2)-h_b(p_4)\big)\nonumber\\ &\overset{(d)}{=}&2(1-t)(1-p_4)\ln\frac{(1-t)p_2}{p_1}+\ln\frac{p_1}{p_2(1-p_2)}+p_4h_b^{'}(p_2)-h_b(p_4)\nonumber\\ &=&[2(1-t)(1-p_4)-1]\ln\frac{(1-t)p_2}{p_1}+\underbrace{\ln\frac{1-t}{1-p_2}+p_4h_b^{'}(p_2)-h_b(p_4)}_{I_r<0}\nonumber\\ &\overset{(e)}{\leq}&[2(1-p_2)-1]\ln\frac{p_1-t}{p_1}<0 \end{eqnarray} where equality $(d)$ holds since $1-p_2=(1-p_1)(1-t)$, $t(1-p_4)=p_2-p_4$ and $p_2h_b^{'}(p_2)+h_b(p_2)=-\ln(1-p_2)$, $I_r<0$ since $\ln\frac{1-t}{1-p_2}+p_4h_b^{'}(p_2)-h_b(p_4)=\ln\frac{1}{1-p_4}+p_4h_b^{'}(p_2)-h_b(p_4)<\ln\frac{1}{1-p_4}+p_4h_b^{'}(p_4)-h_b(p_4)=0$, inequality $(e)$ holds since $1-p_2=(1-t)(1-p_4)$, $(1-t)p_2=p_1-t$ and $I_r<0$. Thus, $G(A)$ decreases with peak power $A$. For peak power $A\to\infty$, we have $\lim\limits_{A\to\infty}G(A)=\lim\limits_{A\to\infty}\frac{2h_b(p_2)-h_b(p_1)-h_b(p_4)}{2p_2-p_1-p_4}=-\frac{h_b(p_0)}{1-p_0}$. For peak power $A\to0$, we have Taylor expansion on $p_1$ and $p_2$ as follows, \begin{eqnarray} p_1&=&p_4+(1-p_4)\tau\cdot 2A-\frac{1-p_4}{2}\tau^2\cdot (2A)^2+o(A^2),\\ p_2&=&p_4+(1-p_4)\tau\cdot A-\frac{1-p_4}{2}\tau^2\cdot A^2+o(A^2), \end{eqnarray} thus we have $2p_2-p_1-p_4=(1-p_4)\tau^2A^2+o(A^2)$. Similarly, we have Taylor expansion on $2h_b(p_2)-h_b(p_1)-h_b(p_4)$ as follows, \begin{eqnarray} 2h_b(p_2)-h_b(p_1)-h_b(p_4)=-[h_b^{''}(p_4)(1-p_4)-h_b^{'}(p_4)](1-p_4)\tau^2A^2+o(A^2), \end{eqnarray} and the limits $\lim\limits_{A\to0}G(A)$ is given by \begin{eqnarray} \lim\limits_{A\to0}G(A)=\frac{-[h_b^{''}(p_4)(1-p_4)-h_b^{'}(p_4)](1-p_4)\tau^2}{(1-p_4)\tau^2}=\frac{1}{p_4}+\ln\frac{1-p_4}{p_4}>\ln\frac{1-p_4}{p_4}. \end{eqnarray} Thus we have $G(A)\in(\ln(1-p_4)+\frac{p_4}{1-p_4}\ln p_4,\frac{1}{p_4}+\ln\frac{1-p_4}{p_4})$. \subsection{Proof of Lemma \ref{lemma.sisomacsymLem2}}\label{appen.sisomacsymLem2} Note that $\hat{p}\in[p_4,p_1]$ for $(\mu_1,\mu_2)\in[0,1]^2$, we have $\ln\frac{1-\hat{p}}{\hat{p}}\in[\ln\frac{1-p_1}{p_1},\ln\frac{1-p_4}{p_4}]$. Based on Lemma~\ref{appenAu.last} and $p_2-p_4>p_1-p_2$, we have $G(A)>\frac{h_b(p_2)-h_b(p_4)}{p_2-p_4}>\ln\frac{p_2}{p_2}>\ln\frac{p_1}{p_1}$. According to Lemma~\ref{lemma.sisomacsymLem} and $\lim\limits_{A\to0}G(A)=\frac{1}{p_4}+\ln\frac{1-p_4}{p_4}>\ln\frac{1-p_4}{p_4}$, there exists unique $A_{th}$ such that $\ln\frac{1-p_4}{p_4}=G(A)$ and the solution $\ln\frac{1-\hat{p}}{\hat{p}}=G(A)$ for $(\mu_1,\mu_2)\in[0,1]^2$ iff $A\geq A_{th}$. \subsection{Proof of Theorem \ref{theo.sisomacsymBound}}\label{appen.sisomacsymBound} It is easy to check that $G(A)\leq\ln\frac{1-p_4}{p_4}$ for $A\geq A_{th}$. Since $\ln\frac{1-\hat{p}}{\hat{p}}=G(A)$ and $\ln\frac{1-\hat{p}}{\hat{p}}$ decreases with $\hat{p}$, we have $\hat{p}=\frac{1}{1+\exp(G(A))}>p_4$. Note that continuous function $\hat{p}(\mu_1,\mu_2)$ increases with $\mu_1$ and $\mu_2$, thus, there exists differentiable function $f_B(\cdot)$ such that $\mathcal{C}=\{(\mu_1,\mu_2):\mu_1=f_B(\mu_2)\}$. According to Lemma~\ref{appenAu.last}, we have $G(A)>\frac{h_b(p_2)-h_b(p_4)}{p_2-p_4}>h_b^{'}(p_2)$ and $\frac{1}{1+\exp(G(A))}<p_2$. Note that the solution $\hat{p}(\mu_1,0)=\mu_1p_3+(1-\mu_1)p_4=\frac{1}{1+\exp(G(A))}\in(p_4,p_2)$ on $\mu_1$ exists, we have $0<f_B(0)<1$. For region $\mu_1\geq\mu_2$, we have \begin{eqnarray} \frac{\partial \hat{p}}{\partial \mu_1}-\frac{\partial \hat{p}}{\partial \mu_2}&=&[\mu_2(p_1-p_2)+(1-\mu_2)(p_3-p_4)]-[\mu_1(p_1-p_3)+(1-\mu_1)(p_2-p_4)]\nonumber\\&=&(\mu_1-\mu_2)(2p_2-p_1-p_4)\geq0 \end{eqnarray} Take total differential on $\hat{p}(\mu_1,\mu_2)=\frac{1}{1+\exp(G(A))}$, we have \begin{eqnarray}\label{eq.firstdefB} f_B^{'}(\mu_2)=\frac{\mathrm{d}\mu_1}{\mathrm{d}\mu_2}=-\frac{\frac{\partial \hat{p}}{\partial \mu_2}}{\frac{\partial \hat{p}}{\partial \mu_1}}\leq-1, \end{eqnarray} where the last inequality holds since $\frac{\partial \hat{p}}{\partial \mu_1}>\frac{\partial \hat{p}}{\partial \mu_2}>0$. Since the cardinality of $|\mathcal{C}\cap\mathcal{L}_{\mu_s}|$ equals the number of intersect of $\mu_1=f_B(\mu_2)$ and $\mu_1+\mu_2=2\mu_s$ for $\mu_1\geq\mu_2$. Define $g_B(\mu_2)=f_B(\mu_2)-(2\mu_s-\mu_2)$, according to Equation (\ref{eq.firstdefB}), we have $g_B^{'}(\mu_2)=f_B^{'}(\mu_2)+1\leq0$ and the number of intersect of $\mu_1=f_B(\mu_2)$ and $\mu_1+\mu_2=2\mu_s$ for $\mu_1\geq\mu_2$ is at most $1$. Furthermore, we have $|\mathcal{C}\cap\mathcal{L}_{\mu_s}|=1$ iff $f_B(0)\geq2\mu_s$ and $f_B(\mu_s)\leq\mu_s$. Define $f_B(\mu_s^{'})=\mu_s^{'}$ and $\mu_s^{*}=\frac{f_B(0)}{2}$, then we have $\mu_s^{*}=\frac{f_B(0)}{2}=\frac{\frac{1}{1+\exp(G(A))}-p_4}{2(p_2-p_4)}$ and $\mu_s^{*}<\frac{\tilde{\mu}_1}{2}$ since $G(A)>\frac{h_b(p_3)-h_b(p_4)}{p_3-p_4}$. In addition, for $\mu_s^{'}$, we have \begin{eqnarray}\label{eq.musapos} (2p_2-p_1-p_4)(\mu_s^{'})^2-2(p_2-p_4)\mu_s^{'}+\big(\frac{1}{1+\exp(G(A))}-p_4\big)=0 \end{eqnarray} Since $2p_2-p_1-p_4>0$, $p_2-p_4>0$ and $\frac{1}{1+\exp(G(A))}-p_4>0$, the two solutions on Equation (\ref{eq.musapos}) both are positive. Note that the summation of the two solutions equals to $\frac{2(p_2-p_4)}{2p_2-p_1-p_4}>2$, thus there exists unique feasible solution as follows, \begin{eqnarray} \mu_s^{'}=\frac{(p_2-p_4)-\sqrt{(p_2-p_4)^2-(2p_2-p_1-p_4)[\frac{1}{1+\exp(G(A))}-p_4]}}{2p_2-p_1-p_4}. \end{eqnarray} \subsection{Proof of Lemma \ref{lemma.sisomacsymLemAth}}\label{appen.sisomacsymLemAth} For any fixed peak power $A$, we need to show that there exists $\tau>0$ such that $G(A)>\ln\frac{1-p_4}{p_4}$. The main clue is based on Taylor expansion of $\tau$. Note that $p(x)=x\tau-\frac{1}{2}x^2\tau^2+o(\tau^2)$, we have \begin{eqnarray}\label{eq.taylorp} 2p_2-p_1-p_4=\frac{1}{2}[(2A+\Lambda_0)^2+\Lambda_0^2-(A+\Lambda_0)^2]\tau^2+o(\tau^2)=A^2\tau^2+o(\tau^2). \end{eqnarray} Since $h_b(x)=(1-\ln x)x+o(x)$, we have Taylor expansion of $h_b\big(p(x)\big)$ on $\tau$ as follows, \begin{eqnarray} \label{eq.taylorhbp} h_b\big(p(x)\big)&=&[1-\ln p(x)]p(x)+o\big(p(x)\big)=p(x)-p(x)\ln\tau+p(x)\ln(x+o(\tau))+o(\tau)\nonumber\\&=&p(x)-p(x)\ln\tau+[x\ln x] \tau+o(\tau). \end{eqnarray} Similarly, we have \begin{eqnarray}\label{eq.taylorlnder} \ln\frac{1-p_4}{p_4}=-\ln\tau-\ln\Lambda_0-\Lambda_0\tau+o(\tau), \end{eqnarray} Based on Equations (\ref{eq.taylorp}), (\ref{eq.taylorhbp}) and (\ref{eq.taylorlnder}), we have \begin{eqnarray} G(A)-\ln\frac{1-p_4}{p_4}&=&\frac{2h_b(p_2)-h_b(p_1)-h_b(p_4)}{2p_2-p_1-p_4}-\ln\frac{1-p_4}{p_4}\nonumber\\ &=&(1-\ln\tau)+\frac{[2(A+\Lambda_0)\ln(A+\Lambda_0)-(2A+\Lambda_0)\ln(2A+\Lambda_0)-\Lambda_0\ln\Lambda_0]\tau}{A^2\tau^2}\nonumber\\ &&-[-\ln\tau-\ln\Lambda_0]+O(1) \nonumber\\ &=&\frac{[2(A+\Lambda_0)\ln(A+\Lambda_0)-(2A+\Lambda_0)\ln(2A+\Lambda_0)-\Lambda_0\ln\Lambda_0]}{A^2}\frac{1}{\tau}+O(1). \end{eqnarray} Since function $x\ln x$ is convex and $2(A+\Lambda_0)\ln(A+\Lambda_0)-(2A+\Lambda_0)\ln(2A+\Lambda_0)-\Lambda_0\ln\Lambda_0>0$, there exists $\tau>0$ such that $G(A)>\ln\frac{1-p_4}{p_4}$ for any fixed peak power $A$, i.e., $\lim\limits_{\tau\to0}A_{th}=+\infty$. \subsection{Proof of Proposition \ref{prop.misomacwork}}\label{appen.misomacwork} Define $b_{mj}(i_m)\in\{0,1\}$ as $j^{th}$ bit in the binary representation of '$i_m$' for user $m$, where $i_m=0,1,\cdots,2^{J_m}-1$, $i_m=\sum_{j_m=1}^{J_m}b_{mj_m}(i_m)2^{j-1}$. Define joint PMF $\mathbf{q}_{[M]}=(\mathbf{q}_1,\mathbf{q}_2)$, where $\mathbf{q}_m=\{q_{mi_m}\}_{i_m=0}^{2^{J_m}-1}$, $q_{mi_m}\stackrel{\triangle}{=}\mathbb{P}(X_{mj}=b_{mj_m}(i)A_{mj}),i_m=0,1,\cdots,2^{J_m}-1$. Then, $\mathbf{q}_{[M]}$ satisfies \begin{eqnarray}\label{eq.macqconstr} q_{mi_m}&\geq&0, \quad i=0,1,\cdots,2^{J_m}-1;\nonumber\\ \sum_{i_m=0}^{2^{J_m}-1}q_{mi_m}&=&1;\\ \sum_{i_m=0}^{2^{J_m}-1}b_{mj_m}(i_m)q_{mi_m}&=&\mu_{mj_m},j_m=1,2,\cdots,J_m,\quad m=1,2.\nonumber \end{eqnarray} Define $\hat{r}_{i_1i_2}=p(\sum_{m=1}^{2}\sum_{j_m=1}^{j_m}b_{mj_m}(i_m)A_{mi_m}+\Lambda_0)$. Noting that $\mu_{mj_m}=\sum_{i_m=0}^{2^J_m-1}b_{j_m}(i_m)q_{mj_m}$ for $j_m=1,2\cdots,J_m$, we have $C_{MISO-MAC}=\max\limits_{\mu_{[MJ]}\in[0,1]^{MJ}}\frac{1}{\tau}I_{MISO}(\mu_{[MJ]})$, where \begin{eqnarray}\label{eq.macjoint} I_{MISO_MAC}(\mu_{[MJ]})&=&\max\limits_{\mathbf{q}_{M}}h_b\Big(\sum_{i_2=0}^{2^{J_2}-1}\sum_{i_1=0}^{2^{J_1}-1}q_{2i_2}q_{1i_1}\hat{r}_{i_1i_2}\Big)-\sum_{i_2=0}^{2^{J_2}-1}\sum_{i_1=0}^{2^{J_1}-1}q_{2i_2}q_{1i_1}h_b(\hat{r}_{i_1i_2})\nonumber\\ &=&\max\limits_{\mathbf{q}_{[M]}}h(\mathbf{q}_{[M]}). \end{eqnarray} Noting that \begin{eqnarray} \sum_{i_2=0}^{2^{J_2}-1}\sum_{i_1=0}^{2^{J_1}-1}q_{1i_1}q_{2i_2}\sum_{m=1}^{2}\sum_{j_m=1}^{J_m}b_{mj_m}(i_m)h_b\big(p(A_{mj_m})\big)&=&\sum_{m=1}^{2}\sum_{j_m=1}^{J_m}\sum_{i_2=0}^{2^{J_2}-1}\sum_{i_1=0}^{2^{J_1}-1}q_{1i_1}q_{2i_2}h_b\big(p(A_{mj_m})\big)\nonumber\\ &=&\sum_{m=1}^{2}\sum_{j_m=1}^{J_m}\mu_{mj_m}h_b\big(p(A_{mj_m})\big), \end{eqnarray} we have \begin{eqnarray} h(\mathbf{q_m})&=&h_b\Big(\sum_{i_2=0}^{2^{J_2}-1}\sum_{i_1=0}^{2^{J_1}-1}q_{2i_2}q_{1i_1}\hat{r}_{i_1i_2}\Big)-\sum_{i_2=0}^{2^{J_2}-1}\sum_{i_1=0}^{2^{J_1}-1}q_{1i_1}q_{2i_2}h_b(\hat{r}_{i_1i_2})\nonumber\\&&+\sum_{i_2=0}^{2^{J_2}-1}\sum_{i_1=0}^{2^{J_1}-1}q_{1i_1}q_{2i_2}\sum_{m=1}^{2}\sum_{j_m=1}^{J_m}b_{mj_m}(i_m)h_b\big(p(A_{mj_m})\big)-\sum_{m=1}^{2}\sum_{j_m=1}^{J_m}\mu_{mj_m}h_b\big(p(A_{mj_m})\big),\nonumber \end{eqnarray} \begin{eqnarray} \frac{\partial h(\mathbf{q_{[M]}})}{\partial q_{mi_m}}&=&\sum_{i_{\bar{m}}=0}^{2^{J_{\bar{m}}}-1}\hat{r}_{i_mi_{\bar{m}}}\ln\frac{1-\sum_{i_2=0}^{2^{J_2}-1}\sum_{i_1=0}^{2^{J_1}-1}q_{2i_2}q_{1i_1}\hat{r}_{i_1i_2}}{\sum_{i_2=0}^{2^{J_2}-1}\sum_{i_1=0}^{2^{J_1}-1}q_{2i_2}q_{1i_1}\hat{r}_{i_1i_2}}-\sum_{i_{\bar{m}}=0}^{2^{J_{\bar{m}}}-1}q_{{\bar{m}}i_{\bar{m}}}h_b\big(\hat{r}_{i_mi_{\bar{m}}}\big)\nonumber\\&&+\sum_{i_{\bar{m}}=0}^{2^{J_{\bar{m}}}-1}q_{{\bar{m}}i_{\bar{m}}}\sum_{m=1}^{2}\sum_{j_m=1}^{J_m}b_{mj_m}(i_m)h_b\big(p(A_{mj_m})\big),\label{eq.deriveh} \end{eqnarray} where $\bar{m}=3-m$. Let $I_{mi_m} =\{j_m\in\{1,2\cdots,J_m\} : b_{mj_m}(i_m)=1\}$ denotes the set of nonzero bit positions in the binary representation of $i_m, i_m=0,1,\cdots,2^{J_m}-1$. Then, we will show that $I_{mi_m^{'}}\subseteq I_{mi_m}$ leads to \begin{eqnarray} \frac{\partial h(\mathbf{q_{[M]}})}{\partial q_{mi_m^{'}}}\leq\frac{\partial h(\mathbf{q_{[M]}})}{\partial q_{mi_m}},\text{ for } i_m,i_m^{'}\in\{0,1,\cdots,2^{J_m}-1\}. \end{eqnarray} For $\tau\leq\frac{\ln2}{\sum_{m=1}^{2}\sum_{j_m=1}^{J}A_{mj_m}+\Lambda_0}$, we have $\ln\frac{1-\sum_{i_2=0}^{2^{J_2}-1}\sum_{i_1=0}^{2^{J_1}-1}q_{2i_2}q_{1i_1}\hat{r}_{i_1i_2}}{\sum_{i_2=0}^{2^{J_2}-1}\sum_{i_1=0}^{2^{J_1}-1}q_{2i_2}q_{1i_1}\hat{r}_{i_1i_2}}>0$. According to lemma \ref{appenAu.hpconvex}, $h_b\big(p(x)\big)$ is concave. Based on Lemma \ref{appenAu.concavepro} and $h_b\big(p(0)\big)=0$, we have \begin{eqnarray} \sum_{i_{\bar{m}}=0}^{2^{J_{\bar{m}}}-1}q_{{\bar{m}}i_{\bar{m}}}[h_b\big(\hat{r}_{i_mi_{\bar{m}}}\big)-h_b\big(\hat{r}_{i^{'}_mi_{\bar{m}}}\big)]&\leq& \sum_{i_{\bar{m}}=0}^{2^{J_{\bar{m}}}-1}q_{{\bar{m}}i_{\bar{m}}}h_b\big(p(\sum_{m=1}^{2}\sum_{j_m=1}^{J_m}[b_{mj_m}(i_m)-b_{mj_m}(i^{'}_m)]A_{mj_m})\big)\nonumber\\&\leq& \sum_{i_{\bar{m}}=0}^{2^{J_{\bar{m}}}-1}q_{{\bar{m}}i_{\bar{m}}}\sum_{m=1}^{2}\sum_{j_m=1}^{J_m}[b_{mj_m}(i_m)-b_{mj_m}(i^{'}_m)]h_b\big(p(A_{mj_m})\big).\nonumber \end{eqnarray} According to equation (\ref{eq.deriveh}) and $r_i\geq r_{i^{'}}$, we have \begin{eqnarray} \frac{\partial h(\mathbf{q_{[M]}})}{\partial q_{mi_m}}-\frac{\partial h(\mathbf{q_{[M]}})}{\partial q_{mi^{'}_m}}=\sum_{i_{\bar{m}}=0}^{2^{J_{\bar{m}}}-1}\underbrace{(\hat{r}_{i_mi_{\bar{m}}}-\hat{r}_{i^{'}_mi_{\bar{m}}})}_{\geq0}\underbrace{\ln\frac{1-\sum_{i_2=0}^{2^{J_2}-1}\sum_{i_1=0}^{2^{J_1}-1}q_{2i_2}q_{1i_1}\hat{r}_{i_1i_2}}{\sum_{i_2=0}^{2^{J_2}-1}\sum_{i_1=0}^{2^{J_1}-1}q_{2i_2}q_{1i_1}\hat{r}_{i_1i_2}}}_{\geq0}\\+\sum_{i_{\bar{m}}=0}^{2^{J_{\bar{m}}}-1}q_{{\bar{m}}i_{\bar{m}}}\underbrace{\Big\{\sum_{m=1}^{2}\sum_{j_m=1}^{J_m}b_{mj_m}(i_m)h_b\big(p(A_{mj_m})\big)-[h_b\big(\hat{r}_{i_mi_{\bar{m}}}\big)-h_b\big(\hat{r}_{i^{'}_mi_{\bar{m}}}\big)]\Big\}}_{\geq0}\geq0. \end{eqnarray} Similar to \cite[Appendix B.2]{Chakraborty05}, property $\frac{\partial h(\mathbf{q_{[M]}})}{\partial q_{mi_m}}\geq\frac{\partial h(\mathbf{q_{[M]}})}{\partial q_{mi^{'}_m}}$ for $I_{i^{'}}\subseteq I_{i}$ suggests the following $J+1$ steps algorithm for $m=1,2$ to complete the optimal PMF vector $\mathbf{q}_[M]^{*}$: \begin{itemize} \item Step $0$: For $\mu_{[MJ]}$ that does not satisfy $\mu_{m1}\geq\mu_{m2}\geq\cdots\geq\mu_{mJ_m}$, we can take a permutation $\Pi_m:\{1,\cdots,J_m\}\rightarrow\{1,\cdots,J_m\}$ such that $\mu_{m\Pi_m(i_m)}\geq\mu_{m\Pi_m(i_m+1)},i_m=1,\cdots,J_m-1$. Repeating Step $1$ to Step $J$, we can have similar result by substituting $\Pi_m(j)$ to $j$. \item Step 1: Assume $\mu_{m1}\geq\mu_{m2}\geq\cdots\geq\mu_{mJ_m}$. Since $\frac{\partial h(\mathbf{q})}{\partial q_{2^J-1}}\geq\frac{\partial h(\mathbf{q})}{\partial q_{i}}$ for all $i=0,1,\cdots,2^J-1$, $q^{*}_{m(2^J-1)}$ should be assigned the biggest allowable value. Note that $q_{m(2^J-1)}\leq\mu_{mj},j_m=1,\cdots,J_m$, we have \begin{eqnarray} q^{*}_{m(2^J-1)}=\min\limits_{j_m=1,\cdots,J_m}\mu_{mj}=\mu_{mJ_m}. \end{eqnarray} Due to constraints equation (\ref{eq.macqconstr}), we have $q^{*}_{mi_m}=0$ for $i_m$ with $b_{mJ_m}(i_m)=1$ and $i_m\neq2^{J_m}-1$. \item Step 2: For all $i_m\in\{0,1,\cdots,2^{J_m}-1\}$ and $b_{mJ_m}(i_m)=0$, we have $\frac{\partial h(\mathbf{q}_{[M]}}{\partial q_{i_m^{'}}}\geq\frac{\partial h(\mathbf{q}_{[M]})}{\partial q_{i_m}}$, where $i_m^{'}=\sum_{j_m=1}^{J_m-1}2^{j}_m-1$. Furthermore, for all $i_m$, $b_{mJ_m}(i_m)=0$, it follows that $q_{mi_m}\leq\mu_{mj}-\mu_{mJ_m}$ for $j_m=1,\cdots J_m-1$. Summarizing these facts, we have $q^{*}_{m(2^{J_m-1}-1)}=\mu_{J_m-1}-\mu_{J_m}$, and $q^{*}_{mi_m}=0$ for $i_m$ with $b_{mJ_m}(i_m)=0,b_{J_m-1}(i_m)=1$, and $i_m\neq\sum_{j_m=1}^{J_m-1}2^{j_m-1}$. \item Step $k_m$, $2<k_m<J_m$: Similar to Step $2$, we get $ q^{*}_{m(2^{J_m-k_m+1}-1)}=\mu_{J_m-k_m+1}-\mu_{J_m-k_m+2}$ and $q^{*}_{mi_m}=0$, for $i_m$ with $b_s(i_m)=0$, where $s=J_m-k_m+2,\cdots,J$, and $b_{m(J_m-k_m+1)}(i_m)=1,i_m\neq\sum_{j_m=1}^{J_m-k_m+1}2^{j_m-1}$. \item Step $J_m$: The only remaining PMF is $q_{m0}^{*}$ and $q_{m0}^{*}=1-\sum_{i_m=1}^{2^J_m-1}q_{mi_m}^{*}$. \end{itemize} Thus, the right side of equation (\ref{eq.macjoint}) is maximized for $q_{mi}^{*}=\nu_{mi}$ if there exists $k_m\in\{0,1,\cdots,J\}$ such that $i_m=\sum_{j=1}^{k_m}2^{\Pi_m(j)-1}$; otherwise $q_i^{*}=0$, where \begin{eqnarray}\label{eq.optnu2} \nu_{mi}\stackrel{\triangle}{=}\left\{\begin{array}{ll} 1-\mu_{\Pi_m(1)},&i=0, \\ \mu_{\Pi_m(i_m)}-\mu_{\Pi_m(i_m+1)},&i_m=1,\cdots,J_m-1, \\ \mu_{\Pi_m(J_m)},&i=J_m; \end{array}\right. \end{eqnarray} and $\Pi_m:\{1,\cdots,J_m\}\rightarrow\{1,\cdots,J_m\}$ is a permutation of $\{1,\cdots,J_m\}$ such that $\mu_{\Pi_m(i_m)}\geq\mu_{\Pi_m(i_m+1)},i_m=1,\cdots,J_m-1$. \subsection{Proof of Proposition \ref{prop.misomacwork2}}\label{appen.misomacwork2} For simplicity, define $s_{mj_m}=p(\sum_{i_m=1}^{j_m}A_{mi_m}+\Lambda_0)$ for $m=1,2$, and $\hat{s}_{j_1j_2}=p(\sum_{m=1}^{2}\sum_{i_m=1}^{j_m}A_{mi_m}+\Lambda_0)$. Based on symmetry, without loss of generality, assume $\mu_{m1}\geq\mu_{m2}\geq\cdots\geq\mu_{mJ_m}$. We know \begin{eqnarray} I_{MISO-MAC}(\mathbf{\mu}_{[MJ]})=h_b\Big(\sum_{j_1=0}^{J_1}\sum_{j_2=0}^{J_2}\nu_{1j_1}\nu_{2j_2}\hat{s}_{j_1j_2}\Big)-\sum_{j_1=0}^{J_1}\sum_{j_2=0}^{J_2}\nu_{1j}\nu_{2j}h_b\big(\hat{s}_{j_1j_2}\big), \end{eqnarray} Note that $\sum_{j=0}^{J_m}\nu_{mj}=1$ for $m=1,2$, after rearrangement we get \begin{eqnarray} &&I_{MISO-MAC}(\mathbf{\mu}_{[MJ]})\nonumber\\&=&h_b\Big(\sum_{j_2=0}^{J_2}\nu_{2j_2}\big[(1-\sum_{j_1=1}^{J_1}\nu_{1j_1})s_{2j_2}+\sum_{j_1=1}^{J_1}\nu_{1j_1}\hat{s}_{j_1j_2}\big]\Big)\nonumber\\&&-\Big(\sum_{j_2=0}^{J_2}\nu_{2j_2}\big[(1-\sum_{j_1=1}^{J_1}\nu_{1j_1})h_b(s_{2j_2})+\sum_{j_1=1}^{J_1}\nu_{1j_1}h_b\big(\hat{s}_{j_1j_2}\big)\big]\Big)\nonumber\\ &=&h_b\Big(\sum_{j_2=0}^{J_2}\nu_{2j_2}\big[s_{2j_2}+u_{2J_2}\big(\hat{s}_{j_1j_2}-s_{2j_2}\big)-\sum_{j_1=1}^{J_1-1}u_{1j_1}\big(\hat{s}_{j_1j_2}-s_{2j_2}\big)\big]\Big)-\sum_{j_2=0}^{J_2}\nu_{2j_2}\big[h_b(s_{2j_2})\nonumber\\&&+u_{2J_2}\big(h_b(\hat{s}_{j_1j_2})-h_b(s_{2j_2})\big)-\sum_{j_1=1}^{J_1-1}u_{1j_1}\big(h_b(\hat{s}_{j_1j_2})-h_b(s_{2j_2})\big)\big] \end{eqnarray} where $u_{mj_m}\stackrel{\triangle}{=}\nu_{mj_m}$ for $j_m=1,2,\cdots,J_m-1$, $m=1,2$ and $u_{J_m}\stackrel{\triangle}{=}\sum_{j_m=1}^{J_m}\nu_{mj_m}$, then we have $0\leq u_{mj_m}\leq 1$ for $j_m=1,2,\cdots,J_m-1$ and $\max\{u_{mj_m},j_m=1,2,\cdots,J_m-1\}\leq u_{J_m}\leq 1$. Note that $\hat{s}_{J_1J_2}=p(\sum_{m=1}^{2}\sum_{j_m=1}^{J_m}A_{mj}+\Lambda_0)\leq\frac{1}{2}$, then for $j_m=1,2,\cdots,J_m-1$, \begin{eqnarray} \frac{\partial I_{MISO-MAC}}{\partial u_{2j_2}}&=&\underbrace{-h_b^{'}\Big(\sum_{j_2=0}^{J_2}\nu_{2j_2}\big[s_{2j_2}+u_{2J_2}\big(\hat{s}_{j_1j_2}-s_{2j_2}\big)-\sum_{j_1=1}^{J_1-1}u_{1j_1}\big(\hat{s}_{j_1j_2}-s_{2j_2}\big)\big]\Big)}_{\leq0}\nonumber\\&&\cdot\sum_{j_2}^{J_2}\nu_{2j_2}\big(\hat{s}_{j_1j_2}-s_{2j_2}\big)-\underbrace{\big[\big(h_b(\hat{s}_{j_1j_2})-h_b(s_{2j_2})\big)\big]}_{>0}<0 \end{eqnarray} and the max range of optimized $u_{J_m}$ corresponds to $u_{m1}=u_{m2}=\cdots=u_{J_m-1}$, we have the optimal $u_{[MJ]}$ satisfies $u_{m1}=u_{m2}=\cdots=u_{J_m-1}$, which implies $\mu_{m1}=\mu_{m2}=\cdots=\mu_{mJ}$ for $m=1,2$. \renewcommand{\baselinestretch}{1.4} \section{Auxilary Lemma} \begin{lemma}\label{appenAu.convex} Assume function $f(x)$ is strictly convex and its first-order derivative exists. For $x>y$, then we have function $g(x,y)\stackrel{\triangle}{=}\frac{f(x)-f(y)}{x-y}$ strictly monotonically increases with $x$, strictly monotonically decreases with $y$. To be specific, we have $f^{'}(y)<\frac{f(x)-f(y)}{x-y}<f^{'}(x)$ \begin{proof} According to Lagrange mean value theorem, for $x>y$, we have $f(x)-f(y)=f^{'}(\xi)(x-y)<f^{'}(x)(x-y)$, where $y<\xi<x$. Since $g^{'}_x=\frac{f^{'}(x)(x-y)-[f(x)-f(y)]}{(x-y)^2}>0$, function $g(x,y)$ strictly monotonically increases with $x$. Similarly, we have function $g(x,y)$ strictly monotonically decreases with $y$. Note that function $g(x,y)$ strictly monotonically increases with $x$, we have $f^{'}(x)=\sup\limits_{y:x>y}\frac{f(x)-f(y)}{x-y}>\frac{f(x)-f(y)}{x-y}$ for any $y<x$. Similarly, we have $f^{'}(y)<\frac{f(x)-f(y)}{x-y}$. \end{proof} \end{lemma} \begin{lemma}\label{appenAu.hpconvex} Assume $\tau\leq\frac{\ln2}{b}$. $p(x)=1-e^{-x\tau}$, then we have function $h_b\big(p(x)\big)$, $x\in[0,b]$ is concave. \begin{proof} Note that $[h_b(p(x))]^{''}=h_b^{''}(p(x))[p^{'}(x)]^2+h_b^{'}(p(x))g^{''}(x)$, $h_b^{''}(x)<0$, $h_b(x)$ monotonically increase if $x\leq\frac{1}{2}$ and $p^{''}(x)<0$, we have $h_b^{''}\big(p(x)\big)<0$ when $\tau\leq\frac{\ln2}{b}$. \end{proof} \end{lemma} \begin{lemma}\label{appenAu.concavepro} Assume function $f(x)$ is concave. For $a<b<c<d$ and $a+d=b+c$, then we have $f(a)+f(d)<f(b)+f(c)$. \begin{proof} Note that $b-a=d-c$ and $f(x)$ is concave, then we have $f(b)-f(a)>f(d)-f(c)$. \end{proof} \end{lemma} \begin{lemma}\label{appenAu.convexyfrac} For $f(x)=\frac{d_2x+d_3}{d_1x+d_0}$, $x\in[0,1]$ and $\min\{d_0,d_1+d_0\}>0$. if $d_1<0$ and $d_2d_0-d_3d_1<(>)0$, then $f(x)$ is concave (convex) and monotonically decrease (increase). \begin{proof} Taking the derivative of $f(x)$, we have $f^{'}(x)=\frac{d_2d_0-d_3d_1}{(d_1x+d_0)^2}$ and $f^{''}(x)=-2d_1\frac{d_2d_0-d_3d_1}{(d_1x+d_0)^3}$. Therefore, it is obvious to complete the proof. \end{proof} \end{lemma} \begin{lemma}\label{appenAu.last} For $a,b,c,d>0$, $a<c$, and $\frac{b}{a}<\frac{d}{c}$, then we have $\frac{b}{a}<\frac{d}{c}<\frac{d-b}{c-a}$ for any $\mu\in[0,1]$ \begin{proof} It is easy to check \begin{eqnarray} \frac{d}{c}<\frac{d-b}{c-a}\Leftrightarrow dc-da<dc-bc\Leftrightarrow bc<ad \end{eqnarray} \end{proof} \end{lemma} \begin{lemma}\label{appenAu.sisomacaux} For $a,b,c,d>0$, $a<c$, $\frac{b}{a}<\frac{d}{c}$ and $f(\mu)\stackrel{\triangle}{=} \frac{\mu b+(1-\mu)d}{\mu a+(1-\mu)c}$, then we have $\mu\frac{b}{a}+(1-\mu)\frac{d}{c}<f(\mu)<\frac{d}{c}$ for any $\mu\in(0,1)$, $f^{'}(\mu)<0$ and $f^{''}(\mu)<0$ \begin{proof} For the inequality on $f(\mu)$, we have \begin{eqnarray} \frac{\mu b+(1-\mu)d}{\mu a+(1-\mu)c}>\mu\frac{b}{a}+(1-\mu)\frac{d}{c}\Leftrightarrow \frac{\mu(b-da/c)}{\mu a+(1-\mu)c}>\frac{\mu(b-da/c)}{a}\Leftrightarrow a<c, \nonumber \end{eqnarray} Based on Lemma \ref{appenAu.last}, we have \begin{eqnarray} f^{'}(\mu)&=&c(\frac{d}{c}-\frac{d-b}{c-a})(c-a)[c-(c-a)\mu]^{-2}<0,\\ f^{''}(\mu)&=&2c(\frac{d}{c}-\frac{d-b}{c-a})(c-a)^2[c-(c-a)\mu]^{-3}<0, \end{eqnarray} \end{proof} \end{lemma} \renewcommand{\baselinestretch}{1.3} \small{\baselineskip = 10pt \bibliographystyle{IEEEtran}
{'timestamp': '2019-04-23T02:27:37', 'yymm': '1904', 'arxiv_id': '1904.09924', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.09924'}
arxiv
\section{Introduction} Graph Neural Networks (GNNs) have been popularly used for analyzing graph data such as social network data and biological data. The basic idea of GNNs such as GraphSAGE ~\cite{GraphSAGE} is to propagate feature information between neighboring nodes so that nodes can learn feature representations by using locally connected graph structure information. Although GNNs have achieved great success, one shorting is to tune many parameters of the graph neural architectures. Similar to CNNs that contain many manually setting parameters such as the sizes of filters, the types of pooling layers and residual connections, tuning the parameters of GNNs generally takes heavy manual work which requires domain knowledge as well. Recently we observe that reinforcement learning has been successfully used to generate accurate neural architectures for CNNs and RNNs. The seminar work NAS~\cite{NAS} uses a recurrent network as controller to generate CNN and RNN network descriptions (which are referred to as child networks), and then uses the validation results of the child networks as feedback of the controller to maximize the expected accuracy of the generated architectures of the CNNs and RNNs. According to the experimental reports, the NAS search algorithm can improve CNNs and RNNs on benchmark data by percentage of 0.09 on the CIFAR-10 data and 3.6 perplexity on the Penn Treebank data. Inspired by NAS, a large body of advanced neural architecture search algorithms based on reinforcement learning have been proposed to improve its efficient and accuracy, such as the Efficient neural architecture search algorithm (ENAS ~\cite{ENAS}) and Stochastic Neural Architecture Search algorithm (SNAS) ~\cite{Xie2018SNASSN}. The promising results of using NAS to search neural architectures for CNNs and RNNs motivate us to use reinforcement learning to search graph neural architectures in this work. Our idea is similar to NAS for CNNs and RNNs that first uses a recurrent network as controller to generate the descriptions of GNNs and then compute the rewards of the GNNs as feedback of the controller to maximize the expected accuracy of the generated architectures of the GNNs. However, when using NAS for graph neural architecture search, the following new challenges need to be addressed: \begin{itemize} \item \textit{Challenge 1}. How to design the search space of GNNs. Different from CNNs for processing regular grid-structural inputs, GNNs for processing graph data that are non-Euclidean and irregularly distributed in a feature space generally contain both spatial and convolutional descriptions \cite{GraphSAGE} and GCN \cite{kipf2017semi} . \item \textit{Challenge 2}. How to design an efficient reinforcement learning search algorithm. The search space of GNNs are generally very large. When generating the descriptions for GNNs by the controller, the training of reinforcement learning converges slowly. \item \textit{Challenge 3}. How to evaluate the performance of the algorithm in both transductive and inductive learning settings is the third challenge. \end{itemize} In this paper, we present an efficient \textit{Graph Neural Architecture Search} algorithm GraphNAS that can automatically generate neural architecture for GNNs by using reinforcement learning. To solve \textit{Challenge 1}, GraphNAS designs a search space covering sampling functions, aggregation functions and gated functions. To solve \textit{Challenge 2}, GraphNAS uses a new parameters sharing and architecture search algorithm that is more efficient than NAS for CNNs and RNNs. To solve \textit{Challenge 3}, we validate the performance of GraphNAS on node classification tasks in both transductive and inductive learning settings. The results demonstrate that GraphNAS can achieve consistently better performance on the Cora, Citeseer, Pubmed citation network, and protein-protein network. The contribution of the paper is fourfolder: \begin{itemize} \item We first study the problem of using reinforcement learning to search graph neural architectures, which has the potential to save a lot of manual work for designing graph neural architectures. \item We present a new GraphNAS algorithm that can efficiently search the graph neural architectures in a large search space. \item We validate the performance of GraphNAS on real-world data sets. The results show that GraphNAS can design a graph neural architecture that rivals the best human-invented architecture in terms of accuracy and F1 score on test sets. \item We publish the Python codes based on Pytorch for future comparisons at: https://github.com/GraphNAS/GraphNAS-simple \end{itemize} \section{Related work} \textbf{Graph Neural Networks}. The notation of graph neural networks was firstly outlined in the work ~\cite{Gori2005A}. Inspired by the convolutional networks in computer vision, a large number of methods that re-define the notation of convolution filter for graph data have been proposed recently. convolution filters for graph data fall into two categories, spectral-based and spatial-based. As spectral methods usually handle the whole graph simultaneously and are difficult to parallel or scale to large graphs, spatial-based graph convolutional networks have rapidly developed recently ~\cite{GraphSAGE,Monti2017GeometricDL,Niepert2016LearningCN,Gao2018LargeScaleLG,GAT}. These methods directly perform the convolution in the graph domain by aggregating the neighbor nodes’ information. Together with sampling strategies, the computation can be performed in a batch of nodes instead of the whole graph ~\cite{GraphSAGE,Gao2018LargeScaleLG}. Recent graph neural architectures follow the neighborhood aggregation scheme that consists of three types of functions, i.e., neighbor sampling, correlation measurement, and information aggregation. Each layer of GNNs includes the combination of the three types of functions. For example, each layer of semi-GCN~\cite{kipf2017semi} consists of the first-order neighbor sampling, correlation measured by node's degree and the aggregate function. In this paper, we use reinforcement learning to search the best combination of these types of functions on each layer of GNNs, instead of manual settings in the previous work. \noindent\textbf{Neural architecture search}. Neural architecture search (NAS) has been popularly used to design convolutional architectures for classification tasks with image and text streaming as input~\cite{NAS,ENAS,Xie2018SNASSN,Zoph2018LearningTA,Bello2017NeuralOS}. The seminal work of using reinforcement learning for neural architecture search aims to automatically design deep neural architecture by using a recurrent network to generate structure description of CNNs and RNNs. Following the NAS, Evolution-based NAS such as work in ~\cite{Real2017LargeScaleEO,Real2018RegularizedEF} employs evolution algorithm to simultaneously optimize topology alongside with parameters. However, evolution-based methods take enormous computational time and could not leverage the efficient gradient back-propagation. To achieve the state-of-the-art performance as human-designed architectures, the work~\cite{Real2018RegularizedEF} takes 3150 GPU days for the whole evolution. In comparison, the work ENAS ~\cite{ENAS} is end-to-end for gradient back-propagation. To get rid of the architecture sampling process, DARTS ~\cite{Liu2018DARTSDA} replace the feedback triggered by constant rewards in reinforcement learning with more efficient gradient feedback from generic loss. \section{Methods} In this section, we first introduce the problem of searching graph neural architectures with reinforcement learning. Then, we establish the search space and we discuss an efficient search algorithm based on policy gradient descent and the parameter sharing method during training. \subsection{Problem formulation} Given the search space of a graph neural architecture $\mathcal{M}$, we aim to find the best architecture $m^{*} \in \mathcal{M}$ that maximizes the accuracy $\mathcal{R}$ of the network on a validation set $D$. Here we use reinforcement learning to obtain $m^{*}$ by sampling from feasible architectures in the space $\mathcal{M}$ based on the rewards $\mathcal{R}$ observed on $D$. % \textbf{Figure~\ref{fig:GraphNAS-RL}} shows the entire reinforcement learning framework. First, the recurrent network generates network descriptions of GNNs. Then, the generated GNNs are tested on the given validate set $D$ and the test results are used as feedback of the recurrent network. The iteration maximizes the expected accuracy of the generated GNNs on the set $D$. \label{formulation} \begin{figure} \includegraphics[width=0.48\textwidth]{RL.pdf} \caption{A simple illustration of GraphNAS. A recurrent network (the upper part) generates descriptions of graph neural architectures (the lower part), and then the validation results of the generated GNNs are used as feedback of the recurrent network (the upper part) to maximize the expected accuracy of the generated graph neural architecture (the lower part). The actions showed in current picture is not complete. All actions are described in Section~\ref{Search Space} } \label{fig:GraphNAS-RL} \end{figure} Formally, during the learning process, the recurrent network as the controller maximizes the expected accuracy $\mathcal{E}_{P(m;\theta)}[\mathcal{R}(m(w^{*},\mathcal{G}))]$ on the validation set $D$, where $P(m;\theta)$ is the distribution of $m$ parameterized by the choice of controller $\theta$, and the shared weights $w^{*}$ describing the architecture. The learning is to minimize the training loss $\mathcal{L}_{train}(m(w,\mathcal{G}))$ which can be represented as a bi-level optimization problem listed below, \begin{small} \begin{align} max_{w} & ~~ \mathcal{E}[\mathcal{R}(m(w^{*},\mathcal{G})))] \nonumber \\ s.t.: & \ w^{*}=argmin_{w} ~ \mathcal{L}_{train}(m(w,\mathcal{G})) . \end{align} \end{small} The training process of Eq.(1) will be discussed in the remaining parts of this section. The goal of GraphNAS is to find $m^{*}$ that maximizes the expected validation accuracy $ \mathcal{E}[\mathcal{R}(m(\mathcal{G}))]$. \subsection{Search Space} \label{Search Space} In GraphNAS, we use a controller network to generate the descriptions of GNNs. The controller network used in GraphNAS is implemented as a recurrent neural network which requires a state space. In order to define the search space, we introduce a generalized framework of GNNs, where each layer can be described as follows, \begin{table}[] \caption{Attention functions } \label{operators} \begin{tabular}{l|l} \hline Attention & Formula \\ \hline const & $e_{ij}^{con} = 1$ \\ \hline gcn & $e^{gcn}_{ij} = 1/\sqrt{d_{i}d_{j}}$ \\ \hline gat & $e_{ij}^{gat} = leaky\_relu((W_{l} *h_{i} + W_{r} *h_{j}))$ \\ \hline sym-gat & $e_{ij}^{sym} = e_{ji}^{gat} + e_{ij}^{gat} $ \\ \hline cos & $e_{ij}^{cos} = <W_{l} *h_{i} , W_{r} *h_{j}>$ \\ \hline linear & $e_{ij}^{lin} = tanh(sum (W_{l} *h_{j} ) )$ \\ \hline gene-linear & $e_{ij}^{gat} = W_{a}*tanh(W_{l} *h_{i} + W_{r} *h_{j} )$ \\ \hline \end{tabular} \end{table} \begin{enumerate} \item \textbf{Feature transform functions}. The hidden embedding $H^{i-1}$ ($H^{0}$ represents the initial input) is multiplied by a weight matrix $W_{T}$, which is used to extract features and reduce feature dimensions. For each layer of GNNs, the output dimension $\mathcal{DIM}$ is required. \item \textbf{Sampling functions.} Select the receptive field $N(v)$ for a given target node. Many GNNs samples the first-order neighbors iteratively and collect messages globally. GraphSAGE and PinSAGE sample a fixed size neighbor to speed up for large graphs. FastGCN uses importance sampling while maintaining the performance of the algorithm. LGCN sorts the first-order neighbors' features and selects top-$k$ features. For each layer, one of the sampling methods $\mathcal{SAM}$ is required. \item \textbf{Correlation measure functions.} Calculate the correlation of node $v$ with its neighbors $N(v)$. GAT assigns neighborhood importance by using attention layers. Semi-GCN assigns neighborhood importance according to the degree of nodes. More choices are listed in Table \ref{operators}. For each layer, we choose one correlation measurement method $\mathcal{ATT}$ and repeat times $\mathcal{K}$. \item \textbf{Aggregation functions.} Aggregate data from neighbors to generate an embedding for each node $v$. Most GNNs use the sum aggregator, Mean aggregator, LSTM aggregator and pooling aggregator. MLP aggregator are described in the work~\cite{Xu2018HowPA}. For each layer, one of the aggregation functions $\mathcal{AGG}$ is required. \item \textbf{Residual functions.} Merge historical hidden representation $H^{his}$ as a part of the current embedding after a transform function. The merge function includes concatenation and adding. For each layer of GNNs, a previous layer's index $\mathcal{I}$ and the activation function $\mathcal{ACT}$ of the current layer are required to build a residual layer. \item \textbf{Gated functions.} As in GeniePath~\cite{GeniePath}, the attention procedure learns the importance of neighbors with different sizes. Gated procedure extracts and filters signals aggregated from neighbors of distant hops. \end{enumerate} To sum up, we define the search space of GNNs $\mathcal{M}$ as follows: the sampling dimension $\mathcal{SAM}$ , the correlation measure dimension $\mathcal{ATT}$, the aggregation dimension $\mathcal{AGG}$, the numbers of multi-heads $\mathcal{K}$, the output hidden embedding $\mathcal{DIM}$, the previous layers' index $\mathcal{I}$ and the activation function $\mathcal{ACT}$. As a result, GraphNAS can generate the architecture descriptions as a sequence of tokens. Each token represents one of the functions in the architecture space $\mathcal{M}$. Note that we do not predict training parameters such as the learning rates of GNNs and we also assume that the architectures without gated procedures bring large computation and improvement during the initial stage of training. It is possible to add those actions as one of the predictions. In our experiments, the process of generating an architecture stops if the number of layers exceeds a preset value. \begin{table} \caption{Action operators in search space} \label{actions} \begin{tabular}{l|l} \hline action & operators \\ \hline sample method & "first-order" \\ \hline attention type & listed in Table \ref{operators} \\ \hline aggregation type & "sum", "mean-pooling", "max pooling", \\ & "mlp" \\ \hline activation type & "sigmoid", "tanh", "relu", "linear",\\ &"softplus", "leaky\_relu", "relu6", "elu" \\ \hline number of heads & 1,2,4,6,8,16 \\ \hline hidden units & 4, 8, 16, 32, 64, 128,256 \\ \hline \end{tabular} \end{table} \subsection{Search Algorithm} \label{Algorithms} \textbf{Training the controller parameters $\theta$.} In order to maximize the objective function given in Eq.(1), we describe a policy gradient method to update parameters $\theta$ so that the controller network generates better architectures over time. The architecture descriptions (hyperparameters) of GNNs that the controller predicts can be viewed as a list of actions $m_{1:T}$. GNNs will achieve an accuracy of $m(w,\mathcal{G})$ on a held-out dataset at convergence. We use the accuracy $\mathcal{R}$ as reward signal and use reinforcement learning to train the controller. Since the reward signal $\mathcal{R}$ is non-differentiable, we use a policy gradient method to iteratively update $\theta$ with a moving average baseline for reward to reduce variance~\cite{Williams1992Simple} as follows, \begin{small} \begin{eqnarray} & &\nabla_{\theta}\mathcal{E}_{{P(m_{1:T};\theta)}}[R(m(w,\mathcal{G}))]~\\ \cdot & & =\sum_{t=1}^{T}\mathcal{E}_{P(m_{1:T};\theta)}[\nabla_{\theta}logP(m_{t}|m_{t-1:1};\theta)R(m(w,\mathcal{G}))] \nonumber \end{eqnarray} \end{small} \textbf{Training the shared parameters $w $.} In this step, we use stochastic gradient descent (SGD) with respect to $w$ to minimize the training loss $\mathcal{L}_{train}$, where $\mathcal{L}_{train}$ is the standard cross-entropy loss in node classification, obtained from a minibatch of training data with a model $m$ sampled by the controller. \subsection{Parameters Sharing} In most previous neural architecture search algorithms, generated models are trained from the scratch. However, training models from scratch to convergence brings heavy computation. Recently, ENAS~\cite{ENAS} forces all child models to share weights in order to improve the efficiency. Similarly, we introduce parameters sharing for GraphNAS. Parameters sharing in ENAS are without conditions, ignoring the performance of the child models. This strategy does not suit for GNNs. As we found in experiments, parameters sharing between different GNNs does not work immediately, but can be observed after several iterations. Therefore we use a new strategy to share weights between different GNNs. \textbf{Sharing strategy.} Figure~\ref{fig:parametersharing} shows the parameters from one layer. Solid arrows represent the transform weights in GNNs which are shared between different GNNs including $W_{T}$, $W_{l}$, $W_{l}$ and $W_{res}$. However, GNNs constraints search dimensions such as the attention and aggregation dimensions. For instance, $W_{l}$, $W_{r}$ listed in Table \ref{operators} are used to form correlation measures for the attention functions. In GraphNAS, we allow different GNNs sharing the transform weights. Parameters are only shared for specific combinations of attention and aggregation functions \textbf{Update strategy.} The parameters $w$ are trained and updated during training child models. The parameter update is also different from ENAS. Parameters shared by GNNs stored in the form of dictionary. When training, GNNs obtain a copy of shared parameters. After training, the parameters of the current child model are merged into the shared parameters $w$ when the reward is positive. \label{Parameters share} \begin{figure} \includegraphics[width=0.48\textwidth]{share.pdf} \caption{Parameters of each layer in GNNs. Circles represent hidden embeddings in each layer. Solid arrows represent the transform operation with parameters, dotted arrows indicate operations with no parameters, and hollow arrows with text represent the remaining functions such as Att for $\mathcal{ATT}$, Agg for $\mathcal{AGG}$).} \label{fig:parametersharing} \end{figure} \textbf{Reward generation.} In ENAS \cite{ENAS}, the reward is generated according to the shared parameters without training child models. Since there may be parameters untrained, the strategy may cause deviation during reward generation. In GraphNAS, we train the child models with shared parameters to obtain more precise reward. After then, we apply a moving average on rewards to generate the final reward. \textbf{Exploration for shared parameters.} Models with updated sharing parameters generally have large reward. Therefore, the controller has the potential to choose structures appearing at the beginning. In order to avoid this bias, we allow the GraphNAS to do exploration. During exploration, the parameters $\theta$ of the controller are fixed, while the shared parameters $w$ are trained with novel structures. \textbf{Deriving architectures.} We derive novel architectures from a trained GraphNAS model. We first sample several models under the distribution of $P(m,\theta)$. For each sampled model, we compute its reward on a single minibatch sampled from the validation set after a few iterations. We then take only the model with the highest reward to re-train from scratch. It is possible to improve the results by training all the sampled models from scratch and select the model with the highest accuracy on a separated validation set~\cite{NAS,Zoph2018LearningTA}. \section{Experiments} We test the performance of GraphNAS on both transductive and inductive learning scenarios. We use citation networks including Cora, Citeseer, and Pubmed for the transductive learning, and PPI for the inductive learning. On each dataset, we have a separated held-out validation set used to generate reward to compute the reward signal. The reported performance on the test set is computed only once for the network that achieves the best result on the held-out validation set. \subsection{Datasets} \textbf{Transductive Learning Task} We classify academic papers into different subjects using the Cora, Citeseer and Pubmed datasets. The data obtained from semi-GCN \cite{kipf2017semi} has been preprocessed. We follow the same setting used in semi-GCN that allows 20 nodes per class for training, 500 nodes for validation and 1,000 nodes for testing. \textbf{Inductive Learning Task} We use the protein-protein interaction (PPI) dataset, which contains 20 graphs for training, two graphs for validation, and two graphs for testing. Since the graphs for validation and testing are separated, the training process does not use them. There are 2,372 nodes in each graph on average. Each node has 50 features including positional, motif genes and signatures. Each node has multiple labels from 121 classes. \subsection{Baseline Methods} In order to evaluate the GNNs searched by GraphNAS, we choose the state-of-the-art GNNs for comparisons, \begin{itemize} \item Chebyshev ~\cite{Defferrard2016ConvolutionalNN}. The method approximates the graph spectral convolutions by a truncated expansion in terms of Chebyshev polynomials up to T-th order. This method needs the graph Laplacian in advance, so that it only works in the transductive setting. \item Semi-GCN ~\cite{kipf2017semi} is the same as Chebyshev, it works only in the transductive setting. \item GraphSAGE ~\cite{GraphSAGE} consists of a group of inductive graph representations with different aggregation functions. The GCN-mean with residual connections is equivalent to GraphSAGE using mean pooling. \item GAT~\cite{GAT} introduces attention into GNN. Therefore, GAT archives good results in both transductive and inductive learning. \item LGCN ~\cite{Gao2018LargeScaleLG} enables regular convolutional operations on generic graphs which archives good results in both transductive and inductive learning. \end{itemize} All the tasks in transductive learning are single-label classification. We use accuracy as the measure for comparison. On the other hand, tasks in transductive learning are multi-label classification, and we use F1 score as the measure. \subsection{Architecture on Transductive learning} \textbf{Search space.} Our search space consists of the functions listed in Section~\ref{Search Space}. For each layer of GNNs, the controller has to sample actions $m \in {\mathcal{DIM},\mathcal{SAM},\mathcal{ATT},\mathcal{K},\mathcal{AGG},\mathcal{ACT}}$ which do not contain previous layer index $\mathcal{I}$ for skip connection. In experiments on the citation dataset, there are usually two layers for GNNs. \textbf{Training details.} The controller is a one-layer LSTM with 100 hidden units. It is trained with the ADAM optimizer ~\cite{Kingma2015AdamAM} with a learning rate of 0.0035. The weights of the controller are initialized uniformly between -0.1 and 0.1. To prevent premature convergence, we also use a tanh of 2.5 and a temperature of 5.0 for the sampling logits ~\cite{Bello2017NeuralOS,Bello2016NeuralCO}, and add the controller’s sample entropy to the reward, weighted by 0.0001. Once the controller samples an architecture, a child model is constructed and trained for 200 epochs without parameter sharing. During training, we apply L2 regularization with $\lambda$ = 0.0005 for Cora and Citeseer. Furthermore, dropout with $p$ = 0.6 is applied to both layers’ inputs, as well as to the normalized attention coefficients. For Pubmed, we set L2 regularization to $\lambda$ = 0.001. In all experiments, child models are initialized using the Glorot initialization ~\cite{Glorot2010UnderstandingTD} and trained to minimize cross-entropy loss on the training nodes using the Adam SGD optimizer ~\cite{Kingma2015AdamAM} with an initial learning rate of 0.01 for Pubmed, and 0.005 for all the other datasets. In both cases we use an early stopping strategy according to the cross-entropy loss and accuracy on the validation nodes, with a patience of 100 epochs. During training the controller, we fix the number of child network layers to be two, because many GNNs obtain the best performance on these dataset with two layers. Besides, we do not force GNNs sharing parameters, because training GNNs to convergence are fast on these datasets and models are easy to over-fitting in a semi-supervision task. \textbf{Results.} After the controller trains 1,000 architectures, we collect the top 5 architectures that achieve the best validation accuracy. Then, we compute the test accuracy and time for each epoch of such models and summarize their results in Table ~\ref{table:cora}. The time reported here is the training time for running one epoch using a single 1080Ti GPU. As can be seen from the table, GraphNAS can design several promising architectures that perform as well as some of the best models on this dataset. Other experiments results on citation network are listed in Table ~\ref{other_citation}. \textbf{Random Search.} Besides reinforcement learning, one can use random search to find the network. Although this baseline seems simple, it is often very hard to surpass. We report the number of GNNs model which has accuracy over 0.81 on validation set during search in Figure ~\ref{fig:random}. And we list the best structure found by random search in Table\ref{table:cora}. The results show that GraphNAS trends to find better GNNs. \begin{figure} \includegraphics*[width=.45\textwidth, height=150pt]{Cora} \caption{The number of GNNs whose accuracy over 0.81 on the validation set during search. Red line stands for GraphNAS, blue line stands for random search. GraphNAS outperforms random search. } \label{fig:random} \end{figure} \begin{table}[] \caption{Performance of GraphNAS and the state-of-the-art on Cora.} \label{table:cora} \begin{tabular}{l|ll|ll} \hline Models & Depth & Params & Time(s) & Accuracy \\ \hline Chebyshev & 2 & 92K & 0.49 & 81.2\% \\ GCN & 2 & 23K & 0.08 & 81.5\% \\ GAT & 2 & 237K & 0.62 & 83.0$\pm$0.7\% \\ LGCN & 2 & 56K & 0.14 & 83.3$\pm$0.5\% \\ \hline random & 2 & 364K & 1.29 &82.0$\pm$0.6\% \\ GraphNAS & 2 & 188K & 0.13 & 84.2$\pm$1.0\% \\ \hline \end{tabular} \end{table} \begin{table}[] \caption{Performance of GraphNAS and the state-of-the-art models on Citeseer and Pubmed in term of accuracy.} \label{other_citation} \begin{tabular}{l|l|l} \hline Models & Citeseer & Pubmed \\ \hline Chebyshev & 69.8\% & 74.4\% \\ GCN & 70.3\% & 79.0\% \\ GAT & 72.5$\pm$0.7\% & 79.0$\pm$0.3\% \\ LGCN & 73.0$\pm$0.6\% & 79.5$\pm$0.2\% \\ \hline GraphNAS & 73.1$\pm$0.9\% & 79.6$\pm$0.4\% \\ \hline \end{tabular} \end{table} \subsection{Architecture on Inductive Learning} \textbf{Search space.} We use the full search space defined in Section~\ref{Search Space} . For skip-connection, we perform two sets of experiments, where one fixes the input of residual layer with output of the last hidden layer and the other allows the controller to predict previous layer index to build skip-connection. \textbf{Training details.} The setting of training and the controller are the same as in transductive learning. We use parameter sharing to solve the huge computational resource requirements. The shared parameters of the child models are trained using the Adam SGD optimizer with a learning rate of 0.005. Before training the controller, the exploration process is executed at the first 20 epochs. After that the controller is trained for 50 epochs. During training of the child model, we apply no L2 regularization and dropout. During the process, each GNN model sampled by the controller is trained for five epochs with shared parameters. During the training of the controller, we fix the number of child networks layers at three, because most GNNs obtain the best performance on this dataset are with three layers. \textbf{Results.} After the controller trained for 1,000 time, we let the controller to output the best model from 200 sampled GNNs. And we then compute the micro-f1 score and the time for each epoch of the model and summarize the results in Table \ref{PPI result}. The time reported here is the training time for running one epoch using a single 1080Ti GPU. As can be seen from the table, GraphNAS can design several promising architectures that perform as well as the best models on this dataset. \begin{figure} \includegraphics*[width=.48\textwidth, height=170pt]{runing_process} \caption{F1 score of the best GNNs on the ppi validation set during GraphNAS search. Blue is the best, Green is the average of top 5, Red is the average of top 10, Black is the best search in 600 structures which appears at the search $500^{th}$. } \label{fig:runing_process} \end{figure} \begin{table}[] \caption{Performance of GraphNAS and the state-of-the-art on PPI.} \label{PPI result} \begin{tabular}{l|ll|l} \hline Models & Depth & Params & micro-F1(\%) \\ \hline GraphSAGE(lstm) & 2 & 0.26M & 61.2 \\ GeniePath & 3 & 1.81M &97.9 \\ GAT & 3 & 3.64M & 97.3$\pm$0.2 \\ LGCN & - & - & 77.2$\pm$0.2 \\ \hline GraphNAS( no sc) & 3 & 3.95M & 98.6$\pm$0.1 \\ GraphNAS with sc& 3 & 2.11M & 97.7$\pm$0.2 \\ NAS-like search & 3 & 0.95M & 95.7$\pm$0.2 \\ ENAS-like search& 3 & 1.38M & 96.5$\pm$0.2 \\ \hline \end{tabular} \end{table} \textbf{Effectiveness of parameters sharing.} To evaluate the effectiveness of parameter sharing strategy during search, we compare the F1 score of the best structure designed by GraphNAS with parameters sharing and trained from scratch in Figure ~\ref{fig:runing_process}. Both of them are trained for five epochs. \begin{figure} \includegraphics*[width=.48\textwidth, height=170pt]{compare_random} \caption{GraphNAS compares with \textit{random search}, \textit{NAS-like GraphNAS}, and \textit{ ENAS-like GraphNAS} on ppi dataset. GrpahNAS has the best F1 score.} \label{fig:ppi_compare_random} \end{figure} \textbf{Comparison against Search strategy.} We compare GraphNAS with other search strategies including random search, reinforcement learning without parameter sharing (NAS-like), and GraphNAS without iterations of GNNs during training the controller (ENAS-like). Each sampled GNN is trained for two epochs. We show the model's validation F1-score during training in Figure ~\ref{fig:ppi_compare_random}. The performance of the found best model are listed in Table\ref{PPI result}. The results show that GraphNAS trends to find a better GNN model. \section{Conclusions} In this paper, we study a new problem of graph neural architecture search with reinforcement learning. We present a GraphNAS algorithm that can design accurate graph neural network architectures that rival the best human-invented architectures in terms of test set accuracy. Experiments on node classification tasks in both transductive and inductive learning settings demonstrate that GraphNAS can achieve consistently better performance on citation networks, and protein-protein interaction network. Comparisons with existing search strategies show that the new parameters sharing and search strategy used in GraphNAS are effective. \newpage \newpage
{'timestamp': '2019-08-21T02:06:03', 'yymm': '1904', 'arxiv_id': '1904.09981', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.09981'}
arxiv
\section{Introduction} Sequential decision-making problems, where at each point in time an agent must choose the best action out of several alternatives, are frequently encountered in various practical applications, from clinical trials \cite{durand2018contextual} to recommender systems \cite{MaryGP15} and anomaly detection \cite{Ding:2019}. Often, there is a side information, or {\em context}, associated with each action (e.g., a user's profile), and the feedback, or {\em reward}, is limited to the chosen option. For example, in clinical trials \cite{durand2018contextual,bastani2015online} the context is the patient's medical record (e.g. health condition, family history, etc.), the actions correspond to the treatment options being compared, and the reward represents the outcome of the proposed treatment (e.g., success or failure). An important aspect affecting the long-term success in such settings is finding a good trade-off between {\em exploration} (e.g., trying a new drug) and {\em exploitation} (choosing the known drug). This inherent exploration vs. exploitation trade-off exists in many sequential decision problems, and is traditionally formulated as the {\em multi-armed bandit (MAB)} problem, stated as follows: given $K$ possible actions, or ``arms'', each associated with a fixed but unknown reward probability distribution ~\cite {LR85,UCB}, at each iteration (time point) an agent selects an arm to play and receives a reward, sampled from the respective arm's probability distribution independently from the previous actions. The task of an agent is to learn how to choose its actions so that the cumulative rewards over time is maximized. Different solutions have been proposed for this problem, based on a stochastic formulation ~\cite {LR85,UCB,BouneffoufF16} and a Bayesian formulation ~\cite {AgrawalG12}; however, these approaches did not take into account the context, or side information available to the agent. A particularly useful version of the MAB is the {\em contextual multi-arm bandit (CMAB)}, or simply the {\em contextual bandit} problem, where at each iteration, before choosing an arm, the agent observes an $N$-dimensional {\em context}, or {\em feature vector}. The agent uses this context, along with the rewards of the arms played in the past, to choose which arm to play in the current iteration. Over time, the agent's aim is to collect enough information about the relationship between the context vectors and rewards, so that it can predict the next best arm to play by looking at the current context \cite{langford2008epoch,AgrawalG13}. Different algorithms were proposed for the general case, including LINUCB ~\cite{Li2010}, Neural Bandit \cite{AllesiardoFB14} and Contextual Thompson Sampling (CTS)~\cite{AgrawalG13}, where a linear dependency is typically assumed between the expected reward of an action and its context. We will now provide an extensive overview including various applications of the bandit framework, both in real-life problem setting arising in multiple practical domains (healthcare, computer network routing, finance, and beyond), as well as in computer science and machine-learning in particular, where bandit approaches can help improve hyperparameter tuning and other important algorithmic choices in supervised learning, active learning and reinforcement learning. \section{Real-Life Applications of Bandit } As a general mathematical framework, the stochastic multi-armed bandit setting addresses the primary difficulty in sequential decision-making under uncertainty, namely, the exploration versus exploitation dilemma, and therefore provides a natural formalism for most real-life online decision making problems. \subsection{Healthcare} \textbf{Clinical trials. } Collecting data for assessing treatment effectiveness on animal models during the full range of disease stages can be difficult when using conventional random treatment allocation procedures, since poor treatments can cause deterioration of subject's health. Authors in \cite{durand2018contextual} aim to design an adaptive allocation strategy to improve the efficiency of data collection by allocating more samples for exploring promising treatments. They cast this application as a contextual bandit problem and introduce a practical algorithm for exploration vs. exploitation in this framework. The work relies on sub-sampling to compare treatment options using an equivalent amount of information. Precisely, they extend the sub-sampling strategy to contextual bandit setting g by applying sub-sampling within Gaussian Process regression. Warfarin is the most widely used oral anticoagulant agent in the world; however, dosing it correctly remains a significant challenge, as the appropriate dose can be highly variable among individuals due to various clinical, demographic and genetic factors. Physicians currently follow a fixed-dose strategy: they start patients on 5mg/day (the appropriate dose for the majority of patients) and slowly adjust the dose over the course of a few weeks by tracking the patient’s anti-coagulation levels. However, an incorrect initial dosage can result in highly adverse consequences such as stroke (if the initial dose is too low) or internal bleeding (if the initial dose is too high). Thus, authors in \cite{bastani2015online} tackle the problem of learning and assigning an appropriate initial dosage to patients by modeling the problem as a multi-armed bandit with high-dimensional covariates, and propose a novel and efficient bandit algorithm based on the LASSO estimator. \textbf{Brain and behavior modeling.} Drawing an inspiration from behavioral studies of human decision making in both healthy controls and patients with different mental disorders, authors in \cite{bouneffouf2017bandit} propose a general parametric framework for multi-armed bandit problem which extends the standard Thompson Sampling approach to incorporate reward processing biases associated with several neurological and psychiatric conditions, including Parkinson's and Alzheimer's diseases, attention-deficit/hyperactivity disorder (ADHD), addiction, and chronic pain. They demonstrate empirically, from the behavioral modeling perspective, that their parametric framework can be viewed as a first step towards a unifying computational model capturing reward processing abnormalities across multiple mental conditions. \subsection{Finance} In recent years, sequential portfolio selection has been a focus of increasing interest at the intersection of the machine learning and quantitative finance. The trade-off between exploration and exploitation, with the goal of maximizing cumulative reward, is a natural formulation of the portfolio choice problems. In \cite{shen2015portfolio}, the authors proposed a bandit algorithm for making online portfolio choices via exploiting correlations among multiple arms. By constructing orthogonal portfolios from multiple assets and integrating their approach with the upper-confidence-bound bandit framework, the authors derive the optimal portfolio strategy representing a combination of passive and active investments according to a risk-adjusted reward function. In \cite{huo2017risk}, the authors incorporate risk-awareness into the classic multi-armed bandit setting and introduce a novel algorithm for portfolio construction. Through filtering assets based on the topological structure of financial market and combining the optimal multi-armed bandit policy with the minimization of a coherent risk measure, they achieve a balance between risk and return. \subsection{Dynamic Pricing} Online retailer companies are often faced with the dynamic pricing problem: the company must decide on real-time prices for each of its multiple products. The company can run price experiments (make frequent price changes) to learn about demand and maximize long-run profits. The authors in \cite{misra2018dynamic} propose a dynamic price experimentation policy, where the company has only incomplete demand information. For this general setting, authors derive a pricing algorithm that balances earning an immediate profit vs. learning for future profits. The approach combines multi-armed bandit with partial identification of consumer demand from economic theory. Similar to \cite{misra2018dynamic}, authors in \cite{mueller2018low} consider high-dimensional dynamic multi-product pricing with an evolving low-dimensional linear demand model. They show that the revenue maximization problem reduces to an online bandit convex optimization with side information given by the observed demands. The approach applies a bandit convex optimization algorithm in a projected low-dimensional space spanned by the latent product features, while simultaneously learning this span via online singular value decomposition of a carefully-crafted matrix containing the observed demands. \subsection{Recommender Systems} Recommender systems are frequently used in various application to predict user preferences. However, they also face the exploration-exploitation dilemma when making a recommendation, since they need to exploit their knowledge about the previously chosen items the user is interested in, while also exploring new items the user may like. Authors in \cite{zhou2017large} approach this challenge using multi-armed bandit setting, especially for large-scale recommender systems that have really large or infinite number of items. They propose two large-scale bandit approaches in situations when no prior information is available. Continuous exploration in their approaches can address the cold start problem in recommender systems. In context-aware recommender systems, most existing approaches focus on recommending relevant items to users, taking into account contextual information, such as time, location, or social aspects. However, none of those approaches has considered the problem of user’s content evolution. In \cite{bouneffouf2012contextual} authors introduce an algorithm that takes this dynamics into account. It is based on dynamic exploration/exploitation and can adaptively balance the two aspects, deciding which situation is most relevant for exploration or exploitation. In this sense, \cite{bouneffouf2014freshness} propose to study the "freshness" of the user's content through the bandit problem. They introduce in this paper an algorithm named Freshness-Aware Thompson Sampling that manages the recommendation of fresh document according to the user's risk of the situation. \subsection{Influence Maximization} Autors in \cite{vaswani2017model} consider influence maximization (IM) in social networks, which is the problem of maximizing the number of users that become aware of a product by selecting a set of “seed” users to expose the product to. They propose a novel parametrization that not only makes the framework agnostic to the underlying diffusion model, but also statistically efficient to learn from data. They give a corresponding monotone, submodular surrogate function, and show that it is a good approximation to the original IM objective. They also consider the case of a new marketer looking to exploit an existing social network, while simultaneously learning the factors governing information propagation. For this, they develop a LinUCB-based bandit algorithm. Authors in \cite{wen2017online} also study the online influence maximization problem in social networks but under the independent cascade model. Specifically, they try to learn the set of “best seeds or influencers” in a social network online while repeatedly interacting with it. They address the challenges of combinatorial action space, since the number of feasible influencer sets grows exponentially with the maximum number of influencers, and limited feedback, since only the influenced portion of the network is observed. They propose and analyze IMLinUCB, a computationally efficient UCB-based algorithm. \subsection{Information Retrieval} Authors in \cite{losada2017multi} argue that Information Retrieval iterative selection process can be naturally modeled as a contextual bandit problem. Casting document judging as a multi-armed bandit problem leads to highly effective adjudication methods. Under this bandit allocation framework, they consider stationary and non-stationary models and propose seven new document adjudication methods (five stationary methods and two non-stationary variants). This comparative study includes existing methods designed for pooling-based evaluation and existing methods designed for metasearch. In mobile information retrieval, authors in \cite{bouneffouf2013contextual} introduce an algorithm that tackles this dilemma in Context-Based Information Retrieval (CBIR) area. It is based on dynamic exploration/exploitation and can adaptively balance the two aspects by deciding which user’s situation is most relevant for exploration or exploitation. Within a deliberately designed online framework they conduct evaluations with mobile users. \subsection{Dialogue Systems} \textbf{Dialogue response selection.} Dialogue response selection is an important step towards natural response generation in conversational agents. Existing work on conversational models mainly focuses on offline supervised learning using a large set of context-response pairs. In \cite{LiuYLM18} authors focus on online learning of response selection in dialog systems. They propose a contextual multi-armed bandit model with a nonlinear reward function that uses distributed representation of text for online response selection. A bidirectional LSTM is used to produce the distributed representations of dialog context and responses, which serve as the input to a contextual bandit. They propose a customized Thompson sampling method that is applied to a polynomial feature space in approximating the reward. \textbf{Pro-activity dialogue systems.} An objective of pro-activity in dialogue systems is to enhance the usability of conversational agents by enabling them to initiate conversation on their own. While dialogue systems have become increasingly popular during the last couple of years, current task-oriented dialogue systems are still mainly reactive, as users tend to initiate conversations. Authors of \cite{silander2018contextual} propose to introduce the paradigm of contextual bandits as framework for proactive dialog systems. Contextual bandits have been the model of choice for the problem of reward maximization with partial feedback since they fit well to the task description, they also explore the notion of memory into this paradigm, where they propose two differentiable memory models that act as parts of the parametric reward estimation function. The first one, Convolutional Selective Memory Networks, uses a selection of past interactions as part of the decision support. The second model, called Contextual Attentive Memory Network, implements a differentiable attention mechanism over the past interactions of the agent. The goal is to generalize the classic model of contextual bandits to settings where temporal information needs to be incorporated and leveraged in a learnable manner. \textbf{Multi-domain dialogue systems.} Building multi-domain dialogue agents is a challenging task and an open problem in modern AI. Within the domain of dialogue, the ability to orchestrate multiple independently trained dialog agents, or skills, to create a unified system is of particular significance. In \cite{upadhyaybandit}, the authors study the task of online posterior dialogue orchestration, where they define posterior orchestration as the task of selecting a subset of skills which most appropriately answers a user input using features extracted from both the user input and the individual skills. To account for the various costs associated with extracting skill features, they consider online posterior orchestration under a skill execution budget. This setting is formalized as Context-Attentive Bandit with Observations, a variant of context-attentive bandits, and evaluate it on simulated non-conversational and proprietary conversational datasets. \subsection{Anomaly Detection} Performing anomaly detection on attributed networks concerns with finding nodes whose behaviors deviate significantly from the majority of nodes. Authors in \cite{Ding:2019} investigate the problem of anomaly detection in an interactive setting by allowing the system to proactively communicate with the human expert in making a limited number of queries about ground truth anomalies. Their objective is to maximize the true anomalies presented to the human expert after a given budget is used up. Along with this line, they formulate the problem through the principled multi-armed bandit framework and develop a novel collaborative contextual bandit algorithm, that explicitly models the nodal attributes and node dependencies seamlessly in a joint framework, and handles the exploration-exploitation dilemma when querying anomalies of different types. Credit card transactions predicted to be fraudulent by automated detection systems are typically handed over to human experts for verification. To limit costs, it is standard practice to select only the most suspicious transactions for investigation. Authors in \cite{soemers2018adapting} claim that a trade-off between exploration and exploitation is imperative to enable adaptation to changes in behavior. Exploration consists of the selection and investigation of transactions with the purpose of improving predictive models, and exploitation consists of investigating transactions detected to be suspicious. Modeling the detection of fraudulent transactions as rewarding, they use an incremental regression tree learner to create clusters of transactions with similar expected rewards. This enables the use of a {\em contextual} multi-armed bandit (CMAB) algorithm to provide the exploration/exploitation trade-off. \subsection{ Telecommunication} In \cite{boldrini2018mumab}, a multi-armed bandit model was used to describe the problem of best wireless network selection by a multi-Radio Access Technology (multi-RAT) device, with the goal of maximizing the quality perceived by the final user. The proposed model extends the classical MAB model in a twofold manner. First, it foresees two different actions: to measure and to use; second, it allows actions to span over multiple time steps. Two new algorithms designed to take advantage of the higher flexibility provided by the muMAB model are also introduced. The first one, referred to as measure-use-UCB1 is derived from the UCB1 algorithm, while the second one, referred to as Measure with Logarithmic Interval, is appositely designed for the new model so to take advantage of the new measure action, while aggressively using the best arm. The authors in \cite{KerkoucheAFVM18} demonstrate the possibility to optimize the performance of the Long Range Wide Area Network technology. Authors suggest that nodes use multi-armed bandit algorithms, to select the communication parameters (spreading factor and emission power). Evaluations show that such learning methods allow to manage the trade-off between energy consumption and packet loss much better than an Adaptive Data Rate algorithm adapting spreading factors and transmission powers on the basis of Signal to Interference and Noise Ratio values. \subsection{Bandit in Real-Life Applications: Summary and Future Directions} \begin{table}[h] \scriptsize \caption {Bandit for Real Life Application} \label{tab:Life} \begin{tabular}{|l|r|l|l|l|} \hline & & Non- & & Non- \\ & MAB & stationary & CMAB & stationary \\ & & MAB & & CMAB \\ \hline Healthcare & $\surd$ & & $\surd$ & \\ \hline Finance & $\surd$ & & & \\ \hline Dynamic pricing & & $\surd$ & & \\ \hline Recommendr system & $\surd$ & $\surd$ & $\surd$ & $\surd$ \\ \hline Maximization & $\surd$ & & & \\ \hline Dialogue system & & & $\surd$ & \\ \hline Telecomunication & $\surd$ & & & \\ \hline Anomaly detection & $\surd$ & & & \\ \hline \end{tabular} \end{table} Table \ref{tab:Life} provides a summary of bandit problem formulations used in each of the above domain applications. We see that, for example, non-stationary bandit was not used in healthcare applications, since perhaps there was no significant change assumed to happen in the environment in the process of making the treatment decision, i.e. no transition in the state of the the patient; such transition, if it occurred, would be better modeled using reinforcement learning rather than non-stationary bandit. There are clearly other domains where the non-stationary bandit is a more appropriate setting, but it looks like this setting was not yet much investigated in healthcare domain. For example, anomaly detection, is a domain where non-stationary contextual bandit could be used, since in this setting the anomaly could be adversarial, which means that any bandit applied to this setting should have some kind of drift condition, in-order to adapt to new type of attack. Another observation is that none of the existing work tried to develop an algorithm that could solve these different tasks at the same time, or apply the knowledge obtained in one domain to another domain, thus opening a direction of research on {\em multitask} and {\em transfer learning} in bandit setting. Furthermore, given an online nature of bandit problem, {\em continuous}, or {\em lifelong learning} would be a natural next step, adapting the model learned in the previous tasks to the new one, while still remembering how to perform earlier task, thus avoiding the problem of ''catastrophic forgetting''. \section{Bandit for Better Machine Learning} In this section we are describing how bandit algorithms could be used to improve other algorithms, e.g. various machine-learning techniques. \subsection{Algorithm Selection} Algorithm selection is typically based on models of algorithm performance, learned during a separate offline training sequence, which can be prohibitively expensive. In recent work, they adopted an online approach, in which a performance model is iteratively updated and used to guide selection on a sequence of problem instances. The resulting exploration-exploitation trade-off was represented as a bandit problem with expert advice, using an existing solver for this game, but this required using an arbitrary bound on algorithm runtimes, thus invalidating the optimal regret of the solver. In \cite{GaglioloS10}, a simpler framework was proposed for representing algorithm selection as a bandit problem, using partial information and an unknown bound on losses. \subsection{Hyperparameter Optimization} Performance of machine learning algorithms depends critically on identifying a good set of hyperparameters. While recent approaches use Bayesian optimization to adaptively select optimal hyperparameter configurations, they rather focus on speeding up random search through adaptive resource allocation and early-stopping. \cite{li2016hyperband} formulated hyperparameter optimization as a pure-exploration non-stochastic infinite-armed bandit problem where a predefined resources, such as iterations, data samples, or features are allocated to randomly sampled configurations. This work introduced a novel algorithm, Hyperband, for this framework and analyze its theoretical properties, providing several desirable guarantees. Furthermore, Hyperband wascmpared with popular Bayesian optimization methods on a suite of hyperparameter optimization problems; it was observed that Hyperband can provide more than an order-of-magnitude speedup over its competitors on a variety of deep-learning and kernel-based learning problems. \subsection{Feature Selection} In a classical online {\em supervised learning} the true label of a sample is always revealed to the classifier, unlike in a bandit setting were any wrong classification resuls into zero reward, and only the single correct classification yields reward 1. The authors of~\cite{wang2014online} investigate the problem of Online Feature Selection, where the aim is to make accurate predictions using only a small number of active features using epsilon greedy algorithm. The authors of \cite{BouneffoufRCF17} tackle the online feature selection problem by addressing the combinatorial optimization problem in the stochastic bandit setting with bandit feedback, utilizing the Thompson Sampling algorithm. \subsection{Bandit for Active Learning} Labelling all training examples in supervised classification setting can be costly. Active learning strategies solve this problem by selecting the most useful unlabelled examples to obtain the label for, and to train a predictive model. The choice of examples to label can be seen as a dilemma between the exploration and the exploitation over the input space. In \cite{bouneffouf2014contextual}, a novel active learning strategy manages this compromise by modelling the active learning problem as a contextual bandit problem. they propose a sequential algorithm named Active Thompson Sampling (ATS), which, in each round, assigns a sampling distribution on the pool, samples one point from this distribution, and queries the oracle for this sample point label. The authors of \cite{ganti2013building} also propose a multi-armed bandit inspired, pool-based active learning algorithm for the problem of binary classification. They utilize ideas such as lower confidence bounds, and self-concordant regularization from the multi-armed bandit literature to design their proposed algorithm. In each round, the proposed algorithm assigns a sampling distribution on the pool, samples one point from this distribution, and queries the oracle for the label of this sampled point. \subsection{Clustering} \cite{SublimeL18} considers collaborative clustering, which is machine-learning paradigm concerned with the unsupervised analysis of complex multi-view data using several algorithms working together. Well-known applications of collaborative clustering include multiview clustering and distributed data clustering, where several algorithms exchange information in order to mutually improve each others. One of the key issue with multi-view and collaborative clustering is to assess which collaborations are going to be beneficial or detrimental. Many solutions have been proposed for this problem, and all of them conclude that, unless two models are very close, it is difficult to predict in advance the result of a collaboration. To address this problem, the authors of \cite{SublimeL18} propose a collaborative peer to peer clustering algorithm based on the principle of non stochastic multi-arm bandits to assess in real time which algorithms or views can bring useful information. \subsection{Reinforcement learning} Autonomous cyber-physical systems play a large role in our lives. To ensure that agents behave in ways aligned with the values of the societies in which they operate, we must develop techniques that allow these agents to not only maximize their reward in an environment, but also to learn and follow the implicit constraints assumed by the society. In \cite{noothigattu2018interpretable}, the authors study a setting where an agent can observe traces of behavior of members of the society but has no access to the explicit set of constraints that give rise to the observed behavior. Instead, inverse reinforcement learning is used to learn such constraints, that are then combined with a possibly orthogonal value function through the use of a contextual bandit-based orchestrator that picks a contextually-appropriate choice between the two policies (constraint-based and environment reward-based) when taking actions. The contextual bandit orchestrator allows the agent to mix policies in novel ways, taking the best actions from either a reward maximizing or constrained policy. The \cite{LarocheF17} tackles the problem of online RL algorithm selection. A meta-algorithm is given for input a portfolio constituted of several off-policy RL algorithms. It then determines at the beginning of each new trajectory, which algorithm in the portfolio is in control of the behaviour during the next trajectory, in order to maximise the return. A novel meta-algorithm, called Epochal Stochastic Bandit Algorithm Selection. Its principle is to freeze the policy updates at each epoch, and to leave a rebooted stochastic bandit in charge of the algorithm selection. \subsection{Bandit for Machine Learning: \\ Summary and Future Directions} \begin{table}[] \scriptsize \caption {Bandit in Machine Learning} \label{tab:ML} \begin{tabular}{|l|r|l|l|l|} \hline & MAB & Non- & CMAB & Non- \\ & & stationary & & stationary \\ & & MAB & & CMAB \\ \hline Algorithm Slection & & $\surd$ & & \\ \hline Parameter Optimization & $\surd$ & & & \\ \hline Features Selection & $\surd$ & $\surd$ & & \\ \hline Active Learning & $\surd$ & & $\surd$ & \\ \hline Clustering & $\surd$ & & & \\ \hline Reinforcement learning & $\surd$ & $\surd$ & $\surd$ & \\ \hline \end{tabular} \end{table} Table \ref{tab:ML} summarizes the types of bandit problems used to solve the machine-learning problems mentioned above. We see, for example, that contextual bandit was not used in feature selection or hyperparameter optimization. This observation could point into a direction for future work, where side information could be employed in feature selection. Also, non-stationary bandit was rarely considered in these problem settings, which is also suggesting possible extensions of current work. For instance, the non-stationary contextual bandit could be useful in the non-stationary feature selection setting, where finding the right features is time-dependent and context-dependent when the environment keeps changing. Our main observation is also that each technique is solving just one machine learning problem at a time; thus, the question is whether a bandit setting and algoritms can be developed to solve multiple machine learning problems simultaneously, and whether transfer and continual learning can be achieved in this setting. One solution could be to model all these problems in a combinatorial bandit framework, where the bandit algorithm would find the optimal solution for each problem at each iteration; thus, combinatorial bandit could be further used as a tool for advancing automated machine learning. \section{Conclusions} \label{sec:Conclusion} In this article, we reviewed some of the most notable recent work on applications of multi-armed bandit and contextual bandit, both in real-life domains and in automated machine learning. We summarized, in an organized way (Tables 1 and 2), various existing applications, by types of bandit settings used, and discussed the advantages of using bandit techniques in each domain. We briefly outlines of several important open problems and promising future extensions. In summary, the bandit framework, including both multi-arm and contextual bandit, is currently very active and promising research areas, and there are multiple novel techniques and applications emerging each year. We hope our survey can help the reader better understand some key aspects of this exciting field and get a better perspective on its notable advancements and future promises. \bibliographystyle{named}
{'timestamp': '2019-04-24T02:01:50', 'yymm': '1904', 'arxiv_id': '1904.10040', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.10040'}
arxiv
\section{Introduction} \label{sec:intro} Connectomics attempts to recover the connectivity of neural circuits from 3D electron microscopic (EM) images of neural tissue \cite{swanson2016cajal}. Recovering the connectome requires segmenting the image into individual neurons, as well as mapping the synaptic connections between neurons. A synapse is a site of apposition (``synaptic cleft'') between the plasma membranes of two neurons, called ``presynaptic'' and ``postsynaptic.'' The interior of the presynaptic cell contains synaptic vesicles (small circular structures) near the cleft, and the membrane on the postsynaptic side of the cleft often features a ``postsynaptic density'' or PSD. The darkness and thickness of the PSD may vary depending on the type of synapse or the quality of the staining. The presynaptic membrane of the cleft is almost always found on a thin kind of neural branch called an axon, typically at a swelling in the axon known as a bouton. Mitochondria are often found in the presynaptic bouton. The postsynaptic membrane of the cleft most commonly belongs to a thick kind of neural branch called a dendrite. Most of the time the postsynaptic membrane is on a thorn-like protrusion from the dendrite called a ``spine.'' The dendritic spine may contain an intracellular organelle called the spine apparatus, which consists mainly of smooth endoplasmic reticulum. All of the above visual cues are used by human experts to map synapses in EM images. In recent years there have been a number of attempts to automate this process, usually through a two-step approach \cite{dorkenwald2017automated,parag2018detecting,santurkar2017toward,gray2015automated,kreshuk2015talking} though there are alternatives \cite{buhmann2018synaptic,staffler2017synem}. The first step is detection and localization of synaptic clefts. The second step---the focus of the present work---assigns to each synaptic cleft a presynaptic cell and a postsynaptic cell. We refer to this second step as synaptic partner assignment. Almost all machine learning approaches have formulated the problem as classification of candidate synaptic partners: \begin{problem}[Candidate partner classification] Given an EM image and an ordered pair of objects as binary masks, determine whether or not the first object is presynaptic cell and the second object is postsynaptic for the same synaptic cleft. \end{problem} Machine learning classifiers have been trained for this task based on hand-designed features \cite{dorkenwald2017automated,santurkar2017toward,kreshuk2015talking,huang2018fully}. More recently, convolutional networks were trained for this task by Parag et al. \cite{parag2018detecting}. \begin{figure}[htb] \begin{minipage}[b]{1.0\linewidth} \centering \centerline{\includegraphics[width=8.5cm]{figures/basic_approach_v4.pdf}} \end{minipage} \caption{(a) The candidate partner classification task. Several pairs of candidate segment pairs are classified as synaptic or non-synaptic. (b) The voxel association task. Presynaptic and postsynaptic partners are generated from the synaptic cleft object that connects them. These masks are matched with existing segments to assign synaptic partner IDs. Although depicted using 2D images, each process occurs in 3D.} \label{fig:approach} \end{figure} In the present work, we formulate the learned task as follows: \begin{problem}[Voxel association task] Given an EM image and a synaptic cleft as a binary mask, generate the presynaptic and postsynaptic objects as binary masks. \end{problem} We call this the voxel association task, because the output images encode object relations as associations between voxels. We train a convolutional network to perform the voxel association task for the Kasthuri et al. \cite{kasthuri2015saturated} dataset of images from mouse somatosensory cortex. The network achieves very low error rates in multiple evaluations, suggesting that our approach could be sufficiently accurate for practical applications in connectomics of the mammalian cortex. Synaptic partner assignment can be more challenging when the PSD is unclear, in organisms with more than two synaptic partners per synapse, and/or images with inferior staining quality. A preliminary application of our approach in this more challenging setting is given in the Supplementary Material, but a full account is postponed to a future paper. The convolutional net trained by Parag et al. \cite{parag2018detecting} to perform candidate partner classification for the mouse somatosensory cortex (called the ``proximity pruner'' below) also achieves low error on the test set. The difference is not statistically significant due to limited test set size. Therefore, a choice between the two approaches at the present time should be based on considerations other than accuracy. In Problem 2, the convolutional net is applied once per synaptic cleft. In Problem 1, the convolutional net is applied multiple times per cleft (Figure \ref{fig:approach}). On the other hand, a simpler convolutional net may suffice for Problem 1, because it is likely to be a simpler task since the output is a single binary variable. The balance of the preceding considerations will determine which approach requires more computational resources. The voxel association task is potentially simpler to apply, because it avoids the complexity of the candidate suggestion process, which includes a number of manually set thresholds. \subsection{Related Work} Mapping synapses is related to visual scene analysis, the computation of relationships between objects in an image \cite{dai2017detecting, xu2017scene}. Our work differs in its focus on a small set of relationships (presynaptic and postsynaptic). Bounding boxes, commonly computed for scene analysis and instance segmentation \cite{ren2015faster}, could also be used as an intermediate or output representation for synaptic cleft detection, because clefts are usually fairly well-separated from each other. However, bounding boxes are not convenient for neurons, because neuronal branches are highly entangled. Our voxel association task is also similar to the object mask extension task in computer vision \cite{romeraparedes2015recurrent, ren1605end} and connectomics \cite{januszewski2016flood,meirovitch2016multi}, which iteratively grows morphological segments from seed voxels. The voxel association task relies on a single forward pass to sufficiently identify the nearby voxels of interest, yet an iterative procedure could also be useful for difficult examples, or for synapses that are too large to fit in a single context window. \section{Attentional Voxel Association Networks} We train a convolutional net to perform this task using supervised learning. We call the trained network an Attentional Voxel Association Network (AVAN). \subsection{Training \& Inference} The training procedure requires an EM dataset with (1) a morphological segmentation, (2) a synaptic cleft segmentation, and (3) a set of ID pairings which match each cleft segment ID with its presynaptic and postsynaptic IDs within the morphological segments. We take the voxels that are part of some synaptic cleft within a training volume, and form training samples from these locations by centering a patch of local context on each location. We create the cleft mask input from the synaptic cleft at the sample location. We generate target output by creating a mask of the segments with the desired pre- or postsynaptic segment ID within the local context region (one volume of output for a presynaptic ID, and another for a postsynaptic ID). Each network in this work was implemented using PyTorch \cite{paszke2017automatic}. Our association network takes a $2 \times 80 \times 80 \times 18$ window as input (concatenating image context and seed object), and produces a volume of the same size as output. We used a modified version of the Residual Symmetric U-Net architecture \cite{lee2017superhuman}, where the upsampling operation is replaced by a ``resize convolution'' \cite{odena2016deconvolution}, and one level is removed from the downsampling hierarchy. All networks were trained using a cross-entropy loss function and an Adam optimizer \cite{kingma2014adam} using a manual learning rate schedule. During inference, the network is provided with patches of input centered around the centroid of each synaptic cleft. The presynaptic segment is predicted as the segment whose voxels have the highest average output over the presynaptic volume output patch, and a similar judgment is performed for the postsynaptic segment. These judgments are restricted to segments which overlap with a dilated version of the target cleft. We used a human annotated cleft segmentation to train the association task, although the training is agnostic to the source of this segmentation. \subsection{Polyadic Synapses} Synapses of other organisms can have multiple pre- or postsynaptic partners for each synaptic cleft \cite{buhmann2018synaptic, huang2018fully}. This approach can be extended to handle multiple segments by selecting all segments with average output over a tuned threshold value. We've omitted this extension here for clarity, yet preliminary experiments have shown this approach to be competitive with other published methods (Supplementary Materials). \section{Evaluation} We evaluated our basic approach using the Kasthuri et al. dataset \cite{kasthuri2015saturated}, downsampled to a voxel resolution of $\SI{12}{\nano\metre} \times \SI{12}{\nano\metre} \times \SI{30}{\nano\metre}$. This dataset includes two small labeled volumes of voxel dimensions $512 \times 512 \times 100$ and $512 \times 512 \times 256$. An augmented version of these cutouts has been used for comparison of similar systems \cite{parag2018detecting}. We split the labeled cutouts, using the first volume and the top 100 slices of the second as a training set, the middle 56 slices of the second as a validation set, and the bottom 100 as a test set. We labeled synaptic clefts and their partners as required for this task. We evaluated the trained association network in three ways: (1) assigning human annotated cleft segments, (2) combining it with cleft detection systems, and (3) applying it to an automated reconstruction of the larger image volume. \subsection{Synapse Assignment} For comparison, we implemented the candidate classification approach of Parag et al. \cite{parag2018detecting}. In their work, a heuristic suggests candidate partners for each synapse based on overlap of predicted sites with nearby cell segments along with other variables. A ``proximity pruner'' model then classifies each potential pair of candidate partners, using 4 inputs: local image context, the output of their synapse detector, and the pair of candidate segment masks. We chose this work due to its recent results within this dataset. We transformed our synaptic cleft labels to signed proximity, and trained a pruning network on a set of candidate segment pairs, formed by taking distinct pairs which overlapped with a dilated version of each cleft. We also attempted another candidate classification approach for this task, by training a similar classifier network that takes singular cleft segment masks as input instead of signed proximity (a ``mask pruner'' network). \begin{table} \centering \caption{Assignment Test Results (163 synapses).}\label{tab:assign_res} \begin{tabular}{|c|c|} \hline \bfseries{Assignment Method} & \bfseries{Accuracy} (\%) \\ \hline Mask Pruner & 96.9 \\ \hline Proximity Pruner \cite{parag2018detecting} & 97.5 \\ \hline AVAN & 100 \\ \hline \end{tabular} \end{table} During this evaluation, we modified the inference procedure for the pruning networks. Instead of a threshold scheme, each approach took the segment pair with highest output for each ground truth cleft segment as its prediction. This allows all methods to take the identity and number of true synapses as given, and also allows us to use accuracy metrics to compare them. Each of these three methods performed very well and within error of this small dataset (Table \ref{tab:assign_res}). Notably, our modified classification approach rivaled the performance of the original version, and both classification networks performed slightly worse than the association network. This suggests little overall benefit to assignment from adding signed information, and competitive performance for each approach. \subsection{Combined System} Next, we trained models to predict the locations of synaptic clefts, and then combined these predictions with each form of partner assignment. This step explored whether imperfectly predicted seed objects would affect assignment. We also included another training representation to produce cleft masks in an attempt to reproduce its effects on performance \cite{heinrich2018synaptic}. We've found that na\"ive methods of synapse annotation can be inaccurate, as attentional gaps can miss examples \cite{plaza2014annotating}. Our cleft ground truth was initially labeled by humans, and then ``bootstrapped'' twice. Each round of bootstrapping involved reviewing the errors of each cleft prediction method after a round of training, and including valid examples into the labels. This increased the number of examples in the training, validation, and test sets by 18, 17, and 15 respectively. All cleft networks were fine-tuned with the updated ground truth after the final additions. To evaluate each combined system, we performed a grid search over its hyperparameters, optimizing the F-1 score of predicted graph edges. A correct edge was defined as a segment (or pair of segments) that maximally overlaps with a cleft label and is assigned to the correct partners. Each cleft output was generated by a trained model with the same Residual Symmetric U-Net architecture. \begin{figure}[htb] \begin{minipage}[b]{1.0\linewidth} \centering \centerline{\includegraphics[width=\textwidth]{figures/perf_comparison.pdf}} \end{minipage} \caption{Combined System Evaluation (163 synapses). \emph{(left)} Combined system performance optimized for F-1 score. \emph{(right)} Cleft detection performance optimized for combined system F-1 score. Color indicates cleft detection target representation. Shape indicates partner assignment method. Dashed lines show level sets of F-1 score at the value for each system.} \label{fig:combined_res} \end{figure} The performance of the combined systems showed more variability than the assignment task alone (Figure \ref{fig:combined_res}). By inspecting the cleft detection scores at the final hyperparameter settings and performing an error analysis, we found that the differences between methods were mostly due to cleft detection instead of assignment. While the STDT representation and the cleft mask had similar performance, signed proximity output produced more false negatives. \subsection{Large-Scale Evaluation} \begin{figure}[htb] \begin{minipage}[b]{1.0\linewidth} \centering \centerline{\includegraphics[width=8.5cm]{figures/large_scale_fig.pdf}} \end{minipage} \caption{Large-Scale Evaluation. (a) Example reconstructed dendrite with its assigned synapses. Dendrites should only have postsynaptic terminals. Red/blue dots: pre/postsynaptic terminals. Presynaptic terminals target axonal segments incorrectly merged to the dendrite by the segmentation algorithm (red ovals) and one error (black circle) from a false positive cleft.} \label{fig:large_scale} \end{figure} We observed high accuracy of synaptic partner assignment methods in small cutouts. Attempting to mine for harder examples, we further tested our assignment method by applying it to a larger volume. We performed an automated reconstruction of the entire Kasthuri et al. \cite{kasthuri2015saturated} dataset (Fig \ref{fig:large_scale}), predicted synaptic clefts using a cleft mask network, and selected 1000 predicted synapses at random from this result. We applied the AVAN at each selected synapse, as well as an early version of our proximity prediction network and the fully trained proximity pruner. Proofreading the disagreements to remove false positive clefts left 81 locations where the two methods initially predicted different partners. We annotated each of these examples, as well as an equal number of false negative clefts to ensure that our measurement wasn't biased towards locations that the cleft detector is likely to find. We also transformed each cleft to signed proximity in order to fairly apply the proximity pruning approach. Out of this new set of 162 synapses we found 3 mistakes from the association network, and 4 from the proximity pruner. \section{Discussion} We've presented a method for synapse assignment which performs competitively within multiple benchmarks. This serves to establish a proof of principle for our approach. Notably, this method produces reliable results without signed input, hand-designed features, or multi-step candidate suggestion procedures. Our comparisons are specific to the Kasthuri et al. \cite{kasthuri2015saturated} dataset, yet our findings suggest that the dominant source of error is cleft detection for well-stained diadic (two-partner) synapses. Preliminary experiments have shown that our approach also works well in polyadic (multi-partner) systems (Supplemental Materials), yet future work will address general challenges. \section{Introduction} \label{sec:intro} Connectomics attempts to recover the connectivity of neural circuits from 3D electron microscopic (EM) images of neural tissue \cite{swanson2016cajal}. Recovering the connectome requires segmenting the image into individual neurons, as well as mapping the synaptic connections between neurons. A synapse is a site of apposition (``synaptic cleft'') between the plasma membranes of two neurons, called ``presynaptic'' and ``postsynaptic.'' The interior of the presynaptic cell contains synaptic vesicles (small circular structures) near the cleft, and the membrane on the postsynaptic side of the cleft often features a ``postsynaptic density'' or PSD. The darkness and thickness of the PSD may vary depending on the type of synapse or the quality of the staining. The presynaptic membrane of the cleft is almost always found on a thin kind of neural branch called an axon, typically at a swelling in the axon known as a bouton. Mitochondria are often found in the presynaptic bouton. The postsynaptic membrane of the cleft most commonly belongs to a thick kind of neural branch called a dendrite. Most of the time the postsynaptic membrane is on a thorn-like protrusion from the dendrite called a ``spine.'' The dendritic spine may contain an intracellular organelle called the spine apparatus, which consists mainly of smooth endoplasmic reticulum. All of the above visual cues are used by human experts to map synapses in EM images. In recent years there have been a number of attempts to automate this process, usually through a two-step approach \cite{dorkenwald2017automated,parag2018detecting,santurkar2017toward,gray2015automated,kreshuk2015talking} though there are alternatives \cite{buhmann2018synaptic,staffler2017synem}. The first step is detection and localization of synaptic clefts. The second step---the focus of the present work---assigns to each synaptic cleft a presynaptic cell and a postsynaptic cell. We refer to this second step as synaptic partner assignment. Almost all machine learning approaches have formulated the problem as classification of candidate synaptic partners: \begin{problem}[Candidate partner classification] Given an EM image and an ordered pair of objects as binary masks, determine whether or not the first object is presynaptic cell and the second object is postsynaptic for the same synaptic cleft. \end{problem} Machine learning classifiers have been trained for this task based on hand-designed features \cite{dorkenwald2017automated,santurkar2017toward,kreshuk2015talking,huang2018fully}. More recently, convolutional networks were trained for this task by Parag et al. \cite{parag2018detecting}. \begin{figure}[htb] \begin{minipage}[b]{1.0\linewidth} \centering \centerline{\includegraphics[width=8.5cm]{figures/basic_approach_v4.pdf}} \end{minipage} \caption{(a) The candidate partner classification task. Several pairs of candidate segment pairs are classified as synaptic or non-synaptic. (b) The voxel association task. Presynaptic and postsynaptic partners are generated from the synaptic cleft object that connects them. These masks are matched with existing segments to assign synaptic partner IDs. Although depicted using 2D images, each process occurs in 3D.} \label{fig:approach} \end{figure} In the present work, we formulate the learned task as follows: \begin{problem}[Voxel association task] Given an EM image and a synaptic cleft as a binary mask, generate the presynaptic and postsynaptic objects as binary masks. \end{problem} We call this the voxel association task, because the output images encode object relations as associations between voxels. We train a convolutional network to perform the voxel association task for the Kasthuri et al. \cite{kasthuri2015saturated} dataset of images from mouse somatosensory cortex. The network achieves very low error rates in multiple evaluations, suggesting that our approach could be sufficiently accurate for practical applications in connectomics of the mammalian cortex. Synaptic partner assignment can be more challenging when the PSD is unclear, in organisms with more than two synaptic partners per synapse, and/or images with inferior staining quality. A preliminary application of our approach in this more challenging setting is given in the Supplementary Material, but a full account is postponed to a future paper. The convolutional net trained by Parag et al. \cite{parag2018detecting} to perform candidate partner classification for the mouse somatosensory cortex (called the ``proximity pruner'' below) also achieves low error on the test set. The difference is not statistically significant due to limited test set size. Therefore, a choice between the two approaches at the present time should be based on considerations other than accuracy. In Problem 2, the convolutional net is applied once per synaptic cleft. In Problem 1, the convolutional net is applied multiple times per cleft (Figure \ref{fig:approach}). On the other hand, a simpler convolutional net may suffice for Problem 1, because it is likely to be a simpler task since the output is a single binary variable. The balance of the preceding considerations will determine which approach requires more computational resources. The voxel association task is potentially simpler to apply, because it avoids the complexity of the candidate suggestion process, which includes a number of manually set thresholds. \subsection{Related Work} Mapping synapses is related to visual scene analysis, the computation of relationships between objects in an image \cite{dai2017detecting, xu2017scene}. Our work differs in its focus on a small set of relationships (presynaptic and postsynaptic). Bounding boxes, commonly computed for scene analysis and instance segmentation \cite{ren2015faster}, could also be used as an intermediate or output representation for synaptic cleft detection, because clefts are usually fairly well-separated from each other. However, bounding boxes are not convenient for neurons, because neuronal branches are highly entangled. Our voxel association task is also similar to the object mask extension task in computer vision \cite{romeraparedes2015recurrent, ren1605end} and connectomics \cite{januszewski2016flood,meirovitch2016multi}, which iteratively grows morphological segments from seed voxels. The voxel association task relies on a single forward pass to sufficiently identify the nearby voxels of interest, yet an iterative procedure could also be useful for difficult examples, or for synapses that are too large to fit in a single context window. \section{Attentional Voxel Association Networks} We train a convolutional net to perform this task using supervised learning. We call the trained network an Attentional Voxel Association Network (AVAN). \subsection{Training \& Inference} The training procedure requires an EM dataset with (1) a morphological segmentation, (2) a synaptic cleft segmentation, and (3) a set of ID pairings which match each cleft segment ID with its presynaptic and postsynaptic IDs within the morphological segments. We take the voxels that are part of some synaptic cleft within a training volume, and form training samples from these locations by centering a patch of local context on each location. We create the cleft mask input from the synaptic cleft at the sample location. We generate target output by creating a mask of the segments with the desired pre- or postsynaptic segment ID within the local context region (one volume of output for a presynaptic ID, and another for a postsynaptic ID). Each network in this work was implemented using PyTorch \cite{paszke2017automatic}. Our association network takes a $2 \times 80 \times 80 \times 18$ window as input (concatenating image context and seed object), and produces a volume of the same size as output. We used a modified version of the Residual Symmetric U-Net architecture \cite{lee2017superhuman}, where the upsampling operation is replaced by a ``resize convolution'' \cite{odena2016deconvolution}, and one level is removed from the downsampling hierarchy. All networks were trained using a cross-entropy loss function and an Adam optimizer \cite{kingma2014adam} using a manual learning rate schedule. During inference, the network is provided with patches of input centered around the centroid of each synaptic cleft. The presynaptic segment is predicted as the segment whose voxels have the highest average output over the presynaptic volume output patch, and a similar judgment is performed for the postsynaptic segment. These judgments are restricted to segments which overlap with a dilated version of the target cleft. We used a human annotated cleft segmentation to train the association task, although the training is agnostic to the source of this segmentation. \subsection{Polyadic Synapses} Synapses of other organisms can have multiple pre- or postsynaptic partners for each synaptic cleft \cite{buhmann2018synaptic, huang2018fully}. This approach can be extended to handle multiple segments by selecting all segments with average output over a tuned threshold value. We've omitted this extension here for clarity, yet preliminary experiments have shown this approach to be competitive with other published methods (Supplementary Materials). \section{Evaluation} We evaluated our basic approach using the Kasthuri et al. dataset \cite{kasthuri2015saturated}, downsampled to a voxel resolution of $\SI{12}{\nano\metre} \times \SI{12}{\nano\metre} \times \SI{30}{\nano\metre}$. This dataset includes two small labeled volumes of voxel dimensions $512 \times 512 \times 100$ and $512 \times 512 \times 256$. An augmented version of these cutouts has been used for comparison of similar systems \cite{parag2018detecting}. We split the labeled cutouts, using the first volume and the top 100 slices of the second as a training set, the middle 56 slices of the second as a validation set, and the bottom 100 as a test set. We labeled synaptic clefts and their partners as required for this task. We evaluated the trained association network in three ways: (1) assigning human annotated cleft segments, (2) combining it with cleft detection systems, and (3) applying it to an automated reconstruction of the larger image volume. \subsection{Synapse Assignment} For comparison, we implemented the candidate classification approach of Parag et al. \cite{parag2018detecting}. In their work, a heuristic suggests candidate partners for each synapse based on overlap of predicted sites with nearby cell segments along with other variables. A ``proximity pruner'' model then classifies each potential pair of candidate partners, using 4 inputs: local image context, the output of their synapse detector, and the pair of candidate segment masks. We chose this work due to its recent results within this dataset. We transformed our synaptic cleft labels to signed proximity, and trained a pruning network on a set of candidate segment pairs, formed by taking distinct pairs which overlapped with a dilated version of each cleft. We also attempted another candidate classification approach for this task, by training a similar classifier network that takes singular cleft segment masks as input instead of signed proximity (a ``mask pruner'' network). \begin{table} \centering \caption{Assignment Test Results (163 synapses).}\label{tab:assign_res} \begin{tabular}{|c|c|} \hline \bfseries{Assignment Method} & \bfseries{Accuracy} (\%) \\ \hline Mask Pruner & 96.9 \\ \hline Proximity Pruner \cite{parag2018detecting} & 97.5 \\ \hline AVAN & 100 \\ \hline \end{tabular} \end{table} During this evaluation, we modified the inference procedure for the pruning networks. Instead of a threshold scheme, each approach took the segment pair with highest output for each ground truth cleft segment as its prediction. This allows all methods to take the identity and number of true synapses as given, and also allows us to use accuracy metrics to compare them. Each of these three methods performed very well and within error of this small dataset (Table \ref{tab:assign_res}). Notably, our modified classification approach rivaled the performance of the original version, and both classification networks performed slightly worse than the association network. This suggests little overall benefit to assignment from adding signed information, and competitive performance for each approach. \subsection{Combined System} Next, we trained models to predict the locations of synaptic clefts, and then combined these predictions with each form of partner assignment. This step explored whether imperfectly predicted seed objects would affect assignment. We also included another training representation to produce cleft masks in an attempt to reproduce its effects on performance \cite{heinrich2018synaptic}. We've found that na\"ive methods of synapse annotation can be inaccurate, as attentional gaps can miss examples \cite{plaza2014annotating}. Our cleft ground truth was initially labeled by humans, and then ``bootstrapped'' twice. Each round of bootstrapping involved reviewing the errors of each cleft prediction method after a round of training, and including valid examples into the labels. This increased the number of examples in the training, validation, and test sets by 18, 17, and 15 respectively. All cleft networks were fine-tuned with the updated ground truth after the final additions. To evaluate each combined system, we performed a grid search over its hyperparameters, optimizing the F-1 score of predicted graph edges. A correct edge was defined as a segment (or pair of segments) that maximally overlaps with a cleft label and is assigned to the correct partners. Each cleft output was generated by a trained model with the same Residual Symmetric U-Net architecture. \begin{figure}[htb] \begin{minipage}[b]{1.0\linewidth} \centering \centerline{\includegraphics[width=\textwidth]{figures/perf_comparison.pdf}} \end{minipage} \caption{Combined System Evaluation (163 synapses). \emph{(left)} Combined system performance optimized for F-1 score. \emph{(right)} Cleft detection performance optimized for combined system F-1 score. Color indicates cleft detection target representation. Shape indicates partner assignment method. Dashed lines show level sets of F-1 score at the value for each system.} \label{fig:combined_res} \end{figure} The performance of the combined systems showed more variability than the assignment task alone (Figure \ref{fig:combined_res}). By inspecting the cleft detection scores at the final hyperparameter settings and performing an error analysis, we found that the differences between methods were mostly due to cleft detection instead of assignment. While the STDT representation and the cleft mask had similar performance, signed proximity output produced more false negatives. \subsection{Large-Scale Evaluation} \begin{figure}[htb] \begin{minipage}[b]{1.0\linewidth} \centering \centerline{\includegraphics[width=8.5cm]{figures/large_scale_fig.pdf}} \end{minipage} \caption{Large-Scale Evaluation. (a) Example reconstructed dendrite with its assigned synapses. Dendrites should only have postsynaptic terminals. Red/blue dots: pre/postsynaptic terminals. Presynaptic terminals target axonal segments incorrectly merged to the dendrite by the segmentation algorithm (red ovals) and one error (black circle) from a false positive cleft.} \label{fig:large_scale} \end{figure} We observed high accuracy of synaptic partner assignment methods in small cutouts. Attempting to mine for harder examples, we further tested our assignment method by applying it to a larger volume. We performed an automated reconstruction of the entire Kasthuri et al. \cite{kasthuri2015saturated} dataset (Fig \ref{fig:large_scale}), predicted synaptic clefts using a cleft mask network, and selected 1000 predicted synapses at random from this result. We applied the AVAN at each selected synapse, as well as an early version of our proximity prediction network and the fully trained proximity pruner. Proofreading the disagreements to remove false positive clefts left 81 locations where the two methods initially predicted different partners. We annotated each of these examples, as well as an equal number of false negative clefts to ensure that our measurement wasn't biased towards locations that the cleft detector is likely to find. We also transformed each cleft to signed proximity in order to fairly apply the proximity pruning approach. Out of this new set of 162 synapses we found 3 mistakes from the association network, and 4 from the proximity pruner. \section{Discussion} We've presented a method for synapse assignment which performs competitively within multiple benchmarks. This serves to establish a proof of principle for our approach. Notably, this method produces reliable results without signed input, hand-designed features, or multi-step candidate suggestion procedures. Our comparisons are specific to the Kasthuri et al. \cite{kasthuri2015saturated} dataset, yet our findings suggest that the dominant source of error is cleft detection for well-stained diadic (two-partner) synapses. Preliminary experiments have shown that our approach also works well in polyadic (multi-partner) systems (Supplemental Materials), yet future work will address general challenges.
{'timestamp': '2019-11-25T02:06:24', 'yymm': '1904', 'arxiv_id': '1904.09947', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.09947'}
arxiv
\section{Introduction} The adoption of autonomous ground vehicles (AGVs) in real-life applications have recently got the attention of versatile industries. From food and parcel delivery~\cite{joerss2016parcel} to self-driving vehicles~\cite{Daily2017}, AGVs will be playing a vital role in our day-to-day life in the near future. AGVs are still however encountered with a number of technological hurdles preventing them from the wide adoption and acceptance by the society~\cite{lee2015can}. One of the main challenges that AGVs are still faced with is the lack of deep understanding of the behaviors of humans around them. Humans, on the other hand, can subconsciously understand and predict each others behaviors in various scenarios. For example, the scenario in Fig.~\ref{fig:sample}, any human driver will be expecting that the pedestrian in the scene is probably intending to cross. An autonomous vehicle (AV) on the other hand, might find it really difficult to anticipate this behavior. Thus, the understanding of human behaviors and intentions was considered as one of the most crucial capabilities that AGVs need to acquire~\cite{huang2016anticipatory, saleh2017towards}. Our focus in this work will be on the anticipation of human behaviors by AGVs in the context of traffic environments using only one sensor modality (i.e. monocular RGB camera). That being said, the same methodology still can be applied to other environments that involve humans and AGVs such as industrial and indoor environments~\cite{sebanz2009prediction}. In specific, we are in this work will be investigating the behaviors and intentions of one of the vulnerable road users, the pedestrians, that AVs are still challenged with in urban traffic environments~\cite{saleh2017towards}. In the literature, the intent prediction problem from video sequences is often tackled using techniques from the video action/activity recognition domain~\cite{kataoka2016recognition, saleh2017early}. The state-of-the-art frameworks for video action and activity recognition models utilize 2D convolution neural network (ConvNet) in combination with recurrent neural networks (RNNs). As a result, they can model the spatio-temporal information from video streams. Most of these models are however not suitable for real-time applications such as the prediction of intended actions of pedestrians in traffic environments because of the intensive computations required for RNNs. Additionally, these models are not unified in a way that can be easily adapted for a critical task such as intent prediction of pedestrians. For instance, most of these prediction models do not include the pre-processing stages needed for their input data as part of their overall framework. Moreover, they also do not take into account the inherent uncertainty nature of the noisy observations coming from the separate pre-processing stages which commonly exist in the context of AGVs. \begin{figure}[t] \includegraphics[keepaspectratio=true, width=\columnwidth]{Figs/sample_crossing_2} \caption{Crossing scenario from the newly released JAAD dataset~\cite{rasouli2017they}} \label{fig:sample} \end{figure} Thus, in this work, we are proposing a novel real-time unified framework for pedestrians' intent prediction and localization from video sequences. Our framework utilizes a distinctive architecture of spatio-temporal ConvNet models based on densely connected convolutional networks (DenseNets)~\cite{huang2017densely} to model the spatio-temporal information in video sequences. Spatio-temporal ConvNets have been recently shown to provide a reliable temporal modeling especially for image sequences with comparable or even better results than RNNs~\cite{tran2015learning}. DenseNets, on the other hand, have also shown remarkable results in effectively modeling spatial information in deep 2D ConvNets with less number of parameters to be trained. Our framework also integrates a sub-module for real-time tracking-by-detection of pedestrians from video sequences based on state-of-the-art single ConvNet object detection architecture (YOLOv3~\cite{redmon2018yolov3}) and simple online and real-time tracking algorithm (SORT~\cite{Bewley2016sort}). In summary, the contributions of this work are three folds: \begin{itemize} \item A novel framework for effective prediction of the intended actions pedestrians from video sequences using spatio-temporal DensNet. \item An integrated accurate tracking of multi-pedestrians in urban traffic environments as a part of the intent action prediction framework, which takes into account the uncertainty exists in noisy observations and detections from a moving observer. \item A real-time unified and flexible framework for intent prediction of pedestrians in traffic environments using only images sequences coming from an RGB camera. \end{itemize} The next section provides an overview of the related work from the literature. Section~\ref{method}, covers the proposed methodology. Section~\ref{expr}, provides the details of our experiments and the performance evaluation of our proposed framework. Finally, in Section~\ref{concl}, we conclude the paper. \section{Related Work}\label{related} The problem of intent and action prediction of pedestrians and humans in general from image sequences has got an increasing interest over the past few years~\cite{rasouli2017they, kataoka2016recognition, saleh2017early}. More specifically, in the context of AGVs in traffic environments, this problem is still an active research area due to its complexity. In this section, we will give an overview of the work from the literature that is related to the intent prediction problem of pedestrians from image sequences specifically in traffic environments. In~\cite{saleh2017early}, a multi-task 2D ConvNet model was introduced for early intent prediction of pedestrians' actions, where the problem was formulated as an image classification problem. Given a single bounding box image of a pedestrian in a traffic scene, they classify whether the pedestrian is walking or standing. Since they were only classifying the actions and not trying to anticipate them, they did not rely on any temporal information such a consecutive sequence of bounding box images. They did not also investigate scenarios of multi pedestrians in the scene. Moreover, they did not consider how the object detection stage could influence the performance of their model as they were relying on ground truth bounding boxes annotation. Similarly, in~\cite{rasouli2017they} they also relied on a 2D ConvNet model based on AlexNet architecture~\cite{krizhevsky2012imagenet} to predict whether pedestrians will cross the road or not. They introduced two different models, one only takes a single bounding box image as in~\cite{saleh2017early}. The other one takes as input a sequence of 15 consecutive bounding boxes of the pedestrians before they cross. Then, they extract the features after the last fully connected layer from AlexNet and use them to train a linear SVM classifier to decide whether the pedestrian will cross or not. They trained their models using images collected from short sequence videos using a vehicle-mounted monocular RGB camera in diverse urban traffic environments. Similar to~\cite{rasouli2017they}, the pedestrian detection phase was not also part of their proposed model and they relied on ground-truth annotations for the bounding boxes of the pedestrians. In~\cite{carreira2017quo}, two of the most common approaches that have been recently heavily utilized in literature for video activity recognition were presented. These two approaches are often referred to in the literature as spatio-temporal approaches. The first approach is based on a 2D ConvNet model which takes $k$-sequence of images and for each image it extract its features after the last fully connected layers similar to~\cite{kataoka2016recognition, rasouli2017they}. However, instead of feeding these features to a classification stage directly, they feed them to a long-short-term memory (LSTM) layer(s) first. LSTM is one of the most commonly used RNN architectures which is efficient in modeling temporal or time-series information in general~\cite{gers1999learning}. \begin{figure*}[t] \includegraphics[keepaspectratio=true, width=\textwidth]{Figs/framework} \caption{Proposed unified framework for intent action prediction of pedestrians. The input to our framework is a sequence of $k$-frames. We first detect and track all the pedestrians (first stage) in the scene and then predict their intended actions (second stage).} \label{fig:frmwrk} \end{figure*} One drawback of the aforementioned approach is its lack of flexibility because of the two separate stages of training (one for the 2D ConvNet model and the other stage for the LSTM). Thus, another approach based on spatio-temporal ConvNets using 3D convolutions was introduced. Spatio-temporal ConvNets was introduced in~\cite{tran2015learning} as an extension to the conventional 2D ConvNets but with 3D convolution filters for modeling video frames both spatially and temporally. Unlike the aforementioned approach, they can directly in a single stage, model the hierarchical representations of spatio-temporal data from video frames. One of the challenges that the spatio-temporal ConvNet models introduced in~\cite{carreira2017quo, tran2015learning} are faced with is their applicability to only shallow ConvNet architectures. Which in return affects their performance in comparison to 2D ConvNet with LSTMs. In terms of real-time performance, both the aforementioned models (2D ConvNets with LSTM and spatio-temporal ConvNets) require an extensive amount of GPU computations, which in return make them not a very appealing approach to be deployed in AGVs for real-time applications. Thus, till the rest of this paper, we will introduce, discuss and evaluate our proposed approach which combines between the level of accuracy expected from spatio-temporal techniques but with the advantage of low latency at the inference phase. As a result, our proposed approach can be easily adopted for real-time intent action prediction of pedestrians using only sequence of RGB images from a monocular camera. \section{Proposed Method}~\label{method} The goal of our work is to provide AGVs with the capabilities to efficiently predict the intended actions of the pedestrians around them in real-time using only video stream from a monocular RGB camera. In fulfilling this goal, we are introducing a unified framework that can firstly detect and track the pedestrians in traffic environments using a moving observer RGB camera. Secondly, our framework takes $k$-sequence of observed bounding boxes of the pedestrians and using a real-time spatio-temporal model it predicts the intended actions of the pedestrians. \subsection{Problem Formulation}\label{formulation} In this work, we are focused on specific scenarios of pedestrians in traffic environment which might or not cross the road at any moment. Since in crossing scenarios, the temporal dependency of subsequent frames of pedestrians over time prior to the actual crossing could help in predicting their final intended action. Thus, we found that the spatio-temporal ConvNet approach would be an effective approach for this task. As we have pointed out in Section~\ref{related}, that conventional spatio-temporal ConvNet usually requires a huge amount of parameters for training them which as a result affects their real-time performance at inference time. Therefore, we will be utilizing the DenseNet architecture as the backbone architecture of our spatio-temporal ConvNet model and we refer to it as spatio-temporal DenseNet (ST-DenseNet). The rationale behind choosing DenseNet specifically is because of its efficient number of parameters required for training them as well as their recent state-of-the-art results in image classification tasks. ST-DenseNet has also recently shown promising results in video activity recognition tasks~\cite{diba2018temporal}. The formulation and the setup for our task is however slightly different from video activity recognition tasks. In a video activity recognition task, the assumption is, given a video of a certain human activity $a$ starts at time $t_s$ and ends at time $t_{s+n}$. In light of this scenario according to Fig.~\ref{fig:sample}, the input to the ST-DenseNet for video activity recognition task, would be an image sequence of all the frames of the input video from time $t_s$ to time $t_{s+n}$ inclusive. On the other hand, in the formulation for our intent action prediction task, the input image sequence will be all the $k$ frames before the starting of the activity (i.e from time $t_{k-s}$ to time $t_{s}$). In the following sub-sections, we will discuss the two main stages of our proposed framework (shown in Fig.~\ref{fig:frmwrk}) in more details. \subsection{Multi-Pedestrian Tracking}\label{multi} Initially and before we can be able to predict the intended actions of pedestrians in the traffic scene, we need first to detect and track them over a $k$-image sequence. One of the most utilized approaches for this task especially in the context of AGVs is the tracking-by-detection paradigm~\cite{Bewley2016sort,yu2016poi,avidan2004support}. The reason for the wide adoption of the tracking-by-detection paradigm is its balance in giving good accurate estimations without neglecting the real-time performance which is crucial for AGVs. Thus, we will rely on this paradigm for the multi-pedestrian tracking stage of our proposed framework. More specifically, we will utilize a modified version of the simple online and real-time tracking (SORT)~\cite{Bewley2016sort} which recently achieved state-of-the-art results in multiple object tracking (MOT) benchmarks. One of the main advantages of the SORT is its super real-time performance, where it was benchmarked as 20x faster than the other state-of-the-art trackers. SORT exploits the recent success of ConvNet-based models for visual object detection in order to provide frame-to-frame associations. Given bounding boxes (BBoxes) from a generic ConvNet-based object detection model, SORT first predicts the next time step motion of the detected pedestrians' BBoxes using a linear Kalman filter (KF)~\cite{kalman1960new}. Then, it associates the predicted BBoxes with the observed BBoxes from the ConvNet model using a Hungarian method based on the intersection-over-union (IOU) distance~\cite{kuhn1955hungarian}. The following are our two modifications on the original SORT algorithm for our multi-pedestrian tracking stage: \subsubsection*{\textbf{Detection using YOLOv3}} Instead of the Faster-RCNN model that was used for the visual object detection in the original SORT algorithm, we will rely on the recently released YOLOv3 architecture for real-time pedestrian tracking~\cite{redmon2018yolov3}. The reason for replacing Faster-RCNN model is because it consists of two-stages for its operation which slows down its run-time. YOLOv3 on the other hand, is one of the state-of-the-art real-time single stage ConvNet-based object detectors. Since the multi-pedestrian tracking stage is a sub task of our framework, hence we need to make sure that it is done as fast as possible. Thus, we found that YOLOv3 given its real-time performance and accurate results would be the perfect match for the requirements of our framework. We utilized the same architecture as the YOLOv3-416 architecture proposed in~\cite{redmon2018yolov3}. Our only modification in the architecture is changing the number of object classes in the final classification stage to our only object of interest (i.e pedestrian). YOLOv3-416 takes as input an RGB image of size $(416H \times 416W)$, hence the name. \subsubsection*{\textbf{Estimation using UKF}} In the original SORT algorithm, it relied on the linear KF for estimating the motion model of pedestrians. The underlying assumption for the KF was a linear constant velocity model. Since in traffic environments and more specifically in crossing scenarios, pedestrians do not follow a linear motion model as it was shown in~\cite{keller2011will}. Thus, we are proposing the unscented Kalman filter (UKF)~\cite{wan2000unscented} as a non-linear motion estimation model for the multi-pedestrian tracking stage. Similar to the linear KF of the original SORT, our proposed SORT version using UKF (SORT-UKF) is assuming a constant velocity model for the pedestrians where the state of each pedestrian is represented by the following state $\textbf{x}$: \begin{equation} \textbf{x} = [u, v, s, r, \dot{u}, \dot{v}, \dot{s}]^T \end{equation} where $u$ as $v$ are the horizontal and vertical location of the center pixel of the pedestrians' BBoxes respectively. While $s$ is the scale area of the BBox and $r$ is the aspect ratio of the BBox. We used the same data association technique used in the SORT algorithm, based on the intersection-over-union (IOU) distance. Each detected BBox of pedestrian in the scene is associated based on IOU with the predicted BBoxes from the UKF. Afterwards, the detections are used for updating the UKF. \begin{figure}[t] \includegraphics[keepaspectratio=true, height= 2.4cm, width=\columnwidth]{Figs/dense_block} \caption{A 4-layer dense block of our ST-DenseNet model. Each ''conv`` is a composition function of (BN-ReLU-3D Convolution). Between each dense block a transition layer (TL) exists.} \label{fig:dblock} \end{figure} \subsection{Spatio-Temporal DenseNet (ST-DenseNet)} In ST-DenseNet, we extend the original DenseNet architecture proposed in~\cite{huang2017densely} by replacing the 2D kernels of the convolution and pooling layers with 3D counterparts. 3D convolution layers convolve its input feature maps spatially similar to the 2D convolution as well as temporally to model the temporal dependency between consecutive frames. Similarly, 3D pooling layers down-sample the size of its input feature maps spatially and temporally. The kernel of both 3D convolution layers and 3D pooling layers is of size ($s \times s \times d$), where $s$ is the spatial size and $d$ is the input video frames depth/length. The name of the DenseNet is after its architectural design, where each layer in the DenseNet is directly/densely connected to all its preceding layers. This in return helps in improving the flow of information and gradients during the training phase which accelerates it significantly. Additionally, it also reduces the number of parameters needs to be learned because the network can preserve information and eliminates the redundant re-learning of the same weights such as in conventional ConvNet architectures. The cornerstone unit of DenseNet architecture is the dense blocks. As it can be shown in Fig.~\ref{fig:dblock}, similar to 2D DenseNet, each "conv`` layer in dense block in the ST-DenseNet is internally a composition function of three consecutive operations: batch normalization (BN)~\cite{ioffe2015batch}, ReLU and a 3D convolution (with size $3 \times 3 \times 3$) unlike the 2D one in 2D DenseNet. The following equation describes how the output feature map $\textbf{f}_l$ from layer $l$ in ST-DenseNet's dense block is calculated: \begin{equation} \textbf{f}_l = \textbf{H}_l([\textbf{f}_0, \textbf{f}_1, \ldots,\textbf{f}_{l-1}]) \end{equation} where $\textbf{H}_l$ is the composition function (BN-ReLU-3DConv). The $[\textbf{f}_0, \textbf{f}_1, \ldots,\textbf{f}_{l-1}]$ is dense connectivity (concatenation operation) of the input feature maps from all the preceding layers. Similar also to the 2D DenseNet, the connection between every two dense blocks in ST-DenseNet is done via transition layers (TL). TL is comprised of two internal consecutive layers: 3D convolution and 3D pooling layers to resize the feature maps between dense blocks. Given the deep structure of ST-DenseNet and the added advantage of the dense connectivity, the number of input feature maps for each layer increases largely. In the conventional 2D DenseNets, two approaches were introduced for overcoming this problem. The first one is the growth rate parameter, which is used inside each dense block to control the number of feature maps generated from each layer in dense blocks. We extend the same growth rate parameter in our ST-DenseNet and we used a value of 24 for it. The second approach was the bottleneck layers. Bottleneck layers were firstly introduced in~\cite{szegedy2016rethinking} for addressing the same issue of high number of feature maps in the inception and ResNet architectures. The bottleneck layer in the case of 2D ConvNet models is a ``1 $\times$ 1 conv'' layer to reduce the number of input feature maps. In our ST-DenseNet model we will extend it to be a 3D bottleneck layer ``1 $\times$ 1 $\times$ 1 conv'' and will be at the start of each dense block. The total number of dense blocks we used in our ST-DenseNet model for the intended action prediction task are 3 blocks with 4 layers within each one. The input to the model is a sequence of the cropped BBox images (resized to 100H$\times$ 100W) of the pedestrians tracked over the past 16 frames ($\approx$ 0.5 sec of 30 FPS camera) from the multi-pedestrian tracking stage. The output is two softmax classification probability scores (to cross or not) for each input sequence of the unique tracked pedestrians. The full details of our ST-DenseNet model and each layer's spatial and temporal size are presented in Table~\ref{st-DenseNet}. \begin{table}[t] \centering \resizebox{0.85\columnwidth}{!}{% \begin{tabular}{c|c|c} \hline Layers & Output Size & Proposed ST-DenseNet \\ \hline Convolution-3D & \cross{50} $\times$ 16 & \cross{7} $\times$ 7 conv, stride 2 \\ \hline Pooling-3D & \cross{25} $\times$ 16 & \cross{3} $\times$ 3 average pool, stride 2 \\ \hline \begin{tabular}[c]{@{}c@{}}Dense-Block-3D\\ (1)\end{tabular} & \cross{25} $\times$ 16 & \multicolumn{1}{c}{\conv{4}} \\ \hline \multirow{2}{*}{\begin{tabular}[c]{@{}c@{}}Transition-Layer-3D\\ (1)\end{tabular}} & \cross{25} $\times$ 16 & \cross{1} $\times$ 1 conv \\ \cline{2-3} & \cross{13} $\times$ 8 & \cross{2} $\times$ 2 average pool, stride 2 \\ \hline \begin{tabular}[c]{@{}c@{}}Dense-Block-3D\\ (2)\end{tabular} & \cross{13} $\times$ 8 & \multicolumn{1}{c}{\conv{4}} \\ \hline \multirow{2}{*}{\begin{tabular}[c]{@{}c@{}}Transition-Layer-3D\\ (2)\end{tabular}} & \cross{13} $\times$ 8 & \cross{1} $\times$ 1 conv \\ \cline{2-3} & \cross{7} $\times$ 4 & \cross{2} $\times$ 2 average pool, stride 2 \\ \hline \begin{tabular}[c]{@{}c@{}}Dense-Block-3D\\ (3)\end{tabular} & \cross{7} $\times$ 4 & \multicolumn{1}{c}{\conv{4}} \\ \hline \multirow{2}{*}{\begin{tabular}[c]{@{}c@{}}Classification Layer\end{tabular}} & \cross{1} $\times$ 1 & \cross{7} $\times$ 4 average pool \\ \cline{2-3} & & 2D fully-connected, softmax \\ \hline \end{tabular} } \vspace{1 ex} \caption{ST-DenseNet architectures for pedestrian intent action prediction task. The growth rate for all the networks is $k=24$. Note that each ``conv'' layer shown in the table corresponds the sequence BN-ReLU-3DConv. } \label{st-DenseNet} \vspace{-3 ex} \end{table} \section{Experiments and Results}\label{expr} In this section, we will discuss the experiments we have done and datasets we have used for evaluating the performance of our proposed framework for real-time intent prediction of pedestrians from only video sequences. \subsection{Training and Testing Dataset} For training our proposed framework for the pedestrian intent prediction task, we had two separate training phases. The first one is for the ST-DenseNet model. The other training phase was for the YOLOV3 object detection model of our multi-pedestrian tracking stage. Before we get into the details of the data we used for training and evaluating the two phases, it is worth noting that during the inference/testing phase, the two stages of our framework work consecutively on the same GPU. \subsubsection*{\textbf{Training ST-DenseNet}} In our ST-DenseNet model, we trained it using the recently released Joint Attention for Autonomous Driving (JAAD) dataset~\cite{rasouli2017they}. JAAD dataset is vehicle-based dataset captured using a dash camera (at 30 FPS with 1080H$\times$1920W). JAAD is not only annotated with pedestrians' BBoxes but also with temporal behavioral annotations as well. The temporal behavioral annotations are such as the crossing action between a specific start and end frames. Additionally, JAAD was collected in naturalistic driving sessions across different countries (mainly in North America and Eastern Europe) under various weather conditions. The dataset consists of a total of 346 video sequences, the duration of each is 5-10 sec involving pedestrians in urban traffic environments (sample frames of the dataset are shown in Fig.~\ref{fig:sample}). The density of the annotated pedestrians in the video is relatively large with 2793 unique pedestrians with only 868 provided with behavior annotations. We have split the dataset videos into 70\% for training, 15\% for validation and 15\% for testing. The training of our ST-DenseNet was done using the training split videos with the ground truth behavior and BBoxes annotations. The labels for the pedestrians' intended action of interest (crossing or not) are done according to the formulation we described in Section~\ref{formulation}. Regarding the crossing intended action label, we crop and resize all the BBoxes sequences to (100H$\times$100W) of unique pedestrians in all frames preceding the starting frame where the pedestrian commence the crossing action. Then, we label this whole sequence of frames as the intended crossing action. For the labels of non-crossing intended actions, we chose the instances of pedestrians standing or walking beside the curb and we both cropped and resized the corresponding pedestrians' BBoxes sequence to (100H$\times$100W) for each video. Given that we are interested in predicting the intended action of pedestrians at least half a second before the committed action. Thus, we have to further pre-process the extracted sequences by running a sliding window of length 16 (roughly 0.5 sec) over all the extracted sequences before we input them to our ST-DenseNet model. As a result of this pre-processing stages, we ended up with a total number of 3602 sequence samples (16 BBoxes each) with 3061 for training and validation; 541 for testing. We trained our ST-DenseNet model using the Adam optimizer with a learning rate of 0.01 and batch size of 10 samples for 70 training epochs on Nvidia Titan X GPU. \subsubsection*{\textbf{Training YOLOv3}} For training the YOLOv3, we did not start training the model from scratch instead we took advantage of the transfer learning feature of deep ConvNet models to reduce the amount of data and time needed for training as well as enhancing the model capabilities~\cite{yosinski2014transferable}. We have fine-tuned the original YOLOv3 model which was trained on MS COCO dataset~\cite{lin2014microsoft} using the same training/validation split of the JAAD dataset similar to our ST-DenseNet model. We extracted the raw images of the training split videos and resized them to (416H $\times$ 416W) to comply with the original YOLOv3 model. We ended up with a roughly 10K images annotated with at least one pedestrian BBox for each image. \subsection{Performance of Intent Action Prediction Framework} In this experiment, the performance of our proposed framework will be assessed in accordance with our first claim that our ST-DenseNet model can effectively predict the intended actions of pedestrians. In Table~\ref{tab:table1}, we are evaluating the performance of our framework in comparison to four baseline models; one of them was the best performing baseline model on the JAAD dataset~\cite{rasouli2017they}. In order to have a fair comparison with~\cite{rasouli2017they}, in this experiment, we are testing the four models on the same JAAD testing split using the ground truth detection and tracking without using our multi-pedestrian tracking stage. \begin{table}[t] \caption{Comparison between out ST-DenseNet model and other baseline approaches from the literature to evaluate the performance of our proposed framework.} \label{tab:table1} \resizebox{0.85\columnwidth}{!}{% \centering \begin{tabular}{l|c|c|c|c} \toprule Approach & \multicolumn{4}{c}{Average Precision (\%)} \\ \midrule & GT & ACF & SSD & YOLOv3 (ours)\\ \midrule ConvNet-Softmax~\cite{saleh2017early} & 78.38 & 59.52 & 54.98 & 66.27\\ ConvNet-SVM~\cite{rasouli2017they} & 75.63 & 57.68 & 55.42 & 64.25 \\ ConvNet-LSTM~\cite{carreira2017quo} & 81.01 & \textbf{63.84} & 61.66 & 68.54 \\ C3D~\cite{carreira2017quo} & 76.83 & 51.72 & 51.66 & 56.81\\ ST-DenseNet (ours) & \textbf{84.76} & 62.35 & \textbf{62.53} & \textbf{73.78}\\ \bottomrule \end{tabular} } \end{table} We have used the average precision (AP) score as our evaluation metric which is commonly utilized and accepted in the spatio-temporal action recognition and localization tasks~\cite{rasouli2017they,saleh2017early}. The AP score is a summarization of the precision-recall curve in terms of a weighted average of precisions at different threshold values between 0.0 and 1.0. The first baseline approach is the approach introduced in~\cite{saleh2017early}. The model is based on a ConvNet architecture similar to the inception architecture. For a fair comparison, we have made a slight modification to the original model to accept a temporal sequence of BBoxes rather than one single BBox. That model in return extracts the features of the sequence BBoxes after the last fully connected layer. Using these features, they are finally passed to a 2D softmax classifier. We refer to this approach as the ConvNet-Softmax. The second baseline approach is an implementation of the model introduced recently and tested on the JAAD dataset in~\cite{rasouli2017they}. The model is based on AlexNet ConvNet architecture, which takes a sequence of length 16 as pedestrian BBoxes and extracts their features to train an SVM model. This model was trained on the same training split as our ST-DenseNet model. We refer to this model as ConvNet-SVM. The third baseline approach is similar to the first baseline model but instead of feeding the extracted features to a softmax directly, they are used to train a two-layers LSTM model. The last baseline approach is the C3D approach described in Section~\ref{related}. It consists of total 9 3D convolution layers interleaved with 5 3D max pooling layers with two fully connected layers on top of them before feeding lastly to a softmax layer. Similar to our ST-DenseNet model, all baseline models were trained using an input sequence of 16 BBoxes of tracked pedestrians in the scene using the same training/validation splits. In Table~\ref{tab:table1}-second column (GT), we report the AP scores in \% for each baseline approach in comparison to our ST-DenseNet. These scores are the result of evaluating all the models on ground-truth detections/tracks (hence the name) over the same testing split of the JAAD dataset. As it can be noticed from the table our ST-DenseNet model has achieved a high AP score of 84.76\%. The nearest model with AP score to our ST-DenseNet model is the ConvNet-LSTM model, which makes a lot of sense given the recent successes of LSTM to be good in capturing the dependency in spatio-temporal data. Similar also to~\cite{carreira2017quo}, the C3D model scored lower than the ConvNet-LSTM in the AP score. Additionally, in Fig.~\ref{fig:quali}, we show sample of the predictions of our framework on two different scenarios from the JAAD dataset. \begin{figure}[t] \includegraphics[keepaspectratio=true, width=\columnwidth]{Figs/quali_2} \caption{Qualitative results of the predictions of our framework on two scenario from the JAAD dataset. Notice how our framework can accurately predict the intended actions of the pedestrians prior to the actual action.} \label{fig:quali} \end{figure} \subsection{Effect of Noisy Observations} In order to further evaluate the performance of our proposed framework and to support our claim regarding the second contribution of this paper, we design the following experiment. Since AGVs rely on sensor observations to get the detection and tracks of objects in the scene which are usually noisy whether due to the optics of the sensor itself or the uncertainty in the detection and tracking stages. Thus, we have trained two different object detection models other than our proposed YOLOv3 to assess the resiliency of our ST-DenseNet model against noisy observations. We used the same SORT-UKF algorithm discussed in Section~\ref{multi} of our multi-pedestrian tracking stage for all compared baseline approaches. The first object detection model is the single shot multi-box detector (SSD), is another single stage ConvNet-based model similar to YOLOv3. We specifically used the SSD-MobileNet architecture which provides a decent detections with real-time performance as it was targeted for mobile devices~\cite{huang2017speed}. The other object detection model, is the aggregate channel features (ACF) model, another famous and heavily used model for the task of pedestrian detection in the literature and it has relatively near real-time performance on CPU. For the ACF we did not train it on JAAD training dataset due to memory and computations restrictions since it can only be trained on CPU. We however, used the ACF model trained on the Caltech pedestrian dataset from~\cite{Dollar2012PAMI}. As it is shown in Table~\ref{tab:table1}, our ST-DenseNet model continued to provide resilient results in comparison to the baseline models despite of the noisy observations. The only exception was with the ACF detector, where the ConvNet-LSTM model achieved a marginal improvement of only 1\% in AP score over our ST-DenseNet model. Overall, the best AP score achieved was with our proposed framework (ST-DenseNet+YOLOv3) with 73.78\% AP score. \begin{table}[t] \caption{Runtime performance analysis of our proposed framework in comparison to other baseline approaches.} \label{tab:rt} \resizebox{0.85\columnwidth}{!}{% \centering \begin{tabular}{c|c|c|c|c} \toprule Approach & Tracking & Prediction & Total & FPS\\ \toprule ConvNet-Softmax~\cite{saleh2017early} & 40ms & 28ms & 68ms & 14.7 \\ ConvNet-SVM~\cite{rasouli2017they} & 40ms & 27ms & 67ms & 14.9 \\ ConvNet-LSTM~\cite{carreira2017quo} & 40ms & 40ms & 80ms & 12.5 \\ C3D~\cite{carreira2017quo} & 40ms & 27ms & 67ms & 14.9\\ ST-DenseNet (ours) & 40ms & \textbf{10ms} & \textbf{50ms} & \textbf{20}\\ \bottomrule \end{tabular} } \end{table} \subsection{Runtime Analysis} In Table~\ref{tab:rt}, the run time performance of our proposed framework in comparison to the other baseline approaches is listed. Since the baseline models from the literature did not include the detection or the tracking stages as part of their action prediction models, we report the runtime performance in ms for each separate stage. The tracking column represents the first stage of the framework which is the multi-pedestrian tracking using YOLOv3+SORT-UKF. The prediction column represents the second stage which could be any of the four baseline models in addition to our ST-DenseNet model from the first column. As it can be noticed, our framework has achieved a real-time performance of 20 FPS, while the other baseline models were facing some challenges with the nearest model achieving only 14.9 FPS. All the run-time analysis experiments run on the same PC with an Intel i7 CPU and an Nvidia Titan X GPU. \section{Conclusion }\label{concl} In this work, we have introduced a real-time framework for the task of intent action prediction of pedestrians in urban traffic environments. We have extended state-of-the-art deep DenseNet architecture to accommodate spatio-temporal image sequences from a monocular RGB camera to predict pedestrians' intended actions. Our framework has achieved a remarkable results in comparison to a number of baseline approaches from the literature. We have scored an average precision score of 84.76\% in comparison to 76.83\% reported by the C3D model from the literature. Additionally, our framework has also achieved a real-time performance of 20 FPS. \bibliographystyle{IEEEtran}
{'timestamp': '2019-04-23T02:25:59', 'yymm': '1904', 'arxiv_id': '1904.09862', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.09862'}
arxiv
\section{Conclusion}\label{sect:conclu} In this paper we presented a calculus for an imperative object-oriented language whose distinguished features are the following. \begin{itemize} \item Local variable declarations are used to directly represent the memory. That is, a declared {(non affine)} variable is not replaced by its value, as in standard \texttt{let}, but the association is kept and used when necessary.\item In this way, there are language values (block values) which represent (a portion of) memory, and the fact that such portion of memory is isolated can be \emph{modularly} checked by inspecting only the value itself, without any need to explore the whole graph structure of the global memory as it would be in the conventional model. \item To safely handle capsules, the syntactic calculus supports \emph{affine} variables with a special semantics. Runtime checks ensure that their initializing value is a capsule, and their (unique by definition) occurrence is replaced by their capsule value (rule \rn{affine-elim}). \item {\emph{Block annotations} allow a variable declaration to be moved outside of a block only if such variable will \emph{not} be part of its final result. This additional runtime check prevents to ``break'' capsules before they are moved.} \end{itemize} In previous work \cite{CapriccioliSZ15,ServettoZucca15,GianniniSZ16,GianniniSZ17,GianniniSZ18,GianniniSZC19b,GianniniRSZ19a}, we have designed type systems which statically ensure that such runtime checks succeed, hence execution is not stuck. In this paper we {prove} that the syntactic calculus preserves the standard semantics of imperative calculi relying on a global memory. In such calculi reasoning about program properties such as sharing requires the formalization of invariants on the memory and the proof of their preservation under reduction, whereas in ours this can be done by structural induction on terms. The wider context of the paper is the huge amount of research on mechanisms for controlling sharing and interference. In this paper we focus on the property that the the subgraph reachable from a reference $\metavariable{x}$ is an isolated portion of store, that is, all its (non immutable) nodes can be reached only through this reference. This property has many variants in literature \cite{ClarkeWrigstad03,Almeida97,Hogg91,DietlEtAl07,GordonEtAl12}. Examples of other relevant properties of referenes studied in literature are the following: \begin{itemize} \item $\metavariable{x}$ is \emph{immutable}, that is, the subgraph reachable from $\metavariable{x}$ is an \emph{immutable} portion of store. An immutable reference can be safely shared in a multithreaded environment. \item $\metavariable{x}$ is \emph{lent}, that is, the subgraph reachable from $\metavariable{x}$ can be manipulated, but not shared, by a client \cite{ServettoZucca15,GianniniSZ16,GianniniSZ18}. This is also called \emph{borrowed} in literature \cite{Boyland01,NadenEtAl12}. \item $\metavariable{x}$ is \emph{read-only} if no modification is permitted through $\metavariable{x}$. Note that there is no immutability guarantee. \end{itemize} A specular approach to the use of qualifiers to restrict the usage of references is that on \emph{ownership} (see an overview in~\cite{ClarkeEtAl13}), where a formal way is provided to express and prove the ownership invariants. Among the many works in this stream, we mention Rust \cite{Turon17}, which uses ownership {and qualifiers} for memory management. In future work we plan to add the modelling of immutable references. We will also investigate (a form of) Hoare logic on top of our model. \section{The conventional calculus}\label{sect:conventional} We illustrate our approach in the context of calculi with an object-oriented flavour, inspired {by} Featherweight Java \cite{IgarashiEtAl01} (FJ for short). This is only a presentation choice: the ideas and results of the paper could be rephrased in different imperative calculi, e.g., supporting data type constructors and reference types. For the same reason, we omit features such as inheritance and late binding, which are orthogonal to our focus. The conventional calculus is given in \refToFigure{conventional}. It is similar to other imperative variants of FJ which can be found in the literature \cite{AhernY05,BiermanP03,BettiniDS10}. We assume sets of \emph{variables} $\metavariable{x}, \metavariable{y}, \metavariable{z}$, \emph{class names} $\metavariable{C}, \metavariable{D}$, \emph{field names} $\metavariable{f}$, and \emph{method names} $\metavariable{m}$. We adopt the convention that a metavariable which ends in \metavariable{s} is implicitly defined as a (possibly empty) sequence in which elements may or may not be separated by commas. In particular, $\metavariable{ds}$ (and $\metavariable{dvs}$ in the next section) are sequences of $\metavariable{d}$ (and $dv$) and $\metavariable{es}$, $\metavariable{vs}$ and $\metavariable{xs}$ are sequences of $\metavariable{e}$, $\metavariable{v}$ and $\metavariable{x}$ separated by commas. \begin{figure}[h] {\small \begin{grammatica} \produzione{\metavariable{e}}{\metavariable{x}\mid\FieldAccess{\metavariable{e}}{\metavariable{f}}\mid\FieldAssign{\metavariable{e}}{\metavariable{f}}{\metavariable{e}'}\mid\ConstrCall{\metavariable{C}}{\metavariable{es}}\mid\MethCall{\metavariable{e}}{\metavariable{m}}{\metavariable{es}}\mid\Block{\metavariable{ds}}{\metavariable{e}}\mid\iota}{expression}\\ \produzione{\metavariable{d}}{\Dec{\metavariable{C}}{\metavariable{x}}{\metavariable{e}}}{declaration}\\ \\ \produzione{\metavariable{v}}{\iota}{value}\\ \produzione{{\cal{E}}}{[\ ]\mid\FieldAccess{{\cal{E}}}{\metavariable{f}}\mid\FieldAssign{{\cal{E}}}{\metavariable{f}}{\metavariable{e}'}\mid\FieldAssign{\iota}{\metavariable{f}}{{\cal{E}}}\mid\ConstrCall{\metavariable{C}}{\metavariable{vs},{\cal{E}},\metavariable{es}}}{evaluation context}\\ \seguitoproduzione{\mid\MethCall{{\cal{E}}}{\metavariable{m}}{\metavariable{es}}\mid\MethCall{\iota}{\metavariable{m}}{\metavariable{vs},{\cal{E}},\metavariable{es}}\mid\Block{\Dec{\metavariable{C}}{\metavariable{x}}{{\cal{E}}}\ \metavariable{ds}}{\metavariable{e}}}{} \end{grammatica} { \bigskip \hrule \bigskip \begin{math} \begin{array}{l} {\NamedRuleOL{alpha}{\congruence{\Block{\metavariable{ds}\ \Dec{\metavariable{C}}{\metavariable{x}}{\metavariable{e}}\ \metavariable{ds}'}{\metavariable{e}'}}{\Block{\Subst{\metavariable{ds}}{\metavariable{y}}{\metavariable{x}}\ \Dec{\metavariable{C}}{\metavariable{y}}{\Subst{\metavariable{e}}{\metavariable{y}}{\metavariable{x}}}\ \Subst{\metavariable{ds}'}{\metavariable{y}}{\metavariable{x}}}{\Subst{\metavariable{e}'}{\metavariable{y}}{\metavariable{x}}}}}{}} \hskip 1.5em\NamedRuleOL{block-elim}{\congruence{\Block{}{\metavariable{e}}}{\metavariable{e}}}{} \end{array} \end{math}} \bigskip \hrule \bigskip \begin{math} \begin{array}{l} \NamedRule{ctx}{\creduce{\ExpMem{\metavariable{e}}{\mu}}{\ExpMem{\metavariable{e}'}{\mu'}}}{\creduce{\ExpMem{\Ctx{\metavariable{e}}}{\mu}}{\ExpMem{\Ctx{\metavariable{e}'}}{\mu'}}}{}\hskip 1.5em \NamedRuleOL{field-access}{\creduce{\ExpMem{\FieldAccess{\iota}{\metavariable{f}_i}}{\mu}}{\ExpMem{\metavariable{v}_i}{\mu}}} {\mu(\iota)=\ConstrCall{\metavariable{C}}{\metavariable{v}_1,\dots,\metavariable{v}_n}\\ \fields{\metavariable{C}}=\Field{\metavariable{C}_1}{\metavariable{f}_1}\dots\Field{\metavariable{C}_n}{\metavariable{f}_n}{\ \wedge\ 1\leq i\leq n}}\\[4ex] \NamedRuleOL{field-assign}{\creduce{\ExpMem{\FieldAssign{\iota}{\metavariable{f}_i}{\metavariable{v}}}{\mu}}{\ExpMem{\metavariable{v}}{\UpdateMem{\mu}{\iota}{i}{\metavariable{v}}}}}{\mu(\iota)=\ConstrCall{\metavariable{C}}{\metavariable{vs}}\\ \fields{\metavariable{C}}=\Field{\metavariable{C}_1}{\metavariable{f}_1}\dots\Field{\metavariable{C}_n}{\metavariable{f}_n}{\ \wedge\ 1\leq i\leq n}}\\[4ex] \NamedRuleOL{new}{\creduce{\ExpMem{\ConstrCall{\metavariable{C}}{\metavariable{vs}}}{\mu}}{\ExpMem{\iota}{\Subst{\mu}{\ConstrCall{\metavariable{C}}{\metavariable{vs}}}{\iota}}}}{\iota\not\in\dom{\mu}}\\[4ex] \NamedRuleOL{invk}{\creduce{\ExpMem{\MethCall{\iota}{\metavariable{m}}{\metavariable{v}_1,\dots,\metavariable{v}_n}}{\mu}}{\ExpMem{\Block{\Dec{\metavariable{C}_1}{\terminale{this}}{\iota}\ \Dec{\metavariable{C}_1}{\metavariable{x}_1}{\metavariable{v}_1}\dots\Dec{\metavariable{C}_n}{\metavariable{x}_n}{\metavariable{v}_n}}{\metavariable{e}}}}{\mu}} {\mu(\iota)=\ConstrCall{\metavariable{C}}{\metavariable{vs}}\\ \method{\metavariable{C}}{\metavariable{m}}=\Pair{\metavariable{x}_1\dots\metavariable{x}_n}{\metavariable{e}}}\\[4ex] \NamedRuleOL{dec}{\creduce{\ExpMem{\Block{\Dec{\metavariable{C}}{\metavariable{x}}{\iota}\ \metavariable{ds}}{\metavariable{e}}}{\mu}}{\ExpMem{\Subst{\Block{\metavariable{ds}}{\metavariable{e}}}{\iota}{\metavariable{x}}}{\mu}}}{} \end{array} \end{math} } \caption{Conventional calculus}\label{fig:conventional} \end{figure} An expression can be a variable (including the special variable $\terminale{this}$ denoting the receiver in a method body), a field access, a field assignment, a constructor invocation, a method invocation, or a block consisting of a sequence of local variable declarations and a body. In addition, a (runtime) expression can be an \emph{object identifier} $\iota$. Blocks are included to have a more direct correspondence with the syntactic calculus. In a block, a declaration specifies a type (class name), a variable and an initialization expression. We assume that in well-formed blocks there are no multiple declarations for the same variable{, that is, $\metavariable{ds}$ can be seen as a map from variables to expressions: $\dom{\metavariable{ds}}$ denotes the set of variables declared in $\metavariable{ds}$ and $\metavariable{ds}(\metavariable{x})$ the initialization expression for $\metavariable{x}$ in $\metavariable{ds}$, if any. In the examples, we generally omit the brackets of the outermost block, and abbreviate $\Block{\Dec{\metavariable{T}}{\metavariable{x}}{\metavariable{e}}}{\metavariable{e}'}$ by $\Sequence{\metavariable{e}}{\metavariable{e}'}$ when $\metavariable{x}$ does not occur free in $\metavariable{e}'$. We also assume integer constants, which are not included in the formalization. {Expressions are identified modulo congruence, denoted by $\congruence{}{}$, defined as the smallest congruence satisfying the axioms in the mid section of \refToFigure{conventional}. Rule \rn{alpha} is the usual $\alpha$-conversion. The condition $\metavariable{x},\metavariable{y}\not\in\dom{\metavariable{ds}\,\metavariable{ds}'}$ is implicit by well-formedness of blocks. Rule \rn{block-elim} identifies a block without declarations with its body.} The class table is abstractly modelled by the following functions: \begin{itemize} \item $\fields{\metavariable{C}}$ gives, for each declared class $\metavariable{C}$, the sequence $\Field{\metavariable{C}_1}{\metavariable{f}_1}\dots\Field{\metavariable{C}_n}{\metavariable{f}_n}$ of its fields declarations. \item $\method{\metavariable{C}}{\metavariable{m}}$ gives, for each method $\metavariable{m}$ declared in class $\metavariable{C}$, the pair consisting of its parameters and body. \end{itemize} The reduction relation $\creduce{}{}$ is defined on pairs $\ExpMem{\metavariable{e}}{\mu}$ where a \emph{memory} $\mu$ is a finite map from object identifiers $\iota$ into object states of shape $\ConstrCall{\metavariable{C}}{\metavariable{vs}}$. Values are object identifiers (we do not identify the two sets since, extending the language, values would be extended to include, e.g., primitive values {such as integers}). Evaluation contexts and reduction rules are straightforward. {In rule \rn{field-assign}, we} denote by $\UpdateMem{\mu}{\iota}{i}{\metavariable{v}}$ the memory where the $i$-th field of the object state associated to $\iota$ has been replaced by $\metavariable{v}$. {In rule \rn{invk}, we take advantage of the block construct to provide a modular semantics, where a method call is reduced to a block where declarations of the appropriate type for $\terminale{this}$ and the parameters are initialized with the receiver and the arguments, respectively, and the body is the method body. Indeed, this rule plus a sequence of applications of rule \rn{Dec} is equivalent to the standard FJ rule} ${\creduce{\ExpMem{\MethCall{\iota}{\metavariable{m}}{\metavariable{v}_1,\dots,\metavariable{v}_n}}{\mu}}{\ExpMem{\SubstDot{\Subst{\metavariable{e}}{\iota}{\terminale{this}}}{\metavariable{v}_1}{\metavariable{x}_1}{\metavariable{v}_n}{\metavariable{x}_n}}}{\mu}}$.} Local variable declarations have the standard substitution semantics, and are elaborated in the usual left-to-right order (no recursion is allowed). \section{Introduction} In languages with state and mutations, keeping control of aliasing relations is a key issue for correctness. This is {exacerbated} by concurrency mechanisms, since side-effects in one thread can affect the behaviour of another thread, hence unpredicted aliasing can induce unplanned/unsafe communication. For these reasons, the last few decades have seen considerable interest in type systems for controlling sharing and interference, to make programs easier to maintain and understand, notably using \emph{qualifiers} to restrict the usage of references \cite{ZibinEtAl10,GordonEtAl12,NadenEtAl12,ClebschEtAl15}. In particular, in an ongoing stream of work \cite{ServettoZucca15,GianniniSZ16,GianniniSZ17,GianniniSZ17a, GianniniSZ18,GianniniRSZ19a,GianniniSZC19b}, we have adopted an innovative execution model \cite{ServettoLindsay13,CapriccioliSZ15} for imperative languages which, differently from traditional ones, {is a \emph{reduction relation on language terms}. That is, we do not add an auxiliary structure which mimics physical memory, but such structure is encoded in the language itself.} Whereas this makes no difference from a programmer's point of view, it is important on the foundational side, since, as will be informally illustrated below, language semantics directly represents at the syntactic level constraints on aliasing, allowing simpler reasoning about related properties. In this paper, we focus on the operational model itself, rather than on type systems, and formalize its relation with the conventional model, where an auxiliary global structure mimics memory. To informally introduce this syntactic calculus, we show examples of reduction sequences. The main idea is to use variable declarations to directly represent the memory. That is, a declared variable is not replaced by its value, as in standard \texttt{let}, but the association is kept and used when necessary, as it happens, with different aims and technical problems, in cyclic lambda calculi \cite{AriolaFelleisen97,MaraistEtAl98,AriolaBlom02}. Assuming a program (class table) where class \lstinline{C} has two fields \lstinline{f1} and \lstinline{f2} of type \lstinline{D}, and class \lstinline{D} has a field \lstinline{f} of type \lstinline{D}, the term \begin{lstlisting}[basicstyle=\ttfamily\footnotesize,backgroundcolor=\color{white}] D x=new D(y); D y=new D(x); C w={D z=new D(z); x.f=x; new C(z,z)}; w.f1 \end{lstlisting} starts with two declarations that can be seen as a memory consisting of two mutually referring objects. Then there is a declaration whose right-hand-side needs to be evaluated and the final expression returns the value of a field of the object associated with this last variable. The reduction of the term is as follows. \begin{lstlisting}[basicstyle=\ttfamily\footnotesize,backgroundcolor=\color{white}] $\store{D x=new D(y); D y=new D(x);}$ C w={D z=new D(z); x.f=x; new C(z,z)}; w.f1 $\longrightarrow$ $\store{D x=new D(x); D y=new D(x);}$ C w={D z=new D(z); new C(z,z)}; w.f1 $\longrightarrow$ $\store{D x=new D(x); D y=new D(x); D z=new D(z);}$ C w={new C(z,z)}; w.f1 $\cong$ $\store{D x=new D(x); D y=new D(x); D z=new D(z); C w=new C(z,z);}$ w.f1 $\longrightarrow$ $\store{D x=new D(x); D y=new D(x); D z=new D(z); C w=new C(z,z);}$ z $\longrightarrow$ $\store{D z=new D(z);}$ z \end{lstlisting} Evaluation proceeds left to right. {We emphasize at each step the declarations which can be seen as the store (in grey).} We start evaluating the right-hand-side of the declaration for \lstinline{w}, by updating the field \lstinline{f} of \lstinline{x}. Then, in order to evaluate the field access \lstinline{w.f1}, {we need to move the declaration of \lstinline{z} outside of the inner block. A block with no declarations is considered equivalent to its body, as expressed by $\cong$.} Now the field access \lstinline{w.f1} can be performed, getting \lstinline{z}, and the last step removes declarations (memory) which are not reachable from \lstinline{z}, giving as final result a memory consisting of only one cyclic object. To illustrate how aliasing constraints are directly represented in this syntactic model, we consider an important example: how to characterize an isolated portion of memory, which cannot be reached through external references. {This allows programmers (and static analyses) to identify portions of memory that can be safely handled by a thread.} This property has been widely studied in the literature, under different names and variants, such as \emph{isolated} \cite{GordonEtAl12}, \emph{unique} \cite{Boyland10} and \emph{externally unique}~\cite{ClarkeWrigstad03}, \emph{balloon} \cite{Almeida97}, \emph{island} \cite{DietlEtAl07}. In the syntactic calculus, block values with no free variables, called \emph{capsules}, provide a simple representation of portions of memory which are trivially isolated. For instance, in the following example: \begin{lstlisting}[basicstyle=\ttfamily\footnotesize,backgroundcolor=\color{white}] $\rn{ex1}\hskip 1.5em\store{D x=new D(x); D y=new D(x);}$ C$^\terminale{a}$ w={D z=new D(z); new C(z,z)}; x.f=x \end{lstlisting} the right-hand side of the declaration of \lstinline{w} is a capsule. To allow the programmer to \emph{safely rely} on the fact that \lstinline{w} denotes an isolated portion of memory, which nobody else in the program can affect, we introduce the qualifier $\terminale{a}$, as shown above, for \emph{affine} variables/parameters, which should be initialized with capsules. If the term is, instead: \begin{lstlisting}[basicstyle=\ttfamily\footnotesize,backgroundcolor=\color{white}] $\rn{ex2}\hskip 1.5em\store{D x=new D(x); D y=new D(x);}$ C$^\terminale{a}$ w={D z=new D(z); new C(z,y)}; x.f=x \end{lstlisting} then the inner block is \emph{not} a capsule, hence its use to inizialize an affine variable is an error to be prevented, otherwise a programmer using \lstinline@w@ would erroneously rely on the capsule property. In the syntactic calculus, this error can be easily detected at runtime in a modular way, that is, by looking only at the block itself. For instance, in \rn{ex1} the runtime check succeeds, whereas in \rn{ex2} it fails, hence normal execution cannot proceed, since the block contains the free variable \lstinline{y}.\footnote{In the formalization presented in this paper, the term is simply stuck. A different choice could be to introduce explicit \emph{error} terms. In our previous work \cite{ServettoZucca15,GianniniSZ16,GianniniSZ17,GianniniSZ17a, GianniniSZ18} we have designed type systems which are able to statically prevent such error.} Note that, in the conventional calculus, detecting that a reference denotes an isolated portion of memory requires, instead, a dependency analysis involving surrounding code and memory. For instance, in the examples \rn{ex1} and \rn{ex2} above, execution will reach respectively the following step: \begin{quote} $\rn{ex1}\hskip 1.5em\ExpMem{\texttt{C$^\terminale{a}$ w = new C($\iota_\metavariable{z}$,$\iota_\metavariable{z}$); $\iota_\metavariable{x}$.f=$\iota_\metavariable{x}$}}{\mu}$\\ $\rn{ex2}\hskip 1.5em\ExpMem{\texttt{C$^\terminale{a}$ w = new C($\iota_\metavariable{z}$,$\iota_\metavariable{y}$); $\iota_\metavariable{x}$.f=$\iota_\metavariable{x}$}}{\mu}$ \end{quote} where the domain of the memory $\mu$ are \emph{object identifiers} $\iota$, modeling \emph{global} names which, differently from variables, do not support shadowing and $\alpha$-renaming. Here $\mu=\iota_\metavariable{x}\mapsto\ConstrCall{\metavariable{D}}{\iota_\metavariable{x}}, \iota_\metavariable{y}\mapsto\ConstrCall{\metavariable{D}}{\iota_\metavariable{x}},\iota_\metavariable{z}\mapsto\ConstrCall{\metavariable{D}}{\iota_\metavariable{z}}$. It is clear that the two situations cannot be distinguished by only looking locally at the initialization expression of \lstinline{w}. Instead, we must check that the memory portion reachable from such initialization expression is isolated, that is, cannot be reached from references used in other parts of the program. This is true for \rn{ex1}, since there is no sharing between $\iota_\metavariable{z}$ and the reference $\iota_\metavariable{x}$ used in the external code \texttt{$\iota_\metavariable{x}$.f=$\iota_\metavariable{x}$}. For \rn{ex2}, instead, there is sharing between $\iota_\metavariable{y}$ and $\iota_\metavariable{x}$, and indeed the execution of such external code affects the portion of memory reachable from \texttt{new C($\iota_\metavariable{y}$,$\iota_\metavariable{z}$)}. In the general case, detecting sharing through dependency analysis is an expensive check, which could even be impossible in a distributed environment. As said above, by using an affine variable/parameter $\metavariable{x}$ the programmer can safely rely on the fact that $\metavariable{x}$ denotes an isolated portion of memory. On the other hand, the capsule property should be preserved when $\metavariable{x}$ is used. This is ensured by the constraint that affine variables/parameters can be used at most once, and by a special reduction semantics, motivated and described below. As already shown, for (non-affine) variable declarations reduction is as follows: \begin{lstlisting}[basicstyle=\ttfamily\footnotesize,backgroundcolor=\color{white}] $\store{D x=new D(x); D y=new D(x);}$ C w={D z=new D(z); new C(z,z)}; w.f1 $\longrightarrow$ $\store{D x=new D(x); D y=new D(x); D z=new D(z);}$ C w={new C(z,z)}; w.f1 $\cong$ $\store{D x=new D(x); D y=new D(x); D z=new D(z); C w=new C(z,z);}$ w.f1 $\longrightarrow$ $\ldots$ \end{lstlisting} That is, the block is flattened, hence the capsule property is lost. This corresponds to the fact that, if we get access to a portion of memory through an ordinary variable, then sharing could be introduced through such variable, hence, in particular, a portion of memory which was isolated is not guaranteed to remain such. To preserve the property, affine variables have a special semantics, which allow a capsule to be moved to another location in the memory, or passed as argument to a method. In the above example, reduction would be as follows: \begin{lstlisting}[basicstyle=\ttfamily\footnotesize,backgroundcolor=\color{white}] $\store{D x=new D(x); D y=new D(x);}$ C$^\terminale{a}$ w={D z=new D(z); new C(z,z)}; w.f1 $\longrightarrow$ $\store{D x=new D(x); D y=new D(x);}$ {D z=new D(z); new C(z,z)}.f1 $\longrightarrow$ $\store{D x=new D(x); D y=new D(x);}$ {D z=new D(z); new C(z,z).f1} $\longrightarrow$ $\store{D x=new D(x); D y=new D(x);}$ {D z=new D(z); z} $\longrightarrow$ $\store{D z=new D(z);}$ z \end{lstlisting} Differently from the previous reduction, the block occurring as right-hand side of the declaration of \lstinline{w} is \emph{not} flattened, but, rather, used to replace \lstinline{w}. That is, affine variables have a substitution semantics. Then, the field access is propagated inside the block to be performed. In \refToSection{conventional} and \refToSection{syntactic} we define the conventional and the syntactic calculus, respectively. In \refToSection{preservation} we show that the syntactic model can be encoded in the conventional one, hence efficiently implemented, and {prove} that the dynamic semantics is preserved by the encoding. Finally, in \refToSection{conclu} we draw some conclusions. \section{Preservation of semantics}\label{sect:preservation} In this section, for clarity, we use $\hat{\e}$ and $\widehat{\decs}$ to range over expressions and sequences of declarations of the conventional calculus, which could include object identifiers. We show that, if an expression has a reduction sequence in the syntactic calculus, then it has an ``equivalent'' reduction sequence in the conventional calculus. Note that the converse does not hold, since an expression which is stuck in the syntactic calculus, since a capsule runtime check (side condition of rule \rn{affine-elim}) fails, could reduce in the conventional calculus. That is, in the syntactic calculus, by declaring $\metavariable{x}$ affine, the programmer can rely on the fact that during computation $\metavariable{x}$ will always denote an isolated portion of memory\footnote{{Hence, nobody else in the program can affect memory reachable from $\metavariable{x}$, hence such memory can be safely handled by a thread.} }, otherwise an exception would be raised. In order to state the preservation results (\refToTheorem{step} and Corollary \ref{preservation}), we define a \emph{matching} relation $\correspondence{}{\rho}$ between expressions $\metavariable{e}$ of the syntactic calculus and pairs $\ExpMem{\hat{\e}}{\mu}$ of the conventional calculus. {The relation is labelled by an injective mapping $\rho$ from object identifiers in {the domain of} $\mu$ to variables. Intuitively, $\correspondence{\metavariable{e}}{\rho}{\ExpMem{\hat{\e}}{\mu}}$ holds if variables in the image of $\rho$ are all those declared in evaluated declarations in $\metavariable{e}$ and all such declarations are removed in $\hat{\e}$. More precisely, since the same variable could be declared in different blocks inside an expression, the mapping $\rho$ should be from object identifiers to \emph{binding occurrences} of variables. To make the formal treatment simpler, we can assume that each variable is declared at most once in expressions of the syntactic calculus. {This can} be obtained by $\alpha$-renaming. Formally the relation is inductively defined by the rules in \refToFigure{correspondence}. A variable in the syntactic calculus is matched in the conventional calculus by {a pair where the expression is} the corresponding object identifier in $\rho$, if any, rule \rn{oid}, otherwise the variable itself, rule \rn{var}. The former case happens when the variable declaration is evaluated in the syntactic calculus. Rules \rn{field-access}, \rn{field-assign}, \rn{new}, and \rn{invk} just propagate matching to subterms. For $\metavariable{es}=\metavariable{e}_1, \ldots, \metavariable{e}_n$, {$\widehat{\metavariable{es}}=\hat{\e}_1, \ldots, \hat{\e}_n$,} we use $\correspondence{\metavariable{es}}{\rho}{\ExpMem{\widehat{\metavariable{es}}}{\mu}}$ to abbreviate $\correspondence{\metavariable{e}_i}{\rho}{\ExpMem{\hat{\e}_i}{\mu}}\hskip 0.4em \forall i\in 1..n$. In rule \rn{block}, a block $\BlockLab{\metavariable{dvs}\ \metavariable{ds}}{\metavariable{e}}{\metavariable{x}}$ in the syntactic calculus is matched by a block and memory $\ExpMem{\Block{\widehat{\decs}}{\hat{\e}}}{\mu}$ of the conventional calculus if evaluated declarations $\metavariable{dvs}$ are matched by memory $\mu$, as expressed by the auxiliary judgment $\correspondence{\metavariable{dvs}}{\rho}{\mu}$, and matching is propagated to other subterms. For $\metavariable{ds}=\metavariable{d}_1\ldots\metavariable{d}_n$, $\widehat{\decs}=\widehat{\dec}_1\ldots\widehat{\dec}_n$, we use $\correspondence{\metavariable{ds}}{\rho}{\ExpMem{\widehat{\decs}}{\mu}}$ to abbreviate $\correspondence{\metavariable{d}_i}{\rho}{\ExpMem{\widehat{\dec}_i}{\mu}}\hskip 0.4em \forall i\in 1..n$, and analogously for $\correspondence{\metavariable{dvs}}{\rho}{\mu}$. \begin{figure}[h] {\small \begin{math} \begin{array}{l} \NamedRule{oid}{}{\correspondence{\metavariable{x}}{\rho}{\ExpMem{\iota}{\mu}}}{\rho(\iota) = \metavariable{x}}{\hskip 1.5em\NamedRule{var}{}{\correspondence{\metavariable{x}}{\rho}{\ExpMem{\metavariable{x}}{\mu}}}{\metavariable{x}\not\in\img{\rho}}}\\[4ex] \NamedRule{field-access}{\correspondence{\metavariable{e}}{\rho}{\ExpMem{\hat{\e}}{\mu}}}{\correspondence{\FieldAccess{\metavariable{e}}{\metavariable{f}}}{\rho}{\ExpMem{\FieldAccess{\hat{\e}}{\metavariable{f}}}{\mu}}}{}\hskip 1.5em \NamedRule{field-assign}{\correspondence{\metavariable{e}}{\rho}{\ExpMem{\hat{\e}}{\mu}}\hskip 1.5em\correspondence{\metavariable{e}'}{\rho}{\ExpMem{\hat{\e}'}{\mu}}}{\correspondence{\FieldAssign{\metavariable{e}}{\metavariable{f}}{\metavariable{e}'}}{\rho}{\ExpMem{\FieldAssign{\hat{\e}}{\metavariable{f}}{\hat{\e}'}}{\mu}}}{}\\[4ex] \NamedRule{new}{ \correspondence{\metavariable{es}}{\rho}{\ExpMem{\widehat{\metavariable{es}}}{\mu}} }{\correspondence{\ConstrCall{\metavariable{C}}{\metavariable{es}}}{\rho}{\ExpMem{\ConstrCall{\metavariable{C}}{\widehat{\metavariable{es}}}}{\mu}}}{}\hskip 1.5em \NamedRule{invk}{ \correspondence{\metavariable{e}}{\rho}{\ExpMem{\hat{\e}}{\mu}\hskip 1.5em\correspondence{\metavariable{es}}{\rho}{\ExpMem{\widehat{\metavariable{es}}}{\mu}}} }{\correspondence{\MethCall{\metavariable{e}}{\metavariable{m}}{\metavariable{es}}}{\rho}{\ExpMem{\MethCall{\hat{\e}}{\metavariable{m}}{\widehat{\metavariable{es}}}}{\mu}}}{} \\[4ex] {\NamedRule{block}{\correspondence{\metavariable{dvs}}{\rho}{\mu}\hskip 1.5em\correspondence{\metavariable{ds}}{\rho}{\ExpMem{\widehat{\decs}}{\mu}}\hskip 1.5em\correspondence{\metavariable{e}}{\rho}{\ExpMem{\hat{\e}}{\mu}}}{\correspondence{\BlockLab{\metavariable{dvs}\ \metavariable{ds}}{\metavariable{e}}{\X}}{\rho}{\ExpMem{\Block{\widehat{\decs}}{\hat{\e}}}}{\mu}}{} \hskip 1.5em\NamedRule{dec}{\correspondence{\metavariable{e}}{\rho}{\ExpMem{\hat{\e}}{\mu}}}{\correspondence{\Dec{\Type{\metavariable{q}}{\metavariable{C}}}{\metavariable{x}}{\metavariable{e}}}{\rho}{\ExpMem{\Dec{\metavariable{C}}{\metavariable{x}}{\hat{\e}}}{\mu}}}{\Dec{\Type{\metavariable{q}}{\metavariable{C}}}{\metavariable{x}}{\metavariable{e}}\neq\metavariable{dv}}}\\[5ex] \NamedRule{ev-dec}{}{\correspondence{\Dec{\metavariable{C}}{\metavariable{x}}{\ConstrCall{\metavariable{C}}{\metavariable{x}_1, \ldots, \metavariable{x}_n}}}{\rho}{\mu}}{\mu(\rho^{-1}(\metavariable{x}))=\ConstrCall{\metavariable{C}}{\rho^{-1}(\metavariable{x}_1), \ldots, \rho^{-1}(\metavariable{x}_n)}} \end{array} \end{math}} \caption{Matching relation between terms}\label{fig:correspondence} \end{figure} The matching relation can be extended, {in the obvious way,} to evaluation contexts of the syntactic calculus and pairs evaluation context and memory of the conventional calculus, i.e., $\correspondence{{\cal{E}}}{\rho}{\ExpMem{\widehat{{\cal{E}}}}{\mu}}$. The formal definition is given in \refToFigure{ctx-correspondence}. \begin{figure}[h] {\small \begin{math} \begin{array}{l} \NamedRule{C-empty}{}{\correspondence{[\ ]}{\rho}{\ExpMem{[\ ]}{\mu}}}{}\hskip 1.5em \NamedRule{C-field-access}{\correspondence{{{\cal{E}}}}{\rho}{\ExpMem{\widehat{{\cal{E}}}}{\mu}}}{\correspondence{\FieldAccess{{\cal{E}}}{\metavariable{f}}}{\rho}{\ExpMem{\FieldAccess{\widehat{{\cal{E}}}}{\metavariable{f}}}{\mu}}}{}\\[4ex] \NamedRule{C-field-assign-l}{\correspondence{{{\cal{E}}}}{\rho}{\ExpMem{\widehat{{\cal{E}}}}{\mu}}\hskip 1.5em{\correspondence{\metavariable{e}}{\rho}{\ExpMem{\hat{\e}}{\mu} }}}{\correspondence{\FieldAssign{{\cal{E}}}{\metavariable{f}}{\metavariable{e}}}{\rho}{\ExpMem{\FieldAssign{\widehat{{\cal{E}}}}{\metavariable{f}}{\hat{\e}}}{\mu}}}{} \hskip 1.5em \NamedRule{C-field-assign-r}{\correspondence{{{\cal{E}}}}{\rho}{\ExpMem{\widehat{{\cal{E}}}}{\mu}}\hskip 1.5em{\correspondence{\metavariable{x}}{\rho}{\ExpMem{\iota}{\mu} }}}{\correspondence{\FieldAssign{\metavariable{x}}{\metavariable{f}}{{\cal{E}}}}{\rho}{\ExpMem{\FieldAssign{\iota}{\metavariable{f}}{\widehat{{\cal{E}}}}}{\mu}}}{}\\[4ex] \NamedRule{C-new}{\correspondence{{{\cal{E}}}}{\rho}{\ExpMem{\widehat{{\cal{E}}}}{\mu}}\hskip 1.5em\correspondence{\metavariable{es}}{\rho}{\ExpMem{\widehat{\metavariable{es}}}{\mu}}\hskip 1.5em\correspondence{\metavariable{xs}}{\rho}{\ExpMem{\iota_1,\dots,\iota_n}{\mu}}} {\correspondence{\ConstrCall{\metavariable{C}}{\metavariable{xs}, {\cal{E}},\metavariable{es}}}{\rho}{\ExpMem{\ConstrCall{\metavariable{C}}{\iota_1,\dots,\iota_n, \widehat{{\cal{E}}}, \widehat{\metavariable{es}}}}{\mu}}}{}\\[4ex] \NamedRule{C-invk-rcv}{\correspondence{{{\cal{E}}}}{\rho}{\ExpMem{\widehat{{\cal{E}}}}{\mu}}\hskip 1.5em\correspondence{\metavariable{es}}{\rho}{\ExpMem{\widehat{\metavariable{es}}}{\mu}}}{\correspondence{\MethCall{{\cal{E}}}{\metavariable{m}}{\metavariable{es}}}{\rho}{\ExpMem{\MethCall{\widehat{{\cal{E}}}}{\metavariable{m}}{\widehat{\metavariable{es}}}}{\mu}}}{} \hskip 1.5em \NamedRule{C-invk-arg} {\correspondence{{{\cal{E}}}}{\rho}{\ExpMem{\widehat{{\cal{E}}}}{\mu}}\hskip 1.5em\correspondence{\metavariable{es}}{\rho}{\ExpMem{\widehat{\metavariable{es}}}{\mu}}\hskip 1.5em\correspondence{\metavariable{vs}}{\rho}{\ExpMem{\iota_1,\dots,\iota_n}{\mu}}} {\correspondence{\MethCall{\metavariable{x}}{\metavariable{m}}{\metavariable{vs}, {\cal{E}}, \metavariable{es}}}{\rho}{\ExpMem{\MethCall{\iota}{\metavariable{m}}{\iota_1,\dots,\iota_n, \widehat{{\cal{E}}}, \widehat{\metavariable{es}}}}{\mu}}}{} \\[4ex] \NamedRule{C-blk-dec}{\correspondence{\metavariable{dvs}}{\rho}{\mu}\hskip 1.5em\correspondence{{{\cal{E}}}}{\rho}{\ExpMem{\widehat{{\cal{E}}}}{\mu}}\hskip 1.5em\correspondence{\metavariable{ds}}{\rho}{\ExpMem{\widehat{\decs}}{\mu}}\hskip 1.5em\correspondence{\metavariable{e}}{\rho}{\ExpMem{\hat{\e}}{\mu}}}{\correspondence{\BlockLab{\metavariable{dvs}\ \Dec{\metavariable{C}}{\metavariable{y}}{{\cal{E}}}\ \metavariable{ds}}{\metavariable{e}}{\X}}{\rho}{\ExpMem{\Block{\Dec{\metavariable{C}}{\metavariable{y}}{\widehat{{\cal{E}}}}\ \widehat{\decs}}{\hat{\e}}}{\mu}}}{ \hskip 1.5em \NamedRule{C-blk-body}{\correspondence{\metavariable{dvs}}{\rho}{\mu}\hskip 1.5em\correspondence{{{\cal{E}}}}{\rho}{\ExpMem{\widehat{{\cal{E}}}}{\mu}}}{\correspondence{\BlockLab{\metavariable{dvs}}{{\cal{E}}}{\X}}{\rho}{\ExpMem{\widehat{{\cal{E}}}}{\mu}}}{} \end{array} \end{math}} \caption{Matching relation between evaluation contexts}\label{fig:ctx-correspondence} \end{figure} It is easy to show the following lemma. \begin{lemma}\label{lemma:evCtx} $\correspondence{\Ctx{\metavariable{e}}}{\rho}{\ExpMem{\hat{\e}'}{\mu}}$ if and only if $\hat{\e}'=\CtxHat{\hat{\e}}$ such that $\correspondence{{\cal{E}}}{\rho}{\ExpMem{\widehat{{\cal{E}}}}{\mu}}$ and $\correspondence{{\metavariable{e}}}{\rho}{\ExpMem{\hat{\e}}{\mu}}$. \end{lemma} {Note that, when $\Ctx{\metavariable{e}}$ is closed, all the free variables in $\metavariable{e}$ are declared in ${\cal{E}}$ and their declaration is evaluated. Therefore, the previous lemma implies that} they are in the image of $\rho$, and so in $\hat{\e}$ they match object identifiers. The following lemma asserts the conditions on which a value in the syntactic calculus {is matched by a pairs of value and memory} in the conventional one. \begin{lemma}\label{lemma:value} Let $\metavariable{v}$ be such that $\correspondence{\metavariable{v}}{\rho}{\ExpMem{\hat{\e}}{\mu}}$ for some $\hat{\e}$, $\rho$ and $\mu$. Then: \begin{enumerate} \item if $\metavariable{v}=\metavariable{x}$, then {either $\hat{\e}=\iota$ for some $\iota$ and $\rho(\iota)=\metavariable{x}$, or $\hat{\e}=\metavariable{x}$} \item if $\metavariable{v}=\BlockLab{\metavariable{dvs}}{\metavariable{x}}{\X}$, then $\hat{\e}=\iota$ {and $\rho(\iota)=\metavariable{x}$}. \end{enumerate} \end{lemma} \begin{proof} \begin{enumerate} \item {The judgment $\correspondence{\metavariable{x}}{\rho}{\ExpMem{\hat{\e}}{\mu}}$ has been necessarily derived by rule either \rn{oid} or \rn{var}} in \refToFigure{correspondence}. \item First observe that $\metavariable{dvs}$ cannot be empty and that $\Dec{\metavariable{C}}{\metavariable{x}}{\ConstrCall{\metavariable{C}}{\metavariable{xs}}}$ must be in $\metavariable{dvs}$. {The judgment} $\correspondence{\BlockLab{\metavariable{dvs}}{\metavariable{x}}{\X}}{\rho}{\ExpMem{\hat{\e}}{\mu}}$ {has been necessarily derived by} rule \rn{Block} in \refToFigure{correspondence}. Therefore {$\correspondence{\metavariable{dvs}}{\rho}{\mu}$, and, since for each declaration in $\metavariable{dvs}$ we have applied rule $\rn{Ev-Dec}$,} all the variables in $\metavariable{dvs}$ must be in the image of $\rho$ and $\hat{\e}=\iota$ such that $\rho(\iota)=\metavariable{x}$. \end{enumerate} \end{proof} {From the previous lemma we have that, if all the free variables of $\metavariable{v}$ are in the image of $\rho$, then $\metavariable{v}$ can only match an object identifier.} A step in the reduction of a {closed} expression $\metavariable{e}$ in the syntactic calculus can be simulated by a possibly empty sequence of reduction steps of the matching configuration $\ExpMem{\hat{\e}}{\mu}$ in the conventional calculus. \begin{theorem}\label{theo:step} {If $\FV{\metavariable{e}}=\emptyset$, $\correspondence{\metavariable{e}}{\rho}{\ExpMem{\hat{\e}}{\mu}}$,} and $\reduce{\metavariable{e}}{\metavariable{e}'}$, then $\creducestar{\ExpMem{\hat{\e}}{\mu}}{\ExpMem{\hat{\e}'}{\mu'}}$ such that $\correspondence{\metavariable{e}'}{\rho'}{\ExpMem{\hat{\e}'}{\mu'}}$, for some $\hat{\e}'$, $\rho'$, $\mu'$ such that $\rho\subseteq\rho'$, $\dom{\mu}\subseteq\dom{\mu'}$. \end{theorem} \begin{proof} If $\reduce{\metavariable{e}}{\metavariable{e}'}$, then either rule \rn{Ctx} or rule \rn{new} of \refToFigure{pure-red} were applied.\\ Consider first \underline{rule \rn{Ctx}}. Then $\metavariable{e}=\Ctx{\metavariable{e}_1}$, $\metavariable{e}'=\Ctx{\metavariable{e}'_1}$ and $\reduceOS{\metavariable{e}_1}{\metavariable{e}_1'}$. From $\correspondence{\metavariable{e}}{\rho}{\ExpMem{\hat{\e}}{\mu}}$ and \refToLemma{evCtx} we have that $\hat{\e}=\CtxHat{\hat{\e}_1}$ where $\correspondence{{\cal{E}}}{\rho}{\ExpMem{\widehat{{\cal{E}}}}{\mu}}$ and $\correspondence{{\metavariable{e}_1}}{\rho}{\ExpMem{\hat{\e}_1}{\mu}}$.\\ By cases on the reduction rule of \refToFigure{pure-red} applied to reduce ${\metavariable{e}_1}$ to ${\metavariable{e}_1'}$. We consider \rn{Field-Assign}, \rn{Affine-elim}, \rn{Move-Dec} and \rn{Move-subterm}. The proof for the other rules is similar.\\ Rule $\rn{Field-Assign}$. Then \begin{enumerate}[(i)] \item $\metavariable{e}_1=\BlockCtx{\FieldAssign{\metavariable{x}}{\metavariable{f}_i}{\metavariable{y}}}$, \item $\metavariable{e}'_1={\UpdateCtx{\metavariable{y}}{\metavariable{x}}{i}{\metavariable{y}}}$, \item $\extractDec{\ctx_b}{\metavariable{x}}=\ConstrCall{\metavariable{C}}{\metavariable{x}_1,\dots,\metavariable{x}_n}$, and \item $\fields{\metavariable{C}}=\Field{\metavariable{C}_1}{\metavariable{f}_1}\dots\Field{\metavariable{C}_n}{\metavariable{f}_n}{\ \wedge\ 1\leq i\leq n}$. \end{enumerate} From $\correspondence{{\metavariable{e}_1}}{\rho}{\ExpMem{\hat{\e}_1}{\mu}}$ and \refToLemma{evCtx} we have that $\hat{\e}_1=\BlockCtxHat{\hat{\e}_2}$ with $\correspondence{\ctx_b}{\rho}{\ExpMem{\widehat{\ctx_b}}{\mu}}$ and $\correspondence{\FieldAssign{\metavariable{x}}{\metavariable{f}_i}{\metavariable{y}}}{\rho}{\ExpMem{\hat{\e}_2}{\mu}}$ for some $\hat{\e}_2$. Since $\metavariable{e}$ is a closed term we get that $\metavariable{x}$ and $\metavariable{y}$ are defined in the evaluated declarations of $\Ctx{\ctx_b}$. Therefore $\hat{\e}_2$ is $\FieldAssign{\iota}{\metavariable{f}_i}{\iota'}$ for some $\iota$ and $\iota'$ such that $\rho(\iota)=\metavariable{x}$ and $\rho(\iota')=\metavariable{y}$. Moreover, from rules \rn{block} and \rn{ev-dec} and (iii){, it} must be $\mu(\iota)=\ConstrCall{\metavariable{C}}{\iota_1,\dots,\iota_n}$ for some $\iota_i$ such that $\rho(\iota_i)=\metavariable{x}_i$ for $i\in 1,\dots,n$. From (iv) {and} rule \rn{ctx} with premise \rn{invk} of \refToFigure{conventional} we get $\creduce{\ExpMem{\BlockCtxHat{\FieldAssign{\iota}{\metavariable{f}_i}{\iota'}}}{\mu}}{\ExpMem{\BlockCtxHat{\iota'}}{{\UpdateMem{\mu}{\iota}{i}{\iota'}}}}$. Since we have assumed no shadowing of variables, in ${\cal{E}}$ there is no declaration of $\metavariable{x}$ and so \begin{enumerate}[(a)] \item $\correspondence{{\cal{E}}}{\rho}{\ExpMem{\widehat{{\cal{E}}}}{\UpdateMem{\mu}{\iota}{i}{\iota'}}}$. \end{enumerate} From $\correspondence{\ctx_b}{\rho}{\ExpMem{\widehat{\ctx_b}}{\mu}}$, $\rho(\iota)=\metavariable{x}$, $\rho(\iota')=\metavariable{y}$ and $\mu(\iota)=\ConstrCall{\metavariable{C}}{\iota_1,\dots,\iota_n}$ we get \begin{enumerate}[(a)]\addtocounter{enumi}{1} \item $\correspondence{\updateCtx{\metavariable{y}}{\metavariable{x}}{i}}{\rho}{\ExpMem{\widehat{\ctx_b}}{\UpdateMem{\mu}{\iota}{i}{\iota'}}}$. \end{enumerate} Finally from (a), (b), $\rho(\iota')=\metavariable{y}$ and \refToLemma{evCtx} we derive that $\correspondence{\Ctx{{\UpdateCtx{\metavariable{y}}{\metavariable{x}}{i}{\metavariable{y}}}}}{\rho}{\ExpMem{\CtxHat{\BlockCtxHat{\iota'}}}{{\UpdateMem{\mu}{\iota}{i}{\iota'}}}}$. \\ Rule $\rn{Affine-Elim}$. Then \begin{enumerate}[(i)] \item $\metavariable{e}_1=\BlockLab{\metavariable{dvs}\ \Dec{\Type{\terminale{a}}{\metavariable{C}}}{\metavariable{x}}{\metavariable{v}}\ \metavariable{ds} }{\metavariable{e}_b}{X}$, \item $\metavariable{e}'_1={\BlockLab{\metavariable{dvs}\ \Subst{\metavariable{ds}}{\metavariable{v}}{\metavariable{x}}}{\Subst{\metavariable{e}_b}{\metavariable{v}}{\metavariable{x}}}{\X\setminus\{\metavariable{x}\}}}$ and \item $\IsCapsule{\metavariable{v}}$. \end{enumerate} From (iii) $\metavariable{v}$ is closed and so $\metavariable{v}=\BlockLab{\metavariable{dvs}'}{\metavariable{y}}{{\Y}}$ for some ${\Y}$, $\metavariable{dvs}'$, and $\metavariable{y}$. From $\correspondence{{\metavariable{e}_1}}{\rho}{\ExpMem{\hat{\e}_1}{\mu}}$, (i), rule \rn{block} of \refToFigure{correspondence}, \refToLemma{value}.2 we have that \begin{enumerate}[(a)] \item $\hat{\e}_1=\Block{\Dec{\Type{}{\metavariable{C}}}{\metavariable{x}}{\iota}\ \widehat{\decs} }{\hat{\e}_b}$, $\correspondence{\metavariable{dvs}\,\metavariable{dvs}'}{\rho}{\mu}$, $\correspondence{\metavariable{ds}}{\rho}{\ExpMem{\widehat{\decs}}{\mu}}$, $\correspondence{\metavariable{e}_b}{\rho}{\ExpMem{\hat{\e}_b}{\mu}}$, \item $\rho(\iota)=\metavariable{y}$ and $\correspondence{\metavariable{v}}{\rho}{\ExpMem{\iota}{\mu}}$. \end{enumerate} Applying reduction rule \rn{Dec} of \refToFigure{conventional} we get $\creduce{\ExpMem{\Block{\Dec{\Type{}{\metavariable{C}}}{\metavariable{x}}{\iota}\ \widehat{\decs} }{\hat{\e}_b}}{\mu}}{\ExpMem{\Subst{\Block{\widehat{\decs}}{\hat{\e}_b}}{\iota}{\metavariable{x}}}{\mu}}$. Since $\Dec{\Type{\terminale{a}}{\metavariable{C}}}{\metavariable{x}}{\metavariable{v}}$ is not an evaluated declaration $\metavariable{x}\not\in\img{\rho}$. Therefore the occurrence of $\metavariable{x}$ in $\metavariable{e}_1$ is in the matching relation with an occurrence of $\metavariable{x}$ in $\hat{\e}_1$ and there is only one such occurrence. Therefore from (a) and (b) we have \begin{enumerate}[(a)]\addtocounter{enumi}{2} \item $\correspondence{{\BlockLab{\metavariable{dvs}\ \Subst{\metavariable{ds}}{\metavariable{v}}{\metavariable{x}}}{\Subst{\metavariable{e}_b}{\metavariable{v}}{\metavariable{x}}}{\X\setminus\{\metavariable{x}\}}}}{\rho}{\ExpMem{\Subst{\Block{\widehat{\decs}}{\hat{\e}_b}}{\iota}{\metavariable{x}}}{\mu}}$. \end{enumerate} From $\correspondence{{\cal{E}}}{\rho}{\ExpMem{\widehat{{\cal{E}}}}{\mu}}$, (i), (a), (c) and \refToLemma{evCtx} we derive that $\correspondence{\Ctx{\metavariable{e}_1}}{\rho}{\ExpMem{\Ctx{\hat{\e}_1}}{\mu}}$. \\ Rule $\rn{Move-Dec}$. Then \begin{enumerate}[(i)] \item $\metavariable{e}_1={\BlockLab{{\metavariable{dvs}}\ \Dec{{\Type{\metavariable{q}}{\metavariable{C}}}}{\metavariable{x}}{\BlockLab{{\metavariable{dvs}'}\ {\metavariable{ds}}}{\metavariable{e}_b}{\X}}\ \metavariable{ds}'}{\metavariable{e}'}{{\Y}}}$ and \item $\metavariable{e}'_1={\BlockLab{{\metavariable{dvs}}\ {\metavariable{dvs}'}\ \Dec{{\Type{\metavariable{q}}{\metavariable{C}}}}{\metavariable{x}}{\BlockLab{{\metavariable{ds}}}{\metavariable{e}_b}{\X}}\ \metavariable{ds}'}{\metavariable{e}'}{{\Y}}}$ \end{enumerate} We consider two cases: \begin{enumerate} \item either $\congruence{{\BlockLab{\metavariable{ds}}{\metavariable{e}_b}{\X}}}{\ConstrCall{\metavariable{C}}{\metavariable{x}_1,\dots,\metavariable{x}_n}}$ for some $x_1,\dots,\metavariable{x}_n$ \item {or this is not the case.} \end{enumerate} Case 1. Then \begin{enumerate}[(i)]\addtocounter{enumi}{2} \item $\metavariable{e}_1={\BlockLab{{\metavariable{dvs}}\ \Dec{{\Type{\metavariable{q}}{\metavariable{C}}}}{\metavariable{x}}{\BlockLab{{\metavariable{dvs}'}}{\ConstrCall{\metavariable{C}}{\metavariable{x}_1,\dots,\metavariable{x}_n}}{\X}}\ \metavariable{ds}'}{\metavariable{e}'}{{\Y}}}$ and \item $\metavariable{e}'_1={\BlockLab{{\metavariable{dvs}}\ {\metavariable{dvs}'}\ \Dec{{\Type{\metavariable{q}}{\metavariable{C}}}}{\metavariable{x}}{\ConstrCall{\metavariable{C}}{{\metavariable{x}_1,\dots,\metavariable{x}_n}}}\ \metavariable{ds}'}{\metavariable{e}'}{{\Y}}}$. \end{enumerate} From $\correspondence{\metavariable{e}_1}{\rho}{\ExpMem{\hat{\e}_1}{\mu}}$, \refToLemma{evCtx} and rules \rn{new} and \rn{block} of \refToFigure{correspondence} we have that \begin{enumerate}[(a)] \item $\hat{\e}_1={\Block{\Dec{{\Type{}{\metavariable{C}}}}{\metavariable{x}}{{\ConstrCall{\metavariable{C}}{\iota_1,\dots,\iota_n}}}\ \widehat{\decs}'}{\hat{\e}'}}$, \item $\correspondence{\metavariable{dvs}\ \metavariable{dvs}'}{\rho}{\mu}$, $\correspondence{\metavariable{ds}'}{\rho}{\ExpMem{\widehat{\decs}'}{\mu}}$, $\correspondence{\metavariable{e}'}{\rho}{\ExpMem{\hat{\e}'}{\mu}}$ and \item {$\rho(\iota_i)=\metavariable{x}_i$} for $i\in 1,\dots,n$. \end{enumerate} Applying reduction rule \rn{new} of \refToFigure{conventional} we have that $\creduce{\ExpMem{\ConstrCall{\metavariable{C}}{\iota_1,\dots,\iota_n}}{\mu}}{\ExpMem{\iota}{\mu'}$ where $\iota\not\in\dom{\mu}$ and $\mu'=\Subst{\mu}{\ConstrCall{\metavariable{C}}{\iota_1,\dots,\iota_n}}{\iota}}$. Then, applying rule \rn{block} {of \refToFigure{conventional}} we get $\creduce{\ExpMem{\Block{\Dec{\metavariable{C}}{\metavariable{x}}{\iota}\ \widehat{\decs}'}{\hat{\e}'}}{\mu'}}{\ExpMem{\Block{\Subst{\widehat{\decs}'}{\iota}{\metavariable{x}}}{\Subst{\hat{\e}'}{\iota}{\metavariable{x}}}}{\mu'}}$. Let $\rho'=\Subst{\rho}{\metavariable{x}}{\iota}$, from (iv), (b), (c) and rule \rn{block} of \refToFigure{correspondence} we get that $\correspondence{\metavariable{e}'_1}{\rho'}{\ExpMem{\Block{\Subst{\widehat{\decs}'}{\iota}{\metavariable{x}}}{\Subst{\hat{\e}'}{\iota}{\metavariable{x}}}}{\mu'}}$, and so by \refToLemma{evCtx} we derive $\correspondence{\Ctx{\metavariable{e}'_1}}{\rho'}{\ExpMem{\CtxHat{\Block{\Subst{\widehat{\decs}'}{\iota}{\metavariable{x}}}{\Subst{\hat{\e}'}{\iota}{\metavariable{x}}}}}{\mu'}}$ where $\rho\subseteq\rho'$ and $\dom{\mu}\subseteq\dom{\mu'}$.\\ Case 2. In this case from $\correspondence{\metavariable{e}_1}{\rho}{\ExpMem{\hat{\e}_1}{\mu}}$, \refToLemma{evCtx} and rule \rn{block} of \refToFigure{correspondence} we get \begin{enumerate}[(a)]\addtocounter{enumi}{3} \item $\hat{\e}_1={\Block{\Dec{{\Type{}{\metavariable{C}}}}{\metavariable{x}}{\widehat{\Block{\metavariable{ds}}{\metavariable{e}_b}}}\ \widehat{\decs}'}{\hat{\e}'}}$ where \item $\correspondence{\metavariable{dvs}\ \metavariable{dvs}'}{\rho}{\mu}$, $\correspondence{\metavariable{ds}'}{\rho}{\ExpMem{\widehat{\decs}'}{\mu}}$, $\correspondence{\metavariable{e}'}{\rho}{\ExpMem{\hat{\e}'}{\mu}}$, and $\correspondence{{\Block{\metavariable{ds}}{\metavariable{e}_b}}}{\rho}{\ExpMem{\widehat{\Block{\metavariable{ds}}{\metavariable{e}_b}}}}{\mu}$ \end{enumerate} From (ii), (d), (e) and rule \rn{block} of \refToFigure{correspondence} we derive that $\correspondence{\metavariable{e}'_1}{\rho}{\ExpMem{\hat{\e}'_1}{\mu}}$ and by \refToLemma{evCtx} we have $\correspondence{\Ctx{\metavariable{e}'_1}}{\rho}{\ExpMem{\CtxHat{\hat{\e}'_1}}{\mu}}$. Since $\ExpMem{\CtxHat{\hat{\e}'_1}}{\mu}$ reduces in 0 steps to itself we get the result.\\ Rule $\rn{Move-Subterm}$. We consider the value context $\ConstrCall{\metavariable{C}}{{\metavariable{x}_1,\ldots,\metavariable{x}_n},[\ ],{\metavariable{es}}}$. The other contexts are similar and easier. Then \begin{enumerate}[(i)] \item $\metavariable{e}_1=\ConstrCall{\metavariable{C}}{{\metavariable{x}_1,\ldots,\metavariable{x}_n},\BlockLab{{\metavariable{dvs}}\ {\metavariable{dvs}'}}{{\metavariable{x}}}{\X},{\metavariable{es}}}$ and \item $\metavariable{e}'_1={\BlockLab{\metavariable{dvs}}{\ \ConstrCall{\metavariable{C}}{{\metavariable{x}_1,\ldots,\metavariable{x}_n},\BlockLab{{\metavariable{dvs}'}}{{\metavariable{x}}}{\X},{\metavariable{es}}}}{\X\cap\dom{\metavariable{dvs}}}}$. \end{enumerate} From $\correspondence{{\metavariable{e}_1}}{\rho}{\ExpMem{\hat{\e}_1}{\mu}}$, (i), rule \rn{new} and rule \rn{block} of \refToFigure{correspondence}, we have that \begin{enumerate}[(a) \item $\hat{\e}_1=\ConstrCall{\metavariable{C}}{\iota_1,\dots,\iota_n,\iota,\widehat{\metavariable{es}}}$, \item $\correspondence{\metavariable{dvs}\ \metavariable{dvs}'}{\rho}{\mu}$, $\correspondence{{\metavariable{x}_1,\ldots,\metavariable{x}_n}}{\rho}{\ExpMem{\iota_1,\dots,\iota_n}{\mu}}$, $\correspondence{\BlockLab{{\metavariable{dvs}}\ {\metavariable{dvs}'}}{{\metavariable{x}}}{\X}}{\rho}{\ExpMem{\iota}{\mu}}$ and $\correspondence{{\metavariable{es}}}{\rho}{\ExpMem{\widehat{\metavariable{es}}}{\mu}}$. \end{enumerate} From (b) we derive that $\correspondence{\BlockLab{{\metavariable{dvs}'}}{{\metavariable{x}}}{\X}}{\rho}{\ExpMem{\iota}{\mu}}$. Therefore \begin{enumerate}[(a)]\addtocounter{enumi}{2} \item $\correspondence{{\BlockLab{\metavariable{dvs}}{\ \ConstrCall{\metavariable{C}}{{\metavariable{x}_1,\ldots,\metavariable{x}_n},\BlockLab{{\metavariable{dvs}'}}{{\metavariable{x}}}{\X},{\metavariable{es}}}}{\X\cap\dom{\metavariable{dvs}}}}}{\rho}{\ExpMem{\ConstrCall{\metavariable{C}}{\iota_1,\dots,\iota_n,\iota,\widehat{\metavariable{es}}}}{\mu}}$. \end{enumerate} From $\correspondence{{\cal{E}}}{\rho}{\ExpMem{\widehat{{\cal{E}}}}{\mu}}$, (i), (a) and \refToLemma{evCtx} we derive that $\correspondence{\Ctx{e_1}}{\rho}{\ExpMem{{\CtxHat{\hat{\e}_1}}} {\mu}}$. Since $\ExpMem{{\CtxHat{\hat{\e}_1}}} {\mu}$ reduces in 0 steps to itself we get the result.\\ Consider now \underline{rule \rn{New}}. Then \begin{enumerate}[(i)] \item $\metavariable{e}= \Ctx{\ConstrCall{\metavariable{C}}{\metavariable{x}_1,\dots,\metavariable{x}_n}} $ and \item $\metavariable{e}'= \Ctx{\BlockLab{\Dec{\metavariable{C}}{\metavariable{x}}{\ConstrCall{\metavariable{C}}{\metavariable{x}_1,\dots,\metavariable{x}_n}}}{\metavariable{x}}{{\{\metavariable{x}\}}}}$. \end{enumerate} From $\correspondence{\metavariable{e}}{\rho}{\ExpMem{\hat{\e}}{\mu}}$, \refToLemma{evCtx} and rule \rn{new} of \refToFigure{correspondence} we have that \begin{enumerate}[(a)] \item $\hat{\e}=\CtxHat{\ConstrCall{\metavariable{C}}{\iota_1,\dots,\iota_n}}$ , \item $\correspondence{{\cal{E}}}{\rho}{\ExpMem{\widehat{{\cal{E}}}}{\mu}}$ and {$\rho(\iota_i)=\metavariable{x}_i$} for $i\in 1,\dots,n$. \end{enumerate} Applying rule \rn{new} of \refToFigure{conventional} we have that $\creduce{\ExpMem{\ConstrCall{\metavariable{C}}{\iota_1,\dots,\iota_n}}{\mu}}{\ExpMem{\iota}{\mu'}}$ where $\mu'=\Subst{\mu}{\ConstrCall{\metavariable{C}}{\iota_1,\dots,\iota_n}}{\iota}$ and $\iota\not\in\dom{\mu}$. Let $\rho'=\Subst{\rho}{\metavariable{x}}{\iota}$, from (ii) and rule \rn{block} of \refToFigure{correspondence} we get that $ \correspondence{\metavariable{e}'}{\rho'}{\ExpMem{\iota}{\mu'}} $ with $\rho\subseteq\rho'$ and $\dom{\mu}\subseteq\dom{\mu'}$, which proves the result. \end{proof} \begin{corollary}\label{preservation} {If $\FV{\metavariable{e}}=\emptyset$,} $\reducestar{\metavariable{e}}{\metavariable{v}}$, and $\correspondence{\metavariable{e}}{\rho}{\ExpMem{\hat{\e}}{\mu}}$, then $\creducestar{\ExpMem{\hat{\e}}{\mu}}{\ExpMem{\iota}{\mu'}}$ with $\correspondence{\metavariable{v}}{\rho'}{\ExpMem{\iota}{\mu'}}$ for some $\rho', \mu'$ such that $\rho\subseteq\rho'$, and $\dom{\mu}\subseteq\dom{\mu'}$. \end{corollary} \begin{proof} By arithmetic induction on the number of steps. \begin{description} \item[Base] If $\reduceN{\metavariable{e}}{\metavariable{v}}{0}$, then $\metavariable{e}=\metavariable{v}$, and $\correspondence{\metavariable{v}}{\rho}{\ExpMem{\hat{\e}}{\mu}}$. Since $\metavariable{e}$ has no free variables, we have that $\metavariable{v}=\BlockLab{\metavariable{dvs}}{\metavariable{x}}{\X}$ for some $\X$, $\metavariable{dvs}$, and $\metavariable{x}$. From \refToLemma{value}.2, $\hat{\e}=\iota$ for some $\iota$ such that $\rho(\iota)=\metavariable{x}$. Therefore $\ExpMem{\iota}{\mu}$ reduces in zero steps to $\ExpMem{\iota}{\mu}$ and the thesis holds. \item[Inductive step] If $\reduceN{\metavariable{e}}{\metavariable{v}}{n+1}$, then $\reduce{\metavariable{e}}{\metavariable{e}'}$ and $\reduceN{\metavariable{e}'}{\metavariable{v}}{n}$. By inductive hypothesis we have that, if $\correspondence{\metavariable{e}'}{\rho'}{\ExpMem{\hat{\e}'}{\mu'}}$, then $\creducestar{\ExpMem{\hat{\e}'}{\mu'}}{\ExpMem{\iota}{\mu''}}$ and $\correspondence{\metavariable{v}}{\rho''}{\ExpMem{\iota}{\mu''}}$, for some $\rho'',\mu''$ such that $\rho'\subseteq\rho''$, $\dom{\mu'}\subseteq\dom{\mu''}$. Then, the thesis follows by \refToTheorem{step}. \end{description} \end{proof} \section{The syntactic calculus}\label{sect:syntactic} The syntax of the expressions, given in \refToFigure{pure-syntax}, is the same as the conventional calculus, except that runtime expressions (object identifiers) are not needed. To lighten the notation, we use the same metavariables. \begin{figure}[h] {\small \begin{grammatica} \produzione{\metavariable{e}}{\metavariable{x}\mid\FieldAccess{\metavariable{e}}{\metavariable{f}}\mid\FieldAssign{\metavariable{e}}{\metavariable{f}}{\metavariable{e}'}\mid\ConstrCall{\metavariable{C}}{\metavariable{es}}\mid\MethCall{\metavariable{e}}{\metavariable{m}}{\metavariable{es}}\mid\BlockLab{\metavariable{ds}}{\metavariable{e}}{\X}}{expression}\\ \produzione{\metavariable{d}}{\Dec{\metavariable{T}}{\metavariable{x}}{\metavariable{e}}}{declaration}\\ \produzione{\metavariable{T}}{\Type{\metavariable{q}}{\metavariable{C}}}{declaration type}\\ \produzione{\metavariable{q}}{\epsilon\mid\terminale{a}}{optional qualifier}\\ \\ \produzione{\metavariable{v}}{\metavariable{x}\mid\BlockLab{\metavariable{dvs}}{\metavariable{x}}{\X}}{value}\\ \produzione{\metavariable{dv}}{\Dec{\metavariable{C}}{\metavariable{x}}{\ConstrCall{\metavariable{C}}{\metavariable{xs}}}}{evaluated declaration}\\ \produzione{{\cal{E}}}{[\ ]\mi \FieldAccess{{\cal{E}}}{\metavariable{f}}\mid\FieldAssign{{\cal{E}}}{\metavariable{f}}{\metavariable{e}'}\mid\FieldAssign{\metavariable{x}}{\metavariable{f}}{{\cal{E}}}\mid \ConstrCall{\metavariable{C}}{{\metavariable{xs}},{\cal{E}},\metavariable{es}}\mid\MethCall{{\cal{E}}}{\metavariable{m}}{\metavariable{es}}\mid \MethCall{{\metavariable{x}}}{\metavariable{m}}{\metavariable{vs},{\cal{E}},\metavariable{es}} \mid\ctx_b{}}{evaluation context}\\ \produzione{\ctx_b}{\BlockLab{\metavariable{dvs}\ \Dec{\metavariable{C}}{\metavariable{y}}{{\cal{E}}}\ \metavariable{ds}}{\metavariable{e}}{\X}\mid \BlockLab{\metavariable{dvs}}{{\cal{E}}}{\X} }{block context}\\ \produzione{\ctx_v}{\FieldAccess{[\ ]}{\metavariable{f}}\mid\FieldAssign{[\ ]}{\metavariable{f}}{\metavariable{e}'}\mid\FieldAssign{\metavariable{x}}{\metavariable{f}}{[\ ]}\mid\ConstrCall{\metavariable{C}}{\metavariable{xs},[\ ],\metavariable{es}}\mid{\MethCall{[\ ]}{\metavariable{m}}{\metavariable{es}}}}{value context} \end{grammatica}} \caption{Syntactic calculus: syntax, values, and evaluation contexts} \label{fig:pure-syntax} \end{figure} Moreover, some annotations are inserted in terms. Namely: \begin{itemize} \item Local variable declarations (and method parameters) are possibly annotated with a qualifier $\terminale{a}$, {which, if present, indicates that} the variable is \emph{affine}. An affine variable can occur at most once in its scope, and should be initialized with a \emph{capsule}, that is, an isolated portion of store. In this way, it can be used as a temporary reference, to ``move'' a capsule to another location in the store, without introducing sharing. \item Blocks are annotated with a set $\X$ of variables, assumed to be a subset of the declared variables. During reduction, if a block $\BlockLab{\metavariable{ds}}{\metavariable{e}}{\X}$ should reduce to a capsule, only declarations of variables which are not in $\X$ can be safely moved outside of the block, see rule \rn{move-dec}. In this paper, since our focus is on the operational model, we do not care about how block annotations are generated. Of course, a trivial overapproximation consists in taking as $\X$ the set of all declared variables; a better approximation is taking only those which are used (that is, have some free occurrence in initialization expressions/body), or, {even better}, {only those which} are transitively used by the body, in the sense formally defined below. We have shown in previous work \cite{GianniniSZ17,GianniniSZ17a,GianniniSZ18} that through a type and effect system it is possible to {obtain a much more precise approximation, computing $\X$ to be the set of the} variables which \emph{will be possibly connected with the final result of the block}. \end{itemize} A sequence $\metavariable{dvs}$ of \emph{evaluated declarations} plays the role of the memory in the conventional calculus, that is, each $\metavariable{dv}$ can be seen as an association of an \emph{object state} $\ConstrCall{\metavariable{C}}{\metavariable{xs}}$ to a reference. A value is a reference to an object, possibly enclosed in a block where all declarations are evaluated (hence, correspond to a local memory).\\ We assume that, in a block value $\BlockLab{\metavariable{dvs}}{\metavariable{x}}{\X}$, $\metavariable{dvs}\neq\epsilon$ and $\Reduct{\metavariable{dvs}}{\metavariable{x}}=\metavariable{dvs}$, where, given a sequence of declarations $\metavariable{ds}\equiv\Dec{\metavariable{T}_1}{\metavariable{x}_1}{\metavariable{e}_1}\dots\Dec{\metavariable{T}_n}{\metavariable{x}_n}{\metavariable{e}_n}$ and an expression $\metavariable{e}$, $\Reduct{\metavariable{ds}}{\metavariable{e}}$ are the declarations of variables (transitively) used by $\metavariable{e}$, that is, free either in $\metavariable{e}$ or in some $\metavariable{e}_i$ such that $\metavariable{x}_i$ is transitively used by $\metavariable{e}$. We write $\FV{\metavariable{ds}}$ and $\FV{\metavariable{e}}$ for the free variables of a sequence of declarations and of an expression, respectively, and $\Subst{\X}{\metavariable{y}}{\metavariable{x}}$, $\Subst{\metavariable{ds}}{\metavariable{y}}{\metavariable{x}}$, and $\Subst{\metavariable{e}}{\metavariable{y}}{\metavariable{x}}$ for the capture-avoiding variable substitution on a set of variables, a sequence of declarations, and an expression, respectively, all defined in the standard way. In the syntactic calculus, capsules can be characterized in a very simple way: indeed, a value is a capsule, written $\IsCapsule{\metavariable{v}}$, if it is a closed block value, that is, of shape $\Block{\metavariable{dvs}}{\metavariable{x}}$ with no free variables. The above requirement that all local variables must be transitively used by $\metavariable{x}$ is needed, indeed, since otherwise a block value containing unused free variables, e.g., $\Block{\Dec{\metavariable{C}}{\metavariable{x}}{\ConstrCall{\metavariable{C}}{}}\ \Dec{\metavariable{D}}{\metavariable{y}}{\ConstrCall{\metavariable{D}}{\metavariable{z}}} }{\metavariable{x}}$ would be not recognized to be a capsule. Unused evaluated declarations are removed by rule \rn{garbage}. Evaluation contexts ${\cal{E}}$ are mostly standard. Note that values are assumed to be references, apart from arguments of method calls, which are allowed to be block values. This models the fact that block values (hence, capsules) are first-class values which can be passed to methods. However, they need to be ``opened'' when we perform an actual operation on them. We distinguish, among evaluation context, \emph{block contexts}, $\ctx_b$, having the shape of a block, which play a special role in the reduction rules. The {\em hole binders} of a context ${\cal{E}}$, dubbed $\HB{{\cal{E}}}$, are the variables bound by the context, defined by: \begin{itemize} \item $\HB{[\ ]}=\emptyset$, $\HB{\FieldAccess{{\cal{E}}}{\metavariable{f}}}=\cdots=\HB{\MethCall{{\metavariable{x}}}{\metavariable{m}}{\metavariable{vs},{\cal{E}},\metavariable{es}}}=\HB{{\cal{E}}}$ \item $\HB{\BlockLab{\metavariable{dvs}\ \Dec{\metavariable{C}}{\metavariable{y}}{{\cal{E}}}\ \metavariable{ds}}{\metavariable{e}}{\X}}=\dom{\metavariable{dvs}\, \metavariable{ds}}\cup\{\metavariable{y}\}\cup\HB{{\cal{E}}}$ and $\HB{\BlockLab{\metavariable{dvs}}{{\cal{E}}}{\X}}=\dom{\metavariable{dvs}}\cup\HB{{\cal{E}}}$. \end{itemize} Moreover, given $\ctx_b=\BlockLab{\metavariable{dvs}\ \Dec{\metavariable{C}}{\metavariable{y}}{{\cal{E}}}\ \metavariable{ds}}{\metavariable{e}}{\X}$ or $\ctx_b=\BlockLab{\metavariable{dvs}}{{\cal{E}}}{\X}$, we define \begin{itemize} \item $\extractDec{\ctx_b}{\metavariable{x}}=\metavariable{dvs}(\metavariable{x})$, i.e., the object state associated to $\metavariable{x}$ in $\metavariable{dvs}$, if $\metavariable{x}\in\dom{\metavariable{dvs}}$, and \item $\Inner{\ctx_b}=\HB{{\cal{E}}}$, i.e., the set of variables declared in the direct subcontext ${\cal{E}}$ of $\ctx_b$. \end{itemize} A \emph{value context} $\ctx_v$ is an evaluation context with the shape of either a field access, or a field assignment, or a constructor invocation, or a method invocation, where the hole (expected to be filled with a block value) is a direct subterm (the receiver in the last case). Expressions are identified modulo congruence, denoted by $\cong$, defined as the smallest congruence satisfying the axioms in \refToFigure{pure-cong}. {Rules \rn{alpha} and \rn{block-elim} are as in the conventional calculus.} Rule \rn{reorder} states that we can move evaluated declarations in an arbitrary order. Note that, instead, $\metavariable{ds}$ and $\metavariable{ds}'$ cannot be swapped, because this could change the order of side effects. \begin{figure}[h] {\small \begin{math} \begin{array}{l} {\NamedRuleOL{alpha}{{\congruence{\BlockLab{\metavariable{ds}\ \Dec{\metavariable{C}}{\metavariable{x}}{\metavariable{e}}\ \metavariable{ds}'}{\metavariable{e}'}{\X}}{\BlockLab{\Subst{\metavariable{ds}}{\metavariable{y}}{\metavariable{x}}\ \Dec{\metavariable{C}}{\metavariable{y}}{\Subst{\metavariable{e}}{\metavariable{y}}{\metavariable{x}}}\ \Subst{\metavariable{ds}'}{\metavariable{y}}{\metavariable{x}}}{\Subst{\metavariable{e}'}{\metavariable{y}}{\metavariable{x}}}{{\Subst{\X}{\metavariable{y}}{\metavariable{x}}}}}}}{}} \hskip 1.5em{\NamedRuleOL{block-elim}{\congruence{\BlockLab{}{\metavariable{e}}{\emptyset}}{\metavariable{e}}}{}}\\[3ex] \NamedRuleOL{reorder}{\congruence{ \BlockLab{ \metavariable{ds}\ \metavariable{dv}\ \metavariable{ds}'}{\metavariable{e}}{\X}}{ \BlockLab{ \metavariable{dv}\ \metavariable{ds}\ \metavariable{ds}' }{\metavariable{e}}{\X}}}{} \end{array} \end{math}} \caption{Syntactic calculus: congruence rules}\label{fig:pure-cong} \end{figure} Reduction rules are given in \refToFigure{pure-red}. {We explicitly distinguish the relation $\reduceOS{}{}$ defined by \emph{computational rules} only, and reduction $\reduce{}{}$, defined as its contextual closure. In other words, in rule \rn{ctx} we assume that ${\cal{E}}$ is a maximal context. This simplifies proofs in \refToSection{preservation}. More importantly, in this way we can prevent reduction of a constructor call in a declaration context, see comments to rule \rn{new} below.} \begin{figure}[h] {\small \begin{math} \begin{array}{l} \NamedRule{ctx}{\reduceOS{\metavariable{e}}{\metavariable{e}'}}{\reduce{\Ctx{\metavariable{e}}}{\Ctx{\metavariable{e}'}}}{}\hskip 1.5em {\NamedRuleOL{new} { \reduce{ \Ctx{\ConstrCall{\metavariable{C}}{\metavariable{xs}}} } { \Ctx{\BlockLab{\Dec{\metavariable{C}}{\metavariable{x}}{\ConstrCall{\metavariable{C}}{\metavariable{xs}}}}{\metavariable{x}}{{\{\metavariable{x}\}}}} } } {{\cal{E}}\ {\neq\ \CtxP{\BlockLab{\metavariable{dvs}\ \Dec{\metavariable{C}}{\metavariable{y}}{[\ ]}\ \metavariable{ds}}{\metavariable{e}}{\X}}}}} \\[4ex] \NamedRuleOL{field-access}{\reduceOS{\BlockCtx{\FieldAccess{\metavariable{x}}{\metavariable{f}_i}}}{\BlockCtx{\metavariable{x}_i}}}{ {\extractDec{\ctx_b}{\metavariable{x}}=\ConstrCall{\metavariable{C}}{\metavariable{x}_1,\dots,\metavariable{x}_n} \wedge\ {\metavariable{x}\not\in\Inner{\ctx_b}}}\\ \fields{\metavariable{C}}=\Field{\metavariable{C}_1}{\metavariable{f}_1}\dots\Field{\metavariable{C}_n}{\metavariable{f}_n}{\ \wedge\ 1\leq i\leq n}\\ \metavariable{x}_i\not\in\Inner{\ctx_b}} \\[4ex] {\NamedRuleOL{field-assign}{ \reduceOS{\BlockCtx{\FieldAssign{\metavariable{x}}{\metavariable{f}_i}{\metavariable{y}}}}{{\UpdateCtx{\metavariable{y}}{\metavariable{x}}{i}{\metavariable{y}}}} }{ {\extractDec{\ctx_b}{\metavariable{x}}=\ConstrCall{\metavariable{C}}{{\metavariable{xs}}}\wedge\ {\metavariable{x}\not\in\Inner{\ctx_b}}}\\ \fields{\metavariable{C}}=\Field{\metavariable{C}_1}{\metavariable{f}_1}\dots\Field{\metavariable{C}_n}{\metavariable{f}_n}{\ \wedge\ 1\leq i\leq n}\\ \metavariable{y}\not\in\Inner{\ctx_b}}} \\[4ex] \NamedRuleOL{invk}{\reduceOS{\BlockCtx{\MethCall{{\metavariable{x}}}{\metavariable{m}}{\metavariable{v}_1,\ldots,\metavariable{v}_n}}}{\BlockCtx{\Block{\Dec{\metavariable{C}}{\terminale{this}}{{\metavariable{x}}}\, \Dec{\Type{\metavariable{q}_1}{\metavariable{C}_1}}{\metavariable{x}_1}{\metavariable{v}_1}, \ldots,\Dec{\Type{\metavariable{q}_n}{\metavariable{C}_n}}{\metavariable{x}_n}{\metavariable{v}_n}}{\metavariable{e}}}}}{ \!\!\!\!\!\extractDec{\ctx_b}{\metavariable{x}}{=}\ConstrCall{\metavariable{C}}{\metavariable{xs}}\\ \!\!\!\!\! \metavariable{x}\not\in\Inner{\ctx_b}\\ \!\!\!\!\!\method{\metavariable{C}}{\metavariable{m}}{=}{\Pair{\Param{\Type{\metavariable{q}_1}{\metavariable{C}_1}}{\metavariable{x}_1},\ldots,\Param{\Type{\metavariable{q}_n}{\metavariable{C}_n}}{\metavariable{x}_n}}{\metavariable{e}}}} \\[4ex] {\NamedRuleOL{alias-elim}{\reduceOS{\BlockLab{\metavariable{dvs}\ \Dec{\metavariable{C}}{\metavariable{x}}{\metavariable{y}}\ \metavariable{ds} }{\metavariable{e}}{\X}}{\BlockLab{\metavariable{dvs}\ \Subst{\metavariable{ds}}{\metavariable{y}}{\metavariable{x}}}{\Subst{\metavariable{e}}{\metavariable{y}}{\metavariable{x}}}{\X\setminus\{\metavariable{x}\}}}}{}} \\[4ex] {\NamedRuleOL{affine-elim}{\reduceOS{\BlockLab{\metavariable{dvs}\ \Dec{\Type{\terminale{a}}{\metavariable{C}}}{\metavariable{x}}{\metavariable{v}}\ \metavariable{ds} }{\metavariable{e}}{X}}{{\BlockLab{\metavariable{dvs}\ \Subst{\metavariable{ds}}{\metavariable{v}}{\metavariable{x}}}{\Subst{\metavariable{e}}{\metavariable{v}}{\metavariable{x}}}{\X\setminus\{\metavariable{x}\}}}}}{\IsCapsule{\metavariable{v}}}} \\[4ex] \NamedRuleOL{garbage} { \reduceOS{ \BlockLab{\metavariable{dvs}\ \metavariable{ds}}{\metavariable{e}}{\X}}{\BlockLab{\metavariable{ds}}{\metavariable{e}}{{\X}\setminus{\dom{\metavariable{dvs}}}}}} { \begin{array}{l} (\FV{\metavariable{ds}}\cup\FV{\metavariable{e}})\cap\dom{\metavariable{dvs}}=\emptyset \end{array}} \\[4ex] \NamedRuleOL{move-dec} {\reduceOS{\BlockLab{{\metavariable{dvs}}\ \Dec{{\Type{\metavariable{q}}{\metavariable{C}}}}{\metavariable{x}}{\BlockLab{{\metavariable{dvs}'}\ {\metavariable{ds}}}{\metavariable{e}}{\X}}\ \metavariable{ds}'}{\metavariable{e}'}{{\Y}}} {\BlockLab{{\metavariable{dvs}}\ {\metavariable{dvs}'}\ \Dec{{\Type{\metavariable{q}}{\metavariable{C}}}}{\metavariable{x}}{\BlockLab{{\metavariable{ds}}}{\metavariable{e}}{\X}}\ \metavariable{ds}'}{\metavariable{e}'}{{\Y}}}} {\FV{{\metavariable{dvs}'}}\cap\dom{{\metavariable{ds}}}=\emptyset\\ \FV{{\metavariable{dvs}}\ \metavariable{ds}'\ {\metavariable{e}'}}{\cap}\dom{{\metavariable{dvs}'}}{=}\emptyset\\ {\metavariable{q}=\terminale{a}\Rightarrow\dom{\metavariable{dvs}'}{\cap}\X{=}\emptyset}} \\[4ex] \NamedRuleOL{move-body} {\reduceOS{\BlockLab{{\metavariable{dvs}}}{\BlockLab{{\metavariable{dvs}'}\ {\metavariable{ds}}}{\metavariable{e}}{\X}}{\Y}}{\BlockLab{\metavariable{dvs}\ \metavariable{dvs}'}{\BlockLab{\metavariable{ds}_2}{\metavariable{e}}{\X}}{{\Y}}}} {\FV{{\metavariable{dvs}'}}\cap\dom{{\metavariable{ds}}}=\emptyset\\ \FV{{\metavariable{dvs}}}\cap\dom{{\metavariable{dvs}'}}=\emptyset} \\[4ex] \NamedRuleOL{move-subterm}{\reduceOS {\ValCtx{\BlockLab{{\metavariable{dvs}}\ {\metavariable{dvs}'}}{{\metavariable{x}}}{\X}}} {\BlockLab{{\metavariable{dvs}}}{\ValCtx{\BlockLab{ {\metavariable{dvs}'}}{{\metavariable{x}}}{\X\setminus{\dom{{\metavariable{dvs}}}}}}}{\X\cap\dom{{\metavariable{dvs}}}}}} {\FV{{\metavariable{dvs}}}\cap\dom{ {\metavariable{dvs}'}}=\emptyset\\ \FV{\ctx_v}\cap\dom{{\metavariable{dvs}}}=\emptyset} \end{array} \end{math}} \caption{Syntactic calculus: reduction rules}\label{fig:pure-red} \end{figure} Rule \rn{ctx} is the usual contextual closure. In rule \rn{new}, a constructor invocation where all arguments are references is reduced to an elementary block where a new object is allocated. However, this reduction is not allowed when the constructor invocation occurs as right-hand side of a declaration, to prevent non-terminating reduction sequences such as the following:\\ \centerline{$\BlockLab{\Dec{\metavariable{C}}{\metavariable{x}}{\ConstrCall{\metavariable{C}}{\metavariable{x}}}}{\metavariable{x}}{}\longrightarrow\BlockLab{\Dec{\metavariable{C}}{\metavariable{x}}{\BlockLab{\Dec{\metavariable{C}}{\metavariable{x}}{\ConstrCall{\metavariable{C}}{\metavariable{x}}}}{\metavariable{x}}{}}}{\metavariable{x}}{}\longrightarrow\cdots$} {Note that, if the constructor invocation occurs, instead, on the right-side of a declaration of an affine variable, the rule is applicable and does not produce a non-terminating reduction sequence. For instance:\\ \centerline{ $\BlockLab{\Dec{\Type{\terminale{a}}{\metavariable{C}}}{\metavariable{x}}{\ConstrCall{\metavariable{C}}{\metavariable{x}}}}{\metavariable{x}}{}\longrightarrow\BlockLab{\Dec{\Type{\terminale{a}}{\metavariable{C}}}{\metavariable{x}}{\BlockLab{\Dec{\metavariable{C}}{\metavariable{x}}{\ConstrCall{\metavariable{C}}{\metavariable{x}}}}{\metavariable{x}}{}}}{\metavariable{x}}{}$} and rule \rn{new} is no longer applicable. } In rule \rn{field-access}, a field access of shape $\FieldAccess{\metavariable{x}}{\metavariable{f}}$ is evaluated in the block context containing the first enclosing (evaluated) declaration for $\metavariable{x}$, as expressed by the first side condition and the definition of $\extractDec{\ctx_b}{\metavariable{x}}$. The fields of the class $\metavariable{C}$ of $\metavariable{x}$ are retrieved from the class table. If $\metavariable{f}$ is the name of a field of $\metavariable{C}$, say, the $i$-th, then the field access is reduced to the reference $\metavariable{x}_i$ stored in this field. The condition $\metavariable{x}_i\not\in\Inner{\ctx_b}$ ensures that there are no inner declarations for $\metavariable{x}_i$ (otherwise $\metavariable{x}_i$ would be erroneously bound). This can always be obtained by rule \rn{alpha} of \refToFigure{pure-cong}. For instance, assuming a class table where class \lstinline{A} has an \lstinline{int} field, and class \lstinline{B} has an \lstinline{A} field \lstinline{f}, without this side condition, the term: \begin{lstlisting} A a=new A(0); B b=new B(a); {A a=new A(1); b.f} \end{lstlisting} {would reduce to} \begin{lstlisting} A a=new A(0); B b=new B(a); {A a=new A(1); a} \end{lstlisting} whereas this reduction is forbidden by the side condition. However, by rule \rn{alpha} of \refToFigure{pure-cong}, the term is congruent to one that can be reduced to \begin{lstlisting} A a=new A(0); B b=new B(a); {A a1=new A(1); a} \end{lstlisting} In rule \rn{field-assign}, a field assignment of shape $\FieldAssign{\metavariable{x}}{\metavariable{f}}{\metavariable{y}}$ is evaluated in the block context containing the first enclosing (evaluated) declaration for $\metavariable{x}$, as expressed by the first side condition. The fields of the class $\metavariable{C}$ of $\metavariable{x}$ are retrieved from the class table. If $\metavariable{f}$ is the name of a field of $\metavariable{C}$, say, the $i$-th, then this first enclosing declaration is updated, by replacing the $i$-th constructor argument by $\metavariable{y}$ obtaining the declaration $\Dec{\metavariable{C}}{\metavariable{x}}{\ConstrCall{\metavariable{C}}{\metavariable{x}_1,\metavariable{x}_{i-1},\metavariable{y},\metavariable{x}_{i+1},\dots,\metavariable{x}_n}}$ as expressed by the notation $\updateCtx{\metavariable{y}}{\metavariable{x}}{i}$ (whose obvious formal definition is omitted). Analogously to rule \rn{field-access}, we have the side condition that $\metavariable{y}\not\in\Inner{\ctx_b}$. This side condition, requiring that there are no inner declarations for $\metavariable{y}$, prevents scope extrusion, since if $\metavariable{y}\in\Inner{\ctx_b}$, $\updateCtx{\metavariable{y}}{\metavariable{x}}{i}$ would take $\metavariable{y}$ outside the scope of its definition. For example, without this side condition, the term \begin{lstlisting} A a=new A(0); B b=new B(a); {A a1=new A(1); b.f=a1} \end{lstlisting} would reduce to \begin{lstlisting} A a=new A(0); B b=new B(a1); {A a1=new A(1); a1} \end{lstlisting} which is not correct since \verb!a1! is a free variable. The rules \rn{move-dec} and \rn{move-body} (see below) can be used to move the declaration of $\metavariable{y}$ outside its declaration block. So the term reduces, instead, to \begin{lstlisting} A a=new A(0); B b=new B(a); A a1=new A(1); b.f=a1 \end{lstlisting} by applying first rule \rn{move-body}, and then {congruence rule} \rn{block-elim}. Now the term correctly reduces to \begin{lstlisting} A a=new A(0); B b=new B(a1); A a1=new A(1); a1 \end{lstlisting} In rule \rn{invk}, a method call of shape $\MethCall{\metavariable{x}}{\metavariable{m}}{\metavariable{v}_1,..,\metavariable{v}_n}$ is evaluated in the block context containing the first enclosing (evaluated) declaration for $\metavariable{x}$, as expressed by the first side condition. Method $\metavariable{m}$ of $\metavariable{C}$, if any, is retrieved from the class table. The call is reduced to a block where declarations of the appropriate type for $\terminale{this}$ and the parameters are initialized with the receiver and the arguments, respectively, and the body is the method body. If a parameter is affine, then the corresponding argument will be checked to be a capsule when the formal parameter will be substituted with the associated value by rule \rn{affine-elim}, see below. We assume that parameters which are affine occur at most once in the body of the method. The following two rules eliminate declarations from a block.\\ In rule \rn{alias-elim}, a reference (non affine variable) $\metavariable{x}$ which is initialized as an alias of another reference $\metavariable{y}$ is eliminated by replacing all its occurrences. In rule \rn{affine-elim}, an affine variable is eliminated by replacing its unique occurrence with the value associated to its declaration. The rule can only be applied if such value is a capsule. Such side condition formally models that execution includes a runtime check in this case, as it happens, e.g., in Java downcasts. Note also that, even ignoring the $\terminale{a}$ qualifier in the latter, the two rules do not overlap, since a reference $\metavariable{y}$ is trivially not a capsule. Rule \rn{garbage} states that we can remove an unused sequence of evaluated declarations from a block. Note that it is only possible to safely remove declarations which are evaluated, since they do not have side effects. With the remaining rules we can move a sequence of evaluated declarations from a block to the directly enclosing block, as it happens with rules for \emph{scope extension} in the $\pi$-calculus \cite{Milner99}. In rules \rn{move-dec} and \rn{move-body}, the inner block is the right-hand side of a declaration, or the body, respectively, of the enclosing block. The first two side conditions ensure that moving the declarations {$\metavariable{dvs}'$} {does cause neither scope extrusion nor capture of free variables}. More precisely: the first prevents moving outside a declaration {$\metavariable{dvs}'$} which depends on local variables of the inner block. The second prevents capturing with {$\metavariable{dvs}'$} free variables of the enclosing block. Note that the second condition can be obtained by $\alpha$-conversion of the inner block, but the first cannot. Finally, when the block initializes an affine variable, the third side condition of rule \rn{dec} forbids to move outside the block declarations of variables that are in the annotation $\X$ of the block. Indeed, annotations can be rough or very precise, as discussed before, but in any case such that variables not in $\X$ cannot be possibly connected to the final result of the block, hence can be safely moved outside without ``breaking'' the capsule property (that the block should ultimately reduce to a closed expression). In case of a non affine declaration, instead, this is not a problem. Rule \rn{move-subterm} handles the cases when the inner block is a subterm of a field access, field assignment, constructor invocation, or method invocation. Note that in this case the inner block is necessarily a (block) value. We use value contexts to express all such cases in a compact way.
{'timestamp': '2019-04-24T02:04:42', 'yymm': '1904', 'arxiv_id': '1904.10107', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.10107'}
arxiv
\section{Introduction} Convolutional neural network (CNN) is an effective method to solve the computer vision tasks~\cite{krizhevsky2012imagenet,simonyan2014very,he2016deep}. Furthermore, combining it with attention mechanisms can better solve them~\cite{chen2017sca,wang2017residual,yang2016stacked,nguyen2018attentive}, such as channel-wise attention networks~\cite{hu2018squeeze,li2018harmonious,hu2018gather,woo2018cbam,zhu2019stacked}. They usually use Global Average Pooling (GAP) to squeeze the entire feature map into a descriptor~\cite{hu2018squeeze,hu2018competitive,li2018harmonious,woo2018cbam}. However, GAP tends to ignore the detail area in feature map with lower magnitude, which easily leads to the homogeneity of the channel descriptors. To alleviate this problem, some researchers combine channel-wise attention with spatial attention to make the attention module to pay attention to the spatial details of the feature map~\cite{li2018harmonious,linsley2018global}. And some researcher even design a 3D-like attention module to extract the channel descriptors with spatial information~\cite{hu2018gather}. However, these methods bring a lot of additional parameters and computational consumption. Therefore, it is expected that the attention mechanism is paid attention to the details of feature maps under the framework of the channel-wise attention mechanism but with only a little additional cost. This paper attempts to improve the representation of descriptors extracted by GAP through providing the feature maps with higher quality. The proposed method is called as Stochastic Region Pooling (SRP), which does not brings extra parameters and computation in test phase. SRP emphasizes more local features in the convolutional layer, making the channel descriptors extracted by GAP more representative and thus making the channel-wise attention mechanism works better. In more details, it stochastically selects the region from the feature map and used GAP to obtain the region descriptor, where the descriptor is the accurate representation of the region. Subsequently, the region descriptors are used in the follow-up attention structure. In such case, the back propagation~\cite{lecun1989backpropagation} will encourage these regions to have more important feature responses to represent its original entire feature map. This paper proposes a simple method to implement SRP, named as Single Square SRP (SS-SRP), which stochastically selects a single square region from feature map to extract the descriptor. In order to consider local response of irregular shape in feature map, another method named as Multiple Squares SRP (MS-SRP) is proposed that stochastically selects multiple square regions from the feature map and then extracts the descriptor from their union regions. These two methods are illustrated in figure.\ref{fig:1}. On the other hand, in residual networks, most of attention mechanisms only act on the residual branch of residual block. In order to make the feature maps of identity branch also have more feature responses, we use SRP to extract the channel descriptors of both identity branch and residual branch, which are then applied to serve the follow-up attention structure. The main contributions are as follows: \begin{figure*} \centering \includegraphics[width=16cm]{O_D_srp_structure_new} \caption{The framework of Stochastic Region Pooling (SRP) with applications to one branch or double branch attention block, where SS-SRP and MS-SRP are considered.} \label{fig:1} \end{figure*} \begin{itemize} \item A new method SRP is proposed that make more local regions in the feature map to have more important feature responses, so that the channel descriptors extracted later by GAP are more representative and robust. \item SRP obtains the significant improvement of the performance for one branch or double branch block of channel-wise attention structures without any additional parameters and computation in test phase. It can also work well with some augmentation methods to further improve the performance. \item A linear strategy is proposed to make SRP work well that gradually reduces the scale ratio of region as the depth of the layer increases. \item Experiments are conducted on serval datasets, including CIFAR-10/100, ImageNet and three Fine-grained datasets (CUB-200-2011, Stanford Cars and Stanford Dogs), which verified the effectiveness of SRP. \end{itemize} \begin{algorithm*} \KwIn{Feature map:$U$, height and width of the feature map: $H$ and$W$, scale ratio:$\lambda$, the number of square regions:$M$, $mode$. } \KwOut{The channel descriptors $z$ ($z_c$ is the $c^{th}$ channel descriptor of $z$).} \If{$mode$ != $Training Stage$}{ $\forall c : z_c=F_{sq}(u_c) \qquad \qquad \qquad \qquad \rhd {F}_{sq}$ computes Eq.~\eqref{eqn:01}\; return $z$\; } Calculate the height and width of square region: $H'=\lfloor \lambda H + \frac{1}{2}\rfloor, W'=\lfloor \lambda W + \frac{1}{2}\rfloor$\; Stochastically sample $M$ positions $P^m_{i,j}$ from the feature map $U$ where $1\leq i \leq H-H'+1$, $1\leq j \leq W-W'+1$\; Crop $M$ square regions from the feature map $U$ with the left-top position as $P^m_{i,j}$, where the width and height of square region are $W'$ and $H'$\ respectively; $\forall c: {z}_c={F^{\*}}_{sq}(u_c,P_{i,j},H',W') \qquad \qquad \rhd {F^{\*}}_{sq}$ computes Eq.~\eqref{eqn:04} or Eq.~\eqref{eqn:06}\; return ${z}$\ ; \caption{Stochastic Region Pooling} \label{alg:one} \end{algorithm*} \section{Related Work} \noindent\textbf{Improving representation of feature maps}.$\quad$ A common way to obtain high-quality feature maps is to find efficient network structures, such as~\cite{simonyan2014very, szegedy2015going, he2016deep,huang2017densely,yang2018convolutional} to extract more and better features. However, the feature maps learned by these networks are still not diverse enough. Another way is regularization. Some regularization for channel can maintain high quality channels by removing or retraining the inefficient channels ~\cite{he2017channel,zhang2016picking,gao2018dynamic,hou2019Weighted}. For ~\cite{he2017channel,zhang2016picking}, they will change the network structure. And for ~\cite{gao2018dynamic,hou2019Weighted}, we have not found the evidence to prove that they are suitable for channel-wise attention neural networks. Other regularizations such as dropout~\cite{srivastava2014dropout}, droppath~\cite{larsson2017fractalnet}, dropblock~\cite{ghiasi2018dropblock}, cutout~\cite{devries2017improved} can enhance the robustness of the feature by introducing randomness. And our method is closely related to Dropblock~\cite{ghiasi2018dropblock} which drops spatially correlated information to promote the network to reconstruct the important features from its surrounding. However, our method is aims to solve the problem that the descriptor in the channel-wise attention network contains few detailed information of the feature map, such as by promoting the feature map to have more or wider important feature responses. \noindent\textbf{Extracting descriptors by spatial feature pooling}.$\quad$ The idea of spatial feature pooling was proposed by Hubel and Wiesel~\cite{hubel1962receptive}, and then Yann Lecun~\cite{lecun1998gradient} successfully applied it to CNN. Furthermore, Spatial Pyramid Matching(SPM)~\cite{lazebnik2006beyond,yang2009linear} manually designed the pooling weights to obtain spatial feature pyramid, Malinowski~\cite{malinowski2013learning} parameterized pooling operator to learn the pooling regions, and Lee~\cite{lee2016generalizing} combined the max pooling and the average pooling to obtains a generalized pooling function. Some researchers also use the second-order pooling even the third-order pooling instead of the first-order pooling (i.e., GAP) to collect richer statistics of the last convolution layer in CNN~\cite{cui2017kernel,lin2015bilinear,wang2018global}. Introducing randomness can also improve the performance of spatial pooling. For example, stochastic pooling~\cite{zeiler2013stochastic} randomly selects the activation value based on a multinomial distribution formed by activations of each pooling region to regularize the network, and S3Pool~\cite{zhai2017s3pool} randomly picks feature map's rows and columns and then performs the max pooling operation to implicitly introduce data augmentation. However, using the above method to extract the channel descriptor will bring a lot of extra consumption, or it will still not make the descriptor's representation stronger. We select a simplest way, which takes GAP to extract the descriptor because it is widely used, does not bring any extra parameters, and has the potential to get global spatial information. \noindent\textbf{Methods of spatial pooling in attention mechanism}.$\quad$ Channel-wise attention mechanisms have developed rapidly in recent years~\cite{nguyen2018attentive,chen2017sca,li2018harmonious,hu2018squeeze,hu2018gather,woo2018cbam} and the channel descriptors are crucial to them. In order to extract more representative descriptors, CBAM~\cite{woo2018cbam} combines the output of the global max pooling and the global average pooling as the pooling method, and GEnet~\cite{hu2018gather} uses the depth-wise convolution with large kernel to replace GAP. However, the global max pooling in CBAM is prone to network overfitting~\cite{zeiler2013stochastic}, and CBAM also cannot enhance the channel descriptor with more spatial details. Besides, GENet will brings a lot of additional parameters or computation. Different from them, SRP is a training method that can encourage the descriptors to have more information about the feature map details. The reason why SRP uses GAP instead of the above methods to extract the descriptor is not only because GAP is simple and does not bring any additional parameters, but also that GAP is widely used for attention networks. This enables SRP to be conveniently used on these networks without modifying the network structure. \section{Stochastic Region Pooling} Many channel-wise attention block applied GAP operation to obtain the descriptor of feature map. Formally, given the feature maps $U=[u_1,u_2,\cdots,u_c]\in \mathbb{R}^{H\times W\times C}$ in the convolutional layer and the function $S(\cdot)$ squeezes the global spatial information into a channel descriptor $z = [z_1,z_2,\cdots,z_C]\in R^{C}$, the $c^{th}$ channel descriptor of $z$ can be calculated in GAP by \begin{equation} \label{eqn:01} z_c=S(u_c)=\frac{1}{H\times W}\sum^{H}_{i=1}\sum^{W}_{j=1}u_c(i,j). \end{equation} From the Eq.\ref{eqn:01}, it can be concluded that GAP regards each position of the space to make the same contribution, even if the elements of some local regions have the low magnitude~\cite{zeiler2013stochastic}. This will weaken the details of the feature map and easily leads to high similarity between descriptors. Here we propose Stochastic Region Pooling (SRP) method that stochastically selects the region from the feature map instead of the whole map to extract descriptors during the training stage. SRP is presented as Algorithm ~\ref{alg:one}. \textbf{SS-SRP} is a simple method to be implemented, which stochastically selects a single square region from map. Supposing that the scale ratio $\lambda$ controls the size of square region, the width and height of the square region can be formulated as follows, \begin{equation} \label{eqn:03} H'=\lfloor \lambda H + \frac{1}{2}\rfloor, W'=\lfloor \lambda W + \frac{1}{2}\rfloor. \end{equation} For each feature map, we stochastically select a position $P(a,b)$ as the upper left corner of the square region $R\in \mathbb{R}^{H'\times W'}$, where the spatial position $P(a,b)$ subject to $1\leq i \leq H-H'+1$, $1\leq j \leq W-W'+1$. Now we use the average pooling as the squeeze operator $S(\cdot)$ to extract the descriptors $z$, and the $c^{th}$ channel descriptor of $z$ can be calculated by \begin{equation} \label{eqn:04} {z}_c=S(u_c)=\frac{1}{H'\times W'}\sum^{a+H'-1}_{i=a}\sum^{b+W'-1}_{j=b}u_c(i,j). \end{equation} The module of SS-SRP can be seen in the Figure \ref{fig:1}. \textbf{MS-SRP} is applied to consider the non-regular shape of the local region in feature map, which stochastically selects multiple square regions from the feature map and then extracts the descriptor from their union regions. Suppose that we stochastically choose $M$ square regions from the feature map, defined as $R \in \mathbb{R}^{M\times H\times W}$, the target region we want is their union area $R^{*}$. Let $\Omega^{*}$ be the set of all the points in $R^{*}$ and $\Omega_m$ be the set of all points in the $m^{th}$ square region $R_m$, we have \begin{equation} \label{eqn:05} \Omega^{*}= \bigcup_{m = 1}^{M} \Omega_m=\bigcup_{m = 1}^{M} \big\{(x,y)\mid(x,y)\in \Omega_m\big\}. \end{equation} The global average pooling is used as we did before to squeeze the regional spatial information. Thus the $c^{th}$ channel descriptor of $z$ can be calculated by \begin{equation} \label{eqn:06} {z}_c=S(u_c,\Omega^{*})=\frac{1}{\mid\Omega^{*}\mid}\sum_{(i,j)\in \Omega^{*}}u_c(i,j), \end{equation} where $\mid\Omega^{*}\mid$ is the number of elements in $\Omega^{*}$,i.e. the number of points in region $R^{*}$. The module of MS-SRP can be seen in the Figure \ref{fig:1}. \noindent\textbf{One branch or double branch attention block.} \label{sec:3} After calculating the channel descriptors, a one branch attention block applies an excitation operation $T^{O}(\cdot)$ to obtain the relationship $\mathbb{\alpha}\in \mathbb{R}^{C}$ between the channels of the residual branch, which is $\alpha=T^{O}\big(z^r)$ where $z^r$ is the channel descriptor of the residual branch. And a double branch attention block utilizes $T^{D}(\cdot,\cdot)$ to compute the relationship among channels of the residual branch, which is $\alpha=T^{D}\big(z^{id},z^{r})$, where $z^{id}$ and $z^{r}$ are the channel descriptors of the identity branch and the residual branch respectively. For the one branch attention block, we use two fully connected(FC) layers as the function $T^{O}\big(z^r)$ as described in SENet~\cite{hu2018squeeze}. For the double branch attention block, we fold two branch's descriptors and use convolution $3\times 3$ to model their relationship as the function $T^{D}\big(z^{id},z^{r})$ as described in CMPE-SENet~\cite{hu2018competitive}. Finally, these recalibrated feature maps $\widetilde{U}\in \mathbb{R}^{H\times W \times C}$ can be calculated by $\widetilde{U}= \alpha \cdot U$, where $\cdot$ is the element-wise multiplication. \noindent\textbf{Scheduled SRP.}$\quad$ The neurons in the shallow layers of the network have smaller receptive field. In order to maintain a majority of responses in the region selected by SRP in the shallow layers, we gradually reduce $\lambda$ from 1 to the smaller value as the depth of the layer increases, instead of setting $\lambda$ to a fixed value. In our experiments, we use linear strategy to reduce $\lambda$, which is inspired by ScheduledDropPath~\cite{zoph2018learning}, but ScheduledDropPath changes its parameters over training time. \section{Experiments} Some experiments are conducted to validate the proposed method on the CIFAR-10/100\cite{krizhevsky2009learning}, ImageNet\cite{ILSVRC15}, and three fine-grained datasets (CUB-200-2011\cite{wah2011caltech}, Stanford Dogs\cite{khosla2011novel} and Stanford Cars\cite{krause20133d}). For experiments on CIFAR and fine-grained datasets, we report the average accuracy by running five times, while on ImageNet, we report the average accuracy by doing three times due to the limitation of computational resources. In the following subsections, SRP-O indicates that SRP is applied to the one branch attention block, and SRP-D indicates that SRP is applied to the double branch attention block. \subsection{Experiment Settings} \begin{table \begin{minipage}{\columnwidth} \begin{center} \scalebox{1}{ \begin{tabular}{lccc} \toprule Datasets & \#Class & \#Train & \#Test \\ \midrule CUB-200-2011 & 200 & 5,994 & 5,794 \\ Stanford Cars & 196 & 8,144 & 8,041 \\ Stanford Dogs & 120 & 12,000 & 8,580 \\ \bottomrule \end{tabular}} \end{center} \end{minipage} \caption{Statistics of three common Fine-grained datasets.} \label{tab:1} \end{table}% \begin{figure \centering \includegraphics[width=4cm]{lambda_ss_srp_o_wrn2810_cifar100} \includegraphics[width=4cm]{lambda_ss_srp_d_wrn2810_cifar100} \includegraphics[width=4cm]{lambda_ss_srp_o_res110_cifar100} \includegraphics[width=4cm]{lambda_ss_srp_d_res110_cifar100} \caption{Testing acc (\%) of SS-SRP (with or without scheduled) applied to One or Double branch block on CIFAR-100 data with the different $\lambda$.} \label{fig:2} \end{figure} \begin{figure \centering \includegraphics[width=4cm]{heatmap_SRP-O-WRN-28-10_cifar100_number_nocbar} \includegraphics[width=4cm]{heatmap_SRP-D-WRN-28-10_cifar100_number_nocbar} \caption{Test acc (\%) of MS-SRP applied to One or Double Branch block on CIFAR-100 dataset under different hyperparameters ($\lambda, M$).} \label{fig:3} \end{figure} \noindent\textbf{CIFAR.} Following ~\cite{he2016identity,Zagoruyko2016WRN,xie2017aggregated}, we use stochastic gradient descent (SGD) with 0.9 Nesterov momentum and batchsize of 128. The learning rate is set to be 0.1, which is then divided by 10 at epochs 100, 150 for ResNet, divided by 5 at epochs 60,120,160 for WRN, and divided by 10 at epochs 150,225 for ResNeXt. We train the model by 200 epochs for ResNet and WRN, and 300 epochs for ResNeXt. The weight decay is 0.0001 for ResNet, 0.0005 for WRN and ResNeXt. we use the standard data augmentation (translation/mirroring) for the training sets. \noindent\textbf{ImageNet.} The ILSVRC 2012 contains 1.2 million training images and 50K validation images with 1K classes. We adopt the standard data augmentation for the training sets, which randomly samples a 224$\times$224 crop from the original images or their horizontal flip, and applies a single-crop with the size 224$\times$224 at testing stage. We train our models for 100 epochs and drop the learning rate by 0.1 at epoch 30, 60, and 90, and use SGD with the mini-batch size of 256 on 4 GPUs (64 each). The weight decay is 0.0001 and Nesterov momentum is 0.9. In experiments, we report the classification accuracy on the validation set. \noindent\textbf{Fine-grained Datasets.} We conduct experiments on three fine-grained datasets, including CUB-200-2011,Stanford Dogs and Stanford Cars. The detailed statistics of each dataset are shown in Table \ref{tab:1}. For all fine-grained datasets, we resize the input images to 512$\times$512 and randomly crop the smaller images with 448$\times$448 from it, and then generates the horizontal flip of the cropped images for training. At the testing stage, we only use a single cropped image with 448$\times$448 from the input image which have been resized to 512$\times$512. We fine-tune networks (pre-trained on ImageNet) using SGD with the batch size of 16, momentum of 0.9 and weight decay of 0.00001. For all fine-grained datasets, we train the networks for 90 epochs. The learning rate begins with 0.001 and then divided by 10 at epoch 30 and 60. \subsection{Impact of Hyper-parameters} In order to demonstrate the influence of two hyper-parameters (scale ratio $\lambda$ and the square regions number $M$) on the performance of our model, experiments are conducted on CIFAR-100, where SRP applied on attention networks with different hyper-parameter settings. \noindent\textbf{SS-SRP}. It only randomly selects one square region, which becomes standard mothod when we set $\lambda=1$. It can be seen from figure \ref{fig:2} that an appropriate $\lambda$ can improve the network performance and the lower $\lambda$ will result in the poor results. In the following experiments of SS-SRP, we use $\lambda=0.8$ unless specified elsewhere, because SS-SRP obtains the better results at $\lambda=0.8$. From figure \ref{fig:2}, it can be also observed that SRP with the fixed scale ratio $\lambda$ can effectively improve the network performance, but the scheduled SRP makes the network work better. In all following experiments of SRP, scheduled SRP is used. \noindent\textbf{MS-SRP}. In MS-SRP, there are two hyper-parameters that affects the network performance, i.e., the scale ratio $\lambda$ and the square number $M$. By observing the results in figure \ref{fig:3}, MS-SRP outperforms standard method SRP (i.e., $\lambda=1$) and SS-SRP within a wider range of hyper-parameters. Since $\lambda=0.6$ and $M=5$ can obtain the better results, we use these hyper-parameters for all experiments of MS-SRP unless stated elsewhere. \begin{table \centering \scalebox{0.75}{ \begin{tabular}{lcccccc} \toprule Model & depth & params & C10 & C100 \\ \midrule FractalNet~\cite{larsson2017fractalnet} & 21 & 38.6M & 95.40 & 76.27 \\ WRN-28-10~\cite{Zagoruyko2016WRN} & 28 & 36.5M & 96.00 & 80.75 \\ ResNeXt-29(8x64d)~\cite{xie2017aggregated} & 29 & 34.4M & 96.35 & 82.23 \\ ResNeXt-29(16x64d)~\cite{xie2017aggregated} & 29 & 68.1M & 96.42 & 82.69 \\ DenseNet(k=24)~\cite{huang2017densely} & 100 & 27.2M & 96.26 & 80.75 \\ DenseNet-BC(k=40)~\cite{huang2017densely} & 190 & 25.6M & 96.54 & 82.82 \\ PyramidNet(bottleneck,$\alpha=270$)~\cite{han2017deep} & 272 & 27.0M & 96.52 & {\color{red}{82.99}} \\ \midrule \textit{mixup}~\cite{zhang2017mixup}, WRN-28-10~\cite{Zagoruyko2016WRN} & 28 & 36.5M & 97.30 & 82.50 \\ \textit{mixup}~\cite{zhang2017mixup}, DenseNet-BC(k=40)~\cite{huang2017densely} & 190 & 25.6M & 97.30 & 83.20 \\ \textit{mixup}~\cite{zhang2017mixup}, SE-WRN-28-10~\cite{hu2018squeeze} & 28 & 36.8M & 97.32 & 83.23 \\ \midrule \textbf{SS-SRP-O}, WRN-28-10 & 28 & 36.8M & 96.28 & 81.38 \\ \textbf{SS-SRP-O}, ResNeXt-29(8x64d) & 29 & 34.9M & 96.52 & 82.59 \\ \textbf{SS-SRP-D}, WRN-16-8 & 16 & 11.1M & 96.02 & 80.89 \\ \textbf{SS-SRP-D}, WRN-28-10 & 28 & 36.9M & 96.50 & 81.78 \\ \midrule \textbf{MS-SRP-O}, WRN-28-10 & 28 & 36.8M & 96.34 & 81.38 \\ \textbf{MS-SRP-O}, ResNeXt-29(8x64d) & 29 & 34.9M & 96.53 & \textbf{82.62} \\ \textbf{MS-SRP-D}, WRN-16-8 & 16 & 11.1M & 96.10 & 80.98 \\ \textbf{MS-SRP-D}, WRN-28-10 & 28 & 36.9M & {\color{red}{96.61}} & 81.91 \\ \midrule \textbf{MS-SRP-O}, \textit{mixup}, WRN-28-10 & 28 & 36.8M & 97.48 & 84.08 \\ \textbf{MS-SRP-D}, \textit{mixup}, WRN-16-8 & 16 & 11.1M & 96.84 & 82.71 \\ \textbf{MS-SRP-D}, \textit{mixup}, WRN-28-10 & 28 & 36.9M & {\color{red}{97.56}} & {\color{red}{84.12}} \\ \bottomrule \end{tabular}} \caption{Comparison of test accuracy (\%) with different methods on the CIFAR-10 and CIFAR-100. The best results are highlighted in {\color{red}{red}}, and the best records of our models are in \textbf{bold}. Combined with the augmentation method of \textit{mixup}~\cite{zhang2017mixup}, SRP can challenge state-of-the-art results.} \label{tab:2} \end{table}% \begin{table \begin{minipage}{\columnwidth} \begin{center} \scalebox{0.8}{ \begin{tabular}{lccc } \toprule Model & params & top-1 & top-5 \\ \midrule CliqueNet-S3~\cite{yang2018convolutional} & 14.4M & 75.95 & 92.85 \\ ResNet-50~\cite{he2016deep} & 25.6M & 75.30 & 92.20 \\ ResNet-101~\cite{he2016deep} & 44.6M & 76.40 & 92.90 \\ SE-ResNet-50~\cite{hu2018squeeze} & 28.1M & 76.71 & 93.38 \\ ResNet-152~\cite{he2016deep} & 28.1M & 77.00 & 93.30 \\ DenseNet-201~\cite{huang2017densely} & 20.2M & 77.42 & 93.66 \\ SE-ResNet-101~\cite{hu2018squeeze} & 49.4M & 77.62 & 93.93 \\ CBAM-ResNet-50~\cite{woo2018cbam} & 25.9M & 77.34 & 93.69 \\ GE-$\theta^+$-ResNet-50~\cite{hu2018gather} & 33.7M & \textbf{78.12} & 94.20 \\ \midrule \textbf{SS-SRP-O}-ResNet-50 & 28.1M & 77.43 & 93.81 \\ \textbf{MS-SRP-O}-ResNet-50 & 28.1M & 77.58 & 93.88 \\ \textbf{SS-SRP-D}-ResNet-50 & 29.2M & 77.94 & 94.35 \\ \textbf{MS-SRP-D}-ResNet-50 & 29.2M & 78.09 & \textbf{94.40} \\ \bottomrule \end{tabular}} \end{center} \end{minipage} \caption{Comparison of test accuracy (\%) between SRP and other different methods on the large ImageNet, where a single crop method is applied.} \label{tab:3} \end{table}% \begin{table* \centering \begin{minipage}[b]{0.7\columnwidth} \scalebox{0.7}{ \begin{tabular}{lccc } \toprule Model & Anno. & 1-Stage & Acc. \\ \midrule DVAN~\cite{zhao2017diversified} & $\times$ & $\times$ & 79.0 \\ Part-RCNN~\cite{zhang2014part} & \checkmark & $\times$ & 81.6 \\ PA-CNN~\cite{krause2015fine} & \checkmark & \checkmark & 82.8 \\ RAN~\cite{wang2017residual} & $\times$ & $\times$ & 82.8 \\ FCAN~\cite{liu2016fully} & \checkmark & \checkmark & 84.7 \\ RACNN~\cite{fu2017look} & $\times$ & $\times$ & 85.3 \\ \midrule VGG-19~\cite{simonyan2014very} & $\times$ & \checkmark & 77.8 \\ ResNet-50~\cite{he2016deep} & $\times$ & \checkmark & 81.7 \\ DenseNet-161~\cite{huang2017densely} & $\times$ & \checkmark & 84.2 \\ FCAN~\cite{liu2016fully} & $\times$ & \checkmark & 84.3 \\ ResNet-101~\cite{he2016deep} & $\times$ & \checkmark & 84.5 \\ \midrule \textbf{SS-SRP-D}-ResNet50 & $\times$ & \checkmark & 84.9 \\ \textbf{MS-SRP-D}-ResNet50 & $\times$ & \checkmark & \textbf{85.6} \\ \bottomrule \end{tabular}} \subcaption{CUB-200-2011.} \label{tab:4a} \end{minipage}\begin{minipage}[b]{0.7\columnwidth} \scalebox{0.7}{ \begin{tabular}{lccc } \toprule Model & Anno. & 1-Stage & Acc. \\ \midrule DVAN~\cite{zhao2017diversified} & $\times$ & $\times$ & 87.1 \\ RAN~\cite{wang2017residual} & $\times$ & $\times$ & 91.0 \\ FCAN~\cite{liu2016fully} & \checkmark & \checkmark & 91.3 \\ RACNN~\cite{fu2017look} & $\times$ & $\times$ & 92.5 \\ PA-CNN~\cite{krause2015fine} & \checkmark & \checkmark & \textbf{92.8} \\ \midrule VGG-19~\cite{simonyan2014very} & $\times$ & \checkmark & 84.9 \\ FCAN~\cite{liu2016fully} & $\times$ & \checkmark & 89.1 \\ ResNet-50~\cite{he2016deep} & $\times$ & \checkmark & 89.8 \\ DenseNet-161~\cite{huang2017densely} & $\times$ & \checkmark & 91.8 \\ ResNet-110~\cite{he2016deep} & $\times$ & \checkmark & 91.9 \\ \midrule \textbf{SS-SRP-D}-ResNet50 & $\times$ & \checkmark & 92.3 \\ \textbf{MS-SRP-D}-ResNet50 & $\times$ & \checkmark & \textbf{92.8} \\ \bottomrule \end{tabular}} \subcaption{Stanford Cars.} \label{tab:4b} \end{minipage}\begin{minipage}[b]{0.7\columnwidth} \scalebox{0.7}{ \begin{tabular}{lccc } \toprule Model & Anno. & 1-Stage & Acc. \\ \midrule DVAN~\cite{zhao2017diversified} & $\times$ & $\times$ & 81.5 \\ RAN~\cite{wang2017residual} & $\times$ & $\times$ & 83.1 \\ \midrule VGG-16~\cite{simonyan2014very} & $\times$ & \checkmark & 76.7 \\ ResNet-50~\cite{he2016deep} & $\times$ & \checkmark & 81.1 \\ DenseNet-161~\cite{huang2017densely} & $\times$ & \checkmark & 81.2 \\ FCAN~\cite{liu2016fully} & $\times$ & \checkmark & 84.2 \\ MAMC-ResNet50~\cite{sun2018multi} & $\times$ & \checkmark & 84.8 \\ ResNet-101~\cite{he2016deep} & $\times$ & \checkmark & 84.9 \\ \midrule \textbf{SS-SRP-D}-ResNet50 & $\times$ & \checkmark & 85.9 \\ \textbf{MS-SRP-D}-ResNet50 & $\times$ & \checkmark & \textbf{86.3} \\ \bottomrule \end{tabular}} \subcaption{Stanford Dogs.} \label{tab:4c} \end{minipage} \caption{Comparison results on three Fine-grained datasets including CUB-200-2011, Stanford Cars and Stanford Dogs. "Anno." represents using extra annotation in training. "1-Stage" represents whether the training can be done in one stage. "Acc." represents the test set accuracy (\%)} \label{tab:4} \end{table*}% \begin{figure \centering \includegraphics[width=8cm]{grad_cam_figure} \caption{In \textbf{ImageNet}, the Grad-CAM~\cite{selvaraju2017grad} visualization for double branch block of attention ResNet50 model trained without SRP and trained with SRP. Best viewed in color.} \label{fig:4} \end{figure} \subsection{CIFAR Classification} Table \ref{tab:2} presents the results of SRP and compared state-of-the-art CNN architectures on CIFAR. It can be observed that SRP method consistently achieve the better effective performance when applied it to other networks. Furthermore, the small network trained with SRP can achieve the comparable accuracy to some larger models, such as MS-SRP-O-ResNext-29 (34.9M) vs ResNext-29 (68.1M)~\cite{xie2017aggregated}, MS-SRP-D-WRN-16-8 (11.1M) vs DenseNet (27.2M)~\cite{huang2017densely} or WRN-28-10 (36.5M)~\cite{Zagoruyko2016WRN}. On the other hand, SRP may further improve network performance when augmentation methods are applied, such as \textit{mixup}~\cite{zhang2017mixup}. Combined with \textit{mixup} in the training stage, MS-SRP-D surpasses all the comparison methods, and can challenge state-of-the-art results. \subsection{ImageNet Classification} We next investigate the effectiveness of SRP on large dataset, the ILSVRC 2012 dataset. \noindent\textbf{Comparison with state-of-the-arts CNNs.} It can be observed from Table \ref{tab:3} that SRP can still improve the network performance effectively on the large data sets and achieved very competitive accuracy. For example, it exceeds all the methods in terms of top-5 accuracy, while it is much close to the state-of-the-art method by top-1. For SE-ResNet-50, the accuracy improvement of SRP is 0.87\% on top-1 and 0.5\% on top-5. And the best result of SRP surpasses the basic ResNet-50 and SE-ResNet-50 more than 2\% and 1\% respectively, by both top-1 and top-5. Compared with the GE-$\theta^+$~\cite{hu2018gather}, SRP can achieve comparable or better performance but obviously uses fewer parameters. Moreover, compared with the counterparts, SRP can achieve higher accuracy by top-5 while their accuracy are similar by top-1. This is because SRP promotes the feature maps to contain more features response, making the network have better generalization ability. \noindent\textbf{SRP learns more and wider regions.} The model trained with SRP will promote more local feature responses in the convolutional layer, making the network focus on the more and wider regions. Here, we use Grad-CAM~\cite{selvaraju2017grad} to visualize the importance of the spatial position in the convolutional layer. The visualization results of SRP networks (SS-SRP-D-ResNet50, MS-SRP-D-ResNet50) and the baseline (ResNet50 with double branch attention block) can been seen in Figure \ref{fig:4}. It can be clearly observed that the Grad-CAM masks of SRP cover the target object better and wider than the baseline. That is, the model trained with SRP tends to focus on several spatially distributed regions, and aggregate information from multiple or wider regions. \begin{figure* \centering \includegraphics[width=16cm]{channels_three_figure} \caption{The feature maps of ResNet-50 with different mode. D-ResNet means ResNet-50 with double branch attention block. SRP-O-ResNet and SRP-D-ResNet means ResNet-50 with one or double branch attention block and train with MS-SRP. These feature maps are from the residual branch or identity branch of the 14th block of the network. We only display the first 20 feature maps. Best viewed in color.} \label{fig:5} \end{figure*} \subsection{Fine-Grained Classification} The difficulty of fine-grained classification tasks is that even with different categories of objects, they are still very similar. This requires the network to have the ability to learn multiple and more accurate region features. In this section, we investigate the performance of SRP on fine-grained classification tasks. We first analyze the results on CUB-200-2011 dataset, as shown in Table \ref{tab:4a}. Our method achieves strong performance with ResNet-50, which surpasses some deeper or larger network such as DenseNet-161~\cite{huang2017densely} or ResNet-110~\cite{he2016deep} more than 1\%. Also, compared with the method using extra annotation (FCAN~\cite{liu2016fully}), the method using multiple training stage (Part-RCNN~\cite{zhang2014part}), and the method using both extra annotation and multi-stage (RACNN~\cite{fu2017look}), our method outperforms them by 0.9\%, 4.0\% and 0.3\% respectively. Our method also obtains the good performance on the Stanford Cars and Stanford Dogs, as shown in both Table \ref{tab:4b} and Table \ref{tab:4c}. On Stanford Cars, SRP outperforms all the comparison methods, except PA-CNN that uses extra annotation. On Stanfor Dogs, SRP surpasses the best result of other methods about 1.4\% in Table \ref{tab:4c}. Also, SRP outperforms its deeper or larger counterparts such as ResNet-110 and DenseNet-161 by about 1.0\% on Stanford Cars and 3.3\% on Stanford Dogs averagely. Furthermore, on these two datasets, SRP exceeds the efficient methods like DVAN~\cite{zhao2017diversified} and RAN~\cite{wang2017residual} by about 5.2\% and 2.5\% respectively, while DVAN and RAN both use extra annotation and multi-stage. These facts indicate that SRP can obtain the significant improvement on fine-grained datasets, which even challenge the state-of-the-art results. It is worth mentioning that our method is a general method for the attention mechanisms. It may further improve the classification accuracy by combining with the better base network or some methods which are specifically for the fine-grained image classification. \section{Discussion and Analysis} \begin{figure \centering \includegraphics[width=8.3cm]{cub_grad_figure} \caption{In \textbf{Fine-Grained} dataset, the Grad-CAM~\cite{selvaraju2017grad} visualization datasets for double branch block of attention ResNet50 model trained without SRP, trained with MS-SRP($M=5,\lambda=0.6$), and trained with MS-SRP$^*$($M=5,\lambda=0.2$). It indicates that SRP can promote the network to learn more detailed features of object, while SRP with too smal $\lambda$ will make the network pay attention to some unimportant fragment regions. Best viewed in color.} \label{fig:6} \end{figure} \noindent\textbf{Scheduled SRP.} The results in figure \ref{fig:2} shows that the scheduled SRP is superior to SRP with fixed $\lambda$ within a wide range of hyper-parameters. This indicates that the scheduled SRP is effective and practical. The possible reason is that the receptive field of shallow neurons in CNN are small. When SRP takes the fixed $\lambda$, the attention mechanism will receive a over-fragmented information about the feature map in shallow layer, which will in turn disturb the learning of the attention mechanism. Scheduled SRP avoided this problem by reducing $\lambda$ from 1 to the target value as the depth of layer increases. \noindent\textbf{Feature maps analysis.} The purpose of SRP is to improve the representation of channel descriptors by increasing or widening the important responses in the feature map. Hence we output some feature maps of SRP-O-ResNet, SRP-D-ResNet and D-ResNet to analyze the effects of SRP visually, as shown in Figure \ref{fig:5}. For SRP-O-ResNet, SRP only acts on the residual branch. For SRP-D-ResNet, SRP acts on both the residual and identity branchs. For D-ResNet, SRP is not used. It can be seen that in the residual branch, the feature map of SRP-O-ResNet and SRP-D-ResNet contains more and wider responses than D-ResNet (double branch attention of ResNet-50). In the identity branch, the feature map of SRP-D-ResNet contains more and wider responses than both SRP-O-ResNet and D-ResNet. These facts indicate that due to the effect of SRP, the feature maps from corresponding branch will have more and wider object responses. \noindent\textbf{SRP on fine-grained Recognition.} In order to investigate the reason why SRP is more effective in fine-grained classification tasks, we use Grad-CAM to compare the visualization results of network train with or without SRP in CUB-200-2011. As we can see in Figure \ref{fig:6}, SRP can promote the network to focus on more details of the bird, such as the tip of the wing, the tail or the claw, while the network without SRP mostly tends to focus on one region. This indicates that SRP can promote the network to learn more detailed features of object, which becomes the key to the success of SRP in fine-grained classification tasks. It can be also observed that the network will pay attention to some unimportant fragment regions when $\lambda$ of SRP is too small. We conjecture that a too small $\lambda$ will cause SRP to obtain the over-fragmented information about the feature map, which may affect the performance of the attention mechanism. \section{Conclusion} In this paper, we propose a new method called Stochastic Region Pooling(SRP) for channel-wise attention networks. SRP stochastically selects the region from the feature map to extract descriptor in the training stage, promoting convolutional layer have more important feature responses, and making the network to focus on more and wider spatially distributed regions. Besides, SRP is the general method that can be applied to attention network without modifying the network structure and increasing any additional parameters. Our experiments show that the channel-wise attention network trained with SRP can achieve significant performance improvements on various image classification tasks and challenge the state-of-the-art methods. It is also proved that gradually decreasing the scale ratio of region as the depth of layer leads to the better accuracy. {\small \bibliographystyle{ieee}
{'timestamp': '2019-04-23T02:25:43', 'yymm': '1904', 'arxiv_id': '1904.09853', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.09853'}
arxiv
\section{Appendix} \subsection{Experimental details} \paragraph{Tuning} Unless specified otherwise, we use the default hyperparameters found in reference baseline codebases without tuning. $\kappa$ was searched in \{0.1, 0.2, 0.5\}, $\upsilon$ in \{0.0, 0.1, 0.25, 0.5, 0.75, 1.0\} and the number of heads was chosen based on memory constraints (starting from 8 and decreasing when necessary). We report the final accuracy for each run without performing early stopping. \vspace{-5pt} \paragraph{CIFAR-100} Given the low resolution of CIFAR-100 images, we do not downsample feature maps before the attention operation and instead resort to a smaller batch size. We train all networks for 500 epochs using synchronous SGD with momentum 0.9 distributed across 8 TESLA V100 GPUs. The learning rate is linearly scaled from 0 to $0.2B/256$, where $B$ is the total batch size, for the first $5\%$ training epochs and then annealed with cosine decay~\cite{cosine}. We use standard CIFAR preprocessing: mean normalizing, random flipping and cropping~\cite{zoph2018learning,gastaldi2017shake,yamada2018shakedrop}. Non-augmented architectures are trained with a batch size of 1024 and a weight decay of 2e-4. Augmented architectures are trained with batch size of 256 and a weight decay of 5e-4. \vspace{-5pt} \paragraph{ImageNet classification with ResNet} We train all ResNet architectures for 100 epochs using synchronous SGD with momentum 0.9 across 8 TESLA V100 GPUs and weight decay of 1e-4. We use the largest batch size per worker $B \in \{32, 64, 128, 256\}$ that fits in a minibatch. The initial learning rate is scaled linearly according to the total batch size using a base learning rate of 0.128 for total batch size of 256. During training, we linearly scale the learning rate from 0 to this value for the first 5\% of training epochs and divide it by 10 at epochs 30, 60, 80 and 90. We use standard Inception data augmentation as described in~\cite{szegedy2016rethinking}. \vspace{-5pt} \paragraph{ImageNet classification with MnasNet} We follow the training setup described in~\cite{tan2018mnasnet} and train all networks for 350 epochs with the RMSProp optimizer using exponential learning rate decay. When training our augmented MnasNets, we divide the learning rate by 2 and adjusted the learning rate decay so that the final learning rate stays the same. \vspace{-5pt} \paragraph{Object Detection with COCO dataset} We follow the setup described in \cite{lin2017focal,ghiasi2018dropblock} and train the RetinaNet from scratch for 150 epochs without using ImageNet pretraining for the ResNet backbone. \subsection{Computational \& Memory costs} Table \ref{tab:memory_cost} provides the breakdown of self-attention related computational costs per image. Storing attention maps in each layer induces a memory cost of $N_h (HW)^2$ {\tt bfloat16}. At inference, the memory cost for storing attention maps is only 1.2\% of the memory required to store model parameters (49MB). \begin{table}[h!] \begin{center} {\small \begin{tabular}{|l|c|c|c|} \hline Layer & Memory & Params & FLOPS \\ \hline \{Stage 2 - H=W=14\} * 4 & 600KB & 43k & 22M \\ \{Stage 3 - H=W=14\} * 6 & 600KB & 90k & 40M \\ \{Stage 4 - H=W=7\} * 3 & 37.5KB & 190k & 19M \\ \hline \emph{Training} & 6MB (total) & 1.3M & 390M \\ \hline \emph{Inference} & 600KB (max) & 1.3M & 390M \\ \hline \end{tabular} } \end{center} \caption{Computational costs associated with self-attention in the forward pass of the ResNet50. During inference, we only consider the largest memory cost since activations are not stored. } \label{tab:memory_cost} \end{table} Figures~\ref{fig:resnet_curve_flops} and~\ref{fig:mnasnet_curve_flops} show the accuracies of our attention augmented networks across FLOPS counts, which correlate with running times across hardware platforms. \begin{figure}[h!] \centering \includegraphics[width=0.8\columnwidth]{figures/ImageNet-Accuracy-vs-Flops.pdf} \caption{ImageNet top-1 accuracy as a function of computational demand for variety of ResNet architectures \cite{identity-mappings}. From left to right: ResNet-34, ResNet-50, ResNet-101 and ResNet-152.} \label{fig:resnet_curve_flops} \vspace{-5mm} \end{figure} \begin{figure}[h!] \centering \includegraphics[width=0.8\columnwidth]{{figures/MNAS-vs-Flops.pdf}} \caption{ImageNet top-1 accuracy as a function of computational demand for MnasNet (black) and Attention-Augmented-MnasNet (red) with width multipliers $0.75$, $1.0$, $1.25$ and $1.4$.} \label{fig:mnasnet_curve_flops} \end{figure} \subsection{2D Relative Self-Attention implementation\label{sec:code}} While our method is simple and only requires matrix multiplication, addition and the softmax operation (Equations \ref{eq:relative-att-unbatched} and \ref{eq:relative-att}), our implementation relies on non-trivial operations (e.g. tiling, transposing and reshaping) because no low-level kernels currently exist for hardware platforms. Future work may develop specialized kernels as previously done for convolutions. Therefore, we believe that current latency times (Table \ref{tab:attention_compare}) reflect the lack of dedicated engineering as opposed to inefficiency in the proposed method. \lstset{ backgroundcolor=\color{white}, basicstyle=\fontsize{7.5pt}{8.5pt}\fontfamily{lmtt}\selectfont, columns=fullflexible, breaklines=true, captionpos=b, commentstyle=\fontsize{8pt}{9pt}\color{codegray}, keywordstyle=\fontsize{8pt}{9pt}\color{codegreen}, stringstyle=\fontsize{8pt}{9pt}\color{codeblue}, frame=tb, otherkeywords = {self}, } \begin{figure}[h!] \tiny \begin{lstlisting}[language=python] def shape_list(x): """Return list of dims, statically where possible.""" static = x.get_shape().as_list() shape = tf.shape(x) ret = [] for i, static_dim in enumerate(static): dim = static_dim or shape[i] ret.append(dim) return ret def split_heads_2d(inputs, Nh): """Split channels into multiple heads.""" B, H, W, d = shape_list(inputs) ret_shape = [B, H, W, Nh, d // Nh] split = tf.reshape(inputs, ret_shape) return tf.transpose(split, [0, 3, 1, 2, 4]) def combine_heads_2d(inputs): """Combine heads (inverse of split_heads_2d).""" transposed = tf.transpose(inputs, [0, 2, 3, 1, 4]) Nh, channels = shape_list(transposed)[-2:] ret_shape = shape_list(transposed)[:-2] + [Nh * channels] return tf.reshape(transposed, ret_shape) def rel_to_abs(x): """Converts tensor from relative to aboslute indexing.""" # [B, Nh, L, 2L-1] B, Nh, L, _ = shape_list(x) # Pad to shift from relative to absolute indexing. col_pad = tf.zeros((B, Nh, L, 1)) x = tf.concat([x, col_pad], axis=3) flat_x = tf.reshape(x, [B, Nh, L * 2 * L]) flat_pad = tf.zeros((B, Nh, L-1)) flat_x_padded = tf.concat([flat_x, flat_pad], axis=2) # Reshape and slice out the padded elements. final_x = tf.reshape(flat_x_padded, [B, Nh, L+1, 2*L-1]) final_x = final_x[:, :, :L, L-1:] return final_x def relative_logits_1d(q, rel_k, H, W, Nh, transpose_mask): """Compute relative logits along one dimenion.""" rel_logits = tf.einsum('bhxyd,md->bhxym', q, rel_k) # Collapse height and heads rel_logits = tf.reshape( rel_logits, [-1, Nh * H, W, 2 * W-1]) rel_logits = rel_to_abs(rel_logits) # Shape it and tile height times rel_logits = tf.reshape(rel_logits, [-1, Nh, H, W, W]) rel_logits = tf.expand_dims(rel_logits, axis=3) rel_logits = tf.tile(rel_logits, [1, 1, 1, H, 1, 1]) # Reshape for adding to the logits. rel_logits = tf.transpose(rel_logits, transpose_mask) rel_logits = tf.reshape(rel_logits, [-1, Nh, H*W, H*W]) return rel_logits \end{lstlisting} \caption{Helper functions in Tensorflow for 2D relative self-attention.} \label{fig:helper_relative_code} \vspace{-1em} \end{figure} \lstset{ backgroundcolor=\color{white}, basicstyle=\fontsize{7.5pt}{8.5pt}\fontfamily{lmtt}\selectfont, columns=fullflexible, breaklines=true, captionpos=b, commentstyle=\fontsize{8pt}{9pt}\color{codegray}, keywordstyle=\fontsize{8pt}{9pt}\color{codegreen}, stringstyle=\fontsize{8pt}{9pt}\color{codeblue}, frame=tb, otherkeywords = {self}, } \begin{figure}[h!] \tiny \begin{lstlisting}[language=python] def relative_logits(q, H, W, Nh, dkh): """Compute relative logits.""" # Relative logits in width dimension first. rel_embeddings_w = tf.get_variable( 'r_width', shape=(2*W - 1, dkh), initializer=tf.random_normal_initializer(dkh**-0.5)) # [B, Nh, HW, HW] rel_logits_w = relative_logits_1d( q, rel_embeddings_w, H, W, Nh, [0, 1, 2, 4, 3, 5]) # Relative logits in height dimension next. # For ease, we 1) transpose height and width, # 2) repeat the above steps and # 3) transpose to eventually put the logits # in their right positions. rel_embeddings_h = tf.get_variable( 'r_height', shape=(2 * H - 1, dkh), initializer=tf.random_normal_initializer(dkh**-0.5)) # [B, Nh, HW, HW] rel_logits_h = relative_logits_1d( tf.transpose(q, [0, 1, 3, 2, 4]), rel_embeddings_h, W, H, Nh, [0, 1, 4, 2, 5, 3]) return rel_logits_h, rel_logits_w def self_attention_2d(inputs, dk, dv, Nh, relative=True): """2d relative self-attention.""" _, H, W, _ = shape_list(inputs) dkh = dk // Nh dvh = dv // Nh flatten_hw = lambda x, d: tf.reshape(x, [-1, Nh, H*W, d]) # Compute q, k, v kqv = tf.layers.conv2d(inputs, 2 * dk + dv, 1) k, q, v = tf.split(kqv, [dk, dk, dv], axis=3) q *= dkh ** -0.5 # scaled dot-product # After splitting, shape is [B, Nh, H, W, dkh or dvh] q = split_heads_2d(q, Nh) k = split_heads_2d(k, Nh) v = split_heads_2d(v, Nh) # [B, Nh, HW, HW] logits = tf.matmul(flatten_hw(q, dkh), flatten_hw(k, dkh), transpose_b=True) if relative: rel_logits_h, rel_logits_w = relative_logits(q, H, W, Nh, dkh) logits += rel_logits_h logits += rel_logits_w weights = tf.nn.softmax(logits) attn_out = tf.matmul(weights, flatten_hw(v, dvh)) attn_out = tf.reshape(attn_out, [-1, Nh, H, W, dvh]) attn_out = combine_heads_2d(attn_out) # Project heads attn_out = tf.layers.conv2d(attn_out, dv, 1) return attn_out def augmented_conv2d(X, Fout, k, dk, dv, Nh, relative): conv_out = tf.layers.conv2d(inputs=X, filters=Fout - dv, kernel_size=k, padding='same') attn_out = self_attention_2d(X, dk, dv, Nh, relative=relative) return tf.concat([conv_out, attn_out], axis=3) \end{lstlisting} \caption{Tensorflow code for 2D relative self-attention.} \label{fig:relative_code} \vspace{-1em} \end{figure} \clearpage \subsection{Attention visualizations.\label{sec:attn_viz}} In Figure~\ref{fig:visualization}, we present attention maps visualizations for the input image shown in Figure~\ref{fig:input_image}. We see that attention heads learn to specialize to different content and notably can delineate object boundaries. \begin{figure}[h!] \centering \includegraphics[width=\columnwidth]{{figures/attn_viz_input_better.png}} \caption{An input image. The red crosses indexed 1 to 4 represent the pixel locations for which we show the attention maps in Figure ~\ref{fig:visualization}.} \label{fig:input_image} \end{figure} \begin{figure}[h!] \centering \includegraphics[width=\columnwidth]{{figures/attn_viz_better.png}} \caption{Visualization of attention maps for an augmented convolution in the Attention-Augmented-ResNet50. Rows correspond to the 8 different heads and columns correspond to the 4 pixel locations depicted in the input image (See Figure ~\ref{fig:input_image}).}\label{fig:visualization} \end{figure} \section{Discussion and future work} In this work, we consider the use of self-attention for vision models as an alternative to convolutions. We introduce a novel two-dimensional relative self-attention mechanism for images that enables training of competitive fully self-attentional vision models on image classification for the first time. We propose to augment convolutional operators with this self-attention mechanism and validate the superiority of this approach over other attention schemes. Extensive experiments show that Attention Augmentation leads to systematic improvements on both image classification and object detection tasks across a wide range of architectures and computational settings. Several open questions from this work remain. In future work, we will focus on the fully attentional regime and explore how different attention mechanisms trade off computational efficiency versus representational power. For instance, identifying a {\em local} attention mechanism may result in an efficient and scalable computational mechanism that could prevent the need for downsampling with average pooling \cite{ramachandran2019sasa}. Additionally, it is plausible that architectural design choices that are well suited when exclusively relying on convolutions are suboptimal when using self-attention mechanisms. As such, it would be interesting to see if using Attention Augmentation as a primitive in automated architecture search procedures proves useful to find even better models than those previously found in image classification~\cite{zoph2018learning}, object detection~\cite{ghiasi2019NASFpn}, image segmentation~\cite{chen2018searching} and other domains~\cite{bello2017nos,alber2018backprop,ramachadran2017searching,dogus2018autoaugment}. Finally, one can ask to which degree fully attentional models can replace convolutional networks for visual tasks. \section{Introduction} Please follow the steps outlined below when submitting your manuscript to the IEEE Computer Society Press. This style guide now has several important modifications (for example, you are no longer warned against the use of sticky tape to attach your artwork to the paper), so all authors should read this new version. \subsection{Language} All manuscripts must be in English. \subsection{Dual submission} Please refer to the author guidelines on the ICCV 2019 web page for a discussion of the policy on dual submissions. \subsection{Paper length} Papers, excluding the references section, must be no longer than eight pages in length. The references section will not be included in the page count, and there is no limit on the length of the references section. For example, a paper of eight pages with two pages of references would have a total length of 10 pages. Overlength papers will simply not be reviewed. This includes papers where the margins and formatting are deemed to have been significantly altered from those laid down by this style guide. Note that this \LaTeX\ guide already sets figure captions and references in a smaller font. The reason such papers will not be reviewed is that there is no provision for supervised revisions of manuscripts. The reviewing process cannot determine the suitability of the paper for presentation in eight pages if it is reviewed in eleven. \subsection{The ruler} The \LaTeX\ style defines a printed ruler which should be present in the version submitted for review. The ruler is provided in order that reviewers may comment on particular lines in the paper without circumlocution. If you are preparing a document using a non-\LaTeX\ document preparation system, please arrange for an equivalent ruler to appear on the final output pages. The presence or absence of the ruler should not change the appearance of any other content on the page. The camera ready copy should not contain a ruler. (\LaTeX\ users may uncomment the \verb'\iccvfinalcopy' command in the document preamble.) Reviewers: note that the ruler measurements do not align well with lines in the paper --- this turns out to be very difficult to do well when the paper contains many figures and equations, and, when done, looks ugly. Just use fractional references (e.g.\ this line is $095.5$), although in most cases one would expect that the approximate location will be adequate. \subsection{Mathematics} Please number all of your sections and displayed equations. It is important for readers to be able to refer to any particular equation. Just because you didn't refer to it in the text doesn't mean some future reader might not need to refer to it. It is cumbersome to have to use circumlocutions like ``the equation second from the top of page 3 column 1''. (Note that the ruler will not be present in the final copy, so is not an alternative to equation numbers). All authors will benefit from reading Mermin's description of how to write mathematics: \url{http://www.pamitc.org/documents/mermin.pdf}. \subsection{Blind review} Many authors misunderstand the concept of anonymizing for blind review. Blind review does not mean that one must remove citations to one's own work---in fact it is often impossible to review a paper unless the previous citations are known and available. Blind review means that you do not use the words ``my'' or ``our'' when citing previous work. That is all. (But see below for techreports.) Saying ``this builds on the work of Lucy Smith [1]'' does not say that you are Lucy Smith; it says that you are building on her work. If you are Smith and Jones, do not say ``as we show in [7]'', say ``as Smith and Jones show in [7]'' and at the end of the paper, include reference 7 as you would any other cited work. An example of a bad paper just asking to be rejected: \begin{quote} \begin{center} An analysis of the frobnicatable foo filter. \end{center} In this paper we present a performance analysis of our previous paper [1], and show it to be inferior to all previously known methods. Why the previous paper was accepted without this analysis is beyond me. [1] Removed for blind review \end{quote} An example of an acceptable paper: \begin{quote} \begin{center} An analysis of the frobnicatable foo filter. \end{center} In this paper we present a performance analysis of the paper of Smith \etal [1], and show it to be inferior to all previously known methods. Why the previous paper was accepted without this analysis is beyond me. [1] Smith, L and Jones, C. ``The frobnicatable foo filter, a fundamental contribution to human knowledge''. Nature 381(12), 1-213. \end{quote} If you are making a submission to another conference at the same time, which covers similar or overlapping material, you may need to refer to that submission in order to explain the differences, just as you would if you had previously published related work. In such cases, include the anonymized parallel submission~\cite{Authors14} as additional material and cite it as \begin{quote} [1] Authors. ``The frobnicatable foo filter'', F\&G 2014 Submission ID 324, Supplied as additional material {\tt fg324.pdf}. \end{quote} Finally, you may feel you need to tell the reader that more details can be found elsewhere, and refer them to a technical report. For conference submissions, the paper must stand on its own, and not {\em require} the reviewer to go to a techreport for further details. Thus, you may say in the body of the paper ``further details may be found in~\cite{Authors14b}''. Then submit the techreport as additional material. Again, you may not assume the reviewers will read this material. Sometimes your paper is about a problem which you tested using a tool which is widely known to be restricted to a single institution. For example, let's say it's 1969, you have solved a key problem on the Apollo lander, and you believe that the ICCV70 audience would like to hear about your solution. The work is a development of your celebrated 1968 paper entitled ``Zero-g frobnication: How being the only people in the world with access to the Apollo lander source code makes us a wow at parties'', by Zeus \etal. You can handle this paper like any other. Don't write ``We show how to improve our previous work [Anonymous, 1968]. This time we tested the algorithm on a lunar lander [name of lander removed for blind review]''. That would be silly, and would immediately identify the authors. Instead write the following: \begin{quotation} \noindent We describe a system for zero-g frobnication. This system is new because it handles the following cases: A, B. Previous systems [Zeus et al. 1968] didn't handle case B properly. Ours handles it by including a foo term in the bar integral. ... The proposed system was integrated with the Apollo lunar lander, and went all the way to the moon, don't you know. It displayed the following behaviours which show how well we solved cases A and B: ... \end{quotation} As you can see, the above text follows standard scientific convention, reads better than the first version, and does not explicitly name you as the authors. A reviewer might think it likely that the new paper was written by Zeus \etal, but cannot make any decision based on that guess. He or she would have to be sure that no other authors could have been contracted to solve problem B. \noindent FAQ\medskip\\ {\bf Q:} Are acknowledgements OK?\\ {\bf A:} No. Leave them for the final copy.\medskip\\ {\bf Q:} How do I cite my results reported in open challenges? {\bf A:} To conform with the double blind review policy, you can report results of other challenge participants together with your results in your paper. For your results, however, you should not identify yourself and should not mention your participation in the challenge. Instead present your results referring to the method proposed in your paper and draw conclusions based on the experimental comparison to other results.\medskip\\ \begin{figure}[t] \begin{center} \fbox{\rule{0pt}{2in} \rule{0.9\linewidth}{0pt}} \end{center} \caption{Example of caption. It is set in Roman so that mathematics (always set in Roman: $B \sin A = A \sin B$) may be included without an ugly clash.} \label{fig:long} \label{fig:onecol} \end{figure} \subsection{Miscellaneous} \noindent Compare the following:\\ \begin{tabular}{ll} \verb'$conf_a$' & $conf_a$ \\ \verb'$\mathit{conf}_a$' & $\mathit{conf}_a$ \end{tabular}\\ See The \TeX book, p165. The space after \eg, meaning ``for example'', should not be a sentence-ending space. So \eg is correct, {\em e.g.} is not. The provided \verb'\eg' macro takes care of this. When citing a multi-author paper, you may save space by using ``et alia'', shortened to ``\etal'' (not ``{\em et.\ al.}'' as ``{\em et}'' is a complete word.) However, use it only when there are three or more authors. Thus, the following is correct: `` Frobnication has been trendy lately. It was introduced by Alpher~\cite{Alpher02}, and subsequently developed by Alpher and Fotheringham-Smythe~\cite{Alpher03}, and Alpher \etal~\cite{Alpher04}.'' This is incorrect: ``... subsequently developed by Alpher \etal~\cite{Alpher03} ...'' because reference~\cite{Alpher03} has just two authors. If you use the \verb'\etal' macro provided, then you need not worry about double periods when used at the end of a sentence as in Alpher \etal. For this citation style, keep multiple citations in numerical (not chronological) order, so prefer \cite{Alpher03,Alpher02,Authors14} to \cite{Alpher02,Alpher03,Authors14}. \begin{figure*} \begin{center} \fbox{\rule{0pt}{2in} \rule{.9\linewidth}{0pt}} \end{center} \caption{Example of a short caption, which should be centered.} \label{fig:short} \end{figure*} \section{Formatting your paper} All text must be in a two-column format. The total allowable width of the text area is $6\frac78$ inches (17.5 cm) wide by $8\frac78$ inches (22.54 cm) high. Columns are to be $3\frac14$ inches (8.25 cm) wide, with a $\frac{5}{16}$ inch (0.8 cm) space between them. The main title (on the first page) should begin 1.0 inch (2.54 cm) from the top edge of the page. The second and following pages should begin 1.0 inch (2.54 cm) from the top edge. On all pages, the bottom margin should be 1-1/8 inches (2.86 cm) from the bottom edge of the page for $8.5 \times 11$-inch paper; for A4 paper, approximately 1-5/8 inches (4.13 cm) from the bottom edge of the page. \subsection{Margins and page numbering} All printed material, including text, illustrations, and charts, must be kept within a print area 6-7/8 inches (17.5 cm) wide by 8-7/8 inches (22.54 cm) high. Page numbers should be in footer with page numbers, centered and .75 inches from the bottom of the page and make it start at the correct page number rather than the 4321 in the example. To do this fine the line (around line 23) \begin{verbatim} \setcounter{page}{4321} \end{verbatim} where the number 4321 is your assigned starting page. Make sure the first page is numbered by commenting out the first page being empty on line 46 \begin{verbatim} \end{verbatim} \subsection{Type-style and fonts} Wherever Times is specified, Times Roman may also be used. If neither is available on your word processor, please use the font closest in appearance to Times to which you have access. MAIN TITLE. Center the title 1-3/8 inches (3.49 cm) from the top edge of the first page. The title should be in Times 14-point, boldface type. Capitalize the first letter of nouns, pronouns, verbs, adjectives, and adverbs; do not capitalize articles, coordinate conjunctions, or prepositions (unless the title begins with such a word). Leave two blank lines after the title. AUTHOR NAME(s) and AFFILIATION(s) are to be centered beneath the title and printed in Times 12-point, non-boldface type. This information is to be followed by two blank lines. The ABSTRACT and MAIN TEXT are to be in a two-column format. MAIN TEXT. Type main text in 10-point Times, single-spaced. Do NOT use double-spacing. All paragraphs should be indented 1 pica (approx. 1/6 inch or 0.422 cm). Make sure your text is fully justified---that is, flush left and flush right. Please do not place any additional blank lines between paragraphs. Figure and table captions should be 9-point Roman type as in Figures~\ref{fig:onecol} and~\ref{fig:short}. Short captions should be centred. \noindent Callouts should be 9-point Helvetica, non-boldface type. Initially capitalize only the first word of section titles and first-, second-, and third-order headings. FIRST-ORDER HEADINGS. (For example, {\large \bf 1. Introduction}) should be Times 12-point boldface, initially capitalized, flush left, with one blank line before, and one blank line after. SECOND-ORDER HEADINGS. (For example, { \bf 1.1. Database elements}) should be Times 11-point boldface, initially capitalized, flush left, with one blank line before, and one after. If you require a third-order heading (we discourage it), use 10-point Times, boldface, initially capitalized, flush left, preceded by one blank line, followed by a period and your text on the same line. \subsection{Footnotes} Please use footnotes\footnote {This is what a footnote looks like. It often distracts the reader from the main flow of the argument.} sparingly. Indeed, try to avoid footnotes altogether and include necessary peripheral observations in the text (within parentheses, if you prefer, as in this sentence). If you wish to use a footnote, place it at the bottom of the column on the page on which it is referenced. Use Times 8-point type, single-spaced. \subsection{References} List and number all bibliographical references in 9-point Times, single-spaced, at the end of your paper. When referenced in the text, enclose the citation number in square brackets, for example~\cite{Authors14}. Where appropriate, include the name(s) of editors of referenced books. \begin{table} \begin{center} \begin{tabular}{|l|c|} \hline Method & Frobnability \\ \hline\hline Theirs & Frumpy \\ Yours & Frobbly \\ Ours & Makes one's heart Frob\\ \hline \end{tabular} \end{center} \caption{Results. Ours is better.} \end{table} \subsection{Illustrations, graphs, and photographs} All graphics should be centered. Please ensure that any point you wish to make is resolvable in a printed copy of the paper. Resize fonts in figures to match the font in the body text, and choose line widths which render effectively in print. Many readers (and reviewers), even of an electronic copy, will choose to print your paper in order to read it. You cannot insist that they do otherwise, and therefore must not assume that they can zoom in to see tiny details on a graphic. When placing figures in \LaTeX, it's almost always best to use \verb+\includegraphics+, and to specify the figure width as a multiple of the line width as in the example below {\small\begin{verbatim} \usepackage[dvips]{graphicx} ... \includegraphics[width=0.8\linewidth] {myfile.eps} \end{verbatim} } \subsection{Color} Please refer to the author guidelines on the ICCV 2019 web page for a discussion of the use of color in your document. \section{Final copy} You must include your signed IEEE copyright release form when you submit your finished paper. We MUST have this form before your paper can be published in the proceedings. {\small \bibliographystyle{ieee} \section{Introduction} Convolutional Neural Networks have enjoyed tremendous success in many computer vision applications, especially in image classification~\cite{lecun1998gradient,krizhevsky2012imagenet}. The design of the convolutional layer imposes 1) locality via a limited receptive field and 2) translation equivariance via weight sharing. Both these properties prove to be crucial inductive biases when designing models that operate over images. However, the local nature of the convolutional kernel prevents it from capturing global contexts in an image, often necessary for better recognition of objects in images~\cite{rabinovich2007objects}. \begin{figure}[t] \centering \includegraphics[width=\linewidth]{figures/ImageNet-Accuracy-vs-Params.pdf} \caption{\textbf{Attention Augmentation systematically improves image classification across a large variety of networks of different scales.} ImageNet classification accuracy \cite{deng2009imagenet} versus the number of parameters for baseline models (ResNet) \cite{identity-mappings}, models augmented with channel-wise attention (SE-ResNet)~\cite{hu2017squeeze} and our proposed architecture (AA-ResNet). } \label{fig:marketing} \end{figure} \begin{figure*}[t!] \begin{center} \includegraphics[width=\textwidth]{figures/augmented_conv_diagram.pdf} \end{center} \caption{\textbf{Attention-augmented convolution}: For each spatial location (h, w), $N_h$ attention maps over the image are computed from queries and keys. These attention maps are used to compute $N_h$ weighted averages of the values V. The results are then concatenated, reshaped to match the original volume's spatial dimensions and mixed with a pointwise convolution. Multi-head attention is applied in parallel to a standard convolution operation and the outputs are concatenated.} \label{fig:attention-diagram} \end{figure*} Self-attention \cite{vaswani2017attention}, on the other hand, has emerged as a recent advance to capture long range interactions, but has mostly been applied to sequence modeling and generative modeling tasks. The key idea behind self-attention is to produce a weighted average of values computed from hidden units. Unlike the pooling or the convolutional operator, the weights used in the weighted average operation are produced dynamically via a similarity function between hidden units. As a result, the interaction between input signals depends on the signals themselves rather than being predetermined by their relative location like in convolutions. In particular, this allows self-attention to capture long range interactions without increasing the number of parameters. In this paper, we consider the use of self-attention for discriminative visual tasks as an alternative to convolutions. We develop a novel two-dimensional relative self-attention mechanism~\cite{shaw2018self} that maintains translation equivariance while being infused with relative position information, making it well suited for images. Our self-attention formulation proves competitive for replacing convolutions entirely, however we find in control experiments that the best results are obtained when combining both. We therefore do not completely abandon the idea of convolutions, but instead propose to augment convolutions with this self-attention mechanism. This is achieved by concatenating convolutional feature maps, which enforce locality, to self-attentional feature maps capable of modeling longer range dependencies (see Figure~\ref{fig:attention-diagram}). We test our method on the CIFAR-100 and ImageNet classification \cite{krizhevsky2009learning,deng2009imagenet} and the COCO object detection \cite{lin2014microsoft} tasks, across a wide range of architectures at different computational budgets, including a state-of-the art resource constrained architecture~\cite{tan2018mnasnet}. Attention Augmentation yields systematic improvements with minimal additional computational burden and notably outperforms the popular Squeeze-and-Excitation~\cite{hu2017squeeze} channelwise attention approach in all experiments. In particular, Attention Augmentation achieves a 1.3\% top-1 accuracy ImageNet on top of a ResNet50 baseline and 1.4 mAP increase in COCO object detection on top of a RetinaNet baseline. Suprisingly, experiments also reveal that fully self-attentional models, a special case of Attention Augmentation, only perform slightly worse than their fully convolutional counterparts on ImageNet, indicating that self-attention is a powerful stand-alone computational primitive for image classification. \section{Methods} We now formally describe our proposed Attention Augmentation method. We use the following naming conventions: $H$, $W$ and $F_{in}$ refer to the height, width and number of input filters of an activation map. $N_h$, $d_v$ and $d_k$ respectively refer the number of heads, the depth of values and the depth of queries and keys in multihead-attention (MHA). We further assume that $N_h$ divides $d_v$ and $d_k$ evenly and denote $d_v^h$ and $d_k^h$ the depth of values and queries/keys per attention head. \subsection{Self-attention over images} Given an input tensor of shape $(H, W, F_{in})$,\footnote{We omit the batch dimension for simplicity.} we flatten it to a matrix $X \in \mathbb{R}^{HW \times F_{in}}$ and perform multihead attention as proposed in the Transformer architecture~\cite{vaswani2017attention}. The output of the self-attention mechanism for a single head $h$ can be formulated as: \begin{equation} O_h = \textsf{Softmax}\left(\frac{(XW_q)(XW_k)^T}{\sqrt{d_k^h}}\right) (XW_v) \label{eq:dot-prod-att} \end{equation} where $W_q$, $W_k \in \mathbb{R}^{F_{in} \times d_k^h}$ and $W_v \in \mathbb{R}^{F_{in} \times d_v^h}$ are learned linear transformations that map the input $X$ to queries $Q=XW_q$, keys $K=XW_k$ and values $V=XW_v$. The outputs of all heads are then concatenated and projected again as follows: \begin{equation} \textsf{MHA}(X) = \textsf{Concat}\Big[O_1, \dots, O_{Nh}\Big]W^O \label{eq:multihead} \end{equation} where $W^O \in \mathbb{R}^{d_v \times d_v}$ is a learned linear transformation. $\textsf{MHA}(X)$ is then reshaped into a tensor of shape $(H,W,d_v)$ to match the original spatial dimensions. We note that multi-head attention incurs a complexity of $O((HW)^2 d_k)$ and a memory cost of $O((H W)^2 N_h)$ as it requires to store attention maps for each head. \subsubsection{Two-dimensional Positional Embeddings} \label{sec:pos-embedding} Without explicit information about positions, self-attention is \emph{permutation equivariant}: $$\textsf{MHA}(\pi(X)) = \pi(\textsf{MHA}(X))$$ for any permutation $\pi$ of the pixel locations, making it ineffective for modeling highly structured data such as images. Multiple positional encodings that augment activation maps with explicit spatial information have been proposed to alleviate related issues. In particular, the Image Transformer~\cite{parmar2018image} extends the sinusoidal waves first introduced in the original Transformer~\cite{vaswani2017attention} to 2 dimensional inputs and CoordConv~\cite{liu2018intriguing} concatenates positional channels to an activation map. However these encodings did not help in our experiments on image classification and object detection (see Section~\ref{sec:ablation}). We hypothesize that this is because such positional encodings, while not permutation equivariant, do not satisfy \emph{translation equivariance}, which is a desirable property when dealing with images. As a solution, we propose to extend the use of relative position encodings~\cite{shaw2018self} to two dimensions and present a memory efficient implementation based on the Music Transformer~\cite{huang2018improved}. \paragraph{Relative positional embeddings:} Introduced in \cite{shaw2018self} for the purpose of language modeling, relative self-attention augments self-attention with relative position embeddings and enables translation equivariance while preventing permutation equivariance. We implement two-dimensional relative self-attention by independently adding relative height information and relative width information. The attention logit for how much pixel $i=(i_x, i_y)$ attends to pixel $j=(j_x,j_y)$ is computed as: \begin{equation} l_{i,j} = \frac{q_i^T}{\sqrt{d_k^h}} (k_j + r_{j_x - i_x}^W + r_{j_y - i_y}^H) \label{eq:relative-att-unbatched} \end{equation} where $q_i$ is the query vector for pixel $i$ (the i-th row of $Q$), $k_j$ is the key vector for pixel $j$ (the j-th row of $K$) and $r_{j_x - i_x}^W$ and $r_{j_y - i_y}^H$ are learned embeddings for relative width $j_x - i_x$ and relative height $j_y - i_y$, respectively. The output of head $h$ now becomes: \begin{equation} O_h = \textsf{Softmax}\left(\frac{QK^T + S_H^{rel} + S_W^{rel}}{\sqrt{d_k^h}} \right)V \label{eq:relative-att} \end{equation} where $S_H^{rel}, S_W^{rel} \in \mathbb{R}^{HW \times HW}$ are matrices of relative position logits along height and width dimensions that satisfy $S_H^{rel}[i,j] = q_i^T r_{j_y - i_y}^H$ and $S_W^{rel}[i,j] = q_i^T r_{j_x - i_x}^W$. The relative attention algorithm in \cite{shaw2018self} explicitly stores all relative embeddings $r_{ij}$ in a tensor of shape $(HW, HW, d_k^h)$, thus incurring an additional memory cost of $O((HW)^2d_k^h)$. This compares to $O((HW)^2N_h)$ for the position-unaware version self-attention that does not use position encodings. As we typically have $N_h < d_k^h$, such an implementation can prove extremely prohibitive and restrict the number of images that can fit in a minibatch. Instead, we extend the memory efficient relative masked attention algorithm presented in \cite{huang2018improved} to unmasked relative self-attention over 2 dimensional inputs. Our implementation has a memory cost of $O(HWd_k^h)$. We leave the Tensorflow code of the algorithm in the Appendix. The relative positional embeeddings $r^H$ and $r^W$ are learned and shared across heads but not layers. For each layer, we add $(2(H+W)-2)d_k^h$ parameters to model relative distances along height and width. \subsection{Attention Augmented Convolution} \label{sec:augmented-conv} Multiple previously proposed attention mechanisms over images \cite{hu2017squeeze,hu2018gather,park2018bam,woo2018cbam} suggest that the convolution operator is limited by its locality and lack of understanding of global contexts. These methods capture long-range dependencies by recalibrating convolutional feature maps. In particular, Squeeze-and-Excitation (SE) \cite{hu2017squeeze} and Gather-Excite (GE) \cite{hu2018gather} perform channelwise reweighing while BAM \cite{park2018bam} and CBAM \cite{woo2018cbam} reweigh both channels and spatial positions \emph{independently}. In contrast to these approaches, we 1) use an attention mechanism that can attend \emph{jointly} to spatial and feature subspaces (each head corresponding to a feature subspace) and 2) introduce additional feature maps rather than refining them. Figure \ref{fig:attention-diagram} summarizes our proposed augmented convolution. \paragraph{Concatenating convolutional and attentional feature maps:} Formally, consider an original convolution operator with kernel size $k$, $F_{in}$ input filters and $F_{out}$ output filters. The corresponding attention augmented convolution can be written as $$\textsf{AAConv}(X) = \textsf{Concat}\Big[\textsf{Conv}(X),\textsf{MHA}(X)\Big].$$ We denote $\upsilon = \frac{d_v}{F_{out}}$ the ratio of attentional channels to number of original output filters and $\kappa = \frac{d_k}{F_{out}}$ the ratio of key depth to number of original output filters. Similarly to the convolution, the proposed attention augmented convolution 1) is equivariant to translation and 2) can readily operate on inputs of different spatial dimensions. We include Tensorflow code for the proposed attention augmented convolution in the Appendix \ref{sec:code}. \paragraph{Effect on number of parameters:} Multihead attention introduces a 1x1 convolution with $F_{in}$ input filters and $(2d_k + d_v) = F_{out} (2 \kappa + \upsilon)$ output filters to compute queries, keys and values and an additional 1x1 convolution with $d_v = F_{out} \upsilon$ input and output filters to mix the contribution of different heads. Considering the decrease in filters in the convolutional part, this leads to the following change in parameters: \begin{equation} \Delta_{params} \sim F_{in} F_{out} (2 \kappa + (1 - k^2) \upsilon + \frac{F_{out}}{F_{in}} \upsilon^2), \end{equation}\label{eq:params} where we ignore the parameters introduced by relative position embeddings for simplicity as these are negligible. In practice, this causes a slight decrease in parameters when replacing 3x3 convolutions and a slight increase in parameters when replacing 1x1 convolutions. Interestingly, we find in experiments that attention augmented networks still significantly outperform their fully convolutional counterparts while using less parameters. \paragraph{Attention Augmented Convolutional Architectures:} In all our experiments, the augmented convolution is followed by a batch normalization~\cite{BatchNorm} layer which can learn to scale the contribution of the convolution feature maps and the attention feature maps. We apply our augmented convolution once per residual block similarly to other visual attention mechanisms~\cite{hu2017squeeze,hu2018gather,park2018bam,woo2018cbam} and along the entire architecture as memory permits (see Section \ref{sec:experiments} for more details). Since the memory cost $O((N_h(HW)^2)$ can be prohibitive for large spatial dimensions, we augment convolutions with attention starting from the last layer (with smallest spatial dimension) until we hit memory constraints. To reduce the memory footprint of augmented networks, we typically resort to a smaller batch size and sometimes additionally downsample the inputs to self-attention in the layers with the largest spatial dimensions where it is applied. Downsampling is performed by applying 3x3 average pooling with stride 2 while the following upsampling (required for the concatenation) is obtained via bilinear interpolation. \section*{Acknowledgements} The authors would like to thank Tsung-Yi Lin, Prajit Ramachandran, Mingxing Tan, Yanping Huang and the Google Brain team for insightful comments and discussions. {\small \bibliographystyle{ieee_fullname} \section{Related Work} \subsection{Convolutional networks} Modern computer vision has been built on powerful image featurizers learned on image classification tasks such as CIFAR-10 \cite{krizhevsky2009learning} and ImageNet \cite{deng2009imagenet}. These datasets have been used as benchmarks for delineating better image featurizations and network architectures across a broad range of tasks \cite{kornblith2019better}. For example, improving the ``backbone'' network typically leads to improvements in object detection \cite{huang2016speed} and image segmentation \cite{chen2018searching}. These observations have inspired the research and design of new architectures, which are typically derived from the composition of convolution operations across an array of spatial scales and skip connections \cite{krizhevsky2012imagenet,szegedy2016rethinking, szegedy2016inception, szegedy2015going,identity-mappings,xie2016aggregated, he2015deep}. Indeed, automated search strategies for designing architectures based on convolutional primitives result in state-of-the-art accuracy on large-scale image classification tasks that translate across a range of tasks~\cite{zoph2018learning, kornblith2019better}. \subsection{Attention mechanisms in networks} Attention has enjoyed widespread adoption as a computational module for modeling sequences because of its ability to capture long distance interactions~\cite{bahdanau2014neural,vinyals2015ptrnet,bello2016nco,bello2018seq2slate}. Most notably, Bahdanau et al.~\cite{bahdanau2014neural} first proposed to combine attention with a Recurrent Neural Network~\cite{lstm} for alignment in Machine Translation. Attention was further extended by Vaswani et al.~\cite{vaswani2017attention}, where the self-attentional Transformer architecture achieved state-of-the-art results in Machine Translation. Using self-attention in cooperation with convolutions is a theme shared by recent work in Natural Language Processing~\cite{yang2018csan} and Reinforcement Learning~\cite{santoro2019drlrib}. For example, the QANet~\cite{yu2018qanet} and Evolved Transformer~\cite{So2019} architectures alternate between self-attention layers and convolution layers for Question Answering applications and Machine Translation respectively. Additionally, multiple attention mechanisms have been proposed for visual tasks to address the weaknesses of convolutions~\cite{hu2017squeeze,hu2018gather,chen2018double,woo2018cbam,wang2018non,han18sagan}. For instance, Squeeze-and-Excitation~\cite{hu2017squeeze} and Gather-Excite~\cite{hu2018gather} reweigh feature channels using signals aggregated from entire feature maps, while BAM~\cite{park2018bam} and CBAM~\cite{woo2018cbam} refine convolutional features \emph{independently} in the channel and spatial dimensions. In non-local neural networks~\cite{wang2018non}, improvements are shown in video classification and object detection via the additive use of a few non-local residual blocks that employ self-attention in convolutional architectures. However, non-local blocks are only added to the architecture after ImageNet pretraining and are initialized in such a way that they do not break pretraining. In contrast, our attention augmented networks do not rely on pretraining of their fully convolutional counterparts and employ self-attention along the entire architecture. The use of multi-head attention allows the model to attend \emph{jointly} to both spatial and feature subspaces. Additionally, we enhance the representational power of self-attention over images by extending relative self-attention~\cite{shaw2018self,huang2018improved} to two dimensional inputs allowing us to model translation equivariance in a principled way. Finally our method produces additional feature maps, rather than recalibrating convolutional features via addition~\cite{wang2018non,han18sagan} or gating~\cite{hu2017squeeze,hu2018gather,park2018bam,woo2018cbam}. This property allows us to flexibly adjust the fraction of attentional channels and consider a spectrum of architectures, ranging from fully convolutional to fully attentional models. \section{Experiments} \label{sec:experiments} In the subsequent experiments, we test Attention Augmentation on standard computer vision architectures such as ResNets~\cite{identity-mappings, xie2016aggregated, he2015deep}, and MnasNet~\cite{tan2018mnasnet} on the CIFAR-100 \cite{krizhevsky2009learning}, ImageNet \cite{deng2009imagenet} and COCO \cite{lin2016feature} datasets. Our experiments show that Attention Augmentation leads to systematic improvements on both image classification and object detection tasks across a broad array of architectures and computational demands. We validate the utility of the proposed two-dimensional relative attention mechanism in ablation experiments. In all experiments, we substitute convolutional feature maps with self-attention feature maps as it makes for an easier comparison against the baseline models. Unless specified otherwise, all results correspond to our two-dimensional relative self-attention mechanism. Experimental details can be found in the Appendix. \subsection{CIFAR-100 image classification} We first investigate how Attention Augmentation performs on CIFAR-100 \cite{krizhevsky2009learning}, a standard benchmark for low-resolution imagery, using a Wide ResNet architecture~\cite{wide}. The Wide-ResNet-28-10 architecture is comprised of 3 stages of 4 residual blocks each using two $3\times3$ convolutions. We augment the Wide-ResNet-28-10 by augmenting the first convolution of all residual blocks with relative attention using $N_h$=8 heads and $\kappa$=$2\upsilon$=0.2 and a minimum of 20 dimensions per head for the keys. We compare Attention Augmentation (AA) against other forms of attention including Squeeze-and-Excitation (SE) \cite{hu2017squeeze} and the parameter-free formulation of Gather-Excite (GE) \cite{hu2018gather}. Table \ref{tab:cifar100_experiments} shows that Attention Augmentation improves performance both over the baseline network and Squeeze-and-Excitation at a similar parameter and complexity cost. \begin{table}[h!] \begin{center} {\small \begin{tabular}{|l|c|c|c|c|} \hline Architecture & Params & GFlops & top-1 & top-5 \\ \hline Wide-ResNet \cite{wide} & 36.3M & 10.4 & 80.3 & 95.0 \\ GE-Wide-ResNet \cite{hu2018gather} & 36.3M & 10.4 & 79.8 & 95.0 \\ SE-Wide-ResNet \cite{hu2017squeeze} & 36.5M & 10.4 & 81.0 & 95.3 \\ AA-Wide-ResNet (ours) & 36.2M & 10.9 & 81.6 & 95.2 \\ \hline \end{tabular} } \end{center} \caption{Image classification on the CIFAR-100 dataset \cite{krizhevsky2009learning} using the Wide-ResNet 28-10 architecture \cite{wide}.} \label{tab:cifar100_experiments} \end{table} \subsection{ImageNet image classification with ResNet} \label{sec:resnet_experiments} We next examine how Attention Augmentation performs on ImageNet \cite{deng2009imagenet, kornblith2019better}, a standard large-scale dataset for high resolution imagery, across an array of architectures. We start with the ResNet architecture~\cite{identity-mappings, xie2016aggregated, he2015deep} because of its widespread use and its ability to easily scale across several computational budgets. The building block in ResNet-34 comprises two 3x3 convolutions with the same number of output filters. ResNet-50 and its larger counterparts use a bottleneck block comprising of 1x1, 3x3, 1x1 convolutions where the last pointwise convolution expands the number of filters and the first one contracts the number of filters. We modify all ResNets by augmenting the 3x3 convolutions as this decreases number of parameters.\footnote{We found that augmenting the pointwise expansions works just as well but does not save parameters or computations.} We apply Attention Augmentation in each residual block of the last 3 stages of the architecture -- when the spatial dimensions of the activation maps are 28x28, 14x14 and 7x7 -- and downsample only during the first stage. All attention augmented networks use $\kappa$=$2\upsilon$=0.2, except for ResNet-34 which uses $\kappa$=$\upsilon$=0.25. The number of attention heads is fixed to $N_h$=8. \begin{table}[h!] \begin{center} {\footnotesize \begin{tabular}{|l|c|c|c|c|} \hline Architecture & Params (M) & $\Delta_{Infer}$ & $\Delta_{Train}$ & top-1 \\ \hline ResNet-50 & 25.6 & - & - & 76.4 \\ SE \cite{hu2017squeeze} & 28.1 & +12\% & +92\% & 77.5 (77.0) \\ BAM \cite{park2018bam} & 25.9 & +19\% & +43\% & 77.3 \\ CBAM \cite{woo2018cbam} & 28.1 & +56\% & +132\% & 77.4 (77.4) \\ GALA \cite{linsley2018gala} & 29.4 & +86\% & +133\% & 77.5 (77.3) \\ \textbf{AA ($\upsilon=0.25$)} & \textbf{24.3} & \textbf{+29\%} & \textbf{+25\%} & \textbf{77.7} \\ \hline \end{tabular} } \end{center} \caption{Image classification performance of different attention mechanisms on the ImageNet dataset. $\Delta$ refers to the increase in latency times compared to the ResNet50 on a single Tesla V100 GPU with Tensorflow using a batch size of 128. For fair comparison, we also include top-1 results (in parentheses) when scaling networks in width to match $\sim25.6$M parameters as the ResNet50 baseline.} \label{tab:attention_compare} \end{table} \begin{table}[h!] \begin{center} {\small \begin{tabular}{|l|c|c|c|c|} \hline Architecture & GFlops & Params & top-1 & top-5 \\ \hline ResNet-34 \cite{identity-mappings} & 7.4 & 21.8M & 73.6 & 91.5 \\ SE-ResNet-34 \cite{hu2017squeeze} & 7.4 & 22.0M & 74.3 & 91.8 \\ AA-ResNet-34 (ours) & 7.1 & 20.7M & 74.7 & 92.0 \\ \hline ResNet-50 \cite{identity-mappings} & 8.2 & 25.6M & 76.4 & 93.1 \\ SE-ResNet-50 \cite{hu2017squeeze} & 8.2 & 28.1M & 77.5 & 93.7 \\ AA-ResNet-50 (ours) & 8.3 & 25.8M & 77.7 & 93.8 \\ \hline ResNet-101 \cite{identity-mappings} & 15.6 & 44.5M & 77.9 & 94.0 \\ SE-ResNet-101 \cite{hu2017squeeze} & 15.6 & 49.3M & 78.4 & 94.2 \\ AA-ResNet-101 (ours) & 16.1 & 45.4M & 78.7 & 94.4 \\ \hline ResNet-152 \cite{identity-mappings} & 23.0 & 60.2M & 78.4 & 94.2 \\ SE-ResNet-152 \cite{hu2017squeeze} & 23.1 & 66.8M & 78.9 & 94.5 \\ AA-ResNet-152 (ours) & 23.8 & 61.6M & 79.1 & 94.6 \\ \hline \end{tabular} } \end{center} \caption{Image classification on the ImageNet dataset \cite{deng2009imagenet} across a range of ResNet architectures: ResNet-34, ResNet-50, Resnet-101, and ResNet-152 \cite{identity-mappings, xie2016aggregated, he2015deep}. } \label{tab:resnet_experiments} \end{table} Table \ref{tab:attention_compare} benchmarks Attention Augmentation against \emph{channel and spatial attention} mechanisms BAM~\cite{park2018bam}, CBAM~\cite{woo2018cbam} and GALA~\cite{linsley2018gala} with channel reduction ratio $\sigma=16$ on the ResNet50 architecture. Despite the lack of specialized kernels (See Appendix \ref{sec:code}), Attention Augmentation offers a competitive accuracy/computational trade-off compared to previously proposed attention mechanisms. Table~\ref{tab:resnet_experiments} compares the non-augmented networks and Squeeze-and-Excitation (SE)~\cite{hu2017squeeze} across different network scales. In all experiments, Attention Augmentation significantly increases performance over the non-augmented baseline and notably outperforms Squeeze-and-Excitation (SE)~\cite{hu2017squeeze} while being more parameter efficient (Figure~\ref{fig:marketing}). Remarkably, our AA-ResNet-50 performs comparably to the baseline ResNet-101 and our AA-ResNet-101 outperforms the baseline ResNet-152. These results suggest that attention augmentation is preferable to simply making networks deeper. We include and discuss attention maps visualizations from different pixel positions in the appendix. \subsection{ImageNet classification with MnasNet} \begin{table}[t!] \begin{center} {\small \begin{tabular}{|l|c|c|c|c|} \hline Architecture & GFlops & Params & top-1 & top-5 \\ \hline MnasNet-0.75 & 0.45 & 2.91M & 73.3 & 91.3 \\ AA-MnasNet-0.75 & 0.51 & 3.02M & 73.9 & 91.6 \\ \hline MnasNet-1.0 & 0.63 & 3.89M & 75.2 & 92.4 \\ AA-MnasNet-1.0 & 0.70 & 4.06M & 75.7 & 92.6 \\ \hline MnasNet-1.25 & 1.01 & 5.26M & 76.7 & 93.2 \\ AA-MnasNet-1.25 & 1.11 & 5.53M & 77.2 & 93.6 \\ \hline MnasNet-1.4 & 1.17 & 6.10M & 77.2 & 93.5 \\ AA-MnasNet-1.4 & 1.29 & 6.44M & 77.7 & 93.8 \\ \hline \end{tabular} } \end{center} \caption{Baseline and attention augmented MnasNet \cite{tan2018mnasnet} accuracies with width multipliers 0.75, 1.0, 1.25 and 1.4.} \label{tab:MnasNet_experiments} \end{table} \begin{table*}[t!] \begin{center} \begin{tabular}{|l|c|c|c|c|c|} \hline Backbone architecture & GFlops & Params & mAP$_{\sf COCO}$ & mAP$_{50}$ & mAP$_{75}$ \\ \hline ResNet-50 \cite{lin2017focal} & 182 & 33.4M & 36.8 & 54.5 & 39.5 \\ SE-ResNet-50 \cite{hu2017squeeze} & 183 & 35.9M & 36.5 & 54.0 & 39.1 \\ AA-ResNet-50 (ours) & 182 & 33.1M & 38.2 & 56.5 & 40.7 \\ \hline ResNet-101 \cite{lin2017focal} & 243 & 52.4M & 38.5 & 56.4 & 41.2 \\ SE-ResNet-101 \cite{hu2017squeeze} & 243 & 57.2M & 37.4 & 55.0 & 39.9 \\ AA-ResNet-101 (ours) & 245 & 51.7M & 39.2 & 57.8 & 41.9 \\ \hline \end{tabular} \end{center} \caption{Object detection on the COCO dataset \cite{lin2014microsoft} using the RetinaNet architecture \cite{lin2017focal} with different backbone architectures. We report mean Average Precision at three different IoU values.} \label{tab:retinanet_experiments} \end{table*} In this section, we inspect the use of Attention Augmentation in a resource constrained setting by conducting ImageNet experiments with the MnasNet architecture~\cite{tan2018mnasnet}, which is an extremely parameter-efficient architecture. In particular, the MnasNet was found by neural architecture search~\cite{zoph2017neural}, using only the highly optimized mobile inverted bottleneck block~\cite{sandler2018mobilenetv2} and the Squeeze-and-Excitation operation~\cite{hu2017squeeze} as the primitives in its search space. We apply Attention Augmentation to the mobile inverted bottleneck by replacing convolutional channels in the expansion pointwise convolution using $\kappa$=$2\upsilon$=0.1 and $N_h$=4 heads. Our augmented MnasNets use augmented inverted bottlenecks in the last 13 blocks out of 18 in the MnasNet architecture, starting when the spatial dimension is 28x28. We downsample only in the first stage where Attention Augmentation is applied. We leave the final pointwise convolution, also referred to as the ``head", unchanged. In Table \ref{tab:MnasNet_experiments}, we report ImageNet accuracies for the baseline MnasNet and its attention augmented variants at different width multipliers. Our experiments show that Attention Augmentation yields accuracy improvements across all width multipliers. Augmenting MnasNets with relative self-attention incurs a slight parameter increase, however we verify in Figure \ref{fig:MnasNet_params_curve} that the accuracy improvements are not just explained by the parameter increase. Additionally, we note that the MnasNet architecture employs Squeeze-and-Excitation at multiple locations that were optimally selected via architecture search, further suggesting the benefits of our method. \begin{figure}[t!] \centering \includegraphics[width=1.0\columnwidth]{{figures/MNAS-vs-Params.pdf}} \caption{ImageNet top-1 accuracy as a function of number of parameters for MnasNet (black) and Attention-Augmented-MnasNet (red) with width multipliers $0.75$, $1.0$, $1.25$ and $1.4$.} \label{fig:MnasNet_params_curve} \end{figure} \subsection{Object Detection with COCO dataset} We next investigate the use of Attention Augmentation on the task of object detection on the COCO dataset~\cite{lin2014microsoft}. We employ the RetinaNet architecture with a ResNet-50 and ResNet-101 backbone as done in \cite{lin2017focal}, using the opensourced RetinaNet codebase.\footnote{\url{https://github.com/tensorflow/tpu/tree/master/models/official/retinanet}} We apply Attention Augmentation uniquely on the ResNet backbone, modifying them similarly as in our ImageNet classification experiments. Our relative self-attention mechanism improves the performance of the RetinaNet on both ResNet-50 and ResNet-101 as shown in Table~\ref{tab:retinanet_experiments}. Most notably, Attention Augmentation yields a 1.4\% mAP improvement over a strong RetinaNet baseline from~\cite{lin2017focal}. In contrast to the success of Squeeze-and-Excitation in image classification with ImageNet, our experiments show that adding Squeeze-and-Excitation operators in the backbone network of the RetinaNet significantly hurts performance, in spite of grid searching over the squeeze ratio $\sigma \in \{4, 8, 16\}$. We hypothesize that localization requires precise spatial information which SE discards during the spatial pooling operation, thereby negatively affecting performance. Self-attention on the other hand maintains spatial information and is likely to be able to identify object boundaries successfully. Visualizations of attention maps (See Figures~\ref{fig:input_image} and~\ref{fig:visualization} in the Appendix) reveal that some heads are indeed delineating objects from their background which might be important for localization. \subsection{Ablation Study} \label{sec:ablation} \paragraph{Fully-attentional vision models:} In this section, we investigate the performance of Attention Augmentation as a function of the fraction of attentional channels. As we increase this fraction to 100\%, we begin to replace a ConvNet with a fully attentional model, only leaving pointwise convolutions and the stem unchanged. Table \ref{tab:ablation_experiments} presents the performance of Attention Augmentation on the ResNet-50 architecture for varying ratios $\kappa$=$\upsilon$ $\in \{0.25, 0.5, 0.75, 1.0\}$. Performance slightly degrades as the ratio of attentional channels increases, which we hypothesize is partly explained by the average pooling operation for downsampling at the first stage where Attention Augmentation is applied. Attention Augmentation proves however quite robust to the fraction of attentional channels. For instance, AA-ResNet-50 with $\kappa$=$\upsilon$=0.75 outperforms its ResNet-50 counterpart, while being more parameter and flops efficient, indicating that mostly employing attentional channels is readily competitive. Perhaps surprisingly, these experiments also reveal that our proposed self-attention mechanism is a powerful stand-alone computational primitive for image classification and that fully attentional models are viable for discriminative visual tasks. In particular, AA-ResNet-50 with $\kappa$=$\upsilon$=1, which uses exclusively attentional channels, is only 2.5\% worse in accuracy than its fully convolutional counterpart, in spite of downsampling with average pooling and having 25\% less parameters. Notably, this fully attentional architecture\footnote{We consider pointwise convolutions as dense layers. This architecture employs 4 non-pointwise convolutions in the stem and the first stage of the architecture, but we believe such operations can be replaced by attention too.} also outperforms ResNet-34 while being more parameter and flops efficient (see Table \ref{tab:ablation_experiments}). \begin{table}[h!] \begin{center} \begin{tabular}{|l|c|c|c|c|} \hline Architecture & GFlops & Params & top-1 & top-5 \\ \hline ResNet-34 \cite{identity-mappings} & 7.4 & 21.8M & 73.6 & 91.5 \\ ResNet-50 \cite{identity-mappings} & 8.2 & 25.6M & 76.4 & 93.1 \\ \hline $\kappa=\upsilon=0.25$ & 7.9 & 24.3M & 77.7 & 93.8 \\ $\kappa=\upsilon=0.5$ & 7.3 & 22.3M & 77.3 & 93.6 \\ $\kappa=\upsilon=0.75$ & 6.8 & 20.7M & 76.7 & 93.2 \\ $\kappa=\upsilon=1.0$ & 6.3 & 19.4M & 73.9 & 91.5 \\ \hline \end{tabular} \end{center} \caption{Attention Augmented ResNet-50 with varying ratios of attentional channels.} \label{tab:ablation_experiments} \end{table} \begin{figure}[t!] \centering \includegraphics[width=1.0\columnwidth]{{figures/Fraction-Of-Attention.pdf}} \caption{Effect of relative position embeddings as the ratio of attentional channels increases on our Attention-Augmented ResNet50.} \label{fig:ablation} \end{figure} \paragraph{Importance of position encodings:} In Figure \ref{fig:ablation}, we show the effect of our proposed two-dimensional relative position encodings as a function of the fraction of attentional channels. As expected, experiments demonstrate that our relative position encodings become increasingly more important as the architecture employs more attentional channels. In particular, the fully self-attentional ResNet-50 gains 2.8\% top-1 ImageNet accuracy when using relative position encodings, which indicates the necessity of maintaining position information for fully self-attentional vision models. We additionally compare our proposed two-dimensional relative position encodings to other position encoding schemes. We apply Attention Augmentation using the same hyperparameters as \ref{sec:resnet_experiments} with the following different position encoding schemes: 1) The position-unaware version of self-attention (referred to as \textit{None}), 2) a two-dimensional implementation of the sinusoidal positional waves (referred to as \textit{2d Sine}) as used in~\cite{parmar2018image}, 3) CoordConv~\cite{liu2018intriguing} for which we concatenate (x,y,r) coordinate channels to the inputs of the attention function, and 4) our proposed two-dimensional relative position encodings (referred to as \textit{Relative}). \begin{table}[t!] \begin{center} \begin{tabular}{|c|c|c|c|c|} \hline Architecture & Position Encodings & top-1 & top-5 \\ \hline AA-ResNet-34 & None & 74.4 & 91.9 \\ AA-ResNet-34 & 2d Sine & 74.4 & 92.0 \\ AA-ResNet-34 & CoordConv & 74.4 & 92.0 \\ AA-ResNet-34 & Relative (ours) & 74.7 & 92.0 \\ \hline AA-ResNet-50 & None & 77.5 & 93.7 \\ AA-ResNet-50 & 2d Sine & 77.5 & 93.7 \\ AA-ResNet-50 & CoordConv & 77.5 & 93.8 \\ AA-ResNet-50 & Relative (ours) & 77.7 & 93.8 \\ \hline \end{tabular} \end{center} \caption{Effects of different position encodings in Attention Augmentation on ImageNet classification.} \label{table:resnet-ablation} \end{table} \begin{table}[t!] \begin{center} \begin{tabular}{|l|c|c|c|c|c|} \hline Position Encodings & mAP$_{\sf COCO}$ & mAP$_{50}$ & mAP$_{75}$ \\ \hline None & 37.7 & 56.0 & 40.2 \\ CoordConv \cite{liu2018intriguing} & 37.4 & 55.5 & 40.1 \\ Relative (ours) & 38.2 & 56.5 & 40.7 \\ \hline \end{tabular} \end{center} \caption{Effects of different position encodings in Attention Augmentation on the COCO object detection task using a RetinaNet AA-ResNet-50 backbone.} \label{table:detection-ablation} \end{table} In Table \ref{table:resnet-ablation} and \ref{table:detection-ablation}, we present the results on ImageNet classification and the COCO object detection task respectively. On both tasks, Attention Augmentation without position encodings already yields improvements over the fully convolutional non-augmented variants. Our experiments also reveal that the sinusoidal encodings and the coordinate convolution do not provide improvements over the position-unaware version of Attention Augmentation. We obtain additional improvements when using our two-dimensional relative attention, demonstrating the utility of preserving translation equivariance while preventing permutation equivariance.
{'timestamp': '2020-09-11T02:02:06', 'yymm': '1904', 'arxiv_id': '1904.09925', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.09925'}
arxiv
\section{Introduction} Facial expression and its behavior is one of the most crucial channels for emotional communication between individuals. Intelligent facial expression analysis has recently attracted wide research interest due to its potential applications in the field of human-robot interaction and computer vision. As defined in the Facial Action Coding System (FACS)~\cite{friesen1978facial}, which is the most widely used and versatile method for measuring and describing facial behaviors, the facial action units (AUs) refer to the local facial muscle actions and plays a paramount role in expressing comprehensive facial expressions. AU recognition has thus become a long-standing research topic in the field of artificial intelligence and computer vision~\cite{li2017eac,li2017action,zhao2016deep}. Facial action unit recognition has been mainly treated as a multi-label classification problem that is independent of each other. Most of the traditional methods focus on the design of more discriminative hand-crafted features~(e.g. shape or appearance features) or more effective discriminative learning methods~\cite{valstar2006fully,zhao2015joint,jiang2011action}. In recent years, deep convolutional neural networks have been widely used in AU recognition due to their powerful feature representation and end-to-end efficient learning scheme, and have greatly promoted the development of this field~\cite{zhao2016deep,li2017action,bishay2017fusing,chu2016modeling}. However, recent efforts based on deep convolutional neural networks are indulged in designing deeper and more complex network structures without exception, learning more robust feature representations in a data-driven manner without explicitly considering and modeling the local characteristics of the facial organs and the linkage relationship between the facial muscles. As a common sense, facial action units are not independent from one another, considering the linkage of a same facial expression to multiple action units and the anatomical characteristics of faces. As shown in Fig.~\ref{fig:teaser}, a happiness expression activates both AU6 and AU12, as we generally ``raise cheek'' and ``pull lip corners'' when we smile. On the other hand, due to structural limitations of facial anatomy, some action units are generally not likely to be activated simultaneously. For instance, we can not simultaneously stretch our mouth and raise our cheek. Base on the above concerns, some of the research works propose to improve the AU recognition based on the AU relationship modeling. For example, Tong et al.~\cite{tong2007facial} proposed to apply a dynamic Bayesian network (DBN) to model the relationships among different AUs, Wang et al.~\cite{wang2013capturing} developed a more complex model based on restricted Boltzmann machine~(RBM) to exploit the global relationships among AUs and Chu et al.~\cite{ginosar2015century} recently proposed to model both the spatial and temporal prior cues for more accurate facial AU detection. However, existing AU relationship based recognition methods have the following three shortcomings. First of all, existing AU relationship modeling are designed based on handcrafted low level features and are applied as a post-processing or embedded as a priori rule into complex classification models, usually in isolation with the feature representation, and are hence limited to the performance of feature extraction. Secondly, existing methods only attempt to capture local pair-wise AU dependencies based on limited facial expressions observation. This pair-wise data is not combined to form a graph structure for more comprehensive AU relationship reasoning. Last but not the least, since the AU relationship modeling relies on the preamble feature extraction, the whole algorithm framework can not be run end-to-end, which greatly restricts the model efficiency and the performance of the method. Moreover, existing end-to-end deep learning based models also have not explicitly considered the AU relationship in their model design. Taking into account the above shortcomings and being inspired by the differentiability of the graph neural network and its superior performance in the entity relationships learning, we propose an AU semantic relationship embedded representation learning (SRERL) framework to gradually enhance the regional facial feature by fully exploiting the structural collaboration between AUs. Specifically, we organize the facial action units in the form of structured knowledge-graph and propose to integrate a Gated Graph Neural Network (GGNN)~\cite{li2015gated} in a multi-scale CNN framework to propagate node information through the graph. As the proposed network framework is able to embed the globally structured relationships between AUs in the learning process of features in an end-to-end fashion, the learned feature thus involves both the appearance characteristics and the AU relationship reasoning and is more robust towards more challenging cases, e.g., illumination change and partial occlusion. In summary, this paper has the following contributions: \begin{itemize} \item This work formulates a novel AU semantic relationship embedded representation learning framework which incorporate AU knowledge-graph as an extra guidance for the enhancement of facial region representation. To the best of our knowledge, we are the first to employ graph neural network for AU relationship modeling. \item With the guidance of AU knowledge-graph and the differentiable attributes of the gated graph neural network, we are able to collaboratively learn the appearance representation of each facial region and the structured semantic propagation between AUs in an end-to-end fashion. \item We conduct extensive experiments on the widely used BP4D and DISFA datasets and demonstrate the superiority of the proposed SRERL framework over the state-of-the-art facial AU recognition methods. \end{itemize} \section{Related Work} Automatic facial action unit recognition has attracted widespread research interest and achieved great progress in recent years. The existing AU recognition methods can be roughly divided into robust feature representation based methods and semantic relationship modeling based methods. Traditional feature representation based AU recognition methods focus on the design of more discriminative hand-crafted features. For instance, Valstar et al \cite{valstar2006fully} proposed to analyze the temporal behavior of action units in video and used individual feature GentleBoost templates built from Gabor wavelet features for SVM based AU classification. Baltrusaitis et al~\cite{baltruvsaitis2015cross} designed a facial AU intensity estimation and occurrence detection system based on the fusion of appearance and geometry features. However, these hand-crafted low level feature based algorithms are relatively fragile and difficult to deal with various types of complex situations. In recent years, deep convolutional neural networks have been widely used in a variety of computer vision tasks and have achieved unprecedented progress~\cite{he2016deep,li2018contrast,li2017instance,liu2018facial}. There are also attempts to apply deep CNN to facial AU recognition~\cite{zhao2016deep,li2017action,bishay2017fusing,chu2016modeling}. Zhao et al~\cite{zhao2016deep} proposed a unified architecture for facial AU detection which incorporates a deep regional feature learning and multi-label learning modules. Li et al \cite{li2017action} proposed an ROI framework for AU detection by cropping CNN feature maps with facial landmarks information. However, non of these methods explicitly take into consideration the linkage relationship between different AUs. \begin{figure*}[t] \begin{center} \includegraphics[width=1.80\columnwidth]{./fig2-v2} \end{center} \caption{An overall pipeline of our proposed AU semantic relationship embedded representation learning~(SRERL) framework. It is composed of a multiscale feature learning and cropping module followed by a GGNN for node information propagation. } \label{fig:framework} \vspace*{-7pt} \end{figure*} Considering the linkage effect of facial expressions on various AUs and the anatomical attribute of facial regions, there are research works which rely on action unit relationship modeling to help improve recognition accuracy. Tong et al.~\cite{tong2007facial} proposed a dynamic Bayesian network (DBN) to model relationships between AUs. Wang et al.~\cite{wang2013capturing} further developed a three-layer Restrict Boltzmann Machine~(RBM) to exploit the global relationships between AUs. However, these early works simply model the AU relations from target labels and are independent with feature representation. Wu et al.~\cite{wu2016multiple} proposed a 4-layer RBM to simultaneously capture both feature level and label level dependencies for AU detection. As they are based on handcrafted low level features, the whole algorithm framework can not be performed end-to-end, which greatly restricts the model efficiency and the performance of the method. Recently, Corneanu et al.~\cite{corneanu2018deep} proposed a deep structured inference network (DSIN) for AU recognition which used deep learning to extract image features and structure inference to capture AU relations by passing information between predictions in an explicit way. However, the relationship inference part of DSIN also works as a post-processing step at label level and is isolated with the feature representation. \section{Method} In this section, we introduce our semantic relationship embedded representation learning framework in detail. Firstly, we briefly review the gated graph neural network~(GGNN) and introduce the construction of the AU relationship graph, which will work as a guided knowledge-graph for GGNN propagation in our framework. Then, we present the structure of our proposed SRERL framework. The overall pipeline of our framework is illustrated in Figure~\ref{fig:framework}. \subsection{Preliminary: Gated Graph Neural Network~\cite{li2015gated}} Given a graph with $N$ nodes and the initial representation of each node, the idea of GGNN is to generate an output for each graph node or a global output, by learning a propagation model similar to LSTM. Specifically, denote the node set as $V$ and its corresponding adjacency matrix $A$. For each node $v \in V$, we define a hidden state representation $h^{t}_{v}$ at every time step $t$. When $t=0$, the hidden state representation is set as the initial node feature $x_{v}$. Adjacency matrix $A$ encodes the structure of the graph. The basic recurrent process of GGNN is formulated as \begin{equation} h^{(1)}_{v} = [x^{T}_{v}, 0 ] \label{equation:init} \end{equation} \begin{equation} a^{(t)}_{v} = A^T_v [h^{(t-1)}_{1} \cdots h^{(t-1)}_{|V|}] ^{T} + b \label{equation:update1} \end{equation} \begin{equation}\label{equ:3} z^{t}_{v} = \sigma(W^{z} a^{(t)}_{v}+U^{z} h^{(t-1)}_{v}) \end{equation} \begin{equation} r^{t}_{v} = \sigma(W^{r} a^{(t)}_{v}+U^{r} h^{(t-1)}_{v}) \end{equation} \begin{equation} \widetilde{h^{t}_{v}} = tanh(Wa^{(t)}_{v} + U(r^{t}_{v} \odot h^{(t-1)}_{v})) \end{equation} \begin{equation}\label{equation:update2} h^{(t)}_{v} = (1-z^{t}_{v}) \odot h^{(t-1)}_{v} + z^{t}_{v} \odot \widetilde{h^{t}_{v}} \end{equation} where $A_{v}$ is a sub-matrix of $A$ which refers to the adjacency matrix for node $v$. $W$ and $U$ are learned parameters. $sigma$ and $tanh$ are the logistic sigmoid and hyperbolic tangent functions. $\odot$ means element-wise multiplication operation. The essence of the iterative update of GGNN evolution is to compute the hidden state of next time-step by looking into the combination of the current hidden state of each node and its adjacent information, as shown in Eq~(\ref{equ:3}-\ref{equation:update2}). After $T$ time steps, we get the final hidden states. Then the node-level output can be computed as follow \begin{equation} o^{v} = g(h^{(T)}_{v}, x_{v}) \label{equation:output} \end{equation} where $x_{v}$ is the annotation of node $v$, function $g$ is a fully connected network. \subsection{Preliminary: AU Relationship Graph Construction} AU relationship graph represents the globally structured relationships between AUs, which is composed of a node set $V$ and an edge set $E$. Specifically, each node $v\in V$ represents a specific AU and the edges represent the correlations between AUs in our graph. The graph is constructed based on the AU relationship gathered from the training set and some supplementary a priori connections (from common facial expressions and facial anatomy analysis). We detail the construction of $V$ and $E$ as follow, \begin{figure}[t] \centerline{ \includegraphics[width=0.45\columnwidth]{./au_location.pdf} \hfill \includegraphics[width=0.45\columnwidth]{./knowledge-graph.pdf} } \caption{The location of facial AUs and the constructed AU relationship graph.} \label{fig:knowledge-graph} \end{figure} \subsubsection{Node Set $V$:} Each node in graph represents a corresponding AU. Given a dataset that covers $C$ AUs, the constructed graph is formed by a node set $V$ containing $C$ entities. \subsubsection{Edge Set $E$:} According to FACS \cite{friesen1978facial}, there exists strong relationship between AUs due to the linkage of each facial expression to multiple action units and the anatomical characteristics of faces. The relationship can further be divided into positive and negative ones, where positive correlation means that two AUs are likely to co-occur while negative correlation refers to that the two rarely appear together. We capture most of the AU relationship by calculating the conditional probability on the training samples, which is formulated as \begin{equation} \begin{split} a\_\text{pos}_{i,j} = [P(y_{i}=1 | y_{j}=1)- P(y_{i}=1) > p_{\text{pos}}], \label{equation:A_p} \end{split} \end{equation} \begin{equation} \begin{split} a\_\text{neg}_{i,j} = [P(y_{i}=1 | y_{j}=1) - P(y_{i}=1) < p_{\text{neg}}] \label{equation:A_n}, \end{split} \end{equation} where $y_{n}$ denote the $n$-th AU label. $p_{\text{pos}}$ and $p_{\text{neg}}$ is the threshold for positive and negative relationship, respectively. $a\_\text{pos}_{i,j} \in A_\text{pos}$ and $a\_\text{neg}_{i,j} \in A_\text{neg}$. Thus, we can generate the adjacency matrix of AU relationship graph with the positive relationship matrix $A_{pos}$ and negative relationship matrix $A_{\text{neg}}$, $i.e.$, $A=[A_\text{pos} -I(A),-A_\text{neg},(A_\text{pos} - I(A))^{T},-A_\text{neg}^{T}]$. $I(A)$ denotes the identity matrix of the same dimension as $A$. However, due to the limitation of dataset, there are still a few common relationships that are not counted. Referring to the latest research on AU relations~\cite{zhang2018classifier}, we add some additional relationships. Specifically, we add (AU4, AU7), (AU15, AU24) as positive correlation and (AU2, AU6), (AU12, AU15), (AU12, AU17) as negative correlation for BP4D dataset~\cite{zhang2013high}. These relationship are summarized in Figure~\ref{fig:knowledge-graph}, where green lines represent positive correlation and red lines represent negative ones. For clarity, we use a line with arrow to represent a one-way relationship and a line without arrows to represent a two-way relationship. \subsection{Relationship-Embedded Representation Learning} As shown in Fig.~\ref{fig:framework}, our proposed SRERL framework is composed of a multiscale CNN based feature learning and cropping module followed by a GGNN for node information propagation. The GGNN takes as input the cropped facial region feature and propagate on the defined knowledge-graph to learn relationship-embed AU feature representation. We elaborate these two components in the following. \subsubsection{Multiscale Feature Learning and Cropping} We choose the VGG19~\cite{simonyan2014very} model as our backbone network, which is composed of 5 groups of convolutional layers with down-sampling. For the sake of the trade-off between feature performance and its resolution, we use the first 4 groups of convolutional layers for initial appearance feature extraction. The input to the feature extractor is a $224 \times 224$ RGB facial image with its landmarks information. Since the size of the relevant regions of each AU varies~(e.g. the area corresponding to AU6 ``Cheek Raiser'' is larger than that of AU12 ``Lip Corner Puller''), we concatenate the output feature maps of all the four groups~(all resized to $14\times 14$) to form a multiscale global feature. The concatenated feature maps are further fed into a local response normalization layer which could normalize pixels between channels and help to converge. The formulation is given as \begin{equation} b_{c} = \frac{a_{c}}{(k + \frac{\alpha \times C}{n} \sum^{min(C-1, c+n/2)}_{c^{'}=max(0,c-n/2)} a^{2}_{c^{'}})^{\beta}}, \label{equation:lrn} \end{equation} where $k$, $\alpha$, $\beta$ are hyperparameters, $C$ represents the channel number of the feature maps. $a_{c}$ denotes the pixel in $c^{th}$ channel and $n$ is set to $2$ which refers to the number of neighboring channels chosen to normalize the pixel $a_{c}$. Then we crop out each AU region according to facial landmarks, which is further fed into separate region learning stream for each local AU feature representation. Specifically, we capture adaptive AU region by resorting to facial landmarks. Since there exists relationship between facial anatomy region and AUs, we can generate the location of each AU center, which is further corresponded to the closest facial landmark. After getting the representative landmark of each facial AU, we crop a $6 \times 6$ region from the concatenated global feature maps for its initial regional feature. Figure \ref{fig:knowledge-graph} illustrates the correspondence between facial AUs and facial landmarks. We further refer to \cite{li2017action} and adopt separate filters in each cropped AU region to train its representation separately. Suppose we have $C$ AUs. Due to the symmetry of the face, we obtain $2C$ patch-wise feature maps~( each AU corresponds to two patches), and design $2C$ independent regional feature learning branches. For each individual region learning branch, we use a $3\times3$ convolutional layer and a fully connected layer to learn the specific local representation. These convolutional layers and fully connected layers are trained separately, which could help to avoid information interference between different AU regions caused by varies scales of receptive fields. \subsection{Balanced Loss Function} Data imbalance is a common problem in AU recognition, especially during multi-label training. However, due to the ensemble training setting of multiple classification units, it is hard to apply effective undersampling or oversampling strategies to balance the data bias. In this work, we design an adaptive loss function for imbalanced data training. \begin{equation} \begin{split} loss = -\frac{1}{C \cdot N} \sum_{j=1}^{N} \sum_{i=1}^{C} 2 \{ r^{i}_{\text{neg}} [l^{i}_{j}=1] \cdot \\ log(\frac{p^{i}_{j}+0.05}{1.05}) + r^{i}_{\text{pos}}[l^{i}_{j}=0] log(\frac{1.05-p^{i}_{j}}{1.05}) \} \label{equation:loss_cnn} \end{split} \end{equation} \begin{equation} r^{i}_{\text{pos}} = \frac{\sum_{k=1}^{M}[l^{i}_{k}=1]}{M} \end{equation} \begin{equation} r^{i}_{\text{neg}} = 1-r^{i}_{\text{pos}} \end{equation} where $l$ is the ground truth and $p$ is the probability predicted by our method. $[x]$ is an indicator function which returns $1$ when the statement $x$ is true, and $0$ otherwise. Let $C$ denote the number of AUs, and $N$ denote the batch size. $r^{i}_{\text{pos}}$ and $r^{i}_{\text{neg}}$ are constant, which indicate the proportion of positive samples or negative samples in the training set. $M$ denotes the number of samples in the training set. \subsubsection{GGNN for Action Unit Detection} As shown in Figure~\ref{fig:framework}, we generate the initial local feature of $2C$ regions using our tailored multiscale feature learning and cropping module. Let $f_{i}$ denotes the feature of a specific AU region, $i \in [0,1,2,…,2C-1]$. Considering the symmetry of a human face, each AU corresponds to two specific regions. The initial feature of each node in GGNN is thus given as \begin{equation} x_{v}= \frac{f_{2v} \oplus f_{2v+1}}{2} \end{equation} where $\oplus$ denotes element-wise summation. According to Equation \ref{equation:init}, the hidden state vector is initialized with the corresponding feature $x_{v}$. At each time-step $t$, the hidden state can be updated according to Eq~\ref{equation:update1}$-$\ref{equation:update2}. Finally, the output of each node in GGNN can be computed using Eq~\ref{equation:output}, which is further concatenated for final label prediction. \section{Experimental Results} \subsection{Datasets} We evaluated our model on two spontaneous dataset: BP4D\cite{zhang2013high} and DISFA\cite{mavadati2013disfa}. BP4D contains 2D and 3D facial expression data of 41 young adult subjects, including 18 male and 23 female. Each subject participated in 8 tasks, each of which corresponds to a specific expression. There are totally 146,847 face images with labeled AUs. We refer to~\cite{zhao2016deep} and split the dataset into 3 folds. In which, we take turns to use two folds for training and the other for testing, and report the average results of multiple tests. DISFA contains stereo videos of 27 subjects with different ethnicity. There are totally 130,815 frame images, each of which is labeled with intensities from 0-5. We choose frames with AU intensities higher or equal to C-level as positive samples, and the rest as negative samples. $C$ is chosen as $2$ in our experiment. As with BP4D, we also split the dataset into 3 folds for reliable testing. We use VGG19 model trained on BP4D to directly extract initial appearance feature, and finetune the parameters of separate region learning module and GGNN in DISFA. \subsection{Evaluation Criteria} We evaluate our method with two metrics, including F1 score and AUC. F1 score takes into consideration both the precision $p$ and the recall $r$ , and is widely used in binary classification. F1 score can be computed as $F1=2\frac{p \cdot r}{p+r}$, and AUC refers to the area under the ROC curve. \subsection{Implementation Details} During the knowledge-graph construction, we set $p_\text{pos}$ as $0.2$ and $p_\text{neg}$ as $-0.03$ in Eq~(\ref{equation:A_p}$-$\ref{equation:A_n}), and set $\alpha=0.002$, $\beta=0.75$, $k=2$ in Eq~\ref{equation:lrn}. We use an Adam optimizer with learning rate of 0.0001 and mini-batch size 64 with early stopping to train our models. For F1-score, we set the threshold of prediction to 0.5. All models are trained using NVIDIA GeForce GTX TITAN X GPU based on the open-source Pytorch platform~\cite{paszke2017automatic}. \subsection{Ablation Studies} \label{result} \begin{table*} \centering \resizebox{1.65\columnwidth}{!} { \begin{tabular}{c|cccccccccccc} \toprule AU&1&2&4&6&7&10&12&14&15&17&23&24\\ \midrule positive samples ratio&0.21&0.17&0.20&0.46&0.55&0.59&0.56&0.47&0.17&0.34&0.17&0.15\\ \bottomrule \end{tabular} } \caption{Data distribution of BP4D dataset} \label{tab:ratio} \end{table*} \begin{table*} \centering \resizebox{1.65\columnwidth}{!} { \begin{tabular}{c|ccccc|ccccc} \toprule \multirow{2}{*}{AU} & \multicolumn{5}{c}{F1-score} & \multicolumn{5}{c}{AUC}\cr \cmidrule(lr){2-6} \cmidrule(lr){7-11} &VGG&VGG\_BL&SS\_RL&MS\_RL&SRERL&VGG&VGG\_BL&SS\_RL&MS\_RL&SRERL\cr \midrule 1& 37.3& 41.6& \textbf{47.1}& 46.6& [46.9] &61.4 &63.1 &[67.5] &66.9 &\textbf{67.6}\cr 2& 32.7& 41.4& 42.9& [44.3]& \textbf{45.3} &59.8 &65.4 &67.9 &[68.6] &\textbf{70.0}\cr 4& 52.3& 44.1& 51.5& [53.1]& \textbf{55.6} &70.6 &65.5 &70.8 &[72.1] &\textbf{73.4}\cr 6& 76.2& 76.4& 76.7& \textbf{77.3}& [77.1] &\textbf{78.5} &78.2 &78.2 &[78.4] &[78.4]\cr 7& 75.7& 73.3& [77.2]& 76.8& \textbf{78.4} &74.1 &73.5 &[75.8] &75.2 &\textbf{76.1}\cr 10& 82.3& 81.2& 82.7& \textbf{83.8}& [83.5] &78.9 &78.8 &[80.4] &\textbf{80.9} &80.0\cr 12& 86.9& 86.0& [87.1]& 86.8& \textbf{87.6} &84.8 &85.5 &[85.7] &85.2 &\textbf{85.9}\cr 14& 55.9& \textbf{64.0}& 62.3& 61.9& [63.9] &61.7 &\textbf{64.5} &64.3 &[64.4] &[64.4]\cr 15& 37.2& 46.7& 49.4& [51.1]& \textbf{52.2} &61.7 &70.2 &71.2 &[73.1] &\textbf{75.1}\cr 17& 57.2& 61.7& 61.6& [63.7]& \textbf{63.9} &68.2 &70.1 &70.3 &[71.4] &\textbf{71.7}\cr 23& 29.4& 40.7& [46.2]& 45.6& \textbf{47.1} &58.5 &66.6 &70.9 &[71.1] &\textbf{71.6}\cr 24& 41.7& 51.6& \textbf{53.8}& 53.2& [53.3] &64.7 &\textbf{76.4} &75.3 &[76.0] &74.6\cr \midrule Avg&55.4& 59.1& 61.5& [62.0]& \textbf{62.9} &68.6 &71.5 &73.2 &[73.6] &\textbf{74.1}\cr \bottomrule \end{tabular} } \caption{Ablation study on the BP4D dataset. It demonstrates the effectiveness of balanced loss design, multiscale CNN as well as relationship-embed feature representation} \label{tab:ablations_bp4d} \end{table*} \begin{table} \center \resizebox{0.90\columnwidth}{!} { \begin{tabular}{c|cc|cc} \toprule \multirow{2}{*}{AU} & \multicolumn{2}{c}{F1-score} & \multicolumn{2}{c}{AUC}\cr \cmidrule(lr){2-3} \cmidrule(lr){4-5} &MS\_RL&SRERL&MS\_RL&SRERL\cr \midrule 1& 39.7& \textbf{45.7} &\textbf{76.4} &76.2\cr 2& 44.5& \textbf{47.8} &80.8 &\textbf{80.9}\cr 4& 52.4& \textbf{59.6} &74.9 &\textbf{79.1}\cr 6& 44.7& \textbf{47.1} &77.8 &\textbf{80.4}\cr 9& 44.7& \textbf{45.6} &\textbf{76.8} &76.5\cr 12& 69.0& \textbf{73.5} &87.7 &\textbf{87.9}\cr 25& \textbf{86.3}& 84.3 &\textbf{91.9} &90.9\cr 26& 42.7& \textbf{43.6} &\textbf{75.3} &73.4\cr \midrule Avg&53.0& \textbf{55.9} &80.2 &\textbf{80.7}\cr \bottomrule \end{tabular} } \caption{The effectiveness of relationship-embedded feature enhancement on DISFA dataset.} \label{tab:ablations_disfa} \end{table} \subsubsection{Effectiveness of Multiscale CNN} To verify the effectiveness of multiscale feature learning and cropping, we remove the GGNN part of our framework and directly perform multi-label classification on the extracted regional features, we call this variant multiscale representation learning framework~(MS\_RL). We have also implemented a single-scale version for comparison~(SS\_RL). We trained the two variants with the same setting, using our proposed balanced loss function. We have also listed the result of the original VGG network and that trained using balanced loss function~(VGG\_BL) for comparison. As shown in Table~\ref{tab:ablations_bp4d}, SS\_RL achieved higher F1\_score and AUC in most of AUs when compared with VGG\_BL, especially in AU1, 4, 23. Overall, it outperforms VGG\_BL by 2.4\% and 1.7\% in terms of average F1-score and AUC on the BP4D dataset, respectively. We believe that the reason for its higher performance lies in the application of independent regional feature representation, which avoids the feature interference in different AU regions. When compared with SS\_RL, MS\_RL gains 0.50\% and 0.40\% performance improvement w.r.t F1-score and AUC, which evidences the effectiveness of the multiscale setting. \subsubsection{Effectiveness of Knowledge-Graph based Feature Embedding} To verify the effectiveness of AU relationship-embedded feature enhancement, we have compared the performance of our proposed SRERL to those without relationship modeling~(MS\_RL). As shown in Table~\ref{tab:ablations_bp4d} and Table~\ref{tab:ablations_disfa}, we can clearly see the effectiveness. In BP4D dataset, SRERL achieves 0.90\% and 0.50\% performance boost w.r.t F1-score and AUC when compared with MS\_RL. The accuracy improvement is more significant in DISFA dataset, which is 2.90\% and 0.50\% in terms of F1-score and AUC respectively. At the same time, it can be seen from the analysis of individual AU performance that relationship modeling actually plays a crucial role in improving the accuracy of recognition. For instance, there exists strong positive relationship between AU1 and AU2. In BP4D dataset, AU1 and AU2 increased by 0.3\% and 1.0\% in F1-score, and increased by 0.7\% and 1.4\% in AUC respectively when compared to MS\_RL. Meanwhile, SRERL achieved 6.0\% and 3.3\% higher F1-score in DISFA dataset for AU1 and AU2. On the other side, AU12 and AU15 are negatively correlated. In BP4D dataset, AU12 and AU15 increased by 0.8\% and 1.1\% in F1-scroce, and increased by 0.7\% and 2.0\% in AUC. The experimental results well demonstrate that the relationship-embedded representation learning can greatly enhance the regional facial feature by fully exploiting the structural collaboration between AUs. \subsubsection{Effectiveness of Balance Loss} Table~\ref{tab:ratio} illustrates the data distribution of the BP4D data set. We can clearly see that the occurrence rate of AU2, 15, 23, 24 are less than 20\% while that of AU10 is close to 60\%. From Table~\ref{tab:ablations_bp4d}, we can find that the AUs which are of higher occurrence rate achieve higher performance in VGG method. For example, the occurrence rate of AU12 is 56\% in the dataset, and the F1-score and AUC of AU12 are 86.9\% and 84.8\% respectively. While the occurrence rate of AU23 is 17\%, its corresponding accuracy is relatively lower, which is 29.4\% and 58.5\% respectively. As shown in table \ref{tab:ablations_bp4d}, VGG with balance loss~(VGG\_BL) outperforms the original VGG on many AUs, especially in those with lower occurrence rate. For example, it increases AU2 and AU15 by 8.7\% and 9.5\% w.r.t F1-score, and 5.6\% and 8.5\% in terms of AUC, respectively. Compared to original VGG, VGG\_BL achieved about 4\% and 3\% higher F1-score and AUC in average. \begin{table*}[t] \center \resizebox{1.75\columnwidth}{!} { \begin{tabular}{c|ccccccc|ccccc} \toprule \multirow{2}{*}{AU} & \multicolumn{7}{c}{F1-score} & \multicolumn{5}{c}{AUC}\cr \cmidrule(lr){2-8} \cmidrule(lr){9-13} &LSVM &JPML &LCN &DRML &ROI &DSIN &Ours &LSVM &JPML &LCN &DRML &Ours\cr \midrule{} 1& 23.2& 32.6& 45.0& 36.4 &36.2 &\textbf{51.7} &[46.9] &20.7 &40.7 &51.9 &[55.7] &\textbf{67.6}\cr 2& 22.8& 25.6& 41.2& [41.8] &31.6 &40.4 &\textbf{45.3} &17.7 &42.1 &50.9 &[54.5] &\textbf{70.0}\cr 4& 23.1& 37.4& 42.3& 43.0 &43.4 &\textbf{56.0} &[55.6] &22.9 &46.2 &53.6 &[58.8] &\textbf{73.4}\cr 6& 27.2& 42.3& 58.6& 55.0 &\textbf{77.1} &76.1 &\textbf{77.1} &20.3 &40.0 &53.2 &[56.6] &\textbf{78.4}\cr 7& 47.1& 50.5& 52.8& 67.0 &[73.7] &73.5 &\textbf{78.4} &44.8 &50.0 &[63.7] &61.0 &\textbf{76.1}\cr 10& 77.2& 72.2& 54.0& 66.3 &\textbf{85.0} &79.9 &[83.5] &73.4 &[75.2] &62.4 &53.6 &\textbf{80.0}\cr 12& 63.7& 74.1& 54.7& 65.8 &[87.0] &85.4 &\textbf{87.6} &55.3 &60.5 &[61.6] &60.8 &\textbf{85.9}\cr 14& [64.3]& \textbf{65.7}& 59.9& 54.1 &62.6 &62.7 &63.9 &46.8 &53.6 &[58.8] &57.0 &\textbf{64.4}\cr 15& 18.4& 38.1& 36.1& 33.2 &[45.7] &37.3 &\textbf{52.2} &18.3 &50.1 &49.9 &[56.2] &\textbf{75.1}\cr 17& 33.0& 40.0& 46.6& 48.0 &58.0 &[62.9] &\textbf{63.9} &36.4 &42.5 &48.4 &[50.0] &\textbf{71.7}\cr 23& 19.4& 30.4& 33.2& 31.7 &38.3 &[38.8] &\textbf{47.1} &19.2 &51.9 &50.3 &[53.9] &\textbf{71.6}\cr 24& 20.7& [42.3]& 35.3& 30.0 &37.4 &41.6 &\textbf{53.3} &11.7 &53.2 &47.7 &[53.9] &\textbf{74.6}\cr \midrule Avg&35.3& 45.9& 46.6& 48.3 &56.4 &[58.9] &\textbf{62.9} &32.2 &50.5 &54.4 &[56.0] &\textbf{74.1}\cr \bottomrule \end{tabular} } \caption{Comparison of quantitative results on the BP4D dataset. Our proposed SRERL achieves the best performance, which outperforms the second best method by 4.0\% and 18.1\% in terms of F1-score and AUC respectively.} \label{tab:compare_bp4d} \end{table*} \begin{table*}[t] \centering \resizebox{1.75\columnwidth}{!} { \begin{tabular}{c|cccccc|cccc} \toprule \multirow{2}{*}{AU} & \multicolumn{6}{c}{F1-score} & \multicolumn{4}{c}{AUC}\cr \cmidrule(lr){2-7} \cmidrule(lr){8-11} &LSVM &LCN &DRML &ROI &DSIN &Ours &LSVM &LCN &DRML &Ours\cr \midrule 1& 10.8& 12.8& 17.3& 41.5& [42.4] &\textbf{45.7} &21.6 &44.1 &[53.3] &\textbf{76.2}\cr 2& 10.0& 12.0& 17.7& 26.4& [39.0] &\textbf{47.8} &15.8 &52.4 &[53.2] &\textbf{80.9}\cr 4& 21.8& 29.7& 37.4& [66.4]& \textbf{68.4} &59.6 &17.2 &47.7 &[60.0] &\textbf{79.1}\cr 6& 15.7& 23.1& 29.0& \textbf{50.7}& 28.6 &[47.1] &8.7 &39.7 &[54.9] &\textbf{80.4}\cr 9& 11.5& 12.4& 10.7& 8.5& \textbf{46.8} &[45.6] &15.0 &40.2 &[51.5] &\textbf{76.5}\cr 12& 70.4& 26.4& 37.7& \textbf{89.3}& 70.8 &[73.5] &\textbf{93.8} &54.7 &54.6 &[87.9]\cr 25& 12.0& 46.2& 38.5& [88.9]& \textbf{90.4} &84.3 &3.4 &[48.6] &45.6 &\textbf{90.9}\cr 26& 22.1& 30.0& 20.1& 15.6& [42.2] &\textbf{43.6} &20.1 &[47.0] &45.3 &\textbf{73.4}\cr \midrule Avg&21.8& 24.0& 26.7& 48.5& [53.6] &\textbf{55.9} &27.5 &46.8 &[52.3] &\textbf{80.7}\cr \bottomrule \end{tabular} } \caption{Comparison of quantitative results on the DISFA dataset. Our proposed SRERL achieves the best performance, which outperforms the second best method by 2.3\% and 28.4\% in terms of F1-score and AUC respectively.} \label{tab:compare_disfa} \end{table*} \subsection{Comparison with the State of the Art} We compare our method to alternative methods, including linear SVM(LSVM) \cite{fan2008liblinear}, Joint Patch and Multi-label Learning(JPML) \cite{zhao2015joint}, ConvNet with locally connected layer(LCN) \cite{taigman2014deepface}, Deep Region and Multi-label Learning(DRML) \cite{zhao2016deep}, Region Adaptation, Multi-label Learning(ROI) \cite{li2017action} and Deep Structure Inference Network(DSIN) \cite{corneanu2018deep}. Table \ref{tab:compare_bp4d} and table \ref{tab:compare_disfa} show the result of 12 AUs on BP4D and 8 AUs on DISFA. We can clearly witness that our model outperform all of these state-of-the-art methods. Compared to LSVM, our method achieved 27.6\% and 41.9\% higher F1-score and AUC on BP4D dataset, and achieved 34.1\% and 53.2\% higher F1-score and AUC on DISFA dataset. The reason for the higher performance is that LSVM only use handcraft feature and independent label inference. Our method outperforms JPML by 17\% in terms of F1-score and 23.6\% in AUC on BP4D in average. The main reason lies in that JPML use predefined feature and is not end-to-end trainable. LCN, DRML, ROI and DSIN are four state of the art methods which use convolutional neural network for end-to-end feature learning and multi-label classification. Compared to LCN, our method reaches higher F1-frame and AUC in all AUs on BP4D and DISFA dataset. DRML proposed to divide feature map into 8*8 patches and use region learning for each patch. ROI used facial landmarks to crop the feature and maps to 20 patch, which also applied region learning for each patch. Compared with DRML and ROI, our model achieves 14.6\% and 6.5\% higher performance in F1-score on BP4D while achieves 29.2\% and 7.4\% higher w.r.t F1-score on DISFA. More impressively, our proposed SRERL greatly outperforms DSIN by 4\% and 2.3\% in terms of F1-score on BP4D and DISFA respectively. Noted that DSIN also simultaneously modeled the deep feature learning and the structured AU relationship in an unified framework. However, the relationship inference part of DSIN works as a post-processing step at label level and is being isolated with the feature representation. Compared with DSIN, our performance gain well proves the significance of the joint optimization of feature expression and semantic relationship modeling for face action unit classification, and on the other hand evidences the effectiveness of graph neural network in exploiting more thorough relationship in facial AU representation. \section{Conclusion} In this paper, we have proposed a semantic relationship embedded representation learning framework to well incorporate our constructed AU relationship knowledge-graph as extra guidance information for end-to-end feature representation learning in a deep learning framework. Specifically, the SRERL framework is composed of a multiscale feature learning and cropping module followed by a gated graph neural network for node feature propagation across the defined knowledge-graph. To the best of our knowledge, we are the first to explore the AU relationship based on a differentiable graph neural network module in a feature representation level. Experimental results on the widely used BP4D and DISFA datasets have demonstrated the superiority of the proposed SRERL framework over the state-of-the-art methods. \bibliographystyle{aaai}
{'timestamp': '2019-04-23T02:28:13', 'yymm': '1904', 'arxiv_id': '1904.09939', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.09939'}
arxiv
\section{Introduction} In many fields of physics and engineering, one can only measure the magnitude of the Fourier Transform of a discrete signal $\vect{x} \in \mathbb{C}^N$. Denote the discrete Fourier Transform by $\mathcal{F}$. Recovering $\vect x$ from $\abs{\mathcal{F}\vect{x}}$ is referred to as \textit{phase retrieval} (PR), since the phase is completely lost in measurements. Phase retrieval originated from X-ray crystallography \cite{Millane90,KimH91}, trying to determine atomic and molecular structures of a crystal. This approach was later used to reconstruct an image of a sample with resolution at a nano-meter scale from its X-ray diffraction pattern, known as coherent diffraction imaging (CDI) \cite{MiaoCKS99}. The PR techniques now occur in various applications such as astronomy \cite{Dainty1987} and laser optics \cite{SeifertSDLT06}; please refer to \cite{shechtman2014} for a contemporary overview. Phase retrieval is a very challenging problem largely due to its nonconvexity and solutions being non-unique \cite{Hofstetter1964}. Specifically for the nonuniqueness (a.k.a., \textit{ambiguities}), there are trivial ambiguities and non-trivial ambiguities \cite{shechtman2014}. Trivial ambiguities of $\abs{\mathcal{F}\vect{y}} = \abs{\mathcal{F}\vect{x}}$ can be summarized as follows, \begin{eqnarray} \label{eq:trivial} &&\mbox{global phase shift: } y_k = x_k \cdot e^{i\phi_0}\notag\\ &&\mbox{conjugate inverse: } y_k = \overline{x_{-k}}\\ && \mbox{spatial shift: } y_k = x_{k+k_0}, \notag \end{eqnarray} where the indices are taken cyclically up to $N$, $\bar{\cdot}$ denotes the complex conjugate, and $\phi_0 \in [0, 2\pi), \ k_0 \in \mathbb{Z}$ are the phase shift and spatial shift, respectively. Note that every combination of \eqref{eq:trivial} is also a trivial ambiguity. Non-trivial ambiguities of one-dimensional signals can be classified by the roots of the $Z$-transform of the \textit{autocorrelation} of the signal \cite{BeinertP15}, while almost all multi-dimensional signals only have non-trivial ambiguities \cite{BendoryBE2017}, since the $Z$-transform of their autocorrelation being reducible is of measure zero in the space of all polynomials \cite{BeinertP15, HayesM82}. For unique recovery of a real signal of size $N$ in up to trivial ambiguities, at least $2N-1$ random measurements are needed, provided the sampling matrix has full spark \cite{balan2006signal}. This result was later extended to the complex case in \cite{conca2015algebraic, FickusMNW14}, requiring at least $4N-4$ measurements. Other sufficient conditions for unique recovery include minimum phase signals \cite{HuangES16}, sparse signals with non-periodic support \cite{JaganathanOH13}, and signals with collision-free \cite{RanieriCLV13}. For $s$-sparse signals in $\mathbb{R}^N$, the number of Fourier magnitude measurements is in the order of $O(s\log(N/s))$ \cite{LiV13,ohlsson2014conditions}, while $\min \{ 2s, 2n-1 \}$ for random measurements \cite{WangX14}. In addition to taking more measurements than the ambient dimension, one often relies on regularization to refine the solution space with an attempt to reduce ambiguities. Stemming from image processing, a common choice is a gradient-type formalism. For example, Chang et al.~\cite{changLNZ16} considered the total variation, which is the $\ell_1$ norm of the gradient for phase retrieval. Computationally, many optimization algorithms can be used to solve the (regularized) phase retrieval problems, including alternating projections \cite{Gerchberg1972}, Wirtinger flow \cite{candes2015phaseIT}, alternating direction method of multipliers (ADMM) \cite{changLNZ16}, and a preconditioned proximal algorithm \cite{changMLZ18}. This paper contributes to a new set of characterization theorems for phase retrieval, indicating that gradient-based regularization is redundant to the magnitude measurements. We also impose additional constraints on the underlying signal in order to resolve the ambiguities. In particular, we focus on binary signals \cite{KeiperKLP17} due to its simplicity and a wide variety of applications such as bar code \cite{Esedoglu2003,lou2014partially} and obstacle detection \cite{LitmanLS98}. Specifically for phase retrieval, binary signals are considered in magnetism to describe the x-ray energies of some chemical compound films such as the SmCO$_5$ film \cite{ShiFNELSFTSMRK16}, and in block copolymers to describe films \cite{SteinWYDB16}. It was observed empirically in \cite{hartCL18} that incorporating a box constraint into the ADMM framework, referred to ADMMB, often gives an exact recovery of binary signal, which motivates us to give a theoretical explanation. In this paper, we prove that the phase retrieval problem with binary constraint is equivalent to phase retrieval with box relaxation. We describe a new type of \textit{trivial ambiguities} for binary phase retrieval and show that unique recovery is possible under certain conditions. A related work \cite{YuanWang18} proved binary signals that cannot be uniquely recovered by Fourier magnitude is a zero-measure set. Finally, we take the noise into consideration and develop a denoising algorithm. Our contributions are three-fold: (1) We give a characterization theorem (Theorem~\ref{thm: characterization}), revealing the fact that $\norm{\nabla^n \vect{x}}_2$ is completely determined by $\abs{\mathcal{F}\vect{x}}$ for an arbitrary integer order $n$. (2) We give thorough analysis of phase retrieval problem in a binary setting. We show that the box relaxation to binary constraint is equivalent to the original binary phase retrieval problem (Theorem~\ref{thm: ab box to binary}). We then describe a new type of ambiguities and guarantee the uniqueness of binary phase under certain conditions. (3) We conduct a series of error analysis (Propositions~\ref{prop: denoise}--\ref{cor: denoising related to sparsity} and Corollary~\ref{cor: denoising for integral-valued signal}) of phase retrieval, which motivates a new denoising scheme. The rest of the paper is organized as follows. In Section~\ref{sect:pre}, we set up notations and review some practical ways of taking magnitude measurements. In Section~\ref{sect:char}, we give a new characterization theorem and discuss its consequences. In Section~\ref{sect:box}, we prove that the phase retrieval of binary signals can be relaxed to the box constraint. Furthermore, we show it is possible to relax the set of vectors having the same norm to its convex hull. In Section~\ref{sect:ambi}, we describe a new type of ambiguities for binary signals and show that the unique recovery of binary signals is possible under some special circumstances. Several extensions from the Fourier case to other types of sampling schemes are presented in Section~\ref{sect:more_sampling}. In Section~\ref{sect:denoising}, we estimate recover accuracy with respect to noise and propose a denoising algorithm that empirically yields better performance compared to a na\"ive approach. Section~\ref{sect:conclusion} concludes the paper. Appendix provides all the proofs for the theorems presented. \section{Preliminaries} \label{sect:pre} \subsection{Notations} Let $\vect{x}, \vect{y} \in \mathbb{C}^N$ be arbitrary signals, we define some notations that are used throughout the paper, \begin{itemize} \item $x_k$ denotes the $k$-th entry of $\vect{x}$, i.e. $\vect{x} = (x_0, x_1, x_2, \dots, x_{N-1})^T$ \item $\norm{\vect{x}}_p$ denotes the $\ell_p$-norm of $\vect{x}$, i.e. $\norm{\vect{x}}_p = (\sum^{N-1}_{k=0} \abs{x_k}^p)^{\frac{1}{p}}$, where $p > 0$. For $p=0$, we define $\norm{\vect{x}}_0$ to be the $\ell_0$ ``norm'' by counting the number of its nonzero elements. \item $\vect{e}_k$'s denotes the standard basis in $\mathbb{C}^N$, i.e. the vector with a $1$ in the $k$-th coordinate and $0$'s elsewhere, e.g., $\vect e_0 = (1, 0, 0, \dots, 0)^T$ and $\vect e_1 = (0, 1, 0, \dots, 0)^T$. \item $\mathcal{F}_{N \rightarrow M}: \mathbb{C}^N \to \mathbb{C}^M$ denotes the matrix representing discrete Fourier transform (DFT), i.e. \begin{equation}\label{eq:oversampledFFT} \mathcal{F}_{N\rightarrow M} = \begin{bmatrix} 1 & 1 & 1 & \dots & 1 \\ 1 & \omega & \omega^2 & \dots & \omega^{N-1} \\ 1 & \omega^2 & \omega^4 & \dots & \omega^{2(N-1)} \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ 1 & \omega^{M-1} & \omega^{2(M-1)} & \dots & \omega^{(M-1)(N-1)} \\ \end{bmatrix}, \end{equation} where $\omega = e^{\frac{-2\pi i}{M}}$. Note that $\dfrac{1}{\sqrt{N}}\mathcal{F}_{N \rightarrow N}$ is unitary. If $M>N$, we refer it as an \textit{oversampling} Fourier matrix. \item We define $$\vect{x} \odot \vect{y} = (x_0y_0, x_1y_1, \dots, x_{N-1}y_{N-1}),$$ where $\odot$ denotes the Hadamard product (i.e. entrywise multiplication). \item The \textit{discrete (periodic) convolution} $\vect{x} * \vect{y}$ is defined by \begin{equation} (\vect{x}*\vect{y})_j = \sum^{N-1}_{k=0} x_k y_{(j-k) \text{mod} N}, \end{equation} for $j = 0, 1, \dots, N-1$. \item The \textit{(regular) autocorrelation} is defined by \begin{equation}\label{eq:Aut} (\text{Aut}(\vect{x}))_j = \sum^{N-1}_{k=0} x_{(k+j)} \overline{x_k}, \end{equation} where $j = -N+1, -N+2, \dots, N-1$ and $x_k = 0, \forall k < 0$ and $k > N-1$. \item By replacing the zero boundary condition in the regular autocorrelation with periodic boundary condition, we consider \textit{periodic autocorrelation} defined as \begin{equation}\label{eq:Aut_p} (\text{Aut}_p (\vect{x}))_j = \sum^{N-1}_{k=0} x_{(k+j) \text{mod} N} \overline{x_k}, \end{equation} for $ j=0,1,\cdots, N-1.$ These definitions will be used in the proofs of some interesting results. \end{itemize} For the rest of the paper, we denote $\mathcal{F}_{N \rightarrow N}$ by $\mathcal{F}$, $\mathcal{F}_{N \rightarrow M}$ by $\mathcal{F}_{M}$, and omit $_{\text{mod} N}$ if the context is clear. \subsection{Sampling Schemes} In practice, there are numerous ways \cite{TrebinoDFSKRK97,Trebino00, JaganathanEH2016,candes2015phase,ChangELM18,BendoryEE18} to take magnitude measurements of a signal. This paper develops new theoretical characterizations in PR focusing on the following sampling schemes. \begin{itemize} \item \textbf{Classic Fourier Transform.} One aims to find an unknown signal $\vect{x} \in \mathbb{C}^N$ from the magnitude measurements $\vect{b} := \abs{\mathcal{F}{\vect{x}}}$, i.e. $$b_n = \abs[\Big]{\sum^{N-1}_{k=0} x_k e^{\frac{-2\pi k n i}{N}}}, \quad \forall n = 0, 1, \dots, N-1.$$ \item \textbf{Oversampling Fourier Transform.} An $M$-point ($M > N$) oversampling discrete Fourier Transform (DFT) of a signal $\vect{x} \in \mathbb{C}^N$ is defined by $$b_n = \abs[\Big]{\sum^{N-1}_{k=0} x_k e^{\frac{-2\pi k n i}{M}}}, \quad \forall n = 0, 1, \dots, M-1.$$ One wants to recover an $N$-point signal $\vect x$ based on $M$ measurements of $\abs{\mathcal{F}_M\vect{x}}$. A typical choice of $M$ is $M=2N$ \cite{Hayes1982}, which is experimentally adopted by Miao et al \cite{miao2000oversampling}. Also, a sufficient number of measurements is crucial in avoiding false solutions \cite{soldovieri2005global}. However, we show in Theorem~\ref{thm: characterization Oversampling} theoretically that more measurements (i.e. $M\geq N$) do not resolve ambiguities in the noiseless PR problem. \item \textbf{Short-Time Fourier Transform} (STFT) \cite{eldar2014sparse,JaganathanEH2016}. Let $\vect{x} \in \mathbb{C}^N$ be a signal of length $N$ and $\vect{w} \in \mathbb{C}^W$ be a window function of length $W$. The Short-Time Fourier Transform (STFT) of $\vect{x}$ with respect to $\vect{w}$ is defined as \begin{equation} \label{eq:STFT} \vect{z}_{n,m} = \sum^{N-1}_{k=0} x_k w_{mL-k} e^{\frac{-2\pi k n i}{N}}, \end{equation} for $n = 0, 1, \dots, N-1$ and $m = 0, 1, \dots, R-1$, where $L$ denotes the separation in time between adjacent short-times sections, R = $\ceil{\frac{N+W-1}{L}}$ denotes the number of short-time sections considered, and $w_k := 0$ for all $k<0$ and $k>W-1$. \item \textbf{Frequency-resolved optical gating trace} (FROG) \cite{TrebinoDFSKRK97,Trebino00,BendoryEE18}. Let $$z_{n,m} = x_n x_{n+mL},$$ where $L$ is a fixed integer. The FROG trace is equivalent to the one-dimensional Fourier magnitude of $z_{n,m}$ for each fixed $m$, i.e. \begin{equation}\label{eq:FROG} \abs{\hat{z}_{n,m}}^2 = \abs{\sum^{N-1}_{k=0}x_kx_{k+mL} e^{\frac{-2\pi k n i}{N}}}^2, \end{equation} for $n = 0, \dots, N-1, m = 0, \dots, \ceil*{\frac{N}{L}}-1$. \end{itemize} Both STFT and FROG make experimentally plausible means of additional phaseless measurements to improve the accuracy of phase retrieval. For example, the STFT measurements can be obtained by a set of shifted versions of a single mask, while FROG measures the product of the signal with a shifted version of itself. It was claimed in \cite{eldar2014sparse} that the STFT magnitude leads to better performance than an oversampled DFT with the same number of measurements. \section{Regularization and Constraint in Phase Retrieval} \label{sect:char} Mathematically, the Fourier-type of phase retrieval problems in one dimensional case is formulated as follows, \begin{equation*} \text{Find } \vect{x} \in \mathbb{C}^N, \text{ s.t. } \abs{\mathcal{F}_M\vect{x}} = \vect{b}. \end{equation*} It is desirable and often necessary to impose some regularization term in order to regularize the solution and avoid ambiguities in PR as much as possible. A classic choice is the use of $\norm{\vect x}_2$ and $\norm{\nabla^n \vect{x}}_2$ to enforce the smoothness of an underlying signal $\vect x$, where $\nabla^n$ is the $n$-th order discrete finite difference operator. For simple notations, we define $\nabla^0 \vect x := \vect x$. In other words, a regularized PR problem can be expressed as \begin{equation*} \begin{aligned} \underset{\vect{x}}{\text{minimize}} \norm{\nabla^n \vect{x}}_2 \quad \text{s.t.} \quad \abs{\mathcal{F}\vect{x}} = \vect{b}. \end{aligned} \end{equation*} Unfortunately, Theorem~\ref{thm: same derivative norm} shows that $\norm{\nabla^n \vect{x}}_2$ is completely determined by $\abs{\mathcal{F}\vect{x}}$, which implies that such gradient-based regularization cannot resolve any ambiguities. But on the other hand, adding gradient-based regularizations may help to escape from local optima due to the nonconvex nature of the phase retrieval problem. \begin{thm} \label{thm: same derivative norm} Given $\vect{x}, \vect{y} \in \mathbb{C}^N$, if $\abs{\mathcal{F}\vect{x}} = \abs{\mathcal{F}\vect{y}}$, then ${\norm{\nabla^n\vect{x}}_2 = \norm{\nabla^n\vect{y}}_2},$ for all $n = 0, 1, 2, \dots$. \end{thm} \begin{comment} {\color{red}[I think the reviewer wants to know how the theories apply to L1 norm rather L2?]} {\color{blue} [But this theory cannot be extended to L2 norm in nature. But at least our theory points out that such L1 regularization does not make much sense: if their L2 norm are the same, why should we minimise L1 norm?]} If we replace the regularization term by $l_1$-norm, i.e. \begin{equation*} \begin{aligned} \underset{\vect{x}}{\text{minimize}} \norm{\nabla^n \vect{x}}_1 \quad \text{s.t.} \quad \abs{\mathcal{F}\vect{x}} = \vect{b}, \end{aligned} \end{equation*} then $\nabla^n \vect x$ is assumed to be sparse \cite{hastie2009elements}. If $n = 1$, then $\vect x$ is more like to be piecewise constant. If both $\vect y$ and $\vect z$ satisfy the constraint $\abs{\mathcal F x} = \vect b$ and $\nabla \vect y$ has a smaller $l_1$-norm, i,e, $\norm{\nabla \vect y}_1 < \norm{\nabla \vect z}_1$, then $\vect y$ has less numbers of piece of constant than $\vect z$. While Theorem~\ref{thm: same derivative norm} tells us that $\norm{\nabla \vect y}_2 = \norm{\nabla \vect z}_2$, this forces the jumps in $\vect y$ between constants are larger. \end{comment} One may wonder whether it is helpful to take more measurements and then impose regularizations. \begin{comment} \begin{equation*} \begin{aligned} \underset{\vect{x}}{\text{minimize}} \norm{\nabla^n \vect{x}}_2 \quad \text{s.t.} \quad \abs{\mathcal{F}_M\vect{x}} = \vect{b}_M. \end{aligned} \end{equation*} \end{comment} Theorem~\ref{thm: same derivative norm oversampling} implies that the gradient-type regularization is insufficient for the PR problem with more than phaseless $2N-1$ measurements. \begin{thm} \label{thm: same derivative norm oversampling} Let $M \geq 2N-1$, given $\vect{x}, \vect{y} \in \mathbb{C}^N$, if $\abs{\mathcal{F}_M\vect{x}} = \abs{\mathcal{F}_M\vect{y}}$, then ${\norm{\nabla^n\vect{x}}_2 = \norm{\nabla^n\vect{y}}_2},$ for all $n = 0, 1, 2, \dots$. \end{thm} \begin{rem} When $N < M < 2N-1$, gradient-based regularization may help. For example, let $ \vect x =(0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1)$ and $\vect y =(0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1).$ Both of them are of length $11$ and have the same $\abs{\mathcal{F}_{M}\vect{x}}=\abs{\mathcal{F}_{M}\vect{y}}$ for $M =12$, but $\norm{\nabla^3\vect{x}}_2^2 = 7.5 \neq 7 = \norm{\nabla^3\vect{y}}_2^2$, where the third order finite scheme $\nabla^3\vect{x}$ is defined by $(\nabla^3\vect{x})_k := -\frac{1}{2}x_{k-2} + x_{k-1} - x_{k+1} + \frac{1}{2}x_{k+2}$. \end{rem} To prove Theorems~\ref{thm: same derivative norm}-\ref{thm: same derivative norm oversampling}, we need to review a classical result that $\text{Aut}(\vect x)$ is determined by $\abs{\mathcal{F}_{2N-1} \vect{x}}$ and vice versa, as stated in Theorem~\ref{thm: characterization 2N-1}. \begin{thm}[\cite{BendoryBE2017, YuanWang18}] \label{thm: characterization 2N-1} Given $\vect{x}, \vect{y} \in \mathbb{C}^N$, the following statements are equivalent: \begin{enumerate} \item[(1)] $\abs{\mathcal{F}_{2N-1} \vect{x}} = \abs{\mathcal{F}_{2N-1} \vect{y}}$; \item[(2)] $\text{Aut}(\vect{x}) = \text{Aut}(\vect{y})$. \end{enumerate} \end{thm} We extend this analysis to an arbitrary number of measurements (not just $2N-1$) as well as to period autocorrelation (from regular autocorrelation). Specifically in Theorem \ref{thm: characterization}, we show that when $M=N$, $\text{Aut}_p(\vect{x})$ and $\norm{\vect{v} * \vect{x}}_2$ for $\vect{v} \in \mathbb{C}^N$ are determined by $\abs{\mathcal{F}\vect{x}}$, and vice versa. A similar result for $M\geq 2N-1$ is presented in Theorem~\ref{thm: characterization Oversampling}. \begin{thm} \label{thm: characterization} Given $\vect{x}, \vect{y} \in \mathbb{C}^N$, the following statements are equivalent: \begin{enumerate} \item[(1)] $\abs{\mathcal{F}\vect{x}} = \abs{\mathcal{F}\vect{y}}$; \item[(2)] $\text{Aut}_p(\vect{x}) = \text{Aut}_p(\vect{y})$; \item[(3)] $\norm{\vect{v} * \vect{x}}_2 = \norm{\vect{v} * \vect{y}}_2$ $\forall \vect{v} \in \mathbb{C}^N$. \end{enumerate} \end{thm} \begin{thm} \label{thm: characterization Oversampling} Given $\vect{x}, \vect{y} \in \mathbb{C}^N$, $M \geq 2N-1$, the following statements are equivalent: \begin{enumerate} \item[(1)] $\abs{\mathcal{F}_M \vect{x}} = \abs{\mathcal{F}_M \vect{y}}$ \item[(2)] $\text{Aut}(\vect{x}) = \text{Aut}(\vect{y})$ \end{enumerate} Also, either (1) or (2) implies that $\text{Aut}_p(\vect{x}) = \text{Aut}_p(\vect{y})$ and $\norm{\vect{v} * \vect{x}}_2 = \norm{\vect{v} * \vect{y}}_2$ $\forall \vect{v} \in \mathbb{C}^N$. The converse does not necessarily hold. \end{thm} \begin{rem} For $M<2N-1$ and $M\neq N$, we cannot determine the autocorrelation from $M$ magnitude measurements of $|\mathcal F_M(\vect x)|$, due to an insufficient number of measurements. \end{rem} To the best of our knowledge, the equivalence of phaseless measurements to $\norm{\vect{v} * \vect{x}}_2, \forall \vect{v}$ is novel in the literature, which leads to useful consequences as characterized in Theorems~\ref{thm: same derivative norm} and \ref{thm: same derivative norm oversampling}. In particular, Theorem~\ref{thm: same derivative norm} directly follows from Theorem~\ref{thm: characterization} (1) $\Rightarrow$ (3) and the fact that $\nabla^n\vect{x} = \vect{v}_n * \vect{x}$ for some $\vect{v}_n \in \mathbb{C}^N$. Similarly, Theorem~\ref{thm: same derivative norm oversampling} follows from Theorem~\ref{thm: characterization Oversampling}. \section{Box Relaxation to Binary Constraint} \label{sect:box} We now restrict our attention to binary signals $\vect{x} \in \{0, 1\}^N$, as another way of imposing additional prior knowledge to facilitate phase retrieval. Mathematically, we formulate the binary phase retrieval problem as follows, \begin{equation*} \label{problem: 01 binary phase retrival} \text{Find } \vect{x} \in \{0,1\}^N, \text{ s.t. } \abs{\mathcal{F}\vect{x}} = \vect{b}. \tag{P} \end{equation*} Since the binary constraint is nonconvex, we relax it to a box constraint in a similar way as a linear problem \cite{mao2012reconstruction}: \begin{equation*} \label{problem: 01 box phase retrival} \text{Find } \vect{x} \in [0,1]^N, \text{ s.t. } \abs{\mathcal{F}\vect{x}} = \vect{b}. \tag{Q} \end{equation*} Clearly, if (\ref{problem: 01 binary phase retrival}) has a solution, then (\ref{problem: 01 box phase retrival}) also has a solution. The question is whether we can recover $\vect{x}$ from $\vect{b}$ through (\ref{problem: 01 box phase retrival}). Computationally, the binary constraint in (P) can be posed as a minimization problem of $\vect x (1-\vect x)$ subject to $\vect x \in [0,1]^N$, which can be solved via the difference of the convex algorithm (DCA) \cite{TA,phamLe2005dc}. Each DCA iteration requires to a subproblem similar to the (Q) problem and it takes a few iterations for DCA to converge. Therefore, solving (Q) is computationally more efficient compared to (P). Theoretically, we prove in Theorem~\ref{thm: ab box to binary} that all the solutions to (\ref{problem: 01 box phase retrival}) are solutions to (\ref{problem: 01 binary phase retrival}) and have the same number of $1$'s as the ground-truth signal. \begin{thm} \label{thm: ab box to binary} Given $0 \leq \alpha < \beta$, $\vect{x} \in \{\alpha, \beta \}^N$ and $\vect{y} \in [\alpha, \beta]^N$, if $\abs{\mathcal{F} \vect{x}} = \abs{\mathcal{F} \vect{y}}$, then $\vect{y} \in \{\alpha, \beta \}^N$ and $\vect y$ has the same number of $\alpha$'s and $\beta$'s as $\vect x$. \end{thm} If $\{0, 1\}^N$ in problem (\ref{problem: 01 binary phase retrival}) is replaced by a set such that every element has the same modulus, one can also relax the problem to its convex hull. \begin{thm} \label{thm: extreme point to convex hull} Suppose $\mathcal E$ is a set of complex number and there exists some constant $c > 0$ such that $\abs z= c \geq $ for all $z \in \mathcal E$. Given $\vect x \in \mathcal E^N$ and $\vect y \in \text{conv } \mathcal E^N$, if $\abs{\mathcal F \vect x} = \abs{\mathcal F \vect y}$, then $\vect y \in \mathcal E ^N$, where $\text{conv } \mathcal E$ denotes the convex hull of $\mathcal E$. \end{thm} We have a similar version of Theorem~\ref{thm: ab box to binary} when $\vect x \in \{-1,1\}^N$. \begin{cor} \label{cor: -11 box to binary} Given $\vect{x} \in \{ -1,1 \}^N$ and $\vect{y} \in [-1,1]^N$, if $\abs{\mathcal{F} \vect{x}} = \abs{\mathcal{F} \vect{y}}$, then $\vect{y} \in \{ -1,1 \}^N$, and the number of $1$'s in $\vect{y}$ is the same as the number of $1$'s in $\vect{x}$ or the number of $-1$ in $\vect{x}$. \end{cor} We then characterize trivial ambiguities for binary phase retrieval in Section~\ref{sect:ambi} and extend to other sampling schemes in Section~\ref{sect:more_sampling}. \subsection{Ambiguities and Uniqueness} \label{sect:ambi} In addition to trivial ambiguities \eqref{eq:trivial} for general PR, there is another type of ambiguity in the binary setting. For example, one has $$\abs{\mathcal{F}(1, 1, 1, 1, 0, 0, 1, 0, 0, 0)^T} = \abs{\mathcal{F}(0, 0, 0, 0, 1, 1, 0, 1, 1, 1)^T},$$ in which the two signals are not related by \eqref{eq:trivial}, but rather by switching zeros and ones. We present this ambiguity for binary phase retrieval in Corollary~\ref{cor: flip same magnitude after Fourier Transform}. In fact, this result can be easily extended to the complex case: \begin{prop} \label{prop: more_ambi} Given $\vect x \in \mathbb C^N$, $\abs{\mathcal F \vect x} = \abs{\mathcal F (c\mathbbm 1 -\vect x)}$ if and only if $c = \frac{1+e^{-i\theta}} N\sum x_i$ for some $\theta \in [0,2\pi)$, where $\mathbbm{1}$ denotes the vector of all one's, i.e. $\mathbbm{1} = (1, 1, \dots, 1)^T$. \end{prop} Applying Proposition~\ref{prop: more_ambi} with $\theta = 0$ and noting that $\sum x_i = \norm{\vect x}_0$ for binary signal $\vect x$, one easily obtains: \begin{cor} \label{cor: flip same magnitude after Fourier Transform} Given $\vect{x} \in \{0,1\}^N$ and $N$ is even, if $\norm{\vect{x}}_0 = N/2$, then $\abs{\mathcal{F}\vect{x}} = \abs{\mathcal{F}(\mathbbm{1}-\vect{x})}$. \end{cor} As a by-product from the proof of Proposition \ref{prop: more_ambi}, we reveal an interesting fact, stating that if $\vect{x}$ and $\vect{y}$ have the same Fourier magnitude, then so do $(\mathbbm{1} - \vect{x})$ and $(\mathbbm{1} - \vect{y})$: \begin{prop} \label{prop: x to 1-x} Given $\vect{x}, \vect{y} \in \{0,1\}^N$, $\abs{\mathcal{F}\vect{x}} = \abs{\mathcal{F}\vect{y}}$ if and only if $\abs{\mathcal{F}(\mathbbm{1}-\vect{x})} = \abs{\mathcal{F}(\mathbbm{1}-\vect{y})}$. \end{prop} We show in Proposition~\ref{prop: 0123 uniqueness} that the exact recovery of $\vect x$ up to trivial ambiguities \eqref{eq:trivial} is guaranteed when $\norm{\vect{x}}_0 \leq 3$ and $\norm{\vect{x}}_0 \geq N-3$. The proof uses the fact that $(\text{Aut}_p (\vect{x}))_k$ is the number of pairs of $1$'s with distance\footnote{Note that it is a wrap-around distance. For example, $x_0$ and $x_{N-1}$ are considered of distance $1$.} $k$ for a binary signal $\vect{x}\in\{0, 1\}^N$. The combinatorial nature of $\text{Aut}_p (\vect{x})$ guarantees the uniqueness of $\vect{x}$ up to trivial ambiguities. \begin{prop} \label{prop: 0123 uniqueness} Given $\vect{x} \in \{0,1\}^N$, if $\norm{\vect{x}}_0 = 0, 1, 2, 3, N-3, N-2, N-1$ or $N$, then we can uniquely recover $\vect{x}$ from $\abs{\mathcal{F}\vect{x}}$ up to the trivial ambiguities \eqref{eq:trivial}. \end{prop} \begin{rem} \label{rem: ambiguities} The above does not hold for $4 \leq \norm{\vect{x}}_0 \leq N-4$ in general. For example, $(0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1)^T$ and $(0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1)^T$ have the same magnitude after Fourier Transform, but they are not related to each other by trivial ambiguities. \end{rem} Next, we would like to discuss the uniqueness in oversampling case. Recall that the $Z$-transform of a signal $\vect x \in \mathbb{C}^N$ is defined by $$P_{\vect{x}}(z) = \sum^{N-1}_{k = 0} x_k z^k,$$ which is a complex polynomial. The reciprocal polynomial $\tilde{P}_{\vect x}(z)$ of $P_{\vect x}(z)$ is defined by $\tilde{P}_{\vect x}(z) = z^n P_{\vect x}(z^{-1})$, where $n$ is the degree of the polynomial $P_{\vect x}(z)$. If the $Z$-transform of an unknown binary signal $P_{\vect{x}}$ is either reciprocal or irreducible, then $\vect x$ can be recover uniquely up to conjugate inverse. Using this fact, the exact recovery up to trivial ambiguities in the oversampling case is characterized in Propositions~\ref{prop: uniqueness for equalling to conjugate inverse}-\ref{prop: probability of uniqueness}. \begin{prop} \label{prop: uniqueness for equalling to conjugate inverse} Given $M \geq 2N-1$ in the setting of the oversampling Fourier PR, $\vect{x} \in \{ 0, 1\}^N$, if $x_n = x_{N-1-n}$ for all $n = 0, 1, \dots, N-1$, then we can recover $\vect{x}$ uniquely. \end{prop} \begin{prop} \label{prop: probability of uniqueness} Given $M \geq 2N-1$ in the setting of the oversampling Fourier PR, we can recover a random unknown binary $\vect{x} \in \{ 0, 1\}^N$ uniquely up to the equivalence relation defined by $y_n = x_{N-1-n}$ with probability at least $\frac{c}{logN}$ for a constant $c > 0$. \end{prop} Note that the factor $\frac{c}{logN}$ in Proposition~\ref{prop: probability of uniqueness} is a lower bound. In fact, there is a conjecture in \cite{OdlyzkoP93} that most of all polynomial with $\{0, 1\}$ coefficients are irreducible. If it holds, a much better lower bound can be expected. \subsection{Extensions to other sampling schemes}\label{sect:more_sampling} We extend the analysis of Theorem~\ref{thm: ab box to binary} to the oversampling case, STFT, and FROG in Theorems~\ref{thm: 01 box to binary oversampling}--\ref{thm: -11 FROG}, respectively. Also, it can be extended to $\{0, \alpha\}^N$, $\{-\alpha, \alpha\}^N$ simply by scaling, which are omitted. \begin{thm} \label{thm: 01 box to binary oversampling} Let $M \geq N$, given $\vect{x} \in \{0, 1\}^N, \vect{y} \in [0, 1]^N$, if $\abs{\mathcal{F}_{N \to M}\vect{x}} = \abs{\mathcal{F}_{N \to M}\vect{y}}$, then $\vect{y} \in \{ 0,1 \}^N$ and $\norm{\vect{y}}_0 = \norm{\vect{x}}_0$. \end{thm} \begin{thm} \label{thm: 01 STFT} Given $\vect{x} \in \{0,1\} ^N$ and $\vect{y} \in [0,1]^N$, if $\vect{x}$ and $\vect{y}$ have the same STFT under non-zero constant window, with $W \geq L$, as defined in (\ref{eq:STFT}), then $\vect{y} \in \{0,1\}^N$. \end{thm} \begin{thm} \label{thm: 01 FROG} Given $\vect{x} \in \{0,1\} ^N$ and $\vect{y} \in [0,1]^N$, if $\vect{x}$ and $\vect{y}$ have the same FROG trace \eqref{eq:FROG}, then $\vect{y} \in \{0,1\}^N$ and $\norm{\vect{y}}_0 = \norm{\vect{x}}_0$. \end{thm} \begin{thm} \label{thm: -11 FROG} Given $\vect{x} \in \{-1,1\} ^N$ and $\vect{y} \in [-1,1]^N$, if $\vect{x}$ and $\vect{y}$ have the same FROG trace, then $\vect{y} \in \{-1,1\}^N$. \end{thm} \begin{rem} Unlike Theorem~\ref{cor: -11 box to binary}, the number of $1$'s in $\vect x$ is not necessarily the same as the number of $1$'s nor $-1$'s in $\vect y$. For example, if we take $\vect x = (1, 1)^T$ and $\vect y = (1, -1)^T$, then $\vect x$ and $\vect y$ have the same FROG trace. \end{rem} \section{Denoising} \label{sect:denoising} The preceding sections focus on the noiseless case, where the measured data we obtain is $\vect{b} = \abs{\mathcal{F}\vect{x}}$. However, noise is inevitable in practice and there is a need to develop denoising techniques for phase retrieval. For this purpose, we consider a corrupted measurement $\vect{\tilde{b}} = \vect{b} + \vect{\eta}$ with a noise term $\vect{\eta}$. In the proof of Theorem~\ref{thm: characterization} (specifically Lemma \ref{lemma: compute autocorrelation}), we reveal that $\mathcal{F}^{-1}(\vect{b} \odot \vect{b}) = \text{Aut}_p(\vect{x})$. If the noise $\vect{\eta}$ is small enough, then $\mathcal{F}^{-1}(\vect{\tilde{b}} \odot \vect{\tilde{b}})$ can be approximated by $\mathcal{F}^{-1}(\vect{b} \odot \vect{b})$, which is equivalent to $\text{Aut}_p(\vect{x})$. Proposition~\ref{prop: denoise} is about the approximation error. \begin{prop} \label{prop: denoise} Given $\epsilon > 0$, $\vect{x} \in \mathbb{C}^N \setminus \{\vect{0}\}$, $\vect{b} = \abs{\mathcal{F}\vect{x}}$, $\tilde{\vect{b}} = \vect{b} + \vect{\eta}$ for some noise $\vect{\eta} \in \mathbb{C}^N$, if $\norm{\vect{\eta}}_{\infty} < \text{min} \{\dfrac{\epsilon}{4\norm{\vect{b}}_{\infty}}, \dfrac{\epsilon}{2}, 1\}$, then $\norm{\mathcal{F}^{-1}(\tilde{\vect{b}} \odot \tilde{\vect{b}}) - \text{Aut}_p(\vect{x})}_{\infty} < \epsilon$. \end{prop} Ideally, it would be helpful to analyze the error to the ground-truth signal, which is unfortunately impossible due to trivial and non-trivial ambiguities. In the following, we restrict the ground-truth signal $\vect{x} \in \{0, 1\}^N$ and observe a denoising scheme based on Proposition~\ref{prop: denoise} often gives good results. For binary signal $\vect x$, we know $\text{Aut}_p(\vect{x}) \in \mathbb{Z}^N$. If the noise $\vect{\eta}$ is small such that $\norm{\mathcal{F}^{-1}(\tilde{\vect{b}} \odot \tilde{\vect{b}}) - \text{Aut}_p(\vect{x})}_{\infty} < 1/2$, we can round off each entry of $\mathcal{F}^{-1}(\tilde{\vect{b}} \odot \tilde{\vect{b}})$ to the nearest integer to perform denoising. Since $(\text{Aut}_p (\vect{x}))_k$ is the number of pair of $1$'s with distance $k$, $\norm{\mathcal{F}^{-1}(\tilde{\vect{b}} \odot \tilde{\vect{b}}) - \text{Aut}_p(\vect{x})}_{\infty} \geq 1/2$ means the measurements cannot give us the true number of pairs of $1$'s with distance $k$. In this circumstance, one should not expect to have a successful recovery. \begin{prop} \label{cor: denoising related to sparsity} Given $\vect{x} \in \{0, 1\}^N \setminus \{ \vect 0 \}$, $\vect{b} = \abs{\mathcal{F}\vect{x}}$, $\tilde{\vect{b}} = \vect{b} + \vect{\eta}$ for some noise $\vect{\eta} \in \mathbb{C}^N$, if $\norm{\vect{\eta}}_{\infty} < \dfrac{1}{8\norm{\vect x}_0}$, then $\norm{\mathcal{F}^{-1}(\tilde{\vect{b}} \odot \tilde{\vect{b}}) - \text{Aut}_p(\vect{x})}_{\infty} < \dfrac{1}{2}$. \end{prop} Since $\norm{\vect x}_0\leq N,$ it is straightforward to have Corollary~\ref{cor: denoising for integral-valued signal}. We can also express the error analysis in Proposition~\ref{cor: denoising related to sparsity} in terms of signal-to-noise ratio (SNR). \begin{cor} \label{cor: denoising for integral-valued signal} Given $\vect{x} \in \{0, 1\}^N$, $\vect{b} = \abs{\mathcal{F}\vect{x}}$, $\tilde{\vect{b}} = \vect{b} + \vect{\eta}$ for some noise $\vect{\eta} \in \mathbb{C}^N$, if $\norm{\vect{\eta}}_{\infty} < \dfrac{1}{8N}$, then $\norm{\mathcal{F}^{-1}(\tilde{\vect{b}} \odot \tilde{\vect{b}}) - \text{Aut}_p(\vect{x})}_{\infty} < \dfrac{1}{2}$. \end{cor} Recall SNR is defined by $$\text{SNR}_\text{dB} = 10\log_{10} \dfrac{\norm{\vect x}_2^2}{\norm{\vect \eta}_2^2} .$$ Proposition~\ref{cor: SNR} presents a condition to safely round off each entry to 0 and 1. \begin{cor} \label{cor: SNR} Given $\vect{x} \in \{0, 1\}^N \setminus \vect 0$, if $$\text{SNR}_{\text{dB}} > 10\log_{10}(64) + 30\log_{10}\norm{\vect x}_0,$$ then $\norm{\mathcal{F}^{-1}(\tilde{\vect{b}} \odot \tilde{\vect{b}}) - \text{Aut}_p(\vect{x})}_{\infty} < \dfrac{1}{2}$. \end{cor} \begin{comment} \begin{table} \centering \begin{tabular}{||c||c|c|c|c|c|c|c|c|c|c|} \hline Number of & \multicolumn{10}{c|}{SNR(dB)} \\ \cline{2-11} nonzero elements & 36 & 32 & 28 & 24 & 20 & 16 & 12 & 8 & 4 & 0 \\ \hline 1 & 1 & \textbf{1} & \textbf{1} & \textbf{1} & \textbf{1} & \textbf{1} & \textbf{1} & \textbf{1} & \textbf{.981} & \textbf{.408} \\ \hline 2 & 1 & \textbf{1} & \textbf{1} & \textbf{1} & \textbf{1} & \textbf{1} & \textbf{1} & .\textbf{865} & \textbf{.134} & .002 \\ \hline 3 & 1 & \textbf{1} & \textbf{1} & .\textbf{999} & \textbf{.999} & \textbf{1} & \textbf{.93} & \textbf{.282} & .003 & .001 \\ \hline 4 & .999 & .993 & .995 & .\textbf{991} & .\textbf{998} & \textbf{.99} & \textbf{.565} & .037 & \textbf{.003} & 0 \\ \hline 5 & .983 & .986 & .99 & \textbf{.986} & \textbf{.981} & \textbf{.911} & .208 & .005 & 0 & 0 \\ \hline 6 & \textbf{.96} & .943 & .934 & .943 & \textbf{.951} & \textbf{.722} & .084 & .002 & \textbf{.002} & 0 \\ \hline 7 & \textbf{.885} & \textbf{.879} & .864 & .87 & .862 & .451 & .016 & 0 & 0 & 0 \\ \hline 8 & \textbf{.744} & \textbf{.76} & \textbf{.787} & .776 & .723 & .244 & .009 & 0 & 0 & 0 \\ \hline 9 & \textbf{.657} & \textbf{.651} & \textbf{.654} & .628 & .543 & .121 & .002 & 0 & 0 & 0 \\ \hline 10 & \textbf{.57} & \textbf{.506} & \textbf{.519} & .484 & .401 & .055 & .003 & 0 & 0 & 0 \\ \hline \end{tabular} \caption{\label{tab:rounding_50} Success recovery rates of the rounding scheme for signals of size 50, where the cases obtain better performance are bold.} \end{table} \begin{table}[] \begin{tabular}{||c|| c| c| c| c| c| c| c| c| c| c|} \hline Number of & \multicolumn{10}{c|}{SNR(dB)} \\ \cline{2-11} nonzero elements & 36 & 32 & 28 & 24 & 20 & 16 & 12 & 8 & 4 & 0 \\ \hline 1 & 1 & .999 & .995 & .992 & .99 & .922 & .732 & .304 & .062 & .039 \\ \hline 2 & 1 & .993 & .994 & .976 & .949 & .851 & .616 & .266 & .031 & \textbf{.01} \\ \hline 3 & 1 & .999 & .996 & .995 & .973 & .856 & .546 & .178 & \textbf{.017} & \textbf{.003} \\ \hline 4 & .999 & \textbf{.998} & \textbf{.998} & .99 & .965 & .841 & .402 & \textbf{.085} & .001 & 0 \\ \hline 5 & \textbf{.988} & \textbf{.988} & \textbf{.997} & .982 & .966 & .798 & \textbf{.364} & \textbf{.045} & \textbf{.001} & 0 \\ \hline 6 & .95 & \textbf{.949} & \textbf{.958} & \textbf{.958} & .927 & .721 & \textbf{.259} & \textbf{.024} & 0 & 0 \\ \hline 7 & .873 & .873 & \textbf{.877} & \textbf{.892} & .833 & \textbf{.62} & \textbf{.162} & \textbf{.007} & 0 & 0 \\ \hline 8 & .716 & .743 & .76 & .776 & \textbf{.739} & \textbf{.476} & \textbf{.098} & \textbf{.006} & 0 & 0 \\ \hline 9 & .585 & .636 & .615 & \textbf{.633} & \textbf{.583} & \textbf{.35} & \textbf{.059} & \textbf{.002} & 0 & 0 \\ \hline 10 & .463 & .468 & .495 & \textbf{.495} & \textbf{.449} & \textbf{.271} & \textbf{.03} & 0 & 0 & 0 \\ \hline \end{tabular} \caption{\label{tab:naive_50} Success recovery rates of the na\"ive scheme for signals of size 50, where the cases obtain better performance are bold.} \end{table} \begin{table} \centering \begin{tabular}{||c||c|c|c|c|c|c|c|c|c|c|} \hline Number of & \multicolumn{10}{c|}{SNR(dB)} \\ \cline{2-11} nonzero elements & 36 & 32 & 28 & 24 & 20 & 16 & 12 & 8 & 4 & 0 \\ \hline 1 & .835 & .802 & .83 & .819 & .816 & .783 & \textbf{.812} & \textbf{.819} & \textbf{.83} & \textbf{.677} \\ \hline 2 & \textbf{1} & \textbf{1} & \textbf{1} & \textbf{1} & \textbf{1} & \textbf{1} & \textbf{1} & \textbf{.98} & .507 & 0 \\ \hline 3 & 1 & .999 & 1 & \textbf{1} & \textbf{1} & \textbf{1} & \textbf{.998} & \textbf{.735} & \textbf{.017} & 0 \\ \hline 4 & .999 & \textbf{1} & \textbf{.999} & \textbf{.999} & \textbf{.997} & \textbf{.997} & \textbf{.938} & \textbf{.147} & 0 & 0 \\ \hline 5 & .999 & .998 & .999 & \textbf{1} & \textbf{.996} & \textbf{.993} & \textbf{.679} & .01 & 0 & 0 \\ \hline 6 & .998 & .996 & .998 & \textbf{.997} & \textbf{.996} & \textbf{.973} & \textbf{.329} & .002 & 0 & 0 \\ \hline 7 & .996 & \textbf{.997} & .995 & \textbf{.995} & \textbf{.997} & \textbf{.896} & .111 & 0 & 0 & 0 \\ \hline 8 & .978 & .987 & .989 & \textbf{.989} & \textbf{.989} & .728 & .029 & 0 & 0 & 0 \\ \hline 9 & \textbf{.965} & \textbf{.973} & .958 & \textbf{.957} & \textbf{.95} & .545 & .01 & 0 & 0 & 0 \\ \hline 10 & \textbf{.92} & \textbf{.913} & \textbf{.902} & .907 & \textbf{.88} & .378 & .001 & 0 & 0 & 0 \\ \hline \end{tabular} \caption{\label{tab:rounding_100} Success recovery rates of the rounding scheme for signals of size 100, where the cases obtain better performance are bold.} \end{table} \begin{table}[] \begin{tabular}{||c|| c| c| c| c| c| c| c| c| c| c|} \hline Number of & \multicolumn{10}{c|}{SNR(dB)} \\ \cline{2-11} nonzero elements & 36 & 32 & 28 & 24 & 20 & 16 & 12 & 8 & 4 & 0 \\ \hline 1 & \textbf{.999} & \textbf{1} & \textbf{.996} & \textbf{.993} & \textbf{.979} & \textbf{.882} & .65 & .205 & .009 & 0 \\ \hline 2 & .997 & .993 & .983 & .981 & .935 & .82 & .559 & .129 & .005 & \textbf{.002} \\ \hline 3 & 1 & \textbf{1} & .997 & .994 & .957 & .815 & .491 & .135 & .006 & 0 \\ \hline 4 & \textbf{1} & .999 & .995 & .989 & .96 & .798 & .397 & .06 & 0 & 0 \\ \hline 5 & \textbf{1} & .998 & \textbf{1} & .995 & .95 & .783 & .314 & \textbf{.033} & 0 & 0 \\ \hline 6 & \textbf{.999} & \textbf{.997} & .998 & .996 & .96 & .783 & .292 & \textbf{.017} & 0 & 0 \\ \hline 7 & \textbf{.997} & .995 & \textbf{.996} & .992 & .97 & .742 & \textbf{.229} & \textbf{.005} & 0 & 0 \\ \hline 8 & \textbf{.98} & \textbf{.991} & \textbf{.993} & .985 & .957 & \textbf{.747} & \textbf{.158} & \textbf{.001} & 0 & 0 \\ \hline 9 & .96 & .965 & \textbf{.966} & .955 & .936 & \textbf{.683} & \textbf{.133} & 0 & 0 & 0 \\ \hline 10 & .886 & .903 & .901 & \textbf{.91} & .878 & \textbf{.603} & \textbf{.115} & \textbf{.001} & 0 & 0 \\ \hline \end{tabular} \caption{\label{tab:naive_100} Success recovery rates of the na\"ive scheme for signals of size 100, where the cases obtain better performance are bold.} \end{table} \end{comment} The proposed denoising scheme, referred to as \textit{rounding scheme}, is described as follows: given a corrupted measurement $\vect{\tilde{b}} \in \mathbb{C}^N$, \begin{enumerate} \item Round off each entry $\mathcal{F}^{-1}(\tilde{\vect{b}} \odot \tilde{\vect{b}})$ to nearest integer to get the autocorrelation $\text{Aut}_p(\vect{x})$. \item Calculate $\vect{b} = \sqrt{\mathcal{F}(\text{Aut}_p(\vect{x}))}$, where the square root is taken entrywise. \item Solve the minimization problem: \begin{align}\label{eq:ADMMB} \vect{x^*}=\underset{\vect{x}}{\text{argmin}} \norm{\abs{\mathcal{F}\vect{x}}-\vect{b}}^2_2 \quad \text{s.t.} \quad \vect{x} \in [0,1]^N. \end{align} \item Round off each entry of $\vect{x}^*$ to be either 0 or 1. \end{enumerate} We compare the proposed scheme with a \textit{na\"ive scheme} with the following steps: given a corrupted measurement $\vect{b} \in \mathbb{C}^N$, \begin{enumerate} \item Solve the minimization problem \eqref{eq:ADMMB}. \item Round off each entry of $\vect{x}^*$ to be either 0 or 1. \end{enumerate} Both rounding and na\"ive schemes require to find a solution to \eqref{eq:ADMMB}, which can be solved via the alternating direction methods of multiplier (ADMM) \cite{boydPCPE11admm}. We summarize in Algorithm 1 for Fourier phase retrieval subject to the $[0,1]$-box constraint \eqref{eq:ADMMB} via ADMM; for more details, please refer to \cite{hartCL18}. Notice that ADMM requires two parameters: $\rho_1$ and $\rho_2$. We examine the effects of these two parameters on the na\"ive scheme and the rouding scheme in terms of success rates. We consider a binary vector of length 50 with $5$ nonzero element as the ground-truth $\vect{x}_{\text{true}},$ which is contaminated by noise with SNR$=16$ dB. We choose $\rho_1, \rho_2$ among a candidate set of $\{10^{-6}, 10^{-5}, 10^{-4}, 10^{-3}, 10^{-2}\}$ and plot the success rates in Figure~\ref{fig: para_signal} based on 1000 random realizations; we declare a trial is successful if $\norm{\abs{\mathcal{F}\vect{x}_{\text{recovered}}} - \vect{b}} < 10^{-6}$. We observe no significant difference when $\rho_1 = \rho_2$ and hence we choose $\rho_1 = \rho_2 = 10^{-5}$ for both rounding and na\"ive schemes throughout the experiments. Figure~\ref{fig: para_signal} also shows that our rounding scheme outperforms the na\"ive scheme when $\rho_1 = \rho_2$. \begin{algorithm}[t]\label{algo:ADMMB} \begin{minipage}{20cm} \textbf{Input}: $\vect b$ and two positive parameters $\rho_1, \rho_2$\\ \textbf{Initialize} $k = 0, \vect w^0 = 0, \vect d^0 = 0, \vect y^0 = 0, \vect z^0 = \vect b e^{i\vect \phi}$ with a random vector $\vect \phi$\\ \indent 1 \textbf{while} stopping conditions are not satisfied \textbf{do} \\ \indent 2 \quad $\vect x^{k+1} = (\rho_1+\rho_2)^{-1} (\rho_1 \mathcal F^* \vect z^k + \mathcal F^* \vect d^k + \rho_2 \vect y^k - \vect w^k)$\\ \indent 3 \quad $\vect y^{k+1} = \min(\max(\vect x^{k+1} + \vect w^k/ \rho_2,0),1)$ \\ \indent 4 \quad $\vect z^{k+1} = \textbf{prox}_{\rho_1} (\mathcal F \vect x^{k+1} - \vect d^k /\rho_1)$ \\ \indent 5 \quad $\vect d ^{k+1} = \vect d^k + \rho_1 (\vect z^{k+1} - \mathcal F \vect x^{k+1})$ \\ \indent 6 \quad $\vect w ^{k+1} = \vect w^k + \rho_2 (\vect x^{k+1} - \vect y^{k+1})$ \\ \indent 7 \quad k = k+1 \\ \indent 8 \textbf{end while} \\ \textbf{Output} the solution $\vect x^* = \vect x ^k$ \end{minipage}\\ \caption{Fourier phase retrieval subject to a box constraint \eqref{eq:ADMMB} via ADMM.} \end{algorithm} \begin{figure}[t] \includegraphics[width=.475\textwidth]{para_naive.png} \includegraphics[width=.475\textwidth]{para_rounding.png} \caption{Influence of $\rho_1, \rho_2$ on the na\"ive scheme (left) and the rounding scheme (right) in terms of success rates when SNR $ = 16$ dB and $\norm{\vect x_{\text{true}}}_0 = 5$ for $\vect{x}_{\text{true}}$ of length $50$.} \label{fig: para_signal} \end{figure} \subsection{Fourier phase retrieval} We then compare the performance of both schemes in terms of success rates. We consider the ground-truth signal $\vect{x}_{\text{true}}$ is a binary vector with different combinations of sparsity and noise levels in the Fourier measurements. In particular, we examine ten sparsity levels ($1, 2, \dots, 10$) and generate the noisy measurements $\vect{\tilde{b}}$ by adding Gaussian noise with SNR $=(36 , 32, \dots, 0)$ dB. We plot the success rates of recovering signals of length 50 and 100 based on 1000 random realizations in Figure \ref{fig: 50_signal} and ~\ref{fig: 100_signal}, respectively. Compared to the na\"ive scheme, the rounding scheme works much better when the signal is sparse, which is expected by Proposition~\ref{cor: denoising related to sparsity} that sparser signals allow for larger tolerance of the noise. According to Corollary~\ref{cor: SNR}, the exact recovery bound of SNR is calculated as $18+30\log_{10}\norm{\vect x}_0$, which aligns well with Figures~\ref{fig: 50_signal}-\ref{fig: 100_signal}. Figure~\ref{fig: false_reconstruction} gives some examples on false reconstructions, which implies that one scheme does not dominate the other, as there exist examples when the na\"ive scheme succeeds and the rounding one fails, and vice versa. The conclusion that the rounding scheme is better is based on the success rates. \begin{figure}[t] \includegraphics[width=.475\textwidth]{naive_50.png} \includegraphics[width=.475\textwidth]{rounding_50.png} \caption{Comparison of the na\"ive scheme (left) and rounding scheme (right) in terms of success rates of Fourier phase retrieval for a signal of length 50. The value at each combination of sparsity and SNR is based on 1000 random realizations.} \label{fig: 50_signal} \end{figure} \begin{figure}[t] \includegraphics[width=.475\textwidth]{naive_100.png} \includegraphics[width=.475\textwidth]{rounding_100.png} \caption{ Comparison of the na\"ive scheme (left) and rounding scheme (right) in terms of success rates of Fourier phase retrieval for a signal of length 100.} \label{fig: 100_signal} \end{figure} \begin{figure}[t] \includegraphics[width=.475\textwidth]{false_recovered_signal_2.png} \includegraphics[width=.475\textwidth]{false_recovered_signal.png} \caption{Failed reconstructions by the na\"ive scheme (left) and the rounding scheme (right), when the other scheme succeeds. The ground-truth signals are plotted on the top, while the reconstructed ones are on the bottom. } \label{fig: false_reconstruction} \end{figure} \subsection{Extension to oversampling Fourier Transform} \begin{figure}[t] \includegraphics[width=.475\textwidth]{naive_50_99.png} \includegraphics[width=.475\textwidth]{rounding_50_99.png} \caption{Comparison of the na\"ive scheme (left) and rounding scheme (right) in the case of oversampled Fourier phase retrieval.} \label{fig: over_signal} \end{figure} One may extend our method to oversampling schemes to find the periodic autocorrelation or the regular autocorrelation. We conduct numerical simulations for this case, while leaving the theoretical analysis for the future investigation. When the number of measurements do not match the number of coefficients in autocorrelation, one can perform a polynomial regression and round off to the nearest integer to find the autocorrelation, following equation \ref{eq: polynomial regression}. The extension for the rounding scheme is summarized as follows, similar for the na\"ive scheme. \begin{enumerate} \item Use polynomial regression to estimate the degree $2N-1$ polynomial $A(z)$ by $e^{\frac{2 \pi i k(N-1)}{M}} A(e^{-\frac{2 \pi i k}{M}}) = \tilde{ b}_k^2$. \item Round off each coefficient of $A(z)$ to the nearest integer to get the polynomial $B(z)$ with Aut$( \vect x)$ as its coefficient. \item Calculate $b_k = \sqrt{e^{\frac{2 \pi i k(N-1)}{M}} B(e^{-\frac{2 \pi i k}{M}})}$ \item Solve the minimization problem: \begin{align} \vect{x^*}=\underset{\vect{x}}{\text{argmin}} \norm{\abs{\mathcal{F}_M\vect{x}}-\vect{b}}^2_2 \quad \text{s.t.} \quad \vect{x} \in [0,1]^N. \end{align} \item Round off each entry of $\vect{x}^*$ to be either 0 or 1 \end{enumerate} Again, we compare the performance of the na\"ive scheme and the rounding scheme in terms of success rates. We consider the ground-truth signal $\vect{x}_{\text{true}}$ is a binary vector of length 50 with different combinations of sparsity and noise levels. We take $99$ oversampled Fourier magnitude measurements for each signal, i.e. $N=50, M=99$ in \eqref{eq:oversampledFFT}. We consider ten sparsity levels ($1, 2, \dots, 10$) and generate the noisy measurements $\vect{\tilde{b}}$ by adding Gaussian noise with SNR $=(36 , 32, \dots, 0)$ dB. In Figure~\ref{fig: over_signal}, we plot the success rates based on 1000 random realizations, which shows the rounding scheme outperforms the na\"ive one. \section{Conclusions} \label{sect:conclusion} In this paper, we improved upon an autocorrelation-based characterization of Fourier phase retrieval. We discuss several choices of regularization terms and measurements. Our analysis suggested that a gradient-based regularization, i.e. $\norm{\nabla^n \vect{x}}_2$, is redundant to the magnitude measurements, thus not helpful to phase retrieval. Furthermore, we proved that binary signals can be recovered by imposing a box constraint. We also presented ambiguities and uniqueness for binary phase retrieval. Finally, we proposed a denoising scheme suggested by characterization theorems. Since the proposed denoising scheme involves rounding, it is interesting to extend to 2D images, in which the measured data are often integer-valued. This will be our future work. Another future direction involves theoretical analysis of oversampling schemes and noisy measurements for phase retrieval. \section*{Acknowledgements} WHW and TZ are sponsored in part by the National Natural Science Foundation of China under Grant 11671002, CUHK start-up and CUHK DAG 4053296, 4053342. YL is partially supported by NSF CAREER 1846690. SM was funded by the Center for Advanced Mathematics for Energy Research Applications, US Department of Energy, contract number DOE-DE-AC03-76SF00098.
{'timestamp': '2020-07-16T02:19:02', 'yymm': '1904', 'arxiv_id': '1904.10157', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.10157'}
arxiv
\section{Introduction} \label{sec:intro} With the advent of virtualization technology, cloud computing materializes on-demand computing. A tenant can create a virtual infrastructure based on their exact needs in a much shorter amount of time and the amount of provisioned resources can be adjusted anytime from anywhere by the tenant. The capability of dynamic resource provisioning is a fundamental driving factor for users to adopt the cloud technology. The aspect is also important for cloud infrastructure providers in order to optimize the overall expense (CapEx/OpEx) for running the infrastructure. For enterprise storage solutions, vendors drove an appliance-based model that typically provide proprietary software and customized hardware to support a specific class of applications, e.g., database, and/or a specific layer of storage stack, e.g., NFS storage, SAN block storage, etc. However, since many different tenant/storage applications will share the same infrastructure in the cloud setting, the underlying storage implementation should be able to be adapted for active tenants. Unfortunately, despite the fact that many recent technological advances have been made in virtualizing compute, network, and storage resources in the cloud, it is still the case that the infrastructure providers should decide hardware configuration before deploying a cloud infrastructure, especially from the storage's perspective. For instance, the OpenStack Cinder~\cite{OpenStackCinder} service, which governs block storage management tasks, mandates a preconfigured \emph{storage implementation}\xspace\footnote{In this paper, we use the term \emph{``storage implementation''} as a software/hardware configuration on top of which a logical volume will be created. For instance, it can be a traditional RAID if one uses local disks for cloud block storage, or a Ceph storage pool if one relies upon such a system.} before the operation, e.g., through local RAID configuration, vendor appliances/solutions, etc. In a multi-tenant cloud environment, in particular, the static nature of the storage provisioning practice can cause many significant problems for meeting tenant application requirements, which often come later into the picture. \begin{table}[t] \centering \small \begin{tabular}{|m{4.0cm}|m{2.2cm}|m{1.8cm}|} \hline \textbf{Application} & \textbf{A single \emph{storage implementation}\xspace} & \textbf{Dynamic provisioning} \\ \hline \hline VDI that requires 3x redundancy from underlying storage systems & 3x & 3x \\ \hline vCDN that implements 3x redundancy in the application layer. & 9x & 3x \\ \hline \hline Total Storage Overhead & 12x & 6x \\ \hline \end{tabular} \vspace{0.5ex} \caption \label{tbl:introex}A case of an inefficient utilization of storage capacity.} \vspace{-4ex} \end{table} Table~\ref{tbl:introex} shows an illustrative example. We consider two applications. One is a Virtual Desktop Infrastructure (VDI) application and provides a virtual desktop environment for corporate employees through VMs in the cloud. It requires reliable storage, and consequently demands triple (3x) replication strategy, which is a common industry practice. The other application, vCDN, is a virtualized Content Delivery Network (CDN) application. Unlike the VDI application, vCDN implements triple redundancy in its application layer. In this case, since the application replicates data across three data centers, it is not necessary for underlying storage systems to provide any additional redundancy. Suppose that we first deployed the VDI application to the cloud, and after some time deploy the vCDN application in the same cloud infrastructure. Since the architects only knew about the VDI application when they design the infrastructure, they implemented storage systems based on the triple replication strategy. Even though the vCDN application, which comes later into the picture, does not require an additional redundancy, it needs to be deployed into the same infrastructure. As a result, we end up with wasting a lot of storage space, i.e., 12x vs. 6x in the table. In many practical scenarios, it is not easy to avoid this kind of situation due to the rigid nature of storage services. However, if we can somehow configure the underlying storage parameters dynamically, e.g., this problem might be resolved as depicted in Table~\ref{tbl:introex}. In this particular example, total storage overhead of a single \emph{storage implementation}\xspace is twice as much as the ideal case. In this paper, we propose a system called {IOArbiter}\xspace that enables the dynamic creation of underlying \emph{storage implementation}\xspace in today's cloud. {IOArbiter}\xspace defers the implementation of underlying storage to the volume creation time, i.e., the time at which a tenant actually requests a storage space. To avoid humongous design space, a cloud infrastructure provider may define a customized set of storage implementation types so as to incorporate a range of performance and reliability levels, e.g., RAID-5 or 6 with a minimum of 200 IOPS, Ceph with (6, 3) or (10, 4) erasure coding, etc. and use them with {IOArbiter}\xspace system. When a tenant request, e.g., volume creation, is come into the system, {IOArbiter}\xspace analyzes the request and automatically creates a necessary \emph{storage implementation}\xspace if it is not yet available in the infrastructure, e.g., RAID-5 with 6 disks or Ceph with (10, 4) erasure coding, etc. As a management layer of cloud block storage services, {IOArbiter}\xspace has a number of useful features, including a) an ability to perform garbage collection, e.g, reclaiming unused space and/or a \emph{storage implementation}\xspace, b) an admission control and dynamic throttling mechanism that enables per-VM IOPS allocation, and c) a containerized control plane for effective maintenance. We implemented an {IOArbiter}\xspace prototype with OpenStack Cinder~\cite{OpenStackCinder}. Our preliminary evaluation result shows that {IOArbiter}\xspace can simultaneously satisfy heterogeneous tenant demands, which may not be even possible with a static \emph{storage implementation}\xspace. Moreover, {IOArbiter}\xspace has a negligible overhead in terms of scheduling operation. The rest of the paper is organized as follows. Section~\ref{sec:motiv} gives some basic information on OpenStack Cinder and further motivates the problem. Section~\ref{sec:sysarch} then describes design rationales and overall system architecture. The detailed description of how we implement our system with OpenStack is presented in Section~\ref{sec:impl}. We provide our preliminary evaluation results with our prototype system in Section~\ref{sec:eval}, our investigation on related work in Section~\ref{sec:related}, and conclude the paper. \section{Background and Motivation} \label{sec:motiv} In this section, we provide a brief overview on the block storage management layer in the cloud and present several exemplary problems caused by the static nature of storage provisioning practices. \subsection{Cinder: virtualized block storage management layer} In this paper, we assume a cloud environment based on OpenStack open source software in order to manage underlying physical computing resources. There exist many alternatives including both proprietary~\cite{aws, azure, googlecloud} and open source solutions~\cite{cloudstack}. Nonetheless, OpenStack is chosen by us since it is not only an open source solution, but is also supported by a large community behind it. OpenStack has a block storage management layer, Cinder~\cite{OpenStackCinder}, which is a primary focus of this paper. Cinder governs a control path of cloud block storage, e.g., creating/deleting logical volumes for tenant VMs on the provisioned \emph{storage implementation}\xspace, connecting/disconnecting them to/from VMs, etc. Cinder service is comprised of several sub-components. The \emph{cinder-scheduler} typically runs on the OpenStack cluster's controller nodes. When a block storage request is issued by users through REST API calls, \emph{cinder-scheduler} determines which storage node should handle a given request (e.g., volume creation/deletion). In each storage node, one or more \emph{cinder-volume} services will be instantiated, take the request object, and actually perform the designated task. All communications among \emph{cinder-scheduler} and \emph{cinder-volume} go through a common message bus, e.g., RabbitMQ~\cite{rabbitmq}, ZeroMQ~\cite{zeromq}, etc. When \emph{cinder-volume} receives a request, manipulating logical volumes such as creating/deleting a volume is performed through a \emph{volume-driver} specific to the underlying \emph{storage implementation}\xspace. For instance, a RAID configuration based on local disks typically relies upon the LVM driver implementation. Some open source distributed storage systems provide their own drivers, e.g., Ceph RBD. Vendor appliances have their own driver to properly interact with proprietary software and hardware. For the plumbing part, i.e., connecting/disconnecting a logical volume to/from VMs, Cinder also supports different types of transports, e.g., iSCSI, Fibre channel, etc. Additionally, Cinder provides a plug-in framework for \emph{cinder-scheduler} so that a developer can implement a customized \emph{scheduler filter}. {IOArbiter}\xspace implements its own volume placement strategy using the \emph{scheduler filter} interface. \subsection{Growing pains in cloud block storage: example cases} In addition to the motivating example given in Section~\ref{sec:intro}, our organization have faced several problems due to the static nature of the storage provisioning practice. Here we illustrate some of them to further motivate the problem\footnote{Some of these stories are slightly modified from the real events for more accessible description.}. \para{Reconfiguring storage.} Our IT team provides a disk array preconfigured with RAID-6 with arbitrary internal partitions. There were no problems in the beginning. Later, however, one of our development teams wanted to deploy a virtualized CDN application that replicates its data across multiple datacenters in the application layer. In this case, using RAID-6 for the application is a waste of storage space since it will be unnecessarily replicating data internally. It was hard for the IT team to change it easily since other tenants are already using the array. \para{Meeting multiple performance requirements.} A storage array that has 24 SATA HDDs is configured as JBOD\footnote{Just a Bunch Of Disks} and used by one application that does not require redundancy on the storage layer. Later, another application comes to the cloud and requests a minimum of 500 IOPS\footnote{I/O operations per second} for its VMs' block storage traffic. Unfortunately, its workload is mainly composed of 4 KBytes random read/write, 50\% each. Since the entire disk array is configured as JBOD and a single disk can support $\sim$200 IOPS for this type of workload. If the underlying storage implementation was RAID-5 or 6 with multiple disks, the requirement might be supported more easily. So they have no other choice than to construct a software RAID inside a VM. Unfortunately, however, the disks in the array were all partially occupied by other VMs. \para{Isolation from other tenants.} A storage array is configured as RAID-6 and multiple tenants start to utilize the space. After some time, a tenant from a government organization requests a physically isolated storage for their data. Despite the fact that there are sufficient storage space remained in the disk array, it was not trivial to carve out some of the disks for a new tenant given that SLAs require 24/7 uptime. The cases including all of the above-mentioned scenarios, but not limited to, can be benefited by {IOArbiter}\xspace-like systems that can dynamically configure and change the underlying \emph{storage implementation}\xspace at runtime. \section{{IOArbiter}\xspace Design} \label{sec:sysarch} \subsection{Design principle} {IOArbiter}\xspace is designed based on two fundamental principles: \emph{late binding} and \emph{non-intrusiveness}. \para{Late binding.} To enable dynamic provisioning of a \emph{storage implementation}\xspace, {IOArbiter}\xspace adopts the \emph{late binding} principle, which is a popular computer programming mechanism. Inspired by this principle, a \emph{storage implementation}\xspace will be bound to the cloud infrastructure at the request time, i.e., volume creation time. Storage medium may be provided as a bunch of raw disks or with a state ready to be configured, e.g., a vanilla Ceph installation without any configured storage pools. Then, any relevant \emph{storage implementation}\xspace will be created when necessary, e.g., a RAID for the former and a storage pool for the latter example. \para{Non-intrusiveness.} Since {IOArbiter}\xspace is aimed to be deployed in production clusters, it is desirable to minimize probable impacts on existing OpenStack components. We make a couple of important decisions for this purpose. First, we implement {IOArbiter}\xspace as a filter and driver for the Cinder service rather than making the system as a separate stand-alone service. With this approach, {IOArbiter}\xspace can naturally integrate with existing components, and consequently minimize potential incompatibility problems. Second, we exploit a container technology to isolate a newly created \emph{storage implementation}\xspace. This decision ensures a dedicated agent per \emph{storage implementation}\xspace, and thereby isolates the instance from other {\emph{storage implementation}\xspace}s. As a result, the system administrator can easily enable/disable the \emph{storage implementation}\xspace~as needed. Most failures in a given \emph{storage implementation}\xspace will not affect other {\emph{storage implementation}\xspace}s. \subsection{System architecture} \begin{figure}[t] \centering \includegraphics[viewport=55 130 750 570, scale=0.33, clip=true]{figures/ioarbarch.pdf} \caption {{IOArbiter}\xspace system architecture. Two probable {\emph{storage implementation}\xspace}s are presented.} \label{fig:ioarbarch} \end{figure} Figure~\ref{fig:ioarbarch} illustrates {IOArbiter}\xspace system architecture. The system is comprised of several components including {\emph{Scheduler}}\xspace, {\emph{StateDatabase}}\xspace, {\emph{StorageBroker}}\xspace and {\emph{StorageManager}}\xspace. When a user request arrives at the system with a storage specific requirement, e.g., a triple replicated volume with 100 minimum IOPS, {\emph{Scheduler}}\xspace first checks the resource availability based on the data from {\emph{StateDatabase}}\xspace and decides who should handle the request, i.e., either {\emph{StorageBroker}}\xspace or {\emph{StorageManager}}\xspace. If a new \emph{storage implementation}\xspace is required by the request due to the absence of resources, {\emph{StorageBroker}}\xspace will take the request and create a new \emph{storage implementation}\xspace. Otherwise, i.e., if there exists a \emph{storage implementation}\xspace that can support the request, {\emph{Scheduler}}\xspace will route the request to one of the available {\emph{StorageManager}}\xspace. A \emph{storage implementation}\xspace can be a RAID configuration based on local disks, a storage pool based on a distributed storage systems like Ceph~\cite{Weil2006Ceph}, or any storage vendor solution. When {\emph{StorageBroker}}\xspace creates a \emph{storage implementation}\xspace, it will additionally create a {\emph{StorageManager}}\xspace associated with the \emph{storage implementation}\xspace. {\emph{StorageManager}}\xspace will execute actual storage commands, such as creating/deleting a logical volume at a \emph{storage implementation}\xspace, attaching/detaching it from VMs, etc. It is worth noting that {IOArbiter}\xspace uses container technology to isolate the newly created control path of {\emph{StorageManager}}\xspace. Once instantiated, {\emph{StorageBroker}}\xspace and {\emph{StorageManager}}\xspace instances will report their states to {\emph{StateDatabase}}\xspace so that {\emph{Scheduler}}\xspace can perform the scheduling actions. The report message from {\emph{StorageBroker}}\xspace has a set of information about raw resources for which the {\emph{StorageBroker}}\xspace is responsible. For instance, it can be the number of disks, disk types, and mediums in case of a software RAID-based \emph{storage implementation}\xspace. In contrast, the report from {\emph{StorageManager}}\xspace contains more specific information of the \emph{storage implementation}\xspace. It includes the number of logical volumes already created in the \emph{storage implementation}\xspace, total performance budget and allocated resources, capacity status, etc. \subsection{Performance isolation} {IOArbiter}\xspace is intended to be deployed for multi-tenant cloud environments. In this context, performance isolation is an important issue. {IOArbiter}\xspace provides two features -- admission control based on offline profiles and dynamic throttling based on runtime characteristics. \para{Admission control.} When a new \emph{storage implementation}\xspace is created, a containerized {\emph{StorageManager}}\xspace will be created along with it. At that time, {IOArbiter}\xspace ensures that a new {\emph{StorageManager}}\xspace has a total performance budget for that particular \emph{storage implementation}\xspace. For instance, if the \emph{storage implementation}\xspace is based on a single SATA HDD, {IOArbiter}\xspace allocates $\sim$200 for the worst-case 4k-block IOPS budget. After that, whenever a new volume creation request comes into the system, {\emph{StorageManager}}\xspace manages budgets and inform the remaining budgets to {\emph{StateDatabase}}\xspace. This will ensure that, if a budget is full for a given \emph{storage implementation}\xspace, no more requests will be issued to the corresponding {\emph{StorageManager}}\xspace. \LinesNumbered \SetInd{1ex}{2ex} \begin{algorithm}[ht] \scriptsize Set \emph{minimum IOPS} for each volume $i$ ($R_{i}$)\; By default, $R_{i} = 0$\; Set control interval: M\; \BlankLine \While {wait M seconds} { \emph{is\_throttling = false}\; \BlankLine \ForEach{volume} { collect \emph{current IOPS}\; \uIf {current IOPS $<$ minimum IOPS} { throttle each volume $i$ by $R_{i}$\; \emph{is\_throttling = true}; } \Else { continue\tcc*[r]{do nothing} } } \BlankLine \uIf {is\_throttling == false} { release all throttling\; } \Else { continue\tcc*[r]{do nothing} } } \caption{\small{Dynamic Throttling}} \label{algo:dynamic_throttling} \end{algorithm} \para{Dynamic throttling.} Although {IOArbiter}\xspace allocates performance, e.g., IOPS, based on the budget, it might be the case that some resource interference still happens among the allocated volume traffic. {IOArbiter}\xspace provides a dynamic throttling mechanism to mitigate the problem, as shown in Algo.~\ref{algo:dynamic_throttling}. {IOArbiter}\xspace monitors a runtime statistics (i.e., \emph{current IOPS}) of each volume (at line 7) and, if the performance requirement (i.e., \emph{minimum IOPS}) of a certain volume is violated (at line 8), it suppresses other flows sharing the same \emph{storage implementation}\xspace based on their worst-case requirements (at line 9). If no performance requirements are violated, throttling actions will be disabled (at line 16). \subsection{Discussion} \para{Garbage collection.} Since {IOArbiter}\xspace encourages dynamic provisioning of \emph{storage implementation}\xspace, there exists a concern on resource fragmentation. To mitigate this problem, {IOArbiter}\xspace has a notion of periodic garbage collection mechanism. Based on the mechanism, {IOArbiter}\xspace is able to reclaim unused storage space, if any, and/or rebalance the skewed data in already deployed distributed storage systems. \para{High available and scalable service.} {IOArbiter}\xspace system belongs to a control plane of cloud block storage. In a large scale cloud infrastructure where 1000s of nodes or more can be deployed, it is important to make a service both highly available and scalable. Making a centralized gateway to be highly available, balancing incoming traffic load uniformly across the available resources, and handling partitioned service resources are classic topics of distributed systems. We do not attempt to make any contribution in the above-mentioned problem space. Instead, {IOArbiter}\xspace could exploit an external service that is dedicated to these functions, such as Pacemaker~\cite{pacemaker}. \section{Implementation of {IOArbiter}\xspace system} \label{sec:impl} \begin{figure}[t] \centering \includegraphics[viewport=55 180 750 570, scale=0.33, clip=true]{figures/ioarbimpl.pdf} \caption {{IOArbiter}\xspace implementation with OpenStack Cinder} \label{fig:ioarbimpl} \end{figure} We have implemented an {IOArbiter}\xspace prototype with OpenStack Cinder service~\cite{OpenStackCinder}. The integrated system is described in Fig.~\ref{fig:ioarbimpl}. The {IOArbiter}\xspace sub-components are mapped onto Cinder components. A tenant request is described as a Cinder \emph{volume-type}, which can have a set of user-defined key-value pairs, e.g., \{redundancy=5,min-iops=100,iosize=4k,..\}. Cinder has an RESTful API interface (\emph{cinder-api}) and the communication between clients and \emph{cinder-api} is through a message queue service, e.g., RabbitMQ~\cite{rabbitmq}, ZeroMQ~\cite{zeromq}, etc. {\emph{Scheduler}}\xspace is mapped onto \emph{cinder-scheduler} and implemented as one of its filters. {\emph{StorageBroker}}\xspace and {\emph{StorageManager}}\xspace each are mapped onto \emph{cinder-volume} with a different mode of operations -- \emph{cinder-volume(broker)} and \emph{cinder-volume(provisioned)} -- and implemented as a separate driver\footnote{For instance, an extended version of LVM driver.}. In Fig.~\ref{fig:ioarbimpl}, as an example, we present a software-based RAID configuration based on local disks available in a single storage node. It should be noted that {IOArbiter}\xspace can support other types of \emph{storage implementation}\xspace such as configuring a storage pool for Ceph, etc. As discussed in Section~\ref{sec:sysarch}, {IOArbiter}\xspace exploits a container technology to isolate a newly created control path. We use the Docker container~\cite{docker} for our prototype implementation. The \emph{cinder-volume} uses a local configuration file (cinder.conf) to configure and maintain its internal states. {IOArbiter}\xspace inserts an additional information in that file for our admission control mechanism. When a containerized \emph{cinder-volume} (i.e., \emph{cinder-volume(provisioned)}) is created, {\emph{StorageBroker}}\xspace (i.e., \emph{cinder-volume(broker)}) will insert pre-computed performance budget into a cinder.conf file inside the container. Those budget numbers are based on offline profiles and specific to a given \emph{storage implementation}\xspace. After that, buget accounting operations are done by \emph{cinder-scheduler} based on the reported information from the containerized \emph{cinder-volume} service. Dynamic throttling service will be instantiated inside each container, run as a daemon process, and periodically collect block device performance in case of software-RAID based \emph{storage implementation}\xspace. When an SLA violation is observed, the service throttles all other storage traffic sharing the \emph{storage implementation}\xspace. \section{Preliminary Evaluation} \label{sec:eval} \subsection{Setup} We ran an experiment in an OpenStack cluster that has 11 nodes (servers). For {IOArbiter}\xspace, we carve out two storage nodes, i.e., nodes where \emph{cinder-volumes} are running, and other nodes are operated normally under a single OpenStack installation. For the two nodes, we install the {IOArbiter}\xspace driver for \emph{cinder-volume} services and expose raw local disk drives to {IOArbiter}\xspace system so that it can create a custom \emph{storage implementation}\xspace based on the disks. The two nodes have 10 and 7 local HDDs respectively, each of which has 1TB of storage capacity. \subsection{Dynamic provisioning and meeting multiple requirements} \begin{figure*}[t] \centering \includegraphics[viewport=55 230 750 510, scale=0.65, clip=true]{figures/exp1.pdf} \vspace{-2ex} \caption {{IOArbiter}\xspace running on a real cluster: dynamic provisioning of a \emph{storage implementation}\xspace and admission control.} \label{fig:exp1} \end{figure*} \begin{table}[t] \centering \small \begin{tabular}{|m{1.8cm}|m{6.2cm}|} \hline \textbf{Volume Type} & \textbf{Property of \emph{storage implementation}\xspace} \\ \hline \hline Type 1 & RAID-5 based on 10 disks. \\ \hline Type 2 & RAID-6 based on 4 disks. 100 IOPS. \\ \hline Type 3 & JBOD based on a single disk. \\ \hline \end{tabular} \vspace{0.5ex} \caption \label{tbl:voltype}Cinder volume types for the experiment} \end{table} \begin{table}[t] \centering \small \begin{tabular}{|m{0.45cm}|m{0.75cm}|m{0.75cm}|m{0.75cm}|m{0.75cm}|m{0.75cm}|m{0.75cm}|m{0.75cm}|} \hline \textbf{Req.}& \#1 & \#2 & \#3 & \#4 & \#5& \#6& \#7 \\ \hline \hline Spec.& Type~1 100G& Type~2 100G& Type~3 100G& Type~2 100G& Type~2 100G& Type~2 100G& Type~2 100G \\ \hline \end{tabular} \vspace{0.5ex} \caption \label{tbl:request}Request Sequence (Type \# can be found in Table~\ref{tbl:voltype})} \end{table} We design an experiment that can show the benefits of dynamic provisioning of a \emph{storage implementation}\xspace. Through the experiment, we aim to demonstrate the followings: \begin{itemize} \item[*] Simultaneously meet a diverse set of tenant requests within a tight resource budget. Each request has a different performance and reliability level. \item[*] Meet performance requirements of allocating an IOPS in a per-volume basis. \item[*] Perform a garbage collection for higher resource utilization. \end{itemize} For the experiment, we configure three different \emph{volume type}s (Table~\ref{tbl:voltype}) and use the input sequence described in Table~\ref{tbl:request}. Each request is issued to the cluster every 90 seconds. The result is reported in Fig.~\ref{fig:exp1}. The figure clearly shows that {IOArbiter}\xspace can dynamically create {\emph{storage implementation}\xspace}s to satisfy heterogeneous requests (Req.\#1, \#2, and \#3). In addition, it demonstrates that {IOArbiter}\xspace can allocate IOPS correctly (Req.~\#7 failed due to the budget constraint). In detail, our offline profiles tell us that we could use 200 IOPS (for 4k-block random read/write) per HDD as a total performance budget. So, a RAID-6 based on 4 disks (on node 2) has 400 IOPS of a total performance budget, and consequently the fifth trial with a type-2 request (Req.~\#7) failed; notice that a type-2 volume creation request comes with 100 IOPS. After all 7 requests were processed, we also evaluated the garbage collection capability of {IOArbiter}\xspace system. In a software-RAID based implementation, we built a mechanism that could reclaim unused storage space, especially when there are no logical volumes in a given \emph{storage implementation}\xspace for some amount of time. After deleting volumes, {IOArbiter}\xspace successfully reclaimed disks and each \emph{storage implementation}\xspace returned to a raw disk pool. Although not evaluated in this paper, it is worth noting that the garbage collection mechanism can be useful to other types of \emph{storage implementation}\xspace, e.g., distributed storage systems such as Ceph. In case of Ceph, the garbage collection may trigger rebalancing operations to alleviate a skewed data distribution in the cluster. \subsection{Scheduling overhead} {IOArbiter}\xspace has an additional intelligence for determining which host can satisfy a given requirement. Nonetheless, it turns out the overhead incurred by {IOArbiter}\xspace system is negligible, i.e., only about 5$\sim$6 milliseconds of latency will be added for \emph{cinder-scheduler} to determine the eligibility of a storage host. \section{Related Work} \label{sec:related} As cloud services boom, attention is drawn to providing users with block storage. Amazon Elastic Block Store (EBS)~\cite{AmazonEBS} and OpenStack Cinder~\cite{OpenStackCinder} provide persistent block level storage volumes with virtual instances, usually via iSCSI~\cite{Satran2004rfc3720}. For \emph{cinder-scheduler}, Yao et al. design and implement a new scheduling filter with the ability of IO throughput filtering and weighting to meet IOPS requirements~\cite{Yao2014SLA}, and propose a new block storage resource scheduling algorithm called MVBFD~\cite{Yao2015Multi}. To the best of our knowledge, {IOArbiter}\xspace system is novel for its dynamic provisioning of a \emph{storage implementation}\xspace in the area of cloud block storage. Nonetheless, we can easily observe dynamic operations in modern distributed storage systems. For instance, Ceph storage cluster can dynamically grow, shrink, and rebalance data along with the changes in underlying resources, e.g., \# of OSDs~\cite{Weil2006Ceph, Weil2007RADOS, Weil2006CRUSH}. ASCAR~\cite{li15ASCAR} autonomously controls IO traffic from storage clients using a rule based algorithm called SHARP, which uses the congestion window and rate limit, in order to increase the bandwidth utilization and reduce speed variance. {IOArbiter}\xspace implements a couple of simple, yet powerful, mechanisms to provide QoS. There exists an extensive body of research in the area of providing performance isolation and delivering guaranteed performance to tenants in today's virtualized datacenters. Most of them are complementary to {IOArbiter}\xspace system in nature. Gulati et al. proposes several approaches \cite{mClock, Gulati2009PARDA, Gulati2012Demand} and implements them in VMware ESX hypervisor. mClock~\cite{mClock} proposes an IO scheduling algorithm in a hypervisor for per-VM QoS that supports reservation, limits, and shares. PARDA~\cite{Gulati2009PARDA} provides proportional-share fairness to multiple hosts sharing a single storage array; it detects overload via latency measurements, and then adjusts per-host issue queue lengths using flow control very similar to FAST TCP~\cite{FastTcp2006}. SRP~\cite{Gulati2012Demand} proposes a hierarchical IO resource allocation system that support the logical grouping of related VMs into hierarchical pools; SRP controls IO reservations, limits and proportional shares at VM or pool level in an environment where VMs running multiple hosts are accessing the same storage. Elnably et al.~\cite{Elnably2012EfficientQoS} proposes a scheduling algorithm called reward scheduling to provide QoS in a multi-tiered storage system that uses both SSD and HDD. For key-value cloud storage, Pisces~\cite{Shue2012PerfIsolation} provides per-tenant weight fair sharing and performance isolation, and Pileus~\cite{Douglas2013ConsistencySLA} allows applications to use a choice of consistency guarantees with latency targets for consistency-based SLAs. Tangentially related is a body of work that provides a QoS-aware block device interface to tenants in the cloud. Lin et al.~\cite{Lin2012Towards} proposes a block storage system design called FAST to minimize interference among tenants; read operations are redirected when different types of workloads (i.e., random and sequential reads) are co-located. Mesnier et al.~\cite{Mesnier2011DiffStorage} proposes an IO classification architecture with a slightly-modified block interface in order to provide differentiated storage services. Blizzard~\cite{Mickens2014Blizzard} extends the simple block interface for high IO performance, mapping each virtual driver to multiple backing physical disks, and providing high-level software abstractions such as replication and failure recovery. \section{Conclusion and future work} \label{sec:concl} We present a system, called {IOArbiter}\xspace, that can dynamically provision an underlying storage implementation for cloud block storage services. {IOArbiter}\xspace defers the storage provisioning process to the time at which a tenant actually requests a storage space. The late binding can offer high flexibility to the cloud service providers, thereby resulting in higher utilization. {IOArbiter}\xspace implements two mechanisms, i.e., admission control and dynamic throttling, to provide QoS on performance among tenant applications. Through preliminary evaluation, we demonstrate that {IOArbiter}\xspace can satisfy heterogeneous tenant requests even with considerably limited storage resources and perform a proper admission control for allocating IOPS per volume. Much work remains. We plan to integrate {IOArbiter}\xspace system with an emerging JBOF (Just-a-Bunch-Of-Flash) device and other distributed storage systems in the near future. Its QoS mechanism must be evaluated further thoroughly, even if our preliminary evaluation result looks promising. { \tiny \bibliographystyle{abbrv}
{'timestamp': '2019-04-24T02:00:16', 'yymm': '1904', 'arxiv_id': '1904.09984', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.09984'}
arxiv
\section{Introduction} Intersection type systems are tools for building and analysing models of the $\lambda$-calculus~\cite{interbcd,interbakel,paramlambda,intermodels}. They also provide ways of characterising reduction properties of $\lambda$-terms such as normalization. The main difference to other type systems is the fact that not only \emph{subject reduction} holds (if $t$ reduces to $u$ and $\Gamma\vdash t:A$ then $\Gamma\vdash u:A$) but also \emph{subject expansion} holds (if $t$ reduces to $u$ and $\Gamma\vdash u:A$ then $\Gamma\vdash t:A$). As a consequence it is possible to define a denotational model by associating to each (closed) term the set of its types $\sem{t}=\{A\mid{}\vdash t:A\}$. The most famous intersection type system is probably the \logsys{BCD}{} system~\cite{interbcd}, and this is the one we are focusing on. While \logsys{BCD}{} insists on the interaction between arrow types and intersection types, we want to consider more general sets of type constructors, following~\cite{intermixin}. The \logsys{BCD}{} type system can be decomposed into two parts: typing rules and subtyping rules. They are related through the subsumption rule. Our main contribution is a derivation system for the subtyping relation which allows us to deal with generic type constructors while satisfying a ``subformula property''. Alternative presentations of \logsys{BCD}{} subtyping are studied in~\cite{interlf}. In contrast with ~\cite{intermixin}, we allow contravariant type constructors so that even the arrow constructor can be defined as an instance of our generic pattern, and only intersection has a specific status. \bigskip In Section~\ref{sectyp}, we recall standard syntactic proofs~\cite{intermodels,tutinter} of preservation of typing by $\beta$-reduction and $\beta$-expansion for the \logsys{BCD}{} system. Our presentation stresses the fact that, starting from intersection (and $\Omega$) only, type constructors can be added in a modular way. In Section~\ref{sectypimp}, we consider the arrow types, thus obtaining the usual \logsys{BCD}{} rules. We extend the results to product types in Section~\ref{sectypprod}. The main part of the paper is then Section~\ref{secsub} where we propose a sequent-style derivation system for defining \logsys{BCD}-like subtyping relations for extensions of intersection types to generic sets of constructors. Starting from a transitivity/cut admissibility property, we prove that instances of our system are equivalent with variants of the \logsys{BCD}{} subtyping relation. Key results on subtyping (Propositions~\ref{propisconsadmiss} and~\ref{propmin}, and Theorem~\ref{thmisconsbcd}) are formalized in \texttt{\upshape Coq}: \begin{center} \url{https://perso.ens-lyon.fr/olivier.laurent/bcdc/} \end{center} \section{Intersection Typing}\label{sectyp} We present the system we are looking at, which is mainly \logsys{BCD}~\cite{interbcd} extended with product types. Type constructors are introduced in an incremental and modular way. \subsection{Intersection Types} Let us first consider an at most countable set $\mathcal{X}$ of base types denoted $X$, $Y$, etc, and consider types built using at least the following constructors: \begin{equation*} A,B ::= X \mid A\cap B \mid \Omega \mid \dotsc \end{equation*} Similarly we do not define the exact set of terms (denoted $t$, $u$, etc), but first we only assume they contain a denumerable set of term variables $\mathcal{V}$ (whose elements are denoted $x$, $y$, etc). A first set of typing rules is given on Table~\ref{tabtyp}, with judgements $\Gamma\vdash t:A$ built from a list $\Gamma$ of typing declarations for variables (of the shape $x:B$), a term $t$ and a type $A$. Note these rules rely on a \emph{subtyping} relation $\leq$ on types, which is here just a parameter. \begin{table} \centering \begin{gather*} \VAR{\Gamma,x:A,\Delta\vdash x:A} \DisplayProof \qquad \AIC{\Gamma\vdash t:A} \AIC{A\leq B} \LEQ{\Gamma\vdash t:B} \DisplayProof \qquad \AIC{\Gamma\vdash t:A} \AIC{\Gamma\vdash t:B} \INTER{\Gamma\vdash t:A\cap B} \DisplayProof \qquad \OMG{\Gamma\vdash t:\Omega} \DisplayProof \end{gather*} \caption{Typing Rules with Subtyping and Intersection.}\label{tabtyp} \end{table} \begin{lem}[Weakening]\label{lemwk} If $\Gamma\vdash t:A$ and $\Delta\leq\Gamma$ (meaning that, for each $x:B$ in $\Gamma$, one can find $x:B'$ in $\Delta$ with $B'\leq B$) then $\Delta\vdash t:A$. \end{lem} \begin{lem}[Strengthening]\label{lemstr} If $\Gamma,x:B,\Delta\vdash t:A$ and $x\notin t$ then $\Gamma,\Delta\vdash t:A$. \end{lem} Because it makes hypotheses on the term in conclusion, the rule ($\textit{var}$) is called a \emph{term rule} (the introduced term must be a variable). In the opposite, ($\leq$), ($\cap$) and ($\Omega$) rules are called \emph{non-term} as they apply on any term without any constraint on its main constructor. As a term rule, ($\textit{var}$) admits a so-called \emph{generation lemma} analysing how variables can by typed. For this, we make some hypotheses on the subtyping relation (see Table~\ref{tabsub}). Note in passing, that the axioms of Table~\ref{tabsub} are equivalent to say that $\leq$ is a preorder relation with $\cap$ as greatest lower bound and $\Omega$ as top element. In particular, up to the equivalence relation induced by $\leq$, $\cap$ is a commutative associative idempotent operation with $\Omega$ as unit. As a consequence the notation $\bigcap_{i\in I}A_i$ makes sense (up to the equivalence relation induced by $\leq$) for any (possibly empty) finite set $I$. \begin{table} \centering \begin{align} A &\leq A \tag{\textit{refl}}\label{axsubrefl}\\ A\leq B \;\wedge\; B\leq C \;&\Rightarrow\; A\leq C \tag{\textit{trans}}\label{axsubtrans}\\ A\cap B &\leq A \tag{\ensuremath{\inter_l^1}}\label{axsubinterll} \\ A\cap B &\leq B \tag{\ensuremath{\inter_l^2}}\label{axsubinterlr} \\ C\leq A \;\wedge\; C\leq B \;&\Rightarrow\; C\leq A\cap B \tag{\ensuremath{\inter_r}}\label{axsubinterr}\\ A &\leq \Omega \tag{\ensuremath{\omg_r}}\label{axsubomgr} \end{align} \caption{Kernel Properties of Subtyping.}\label{tabsub} \end{table} \begin{lem}[Generation for Variables]\label{lemgenvar} Assuming that ($\textit{var}$) is the only term rule introducing a variable, the only non-term rules are ($\leq$), ($\cap$) and ($\Omega$), and that the axioms of Table~\ref{tabsub} are satisfied, we have: if $\Gamma\vdash x:A$ with $x:B\in\Gamma$ then $B\leq A$. \end{lem} \begin{lem}[Substitution]\label{lemsubst} If $\Gamma,x:A,\Delta\vdash t:B$ and $\Gamma,\Delta\vdash u:A$ then $\Gamma,\Delta\vdash\subst{t}{u}{x}:B$. \end{lem} \subsection{Arrow Types}\label{sectypimp} We now assume types contain an arrow constructor and terms are extended correspondingly: \begin{equation*} A,B ::= X \mid A\cap B \mid \Omega \mid A\rightarrow B \mid \dotsc \hspace{2cm} t,u ::= x \mid \lb{x}{t} \mid \ap{t}{u} \mid \dotsc \end{equation*} The associated typing rules are given on Table~\ref{tabtypimp}. Note the two new rules are term rules corresponding respectively to $\lb{x}{t}$ and $\ap{t}{u}$ (no new non-term rule). \begin{table} \centering \begin{equation*} \AIC{\Gamma,x:A\vdash t:B} \ABS{\Gamma\vdash \lb{x}{t}:A\rightarrow B} \DisplayProof \qquad\qquad \AIC{\Gamma\vdash t:A\rightarrow B} \AIC{\Gamma\vdash u:A} \APP{\Gamma\vdash \ap{t}{u}:B} \DisplayProof \end{equation*} \caption{Typing Rules for Arrow.}\label{tabtypimp} \end{table} By adding new cases corresponding to the added rules in the proofs, one can check that Lemmas~\ref{lemwk} and~\ref{lemstr} still hold. Moreover the hypotheses of Lemma~\ref{lemgenvar} are still satisfied, and finally Lemma~\ref{lemsubst} (which only relies on the previous lemmas) is still true as well. Since terms may now contain binders (such as $\lb{x}{\_}$), substitution has to be considered as being capture-avoiding substitution. \begin{lem}[Generation for Application]\label{lemgenapp} Assuming that ($\textit{app}$) is the only term rule introducing an application, the only non-term rules are ($\leq$), ($\cap$) and ($\Omega$), and that the axioms of Table~\ref{tabsub} are satisfied, we have: if $\Gamma\vdash\ap{t}{u}:B$ then there exist two families of types $(A_i)_{i\in I}$ and $(B_i)_{i\in I}$ with $\bigcap_{i\in I}B_i\leq B$ and, for each $i\in I$, $\Gamma\vdash t:A_i\rightarrow B_i$ and $\Gamma\vdash u:A_i$. \end{lem} \begin{lem}[Generation for Abstraction]\label{lemgenabs} Assuming that ($\textit{abs}$) is the only term rule introducing an abstraction, the only non-term rules are ($\leq$), ($\cap$) and ($\Omega$), and that the axioms of Table~\ref{tabsub} are satisfied, we have: if $\Gamma\vdash\lb{x}{t}:A$ then there exist two families of types $(B_i)_{i\in I}$ and $(C_i)_{i\in I}$ with $\bigcap_{i\in I}(B_i\rightarrow C_i)\leq A$ and, for each $i\in I$, $\Gamma,x:B_i\vdash t:C_i$. \end{lem} We now have the requested material to prove subject reduction and subject expansion. However a specific property on subtyping is still missing: \begin{equation*} \bigcap_{i\in I}(A_i\rightarrow B_i)\leq A\rightarrow B\;\Rightarrow\; \exists J\subseteq I,\;\left(\bigcap_{i\in J}B_i\leq B\;\wedge\;\forall i\in J,\;A\leq A_i\right) \tag{\ensuremath{\rightarrow\leq\rightarrow}}\label{aximpinv} \end{equation*} The study of this property will be at the heart of Section~\ref{secsub}. \begin{prop}[Subject Reduction]\label{propbetared} Assuming (\ref{aximpinv}), if $t_1\reduct_\beta t_2$ and $\Gamma\vdash t_1:A$ then $\Gamma\vdash t_2:A$. \end{prop} \begin{proof} The key case is $\ap{(\lb{x}{t})}{u}\reduct_\beta\subst{t}{u}{x}$. If $\Gamma\vdash\ap{(\lb{x}{t})}{u}:A$, by Lemma~\ref{lemgenapp}, we have two families $(B_i)_{i\in I}$ and $(C_i)_{i\in I}$ with $\bigcap_{i\in I}C_i\leq A$ and, for each $i\in I$, $\Gamma\vdash\lb{x}{t}:B_i\rightarrow C_i$ and $\Gamma\vdash u:B_i$. For each $i\in I$, by Lemma~\ref{lemgenabs}, we have two families $(B'_j)_{j\in J_i}$ and $(C'_j)_{j\in J_i}$ with $\bigcap_{j\in J_i}(B'_j\rightarrow C'_j)\leq B_i\rightarrow C_i$ and, for each $j\in J_i$, $\Gamma,x:B'_j\vdash t:C'_j$. By (\ref{aximpinv}), there exists $K_i\subseteq J_i$ such that $B_i\leq B'_j$ ($j\in K_i$) and $\bigcap_{j\in K_i}C'_j\leq C_i$. We conclude by using Lemma~\ref{lemsubst} with $\Gamma\vdash u:B'_j$: \begin{prooftree} \AIC{\dotsb} \AIC{\dotsb} \AIC{\Gamma\vdash\subst{t}{u}{x}:C'_j} \AIC{\dotsb} \RL{\cap} \TIC{\Gamma\vdash\subst{t}{u}{x}:\bigcap_{j\in K_i}C'_j} \AIC{\bigcap_{j\in K_i}C'_j\leq C_i} \LEQ{\Gamma\vdash\subst{t}{u}{x}:C_i} \AIC{\dotsb} \RL{\cap} \TIC{\Gamma\vdash\subst{t}{u}{x}:\bigcap_{i\in I}C_i} \AIC{\bigcap_{i\in I}C_i\leq A} \LEQ{\Gamma\vdash\subst{t}{u}{x}:A} \end{prooftree} \end{proof} \begin{prop}[Subject Expansion]\label{propbetaexp} If $t_1\reduct_\beta t_2$ and $\Gamma\vdash t_2:A$ then $\Gamma\vdash t_1:A$. \end{prop} \begin{proof} The key case is $\ap{(\lb{x}{t})}{u}\reduct_\beta\subst{t}{u}{x}$. We first prove that $\Gamma\vdash\subst{t}{u}{x}:B$ implies that we can find a type $A$ such that $\Gamma,x:A\vdash t:B$ and $\Gamma\vdash u:A$, by induction on the derivation of $\Gamma\vdash\subst{t}{u}{x}:B$. And then: \begin{prooftree} \AIC{\Gamma,x:A\vdash t:B} \ABS{\Gamma\vdash\lb{x}{t}:A\rightarrow B} \AIC{\Gamma\vdash u:A} \APP{\Gamma\vdash\ap{(\lb{x}{t})}{u}:B} \end{prooftree} \end{proof} To sum up, we have shown that, given the typing rules of Tables~\ref{tabtyp} and~\ref{tabtypimp}, the subject reduction and subject expansion properties hold for $\beta$-reduction as soon as the chosen subtyping satisfies the axioms of Table~\ref{tabsub} as well as property~(\ref{aximpinv}). The historical example from the literature is the \logsys{BCD}{} system~\cite{interbcd} corresponding to the subtyping relation of Table~\ref{tabsubbcd}. We will come back to the fact that (\ref{aximpinv}) holds for this \logsys{BCD}{} relation (Lemma~\ref{leminvimp}). \begin{table} \centering \begin{gather*} \ZIC{A\leq A} \DisplayProof \qquad\qquad \AIC{A\leq B} \AIC{B\leq C} \BIC{A\leq C} \DisplayProof \qquad\qquad \ZIC{A\leq\Omega} \DisplayProof \\[2ex] \ZIC{A\cap B\leq A} \DisplayProof \qquad\qquad \ZIC{A\cap B\leq B} \DisplayProof \qquad\qquad \ZIC{A\leq A\cap A} \DisplayProof \qquad\qquad \AIC{A\leq C} \AIC{B\leq D} \BIC{A\cap B\leq C\cap D} \DisplayProof \\[2ex] \AIC{C\leq A} \AIC{B\leq D} \BIC{A\rightarrow B\leq C\rightarrow D} \DisplayProof \qquad\qquad \ZIC{(A\rightarrow B)\cap(A\rightarrow C)\leq A\rightarrow(B\cap C)} \DisplayProof \qquad\qquad \ZIC{\Omega\leq\Omega\rightarrow\Omega} \DisplayProof \end{gather*} \caption{\logsys{BCD}{} Subtyping Rules.}\label{tabsubbcd} \end{table} \subsection{Product Types}\label{sectypprod} We now assume types contain a product constructor and terms are extended correspondingly: \begin{equation*} A,B ::= X \mid A\cap B \mid \Omega \mid A\rightarrow B \mid A\times B \mid \dotsc \hspace{1.5cm} t,u ::= x \mid \lb{x}{t} \mid \ap{t}{u} \mid \pa{t}{u} \mid \pl{t} \mid \pr{t} \mid \dotsc \end{equation*} The associated typing rules are given on Table~\ref{tabtypprod}. Note the new rules are all term rules (no non-term rule added). Lemmas~\ref{lemwk}, \ref{lemstr}, \ref{lemgenvar} and~\ref{lemsubst} still hold. It is also easy to check that the new rules do not break Propositions~\ref{propbetared} and~\ref{propbetaexp}. \begin{table} \centering \begin{equation*} \AIC{\Gamma\vdash t:A} \AIC{\Gamma\vdash u:B} \PAIR{\Gamma\vdash\pa{t}{u}:A\times B} \DisplayProof \qquad\qquad \AIC{\Gamma\vdash t:A\times B} \PROJL{\Gamma\vdash\pl{t}:A} \DisplayProof \qquad\qquad \AIC{\Gamma\vdash t:A\times B} \PROJR{\Gamma\vdash\pr{t}:B} \DisplayProof \end{equation*} \caption{Typing Rules for Product.}\label{tabtypprod} \end{table} \begin{lem}[Generation for Pairing]\label{lemgenpair} Assuming that ($\textit{pair}$) is the only term rule introducing a pair, the only non-term rules are ($\leq$), ($\cap$) and ($\Omega$), and that the axioms of Table~\ref{tabsub} are satisfied, we have: if $\Gamma\vdash\pa{t}{u}:A$ then there exist two families of types $(B_i)_{i\in I}$ and $(C_i)_{i\in I}$ with $\bigcap_{i\in I}(B_i\times C_i)\leq A$ and, for each $i\in I$, $\Gamma\vdash t:B_i$ and $\Gamma\vdash u:C_i$. \end{lem} \begin{proof} By induction on the typing derivation of $\Gamma\vdash\pa{t}{u}:A$, by looking at each possible last rule which, by assumption, can only be ($\textit{pair}$), ($\leq$), ($\cap$) or ($\Omega$): \begin{itemize} \item ($\textit{pair}$) rule: $I$ is a singleton and the result is immediate. \item ($\leq$) rule: we have $\Gamma\vdash\pa{t}{u}:A'$ with $A'\leq A$, we apply the induction hypothesis to $\Gamma\vdash\pa{t}{u}:A'$, and we conclude by ($\textit{trans}$). \item ($\cap$) rule: we have $A=A'\cap A''$, by induction hypotheses we obtain families of types indexed by $I'$ and $I''$ and we consider $I=I'\uplus I''$. We conclude by using $E_1\leq E_2\;\wedge\; F_1\leq F_2\;\Rightarrow\; E_1\cap F_1\leq E_2\cap F_2$. \item ($\Omega$) rule: we simply choose $I=\emptyset$. \qedhere \end{itemize} \end{proof} \begin{lem}[Generation for Left Projection]\label{lemgenprojl} Assuming that ($\textit{proj}\ensuremath{_1}$) is the only term rule introducing a left projection, the only non-term rules are ($\leq$), ($\cap$) and ($\Omega$), and that the axioms of Table~\ref{tabsub} are satisfied, we have: if $\Gamma\vdash\pl{t}:A$ then there exist two families of types $(B_i)_{i\in I}$ and $(C_i)_{i\in I}$ with $\bigcap_{i\in I}B_i\leq A$ and, for each $i\in I$, $\Gamma\vdash t:B_i\times C_i$. \end{lem} \begin{proof} By induction on the typing derivation of $\Gamma\vdash\pl{t}:A$, by looking at each possible last rule which, by assumption, can only be ($\textit{proj}\ensuremath{_1}$), ($\leq$), ($\cap$) or ($\Omega$): \begin{itemize} \item ($\textit{proj}\ensuremath{_1}$) rule: $I$ is a singleton and the result is immediate. \item ($\leq$) rule: we have $\Gamma\vdash\pl{t}:A'$ with $A'\leq A$, we apply the induction hypothesis to $\Gamma\vdash\pl{t}:A'$, and we conclude by ($\textit{trans}$). \item ($\cap$) rule: we have $A=A'\cap A''$, by induction hypotheses we obtain families of types indexed by $I'$ and $I''$ and we consider $I=I'\uplus I''$. We conclude by using $E_1\leq E_2\;\wedge\; F_1\leq F_2\;\Rightarrow\; E_1\cap F_1\leq E_2\cap F_2$. \item ($\Omega$) rule: we simply choose $I=\emptyset$. \qedhere \end{itemize} \end{proof} \begin{lem}[Generation for Right Projection] Assuming that ($\textit{proj}\ensuremath{_2}$) is the only term rule introducing a right projection, the only non-term rules are ($\leq$), ($\cap$) and ($\Omega$), and that the axioms of Table~\ref{tabsub} are satisfied, we have: if $\Gamma\vdash\pr{t}:A$ then there exist two families of types $(B_i)_{i\in I}$ and $(C_i)_{i\in I}$ with $\bigcap_{i\in I}C_i\leq A$ and, for each $i\in I$, $\Gamma\vdash t:B_i\times C_i$. \end{lem} \begin{proof} Similar to the proof of Lemma~\ref{lemgenprojl}. \end{proof} We consider the reduction $\reduct_\pi$ to be the congruence generated by: \begin{equation*} \pl{\pa{t}{u}}\reduct_\pi t \hspace{3cm} \pr{\pa{t}{u}}\reduct_\pi u \end{equation*} Similarly to the arrow case, we ask for an additional property of the subtyping relation in order to deduce subject reduction: \begin{equation*} \bigcap_{i\in I}(A_i\times B_i)\leq A\times B\;\Rightarrow\;\bigcap_{i\in I}A_i\leq A\;\wedge\;\bigcap_{i\in I}B_i\leq B \tag{\ensuremath{\times\leq\times}}\label{axprodinv} \end{equation*} \begin{prop}[Subject Reduction for Products] Assuming (\ref{axprodinv}), if $t_1\reduct_\pi t_2$ and $\Gamma\vdash t_1:A$ then $\Gamma\vdash t_2:A$. \end{prop} \begin{proof} The key case is $\pl{\pa{t}{u}}\reduct_\pi t$. If $\Gamma\vdash\pl{\pa{t}{u}}:A$, by Lemma~\ref{lemgenprojl}, we have two families $(B_i)_{i\in I}$ and $(C_i)_{i\in I}$ with $\bigcap_{i\in I}B_i\leq A$ and, for each $i\in I$, $\Gamma\vdash\pa{t}{u}:B_i\times C_i$. For each $i\in I$, by Lemma~\ref{lemgenpair}, we have two families $(B'_j)_{j\in J_i}$ and $(C'_j)_{j\in J_i}$ with $\bigcap_{j\in J_i}(B'_j\times C'_j)\leq B_i\times C_i$ and, for each $j\in J_i$, $\Gamma\vdash t:B'_j$ and $\Gamma\vdash u:C'_j$. By (\ref{axprodinv}), $\bigcap_{j\in J_i}B'_j\leq B_i$. We conclude by: \begin{prooftree} \AIC{\dotsb} \AIC{\dotsb} \AIC{\Gamma\vdash t:B'_j} \AIC{\dotsb} \RL{\cap} \TIC{\Gamma\vdash t:\bigcap_{j\in J_i}B'_j} \AIC{\bigcap_{j\in J_i}B'_j\leq B_i} \LEQ{\Gamma\vdash t:B_i} \AIC{\dotsb} \RL{\cap} \TIC{\Gamma\vdash t:\bigcap_{i\in I}B_i} \AIC{\bigcap_{i\in I}B_i\leq A} \LEQ{\Gamma\vdash t:A} \end{prooftree} \end{proof} \begin{prop}[Subject Expansion for Products] If $t_1\reduct_\pi t_2$ and $\Gamma\vdash t_2:A$ then $\Gamma\vdash t_1:A$. \end{prop} \begin{proof} The key case is $\pl{\pa{t}{u}}\reduct_\pi t$. We have: \begin{prooftree} \AIC{\Gamma\vdash t:A} \OMG{\Gamma\vdash u:\Omega} \PAIR{\Gamma\vdash\pa{t}{u}:A\times\Omega} \PROJL{\Gamma\vdash\pl{\pa{t}{u}}:A} \end{prooftree} \end{proof} Following~\cite{intermixin} in extending \logsys{BCD}{} subtyping in the context of additional type constructors, we can consider the rules of Table~\ref{tabsubbcdprod} for subtyping with products. This system satisfies property~(\ref{axprodinv}) (Lemma~\ref{leminvprod}). \begin{table} \centering \begin{equation*} \AIC{A\leq C} \AIC{B\leq D} \BIC{A\times B\leq C\times D} \DisplayProof \qquad\qquad \ZIC{(A\times B)\cap(C\times D)\leq (A\cap C)\times(B\cap D)} \DisplayProof \end{equation*} \caption{\logsys{BCD}-Style Subtyping Rules for Products.}\label{tabsubbcdprod} \end{table} While the present section focused on the product extension of \logsys{BCD}, our purpose is to use it as a concrete application of a more general pattern of subtyping between types which include intersection as well as other type constructors. What should be remembered from what we have done so far, is that we can get subject reduction and subject expansion as soon as the subtyping relation satisfies Table~\ref{tabsub} as well as (\ref{aximpinv}) and (\ref{axprodinv}). The next section provides a general approach to these results. \section{Intersection Subtyping} \label{secsub} Inspired by~\cite{intermixin}, we directly consider types built with an arbitrary set of constructors. The case of $\times$ for example will be obtained as a particular instance. We go in fact one step further than~\cite{intermixin} by allowing enough generality in the treatment of constructors so that $\rightarrow$ appears as a constructor among others and not as a specific one as given in~\cite{intermixin}. \subsection{Generic Subtyping with Constructors} We consider a given set $\mathcal{K}$ of \emph{type constructors} (denoted $\kappa$, $\kappa_1$, $\kappa_2$, etc) which come with a \emph{contravariant arity} $\convar{\kappa}$ and a \emph{covariant arity} $\covar{\kappa}$. We assume that arities are respected when constructing types, so that if $\convar{\kappa}=2$ and $\covar{\kappa}=1$, then $\kappa(A,B;C)$ is a type when $A$, $B$ and $C$ are three types. Moreover, for each constructor $\kappa$, a $\{0,1\}$-value $\width{\kappa}$ defines its behaviour with respect to top types (see below). Types are thus generated through: \begin{equation*} A,B ::= A\cap B \mid \kappa(\vec A;\vec B) \end{equation*} Base types are provided by constructors with zero arities. We introduce a sequent-calculus-style derivation system \logsys{ISC}{} to define the subtyping relation on these types. We will show that applying proof-theoretical methods, such as cut elimination, allows us to deduce easily some properties of subtyping such as Lemma~\ref{leminv}. Sequents are of the shape $\Gamma\vdash A$ where $\Gamma$ is a (possibly empty) \emph{list} of types. The intended meaning is: \begin{equation*} A_1,\dotsc,A_k\vdash B \text{\quad ``means''\quad} A_1\cap\dotsb\cap A_k\leq B \qquad\qquad\text{(thus if $k=0$, $B$ is a top type)}. \end{equation*} The derivation rules are given in Table~\ref{tabiscons} and satisfy the subformula property. \begin{table} \centering \begin{gather*} \AIC{\Gamma,\Delta\vdash C} \ISCWK{\Gamma,\kappa(\vec A;\vec B),\Delta\vdash C} \DisplayProof \qquad\qquad \AIC{\Gamma\vdash A} \AIC{\Gamma\vdash B} \ISCINTERR{\Gamma\vdash A\cap B} \DisplayProof \qquad\qquad \AIC{\Gamma,A,B,\Delta\vdash C} \ISCINTERL{\Gamma,A\cap B,\Delta\vdash C} \DisplayProof \\[2ex] \AIC{\begin{array}[b]{c}A_1\vdash A_1^1\quad\dotsb\quad A_1\vdash A_1^k \\ \vdots\\ A_{\convar{\kappa}}\vdash A_{\convar{\kappa}}^1\quad\dotsb\quad A_{\convar{\kappa}}\vdash A_{\convar{\kappa}}^k\end{array}} \AIC{\begin{array}[b]{c}B_1^1,\dotsc,B_1^k\vdash B_1\\ \vdots \\ B_{\covar{\kappa}}^1,\dotsc,B_{\covar{\kappa}}^k\vdash B_{\covar{\kappa}}\end{array}} \AIC{\width{\kappa}\leq k} \ISCC{\kappa(A_1^1,\dotsc,A_{\convar{\kappa}}^1;B_1^1,\dotsc,B_{\covar{\kappa}}^1),\dotsc,\kappa(A_1^k,\dotsc,A_{\convar{\kappa}}^k;B_1^k,\dotsc,B_{\covar{\kappa}}^k)\vdash \kappa(A_1,\dotsc,A_{\convar{\kappa}};B_1,\dotsc,B_{\covar{\kappa}})} \DisplayProof \end{gather*} \caption{\logsys{ISC}{} Deduction System.}\label{tabiscons} \end{table} \begin{prop}[Admissible Rules]\label{propisconsadmiss} The following rules are admissible in \logsys{ISC}: \begin{gather*} \begin{array}{c} \AIC{\Gamma\vdash C} \ISCEXC{\Gamma'\vdash C} \DisplayProof\\[2ex] \text{$\Gamma'$ permutation of $\Gamma$} \end{array} \qquad\qquad \AIC{\Gamma,\Delta\vdash C} \ISCWKg{\Gamma,A,\Delta\vdash C} \DisplayProof \qquad\qquad \ISCAX{A\vdash A} \DisplayProof \\[4ex] \AIC{\Gamma,A\cap B,\Delta\vdash C} \ISCINTERLe{\Gamma,A,B,\Delta\vdash C} \DisplayProof \qquad\qquad \AIC{\Gamma,A,A,\Delta\vdash C} \ISCCO{\Gamma,A,\Delta\vdash C} \DisplayProof \qquad\qquad \AIC{\Gamma\vdash A} \AIC{\Delta,A,\Sigma\vdash C} \ISCCUT{\Delta,\Gamma,\Sigma\vdash C} \DisplayProof \end{gather*} \end{prop} \begin{proof} ($\ensuremath{\textit{ex}}$) is obtained by induction on the proof of the premise. ($\ensuremath{\wk_{gen}}$) is obtained by induction on $A$. ($\ensuremath{\textit{ax}}$) is obtained by induction on $A$ using ($\ensuremath{\wk_{gen}}$). ($\ensuremath{{\inter}L_e}$) is obtained by induction on the premise. ($\textit{co}$) is obtained by induction on the lexicographically ordered pair (size of $A$, height of the proof of the premise), by looking at each possible last rule of the premise. The key case is ($\ensuremath{{\inter}L}$): \begin{prooftree} \AIC{\Gamma,A,B,A\cap B,\Delta\vdash C} \ISCINTERL{\Gamma,A\cap B,A\cap B,\Delta\vdash C} \end{prooftree} we apply ($\ensuremath{{\inter}L_e}$) and ($\ensuremath{\textit{ex}}$) to the premise to get $\Gamma,A,A,B,B,\Delta\vdash C$ and we use the induction hypothesis twice. ($\ensuremath{\textit{cut}}$) is obtained by induction on the lexicographically ordered triple (size of $A$, height of the proof of the left premise, height of the proof of the right premise), by looking at possible last rules of the premises. Let us focus on the main cases: \begin{itemize} \item ($\ensuremath{{\inter}R}$) rule on the right: \begin{equation*} \scalebox{0.7}{ \AIC{\pi_1} \noLine \UIC{\Gamma\vdash A} \AIC{\pi_2} \noLine \UIC{\Delta,A,\Sigma\vdash B} \AIC{\pi_3} \noLine \UIC{\Delta,A,\Sigma\vdash C} \ISCINTERR{\Delta,A,\Sigma\vdash B\cap C} \ISCCUT{\Delta,\Gamma,\Sigma\vdash B\cap C} \DisplayProof $\qquad\rightsquigarrow\qquad$ \AIC{\pi_1} \noLine \UIC{\Gamma\vdash A} \AIC{\pi_2} \noLine \UIC{\Delta,A,\Sigma\vdash B} \ISCCUT{\Delta,\Gamma,\Sigma\vdash B} \AIC{\pi_1} \noLine \UIC{\Gamma\vdash A} \AIC{\pi_3} \noLine \UIC{\Delta,A,\Sigma\vdash C} \ISCCUT{\Delta,\Gamma,\Sigma\vdash C} \ISCINTERR{\Delta,\Gamma,\Sigma\vdash B\cap C} \DisplayProof} \end{equation*} we use the induction hypothesis twice with a decreasing height on the right. \item ($\ensuremath{{\inter}R}$) rule on the left and $(\ensuremath{{\inter}L})$ rule on the right: \begin{equation*} \scalebox{0.7}{ \AIC{\pi_1} \noLine \UIC{\Gamma\vdash A} \AIC{\pi_2} \noLine \UIC{\Gamma\vdash B} \ISCINTERR{\Gamma\vdash A\cap B} \AIC{\pi_3} \noLine \UIC{\Delta,A,B,\Sigma\vdash C} \ISCINTERL{\Delta,A\cap B,\Sigma\vdash C} \ISCCUT{\Delta,\Gamma,\Sigma\vdash C} \DisplayProof $\qquad\rightsquigarrow\qquad$ \AIC{\pi_1} \noLine \UIC{\Gamma\vdash A} \AIC{\pi_2} \noLine \UIC{\Gamma\vdash B} \AIC{\pi_3} \noLine \UIC{\Delta,A,B,\Sigma\vdash C} \ISCCUT{\Delta,A,\Gamma,\Sigma\vdash C} \ISCCUT{\Delta,\Gamma,\Gamma,\Sigma\vdash C} \doubleLine \ISCEXC{\dotsb} \doubleLine \ISCCO{\Delta,\Gamma,\Sigma\vdash C} \DisplayProof} \end{equation*} we use the induction hypothesis twice with smaller cut formulas. \item ($\textit{constr}$) rules on both sides (in which we only write the key parts): \begin{gather*} \scalebox{0.65}{ \AIC{\begin{array}{c}\dotsb\quad A_1\vdash A_1^i\quad\dotsb \\ \vdots\\ \dotsb\quad A_{\convar{}}\vdash A_{\convar{}}^i\quad\dotsb\end{array}} \AIC{\begin{array}{c}\dotsc,B_1^i,\dotsc\vdash B_1\\ \vdots \\ \dotsc,B_{\covar{}}^i,\dotsc\vdash B_{\covar{}}\end{array}} \RL{\textit{constr}} \BIC{\dotsc,\kappa(A_1^i,\dotsc,A_{\convar{}}^i;B_1^i,\dotsc,B_{\covar{}}^i),\dotsc\vdash \kappa(A_1,\dotsc,A_{\convar{}};B_1,\dotsc,B_{\covar{}})} \AIC{\begin{array}{c}\dotsb\quad C_1\vdash A_1\quad\dotsb \\ \vdots\\ \dotsb\quad C_{\convar{}}\vdash A_{\convar{}}\quad\dotsb\end{array}} \AIC{\begin{array}{c}\dotsc,B_1,\dotsc\vdash D_1\\ \vdots \\ \dotsc,B_{\covar{}},\dotsc\vdash D_{\covar{}}\end{array}} \RL{\textit{constr}} \BIC{\dotsc,\kappa(A_1,\dotsc,A_{\convar{}};B_1,\dotsc,B_{\covar{}}),\dotsc\vdash \kappa(C_1,\dotsc,C_{\convar{}};D_1,\dotsc,D_{\covar{}})} \ISCCUT{\dotsc,\kappa(A_1^i,\dotsc,A_{\convar{}}^i;B_1^i,\dotsc,B_{\covar{}}^i),\dotsc\vdash \kappa(C_1,\dotsc,C_{\convar{}};D_1,\dotsc,D_{\covar{}})} \DisplayProof} \\[2ex]\rightsquigarrow\qquad \scalebox{0.65}{ \AIC{\dotsb} \AIC{C_p\vdash A_p} \AIC{A_p\vdash A_p^i} \ISCCUT{C_p\vdash A_p^i} \AIC{\dotsb} \AIC{\dotsc,B_p^i,\dotsc\vdash B_p} \AIC{\dotsc,B_p,\dotsc\vdash D_p} \ISCCUT{\dotsc,B_p^i,\dotsc\vdash D_p} \AIC{\dotsb} \RL{\textit{constr}} \QuIC{\dotsc,\kappa(A_1^i,\dotsc,A_{\convar{}}^i;B_1^i,\dotsc,B_{\covar{}}^i),\dotsc\vdash \kappa(C_1,\dotsc,C_{\convar{}};D_1,\dotsc,D_{\covar{}})} \DisplayProof} \end{gather*} we use the induction hypothesis many times (always with smaller cut formulas). \qedhere \end{itemize} \end{proof} Note a $0$-ary constructor $\kappa$ behaves like an atomic type (\emph{i.e.}{} either a type constant or a type variable) if $\width{\kappa}=1$, and defines a top type if $\width{\kappa}=0$: \begin{prooftree} \AIC{\width{\kappa}\leq 0} \RL{\textit{constr}} \UIC{\vdash\kappa} \ISCWKg{A\vdash\kappa} \end{prooftree} In particular the types obtained with such $0$-ary constructors $\kappa$ such that $\width{\kappa}=0$ are all equivalent and we denote them $\Omega$. More generally, $\width{\kappa}$ controls whether $\kappa$ distributes over $\Omega$ or not. In the case of a constructor with unary covariant arity, $\width{\kappa}$ determines whether $\kappa(\vec{A};\Omega)=\Omega$ or not. \begin{prop}[Kernel Properties]\label{propmin} If we define $A\leq B$ as $A\vdash B$ in \logsys{ISC}, the axioms of Table~\ref{tabsub} are satisfied. \end{prop} \begin{proof} (\ref{axsubrefl}) and (\ref{axsubtrans}) correspond to ($\ensuremath{\textit{ax}}$) and ($\ensuremath{\textit{cut}}$) from Proposition~\ref{propisconsadmiss}. (\ref{axsubinterr}) is an instance of ($\ensuremath{{\inter}R}$) and for (\ref{axsubinterll}) we have: \begin{prooftree} \ISCAX{A\vdash A} \ISCWKg{A,B\vdash A} \ISCINTERL{A\cap B\vdash A} \end{prooftree} Finally, if we have a $0$-ary constructor $\Omega$ with $\width{\Omega}=0$, we have just seen it satisfies (\ref{axsubomgr}). \end{proof} \begin{lem}[Inversion]\label{leminv} If $\kappa(A_1^1,\dotsc,A_{\convar{\kappa}}^1;B_1^1,\dotsc,B_{\covar{\kappa}}^1),\dotsc,\kappa(A_1^k,\dotsc,A_{\convar{\kappa}}^k;B_1^k,\dotsc,B_{\covar{\kappa}}^k)\vdash \kappa(A_1,\dotsc,A_{\convar{\kappa}};B_1,\dotsc,B_{\covar{\kappa}})$, there exists $\{i_1,\dotsc,i_p\}\subseteq\{1,\dotsc,k\}$ such that: \begin{equation*} A_1\vdash A_1^{i_1} \;\dotsb\; A_1\vdash A_1^{i_p} \quad\dotsb\quad A_{\convar{\kappa}}\vdash A_{\convar{\kappa}}^{i_1} \;\dotsb\; A_{\convar{\kappa}}\vdash A_{\convar{\kappa}}^{i_p} \quad\text{and}\quad B_1^{i_1},\dotsc,B_1^{i_p}\vdash B_1 \quad\dotsb\quad B_{\covar{\kappa}}^{i_1},\dotsc,B_{\covar{\kappa}}^{i_p}\vdash B_{\covar{\kappa}} \end{equation*} \end{lem} \begin{proof} By induction on the derivation of $\kappa(A_1^1,\dotsc,A_{\convar{\kappa}}^1;B_1^1,\dotsc,B_{\covar{\kappa}}^1),\dotsc,\kappa(A_1^k,\dotsc,A_{\convar{\kappa}}^k;B_1^k,\dotsc,B_{\covar{\kappa}}^k)\vdash \kappa(A_1,\dotsc,A_{\convar{\kappa}};B_1,\dotsc,B_{\covar{\kappa}})$, with only ($\textit{wk}$) and ($\textit{constr}$) as possible last rules. \end{proof} \subsection{The Arrow-Product Instance} \label{secbcdprod} We consider the following set of constructors: \begin{itemize} \item an at most countable set of $0$-ary constructors denoted $X$, $Y$, etc, such that $\width{X}=\width{Y}=\dotsb=1$; \item a $0$-ary constructor $\Omega$ with $\width{\Omega}=0$; \item a constructor $\rightarrow$ with contravariant arity $1$ and covariant arity $1$ such that $\width{\rightarrow}=0$; \item a constructor $\times$ with contravariant arity $0$ and covariant arity $2$ such that $\width{\times}=1$. \end{itemize} By instantiating the $(\textit{constr})$ rule of Table~\ref{tabiscons} to this set of constructors, and using the (\textit{wk}) rule to simplify the $X$ and $\Omega$ cases, we obtain the rules of Table~\ref{tabisconsip} where $k\geq 1$. \begin{table} \centering \begin{gather*} \ISCAXX{X\vdash X} \DisplayProof \qquad \ISCOMG{\vdash\Omega} \DisplayProof \qquad \AIC{A\vdash A_1} \AIC{\dotsb} \AIC{A\vdash A_k} \AIC{B_1,\dotsc,B_k\vdash B} \ISCIMP{A_1\rightarrow B_1,\dotsc,A_k\rightarrow B_k\vdash A\rightarrow B} \DisplayProof \qquad \AIC{\vdash B} \ISCIMPZ{\vdash A\rightarrow B} \DisplayProof \\[2ex] \AIC{A_1,\dotsc,A_k\vdash A} \AIC{B_1,\dotsc,B_k\vdash B} \ISCTIMES{A_1\times B_1,\dotsc,A_k\times B_k\vdash A\times B} \DisplayProof \end{gather*} \caption{\logsys{ISC}{} Deduction System with $\rightarrow$ and $\times$.}\label{tabisconsip} \end{table} \begin{thm}[Equivalence with \logsys{BCD}]\label{thmisconsbcd} $A\vdash B$ in \logsys{ISC}{} with the (\textit{constr}) rule instantiated as given in Table~\ref{tabisconsip} if and only if $A\leq B$ using the rules of Table~\ref{tabsubbcd} extended with the rules of Table~\ref{tabsubbcdprod}. \end{thm} \begin{proof} From left to right, we prove a slightly more general statement: $A_1,\dotsc,A_k\vdash B$ implies $\bigcap_{1\leq i\leq k}A_i\leq B$. From right to left, the key results are in Propositions~\ref{propisconsadmiss} and~\ref{propmin}. Main cases are: \begin{gather*} \ISCAX{C\vdash C} \ISCAX{C\vdash C} \ISCAX{A\vdash A} \ISCWKg{A,B\vdash A} \ISCAX{B\vdash B} \ISCWKg{A,B\vdash B} \ISCINTERR{A,B\vdash A\cap B} \RL{\rightarrow} \TIC{C\rightarrow A,C\rightarrow B\vdash C\rightarrow(A\cap B)} \ISCINTERL{(C\rightarrow A)\cap(C\rightarrow B)\vdash C\rightarrow(A\cap B)} \DisplayProof \qquad\qquad \ISCOMG{\vdash\Omega} \ISCIMPZ{\vdash\Omega\rightarrow\Omega} \ISCWK{\Omega\vdash\Omega\rightarrow\Omega} \DisplayProof \\[3ex] \ISCAX{A\vdash A} \ISCWKg{A,C\vdash A} \ISCAX{C\vdash C} \ISCWKg{A,C\vdash C} \ISCINTERR{A,C\vdash A\cap C} \ISCAX{B\vdash B} \ISCWKg{B,D\vdash B} \ISCAX{D\vdash D} \ISCWKg{B,D\vdash D} \ISCINTERR{B,D\vdash B\cap D} \ISCTIMES{A\times B,C\times D\vdash (A\cap C)\times(B\cap D)} \ISCINTERL{(A\times B)\cap(C\times D)\vdash (A\cap C)\times(B\cap D)} \DisplayProof \end{gather*} \end{proof} \begin{lem}[Inversion for Arrow]\label{leminvimp} If $A\leq B$ is obtained from Tables~\ref{tabsubbcd} and~\ref{tabsubbcdprod}, we have: \begin{equation*} \bigcap_{i\in I}(A_i\rightarrow B_i)\leq A\rightarrow B\;\Rightarrow\; \exists J\subseteq I,\;\left(\bigcap_{i\in J}B_i\leq B\;\wedge\;\forall i\in J,\;A\leq A_i\right) \end{equation*} \end{lem} This is the key property of subtyping allowing for subject $\beta$-reduction to hold in the \logsys{BCD}{} typing system. While the traditional proof goes by induction on the derivation which requires a more general statement to deal with the transitivity rule, we rely here on the subformula property. The traditional approach seems more difficult to use in a context where we may have many type constructors. \begin{proof} By Theorem~\ref{thmisconsbcd}, we have $\bigcap_{i\in I}(A_i\rightarrow B_i)\vdash A\rightarrow B$, thus if $I=\{1,\dotsb,k\}$, we get $A_1\rightarrow B_1,\dotsc,A_k\rightarrow B_k\vdash A\rightarrow B$ by Proposition~\ref{propisconsadmiss}. By applying Lemma~\ref{leminv}, we obtain $A\vdash A_{i_1}$,\dots, $A\vdash A_{i_p}$, $B_{i_1},\dotsc,B_{i_p}\vdash B$ with $J=\{i_1,\dotsc,i_p\}\subseteq I$, so that $\bigcap_{i\in J}B_i\vdash B$, and we conclude with Theorem~\ref{thmisconsbcd}. \end{proof} \begin{lem}[Inversion for Product]\label{leminvprod} If $A\leq B$ is obtained from Tables~\ref{tabsubbcd} and~\ref{tabsubbcdprod}, we have: \begin{equation*} \bigcap_{i\in I}(A_i\times B_i)\leq A\times B\;\Rightarrow\;\bigcap_{i\in I}A_i\leq A\;\wedge\;\bigcap_{i\in I}B_i\leq B \end{equation*} \end{lem} \begin{proof} Similarly by Theorem~\ref{thmisconsbcd}, Proposition~\ref{propisconsadmiss} and Lemma~\ref{leminv}. \end{proof} \subsection{\logsys{BCD}{} Subtyping with Unary Constructors} Our system \logsys{ISC}{} also generalises \logsys{BCD}{} subtyping with unary covariant constructors~\cite{intermixin}. In their setting constructors come as a set of unary covariant operations $\kappa$ on types added to the usual $\rightarrow$ and $\Omega$ constructors: \begin{equation*} A,B ::= X \mid A\rightarrow B \mid A\cap B \mid \Omega \mid \kappa(A) \end{equation*} where each constructor $\kappa$ satisfies the following subtyping properties: \begin{equation*} \AIC{A\leq B} \UIC{\kappa(A)\leq\kappa(B)} \DisplayProof \hspace{2cm} \ZIC{\kappa(A)\cap\kappa(B)\leq\kappa(A\cap B)} \DisplayProof \end{equation*} This exactly corresponds, in the \logsys{ISC}{} setting, to a set of constructors $\kappa$ all satisfying $\convar{\kappa}=0$, $\covar{\kappa}=1$ and $\width{\kappa}=1$ (the constructors $\rightarrow$ and $\Omega$ are obtained as before). For example the associated ($\textit{constr}$) rule can be derived in the \cite{intermixin} setting: \begin{prooftree} \AIC{} \doubleLine \UIC{\bigcap_{1\leq i\leq k}\kappa(A_i)\leq \kappa(\bigcap_{1\leq i\leq k}A_i)} \AIC{\bigcap_{1\leq i\leq k}A_i\leq A} \UIC{\kappa(\bigcap_{1\leq i\leq k}A_i)\leq\kappa(A)} \BIC{\bigcap_{1\leq i\leq k}\kappa(A_i)\leq \kappa(A)} \end{prooftree} \section{Conclusion} We have presented a general way of defining a subtyping relation on intersection types which allows us to extend the \logsys{BCD}{} subtyping to generic contravariant/covariant type constructors. It makes easy to derive key properties used to get subject reduction and subject expansion of the induced type systems. As a concrete example we have fully developed the extension of \logsys{BCD}{} with product types. Our approach can be extended to the case where a preorder relation $\preccurlyeq$ between constructors (with the same arities) leads to $\kappa_1\preccurlyeq\kappa_2\;\Rightarrow\;\kappa_1(\vec A;\vec B)\leq\kappa_2(\vec A;\vec B)$, by a natural generalisation of the ($\textit{constr}$) rule: \begin{prooftree} \AIC{\begin{array}[b]{c}\kappa_1\preccurlyeq \kappa\\ \vdots\\ \kappa_k\preccurlyeq \kappa\end{array}} \AIC{\begin{array}[b]{c}A_1\vdash A_1^1\quad\dotsb\quad A_1\vdash A_1^k \\ \vdots\\ A_{\convar{\kappa}}\vdash A_{\convar{\kappa}}^1\quad\dotsb\quad A_{\convar{\kappa}}\vdash A_{\convar{\kappa}}^k\end{array}} \AIC{\begin{array}[b]{c}B_1^1,\dotsc,B_1^k\vdash B_1\\ \vdots \\ B_{\covar{\kappa}}^1,\dotsc,B_{\covar{\kappa}}^k\vdash B_{\covar{\kappa}}\end{array}} \AIC{\width{\kappa}\leq k} \QIC{\kappa_1(A_1^1,\dotsc,A_{\convar{\kappa}}^1;B_1^1,\dotsc,B_{\covar{\kappa}}^1),\dotsc,\kappa_k(A_1^k,\dotsc,A_{\convar{\kappa}}^k;B_1^k,\dotsc,B_{\covar{\kappa}}^k)\vdash \kappa(A_1,\dotsc,A_{\convar{\kappa}};B_1,\dotsc,B_{\covar{\kappa}})} \end{prooftree} Ordering constructors is natural in the context of object-oriented languages~\cite{nominalsubtyping,intermixin}. Another interesting instance would be the study of sum types, but subject expansion looks more complicated. From $\Gamma\vdash\subst{u}{t}{x}:C$, we can find some type $A$ such that $\Gamma\vdash t:A$ and $\Gamma,x:A\vdash u:C$, but we do not find a way to complete the following derivation: \begin{prooftree} \AIC{\Gamma\vdash t:A} \UIC{\Gamma\vdash \texttt{inl }t:A+\_} \AIC{\Gamma,x:A\vdash u:C} \AIC{\text{\Large ?}} \noLine \UIC{\Gamma,y:\_\vdash v:C} \TIC{\Gamma\vdash\begin{array}[c]{l}\texttt{match inl }t\texttt{ with}\\ \mid\; \texttt{inl } x \;\mapsto\; u \\ \mid\; \texttt{inr } y \;\mapsto\; v \end{array} : C} \end{prooftree} while \quad$\texttt{match inl }t\texttt{ with}\mid\texttt{inl } x \;\mapsto\; u \mid \texttt{inr } y \;\mapsto\; v$\quad reduces to \quad$\subst{u}{t}{x}$. The idea of introducing some bottom type $\alpha$ with a rule \ZIC{\Gamma,x:\alpha\vdash t:C}\DisplayProof seems too naive and breaks the system. We also plan to work on the characterisation of normalizability properties of terms through typing properties in intersection type systems: solvability, normalization, strong normalization, etc. We would like to extend the known results~\cite{interbcd} to the case with more type constructors. \paragraph{Acknowledgements.} We would like to thank to Jan Bessai and Andrej Dudenhefner who suggested investigating \logsys{BCD}{} with constructors. Thanks also to the anonymous referees for their comments. \bibliographystyle{eptcsalpha}
{'timestamp': '2019-04-24T02:04:43', 'yymm': '1904', 'arxiv_id': '1904.10108', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.10108'}
arxiv
\section{Introduction} \label{sec:Intro} Large Intelligent Surfaces (LISs) are envisioned as intrinsic components of beyond-5G wireless systems \cite{Puglielli2015,Hu2018, Faisal2019, Nadeem2019,Jung2018, DeCarvalho2019, Huang2018,Liaskos2018,Bjoernson2019,Sanguinetti2019}. In its core design concept, an LIS realizes a continuous electromagnetically-active surface by stacking a massive number of radiating/sensing elements. These elements interact with the incident signals, for example by reflecting them, in a way that improves the coverage and rate of the wireless systems \cite{Puglielli2015,Hu2018}. This concept is further motivated by the possible energy-efficient implementation using nearly passive elements such as analog phase shifters \cite{Huang2018,Hum2014,Tan2018}. Prior work focused on developing efficient designs for the LIS reflection matrices and evaluating their coverage and rate gains \textit{assuming the existence of global channel knowledge}. \textbf{But how can these extremely large-dimensional channels be estimated if the LIS is implemented using only reflecting elements?} Obtaining this channel knowledge may require huge-and possibly prohibitive-training overhead which represents a main challenge for the operation of the LIS systems. To overcome this challenge, this paper proposes a novel LIS hardware architecture jointly with compressive sensing and deep learning based solutions that design the LIS reflection matrices with negligible training overhead. \subsection{Prior Work} LIS-assisted wireless communication is attracting increased interest in the last few years. In terms of the circuit implementations, LIS surfaces can be realized using nearly passive elements with reconfigurable parameters \cite{Huang2018}. Candidate designs include conventional reflect-arrays \cite{Hum2014,Tan2018}, and software-defined metamaterials \cite{Zhang2018,Liaskos2018} among others. Using these surfaces, several signal processing solutions have been proposed to optimize the design of the LIS reconfigurable parameters (mostly considering the LIS as a reflecting surface) \cite{Huang2018,Nadeem2019,Basar2019}. In \cite{Huang2018}, an LIS-assisted downlink multi-user setup is considered with single-antenna users. The LIS elements in \cite{Huang2018} are modeled as quantized phase shifters/reflectors and computational low-complexity algorithms were developed to design these LIS phase matrices. In \cite{Nadeem2019}, an LIS-assisted downlink scenario, similar to that in \cite{Huang2018}, was considered and the precoder matrix at the base station as well as the LIS reflection matrices were designed, focusing on the case where a line-of-sight (LOS) exists between the base station and the LIS. In \cite{Basar2019}, a new transmission strategy combining LIS with index modulation was proposed to improve the system spectral efficiency. In terms of the overall system performance, \cite{Jung2018} considered an uplink multi-user scenario and characterized the data rates with channel estimation errors. \textbf{The Critical Challenge:} All the prior work in \cite{Huang2018,Nadeem2019,Basar2019,Jung2018,Tan2018} assumed that the knowledge about the channels between the LIS and the transmitters/receivers is available at the base station, either perfectly or with some error. Obtaining this channel knowledge, however, is one of the most critical challenges for LIS systems due to the massive number of antennas (LIS elements) and the hardware constraints on these elements. More specifically, if the LIS elements are implemented using phase shifters that just reflect the incident signals, then there are two main approaches for designing the LIS reflection matrix. The first approach is to estimate the LIS-assisted channels at the transmitter/receiver by training all the LIS elements, normally one by one, and then use the estimated channels to design the reflection matrix. This yields massive channel training overhead due to the very large number of elements at the LIS. Instead of the explicit channel estimation, the LIS reflection matrix can be selected from quantized codebooks via online beam/reflection training. This is similar to the common beam training techniques in mmWave systems that employ similar phase shifter architectures \cite{Wang2009,Hur2013}. To sufficiently quantize the space, however, the size of the reflection codebooks needs normally to be in the order of the number of antennas, which leads to huge training overhead. To avoid this training overhead, a trivial solution is to employ fully-digital or hybrid analog/digital architectures at the LIS, where every antenna element is connected somehow to the baseband where channel estimation strategies can be used to obtain the channels \cite{Alkhateeb2014d,HeathJr2016,Alkhateeb2014}. This solution, however, leads to high hardware complexity and power consumption given the massive number of LIS elements. \subsection{Contribution} In this paper, we consider an LIS-assisted wireless communication system and propose a novel LIS architecture as well as compressive sensing and deep learning based solutions that design the LIS reflection matrix with negligible training overhead. More specifically, the contributions of this paper can be summarized as follows. \begin{itemize} \item \textit{Novel LIS hardware architecture:} We introduce a new LIS architecture where all the elements are passive except a few randomly distributed active channel sensors. Only those few active sensors are connected to the baseband of the LIS controller and are used to enable the efficient design of the LIS reflection matrices with low training overhead. \item \textit{Compressive sensing based LIS reflection matrix design:} Given the new LIS architecture with randomly distributed active elements, we develop a compressive sensing based solution to recover the full channels between the LIS and the transmitters/receivers from the \textit{sampled} channels sensed at the few active elements. Using the constructed channels, we then design the LIS reflection matrices with no training overhead. We show that the proposed solution can efficiently design the LIS reflection matrices when only a small fraction of the LIS elements are active yielding a promising solution for LIS systems from both energy efficiency and training overhead perspectives. \item \textit{Deep learning based LIS reflection matrix design:} Leveraging tools from machine/deep learning, we propose a solution that learns the direct mapping from the sampled channels seen at the active LIS elements and the optimal LIS reflection matrices that maximize the system achievable rate. Essentially, the proposed approach teaches the LIS system how to interact with the incident signal given the knowledge of the sampled channel vectors, that we call \textit{environment descriptors}. In other words, the LIS learns that when it observes these environment descriptors, it should reflect the incident signal using this reflection matrix. Different than the compressive sensing solution, the deep learning approach leverages the prior observations at the LIS and does not require any knowledge of the array structure. \end{itemize} The proposed solutions are extensively evaluated using the accurate ray-tracing based DeepMIMO dataset \cite{DeepMIMO2019}. The results show that the developed compressive sensing and deep learning solutions can approach the optimal upper bound, that assumes perfect channel knowledge, when only a few LIS elements are active and with almost no training overhead, highlighting potential solutions for LIS systems. \textbf{Notation}: We use the following notation throughout this paper: ${\mathbf{A}}$ is a matrix, ${\mathbf{a}}$ is a vector, $a$ is a scalar, $\mathcal{A}$ is a set of scalars, and $\boldsymbol{\mathcal{A}}$ is a set of vectors. $\|{\mathbf{a}} \|_p$ is the p-norm of ${\mathbf{a}}$. $|{\mathbf{A}}|$ is the determinant of ${\mathbf{A}}$, whereas ${\mathbf{A}}^T$, ${\mathbf{A}}^H$, ${\mathbf{A}}^*$, ${\mathbf{A}}^{-1}$, $\pinv{{\mathbf{A}}}$ are its transpose, Hermitian (conjugate transpose), conjugate, inverse, and pseudo-inverse respectively. $[{\mathbf{A}}]_{r,:}$ and $[{\mathbf{A}}]_{:,c}$ are the $r$th row and $c$th column of the matrix ${\mathbf{A}}$, respectively. $\mathrm{diag}({\mathbf{a}})$ is a diagonal matrix with the entries of ${\mathbf{a}}$ on its diagonal. ${\mathbf{I}}$ is the identity matrix. $\mathbf{1}_{N}$ and $\mathbf{0}_{N}$ are the $N$-dimensional all-ones and all-zeros vector respectively. ${\mathbf{A}} \odot {\mathbf{B}}$ and ${\mathbf{A}} \otimes {\mathbf{B}}$ are the Hadamard and Kronecker products of ${\mathbf{A}}$ and ${\mathbf{B}}$, respectively. $\mathcal{N}({\mathbf{m}},{\mathbf{R}})$ is a complex Gaussian random vector with mean ${\mathbf{m}}$ and covariance ${\mathbf{R}}$. ${\mathbb{E}}\left[\cdot\right]$ is used to denote expectation. $\Arg \left( {\mathbf{a}} \right) $ is a vector of arguments of the complex vector ${\mathbf{a}}$. $\boldsymbol{\mathrm{vec}}(\mathbf{A})$ is a vector whose elements are the stacked columns of matrix $\mathbf{A}$. \section{System and Channel Models} \label{sec:SysCh Model} In this section, we describe the adopted system and channel models for the large intelligent surfaces (LISs). \subsection{System Model} \label{sec:Sys_Model} \begin{figure}[t] \centerline{\includegraphics[scale=1]{Sys_Model1.pdf}} \caption{This figure illustrates the system model where the transmitter-receiver communication is assisted by a large intelligent surface (LIS). The LIS is interacting with the incident signal through an interaction matrix $\boldsymbol{\Psi}$.} \label{fig:Sys_Model} \end{figure} Consider the system model shown in \figref{fig:Sys_Model} where a transmitter is communicating with a receiver, and this communication is assisted by a large intelligent surface (LIS). For simplicity, we assume that the LIS has $M$ antennas while both the transmitter and receiver are single-antenna. The proposed solutions and results in this paper, however, can be extended to multi-antenna transceivers. Note also that these transmitters/receivers can represent either base stations or user equipment. Adopting an OFDM-based system of $K$ subcarriers, and defining ${\mathbf{h}}_{\mathrm{T},k}, {\mathbf{h}}_{\mathrm{R},k} \in \mathbb{C}^{M \times 1}$ as the $M \times 1$ uplink channels from the transmitter/receiver to the LIS at the $k$th subcarrier, ${\mathbf{h}}_{\mathrm{T},k}^T, {\mathbf{h}}_{\mathrm{R},k}^T$ as the downlink channels by reciprocity, $h_{\mathrm{TR},k} \in \mathbb{C}$ as the direct channel between the transmitter and receiver, then we can write the received signal at the receiver as \begin{equation} y_k=\underbrace{{\mathbf{h}}_{\mathrm{R},k}^T \boldsymbol{\Psi}_k {\mathbf{h}}_{\mathrm{T},k} s_k}_{\text{LIS-assisted link}} + \underbrace{h_{\mathrm{TR},k} s_k}_\text{Direct link} + n_k, \end{equation} where $s_k$ denotes the transmitted signal over the $k$th subcarrier, and satisfies ${\mathbb{E}}[\left|s_k\right|^2]=\frac{P_\mathrm{T}}{K}$, with $P_\mathrm{T}$ representing the total transmit power, and $n_k \sim \mathcal{N}_\mathbb{C}(0,\sigma_n^2)$ is the receive noise. The $M \times M$ matrix $\boldsymbol{\Psi}_k$, that we call the LIS interaction matrix, represents the \textit{interaction} of the LIS with the incident (impinging) signal from the transmitter. The overall objective of the LIS is then to interact with the incident signal (via adjusting $\boldsymbol{\Psi}_k$) in a way that optimizes a certain performance metric such as the system achievable rate or the network coverage. To simplify the design and analysis of the algorithms in this paper, we will focus on the case where the direct link does not exist. This represents the scenarios where the direct link is either blocked or has negligible receive power compared to that received through the LIS-assisted link. With this assumption, the receive signal can be expressed as \begin{align} y_k&= {\mathbf{h}}_{\mathrm{R},k}^T \boldsymbol{\Psi}_k {\mathbf{h}}_{\mathrm{T},k} s_k + n_k, \\ &\stackrel{(a)}{=} \left( {\mathbf{h}}_{\mathrm{R},k} \odot {\mathbf{h}}_{\mathrm{T},k} \right)^T \boldsymbol{\psi}_k s_k + n_k, \end{align} where (a) follows from noting that the interaction matrix $\boldsymbol{\Psi}_k$ has a diagonal structure, and denoting the diagonal vector as $\boldsymbol{\psi}_k$, i.e., $\boldsymbol{\Psi}_k=\mathrm{diag}\left({\boldsymbol{\psi}_k}\right)$. This diagonal structure results from the operation of the LIS where every element $m, m= 1, 2, ..., M$ reflects the incident signal after multiplying it with an interaction factor $\left[\boldsymbol{\psi}_k\right]_m$. Now, we make two important notes on these interaction vectors. First, while the interaction factors, $\left[\boldsymbol{\psi}_k\right]_m, \forall m,k$, can generally have different magnitudes (amplifying/attenuation gains), it is more practical to assume that the LIS elements are implemented using only phase shifters. Second, since the implementation of the phase shifters is done in the analog domain (using RF circuits), the same phase shift will be applied to the signals on all subcarriers, i.e., $\boldsymbol{\psi}_k=\boldsymbol{\psi}, \forall k$. Accounting for these practical considerations, we assume that every interaction factor is just a phase shifter, i.e., $\left[\boldsymbol{\psi}\right]_m=e^{j \phi_m}$. Further, we will call the interaction vector $\boldsymbol{\psi}$ in this case the \textit{reflection beamforming} vector. \subsection{Channel Model} \label{subsec:Ch_Model} In this paper, we adopt a wideband geometric channel model for the channels ${\mathbf{h}}_{\mathrm{T},k}, {\mathbf{h}}_{\mathrm{R},k}$ between the transmitter/receiver and the LIS \cite{Alkhateeb2018}. Consider a transmitter-LIS uplink channel ${\mathbf{h}}_{\mathrm{T},k}$ (and similarly for ${\mathbf{h}}_{\mathrm{R},k}$) consisting of $L$ clusters, and each cluster $\ell$ is contributing with one ray of time delay $\tau_{\ell} \in {\mathbb{R}}$, a complex coefficient $\alpha_{\ell} \in {\mathbb{C}}$, and azimuth/elevation angles of arrival, $\theta_{\ell},\phi_{\ell} \in [0, 2 \pi)$. Let $\rho_{\mathrm{T}}$ denote the path loss between the transmitter and the LIS and $p\left(\tau\right)$ characterizes the pulse shaping function for $T_{S}$-spaced signaling evaluated at $\tau$ seconds. The delay-$d$ channel vector, $\mathsf{\boldsymbol{h}}_{rd} \in \mathbb{C}^{M \times 1}$, between the transmitter and the LIS can then be defined as \begin{equation} \mathsf{\boldsymbol{h}}_{\mathrm{T}, d} = \sqrt{\frac{M}{\rho_\mathrm{T}}} \sum_{ \ell =1}^L \alpha_{\ell} \ p(d T_S - \tau_{\ell}) \ {\mathbf{a}}\left(\theta_{\ell}, \phi_{\ell} \right), \label{eq:Ch_k} \end{equation} where ${\mathbf{a}}(\theta_{\ell},\phi_{\ell}) \in \mathbb{C}^{M \times 1}$ denotes the array response vector of the LIS at the angles of arrival $\theta_{\ell},\phi_{\ell}$. Given this delay-$d$ channel, the frequency domain channel vector at subcarrier $k$, ${\mathbf{h}}_{\mathrm{T},k}$, can be written as \begin{equation} \label{eq:5} {\mathbf{h}}_{\mathrm{T}, k} = \sum_{d=0}^{D-1} \mathsf{\boldsymbol{h}}_{\mathrm{T}, d} \ e^{-j\frac{2\pi k}{K}d}. \end{equation} Considering a block-fading channel model, ${\mathbf{h}}_{\mathrm{T},k}$ and ${\mathbf{h}}_{\mathrm{R},k}$ are assumed to stay constant over the channel coherence time, denoted $T_{C}$, which depends on the user mobility and the dynamics of the environment among others. It is worth noting that the number of channel paths $L$ depends highly on the operational frequency band and the propagation environment. For example, mmWave channels normally consist of a small number of channel paths, $\sim$3-5 paths, \cite{Rappaport2013,Rappaport2014,Samimi2014}, while sub-6 GHz signal propagation generally experiences rich scattering resulting in channels with more multi-path components. \section{Problem Formulation} \label{sec:Formulation} The objective of this paper is to design the LIS interaction vector (reflection beamforming vector), $\boldsymbol{\psi}$, to maximize the achievable rate at the receiver. Given the system and channel models in \sref{sec:SysCh Model}, this achievable rate can be written as \begin{align} \label{eq:9} R &=\frac{1}{K}\sum_{k=1}^K \log_2\left(1+\mathsf{SNR} \left| {\mathbf{h}}_{\mathrm{R},k}^T \mathbf{\Psi} {\mathbf{h}}_{\mathrm{T},k} \right|^2 \right),\\ &= \frac{1}{K}\sum_{k=1}^K \log_2\left(1+\mathsf{SNR} \left| \left({\mathbf{h}}_{\mathrm{T},k} \odot {\mathbf{h}}_{\mathrm{R},k}\right)^T \boldsymbol{\psi} \right|^2 \right) , \end{align} where $\mathsf{SNR}=\frac{P_{\mathrm{T}}}{K \sigma_n^2}$ denotes the signal-to-noise ratio. As mentioned in \sref{sec:Sys_Model}, every element in the LIS reflection beamforming vector, $\boldsymbol{\psi}$, is implemented using an RF phase shifter. These phase shifters, however, normally have a quantized set of angles and can not shift the signal with any phase. To capture this constraint, we assume that the reflection beamforming vector $\boldsymbol{\psi}$ can only be picked from a pre-defined codebook $\boldsymbol{\mathcal{P}}$. Every candidate reflection beamforming codeword in $\boldsymbol{\mathcal{P}}$ is assumed to be implemented using quantized phase shifters. With this assumption, our objective is then to find the optimal reflection beamforming vector $\boldsymbol{\psi}^\star$ that solves \begin{align} \boldsymbol{\psi}^\star= \argmax_{\boldsymbol{\psi} \in \boldsymbol{\mathcal{P}}} \hspace{10pt} \sum_{k=1}^K \log_2\left(1+\mathsf{SNR} \left| \left({\mathbf{h}}_{\mathrm{T},k} \odot {\mathbf{h}}_{\mathrm{R},k}\right)^T \boldsymbol{\psi} \right|^2 \right), \label{eq:optV} \end{align} to result in the optimal rate $R^\star$ defined as \begin{align} R^\star= \max_{\boldsymbol{\psi} \in \boldsymbol{\mathcal{P}}} \hspace{10pt}\frac{1}{K} \sum_{k=1}^K \log_2\left(1+\mathsf{SNR} \left| \left({\mathbf{h}}_{\mathrm{T},k} \odot {\mathbf{h}}_{\mathrm{R},k}\right)^T \boldsymbol{\psi} \right|^2 \right). \label{eq:optR} \end{align} Due to the quantized codebook constraint and the time-domain implementation of the reflection beamforming vector, i.e., using one interaction vector $\boldsymbol{\psi}$ for all subcarriers, there is no closed form solution for the optimization problem in \eqref{eq:optV}. Consequently, finding the optimal reflection beamforming vector for the LIS $\boldsymbol{\psi}^\star$ requires an exhaustive search over the codebook $\boldsymbol{\mathcal{P}}$. \textbf{The main challenge:} As characterized in \eqref{eq:optV}, finding the optimal LIS interaction vector $\boldsymbol{\psi}^\star$ and achieving the optimal rate $R^\star$ requires an exhaustive search over the codebook $\boldsymbol{\mathcal{P}}$. Note that the codebook size should normally be in the same order of the number of antennas to make use of these antennas. This means that a reasonable reflection beamforming codebook for LIS systems will probably have thousands of candidate codewords. With such huge codebooks, solving the exhaustive search in \eqref{eq:optV} is very challenging. More specifically, there are two main approaches for performing the search in \eqref{eq:optV}. \begin{itemize} \item \textbf{Full channel estimation with offline exhaustive search:} In this approach, we need to estimate the full channels between the LIS and the transmitter/receiver, ${\mathbf{h}}_{\mathrm{T},k}, {\mathbf{h}}_{\mathrm{R},k}$ and use it to find the optimal reflection beamforming vector by the offline calculation of \eqref{eq:optV}. Estimating these channel vectors, however, requires the LIS to employ a complex hardware architecture that connects all the antenna elements to a baseband processing unit either through a fully-digital or hybrid analog/digital architectures \cite{HeathJr2016,Alkhateeb2014d}. Given the massive numbers of antennas at large intelligent surfaces, this approach can yield \textbf{prohibitive hardware complexity} in terms of the routing and power consumption among others. If the LIS is operated and controlled via a base station or an access point \cite{Huang2018}, then this channel estimation process can be done at these communication ends. This, however, assumes an orthogonal training over the LIS antennas, for example by activating one LIS antenna at a time, which leads to \textbf{prohibitive training overhead} given the number of antennas at the LIS. \item \textbf{Online exhaustive beam training:} Instead of the explicit channel estimation, the best LIS beam reflection vector $\boldsymbol{\psi}^\star$ can be found through an over-the-air beam training process. This process essentially solves the exhaustive search in \eqref{eq:optV} by testing the candidate interaction vectors $\boldsymbol{\psi} \in \boldsymbol{\mathcal{P}}$ one by one. This exhaustive beam training process, however, incurs again \textbf{very large training overhead} at the LIS systems. \end{itemize} Our objective in this paper is to enable large intelligent surfaces by addressing this main challenge. More specifically, our objective is to enable LIS systems to approach the optimal achievable rate in \eqref{eq:optR} adopting \textbf{low-complexity hardware architectures} and requiring \textbf{low training overhead}. For this objective, we first propose a novel energy-efficient LIS transceiver architecture in \sref{sec:LIS_arch}. Then, we show in Sections \ref{sec:BL_Solution}-\ref{sec:DL_Solution} how to employ this LIS architecture to achieve near-optimal achievable rates with negligible training overhead via leveraging tools from compressive sensing and deep learning. \section{Large Intelligent Surfaces with Sparse Sensors: A Novel Architecture} \label{sec:LIS_arch} As discussed in \sref{sec:Formulation}, a main challenge for the LIS system operation lies in the high hardware complexity and training overhead associated with designing the LIS interaction (reflection beamforming) vector, $\boldsymbol{\psi}$. In order to overcome this challenge and enable LIS systems in practice, we propose the new LIS architecture in \figref{fig:Sys_Model_Sparse}. In this architecture, the LIS consists of (i) $M$ passive reflecting elements, each one is implemented using an RF phase shifter and is \textit{not connected} to the baseband unit, and (ii) a small number, $\overline{M} \ll M$, of \textit{active} channel sensors distributed over the large intelligent surface. For simplicity, we assume that the $\overline{M}$ active channel sensing elements are selected from the $M$ elements in the LIS and that they have two modes of operation (as shown in \figref{fig:Sys_Model_Sparse}): (i) A channel sensing mode where they work as receivers with full RF chains and baseband processing, and (ii) a reflection mode where they act just like the rest of the passive elements that reflect the incident signal. It is important to note that while we describe the $M$ phase shifting elements as passive elements to differentiate them from the $\overline{M}$ active channel sensors, they are normally implemented using reconfigurable active RF circuits \cite{Hum2014,Foo2017}. Next, we define the channels from the transmitter/receiver to the active channel sensors of the LIS, and then discuss how to leverage this energy-efficient LIS architecture for designing the LIS interaction vector $\boldsymbol{\psi}$. \begin{figure}[t] \centerline{\includegraphics[scale=1]{Sys_Model1_Sparse2.pdf}} \caption{This figure illustrates the proposed LIS architecture where $\overline{M}$ active channel sensors are randomly distributed over the LIS. These active elements have two modes of operation (i) a channel sensing mode where it is connected to the baseband and is used to estimate the channels and (ii) a reflection mode where it just reflects the incident signal by applying a phase shift. The rest of the LIS elements are passive reflectors and are not connected to the baseband.} \label{fig:Sys_Model_Sparse} \end{figure} \textbf{Sampled channel vectors:} We define the $\overline{M} \times 1$ uplink \textit{sampled} channel vector, $\overline{{\mathbf{h}}}_{\mathrm{T},k} \in \mathbb{C}^{\overline{M} \times 1}$, as the channel vector from the transmitter to the $\overline{M}$ active elements at the LIS. This vector can then be expressed as \begin{equation} \label{eq:8} \overline{{\mathbf{h}}}_{\mathrm{T},k} = {\mathbf{G}}_\mathrm{LIS} \ {\mathbf{h}}_{\mathrm{T},k}, \end{equation} where ${\mathbf{G}}_\mathrm{LIS}$ is an $\overline{M} \times M$ selection matrix that selects the entries of the original channel vector, ${\mathbf{h}}_{\mathrm{T},k}$, that correspond to the active LIS elements. If $\mathcal{A}$ defines the set of indices of the active LIS antenna elements, $\left|\mathcal{A}\right|=\overline{M}$, then ${\mathbf{G}}_\mathrm{LIS}=[{\mathbf{I}}]_{\mathcal{A},:}$, i.e., ${\mathbf{G}}_\mathrm{LIS}$ includes the rows of the $M \times M$ identity matrix, ${\mathbf{I}}$, that correspond to the indices of the active elements. The sampled channel vector, $\overline{{\mathbf{h}}}_{\mathrm{R},k} \in \mathbb{C}^{\overline{M} \times 1}$, from the receiver to the $\overline{M}$ active sensors of the LIS is similarly defined. Finally, we define $\overline{\mathbf{h}}_{k} = \overline{\mathbf{h}}_{\mathrm{T},k} \odot \overline{\mathbf{h}}_{\mathrm{R},k}$ as the overall LIS sampled channel vector at the $k$th subcarrier. \textbf{Designing the LIS interaction vector:} For the system model in \sref{sec:Sys_Model} with the proposed LIS architecture in \figref{fig:Sys_Model_Sparse}, estimating the sampled channel vectors $\overline{{\mathbf{h}}}_{\mathrm{T},k}, \overline{{\mathbf{h}}}_{\mathrm{R},k}$ can be easily done with a few pilot signals. For example, adopting an uplink training approach, the transmitter can send one pilot signal that will be simultaneously received and processed by all the active elements in the LIS to estimate $\overline{{\mathbf{h}}}_{\mathrm{T},k}$ (and similarly for $\overline{{\mathbf{h}}}_{\mathrm{R},k}$). Given these sampled channel vectors, however, how can the LIS find the optimal reflection beamforming vector $\boldsymbol{\psi}^\star$ that solves \eqref{eq:optR}? In the next two sections, we propose two approaches for addressing this problem leveraging tools from compressive sensing (in \sref{sec:BL_Solution}) and deep learning (in \sref{sec:DL_Solution}). \section{Compressive Sensing Based LIS Interaction Design} \label{sec:BL_Solution} As shown in \sref{sec:Formulation}, finding the optimal LIS interaction (reflection beamforming) vector $\boldsymbol{\psi}^\star$ that maximizes the achievable rate with no beam training overhead requires the availability of the full channel vectors ${\mathbf{h}}_{\mathrm{T},k}, {\mathbf{h}}_{\mathrm{R},k}$. Estimating these channel vectors at the LIS, however, normally requires that every LIS antenna gets connected to the baseband processing unit through a fully-digital or hybrid architecture \cite{Mendez-Rial2016,Alkhateeb2014d,Alkhateeb2014}. This can massively increase the hardware complexity with the large number of antennas at the LIS systems. In this section, and adopting the low-complexity LIS architecture proposed in \sref{sec:LIS_arch}, we show that it is possible to recover the full channel vectors ${\mathbf{h}}_{\mathrm{T},k}, {\mathbf{h}}_{\mathrm{R},k}$ from the sampled channel vectors $\overline{{\mathbf{h}}}_{\mathrm{T}, k} , \overline{{\mathbf{h}}}_{\mathrm{R}, k}$ when the channels experience sparse scattering. This is typically the case in mmWave and LOS-dominant sub-6 GHz systems. \subsection{Recovering Full Channels from Sampled Channels:} \label{subsec:CS_sol} With the proposed LIS architecture in \figref{fig:Sys_Model_Sparse}, the LIS can easily estimate the \textit{sampled} channel vectors $\overline{{\mathbf{h}}}_{\mathrm{T}, k} , \overline{{\mathbf{h}}}_{\mathrm{R}, k}$ through uplink training from the transmitter and receiver to the LIS with a few pilots. Next, we explain how to use these sampled channel vectors to estimate the full channel vectors ${\mathbf{h}}_{\mathrm{T}, k}, {\mathbf{h}}_{\mathrm{R}, k}$. First, note that the ${\mathbf{h}}_{\mathrm{T}, k}$ in \eqref{eq:Ch_k}, \eqref{eq:5} (and similarly for ${\mathbf{h}}_{\mathrm{R}, k}$) can be written as \begin{align} {\mathbf{h}}_{\mathrm{T}, k} &= \sqrt{\frac{M}{\rho_\mathrm{T}}} \sum_{d=0}^{D-1} \sum_{ \ell =1}^L \alpha_{\ell} \ p(d T_S - \tau_{\ell}) \ {\mathbf{a}}\left(\theta_{\ell}, \phi_{\ell} \right) \ e^{-j\frac{2\pi k}{K}d}, \\ &= \sum_{ \ell =1}^L \beta_{\ell,k} \ {\mathbf{a}}\left(\theta_{\ell}, \phi_{\ell} \right), \end{align} where $\beta_{\ell,k}= \sqrt{\frac{M}{\rho_\mathrm{T}}} \alpha_\ell \sum_{d=0}^{D-1} p(d T_S - \tau_{\ell}) e^{-j\frac{2\pi k}{K}d}$. Further, by defining the array response matrix ${\mathbf{A}}$ and the $k$th subcarrier path gain vector $\boldsymbol{\beta}$ as \begin{align} {\mathbf{A}} &=\left[ {\mathbf{a}}\left(\theta_{1}, \phi_{1} \right), {\mathbf{a}}\left(\theta_{2}, \phi_{2} \right) ..., {\mathbf{a}}\left(\theta_{L}, \phi_{L} \right)\right], \\ \boldsymbol{\beta}_k &= \left[ \beta_{1,k}, \beta_{2,k}, ..., \beta_{L,k}\right]^T, \end{align} we can write ${\mathbf{h}}_{\mathrm{T}, k}$ in a more compact way as ${\mathbf{h}}_{\mathrm{T}, k} = {\mathbf{A}} \ \boldsymbol{\beta}$. Now, we note that in several important scenarios, such as mmWave and LOS-dominant sub-6 GHz, the channel experiences sparse scattering, which results is a small number of paths $L$ \cite{Rappaport2014,HeathJr2016}. In order to leverage this sparsity, we follow \cite{Alkhateeb2014} and define the dictionary of array response vectors ${\mathbf{A}}_\text{D}$, where every column constructs an an array response vector in one quantized azimuth and elevation direction. For example, if the LIS adopts a uniform planar array (UPA) structure, then we can define ${\mathbf{A}}_\text{D}$ as \begin{equation} {\mathbf{A}}_\text{D}={\mathbf{A}}^\mathrm{Az}_{\mathrm{D}} \otimes {\mathbf{A}}^\mathrm{El}_{\mathrm{D}} \end{equation} with ${\mathbf{A}}^\mathrm{Az}_{\mathrm{D}}$ and ${\mathbf{A}}^\mathrm{El}_{\mathrm{D}}$ being the dictionaries of the azimuth and elevation array response vectors. Every column in ${\mathbf{A}}^\mathrm{Az}_{\mathrm{D}}$ (and similarly for ${\mathbf{A}}^\mathrm{El}_{\mathrm{D}}$ ) constructs an azimuth array response in one quantized azimuth (elevation) direction. If the number of grid points in the azimuth and elevation dictionaries are $N_\mathrm{D}^\mathrm{Az}$ and $N_\mathrm{D}^\mathrm{El}$, respectively, and the number of horizontal and vertical elements of the UPA are $M_\mathrm{H}, M_\mathrm{V}$, where $M=M_\mathrm{H} M_\mathrm{V}$, then ${\mathbf{A}}_\text{D}$ has dimensions $M \times N_\mathrm{D}^\mathrm{Az} N_\mathrm{D}^\mathrm{El}$. Now, assuming that size of the grid is large enough such that the azimuth and elevation angles $\theta_\ell, \phi_\ell, \forall \ell$ matches exactly $L$ points in this grid (which is a common assumption in the formulations of the sparse channels estimation approaches \cite{Alkhateeb2014,HeathJr2016,Lee2014}), then we can rewrite ${\mathbf{h}}_{\mathrm{T}, k}$ as \begin{equation} \label{eq:construct_h} {\mathbf{h}}_{\mathrm{T}, k} = {\mathbf{A}}_\mathrm{D} \ {\mathbf{x}}_{\boldsymbol{\beta}}, \end{equation} where ${\mathbf{x}}_{\boldsymbol{\beta}}$ is an $N_\mathrm{D}^\mathrm{Az} N_\mathrm{D}^\mathrm{El}$ sparse vector with $L \ll N_\mathrm{D}^\mathrm{Az} N_\mathrm{D}^\mathrm{El}$ non-zero entries equal to the elements of $\boldsymbol{\beta}$. Further, these non-zero entries are in the positions that correspond to the channel azimuth/elevation angles of arrival. Next, let $\widehat{\overline{{\mathbf{h}}}}_{\mathrm{T}, k}$ denote the noisy sampled channel vectors, then we can write \begin{align} \widehat{\overline{{\mathbf{h}}}}_{\mathrm{T}, k} & = {\mathbf{G}}_{\mathrm{LIS}} {\mathbf{h}}_{\mathrm{T},k} + {\mathbf{v}}_k, \\ & = {\mathbf{G}}_{\mathrm{LIS}}{\mathbf{A}}_\mathrm{D} \ {\mathbf{x}}_{\boldsymbol{\beta}} + {\mathbf{v}}_k, \\ & = \boldsymbol{\Phi} \ {\mathbf{x}}_{\boldsymbol{\beta}} + {\mathbf{v}}_k, \end{align} where ${\mathbf{v}}_k \sim \mathcal{N}_\mathbb{C} \left(\boldsymbol{0}, \sigma_n^2 {\mathbf{I}} \right)$ represent the receive noise vector at the LIS active channel sensors and ${\mathbf{G}}_\mathrm{LIS}$ is the selection matrix defined in \eqref{eq:8}. Now, given the equivalent sensing matrix, $\boldsymbol{\Phi}$ and the noisy sampled channel vector $\widehat{\overline{{\mathbf{h}}}}_{\mathrm{T}, k}$, the objective is to estimate the sparse vector ${\mathbf{x}}_{\boldsymbol{\beta}}$ that solves the non-convex combinatorial problem \begin{equation} \label{eq:sparse_h} \min \left\|{\mathbf{x}}_{\boldsymbol{\beta}}\right\|_0 \ \ \ \text{s.t.} \ \left\| \widehat{\overline{{\mathbf{h}}}}_{\mathrm{T}, k} - \boldsymbol{\Phi} \ {\mathbf{x}}_{\boldsymbol{\beta}}\right\|_2 \leq \sigma. \end{equation} Given the sparse formulation in \eqref{eq:sparse_h}, several compressive sensing reconstruction algorithms, such as orthogonal matching pursuit (OMP) \cite{Cai2011a,Tropp2004a}, can be employed to obtain an approximate solution for ${\mathbf{x}}_{\boldsymbol{\beta}}$. With this solution for ${\mathbf{x}}_{\boldsymbol{\beta}}$, the full channel vector ${\mathbf{h}}_{\mathrm{T},k}$ can be constructed according to \eqref{eq:construct_h}. Finally, the constructed full channel vector can be used to find the LIS reflection beamforming vector $\boldsymbol{\psi}$ via an offline search using \eqref{eq:optV}. In this paper, we assume for simplicity that the $\overline{M}$ active channel sensors are randomly selected from the $M$ LIS elements, assuming that all the elements are equally likely to be selected. It is important, however, to note that the specific selection of the active elements designs the compressive sensing matrix $\boldsymbol{\Phi}$ and decides its properties. Therefore, it is interesting to explore the optimization of the active element selection, leveraging tools from nested arrays \cite{Pal2010}, co-prime arrays \cite{Vaidyanathan2011,Tan2014}, incoherence frames \cite{Rusu2018}, and difference sets \cite{Giannakis2005,Mendez-Rial2016}. \subsection{Simulation Results and Discussion:} \label{subsec:CS_results} \begin{figure}[t] \centerline{\includegraphics[scale=.6]{Fig11.pdf}} \caption{ This figure plots the achievable rates using the proposed compressive sensing based solution for two scenarios, namely a mmWave 28GHz scenario and a low-frequency 3.5GHz one. These achievable rates are compared to the optimal rate $R^\star$ in \eqref{eq:optR} that assumes perfect channel knowledge. The figure illustrates the potential of the proposed solutions that approach the upper bound while requiring only a small fraction of the total LIS elements to be active.} \label{fig:CS} \end{figure} To evaluate the performance of the proposed compressive sensing based solution, we consider a simulation setup at two different carrier frequencies, namely 3.5GHz and 28GHz. The simulation setup consists of one large intelligent surface with a uniform planar array (UPA) in the y-z plane, which reflects the signal coming from one transmitter to another receiver, as depicted in \figref{fig:Setup}. This UPA consists of $16 \times 16$ antennas at 3.5GHz and $64 \times 64$ antennas at 28GHz. We generate the channels using the publicly-available ray-tracing based DeepMIMO dataset \cite{DeepMIMO2019}, with the 'O1' scenario that consists of a street and buildings on the sides of the street. Please refer to \sref{subsec:Sim_Setup} for a detailed description of the simulation setup and its parameters. Given this described setup, and adopting novel LIS architecture in \figref{fig:Sys_Model_Sparse}, we apply the proposed compressive-sensing based solution described in \sref{subsec:CS_sol} as follows: (i) We obtain the channel vectors ${\mathbf{h}}_{\mathrm{T},k}, {\mathbf{h}}_{\mathrm{R},k}$ using the ray-tracing based DeepMIMO dataset, and add noise with the noise parameters described in \sref{subsec:Sim_Setup}. (ii) Adopting the LIS architecture in \figref{fig:Sys_Model_Sparse}, we randomly select $\overline{M}$ elements to be active and construct the sampled channel vectors $\widehat{\overline{{\mathbf{h}}}}_{\mathrm{T}, k}, \widehat{\overline{{\mathbf{h}}}}_{\mathrm{R}, k}$. (iii) Using OMP with a grid of size $N_\mathrm{D}^\mathrm{Az} N_\mathrm{D}^\mathrm{El}, N_\mathrm{D}^\mathrm{Az}=2 M_\mathrm{H}, N_\mathrm{D}^\mathrm{El}=2 M_\mathrm{V}$, we recover an approximate solution of the full channel vectors and use this to search for the optimal LIS interaction vector using \eqref{eq:optV}. The achievable rate using this proposed compressive sensing based solution is shown in \figref{fig:CS} compared to the upper bound with perfect full channel knowledge, calculated according to \eqref{eq:optR}. \textbf{Gains and Limitations:} In \figref{fig:CS}, we plot the achievable rates of the proposed compressive sensing based solution and upper bound versus the ratio of the active elements to the total number of antennas, i.e., $\overline{M}/M$. As shown in this figure, the proposed novel LIS architecture with the compressive sensing based solution can achieve almost the optimal rate with a small fraction of the LIS antennas being active. This illustrates the significant saving in power consumption that can be achieved using the LIS architecture in \figref{fig:Sys_Model_Sparse} that includes a few active channel sensors. Further, since the LIS reflection beamforming vector $\boldsymbol{\psi}$ is obtained through an offline search with no beam training, the proposed solution approaches the optimal rate with negligible training overhead, ideally two uplink pilots to estimate $\widehat{\overline{{\mathbf{h}}}}_{\mathrm{T}, k}, \widehat{\overline{{\mathbf{h}}}}_{\mathrm{R}, k}$. This enables the proposed LIS systems to support highly-mobile applications such as vehicular communications and wireless virtual/augmented reality. Despite this interesting gain of the proposed compressive sensing based solution, it has a number of limitations. First, recovering the full channel vectors from the sampled ones according to \sref{subsec:CS_sol} requires the knowledge of the array geometry and is hard to extend to LIS systems with unknown array structures. Second, the compressive sensing solution relies on the sparsity of the channels and its performance becomes limited in scenarios with rich NLOS scattering. This is shown in \figref{fig:CS} as the compressive sensing based solution requires a higher ratio of the LIS elements to be active to approach the upper bound in the 3.5GHz scenario that has more scattering than the mmWave 28GHz case. Further, the compressive sensing solution does not leverage the previous observations to improve the current channel recovery. These limitations motivate the deep learning based solution that we propose in the following section. \section{Deep Learning Based LIS Interaction Design} \label{sec:DL_Solution} In this section, we introduce a \textit{novel} application of deep learning in the reflection beamforming design problem of large intelligent surfaces. The section is organized as follows: First, the key idea of the proposed deep learning (DL) based reflection beamforming design is explained. Then, the system operation and the adopted deep learning model are diligently described. We refer the interested reader to \cite{Goodfellow2016} for a brief background on deep learning. \subsection{The Key Idea} \label{subsec:keyIdea} \begin{figure}[t] \includegraphics[width = \linewidth]{KeyIdea.pdf} \caption{This figure summarizes the key idea of the proposed deep learning solution. The sampled channel vectors are considered as environment descriptors as they define, with some resolution, the transmitter/receiver locations and the surrounding environment. The deep learning model learns how to map the observed environment descriptors to the optimal LIS reflection vector. } \label{fig:Key_idea} \end{figure} The large intelligent surfaces are envisioned as key components of future networks \cite{Huang2018}. These surfaces will interact with the incident signals, for example by reflecting them, in a way that improves the wireless communication performance. In order to decide on this interaction, however, the LIS systems or their operating base stations and access points need to acquire some knowledge about the channels between the LIS and the transmitter/receiver. As we explained in \sref{sec:Formulation}, the massive number of antennas at these surfaces makes obtaining the required channel knowledge associated with (i) prohibitive training overhead if all the LIS elements are passive or (ii) infeasible hardware complexity/power consumption in the case of fully-digital or hybrid based LIS architectures. The channel vectors/matrices, however, are intuitively some functions of the various elements of the surrounding environment such as the geometry, scatterer materials, and the transmitter/receiver locations among others. Unfortunately, the nature of this function---its dependency on the various components of the environment---makes its mathematical modeling very hard and infeasible in many cases. This dependence though means that the interesting role the LIS is playing could be enabled with some form of awareness about the surrounding environment. With this motivation, and adopting the proposed LIS architecture in \figref{fig:Sys_Model_Sparse}, we propose to consider the sampled channels seen by the few active elements of the LIS as \textit{environment descriptors} capturing a multi-path signature \cite{Alkhateeb2018,Alkhateeb2018b,Li2018b}, as shown in \figref{fig:Key_idea}. We then adopt deep learning models to learn the mapping function from these environment descriptors to the optimal LIS interaction (reflection beamforming) vectors. \textbf{In other words, we are teaching the LIS system how to interact with the wireless signal given the knowledge of the environment descriptors (sampled channel vectors).} It is worth emphasizing here that the sampled channel vectors can be obtained with negligible training overhead as explained in \sref{sec:LIS_arch}. In the ideal case, the learning model will be able to predict the optimal interaction vector given the environment descriptors. Achieving this means that the LIS system can approach the optimal rate in \eqref{eq:optR} with negligible training overhead (that is required to obtain the sampled channel vectors) and with low-complexity architectures (as only a few elements of the LIS are active). \subsection{Proposed System Operation} \label{subsec:Sys_Oper} In this section, we describe the system operation of the proposed deep learning based LIS interaction approach. The proposed system operates in two phases, namely (I) the learning phase and (II) the prediction phase. \\ \LinesNotNumbered \begin{algorithm}[t] \textbf{PHASE I: Learning phase} \\ \For{ $s=1$ \KwTo $S$} { \tcp{For every channel coherence block $s$.} \nl \label{Alg_H_bar_estI}LIS receives two pilots from the transmitter and receiver and estimates $\widehat{\overline{{\mathbf{h}}}}(s)$. \For{ $n=1$ \KwTo $\left|\boldsymbol{\mathcal{P}}\right|$ }{ \nl \label{Alg_ES1}LIS Reflects using $\boldsymbol{\psi}_n$ beam and receives the feedback $R_{n}(s)$. } \nl \label{DSx}LIS constructs ${\mathbf{r}}(s)=[R_{1}(s), R_2(s), ..., R_{|\boldsymbol{\mathcal{P}}|}(s)]$. \nl \label{DS}A new data point is added to the learning dataset: $\mathcal{D} \leftarrow \left\langle \widehat{\overline{{\mathbf{h}}}}(s), {\mathbf{r}}_{s} \right\rangle$. \nl \label{DT_2}LIS uses the interaction vector $\boldsymbol{\psi}_{n^\star}$, with $n^\star=\argmax_n R_n(s)$, for the data reflection. } \nl \label{DLTrain1} Train the DL model using the available dataset $\mathcal{D}$. \textbf{PHASE II: Prediction phase} \\ \While{True}{ \tcp{Repeat every channel coherence block.} \nl \label{Alg_H_bar_estII}LIS receives two pilots from the transmitter and receiver, and estimates $\widehat{\mathbf{\overline{h}}}$. \nl \label{Pred}LIS predicts the interaction (reflection) vector using the trained DL model. \nl \label{DT_2_II}LIS uses the interaction vector $\boldsymbol{\psi}_{n^\mathrm{DL}}$, with $n^\mathrm{DL}=\argmax_n \hat{R}_n$, for the data reflection. } \caption{Proposed Deep Learning Based Reflection Beamforming} \label{alg1} \end{algorithm} \textbf{PHASE I: Learning phase} In this phase, the LIS employs an exhaustive search reflection beamforming approach as will be explained shortly while it is collecting the dataset for the deep learning model. Once the dataset is fully acquired, the LIS trains the deep learning model. Let the term ``data sample" indicate the data captured in one coherence block, and define the concatenated sampled channel vector $\overline{\mathbf{h}} = \textbf{vec} \left( \left[ \overline{\mathbf{h}}_{1}, \overline{\mathbf{h}}_{2}, \dotsc, \overline{\mathbf{h}}_{K} \right] \right)$. Further, let $\overline{\mathbf{h}}(s)$ denote the concatenated sampled channel vector at coherence block $s, s=1, ..., S$. As depicted in Algorithm \ref{alg1}, at every coherence block $s$, the proposed LIS system operation consists of four steps, namely estimating the sampled channel vector, exhaustive beam training, constructing a new data sample for the learning dataset, and data transmission. After collecting the dataset, the deep learning model is trained. Next, we describe these steps in detail. \begin{enumerate} \item \textit{Sampled channel estimation (line \ref{Alg_H_bar_estI}):} For every channel coherence block $s$, the transmitter and receiver transmits two orthogonal uplink pilots. The active elements of the LIS will receive these pilots and estimate the sampled channel vectors \begin{equation} \widehat{\overline{{\mathbf{h}}}}_{\mathrm{T}, k}(s) = \overline{{\mathbf{h}}}_{\mathrm{T},k}(s) + {\mathbf{v}}_k, \label{eq:noisy_ch} \end{equation} % where ${\mathbf{v}}_k \sim \mathcal{N}_\mathbb{C} \left(\boldsymbol{0}, \sigma_n^2 {\mathbf{I}} \right)$ represent the receive noise vector at the LIS active channel sensors. The receiver-LIS sampled channel vector $\widehat{\overline{{\mathbf{h}}}}_{\mathrm{R}, k}(s)$ will be similarly estimated. Finally, the vectors $\widehat{\overline{\mathbf{h}}}_{k}(s) = \widehat{\overline{\mathbf{h}}}_{\mathrm{T},k}(s) \odot \widehat{\overline{\mathbf{h}}}_{\mathrm{R},k}(s)$ and $\widehat{\overline{\mathbf{h}}}(s) = \textbf{vec} \left( \left[ \widehat{\overline{\mathbf{h}}}_{1}(s), \widehat{\overline{\mathbf{h}}}_{2}(s), \dotsc, \widehat{\overline{\mathbf{h}}}_{K}(s) \right] \right)$ will be constructed. \item \textit{Exhaustive search over reflection beamforming codewords (line \ref{Alg_ES1}):} In this step, the LIS performs an exhaustive beam training using the interaction/reflection codebook $\boldsymbol{\mathcal{P}}$. Particularly, the LIS attempts every candidate reflection beamforming vector, $\boldsymbol{\psi}_{n}, n=1, ..., |\boldsymbol{\mathcal{P}}|$, and receives a feedback from the receiver indicating the achievable rate using this interaction vector, $R_{n}{(s)}$, defined as \begin{equation} R_{n}^{(s)} = \frac{1}{K}\sum_{k=1}^K \log_2\left(1+\mathsf{SNR} \left| \left({\mathbf{h}}_{\mathrm{T},k}(s) \odot {\mathbf{h}}_{\mathrm{R},k}(s)\right)^T \boldsymbol{\psi}_n \right|^2 \right). \end{equation} \label{eq:23} % Note that, in practice, the computation and feedback of the achievable rate $R_{n}^{(s)}$ will have some error compared to \eqref{eq:23} due to the limitations in the pilot sequence lentgh and feedback channel, which are neglected in this paper. For the rest of the paper, we define the achievable rate vector at coherence block $s$ as ${\mathbf{r}}(s)=[R_{1}(s), R_2(s), ..., R_{|\boldsymbol{\mathcal{P}}|}(s)]$. \item \textit{Adding a data point to the dataset (lines \ref{DSx}-\ref{DS}):} The new data point of the sampled channel vector and the corresponding rate vector $\left\langle \mathbf{\overline{h}}_{s}, {\mathbf{r}}_{s} \right\rangle$ is added to the deep learning dataset $\mathcal{D}$ \item \textit{Data transmission stage (line \ref{DT_2}):} After the beam training, the optimal reflection beamforming vector, $\boldsymbol{\psi}_{n^\star}$, with the highest achievable rate $n^\star=\argmax_n R_n(s)$ is used to reflect the transmitted data from the transmitter for the rest of the coherence block. \item \textit{Deep learning model training (line \ref{DLTrain1}):} After acquiring the data entries for all $S$ coherence blocks, the deep learning model is trained using the entire dataset $\mathcal{D}$. This model learns how to map an input (the sampled channel vector $\widehat{\overline{{\mathbf{h}}}}$) to an output (predicted achievable rate with every candidate interaction vector $\widehat{{\mathbf{r}}} = \left[ \widehat{R}_{1}, \widehat{R}_{2}, \dotsc, \widehat{R}_{|\boldsymbol{\mathcal{P}}|} \right]$), as shown in \figref{fig:NN_model}. It is worth mentioning here that while we assume that the system will switch one time to PHASE II after the deep learning model is trained, the system will need to retrain and refine the model frequently to account for the changes in the environment. \end{enumerate} \textbf{PHASE II: Prediction phase} Following the deep learning model training in PHASE I, the LIS leverages the trained DL model to predict the reflection beamforming vector directly from the estimated \textit{sampled} channel vector, $\widehat{\overline{\mathbf{h}}}$. As shown in Algorithm \ref{alg1}, Phase II performs the following steps for every channel coherence block. \begin{enumerate} \item \textit{Sampled channel estimation (line \ref{Alg_H_bar_estII}):} This step is the same as the first step in PHASE I. \item \textit{Achievable rate prediction (line \ref{Pred}):} In this step, the estimated \textit{sampled} channel vector, $\widehat{\overline{\mathbf{h}}}$, is fed into the deep learning model to predict the achievable rate vector, $\widehat{{\mathbf{r}}}$. \item \textit{Data transmission (line \ref{DT_2_II}):} In this step, the predicted deep learning reflection beamforming vector, $\boldsymbol{\psi}_{n^\mathrm{DL}}$, that corresponds to the highest predicted achievable rate, is used for reflecting the transmitted data (signal). Note that instead of selecting only the interaction vector with the highest predicted achievable rate, the LIS can generally select the $k_\mathrm{B}$ beams corresponding to the $k_\mathrm{B}$ highest predicted achievable rates. It can then refine this set of beams online with the receiver to select the one with the highest achievable rate. We evaluate the performance gain if more than one reflection beam are selected in \sref{subsec:Tuning}. \end{enumerate} \subsection{Deep Learning Model} \label{subsec:DL Model} Recent years have proven deep learning to be one of the most successful machine learning paradigms \cite{DLAppMeth}. With this motivation, a deep neural network is chosen in this work to be the model with which the desired LIS interaction function is learned. In the following, the elements of this model are described. \textbf{Input Representation:} A single input to the neural network model is defined as a stack of environment descriptors (sampled channel vectors $\widehat{\overline{{\mathbf{h}}}}_k$) obtained from a pair of transmitter and receiver at $K$ different sub-carrier frequencies. This sets the dimensionality of a single input vector to $K \overline{M}$. A common practice in machine learning is the normalization of the input data. This guarantees a stable and meaningful learning process \cite{EffBP}. The normalization method of choice here is a simple per-dataset scaling; all samples are multiplied by a factor that is the inverse of the maximum absolute value over the whole input data \begin{equation}\label{normInput} \widehat{\overline{{\mathbf{h}}}}_\mathrm{norm} = \frac{1}{\Delta}\widehat{\overline{{\mathbf{h}}}}, \end{equation} where $\Delta$ is given by \begin{equation} \label{MaxAbs} \Delta = \max_{\substack{ {b = 1, \dotsc, K \overline{M}}} } \left| \widehat{\overline{h}}_{b} \right|, \end{equation} and $\widehat{\overline{h}}_{b}$ is the $b^{th}$ complex entry of $\widehat{\overline{{\mathbf{h}}}}$. Besides helping the learning process, this normalization choice preserves distance information encoded in the environment descriptors. This way the model learns to become more aware of the surroundings, which is the bedrock for proposing a machine-learning-powered LIS. The last pre-processing step of input data is to convert them into real-valued vectors without losing the imaginary-part information. This is done by splitting each complex entry into real and imaginary values, doubling the dimensionality of each input vector. The main reason behind this step is the modern implementations of DL models, which mainly use real-valued computations. \textbf{Target Representation:} The learning approach used in this work is supervised learning. This means the model is trained with input data that are accompanied by their so-called \textit{target responses} \cite{Goodfellow2016}. They are basically the desired responses the model is expected to approximate when it encounters inputs like those in the input training data. Since the target of the training process is to learn a function mapping descriptors to reflection vectors, the model is designed to output a set of predictions on the achievable rates of every possible reflection beamforming vector in the codebook $\left|\boldsymbol{\mathcal{P}}\right|$. Hence, the training targets are real-valued vectors, ${\mathbf{r}}(s), s=1, ..., S$, with the desired rate for each possible reflection vector. For the same training-efficiency reason expressed for the input representation, the labels are usually normalized. The normalization used in this work is pre-sample scaling where every vector of rates ${\mathbf{r}}(s)$ is normalized using its maximum rate value $\max_n \left[{\mathbf{r}}(s)\right]_n$. The choice of normalizing each vector independently guards the model against being biased towards some strong responses. In terms of our LIS application, it gives the receivers equal importance regardless of how close or far they are from the LIS. \begin{figure}[t] \includegraphics[width = \linewidth]{NN2.pdf} \caption{The adopted neural network architecture consists of $Q$ fully-connected layers. Each layer is followed by a non-linear ReLU activation layer. The deep learning model learns how to map the observed sampled channel vectors to the predicted achievable rate using every LIS interaction vector.} \label{fig:NN_model} \end{figure} \textbf{Neural Network Architecture:} The DL model is designed as a Multi-Layer Perceptron (MLP) network, sometimes referred to as feedforward Fully Connected network. It is well-established that MLP networks are universal function approximators \cite{UniApprox}. This motivates adopting an MLP network to capture the relation between the environment descriptors and the LIS interaction (reflection beamforming) vectors. The proposed MLP model consists of $Q$ layers, as illustrated in \figref{fig:NN_model}. The first $Q-1$ of them alternate between fully-connected and non-linearity layers and the last one (output layer) is a fully-connected layer. The $q^{th}$ layer in the network has a stack of $N_q$ neurons, each of which sees all the outputs of the previous layer. For the non-linearity layers, they all employ Rectified Linear Units (ReLUs) \cite{Goodfellow2016}. Each unit operates on a single input value outputting another single value. Hence, the number of units per layer equals the number of outputs of the previous fully-connected layer. \textbf{Training Loss Function:} The model training process aims at minimizing a loss function that measures the quality of the model predictions. Given the objective of predicting the best reflection beam vector, $\boldsymbol{\psi}_{n^\mathrm{DL}}$, having the highest achievable rate estimate, $\max_n \widehat{R}_n$, the model is trained using a regression loss function. At every coherence block, the neural network is trained to make its output, $\widehat{{\mathbf{r}}}$, as close as possible to the desired output, the normalized achievable rates, $\overline{{\mathbf{r}}}$. Specifically, the training is guided through minimizing the loss function, $L\left(\boldsymbol{\theta}\right)$, expressed as \begin{equation} \label{eq:24} L\left(\boldsymbol{\theta}\right)= \mathsf{MSE} \left( \overline{{\mathbf{r}}}, \widehat{{\mathbf{r}}}\right), \end{equation} where $\boldsymbol{\theta}$ represents the set of all the neural network parameters and $\mathsf{MSE} \left( \overline{{\mathbf{r}}}, \widehat{{\mathbf{r}}} \right)$ indicates the mean-squared-error between $\overline{{\mathbf{r}}}$ and $\widehat{{\mathbf{r}}}$. \section{Simulation Results} \label{sec:Results} In this section, we evaluate the performance of both the deep learning (DL) and the compressive sensing (CS) based reflection beamforming approaches. The flow of this section is as follows. First, we describe the adopted experimental setup and datasets. Then, we compare the performance of the deep learning and compressive sensing solutions at both mmWave and sub-6 GHz bands. After that, we investigate the impact of different system and machine learning parameters on the performance of the deep learning solution. \begin{figure}[t] \centerline{\includegraphics[scale=.3]{Setup_DeepMIMO.png}} \caption{This figure illustrates the adopted ray-tracing scenario where an LIS is reflecting the signal received from one fixed transmitter to a receiver. The receiver is selected from an x-y grid of candidate locations. This ray-tracing scenario is generated using Remcom Wireless InSite \cite{Remcom}, and is publicly available on the DeepMIMO dataset \cite{DeepMIMO2019}. } \label{fig:Setup} \end{figure} \subsection{Simulation Setup} \label{subsec:Sim_Setup} Given the geometric channel model adopted in \sref{sec:SysCh Model} and the nature of the reflection beamforming optimization problem, with its strong dependence on the environmental geometry, it is critical to evaluate the performance of the proposed solutions based on realistic channels. This motivates using channels generated by ray-tracing to capture the dependence on the key environmental factors such as the environment geometry and materials, the LIS and transmitter/receiver locations, the operating frequency, etc. To do that, we adopted the DeepMIMO dataset, described in detail in \cite{DeepMIMO2019}, to generate the channels based on the outdoor ray-tracing scenario `O1' \cite{Remcom}, as will be discussed shortly. The DeepMIMO is a parameterized dataset published for deep learning applications in mmWave and massive MIMO systems. The machine learning simulations were executed using the Deep Learning Toolbox of MATLAB R2019a. Next, we explain in detail the key components of the simulation setup. \begin{table}[h] \caption{The adopted DeepMIMO dataset parameters} \begin{center} \begin{tabular}{ | c | c | } \hline \textbf{DeepMIMO Dataset Parameter} & \textbf{Value} \\ \hline \hline Active BSs & $3$ \\ \hline Active users emulating the receivers & From row R1000 to row R1300 \\ \hline Active user emulating the transmitter & row R850 column 90 \\ \hline Number of BS Antennas & $\left(M_x, M_y, M_z\right) = \left(1,16,16 \right); \left(1,32,32 \right);\left(1,64,64\right)$ \\ \hline Antenna spacing & $0.5$ \\ \hline System bandwidth & $100$ MHz \\ \hline Number of OFDM subcarriers & $512$ \\ \hline OFDM sampling factor & $1$ \\ \hline OFDM limit & $64$ \\ \hline Number of paths & $1, 2, 5, 10$ \\ \hline \end{tabular} \end{center} \label{table:DeepMIMOpset} \end{table} \textbf{System model:} We adopt the system model described in \sref{sec:Sys_Model} with one large intelligent surface that reflects the signal received from a transmitter to a receiver. The transmitter is assumed to be fixed while the receiver can take any random position in a specified x-y grid as illustrated in \figref{fig:Setup}. We implemented this setup using the outdoor ray-tracing scenario 'O1' of the DeepMIMO dataset that is publicly available at \cite{DeepMIMO2019}. As shown in \figref{fig:Setup}, we select BS 3 in the 'O1' scenario to be the LIS and the user in row R850 and column 90 to be the fixed transmitter. The uniform x-y grid of candidate receiver locations include $54300$ points from row R1000 to R1300 in the 'O1' scenario where every row consists of 181 points. Unless otherwise mentioned, the adopted LIS employs a UPA with 64x64 ($M=4096$) antennas at the mmWave 28GHz setup and a UPA with 16x16 ($M=256$) antennas at the 3.5GHz setup. The active channel sensors described in \sref{sec:LIS_arch} are randomly selected from the $M$ UPA antennas. The transmitter and receiver are assumed to have a single antenna each. The antenna elements have a gain of 3dBi and the transmit power is 35dBm. The rest of the adopted DeepMIMO dataset parameters are summarized in Table \ref{table:DeepMIMOpset}. \textbf{Channel generation:} The channels between the LIS and the transmitter/receiver, ${\mathbf{h}}_{\mathrm{T},k}, {\mathbf{h}}_{\mathrm{R},k}$, for all the candidate receiver locations in the x-y grid, are constructed using the DeepMIMO dataset generation code \cite{DeepMIMO2019} with the parameters in Table \ref{table:DeepMIMOpset}. With these channels, and given the randomly selected active elements in the proposed LIS architecture, we construct the sampled channel vectors $\overline{{\mathbf{h}}}_{\mathrm{T},k}, \overline{{\mathbf{h}}}_{\mathrm{R},k}$. The noisy sampled channel vectors $\widehat{\overline{{\mathbf{h}}}}_{\mathrm{T},k}, \widehat{\overline{{\mathbf{h}}}}_{\mathrm{R},k}$ are then generated by adding noise vectors to $\overline{{\mathbf{h}}}_{\mathrm{T},k}, \overline{{\mathbf{h}}}_{\mathrm{R},k}$ according to \eqref{eq:noisy_ch}, with the noise power calculated based on the bandwidth and other parameters in Table \ref{table:DeepMIMOpset}, and with receiver noise figure of $5$dB. These noisy sampled channels are then used to design the LIS interaction (reflection beamforming) vectors following the proposed compressive sensing and deep learning approaches. \textbf{LIS interaction (reflection beamforming) codebook:} We adopt a DFT codebook for the candidate LIS interaction vectors. More specifically, considering the UPA structure, we define the LIS interaction codebook as $\mathrm{DFT}_{M_\mathrm{H}} \otimes \mathrm{DFT}_{M_\mathrm{V}}$. The codebook $\mathrm{DFT}_{M_\mathrm{H}} \in \mathbb{C}^{{M_\mathrm{H}} \times {M_\mathrm{H}}}$ is a DFT codebook for the azimuth (horizontal) dimension where the $m_\mathrm{H}$th column, $m_\mathrm{H}=1,2, ...,M_\mathrm{H}$, is defined as $[1, e^{-j \frac{2 \pi}{M_\mathrm{H}} m_\mathrm{H}}, ..., e^{-j (M_\mathrm{H}-1) \frac{2 \pi}{M_\mathrm{H}} m_\mathrm{H} } ]^T$. The codebook $\mathrm{DFT}_{M_\mathrm{V}}$ is similarly defined. \textbf{Deep learning parameters:} We adopt the deep learning model described in \sref{subsec:DL Model}. To reduce the neural network complexity, however, we input the normalized sampled channels only at the first $K_\mathrm{DL}=64$ subcarriers, where $K_\mathrm{DL} \leq K$, which sets the length of the DL input vector to be $2\overline{M} K_\mathrm{DL}$. The length of the DL output vector is $M=|\boldsymbol{\mathcal{P}}|$, as described in \sref{subsec:DL Model}. The neural network architecture consists of four fully connected layers. The number of hidden nodes of the four layers are $M, 4 M, 4 M, M$, respectively, where $M$ is the number of LIS antennas. Given the size of the x-y grid of the candidate receiver locations in \figref{fig:Setup}, the deep learning dataset has $54300$ data points. We split this dataset into two sets, namely a training set and a testing set with $85\%$ and $15\%$ of the points, respectively. Unless otherwise mentioned, we consider a batch size of $500$ samples and a $50 \%$ dropout rate. The dropout layer is added after every ReLU layer. \begin{figure}[t] \centerline{\includegraphics[width=0.75\columnwidth,height=260pt]{Simfigure8b.pdf}} \caption{The achievable rate of both proposed CS and DL based reflection beamforming solutions are compared to the upper bound $R^\star$ and the CS based beamforming approach, for different numbers of active receivers, $\overline{M}$. The figure is generated at $f_c = 28$ GHz, $M=64 \times 64$ antennas, and $L=10$ paths.} \label{fig:Sim8b} \end{figure} \textbf{Compressive sensing parameters:} We consider the developed compressive sensing solution in \sref{sec:BL_Solution} to recover the full LIS-transmitter/receiver channels and design the LIS reflection beamforming vectors. For approximating the solution of \eqref{eq:sparse_h}, we use OMP with a grid of size $N_\mathrm{D}^\mathrm{Az} N_\mathrm{D}^\mathrm{El}$ points, where $N_\mathrm{D}^\mathrm{Az}=2 M_\mathrm{H}, N_\mathrm{D}^\mathrm{El}=2 M_\mathrm{V}$. Next, we evaluate the performance of the developed compressive sensing and deep learning solutions for designing the LIS interaction vectors. \begin{figure}[t] \centerline{\includegraphics[width=0.75\columnwidth,height=260pt]{Fig8Ax.pdf}} \caption{The achievable rate of the proposed DL based reflection beamforming approach compared to the upper bound $R^\star$ and the CS based beamforming approach, for different numbers of active receivers, $\overline{M}$. The figure is generated at $f_c = 3.5$ GHz, $M=16 \times 16$ antennas, and $L=15$ paths.} \label{fig:Sim8a} \end{figure} \subsection{Achievable Rates with Compressive Sensing and Deep Learning Based LIS Systems} \label{subsec:Compare_CS_DL} In this subsection, we evaluate the achievable rates of the proposed compressive sensing (CS) and deep learning (DL) based reflection beamforming solutions for LIS systems. These rates are compared to the genie-aided upper bound, $R^\star$, in \eqref{eq:optR} which assumes perfect knowledge of the full channel vectors ${\mathbf{h}}_{\mathrm{T},k}, {\mathbf{h}}_{\mathrm{R},k}$. In \figref{fig:Sim8b}, we consider the simulation setup in \sref{subsec:Sim_Setup} at the mmWave 28GHz band with LIS employing a UPA of $64 \times 64$ antennas. The channels are constructed to include the strongest $L=10$ channel paths. Further, the LIS employs the proposed architecture in \figref{fig:Sys_Model_Sparse} with only $\overline{M}$ active sensors. \figref{fig:Sim8b} shows that the proposed deep learning solution approaches the optimal upper bound with a very small number of active antennas. For example, with only $\overline{M}=4$ active antennas (out of $M=4096$ total antennas), the deep learning solution achieves almost $85\%$ of the optimal achievable rate. This figure also illustrates the performance gain of the deep learning solution compared to the compressive sensing approach, especially when the number of active antennas is very small. Note that the two solutions approach the upper bound with $28-36$ active antennas, which represent less than $1\%$ of the total number of antennas ($M=4096$) in the LIS. This illustrates the high energy efficiency of the proposed LIS architecture and reflection beamforming solutions. \begin{figure}[t] \centerline{\includegraphics[width=0.75\columnwidth,height=260pt]{Simfigure1.pdf}} \caption{The achievable rate of the proposed DL based reflection beamforming approach is compared to the upper bound $R^\star$ and the CS beamforming approach, for different numbers of active receivers, $\overline{M}$. The adopted setup considers an LIS with $64 \times 64$ UPA. This figure highlights the promising gain of the proposed deep learning solution that approaches the upper bound using only $8$ active elements (less than $1\%$ of the total number of antennas). This performance requires collecting a dataset of around 20-25 thousand data points (user locations).} \label{fig:Sim1} \end{figure} To evaluate the performance at sub-6 GHz systems, we plot the achievable rates of the proposed deep learning and compressive sensing solutions compare to the optimal rate $R^\star$ in \figref{fig:Sim8a}. This figure adopts the simulation setup in \sref{subsec:Sim_Setup} at a $3.5$GHz band. The LIS is assumed to employ a UPA with $16 \times 16$ antennas and each channel incorporates the strongest $L=15$ paths. \figref{fig:Sim8a} shows that the proposed deep learning and compressive sensing solutions are also promising for sub-6 GHz LIS systems. This is captured by the convergence to the upper bound with only $4$ active elements in the deep learning case and around $18$ elements in the compressive sensing case. This figure also illustrates the larger gain of the deep learning solution compared to the compressive sensing approach in the sub-6 GHz systems, where the channels are less sparse than mmWave systems. This gain, however, has the cost of collecting a dataset to train the deep learning model, which is not required in the compressive sensing approach. \begin{figure}[t] \centerline{\includegraphics[width=0.75\columnwidth,height=260pt]{Simfigure2.pdf}} \caption{The achievable rate of the proposed DL based reflection beamforming approach is compared to the upper bound $R^\star$ for different sizes of intelligent surfaces, namely with LIS of $32 \times 32$ and $64 \times 64$ UPAs. The number of active elements (channel sensors) equals $\overline{M}=8$. } \label{fig:Sim2} \end{figure} \subsection{How much training is needed for the deep learning model?} \label{subsec:Efficiency} The data samples in the deep learning dataset are captured when the receiver is randomly sampling the x-y grid. In \figref{fig:Sim1}, we study the performance of the developed deep learning approach for designing the LIS interaction vectors for different dataset sizes. This illustrates the improvement in the machine learning prediction quality as it sees more data samples. For \figref{fig:Sim1}, we adopt the simulation setup in \sref{subsec:Sim_Setup} with an LIS of $64 \times 64$ UPA and a number of active channel sensors $\overline{M}=2,4$, and $8$. The setup considers a mmWave $28$GHz scenario and the channels are constructed with only the strongest path, i.e., $L=1$. \figref{fig:Sim1} shows that with only $8$ active antennas, the proposed deep learning solution can achieve almost $90\%$ of the optimal rate in \eqref{eq:optR} when the model is trained on $10$ thousand data points (out of the 53400 points) in the x-y grid. Further, this figure highlights the performance gain of the deep learning approach compared to the compressive sensing solution. This gain increases with larger dataset sizes as the compressive sensing solution does not leverage the prior channel estimation/LIS interaction observations and its performance does not depend on the size of the dataset. \subsection{Impact of Important System and Channel Parameters} \label{subsec:Impact} \begin{figure}[t] \centerline{\includegraphics[width=0.75\columnwidth,height=260pt]{Fig4x.pdf}} \caption{The achievable rate of the proposed deep learning based reflection beamforming approach is compared to the upper bound $R^\star$, for different values of user transmit power, $P_\mathrm{T}$. The figure is generated for an LIS with $M=64 \times 64$ UPA and $\overline{M}=8$ active elements. This figure shows that the proposed DL solution is capable of learning and approaching the optimal achievable rate even with a relatively small transmit power.} \label{fig:Sim4} \end{figure} In this subsection, we evaluate the impact of the key system and channel parameters on the performance of the developed deep learning solution. \textbf{Number of LIS antennas:} \figref{fig:Sim2} examines the achievable rate performance of the developed solutions for designing the LIS interaction vectors when the LIS employs either a $32 \times 32$ or a $64 \times 64$ UPA. This figure adopts the same mmWave scenario considered in \figref{fig:Sim1}. As illustrated, with only $\overline{M}=8$ active receivers, the proposed deep learning solution approaches the optimal rate in \eqref{eq:optR} that assumes perfect channel knowledge for different LIS sizes. This shows the potential of the proposed LIS architecture and deep learning solution in enabling large intelligent surfaces with large numbers of antennas. \textbf{Note that the proposed solution does not requires any beam training overhead (as it relies on the deep learning prediction of the best beam) and needs only $8$ active receivers to realize this near-optimal performance in \figref{fig:Sim2}}. \textbf{Transmit power:} In \figref{fig:Sim4}, we study the impact of the transmit power (and receive SNR) on the achievable rate performance of the developed deep learning solution. This is important in order to evaluate the robustness of the learning and prediction quality, as we input the noisy sampled channel vectors to the deep learning model. In \figref{fig:Sim4}, we plot the achievable rates of the proposed deep learning solution as well as the upper bound in \eqref{eq:optR} for three values of the transmit power, $P_\mathrm{T}=-5, 0, 5$ dBW. These transmit powers map to \textit{receive} SNR values of $-3.8, 6.2, 16.2$ dB, respectively, including the LIS beamforming gain of the $4096$ antennas. The rest of the setup parameters are the same as those adopted in \figref{fig:Sim1}. \figref{fig:Sim4} illustrates that the proposed deep learning solution can perform well even with relatively small transmit powers and low SNR regimes. \begin{figure}[t] \centerline{\includegraphics[width=0.75\columnwidth,height=260pt]{Simfigure6.pdf}} \caption{The achievable rate of the proposed DL based reflection beamforming approach is compared to the upper bound $R^\star$, for different numbers of channel paths, $L$. The figure is generated for an LIS with $64 \times 64$ UPA and $\overline{M}=4$ active elements. As the number of channel paths increases, the achievable rate achieved by the proposed DL solution converges slower to the upper bound. Hence, using more training data can help learn multi-path signatures. } \label{fig:Sim6} \end{figure} \textbf{Number of channel paths:} In \figref{fig:Sim6}, we investigate the impact of the number of channel paths on the performance of the developed deep learning solution. In other words, we examine the robustness of the proposed deep learning model with multi-path channels. For this figure, we adopt the same simulation setup of \figref{fig:Sim1} with an LIS employing $64 \times 64$ UPA. The channels are constructed considering the strongest $L=1, 2$, or $5$ channel paths. As illustrated in \figref{fig:Sim6}, with the increase in the number of channel paths, the achievable rate by the proposed deep learning solution converges slower to the upper bound. This shows that the proposed deep learning model can learn from multi-path channels if a large enough dataset is available. \begin{figure}[t] \centerline{\includegraphics[width=0.75\columnwidth,height=260pt]{Simfigure5.pdf}} \caption{The achievable rate of the proposed DL based reflection beamforming approach is compared to the upper bound $R^\star$. The simulation considers an LIS with $64 \times 64$ UPA and $\overline{M}=4$ active channel sensors. The figure illustrates the achievable rate gain when the beams selected by the deep learning model is further refined through beam training over $k_\mathrm{B}$ beams. } \label{fig:Sim5} \end{figure} \subsection{Refining the deep learning prediction } \label{subsec:Tuning} In \figref{fig:Sim8b}-\figref{fig:Sim6}, we considered the proposed deep learning solution where the deep learning model use the sampled channel vectors to predict the best beam and this beam is directly used to reflect the transmitted data. Relying completely on the deep learning model to determine the reflection beamforming vector has the clear advantage of eliminating the beam training overhead and enabling highly-mobile applications. The achievable rates using this approach, however, may be sensitive to small changes in the environment. A candidate approach for enhancing the reliability of the system is to use the machine learning model to predict the most promising $k_\mathrm{B}$ beams. These beams are then refined through beam training with the receiver to select the final beam reflection vector. Note that the most promising $k_\mathrm{B}$ beams refer to the $k_\mathrm{B}$ beams with the highest predicted rates from the deep learning model. To study the performance using this approach, we plot the achievable rate of the deep learning solution in \figref{fig:Sim5}, for different values of $k_\mathrm{B}$. As this figure shows, refining the most promising $k_\mathrm{B}$ yields higher achievable rates compared to the case when the LIS relies completely on the deep learning model to predict the best beam, i.e., with $k_\mathrm{B}$. The gain in \figref{fig:Sim5} is expected to increase with more time-varying and dynamic environment, which is an interesting extension in the future work. \section{Conclusion} \label{sec:Conclusion} In this paper, we considered LIS-assisted wireless communication systems and developed efficient solutions that design the LIS interaction (reflection) matrices with negligible training overhead. More specifically, we first introduced a novel LIS architecture where only a small number of the LIS elements are active (connected to the baseband). Then, we developed two solutions that design the LIS reflection matrices for this new architecture with almost no training overhead. The first solution leverages compressive sensing tools to construct the channels at all the antenna elements from the \textit{sampled} channels seen only at the active elements. The second approach exploits deep learning tools to learn how to predict the optimal LIS reflection matrices directly from the sampled channel knowledge, which represent what we call \textit{environment descriptors}. Extensive simulation results based on accurate ray-tracing showed that the two proposed solutions can achieve near-optimal data rates with negligible training overhead and with a small number of active elements. Compared to the compressive sensing solution, the deep learning approach requires a smaller number of active elements to approach the optimal rate thanks to leveraging its prior observations. Further, the deep learning approach does not require any knowledge of the LIS array geometry and does not assume sparse channels. To achieve these gains, however, the deep learning model needs to collect enough dataset, which is not needed in the compressive sensing solution. For the future work, it is interesting to investigate other machine learning models such as the use of reinforcement learning that does not require an initial dataset collection phase. For the compressive sensing solution, there are several interesting extensions, including the optimization of the sparse distribution of the active sensors leveraging tools from nested and co-prime arrays. \linespread{1.2}
{'timestamp': '2019-05-01T02:21:27', 'yymm': '1904', 'arxiv_id': '1904.10136', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.10136'}
arxiv
\section{INTRODUCTION} 3D scene understanding is a fundamental task with widespread applications in robotics, augmented reality and autonomous driving. For autonomous vehicles it is critical to observe the poses and 3D shapes of other cars for navigation planning and control. Yet the inference of such object properties from images is a challenging task due to camera projection, variability in view-point, appearance and lighting condition, transparent or reflective non-lambertian surfaces on cars, etc. The community therefore has so far mainly cogitated upon estimating bounding boxes which only contain coarse information on the object poses and sizes. Although with the advances in computer vision 2D object detection has gradually evolved to delivering finer grained results such as instance segmentations, 3D methods are still focusing on estimated bounding boxes. \begin{figure}[t] \centering \includegraphics[width=0.47\textwidth]{images/teaser_new_small.png} \caption{We propose to jointly estimate 3D vehicle poses and shapes directly on image intensities using shape priors. Top: The initial and our estimated 3D poses and shapes in 3D. Note that the LiDAR point clouds are only for visualization and are not used in our method. Bottom: The input image and its overlay with our results.} \label{fig:teaser} \vspace{-4.5ex} \end{figure} In this paper, we address joint 3D rigid-body pose estimation and shape reconstruction from a single stereo image pair using 3D shape priors, as illustrated in Fig.~\ref{fig:teaser}. Shape priors allow for confining the search space over possible shapes and make vision based pose and shape estimation more robust to effects such as occlusion, lighting conditions or reflective surfaces. We use volumetric signed distance functions (SDF) to implicitly represent the shape of exemplar car models and a linear low-dimensional subspace embedding of the shapes. While previous works made it possible to align the 3D shape geometrically to point clouds estimated by stereo reconstruction \cite{engelmann2016joint,engelmann2017samp}, we infer shapes and poses directly from images, thus avoid introducing the errors from stereo matching into the pipeline. In our case, the shape prior is aligned with detected cars in stereo images using photometric and silhouette consistency constraints which we formulate as a non-linear least squares problem and optimize using the Gauss-Newton method. Experiments demonstrate superior performance of our method over the previous approach that uses geometric alignment with dense stereo reconstructions. Moreover, as learning based 3D object detectors have become more popular, we also show that our method can be applied as a refinement step that significantly boosts the performances of all the tested methods. In summary, our contributions are: \begin{itemize} \itemsep0em \item A novel approach for joint 3D pose and shape estimation that delivers more precise and fine grained results than 3D bounding boxes that are commonly estimated by most of the current methods. \item Our approach works directly in image space and thus avoids introducing errors from intermediate steps. It delivers superior performance over the previous approach that uses a geometric formulation for alignment. \item A fully differentiable formulation that operates directly between image and SDF based 3D shape embedding. \item Our method can be applied together with state-of-the-art learning based approaches and significantly boosts the performances of all the tested methods. \end{itemize} \section{Related Work} \begin{figure*}[t] \centering \includegraphics[width=0.98\textwidth]{images/system_overview.png} \caption{System overview. As input our method takes a stereo frame $\mathrm{I}^{l}$, $\mathrm{I}^{r}$, an initial object pose $\mathrm{T}_{init}$, the learned mean shape $\mathrm{\Phi}_{mean}$, and the object segmentation masks $\mathrm{M}^{l}$, $\mathrm{M}^{r}$. Based on the current pose and shape, the object is projected to $\mathrm{I}^{l}$ and $\mathrm{I}^{r}$ and the consistencies between the projections and the segmentation masks are measured by the silhouette alignment residuals $\mathrm{r}_{silh}$ (Sec.\ref{subsec:segmentaton_term}). Meanwhile, the object pixels in $\mathrm{I}^{l}$ can be warped to $\mathrm{I}^{r}$. The color consistencies are measured by the photometric consistency residuals $\mathrm{r}_{photo}$ (Sec.\ref{subsec:photo_term}). The two terms together with the prior terms (Sec.\ref{subsec:prior}) are formulated as a non-linear energy function and optimized using the Gauss-Newton method. As output, our method delivers refined object pose $\mathrm{T}_{est}$ and shape $\mathrm{\Phi}_{est}$.} \vspace{-3ex} \label{fig:system_overview} \end{figure*} {\bf 3D object detection.} Many successful object detectors have been focusing on localizing objects by 2D bounding boxes~\cite{felzenszwalb2009object, ren2015_fasterrcnn, dai2016r, dai2017deformable, redmon2017_yolo9000} and later by segmentation masks~\cite{chen2017deeplab, he2017mask, kirillov2019panoptic} in images. As object detection in 2D matures, the community starts to target at the much more challenging 3D object detection task~\cite{satkin2013_3dnn, 3dopNIPS15, shuran2014_3dslidingshapes, cvpr16chen, mousavian20173d, xu2018multi, licvpr2019, wang2019pseudo, kundu20183d}. Chen et al.~\cite{3dopNIPS15} present 3DOP that first generates 3D object proposals in stereo reconstructions and then scores them in the 2D image using Faster-RCNN~\cite{ren2015_fasterrcnn}. By combining the 3D orientations and dimensions regressed by a network with 2D geometric constraints, Mousavian et al.~\cite{mousavian20173d} largely improve the stability and accuracy of 3D detection. While recent deep learning based methods continue to boost the quality of the estimated 3D bounding boxes~\cite{xu2018multi, licvpr2019, wang2019pseudo}, Kundu et al.~\cite{kundu20183d} first propose to use a network to regress the 3D pose and shape at the same time, yet the shape is not evaluated in their paper. At the current stage, learning based approaches still can only provide a coarse estimate of the object pose and shape. Moreover, it is an open research question how to assess the quality of learning based detections. Optimization based methods can refine coarse detections and introspect the quality of the fit of the measurements to the model. We believe that is where they come to the stage. Based on the coarse 3D poses estimated by the learning based approaches, our optimization pipeline jointly refines the poses and estimates precise 3D shapes, which contain much more information than 3D bounding boxes and we believe are more useful for applications such as obstacle avoidance and new view synthesis. {\bf 3D scene understanding.} The availability of large-scale 3D model databases, capable 3D object detectors and fast rendering techniques have spawned novel interest in the use of geometric methods for 3D scene understanding. Salas-Moreno et al.~\cite{salasmoreno2013_slampp} integrate object instances into RGB-D SLAM. The object instances are included as additional nodes in pose graph optimization which finds a consistent camera trajectory and object pose estimate. Geiger and Wang~\cite{Geiger2015GCPR} infer 3D object and scene layout from a single RGB-D image by aligning CAD object models with the scene. The approach in~\cite{Ortizcayon3DV16} detects cars using a CNN-based detector, estimates dense depth using multi-view stereo and aligns a 3D CAD model to the detected car using depth and silhouette constraints. Closely related to our approach, Engelmann et al.~\cite{engelmann2016joint,engelmann2017samp} use 3D shape embeddings to determine pose and shape of cars which are initially detected by 3DOP~\cite{3dopNIPS15}. They also embed volumetric signed distance fields (SDF) of CAD models using PCA and formulate a non-linear least squares problem. Their data term, however, relies on a dense stereo reconstruction and measures the distance of reconstructed points to the object surface. It is thus susceptible to the errors of the black-box stereo reconstruction algorithm. Our approach does not require dense stereo matching but directly fits 3D SDF shape embeddings through photometric and silhouette alignment to the stereo images. While silhouette alignment has been used previously to align 3D object models~\cite{Sandhu2011_kernelsegposerecon, Prisacariu2012_segposerecon, DameCVPR13}, these methods mainly focus on controlled settings such as only one dominated object appears in the image. By combining silhouette alignment with photometric alignment and explicitly addressing occlusions, we target at the much more challenging real-world traffic scenarios. \section{Proposed Method} \subsection{Notations} Throughout this paper, $\mathbf{p}$ and $\mathbf{X}$ respectively denote image pixels and 3D points. Subscripts $o$ and $c$ define coordinates in object and camera coordinate system. 3D rigid body transformations $\mathbf{T}^{b}_{a} = [\mathbf{R}^{b}_{a}, \mathbf{t}^{b}_{a}; 0, 1] \in \text{SE}(3)$ transforms coordinates from system $a$ to system $b$, where $\mathbf{R}$ and $\mathbf{t}$ are the 3D rotation matrix and translation vector. In our optimization, 3D poses are represented by their twist coordinates in Lie-algebra $\boldsymbol{\xi} \in \mathfrak{se}(3)$ and 3D shapes are represented by a SDF voxel grid $\mathbf{\Phi}$. PCA is performed to embed 3D shapes into a low dimensional space~\cite{engelmann2016joint,engelmann2017samp} and thus each shape can be represented by $\mathbf{\Phi(\mathbf{z})} = \mathbf{Vz} + \mathbf{\Phi}_{mean}$, where $\mathbf{V}$ is the transpose of the subspace projection matrix, $\mathbf{z}$ the shape encoding vector and $\mathbf{\Phi}_{mean}$ the mean shape of the gathered object set. The SDF value of a location within the 3D grid is obtained by trilinear interpolation to achieve subvoxel accuracy. While more sophisticated nonlinear shape encodings like Kernel PCA and GP-LVM~\cite{dambreville2008framework, sandhu2011nonrigid,prisacariu2011nonlinear, prisacariu2011shared, prisacariu2012simultaneous, zheng2015object} exist, we find for cars the PCA model is sufficient. Nevertheless, our formulation is agnostic to the shape representation, thus can be easily adopted for other SDF based shape encodings. \subsection{System Overview} An overview of our system is shown in Fig.~\ref{fig:system_overview}. Given a stereo frame with the object segmentations in both images, the quality of the current estimate of the object pose and shape can be measured by two energy terms: (1) by projecting the current shape to both images, a silhouette alignment term ${E}_{silh}$ measures the consistencies of the projections with the corresponding segmentation masks; (2) object pixels in the left image are warped to the right image and the photometric consistency term ${E}_{photo}$ measures the color differences. Based on domain knowledge, we add priors terms on the object pose and shape. Our final energy function combines the terms above and is optimized using the Gauss-Newton method. In the following we present the details of each energy term. \subsection{Silhouette Alignment Term} \label{subsec:segmentaton_term} The silhouette alignment term measures the consistency between the image segmentation masks $\mathbf{M}^{l/r}$ and the object masks obtained by projecting the 3D SDF shape embedding $\mathbf{\Phi}$ into the images based on its current shape and pose estimate. Denoting the value of the shape projection mask at pixel $\mathbf{p}$ by $\pi(\mathbf{\Phi},\mathbf{p})$ (details later) which holds values close to 1 inside and 0 outside the object, the consistency with $\mathbf{M}^{l/r}$ can be expressed by \begin{equation} E_{silh}^{l/r} = \frac{1}{|\Omega|}\sum_{\mathbf{p} \in \Omega} r_{silh}^{l/r}(\mathbf{p}), \end{equation} \begin{equation} r_{silh}^{l/r}(\mathbf{p}) = -\text{log} \big( \pi(\mathbf{\Phi}, \mathbf{p}) p_{fg}(\mathbf{p}) + (1 - \pi(\mathbf{\Phi}, \mathbf{p})) p_{bg}(\mathbf{p}) \big), \end{equation} where $\Omega$ is the set of the pixels of this object instance, $p_{fg}$ and $p_{bg}$ are the foreground and background probabilities from $\mathbf{M}^{l/r}$. Ideally, if at $\mathbf{p}$ the shape projection coincides with the object segmentation, the value inside the $log$ is close to 1, leading to a small silhouette alignment residual $r_{silh}(\mathbf{p})$; Otherwise the value inside the $log$ is a positive number close to 0, resulting in a large $r_{silh}(\mathbf{p})$. Examples of the silhouette alignment residuals in the left and right images are shown in the middle of Fig.~\ref{fig:system_overview} (higher residuals are denoted in red). Our requirement on the shape projection function $\pi(\mathbf{\Phi},\mathbf{p})$ is its differentiability wrt. $\mathbf{\Phi}$ and $\mathbf{p}$. Inspired by~\cite{prisacariu2012simultaneous, DameCVPR13}, we define it as \begin{equation} \pi(\mathbf{\Phi}, \mathbf{p}) = 1 - \prod_{\mathbf{X}_{o}} \frac{1}{e^{\mathbf{\Phi}(\mathbf{X}_{o})\zeta} + 1}, \end{equation} where $\mathbf{X}_{o}$ are sampled 3D points along the ray through the camera center and $\mathbf{p}$, $\zeta$ is a constant that defines the smoothness of the projection contour. \begin{figure}[t] \centering \captionsetup[subfigure]{justification=centering} \begin{subfigure}[t]{0.155\textwidth} \includegraphics[width=\textwidth]{images/ambig_1_new.png} \caption{Iteration 1.} \end{subfigure} \begin{subfigure}[t]{0.155\textwidth} \includegraphics[width=\textwidth]{images/ambig_2_new.png} \caption{Iteration 2.} \end{subfigure} \begin{subfigure}[t]{0.155\textwidth} \includegraphics[width=\textwidth]{images/ambig_3_new.png} \caption{Iteration 3.} \end{subfigure} \vspace{-1ex} \caption{Ambiguity between 3D shape and pose when using only the silhouette alignment term. While fitting the shape projection (harder contour) to the object segmentation (softer contour), the 3D pose drifts away as shown in the bird's-eye view on the left.}\vspace{-4ex} \label{fig:projection_drift} \end{figure} It is worth noting that the silhouette alignment term only confines the projections of 3D shapes to 2D silhouettes, which is not sufficient to resolve the ambiguity between 3D shapes and poses. Especially in our single-frame stereo setting, even with class-specific priors regularizing the estimated pose, the 3D model often drifts away to better fit the 2D silhouettes, as illustrated in Fig.~\ref{fig:projection_drift}. We thus propose in the next section to further enforce photometric consistency to favor poses and shapes that give less color inconsistencies between the left and right images. \subsection{Photometric Consistency Term} \label{subsec:photo_term} By warping the object pixels from the left image $\mathrm{I}^{l}$ to the right $\mathrm{I}^{r}$, the photometric consistency term measures the color consistencies. For each pixel within the shape projection, we determine the depth to the object surface through raycasting and finding the intersection with the zero-level set in the SDF. Using this depth and the current object pose, the pixels are transformed from $\mathrm{I}^{l}$ to $\mathrm{I}^{r}$. Under the brightness constancy assumption, when the pose and shape estimates of an object are correct, the corresponding pixel intensities in the two images should be the same. Our photometric consistency term is formally defined as: \begin{equation} E_{photo} = \frac{1}{|\Omega'| |N_{\mathbf{p}}|} \sum_{\mathbf{p} \in \Omega'} \sum_{\tilde{\mathbf{p}} \in N_{\mathbf{p}}} \omega_{\mathbf{p}} || r_{photo}(\tilde{\mathbf{p}}) ||_{\gamma}, \end{equation} \begin{equation} r_{photo}(\tilde{\mathbf{p}}) = \mathbf{I}_{r}\big(\Pi_{c}(\mathbf{R}_{l}^{r} \Pi_{c}^{-1}(\tilde{\mathbf{p}}, d_{\mathbf{p}}) + \mathbf{t}_{l}^{r})\big) - \mathbf{I}_{l}\big(\tilde{\mathbf{p}}\big), \end{equation} where $\Omega'$ is the set of the pixels that have intersecting rays with the current shape surface, $N_{\mathbf{p}}$ is a small image neighborhood around $\mathbf{p}$. For each pixel $\tilde{\mathbf{p}}$ in $\mathrm{I}^{l}$, we warp it to $\mathrm{I}^{r}$ based on the current depth of its central pixel $d_\mathbf{p}$ and the relative 3D rotation $\mathbf{R}_{l}^{r}$ and translation $\mathbf{t}_{l}^{r}$. $\Pi_{c}(\cdot)$ and $\Pi_{c}^{-1}(\cdot)$ are the camera projection and back-projection functions that transform 3D coordinates to pixel coordinates and vice versa. The photometric residual $r_{photo}(\tilde{\mathbf{p}})$ is guarded by the Huber norm $||\cdot||_{\gamma}$ and an image gradient based weighting $\omega_{\mathbf{p}} = c^{2}/(c^{2} + ||\nabla \mathbf{I}_{l}(\mathbf{p})||_{2}^{2})$, where $c$ is a constant and $\nabla \mathbf{I}_{l}(\mathbf{p})$ is the image gradient at $\mathbf{p}$. An example of the photometric consistency residuals are shown in the middle of Fig.~\ref{fig:system_overview}. The idea behind the photometric consistency term is analogous to direct image alignment applied in recent direct visual odometry (VO) and SLAM methods~\cite{engel2013semi, engel2014lsd, wang2017stereo, engel2018direct}. The difference is that instead of directly optimizing for the depth of each pixel independently, in our case the pixel depths are implicitly parameterized by the object pose and shape, i.e., $d_{\mathbf{p}} = d(\mathbf{p}, \mathbf{z}, \mathbf{T}^{o}_{c})$, which brings challenges when deriving the derivative of $r_{photo}$ wrt. $\mathbf{z}$ and $\mathbf{T}^{o}_{c}$. Nevertheless, the analytical Jacobians are still achievable and the thorough derivations are provided on our project page. \subsection{Prior Terms} \label{subsec:prior} As cars can only locate on road surface and rotate along the axis that is perpendicular to the road, we encode this domain knowledge with two priors for the pose estimation. Besides, since cars cannot have randomly diverse shapes, we further regularize the estimated shape to be close to our mean shape. Our prior term is therefore defined as: \begin{equation} E_{prior} = \lambda_{1} E_{shape} + \lambda_{2} E_{trans} + \lambda_{3} E_{rot}, \end{equation} \begin{equation} E_{shape} = \sum_{i=1}^{K}(\frac{z_{i}}{\sigma_{i}})^2, \end{equation} \begin{equation} E_{trans} = (\mathbf{t}_{o}^{c}(y) - g(\mathbf{t}_{o}^{c}(x, z))(y))^2, \end{equation} \begin{equation} E_{rot} = (1 - (\mathbf{R}_{o}^{c}[0, -1, 0]^{\top})^{\top} \mathbf{n}_{g})^{2}, \end{equation} where $\lambda_{1, 2, 3}$ are scalar weighting factors, $\sigma_{i}$ is the Eigenvalue of the i-th principal component; $g(\mathbf{t}_{o}^{c}(x, z))(y)$ is the height of the road plane at position $\mathbf{t}_{o}^{c}(x, z)$ so that $E_{trans}$ pulls the bottom of the car close to the ground plane; $\mathbf{R}_{o}^{c}[0, -1, 0]^{\top}$ is the direction vector of the negative object y-axis and $\mathbf{n}_{g}$ is the normal vector of the ground surface. $E_{rot}$ penalizes a large difference between the two directions. \subsection{Adaptive Point Sampling} \label{sugsection:point_sampling} In previous works, the silhouette alignment term was computed densely for all the pixels on GPUs~\cite{DameCVPR13}. While the same implementation principal can be applied to the photometric consistency term, we observe that the dense pixel field contains highly redundant information that contributes only minor to both terms. Recent direct VO methods adopt the idea to sample pixels with sufficient gradients and meanwhile favor a more spatially uniform distribution~\cite{engel2018direct, wang2017stereo, yang2018deep, gao2018ldso}. Besides reducing the computational burden, this strategy also suppresses the ambiguous information being added to the system. We observe that due to the reflections on the car surfaces, this strategy becomes even more relevant in our case and can drastically improve the convergence of the photometric term. One issue, though, is the sampling strategy proposed in~\cite{engel2018direct} is adaptive and sometimes can still give very imbalanced spatial distributions. This is undesired for the silhouette alignment if too few pixels are sampled from the object boundary area, as the corresponding 3D parts will not be well constrained. We thus modify the adaptive sampling in~\cite{engel2018direct} to a two-round pipeline: The image is first discretized into a regular grid and a threshold for each cell is computed based on the gradient magnitudes of the pixels within it. The image is then re-discretized using smaller cell size and pixels with gradients above the threshold are selected (green in Fig.~\ref{fig:sampling}). This is identical as in~\cite{engel2018direct}. In the second round, we select the pixel with the highest gradient (red in Fig.~\ref{fig:sampling}) for each cell that doesn't get any sample from the previous round. To ensure a consistent density for object instances with different sizes in the image, we compute the numbers to sample proportionally to the area of their bounding boxes as $0.05\times height\times width$. \begin{figure}[t] \centering \includegraphics[width=0.23\textwidth]{images/sample1.png} \includegraphics[width=0.23\textwidth]{images/sample2.png} \vspace{-0.5ex} \caption{Adaptive point sampling. Pixels are sampled to meet the desired density for each object, preferring pixels with high image gradient (green) but meanwhile maintaining a close to uniform distribution (red).} \vspace{-3ex} \label{fig:sampling} \end{figure} \begin{figure*}[t] \captionsetup[subfigure]{justification=centering} \centering \begin{subfigure}[t]{.18\textwidth} \includegraphics[width=\linewidth]{images/occ1.png} \caption{Input image with bounding box.} \label{box} \end{subfigure} \begin{subfigure}[t]{.18\textwidth} \includegraphics[width=\linewidth]{images/occ5.png} \caption{Segmentation masks and bounding box.} \label{box_and_seg} \end{subfigure} \begin{subfigure}[t]{.18\textwidth} \includegraphics[width=\linewidth]{images/occ6.png} \caption{Occlusion mask.} \label{occ_mask} \end{subfigure} \begin{subfigure}[t]{.18\textwidth} \includegraphics[width=\linewidth]{images/occ4.png} \caption{Silhouette alignment residuals.} \label{silh_term} \end{subfigure} \begin{subfigure}[t]{.18\textwidth} \includegraphics[width=\linewidth]{images/occ3.png} \caption{Photometric consistency residuals.} \label{photo_term} \end{subfigure} \vspace{-1ex} \caption{Occlusion handling. For each object detection, we check if its 2D bounding box is overlapped by the segmentation mask of any other object that is closer to the camera (\ref{box_and_seg}). Such overlapping part is considered as the occlusion mask (\ref{occ_mask}) and is used in the computation of both the silhouette alignment (\ref{silh_term}) and the photometric consistency residuals (\ref{photo_term}) to exclude pixels from the occluded part.} \vspace{-3ex} \label{fig:occ} \end{figure*} \subsection{Occlusion Handling} When a car is occluded by other cars (the most common case in traffic scenarios), we can extract an occlusion mask using the bounding box of the occluded car and the segmentation masks of the occluding cars, as illustrated in Fig~\ref{box}-\ref{occ_mask}. To this end, we sort all the cars appearing in the image based on the bottom coordinates of their 2D bounding boxes and thus they are ordered roughly according to their distances to the camera. Then for each car we check if there is any closer car overlapping with it and if yes we extract the occlusion mask according to Fig~\ref{box}-\ref{occ_mask}. The occlusion mask is used in the computations of both the silhouette alignment term and the photometric consistency term to exclude the samples from the occluded area, as shown in Fig~\ref{silh_term} and~\ref{photo_term}. \subsection{Optimization} \label{subsec:optimziation} Our final energy function is defined as the weighted sum of the previously defined terms \begin{equation} E = \lambda_{silh} E_{silh}^{l} + \lambda_{silh} E_{silh}^{r} + E_{photo} + E_{prior}, \end{equation} where $\lambda_{silh}$ is a scalar weighting factor. Note that all the energy terms have quadratic forms except for $E_{silh}$, which prevents the application of 2nd-order optimization methods. While in the previous works $E_{silh}$ is typically optimized using 1st-order methods like gradient descent, we reformulate it as an iteratively reweighted least squares problem as \begin{equation} E_{silh}^{l/r} = \frac{1}{|\Omega|}\sum_{\mathbf{p} \in \Omega} \omega_{\mathbf{p}}'(r_{silh}^{l/r}(\mathbf{p}))^{2}, \end{equation} where $\omega_{\mathbf{p}}' = 1/r_{silh}{(\mathbf{p})}$ is recalculated in each iteration based on the value of $r_{silh}(\mathbf{p})$ of the current iteration. $E$ is thus optimized using Gauss-Newton for the variables $[\boldsymbol{\xi}_{c}^{o}; \mathbf{z}]$, where $\boldsymbol{\xi}_{c}^{o}$ are the twist coordinates of the 3D rigid-body pose of the object in the camera coordinate system and $\mathbf{z}$ is the shape encoding vector. It is worth pointing out that previous works~\cite{zhu2018object, kundu20183d} stated that the process of rendering from 3D shape to image is not differentiable due to the non-linearity and hidden relationship between the two domains, and thus opt for workarounds such as finite difference. We claim that such process is actually fully differentiable. Please refer to our project page for the details of all the analytical Jacobians. \section{Experiments} Our method aims at estimating more precise and accurate geometric properties than 3D bounding boxes for cars. To demonstrate this ability, we separately evaluate its performances on 3D shape estimation and 3D pose refinement, where the KITTI Stereo 2015~\cite{Menze2015CVPR} and 3D Object~\cite{Geiger2012CVPR} benchmarks are adopted for the two tasks respectively. Throughout all our experiments, object masks are generated by Mask-RCNN~\cite{he2017mask}. We set $\lambda_{silh}=12$, $\lambda_{1}=10$, $\lambda_{2}=10$ and $\lambda_{3}=10^7$ and $\mathrm{\Phi}_{mean}$ is used as shape initialization. The CPU implementation of our optimization runs at around 100ms per object and 180ms per frame on KITTI. Porting to GPU may yield further runtime improvement. \subsection{Shape Estimation} \begin{figure} \centering \includegraphics[width=0.40\textwidth]{images/reconstruction_new-crop.pdf} \vspace{-1ex} \caption{Quantitative evaluation on shape reconstruction. Our approach outperforms the geometric approach~\cite{engelmann2016joint} in all measures.} \label{fig:eval_shape} \vspace{-2.0ex} \end{figure} \begin{figure}[] \centering \includegraphics[width=0.40\textwidth]{images/pose_pr_new2-crop.pdf} \vspace{-1ex} \caption{Quantitative evaluation on pose estimation in comparison to the geometric approach~\cite{engelmann2016joint}. IoU=0.5 is used for computing these precision-recall curves.}\vspace{-2.5ex} \label{fig:eval_pose} \end{figure} \begin{figure}[!] \captionsetup[subfigure]{justification=centering,labelformat=empty} \centering \includegraphics[width=0.091\textwidth]{images/depth_refinement/0083_img.png} \includegraphics[width=0.091\textwidth]{images/depth_refinement/0083_elas.png} \includegraphics[width=0.091\textwidth]{images/depth_refinement/0083_psm.png} \includegraphics[width=0.091\textwidth]{images/depth_refinement/0083_ours.png} \includegraphics[width=0.091\textwidth]{images/depth_refinement/0083_gt.png} \includegraphics[width=0.091\textwidth]{images/depth_refinement/0120_img.png} \includegraphics[width=0.091\textwidth]{images/depth_refinement/0120_elas.png} \includegraphics[width=0.091\textwidth]{images/depth_refinement/0120_psm.png} \includegraphics[width=0.091\textwidth]{images/depth_refinement/0120_ours.png} \includegraphics[width=0.091\textwidth]{images/depth_refinement/0120_gt.png} \includegraphics[width=0.091\textwidth]{images/depth_refinement/0112_img.png} \includegraphics[width=0.091\textwidth]{images/depth_refinement/0112_elas.png} \includegraphics[width=0.091\textwidth]{images/depth_refinement/0112_psm.png} \includegraphics[width=0.091\textwidth]{images/depth_refinement/0112_ours.png} \includegraphics[width=0.091\textwidth]{images/depth_refinement/0112_gt.png} \begin{subfigure}[t]{.089\textwidth} \vspace{-2ex} \caption{Image} \end{subfigure} \begin{subfigure}[t]{.096\textwidth} \vspace{-2ex} \caption{ELAS~\cite{geiger2010efficient}} \end{subfigure} \begin{subfigure}[t]{.098\textwidth} \vspace{-2ex} \caption{PSMNet~\cite{chang2018pyramid}} \end{subfigure} \begin{subfigure}[t]{.089\textwidth} \vspace{-2ex} \caption{Ours} \end{subfigure} \begin{subfigure}[t]{.089\textwidth} \vspace{-2ex} \caption{GT} \end{subfigure} \vspace{-1.5ex} \caption{Qualitative results on 3D shape refinement. We compare our method to a classical (ELAS~\cite{geiger2010efficient}) and a SotA deep learning based (PSMNet~\cite{chang2018pyramid}) stereo matching method. }\vspace{-3ex} \label{fig:eval_shape_quality} \end{figure} \begin{table*}[t] \begin{center} \begin{tabu}{|l|c c c|c c c|c c c|c c c|} \hline & \multicolumn{3}{c}{$\mathrm{AP_{bv}}$ (IoU=0.5)} & \multicolumn{3}{c|}{$\mathrm{AP_{bv}}$ (IoU=0.7)} & \multicolumn{3}{c}{$\mathrm{AP_{3D}}$ (IoU=0.5)} & \multicolumn{3}{c|}{$\mathrm{AP_{3D}}$ (IoU=0.7)}\Tstrut\Bstrut \\ \cline{2-13} Method & Easy & Mode & Hard & Easy & Mode & Hard & Easy & Mode & Hard & Easy & Mode & Hard\Tstrut\Bstrut \\ \tabucline[1pt]{-} Mono3D \cite{cvpr16chen} & 11.70 & 9.62 & 9.32 & 2.06 & 1.91 & 1.39 & 9.55 & 7.72 & 7.23 & 0.62 & 0.75 & 0.76\Tstrut \\ Mono3D + Ours & \textbf{23.53} & \textbf{16.54} & \textbf{15.30} & \textbf{5.21} & \textbf{4.02} & \textbf{3.84} & \textbf{18.88} & \textbf{14.31} & \textbf{11.73} & \textbf{2.61} & \textbf{2.09} & \textbf{2.17}\Bstrut \\ \hline Deep3DBox \cite{mousavian20173d} & 29.99 & 23.74 & 18.81 & 9.96 & 7.69 & 5.29 & 26.94 & 20.51 & 15.85 & 5.82 & 4.08 & 3.83 \Tstrut\\ Deep3DBox + Ours & \textbf{44.89} & \textbf{29.99} & \textbf{24.41} & \textbf{12.35} & \textbf{8.88} & \textbf{7.49} & \textbf{38.40} & \textbf{25.39} & \textbf{20.02} & \textbf{6.50} & \textbf{4.38} & \textbf{4.04}\Bstrut \\ \hline 3DOP \cite{3dopNIPS15} & 48.73 & 35.20 & 30.95 & 12.63 & 9.07 & 7.12 & 40.76 & 28.92 & 24.31 & 5.38 & 3.76 & 3.25\Tstrut \\ 3DOP + Ours & \textbf{59.40} & \textbf{39.43} & \textbf{33.54}& \textbf{19.98} & \textbf{13.40} & \textbf{11.34} & \textbf{50.16} & \textbf{34.66} & \textbf{29.31} & \textbf{11.38} & \textbf{7.36} & \textbf{6.34}\Bstrut \\ \hline MLF \cite{xu2018multi} & 55.03 & 36.73 & 31.27 & 22.03 & 13.76 & 11.60 & 47.88 & 29.48 & 26.44 & 10.53 & 5.69 & 5.39\Tstrut \\ MLF + Ours & \textbf{63.10} & \textbf{37.97} & \textbf{31.84}& \textbf{25.58} & \textbf{15.25} & \textbf{11.97} & \textbf{55.12} & \textbf{34.78} & \textbf{29.44} & \textbf{14.59} & \textbf{8.42} & \textbf{7.26}\Bstrut \\ \hline \end{tabu} \end{center} \vspace{-2ex} \caption{Average precision of bird's eye view ($\mathrm{AP}_{bv}$) and 3D bounding boxes ($\mathrm{AP}_{3D}$), evaluated on the KITTI 3D Object validation set. Note that the KITTI Object Benchmark updated its evaluation script in 2017 which causes some inconsistent numbers in this table and in the original papers.}\vspace{-2ex} \label{tab:3d_pose} \end{table*} \begin{figure*}[] \centering \includegraphics[width=0.34\textwidth,height=2cm]{images/0167_10_overlap_before_small.png}% \includegraphics[width=0.115\textwidth,height=2cm]{images/bev_0167_10_before.png} \includegraphics[width=0.34\textwidth,height=2cm]{images/0018_10_overlap_before_small.png}% \includegraphics[width=0.115\textwidth,height=2cm]{images/bev_0018_10_before.png} \includegraphics[width=0.34\textwidth,height=2cm]{images/0167_10_overlap_after_small.png}% \includegraphics[width=0.115\textwidth,height=2cm]{images/bev_0167_10_after.png} \includegraphics[width=0.34\textwidth,height=2cm]{images/0018_10_overlap_after_small.png}% \includegraphics[width=0.115\textwidth,height=2cm]{images/bev_0018_10_after.png} \caption{Qualitative results of 3D pose refinement. Each column shows the initial and the optimized pose (overlapped with the input image and also in bird-eye view). GT poses are denoted by green boxes. Note that point clouds are not used in our optimization. }\vspace{-0.5ex} \label{fig:eval_pose_quality} \end{figure*} \begin{figure*}[] \centering \includegraphics[width=0.32\textwidth]{images/qualitative_cut/000122_09-min.png} \includegraphics[width=0.32\textwidth]{images/qualitative_cut/000236-min.png} \includegraphics[width=0.32\textwidth]{images/qualitative_cut/000143_10-min.png} \includegraphics[width=0.32\textwidth]{images/qualitative_cut/stereo_0122_09-min.png} \includegraphics[width=0.32\textwidth]{images/qualitative_cut/obj_0236-min.png} \includegraphics[width=0.32\textwidth]{images/qualitative_cut/stereo_0143_10-min.png} \vspace{1ex} \includegraphics[width=0.32\textwidth]{images/qualitative_cut/000677-min.png} \includegraphics[width=0.32\textwidth]{images/qualitative_cut/000117-min.png} \includegraphics[width=0.32\textwidth]{images/qualitative_cut/000083_10-min.png} \includegraphics[width=0.32\textwidth]{images/qualitative_cut/obj_0677-min.png} \includegraphics[width=0.32\textwidth]{images/qualitative_cut/obj_0117-min.png} \includegraphics[width=0.32\textwidth]{images/qualitative_cut/stereo_0083_10-min.png} \caption{Qualitative results of 3D shape and pose estimation. }\vspace{-3ex} \label{fig:eval_quality} \end{figure*} We first compare our method to the previously proposed geometric approach~\cite{engelmann2016joint}, which fits the same PCA model to the point cloud estimated by the dense stereo reconstruction method ELAS~\cite{geiger2010efficient}. To our knowledge it is so far the only method that provides object shape evaluation. To be consistent with~\cite{ZhouICCV15,engelmann2017samp}, we measure $\mathit{completeness}$ (\% of ground-truth (GT) points with at least one estimated point within a certain distance $\tau$), $\mathit{accuracy}$ (\% of estimated points with at least one GT point within $\tau$) and $F_1$ score ($2\cdot \mathit{completeness} \cdot \mathit{accuracy} / (\mathit{completeness}+\mathit{accuracy})$) for the GT segments in the KITTI Stereo 2015 benchmark. To more precisely measure the accuracy, we additionally compute the RMSE: For each GT point, we search within $\tau$ and compute the distance to the closest estimate point. The RMSE is only computed for those GT points with matched estimated points. We use 3DOP for pose initialization for \cite{engelmann2016joint} and our method. The four metrics wrt. different $\tau$ are displayed in Fig.~\ref{fig:eval_shape}, where our method outperforms the geometric approach in all the four evaluations\footnote{When comparing to Fig. 9 in~\cite{engelmann2017samp}, it is worth noting that the results there are obtained from a subset of KITTI Stereo 2015.}. Compared to the laboratorial settings in~\cite{Sandhu2011_kernelsegposerecon, Prisacariu2012_segposerecon, DameCVPR13} where only one dominant car appears in the image, KITTI Stereo 2015 is much more challenging and contains cars with severe truncation, occlusion and at large distance. This explains the degraded performances of the geometric approach, as it lacks occlusion handling and also the stereo reconstruction gets drastically more noisy in faraway areas. In Fig.~\ref{fig:eval_shape_quality}, we qualitatively compare our method to ELAS~\cite{geiger2010efficient} and a recent deep learning based stereo reconstruction method PSMNet~\cite{chang2018pyramid}. Although deep learning with strong supervision has significantly improved the reconstruction quality, it still suffers at large distances. The results in Fig.~\ref{fig:eval_shape_quality} validate the idea of introducing shape priors into the pipeline. More qualitative results can be found in Fig.~\ref{fig:eval_quality}. \subsection{Pose Refinement} Same as above, we first compare our method to the geometric approach~\cite{engelmann2016joint}. Based on the GT provided by KITTI 3D Object, we compute the precision-recall curves for 3D bounding boxes for the three pre-defined difficulties. The results are shown in Fig~\ref{fig:eval_pose}, where our method delivers better 3D pose estimates for all the difficulties. In the categories Moderate and Hard, as many cars are occluded and only part of the object 3D points can be reconstructed, fitting the 3D model to the incomplete point cloud would generally worsen the pose estimation. The qualitative results of our 3D pose refinement on two example images can be found in Fig.~\ref{fig:eval_pose_quality}. In the next experiment we demonstrate the pose refinements of our method over 4 deep learning based 3D detectors, namely Mono3D~\cite{cvpr16chen}, Deep3DBox~\cite{mousavian20173d}, 3DOP~\cite{3dopNIPS15} and MLF~\cite{xu2018multi}. We use the validation splits provided by~\cite{3dopNIPS15,mousavian20173d} and compute the average precisions for bird's eye view ($\mathrm{AP}_{bv}$) and 3D bounding boxes ($\mathrm{AP}_{3D}$). The results in Table~\ref{tab:3d_pose} shows that our method hugely boosts the performances of all the tested methods under all the settings, which demonstrates the effectiveness of our method on 3D pose refinement. Some qualitative results of our method in challenging real-world scenarios can be found in Fig.~\ref{fig:eval_quality}. \section{Conclusions} We propose a new approach for joint vehicle pose and shape estimation based on an energy function combining photometric and silhouette alignment. Our method delivers much more precise and useful information than the current 3D detectors that focus on estimating bounding boxes. In our experiments we demonstrate superior performance over the previous geometric method in both pose and shape estimation. We also demonstrate that our approach can significantly boost the performance of learning-based 3D object detectors. In future work, we are planning to extend our approach to a local window of multiple frames and integrate it into a visual SLAM system. \bibliographystyle{./IEEEtran} \section{Shape Variations of PCA Model} \label{shape_pca} To demonstrate that our PCA model can deform and fit properly to a variety of car shapes, we first fit it to 12 selected vehicles from the CAD samples which we used to extract the PCA model. The shapes together with the color coded signed distance function (SDF) are shown in Fig.~\ref{sdfs}. An animation showing the different car shapes by modifying the shape coefficients $\mathbf{z}$ can be found on the project page. We further show some real-world examples in Fig.~\ref{fig:shape_variation}, where the PCA model is optimized using our approach to fit the corresponding cars in the second row. We claim that although the adopted PCA shape embedding is a simple linear model, it works nicely for object categories like cars. \begin{figure*} \centering \begin{subfigure}[c]{.90\textwidth} \includegraphics[width=0.25\textwidth]{images/sdf2.png}% \includegraphics[width=0.25\textwidth]{images/sdf3.png}% \includegraphics[width=0.25\textwidth]{images/sdf4.png}% \includegraphics[width=0.25\textwidth]{images/sdf9.png} \includegraphics[width=0.25\textwidth]{images/sdf11.png}% \includegraphics[width=0.25\textwidth]{images/sdf30.png}% \includegraphics[width=0.25\textwidth]{images/sdf20.png}% \includegraphics[width=0.25\textwidth]{images/sdf21.png} \includegraphics[width=0.25\textwidth]{images/sdf23.png}% \includegraphics[width=0.25\textwidth]{images/sdf24.png}% \includegraphics[width=0.25\textwidth]{images/sdf27.png}% \includegraphics[width=0.25\textwidth]{images/sdf37.png} \end{subfigure} \begin{subfigure}[c]{.09\textwidth} \includegraphics[width=0.8\textwidth]{images/color_bar.png} \end{subfigure} \caption{Shape variations of PCA model with color coded SDF.} \label{sdfs} \end{figure*} \begin{figure*}[!] \centering \includegraphics[width=0.96\textwidth]{images/shape_variation_real.png} \caption{Qualitative results on the shape estimation.}\vspace{-2ex} \label{fig:shape_variation} \end{figure*} \section{Full Derivations of Jacobians} \label{full_jacobian} \subsection{Jacobian of Silhouette Alignment Residual} As the relative transformation between the left and right cameras are considered to be fixed in this work, the Jacobians of $r_{silh}^{l}$ and $r_{silh}^{r}$ are the same and we will omit the superscript in the following. As shown in Eq. 2 in the main paper, the silhouette alignment residual of pixel $\mathbf{p}$ is defined as \begin{equation} r_{silh}(\mathbf{p}) = -\text{log} \big( \underbrace{\pi(\mathbf{\Phi}, \mathbf{p}) p_{fg}(\mathbf{p}) + (1 - \pi(\mathbf{\Phi}, \mathbf{p})) p_{bg}(\mathbf{p})}_{\coloneqq A(\pi)} \big), \end{equation} thus using chain rule its Jacobian with respect to the pose and shape parameters $[\boldsymbol{\xi}_{c}^{o}; \mathbf{z}]$ can be factorized to \begin{align} \mathbf{J}_{silh} & = \frac{\partial r_{silh}(\mathbf{p})}{\partial [\boldsymbol{\xi}_{c}^{o}; \mathbf{z}]} \\ & = -\frac{\partial log(A(\pi))}{\partial A(\pi)} \frac{\partial A(\pi)}{\partial \pi} \frac{\partial \pi(\mathbf{\Phi}, \mathbf{p})}{\partial \mathbf{\Phi}} \frac{\partial \mathbf{\Phi}}{\partial [\boldsymbol{\xi}_{c}^{o}; \mathbf{z}]}, \end{align} where \begin{align} \frac{\partial log(A(\pi))}{\partial A(\pi)} = \frac{1}{A(\pi)}, \label{eq:dlog_dA} \end{align} \begin{align} \frac{\partial A(\pi)}{\partial \pi} = p_{fg}(\mathbf{p}) - p_{bg}(\mathbf{p}). \label{eq:dA_dpi} \end{align} Recall that the shape embedding projection function $\pi(\mathbf{\Phi}, \mathbf{p})$ is defined as \begin{equation} \pi(\mathbf{\Phi}, \mathbf{p}) = 1 - \prod_{\mathbf{X}_{o}} \frac{1}{e^{\mathbf{\Phi}(\mathbf{X}_{o})\zeta} + 1}, \end{equation} to make it easier to derive its Jacobian, we convert the multiplications in $\pi(\mathbf{\Phi}, \mathbf{p})$ to summations by reformulating it to \begin{equation} \pi(\mathbf{\Phi}, \mathbf{p}) = 1 - \text{exp}\bigg(\underbrace{\sum_{\mathbf{X}_{o}} \text{log}\bigg(\overbrace{\frac{1} {e^{\mathbf{\Phi}(\mathbf{X}_{o})\zeta} + 1}}^{\coloneqq C(\mathbf{\Phi})}\bigg)}_{\coloneqq B(\mathbf{\Phi})} \bigg). \end{equation} Therefore, \begin{align} \frac{\partial \pi(\mathbf{\Phi}, \mathbf{p})}{\partial \mathbf{\Phi}} = -\text{exp}(B(\mathbf{\Phi})) \sum_{\mathbf{X}_{o}} \frac{1}{C(\mathbf{\Phi})} \frac{\partial C(\mathbf{\Phi})}{\partial \mathbf{\Phi}}, \label{eq:dpi_dPhi} \end{align} where \begin{align} \frac{\partial C(\mathbf{\Phi})}{\partial \mathbf{\Phi}} & = \frac{\partial (\frac{1}{e^{\mathbf{\Phi}(\mathbf{X}_{o})\zeta} + 1})}{\partial \mathbf{\Phi}} \\ & = (-1) \frac{e^{\mathbf{\Phi}(\mathbf{X}_{o})\zeta} }{(e^{\mathbf{\Phi}(\mathbf{X}_{o})\zeta} + 1)^2}\zeta \\ & = -\frac{\zeta e^{\mathbf{\Phi}(\mathbf{X}_{o})\zeta} }{(e^{\mathbf{\Phi}(\mathbf{X}_{o})\zeta} + 1)^2}. \label{eq:dC_dPhi} \end{align} The remaining part to derive is $\partial \mathbf{\Phi}(\mathbf{X}_{o}) / \partial [\boldsymbol{\xi}_{c}^{o}; \mathbf{z}]$. As $\mathbf{\Phi}(\mathbf{X}_{o}) = \mathbf{V(\mathbf{X}_{o})z} + \mathbf{\Phi}_{mean} = \sum_{k=1}^{K}\mathbf{v}_{k}(\mathbf{X}_{o})z_k + \mathbf{\Phi}_{mean}$, we have \begin{equation} \label{eq:dPhi_dz} \frac{\partial \mathbf{\Phi}(\mathbf{X}_{o})}{\partial \mathbf{z}} = [\mathbf{v}_{1}(\mathbf{X}_{o}), \mathbf{v}_{2}(\mathbf{X}_{o}),...,\mathbf{v}_{K}(\mathbf{X}_{o})]. \end{equation} To derive $\partial \mathbf{\Phi}(\mathbf{X}_{o}) / \partial \boldsymbol{\xi}_{c}^{o}$, we first compute the coordinate for $\mathbf{X}_{o}$ in the camera coordinate system as $\mathbf{X}_{c}$, so we have $\mathbf{X}_{o} = \text{exp}\left(\hat{\boldsymbol{\xi}_{c}^{o}}\right)\mathbf{X}_{c}$, where $\text{exp}(\hat{\cdot})$ is the exponential map that maps the twist coordinate to $\text{SE(3)}$. The remaining part of the Jacobian is then computed as \begin{equation} \label{eq:dPhi_dxi} \frac{\partial \mathbf{\Phi}(\mathbf{X}_{o})}{\partial \boldsymbol{\xi}_{c}^{o}} = \nabla \mathbf{\Phi} \bigg \rvert_{\mathbf{X}_{o}} \frac{\partial \mathbf{X}_{o}}{\partial \boldsymbol{\xi}_{c}^{o}}, \end{equation} \begin{equation} \label{eq:dx_dxi} \frac{\partial \mathbf{X}_{o}}{\partial \boldsymbol{\xi}_{c}^{o}} = \frac{\partial \text{exp}\left(\hat{\boldsymbol{\xi}_{c}^{o}}\right)}{\partial \boldsymbol{\xi}_{c}^{o}}\bigg \rvert_{\boldsymbol{\xi}_{c}^{o}} \mathbf{X}_{c} = \frac{\partial \text{exp}(\hat{\delta \boldsymbol{\xi}})}{\partial (\delta \boldsymbol{\xi})} \bigg \rvert_{\mathbf{0}} \text{exp}(\hat{\boldsymbol{\xi}_{c}^{o}}) \mathbf{X}_{c}, \end{equation} where $\nabla \mathbf{\Phi}$ is the spatial gradient of $\mathbf{\Phi}$, $\delta \boldsymbol{\xi}$ is a small increment in $\mathfrak{se}(3)$ and is applied with the exponential map to the left hand side of the pose estimate. The closed form solution for $\partial \text{exp}(\hat{\delta \boldsymbol{\xi}}) / \partial (\delta \boldsymbol{\xi})$ near $\delta \boldsymbol{\xi} = \mathbf{0}$ can be obtained using the infinitesimal generators of $\text{SE(3)}$ (please refer Eq.~\ref{eq:generator1} and \ref{eq:generator2}). Depending on the derivations of the specific derivatives above, the full Jacobian of the silhouette alignment residual can be computed by combining Eq.~\ref{eq:dlog_dA}, \ref{eq:dA_dpi}, \ref{eq:dpi_dPhi}, \ref{eq:dC_dPhi} and Eq.~\ref{eq:dPhi_dz}, \ref{eq:dPhi_dxi}, \ref{eq:dx_dxi}. \subsection{Jacobian of the Photometric Consistency Residual} As defined in the main paper, the photometric consistency residual of pixel $\mathbf{p}$ is \begin{equation} r_{photo}(\mathbf{p}) = \mathbf{I}_{r}\big(\underbrace{\Pi_{c}(\mathbf{R}_{l}^{r} \Pi_{c}^{-1}(\mathbf{p}, d_{\mathbf{p}}) + \mathbf{t}_{l}^{r})}_{\coloneqq warp(\mathbf{p}, d_{\mathbf{p}})} \big) - \mathbf{I}_{l}\big(\mathbf{p}\big), \end{equation} where the pose and shape parameters $[\boldsymbol{\xi}_{c}^{o}; \mathbf{z}]$ only appear in $d_{\mathbf{p}}$. Using chain rule the Jacobian with respect to the pose and shape parameters can be factorized to \begin{align} \mathbf{J}_{photo} & = \frac{\partial r_{photo}(\mathbf{p})}{\partial [\boldsymbol{\xi}_{c}^{o}; \mathbf{z}]} \\ & = \nabla \mathbf{I}_r(warp(\mathbf{p}, d_{\mathbf{p}})) \frac{\partial warp(\mathbf{p}, d_{\mathbf{p}})}{\partial d_{\mathbf{p}}} \frac{\partial d_{\mathbf{p}}}{\partial [\boldsymbol{\xi}_{c}^{o}; \mathbf{z}]}, \end{align} where $warp(\mathbf{p}, d_{\mathbf{p}}) = \Pi_{c}(\mathbf{R}_{l}^{r} \Pi_{c}^{-1}(\mathbf{p}, d_{\mathbf{p}}) + \mathbf{t}_{l}^{r})$ is the pixel warping function from the left image to the right image, $\nabla \mathbf{I}_r(warp(\mathbf{p}, d_{\mathbf{p}}))$ is the image gradient of the right image at the warped pixel location $warp(\mathbf{p}, d_{\mathbf{p}})$. In the following we derive $\partial warp(\mathbf{p}, d_{\mathbf{p}}) / \partial d_{\mathbf{p}}$ and $\partial d_{\mathbf{p}} / \partial [\boldsymbol{\xi}_{c}^{o}; \mathbf{z}]$ successively. Denoting the 3D coordinates of $\mathbf{p}$ in the left and the right camera coordinate systems as $\mathbf{X}_l$ and $\mathbf{X}_r$, we have \begin{align} warp(\mathbf{p}, d_{\mathbf{p}}) & = \Pi_{c}(\underbrace{\mathbf{R}_{l}^{r} \overbrace{\Pi_{c}^{-1}(\mathbf{p}, d_{\mathbf{p}})}^{\mathbf{X}_l} + \mathbf{t}_{l}^{r}}_{\mathbf{X}_r}), \end{align} \begin{align} \mathbf{X}_l & = d_{\mathbf{p}}\mathbf{K}^{-1}[\mathbf{p}(u), \mathbf{p}(v), 1]^{\top}, \end{align} \begin{align} \mathbf{X}_r & = \mathbf{R}_{l}^{r}\mathbf{X}_l + \mathbf{t}_{l}^{r},\\ & = d_{\mathbf{p}}\underbrace{\mathbf{R}_{l}^{r}\mathbf{K}^{-1}[\mathbf{p}(u), \mathbf{p}(v), 1]^{\top}}_{\coloneqq \mathbf{v} = [\mathbf{v}(x), \mathbf{v}(y), \mathbf{v}(z)]^{\top}} + \mathbf{t}_{l}^{r}, \\ & = d_{\mathbf{p}}\mathbf{v} + \mathbf{t}_{l}^{r}, \end{align} \begin{align} \Pi_{c}(\mathbf{X}_r) & = \begin{bmatrix} f_u & 0 & c_u \\ 0 & f_v & c_v \end{bmatrix} \begin{bmatrix} \frac{\mathbf{X}_r(x)}{\mathbf{X}_r(z)} \\ \frac{\mathbf{X}_r(y)}{\mathbf{X}_r(z)} \\ 1 \end{bmatrix} \\ & = \begin{bmatrix} f_u\frac{\mathbf{X}_r(x)}{\mathbf{X}_r(z)} + c_u \\ f_v\frac{\mathbf{X}_r(y)}{\mathbf{X}_r(z)} + c_v, \end{bmatrix}, \end{align} where $\mathbf{K} = [f_u, 0, c_u; 0, f_v, c_v; 0, 0, 1]$ is the camera intrinsic matrix. $\partial warp(\mathbf{p}, d_{\mathbf{p}}) / \partial d_{\mathbf{p}}$ therefore can be computed as \begin{align} \frac{\partial warp(\mathbf{p}, d_{\mathbf{p}})}{\partial d_{\mathbf{p}}} & = \begin{bmatrix} f_u \frac{\partial \frac{\mathbf{X}_r(x)}{\mathbf{X}_r(z)}}{d_{\mathbf{p}}} \\ f_v \frac{\partial \frac{\mathbf{X}_r(y)}{\mathbf{X}_r(z)}}{d_{\mathbf{p}}} \end{bmatrix} \\ & = \begin{bmatrix} f_u \frac{\frac{\partial \mathbf{X}_r(x)}{\partial d_{\mathbf{p}}} \mathbf{X}_r(z) - \mathbf{X}_r(x)\frac{\partial \mathbf{X}_r(z)}{\partial d_{\mathbf{p}}}}{\mathbf{X}_r^2(z)} \\ f_v \frac{\frac{\partial \mathbf{X}_r(y)}{\partial d_{\mathbf{p}}} \mathbf{X}_r(z) - \mathbf{X}_r(y)\frac{\partial \mathbf{X}_r(z)}{\partial d_{\mathbf{p}}}}{\mathbf{X}_r^2(z)} \end{bmatrix} \\ & = \begin{bmatrix} f_u \frac{\mathbf{v}(x)\mathbf{X}_r(z) - \mathbf{X}_r(x)\mathbf{v}(z)}{\mathbf{X}_r^2(z)} \\ f_v \frac{\mathbf{v}(y)\mathbf{X}_r(z) - \mathbf{X}_r(y)\mathbf{v}(z)}{\mathbf{X}_r^2(z)} \\ \end{bmatrix}. \end{align} To compute $\partial d_{\mathbf{p}} / \partial [\boldsymbol{\xi}_{c}^{o}; \mathbf{z}]$, we first compute the 3D coordinate of the intersecting point of the ray and the zero-level surface based on $d_{\mathbf{p}}$ obtained by ray-casting, then transform it from the camera coordinate system to the object coordinate system and denote it as $\mathbf{X}_o^d$. The Jacobian with respect to the shape encoding vector is then computed as \begin{equation} \frac{\partial d_{\mathbf{p}}}{\partial \mathbf{z}} = \frac{\partial d_{\mathbf{p}}}{\partial \mathbf{\Phi}} \bigg \rvert_{\mathbf{\Phi}(\mathbf{X}_o^d)} \frac{\partial \mathbf{\Phi}}{\partial \mathbf{z}} \bigg \rvert_{\mathbf{z}}, \end{equation} where $\partial \mathbf{\Phi} / \partial \mathbf{z}$ can be computed similarly as in Eq.~\ref{eq:dPhi_dz}, the derivation of $\partial d_{\mathbf{p}} / \partial \mathbf{\Phi}$ is illustrated in Fig.~\ref{fig:tsdf_derivative}. At the intersecting point $\mathbf{X}^{d}_{o}$, the change of the depth along the ray $\partial d$ is approximately proportional to the change of the SDF value $\delta \mathbf{\Phi}$ by a factor of $1/\text{cos}(\theta)$ where $\theta$ is the angle between the ray and the surface normal. Taking the sign into account we have \begin{equation} \label{eq:dd_dPhi} \frac{\partial d_{\mathbf{p}}}{\partial \mathbf{\Phi}}\bigg \rvert_{\mathbf{\Phi}(\mathbf{X}_o^d)} = -\frac{1}{\text{cos}(\theta)}. \end{equation} The Jacobian with respect to $\boldsymbol \xi^{o}_{c}$ can be factorized to \begin{equation} \frac{\partial d_{\mathbf{p}}}{\partial \boldsymbol{\xi}^{o}_{c}} = \frac{\partial d_{\mathbf{p}}}{\partial \mathbf{\Phi}} \bigg \rvert_{\mathbf{\Phi}(\mathbf{X}_o^d)} \nabla \mathbf{\Phi} \bigg \rvert_{\mathbf{X}_{o}^{d}} \frac{\partial \mathbf{X}_{o}^{d}}{\partial \boldsymbol{\xi}_{c}^{o}} \bigg \rvert_{\boldsymbol{\xi}_{c}^{o}}, \end{equation} which can be computed according to Eq.~\ref{eq:dd_dPhi} and~\ref{eq:dx_dxi}. \subsection{Jacobian of Prior Residuals} Based on the energy terms defined in the Eq. 7-9 in the main paper, we define the residuals of the priors on the shape and pose parameters as \begin{align} r_{shape}^{i} & = \frac{z_i}{\sigma_i}, \quad i = 1, 2,..., K \label{eq:shape}\\ r_{trans} & = \mathbf{t}_o^c(y) - g(\mathbf{t}_o^c(x, z))(y), \\ r_{rot} & = 1 - (\mathbf{R}_{o}^{c}[0, -1, 0]^{\top})^{\top} \mathbf{n}_{g}. \end{align} \begin{figure}[!] \centering \includegraphics[width=0.25\textwidth]{images/sdf-derivative-crop.pdf} \vspace{-0.5ex} \caption{Deriving the Jacobian of the depth wrt. the SDF value.}\vspace{-3ex} \label{fig:tsdf_derivative} \end{figure} \subsubsection{Jacobian of Shape Prior Residuals.} Based on Eq.~\ref{eq:shape} we have \begin{align} \frac{\partial r_{shape}^{i}}{\partial \boldsymbol{\xi}_{c}^{o}} & = \mathbf{0},\\ \frac{\partial r_{shape}^{i}}{\partial \mathbf{z}} & = [0,...,0, \frac{1}{\sigma_i}, 0, ..., 0]. \end{align} \subsubsection{Jacobian of Translation Prior Residuals.} Denoting the equation for the ground plane as $\mathbf{n}_g(x)x + \mathbf{n}_g(y)y + \mathbf{n}_g(z)z + d = 0$ with $\mathbf{n}_g$ the plane normal vector and $d$ a constant, the height of the ground plane at $\mathbf{t}_o^c(x, z)$ is \begin{align} g(\mathbf{t}_o^c(x, z))(y) = -\frac{\mathbf{n}_g(x)\mathbf{t}_o^c(x) + \mathbf{n}_g(z)\mathbf{t}_o^c(z) + d}{\mathbf{n}_g(y)}, \end{align} thus \begin{align} r_{trans} = \mathbf{t}_o^c(y) + \frac{\mathbf{n}_g(x)\mathbf{t}_o^c(x) + \mathbf{n}_g(z)\mathbf{t}_o^c(z) + d}{\mathbf{n}_g(y)}. \end{align} Its Jacobian with respect to $\boldsymbol{\xi}_{c}^{o}$ then can be computed as \begin{align} \frac{\partial r_{trans}}{\partial \boldsymbol{\xi}_{c}^{o}} & = \frac{\partial r_{trans}}{\partial \mathbf{t}_o^c}\frac{\partial \mathbf{t}_o^c}{\partial \boldsymbol{\xi}_{c}^{o}} \\ & = [\frac{\mathbf{n}_g(x)}{\mathbf{n}_g(y)}, 1, \frac{\mathbf{n}_g(z)}{\mathbf{n}_g(y)}]\frac{\partial \mathbf{t}_o^c}{\partial \boldsymbol{\xi}_{c}^{o}}, \end{align} where the last term can be computed as \begin{align} \frac{\partial \mathbf{t}_o^c}{\partial \boldsymbol{\xi}_{c}^{o}} & = \frac{\partial \mathbf{T}_o^c(0\mathbin{:}2, 3)}{\partial \boldsymbol{\xi}_{c}^{o}} \\ & = \frac{\partial {\mathbf{T}_c^o}^{-1}(0\mathbin{:}2, 3)}{\partial \boldsymbol{\xi}_{c}^{o}} \\ & = \frac{\partial \big((exp(\hat{\delta \boldsymbol{\xi}})\mathbf{T}_c^o)^{-1}(0\mathbin{:}2, 3)\big)}{\partial (\delta \boldsymbol{\xi})} \\ & = \frac{\partial \big((\mathbf{T}_o^c exp(-\hat{\delta \boldsymbol{\xi}}))(0\mathbin{:}2, 3)\big)}{\partial (\delta \boldsymbol{\xi})} \\ & = \big(\mathbf{T}_o^c (-\frac{\partial exp(\hat{\delta \boldsymbol{\xi}})}{\partial (\delta \boldsymbol{\xi})}) \big)(0\mathbin{:}2, 3) \label{eq:generator1}\\ & = -[(\mathbf{T}_o^c \mathbf{G}_0)(0\mathbin{:}2, 3), (\mathbf{T}_o^c \mathbf{G}_1)(0\mathbin{:}2, 3),..., (\mathbf{T}_o^c \mathbf{G}_5)(0\mathbin{:}2, 3)],\label{eq:generator2} \end{align} where we use $(0\mathbin{:}2, 3)$ to denote the operation of getting the translation part from the corresponding matrix; $\mathbf{G}_0,...,\mathbf{G}_5$ are the infinitesimal generators of SE(3). Assuming the first three elements in the twist coordinate correspond to the translation part and the last three correspond to the rotation part, the infinitesimal generators are defined as \begin{align} G_0 = \begin{bmatrix} \phantom{-}0 & \phantom{-}0 & \phantom{-}0 & \phantom{-}1\\ \phantom{-}0 & \phantom{-}0 & \phantom{-}0 & \phantom{-}0\\ \phantom{-}0 & \phantom{-}0 & \phantom{-}0 & \phantom{-}0\\ \phantom{-}0 & \phantom{-}0 & \phantom{-}0 & \phantom{-}0 \end{bmatrix},\\ G_1 = \begin{bmatrix} \phantom{-}0 & \phantom{-}0 & \phantom{-}0 & \phantom{-}0\\ \phantom{-}0 & \phantom{-}0 & \phantom{-}0 & \phantom{-}1\\ \phantom{-}0 & \phantom{-}0 & \phantom{-}0 & \phantom{-}0\\ \phantom{-}0 & \phantom{-}0 & \phantom{-}0 & \phantom{-}0 \end{bmatrix},\\ G_2 = \begin{bmatrix} \phantom{-}0 & \phantom{-}0 & \phantom{-}0 & \phantom{-}0\\ \phantom{-}0 & \phantom{-}0 & \phantom{-}0 & \phantom{-}0\\ \phantom{-}0 & \phantom{-}0 & \phantom{-}0 & \phantom{-}1\\ \phantom{-}0 & \phantom{-}0 & \phantom{-}0 & \phantom{-}0 \end{bmatrix},\\ G_3 = \begin{bmatrix} \phantom{-}0 & \phantom{-}0 & \phantom{-}0 & \phantom{-}0\\ \phantom{-}0 & \phantom{-}0 & -1 & \phantom{-}0\\ \phantom{-}0 & \phantom{-}1 & \phantom{-}0 & \phantom{-}0\\ \phantom{-}0 & \phantom{-}0 & \phantom{-}0 & \phantom{-}0 \end{bmatrix},\\ G_4 = \begin{bmatrix} \phantom{-}0 & \phantom{-}0 & \phantom{-}1 & \phantom{-}0\\ \phantom{-}0 & \phantom{-}0 & \phantom{-}0 & \phantom{-}0\\ -1 & \phantom{-}0 & \phantom{-}0 & \phantom{-}0\\ \phantom{-}0 & \phantom{-}0 & \phantom{-}0 & \phantom{-}0 \end{bmatrix},\\ G_5 = \begin{bmatrix} \phantom{-}0 & -1 & \phantom{-}0 & \phantom{-}0\\ \phantom{-}1 & \phantom{-}0 & \phantom{-}0 & \phantom{-}0\\ \phantom{-}0 & \phantom{-}0 & \phantom{-}0 & \phantom{-}0\\ \phantom{-}0 & \phantom{-}0 & \phantom{-}0 & \phantom{-}0 \end{bmatrix}. \end{align} Lastly, the Jacobian with respect to $\mathbf{z}$ is \begin{align} \frac{\partial r_{trans}}{\partial \mathbf{z}} = \mathbf{0}. \end{align} \subsubsection{Jacobian of Rotation Prior Residuals.} The rotation prior residual can be reformulated to \begin{align} r_{rot} & = 1 - (\mathbf{R}_{o}^{c}[0, -1, 0]^{\top})^{\top} \mathbf{n}_{g} \\ & = 1 - [0, -1, 0] {\mathbf{R}_o^c}^{\top}\mathbf{n}_g \\ & = 1 + [0, 1, 0] \mathbf{R}_c^o\mathbf{n}_g \\ & = 1 + \mathbf{r}_2\mathbf{n}_g, \end{align} where $\mathbf{r}_1$ is the second row of $\mathbf{R}_c^o$. Therefore, the Jacobian with respect to $\boldsymbol{\xi}_{c}^{o}$ is \begin{align} \frac{\partial r_{rot}}{\partial \boldsymbol{\xi}_{c}^{o}} & = \frac{\partial \mathbf{r}_1}{\partial \boldsymbol{\xi}_{c}^{o}}\mathbf{n}_g \\ & = \frac{\partial \mathbf{T}_c^o(1,0\mathbin{:}2)}{\partial \boldsymbol{\xi}_{c}^{o}}\mathbf{n}_g \\ & = (\frac{\partial exp(\hat{\delta \boldsymbol{\xi}})}{\partial (\delta \boldsymbol{\xi})} \mathbf{T}_c^o)(1,0\mathbin{:}2) \mathbf{n}_g \\ & = [(\mathbf{G}_0\mathbf{T}_c^o)(1,0\mathbin{:}2),...,(\mathbf{G}_5\mathbf{T}_c^o) (1,0\mathbin{:}2)]\mathbf{n}_g, \end{align} where $(1,0\mathbin{:}2)$ denotes the operation of getting the part corresponding to the second row of the rotation matrix. Lastly, we have \begin{align} \frac{\partial r_{rot}}{\partial \mathbf{z}} = \mathbf{0}. \end{align} \section{More Qualitative Results} \label{more_res} In Fig.~\ref{fig1} we qualitatively show the refinements on 3D pose and shape delivered by our method. The results on each stereo image pair are shown in each two-row block. In the first row we show the initial pose and shape estimates and our results projected onto the left image. In the second row, the initial pose (3DOP) and the estimated pose by our method are shown in the first two images, together with the ground truth 3D point cloud. In the following three images, the 3D point cloud estimated by ELAS and by our method, as well as the ground truth are shown, respectively. As shown in the results, dense stereo matching results become extremely noisy on the strong non-lambertian reflective car surfaces. Our results avoid using such results for recovering the 3D poses and shapes of cars, instead it works directly on images by performing joint silhouette and photometric alignment. While it drastically improves the 3D shape reconstruction, it can also effectively recover the 3D poses of the objects. \begin{figure*} \centering \includegraphics[width=0.465\textwidth]{images/007-6.png}% \includegraphics[width=0.465\textwidth]{images/007-7.png} \includegraphics[width=0.186\textwidth]{images/007-3.png}% \includegraphics[width=0.186\textwidth]{images/007-4.png}% \includegraphics[width=0.186\textwidth]{images/007-1.png}% \includegraphics[width=0.186\textwidth]{images/007-5.png}% \includegraphics[width=0.186\textwidth]{images/007-2.png}\vspace{1ex} \includegraphics[width=0.465\textwidth]{images/010-6.png}% \includegraphics[width=0.465\textwidth]{images/010-7.png} \includegraphics[width=0.186\textwidth]{images/010-3.png}% \includegraphics[width=0.186\textwidth]{images/010-4.png}% \includegraphics[width=0.186\textwidth]{images/010-1.png}% \includegraphics[width=0.186\textwidth]{images/010-5.png}% \includegraphics[width=0.186\textwidth]{images/010-2.png}\vspace{1ex} \includegraphics[width=0.465\textwidth]{images/0198-6.png}% \includegraphics[width=0.465\textwidth]{images/0198-7.png} \includegraphics[width=0.186\textwidth]{images/0198-3.png}% \includegraphics[width=0.186\textwidth]{images/0198-4.png}% \includegraphics[width=0.186\textwidth]{images/0198-1.png}% \includegraphics[width=0.186\textwidth]{images/0198-5.png}% \includegraphics[width=0.186\textwidth]{images/0198-2.png}\vspace{1ex} \includegraphics[width=0.465\textwidth]{images/120_09-6.png}% \includegraphics[width=0.465\textwidth]{images/120_09-7.png} \includegraphics[width=0.186\textwidth]{images/120_09-3.png}% \includegraphics[width=0.186\textwidth]{images/120_09-4.png}% \includegraphics[width=0.186\textwidth]{images/120_09-1.png}% \includegraphics[width=0.186\textwidth]{images/120_09-5.png}% \includegraphics[width=0.186\textwidth]{images/120_09-2.png} \caption{Qualitative results on 3D pose and shape refinements. Each two-row block shows the results on one stereo frame from the KITTI Stereo 2015 benchmark. Top row: The initial pose and shape (left) and our results (right) projected to the left image. Bottom row: The initial poses estimated by 3DOP and the poses refined by our method shown together with the ground truth 3D point cloud (1st and 2nd); The following three images show the 3D points estimated by ELAS (middle), our method (4th) and from the ground truth (last). Note that the 3D point clouds are not used in our optimization. (better viewed electronically)} \label{fig1} \end{figure*} More qualitative results are listed in Fig.~\ref{fig:eval_pose_quality1} and \ref{fig:eval_pose_quality2}, where the input images are shown on the left and our results overlaid to the input images are shown on the right. \begin{figure*}[] \centering \includegraphics[width=0.44\textwidth]{images/qualitative/000120_09.jpg}% \includegraphics[width=0.44\textwidth]{images/qualitative/stereo_0120_09.jpg}\vspace{1ex} \includegraphics[width=0.44\textwidth]{images/qualitative/000328.jpg}% \includegraphics[width=0.44\textwidth]{images/qualitative/obj_0328.jpg}\vspace{1ex} \includegraphics[width=0.44\textwidth]{images/qualitative/000335.jpg}% \includegraphics[width=0.44\textwidth]{images/qualitative/obj_0335.jpg}\vspace{1ex} \includegraphics[width=0.44\textwidth]{images/qualitative/000199_10.jpg}% \includegraphics[width=0.44\textwidth]{images/qualitative/stereo_0199_10.jpg}\vspace{1ex} \includegraphics[width=0.44\textwidth]{images/qualitative/000031.jpg}% \includegraphics[width=0.44\textwidth]{images/qualitative/obj_0031.jpg}\vspace{1ex} \includegraphics[width=0.44\textwidth]{images/qualitative/000323.jpg}% \includegraphics[width=0.44\textwidth]{images/qualitative/obj_0323.jpg}\vspace{1ex} \includegraphics[width=0.44\textwidth]{images/qualitative/000443.jpg}% \includegraphics[width=0.44\textwidth]{images/qualitative/obj_0443.jpg}\vspace{1ex} \includegraphics[width=0.44\textwidth]{images/qualitative/000052.jpg}% \includegraphics[width=0.44\textwidth]{images/qualitative/obj_0052.jpg}\vspace{1ex} \includegraphics[width=0.44\textwidth]{images/qualitative/000420.jpg}% \includegraphics[width=0.44\textwidth]{images/qualitative/obj_0420.jpg}\vspace{1ex} \caption{Qualitative results on 3D pose and shape estimation. }\vspace{-1ex} \label{fig:eval_pose_quality1} \end{figure*} \begin{figure*}[] \centering \includegraphics[width=0.44\textwidth]{images/qualitative/000161.jpg}% \includegraphics[width=0.44\textwidth]{images/qualitative/obj_0161.jpg}\vspace{1ex} \includegraphics[width=0.44\textwidth]{images/qualitative/000415.jpg}% \includegraphics[width=0.44\textwidth]{images/qualitative/obj_0415.jpg}\vspace{1ex} \includegraphics[width=0.44\textwidth]{images/qualitative/000510.jpg \includegraphics[width=0.44\textwidth]{images/qualitative/obj_0510.jpg}\vspace{1ex} \includegraphics[width=0.44\textwidth]{images/qualitative/000694.jpg}% \includegraphics[width=0.44\textwidth]{images/qualitative/obj_0694.jpg}\vspace{1ex} \includegraphics[width=0.44\textwidth]{images/qualitative/000708.jpg}% \includegraphics[width=0.44\textwidth]{images/qualitative/obj_0708.jpg}\vspace{1ex} \includegraphics[width=0.44\textwidth]{images/qualitative/000048_10.jpg}% \includegraphics[width=0.44\textwidth]{images/qualitative/stereo_0048_10.jpg}\vspace{1ex} \includegraphics[width=0.44\textwidth]{images/qualitative/000010_10.jpg}% \includegraphics[width=0.44\textwidth]{images/qualitative/stereo_0010_10.jpg}\vspace{1ex} \includegraphics[width=0.44\textwidth]{images/qualitative/000034_10.jpg}% \includegraphics[width=0.44\textwidth]{images/qualitative/stereo_0034_10.jpg}\vspace{1ex} \includegraphics[width=0.44\textwidth]{images/qualitative/000008.jpg}% \includegraphics[width=0.44\textwidth]{images/qualitative/obj_0008.jpg}\vspace{1ex} \caption{Qualitative results on 3D pose and shape estimation (cont.). }\vspace{-1ex} \label{fig:eval_pose_quality2} \end{figure*} \end{document}
{'timestamp': '2020-03-11T01:03:19', 'yymm': '1904', 'arxiv_id': '1904.10097', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.10097'}
arxiv
\section{Introduction} Autonomous vehicles have a promising future of making transportation time effortless and enabling the driver to partake in other activities and therefore change everyday life across the world. The greatest strength of autonomous vehicle is to avoid traffic accidents caused by human error, and thus to improve safety on roadways \cite{bagloee2016autonomous}. With the development of autonomous vehicles, the focus in research moves towards complex traffic scenarios such as intersections. Intersections, at which multiple roads and opposing directions of traffic meet together, are designed to prevent traffic jams by easing the flow of traffic. The intersections can be divided into signalized intersections and unsignalized intersections \cite{timmurphy.org}. The signalized intersections have signs and signals to regulate traffic while the unsignalized intersections do not. The unsignalized intersections are typically found where the traffic flow is low. However, they usually have higher collision frequencies than the signalized intersections due to driver's indecision. One report of National Highway Traffic Safety Administration (NHTSA) in 2011 indicates that 40$\%$ of car collisions in the U.S. happen at intersections and 60$\%$ of them are related to unsignalized intersections \cite{hubmann2017decision}. It is expected that the autonomous vehicle can efficiently avoid intersection mishap by making appropriate decisions and orchestrating proper actions without driver's intention. The decision making by autonomous vehicle at unsignalized intersections is a critical problem. Several approaches have been recently proposed. One common way is to investigate the human behaviour in unsignalized intersection in order to create a naturalistic decision process \cite{liu2007human, gadepally2014framework}. For example, \cite{de2017decision} proposes a human-like decision-making algorithm based on the human drivers' data. A cooperative approach is developed for collision avoidance at intersections based on formal control theoretic techniques \cite{hafner2013cooperative}. However, the approach requires vehicle-to-vehicle communication and thus is not scalable to general intersection handling. The principle of reachability-based decision-making approach, which predicts the probability of future collisions using error propagation, is applicable to frontal collision avoidance at intersections \cite{de2014collision}. However, this approach may lead to conservative results. An intention-aware decision-making model for unsignalized intersections is studied in \cite{song2016intention}, where drivers' intentions are modelled using two-layered hidden Markov models. However, the intention estimation is deterministic. This paper uses game theory for the decision making. Game theory is the study of decision making where the players (e.g. vehicles) make choices by maximising their own expected utility based on the possible actions of other players. Thus, game theory provides a promising framework for scenarios where interactions are involved and has been widely used in various areas such as robotics \cite{meng2008multi} and economy \cite{hodgson2012evolutionary}. There are also many examples of using game theory in intelligent transport systems. A game theoretic approach for modelling the flow of vehicles in a road with lane change is proposed in \cite{talebpour15}. A cooperative strategy in non-zero-sum games is applicable to solving conflict situations between two autonomous vehicles in a roundabout \cite{banjanovic2016autonomous}. The decision making based on $k$-level games are studied for two autonomous vehicles at unsignalised intersections \cite{li18} and roundabouts \cite{tian18}. In our previous work \cite{pruekprasert19}, we proposed a decision making for multiple autonomous vehicles at roundabouts based on Nash equilibria This paper proposes two main contributions. First, we propose a game-theoretic decision making of multiple autonomous vehicles in an unsignalized intersection using Nash equilibria in a perfect information game. Instead of using the concept of ``aggressiveness'' value proposed in \cite{pruekprasert19}, we determine the decision order of the vehicles based on their priorities (e.g., based on the rules of the right of way). Second, we consider aggressive and unpredictable driving behaviours of malicious vehicles to simulate the real complex traffic environment. Before the widespread adoption of the autonomous vehicles, the human drivers need to share roads with autonomous vehicles. For this reason, we classify the drivers using different levels of maliciousness, describing vehicles breaking the law, or having irrational behaviours. The remainder of this paper is organised as follows. First, we formulate the problem in Section \ref{section:model}. The game-theoretic decision making approach is presented in Section \ref{section:decision}. Then, Section \ref{section:priority} introduces the design of formalising priorities. After validating the performance of the proposed method in Section \ref{section:experiments}, Section \ref{section:conclusion} draws the conclusions. \section{Problem formulation}\label{section:model} \subsection{Vehicles at unsignalised intersection}\label{section: scenario} We consider autonomous vehicles in a four-way unsignalized intersection. We assume that vehicles are driving on the left and that there are at most four vehicles at the intersection, entering from different directions. Their decision making depends on the vehicles that are going to enter or are already engaged in the intersection, but not on those that have already left the intersection. We also assume that every vehicle knows which way every other vehicle is intending to use, as every vehicle declares its intention using their turn signal. \subsection{Vehicle configurations}\label{section:path} We focus on the high-level decision making of autonomous vehicles following a precomputed path. For this reason, we do not consider the path trackers and the low-level control layer in this work. So then, we over-approximate the road occupancy of each vehicle using three circles (much as \cite{cao18}, see Fig.~\ref{fig:threecircles}) and assume that the vehicles perfectly follow the given navigation paths. \begin{figure}[t!] \begin{center} {\includegraphics[width=0.55\linewidth]{threecircles.png}} \caption{Road occupancy by over-approximation} \label{fig:threecircles} \end{center} \end{figure} Much as \cite{pruekprasert19}, we consider the case where the navigation path of each vehicle $i$ is fixed and denoted by $\mathit{path}(i) \in \{$``straight'',``turn right'',``turn left''$\}$. Thus, each vehicle can only control its acceleration along the given navigation path at each time step. More specifically, at each time step $t$, each vehicle $i$ chooses its acceleration $a_i(t)$ in a finite set in order to minimise their overall cost functions. The configuration of the vehicle $i$ at time step $t$ is denoted by: \begin{equation} X_i(t)=[x_i(t), y_i(t), v_i(t), a_i(t), \text{sta}_i(t)]^\top \label{eq:configuration} \end{equation} where $(x_i(t), y_i(t))$ is the position of the vehicle $i$ (where $(0,0)$ is the center of the intersection), $v_i(t)$ is its velocity, $a_i(t)$ is its acceleration, and $\text{sta}_i(t) \in \{\text{``entering'' }, \text{``inside'' }, \text{``leaving''}\}$ is its current status (i.e., not yet entered, already inside the intersection, or far enough from the centre of the intersection) respectively. Then, given the control input, that is, the acceleration $a_i(t)$, the configuration at time step $t+1$ is represented by: \begin{equation} X_i(t+1) = \NEXT_i(X_i(t), a_i(t)), \label{eq:nextstep} \end{equation} where the function $\NEXT_i$ is computed from the navigation path and returns the configuration of the vehicle $i$ after one time step, assuming the vehicle has constant acceleration $a_i(t)$ between the time steps $t$ and $t+1$. \subsection{Rules for the right of way}\label{section:rightofway} For this paper, we use Japanese rules for deciding priorities of vehicles \cite{npa11}. Rules are slightly different in other countries, especially on the side that have more priority (e.g., left in Japan \cite{npa11}, right in Australia \cite{ntg15}). Each vehicle intending to enter an unsignalized intersection then has to give the right of way to any vehicle (in order of importance): \begin{itemize} \item[A)] already engaged in the intersection, \item[B)] on its left-hand side, \item[C)] significantly closer to the intersection. \end{itemize} A vehicle can proceed and engage in the intersection, as long as it does not cross the way of a vehicle to which it should have given the right of way. In Section \ref{section:priority}, we describe more precisely how we implement these rules in our decision making. \subsection{Levels of maliciousness}\label{section:angelicdemonic} \begin{figure}[t!] \begin{center} {\fontsize{8pt}{8pt}\selectfont \begin{tabular}{|c|c|c|c|c|} \hline type & angelic & inter. & demonic & irrational\\ \hline initial. & right of way & \multicolumn{2}{c|}{selfish} & \multirow{2}{*}{none}\\ S.\ref{section:initial} & S.\ref{section:rightofway} & \multicolumn{2}{c|}{i.e. highest priority} &\\ \hline decision & \multicolumn{3}{c|}{\multirow{3}{*}{Nash equilibrium}} & \multirow{3}{*}{random}\\ making & \multicolumn{3}{c|}{} & \\ S.\ref{section:decision} & \multicolumn{3}{c|}{} & \\ \hline update & right of way & \multirow{3}{*}{fitting} & \multicolumn{2}{c|}{\multirow{3}{*}{none}}\\ priority & + & & \multicolumn{2}{c|}{}\\ S.\ref{section:updates} & fitting & & \multicolumn{2}{c|}{}\\ \hline \end{tabular}} \end{center} \caption{Summary of the different level of maliciousness} \label{figure:malicious} \end{figure} In this paper, we consider four kinds of vehicles (see Fig.~\ref{figure:malicious}): \begin{itemize} \item \emph{Angelic}. Such a vehicle tries to follow the rules of Section \ref{section:rightofway} and to avoid any collision. \item \emph{Intermediate}. Such a vehicle does not follow the rules from Section \ref{section:rightofway} by initially considering that it has priority. However, it may give priority to other vehicles if the situation requires it. \item \emph{Demonic}. Such a vehicle is selfish: it does not respect the rules and believes that it always has the priority. However, it considers other vehicles' behaviours in its decision making. \item \emph{Irrational}. Such a vehicle randomly chooses its acceleration at every time step, independently of the situation. \end{itemize} Our goal is to see how our ego vehicle -- considered as angelic -- behaves in presence of different types of vehicles, including some that do not respect the rules, at different degrees of severity. \subsection{Structure of the decision making}\label{section:structure} In the following two sections, we describe more precisely our decision making for autonomous vehicles with different levels of maliciousness. Our method consists of two main components: maintaining priority orders (Section \ref{section:priority}), and computing the control inputs (Section \ref{section:decision}). Both components depend on the computations of Nash equilibria (Section \ref{section:game}), similarly to our previous paper \cite{pruekprasert19}. \section{Control inputs and predictions, as Nash equilibria}\label{section:decision} Other than irrational vehicles, each vehicle determines its acceleration based on rational decision making. In this section, we discuss a game-theoretic approach to the problem, similarly to \cite{pruekprasert19}. Using the concept of \emph{priority order} that we will describe more precisely in Section \ref{section:priority}, we formulate the decision making problem as a finite perfect-information game. The players are non-cooperative vehicles, and they try to minimise their cost. \subsection{$n$-player game with perfect information}\label{section:game} We consider \emph{$1$-round sequential games with perfect and complete information} $G = (P,\Gamma,(H_1,\ldots,H_n))$ where: \begin{itemize} \item $P = \{1, \ldots, n\}$ is a finite set of \emph{players}, \item $\Gamma$ is a finite set of \emph{strategy profiles}, \item $H_j: \Gamma^n \rightarrow \mathbb{R}$ is the \emph{cost function} for player $j$. \end{itemize} In such a game, every player chooses a strategy profile from $\Gamma$ to minimise its cost function. We are particularly interested in \emph{Nash equilibria}, that is, a set of strategies $\gamma_1$, \ldots, $\gamma_n$ for every player that is optimal in the sense that for every player $j$, for every strategy $\gamma_j'$: \[H_j(\gamma_1, \ldots, \gamma_n) \leq H_j(\gamma_1, \ldots, \gamma_j', \ldots, \gamma_n)\] When a total order $\prec$ on the set of players is given, it is possible to compute such a Nash equilibrium by \emph{backward induction}: intuitively, the order $\prec$ gives an order with which the players choose their strategy in such a way they ensure optimality. We invite an interested reader to take a look at usual textbooks, much as \cite{O2009}, for more details on game theory. \subsection{Cost functions for the decision making in an intersection} \label{section:cost} \subsubsection{Cost at each time step} We first introduce the cost of a vehicle at each time step, which we call the \emph{step-cost}. The step-cost of the vehicle $i$ is given by \begin{equation} \SCOST_i(\bm{X}, \prec) = \phi_i^\mathit{safe}(\bm{X}, \prec)+\phi_i^\mathit{velo}(\bm{X}) \label{eq:stepcost} \end{equation} where $\bm{X}$ is a vector of configurations as in (\ref{eq:configuration}), i.e., \[\bm{X} = [X_1^\top, \ldots, X_n^\top]^\top\] and $\prec$ is a total order on the set of vehicles. \subsubsection{Safety} For each pair of vehicles $i$ and $k$, let $d(k,i)$ be the distance between their occupancy, given by the union of three circles (see Section \ref{section:path} and Fig.~\ref{fig:threecircles}). With this, we define the \emph{safety feature} by \[\phi_i^\mathit{safe}(\bm{X}, \prec) = \sum_{k \neq i} \phi_i^k(\bm{X}, \prec),\] where \begin{equation} \phi_i^k(\bm{X}, \prec) = \begin{cases} 0 &\mbox{if } \text{sta}_i=\mbox{``leaving''},\\ \multirow{2}{*}{0} &\mbox{else if the navigation paths}\\ &\mbox{of } i \mbox{ and } k \mbox{ do not collide},\\ 0 &\mbox{else if } d(k,i)\geq D,\\ C_\mathit{d} \cdot (D - d(k,i))^2& \mbox{else if } d(k,i) \leq D_\mathit{danger},\\ \multirow{2}{*}{0} & \mbox{else if } i \mbox{ is minimal for } \prec\\ & \mbox{i.e. } i \mbox{ have highest priority},\\ C_\mathit{n} \cdot (D - d(k,i))^2 & \mbox{otherwise} \end{cases} \label{eq:bfcost} \end{equation} Here, $0 < C_\mathit{n} \ll C_\mathit{d}$, $0 < D_\mathit{danger}<D$ are given constants. The intention is that, as long as there is no danger of collision, the vehicle $i$ does not care about safety, but when there is a possibility of collision, the closer the vehicle $k$ is, the more careful the vehicle $i$ is. A special case is when the vehicle $i$ has the highest priority, where $i$ cares less about safety. This case is in order to break symmetric situations where all vehicles would be too conservative. \subsubsection{Velocity} Let $v_\mathit{l}$ be the speed limit of the road. We define the \emph{velocity feature} by \begin{equation} \phi_i^\mathit{velo}(\bm{X}) = \begin{cases} C_\mathit{u} \cdot( v_\mathit{l} - v_i)^2 &\mbox{if } v_\mathit{l} \geq v\\ C_\mathit{o}\cdot(v_\mathit{l} - v_i)^2 &\mbox{otherwise} \end{cases} \label{eq:velocost} \end{equation} Here, we choose $0 < C_\mathit{u} \ll C_\mathit{o}$ so that each vehicle obeys the law. \subsubsection{Accumulated cost function} We construct the \emph{accumulated cost function} based on the receding horizon control approach~\cite{K2005}, which determines the control inputs of the vehicles based on the predicted future up to a horizon time step $h < \infty$. Given a vector of accelerations $\bm{a} = [a_j(s)]_{j \in N, 0 \leq s \leq h-1}$, define $K_j(\bm{X},\prec,\bm{a}) = \sum\limits_{s = 0}^{h-1}\,\lambda^s\cdot S_j(\widehat{X}(\bm{a},s),\prec)$ where $\lambda$ is the discounted factor and $\widehat{X}(\bm{a},s)$ is defined by induction on $s$: \begin{itemize} \item $\widehat{X}(\bm{a},0) = \bm{X}$, \item $\widehat{X}(\bm{a},s+1) = [\NEXT_k(\widehat{X}_k(\bm{a},s),a_k(s)]_{k \in N}$. \end{itemize} \subsection{Decision game}\label{section:decisiongame} In a very similar spirit as \cite{pruekprasert19}, we describe a collection of games whose players are the vehicles at the intersection. Assume that a total order $\prec$ on the set of vehicles and a vector of configurations $\bm{X}$ are given. We define the game $G_{\bm{X},\prec}$ as follows: \begin{itemize} \item The set $P$ of players is the set of vehicles. \item The set $\Gamma$ is a finite set of \emph{acceleration patterns}, that is, a finite subset of $\mathbb{R}^h$, where $h$ is the time horizon. \item For every vehicle $j$, $H_j(\bm{a}) = K_j(X,\prec, \bm{a})$. \item The order is given by $\prec$. \end{itemize} We can then compute a Nash equilibrium using backward induction as described in Section \ref{section:game}. This produces a collection of acceleration patterns that we denote by \[\bm{a}(\bm{X},\prec) = [a_j(s,\bm{X},\prec)]_{j \in N, 0 \leq s \leq h-1}.\] The intention of $a_j(s,\bm{X},\prec)$ is to be a prediction of the acceleration of the vehicle $j$ after $s$ time steps, starting from the configuration $\bm{X}$, considering $\prec$ as the priority order. \subsection{Computing control inputs and predicted configurations}\label{section:computation} Consider a vehicle $i$ that is not irrational. At each time step $t$, the vehicle $i$ observes the precise configuration $\bm{X}(t)$ of every car. It also maintains a \emph{priority order} $\PRIO{i}{t}$, a total order on the set of vehicles. We will see in Section \ref{section:priority} how this order is initialised and updated. From those data, the vehicle $i$ can consider the game $G_{\bm{X}(t),\PRIO{i}{t}}$, and then compute a Nash equilibrium as previously. We then obtain: \begin{itemize} \item the control input $a_i(t)$ of the vehicle $i$ at time step $t$ given by $a_i(0,\bm{X}(t), \PRIO{i}{t})$, \item a prediction $\widehat{a}_{i,j}(t)$ by the vehicle $i$ of the acceleration of the vehicle $j$ at time step $t$. \end{itemize} From these predicted accelerations, the vehicle $i$ can compute a prediction of the configuration of the vehicle $j$ at time step $t+1$ by: \[\widehat{X}_{i,j}(t+1) = \NEXT_j(X_j(t), \widehat{a}_{i,j}(t))\] \subsection{Resolving deadlocks}\label{section:deadlocks} The previous subsection described a way of computing the control input by solving a game. This method can however lead to deadlocks, that is, situations where no vehicle takes the decision to go on, and every vehicle waits for others to take the lead. This would typically happen when there is a vehicle in each of the four ways, and that there is no clear priority order that would resolve the situation. Formally, for a vehicle $i$ that is not irrational, this case is to be considered when: \begin{enumerate} \item the velocities of all vehicles are zero, and \item the accelerations of all vehicles are precisely predicted using $\PRIO{i}{t}$. \end{enumerate} In the theory of concurrent system, it is known that it is impossible to avoid such a situation using only deterministic choices, and a solution is to introduce some randomness to resolve the situation \cite{lehmann81}. A vehicle $i$ can unlock the situation in two cases: \begin{itemize} \item either when detecting a deadlock and considering having the highest priority, that is, $i$ being minimal for $\PRIO{i}{t}$, \item or when $i$ already detected a deadlock at time $t-1$. \end{itemize} In those cases, the vehicle $i$ set its acceleration $a_i(t+1)$ without following a Nash equilibrium. Concretely, in our simulations, this vehicle $i$ can set its acceleration $a_i(t+1)$ to $10m/s^2$ with probability 0.25, which will ultimately break the symmetry of a deadlock situation. \section{Formalising Priorities}\label{section:priority} Again, other than irrational vehicles, each vehicle assumes some total order. In this section, we describe how each of those vehicles $i$ initialises and updates a total order $\PRIO{i}{t}$ on the set of vehicles. This process depends on the type of the vehicle. This is the main difference from \cite{pruekprasert19}, where the order $\prec$ was deduced from the behaviours of other cars, described by their ``aggressiveness'' values. In this paper, the order is obtained from the rules of the right of way, and by the character angelic/demonic of the cars. \subsection{Initialising priorities}\label{section:initial} \subsubsection{Angelic case} Let us assume first that the vehicle $i$ is angelic. In this case, the vehicle $i$ will try to comply to the rules of the right of way as in Section \ref{section:rightofway}. For that reason, the vehicle $i$ initialises its priority order $\PRIO{i}{0}$ by randomly choosing a total order that satisfies the following: \begin{itemize} \item[A)] If $\text{sta}_j =$ ``inside'' and if $\text{sta}_k \neq$ ``inside'', then $j \prec_{i,0} k$. \item[B)] Else, if the number of vehicles is less than 4 and $j$ is ``on the left-hand side'' of $k$, $j \prec_{i,0} k$. \item[C)] Else, let $d_j$ and $d_k$ be the distances of $j$ and $k$ from the centre of the intersection, respectively. If $j$ is significantly closer to the centre of the intersection than $k$, meaning that $d_k - d_j > 2$ meters, then $j \prec_{i,0} k$. \end{itemize} \subsubsection{Selfish cases} Now, let us assume that the vehicle $i$ is demonic or intermediate. Such a vehicle will consider itself as initially having priority, and will not care about other vehicles. So the vehicle $i$ will initialise its priority order $\PRIO{i}{0}$ by randomly choosing any total order on the set of vehicles such that $i$ is the lowest element $ i \PRIO{i}{0} j$ for all $j\neq i.$ \subsection{Updating the priority predictions}\label{section:updates} As explained in Section \ref{section:angelicdemonic}, demonic vehicles do not update their priority order, while intermediate and angelic ones do. Thus, if the vehicle $i$ is demonic, we always have $\PRIO{i}{t+1} = \PRIO{i}{t}$ for any time step $t$. If the vehicle $i$ is angelic or intermediate, it will update its priority only when necessary: when the priority from the rules of the right of way changes and when its predictions are imprecise. \subsubsection{Update according to the rules of the right of way} If the vehicle $i$ is angelic, $i$ always updates its priority order whenever the right of way changes. For example, when a vehicle leaves the intersection and when a vehicle that does not have priority enters the intersection. For this case, we update $\PRIO{i}{t+1}$ according to the current right of way in the same way as in Section \ref{section:initial}. If the rule of the right of way does not change at the current time step $t$, we use $\PRIO{i}{t+1} = \PRIO{i}{t}$. \subsubsection{Update due to imprecise predictions} We consider this type of update for intermediate vehicles and angelic vehicles that do not use the update according to the rules of the right of way at the current time step $t+1$. Suppose that $i$ is one of those vehicles. As in Section \ref{section:computation}, given the priority order $\prec_{i,t}$ and the observed configuration $\bm{X}(t)$ at the previous time step $t$, the vehicle $i$ can predict the configurations $\widehat{X}_{i,j}(t+1)$ of any other vehicle $j$. In the case where these predictions are different from the observed configurations $X_j(t+1)$, the vehicle $i$ updates its priority order to fit more closely these new observations. To this end, the vehicle $i$ computes the Nash equilibrium of the decision game $G_{\bm{X}(t), \prec}$ for any total order $\prec$, and choose $\prec'$ as the total order such that: \begin{itemize} \item The difference between predicted and observed accelerations is minimal: \[\prec' \in \arg\min_{\prec'}\sum\limits_{j \in N} \lvert a_j(0,\bm{X}_j(t), \prec') - a_j(t+1)\rvert.\] \item If several $\prec'$ satisfy the first condition, choose the one that gives the minimal acceleration $a_i(0,\bm{X}(t), \prec')$. \end{itemize} The intention of the second condition is the following: the reason why vehicle $i$ needs to change its priority order is because some vehicles are going against its believes (either the rules of the right of way for angelic, or selfishness for intermediate). In any case, the vehicle has to be particularly careful in the case it is dealing with a demonic or an irrational vehicle. We also define $\PRIO{i}{t+1}$ as follows: \begin{itemize} \item If $a_i(0,\bm{X}(t), \prec') \leq a_i(0,\bm{X}(t), \PRIO{i}{t})$, $\PRIO{i}{t+1} \,=\, \prec'$. \item Otherwise, $\PRIO{i}{t+1} \,=\, \prec'$ with probability $0.25$, and $\PRIO{i}{t+1} ~=~ \PRIO{i}{t}$ with probability $0.75$. \end{itemize} Again the intention of the second case is to be careful in a situation where the vehicle would benefit by being more aggressive, while in a situation that contradicts its believes. \section{Experimental results}\label{section:experiments} To verify the effectiveness of our approach, we perform numerical simulations using Matlab 2018a and 2018b. \subsection{Experiment scenario} \begin{figure} \centering \includegraphics[ height=4cm]{intersection.png} \caption{The unsignalized intersection used for the simulations, the three navigation paths, and the initial positions of each vehicle.\label{fig:intersection}} \end{figure} We consider four vehicles approaching an unsignalized intersection as shown in Fig.~\ref{fig:intersection}: each vehicle approaching from each entrance. We assume that all vehicles have rectangle shapes, and over-approximate the road occupancy of each vehicle using three circles shown in Fig.~\ref{fig:threecircles}. We consider that two vehicles collide if their road occupancy areas intersect. The structure of the intersection and the three navigation paths are also illustrated in Fig.~\ref{fig:intersection}. The navigation path type of each vehicle is randomised. The length and width of each vehicle are randomised within the range $(3.5m, 5.5m)$ and $(1.5m,2.1m)$, respectively. We consider that the navigation paths of given two vehicles do not collide only when the two vehicles approach the intersection from the opposite directions, and each vehicle either turns left or goes straight. For each vehicle $i$, $\text{sta}_i(t)$ is given as follows: \begin{enumerate} \item $\text{sta}_i(t)= $ ``entering'' if the vehicle $i$ is approaching the intersection but none of its part has yet entered the intersection, i.e., the rectangle that represents the vehicle has not yet intersected the red area in Fig.~\ref{fig:intersection}. \item $\text{sta}_i(t)= $ ``leaving'' if more than half of the vehicle is already outside the intersection. \item $\text{sta}_i(t)= $ ``inside'' otherwise. \end{enumerate} The decision making is performed every $0.1s$. The discounted factor for the accumulated cost function is $\lambda=0.8$. The speed limit of the road is $v_l =16.7 m/s$. The constant parameters are as follows: $C_{n}=20$, $C_{d}=10^{300}$, $D = 25\,m$, $D_\mathit{danger} = 0.5\,m$, $C_u = 1$, and $C_o = 1000$. We use the following patterns of acceleration/deceleration sequences with a time horizon $h = 3$. All the accelerations in this section are in $m/s^2$. \begin{itemize} \item $[-50, -50, -50]$ for a deceleration, \item $[0,0,0]$ for no acceleration, \item $[10,0,0]$ for a small acceleration, \item $[20, 0, 0]$ for a strong acceleration. \end{itemize} The accelerations of a irrational vehicle are randomly selected from the set $\{-50,0,10,20\}$. \subsection{Results and analysis} \begin{table} \begin{center} \caption{Simulation Results} \begin{threeparttable} \renewcommand{\arraystretch}{1.8} {\fontsize{6.5pt}{6.5pt}\selectfont \newcommand{\tabincell}[2]{\begin{tabular}{@{}#1@{}}#2\end{tabular}} \begin{tabular}{r|ccc} \hline \textbf{Case} & \textbf{Collision rate(\%)} & \textbf{Congestion rate(\%)} & \textbf{Avg. Total time steps}\\ \hline 1 & 0 & 0 & 56.87 (5.687s)\\ \hline 2 & 0 & 0.2 & 53.98 (5.398s)\\ \hline 3 & 0 & 0 & 59.09 (5.909s)\\ \hline 4 & 0.4 & 4.0 & 91.88 (9.988s)\\ \hline 1' & 0 & 0.5 & 55.43 (5.543s)\\ \hline 2' & 0 & 1.4 & 50.58 (5.058s)\\ \hline 3' & 0 & 9.4 & 55.81 (5.581s)\\ \hline 4' & 1.1 & 14.3 & 75.82 (7.582s)\\ \hline \end{tabular}} \end{threeparttable} \end{center} \label{Table:ExperimentalResult} \end{table} We perform 2000 simulations for all those cases. \begin{enumerate} \item[1] Four angelic vehicles. \item[2] Three angelic vehicles and one demonic vehicle. \item[3] Four intermediate vehicles. \item[4] Three intermediate vehicles and one irrational vehicle. \end{enumerate} 1000 simulations are done with initial velocity $v_i(0) = 0$ (cases 1-4), and 1000 simulations with random initial velocity depending on the type of the vehicle (cases 1'-4'): \begin{itemize} \item if the vehicle is demonic or irrational, we randomly choose in the interval $[0,16.7]$m/s, \item if the vehicle is angelic or intermediate, we randomly choose in the interval $[0,6]$m/s. \end{itemize} Observe that cases 3 and 4 contain no angelic vehicles, even though we assume that the ego vehicle should be angelic. This is to see how robust the fitting method of Section \ref{section:updates} is for intermediate vehicles. As presented in Table \ref{Table:ExperimentalResult}, we evaluate the simulations by considering the following criteria. The first column presents the collision percentage. The second column presents the percentage of the simulations that have congestions, which are situations such that: 1) there are at least two vehicles, $i$ and $j$, such that $\text{sta}_i(t)= \text{sta}_j(t)= \mbox{``inside''}$ and 2) the navigation paths of both vehicles may collide. The third column presents the average total time that the vehicles spend running along their navigation paths. For cases 1, 2, and 3, all vehicles successfully leave the intersection without any collisions. Some collisions are detected for the case 4, due to the unpredictable behaviour of the irrational vehicle. In the cases where the initial velocity is possibly non zero, we detect more congestions, due to the fact that vehicles have less time to make their decision before entering the intersection. However, the total time is shorter because each vehicle starts with some initial velocity. The results also show that the vehicles may spend less time in the intersection if some of them are selfish. The case 2 is particularly interesting because it has fewer time steps than case 1. One possible explanation for this case is that the selfish vehicle makes the decision making easier: it will force itself through the intersection, so that angelic vehicles have no choice but to let it go first. After this vehicle leaves the intersection, the decision making with three vehicles is much easier. \begin{figure}[t] \centering \includegraphics[scale=0.14]{t9.jpg} \includegraphics[scale=0.14]{t16.jpg} \includegraphics[scale=0.14]{t20.jpg} {\scriptsize (a) time step = 9 \hspace{1cm} (b) time step = 16 \hspace{1cm} (c) time step = 20} \caption{A dangerous situatio \label{fig:example} } \end{figure} In Fig.~\ref{fig:example}, we present a dangerous situation of the case 4'. The red vehicle is irrational, while the other three vehicles are intermediate. In Fig.~\ref{fig:example}(a), the red vehicle is entering the intersection, while the other three are stopped. However, in Fig.~\ref{fig:example}(b), the red vehicle suddenly stops, so the pink vehicle thinks it can enter the intersection. Finally in Fig.~\ref{fig:example}(c), the red vehicle starts again and the pink vehicle is forced to update its priority order as in Section \ref{section:updates} and gives the way to the red vehicle. This scenario demonstrates that our decision making is robust enough to avoid such potential accidents. \section{Conclusion} \label{section:conclusion} In this paper, we propose a decision making for autonomous vehicles in a unsignalized intersection in presence of selfish and irrational vehicles. The decision is made by computing Nash equilibria of sequential games played by the vehicles. The decision orders of those games are based on the believes of which vehicles have priority: angelic vehicles define their priorities based on the rules of the right of way, while malicious ones regard themselves as having priority or do not pay any attention to priorities. We consider several scenarios where vehicles respecting the law (angelic) share the road with selfish vehicles and irrational ones, which randomly choose their accelerations. We illustrate those scenarios in our numerical simulations, demonstrating its feasibility and the robustness of our decision making in presence of malicious vehicles. As a future work, systematic experiments based on more sophisticated and practical traffic simulators will be conducted to further evaluate our model, and more detailed techniques will be adopted to eliminate the potential hazards. \bibliographystyle{IEEEtran}
{'timestamp': '2019-10-07T02:03:50', 'yymm': '1904', 'arxiv_id': '1904.10158', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.10158'}
arxiv
\section{Introduction} Wearable cameras are becoming an increasingly viable platform for entertainment and productivity. In augmented reality (AR), wearable headsets will let users blend useful information from the virtual world together with their real first-person visual experience to access information in a timely manner or interact with games. In healthcare, wearables can open up new forms of remote therapy for rehabilitating patients \cctwo{trying to improve their body's physical function in their own home}. In robotics, wearables could simplify video-based learning from demonstration. \begin{figure}[t] \begin{center} \includegraphics[width=\linewidth]{intro.png} \end{center}\vspace*{-1.8in} \caption{Inter-person interactions are common in daily activity \KG{and offer rich signals for perception. Our work considers how interactions viewed from a first-person wearable camera can facilitate egocentric 3D body pose estimation.}} \vspace{-0.1in} \label{fig:concept} \label{fig:onecol} \end{figure} In all such cases and many more, the camera receives a first-person or ``egocentric" perspective of the surrounding visual world. A vision system analyzing the egocentric video stream should not only extract high-level information about the visible surroundings (object, scenes, events), but also the current state of the person wearing the camera. In particular, the \emph{body pose} of the camera wearer is of great interest, since it reveals his/her physical activity, postures, and gestures. Unfortunately, the camera wearer's body is often largely out of the camera's field of view. While this makes state-of-the-art third-person pose methods poorly suited~\cite{ref44,ref38,ref40,ref36,ref39,ref28}, recent work suggests that an ego-video stream nonetheless offers implicit cues for first-person body pose~\cite{ref1,ref17,kitani-iccv2019}. However, prior work restricts the task to static environments devoid of inter-person interactions, forcing the algorithms to rely on low-level cues like apparent camera motion or coarse scene layout. Our idea is to facilitate the recovery of 3D body pose for the camera wearer (or ``ego-pose" for short) by paying attention to the \emph{interactions} between the first and second person as observed in a first-person video stream.\footnote{\cctwo{Throughout,} we use ``second person" to refer to the person the camera wearer is \cctwo{currently} interacting with; if the wearer is ``I", the interactee \cctwo{or partner in the interaction} is ``you".} Inter-person interactions are extremely common and occupy a large part of any individual's day-to-day activities. As is well-known in cognitive science~\cite{ramirez2011modeling, vinciarelli2012nonverbal, bernieri1988synchrony}, human body pose is \cctwo{largely} influenced by an inherent synchronization between interacting individuals. For instance, a person who sees someone reaching out their hand for a handshake will most likely respond by also reaching out \cctwo{their hand}; a person animatedly gesturing while telling a story may see their interacting partner nod in response; \cctwo{children playing may interact closely with their body motions.} See Figure~\ref{fig:concept}. To that end, we introduce ``You2Me": an approach for ego-pose estimation that explicitly captures the interplay between the first and second person body poses. Our model uses a recurrent neural network to incorporate cues from the \emph{observed} second-person pose together with the camera motion and scene appearance to infer the \emph{latent} ego-pose across an entire video sequence. See Figure~\ref{fig:concept2}. \ENtwo{To our knowledge, no prior work models interactions for ego-pose. \K{Our} key contribution is to leverage the action-reaction dynamics in dyadic interactions to estimate \KGthree{ego-pose} from a monocular wearable video camera.} \begin{figure}[t] \begin{center} \includegraphics[width=\linewidth]{concept.png} \end{center}\vspace*{-0.80in} \caption{Our goal is to infer the full 3D body pose sequence of a person from their egocentric video captured by a single chest-mounted camera. \K{Our model} focuses on interaction dynamics to predict the wearer's pose \K{as a function of the} interactee's pose, which is visible from the ego-view. The figure shows the input video with the interactee's (second-person) pose highlighted, and the output 3D joint predictions of the wearer's pose with corresponding pictures of the camera wearer. Note that our approach sees only the egocentric video (top); it does not see the bottom row of images showing the ``first person" behind the camera.} \vspace*{-0.1in} \label{fig:concept2} \label{fig:onecol} \end{figure} We validate our You2Me ego-pose approach on two forms of ground-truth capture---from Kinect sensors and a Panoptic Studio \EN{\cite{ref75}}---on video data spanning \EN{10} subjects and several interaction domains (conversation, sports, hand games, and ball tossing). Our results demonstrate that even though the first-person's body is largely out of view, the inferred second-person pose provides a useful prior on likely interactions, significantly boosting the estimates possible \K{from} camera motion and scene context alone. \cctwo{Furthermore, our} You2Me \cctwo{approach} outperforms the state-of-the-art \cctwo{approach} for ego-pose as well as a current standard deep third-person pose method when adapted to our setting. \vspace*{-0.05in} \section{Related work} \paragraph{Third-person body pose and interactions} There is extensive literature on human body pose estimation from the \KG{traditional} third-person viewpoint, where the person is entirely visible~\ENtwo{\cite{ref42, rogez2017lcr, xiaohan2015joint, cheron2015p}}. Recent approaches \KG{explore novel CNN-based methods,} which have substantially improved the detection of \emph{visible} body poses in images and video~\ENtwo{\cite{ref28, ref32, ref33, ref35, ref36, ref39, ref43, ref40, liu2019skeleton, lin2017recognizing, lao2018rolling}}. \KG{Our approach instead estimates the largely ``invisible" first-person pose.} Multi-person pose tracking investigates structure in human motion and inter-person interactions to limit potential pose trajectories~\cite{ref23, ref28}. \KG{Beyond body pose,} there is a growing interest in modeling human-human interactions \EN{\cite{ref64, huang2014action, morency2010modeling}} to predict pedestrian trajectories \cite{ref51, ref52, ref54}, analyze social behavior and group activities \cite{ref52, ref53, ref61, ref62,huang2014action}, and understand human-object interactions \cite{ref59, ref63,hico}. \KG{Our method also capitalizes on the structure in inter-person interactions.} However, whereas these existing methods assume that all people are fully within view of the camera, our approach addresses interactions between \KG{an individual in-view and an individual \emph{out-of-view}, i.e., the camera wearer.} \vspace*{-0.15in} \paragraph{Egocentric video} Recent egocentric vision work focuses primarily on recognizing objects \cite{ref3}, activities~\cite{ref2,fathi-activity-2011,mccandless,ref9,ref11,ref12,ref14,ref73,ref65}, \KG{visible} hand and arm pose \cite{ref7,ref18,ref19,rogez-upperbody-2015,rhodin2016egocap}, \KG{eye gaze~\cite{ref13}, or anticipating future camera trajectories~\cite{hyun-soo-park-cvpr2016,ref74}.} \KG{In contrast, we explore 3D pose estimation for the camera wearer's full body, and unlike any of the above, we show that the inferred body pose of another individual directly benefits the pose estimates. } \vspace*{-0.15in} \paragraph{First-person body pose from video} Egocentric 3D full body pose estimation has received only limited attention~\cite{ref1,ref15,ref17}. \KG{The first attempt to the problem is the geometry-based} ``inside-out mocap" approach~\cite{ref15}, which uses structure from motion (SfM) to reconstruct the 3D location of 16 body mounted cameras placed on a person's joints. \KG{In contrast, we propose a learning-based solution, and it requires only a single chest-mounted camera, which makes it more suitable and comfortable for daily activity.} \K{Limited recent work extracts ego-pose from} monocular first-person video~\cite{ref1,ref17}. The method in~\cite{ref1} infers the poses of a camera wearer by \K{optimizing} an implicit motion graph \K{with} an array of \K{hand-crafted} cost functions, \cctwo{including a sit/stand classifier}. \K{In contrast}, we propose an end-to-end learning method, \cctwo{which learns from the full visual frame.} The method in~\cite{ref17} uses a humanoid simulator in a control-based approach to recover the sequence of actions affecting pose, \KG{and is evaluated quantitatively only on synthetic sequences.} Whereas both prior learning-based methods focus on sweeping motions that induce notable camera movements (like bending, sitting, walking , our approach improves the prediction of upper-body joint locations during sequences when the camera \KGthree{has only subtle motions} (like handshakes and other conversational gestures). \KG{Furthermore, unlike~\cite{ref17}, our method does not require a simulator and does all its learning directly from video \cctwo{accompanied by ground truth ego-poses.}} \KG{Most importantly, unlike any of the existing methods~\cite{ref1,ref15,ref17}, our approach} discovers the connection between the dynamics in inter-person interactions and egocentric body poses. \vspace*{-0.1in} \paragraph{Social signals in first-person video} \KG{Being person-centric by definition, first-person video is naturally a rich source of social information. Prior work exploring social signals focuses} on detecting social groups \cite{ref66, ref67, ref70} and \KG{mutual} gaze \cite{ref68, ref69} or shared gaze~\cite{social-saliency} from ego-video. \KG{More relevant to our work}, the activity recognition method of~\cite{ref65} uses paired egocentric videos to learn gestures and micro-actions in dyadic interactions. That approach captures the correlations among inter-person actions (\eg, pointing, passing \K{item}) in two synchronized video clips to better classify them. \KG{However, whereas~\cite{ref65} requires} two egocentric videos at test time, our approach relies only on a single ego-video. While eliminating the second camera \KG{introduces new technical challenges} (since we cannot view both the action and response), it offers greater \K{flexibility}. Furthermore, we infer body pose, whereas~\cite{ref65} classifies \K{actions.} \section{Our approach} \KG{The goal is to take a single first-person video as input, and estimate the camera wearer's 3D body pose sequence as output. Our main insight is to leverage not only the appearance and motion evident in the first-person video, but also an estimate of the second-person's body poses.} In this section, we present \KGCR{a} model that uses first- and \KG{second}-person features---both extracted from monocular egocentric video---to predict the 3D joints of the camera wearer. \KG{We first define the pose encoding (Sec~\ref{sec:problem}) \KGCR{and the} three inputs to our network (Sec~\ref{sec:feat1} to~\ref{sec:feat3}), followed by the recurrent long short-term memory (LSTM) network that uses them to make \KGCR{pose} predictions for a video (Sec~\ref{sec:lstm}).} \vspace*{-0.05in} \subsection{Problem formulation}\label{sec:problem} \vspace*{-0.025in} Given \EN{$N$ video frames} from a chest-mounted camera, we estimate a \EN{corresponding } sequence of \EN{$N$} 3D human poses. \KG{Each output pose} \EN{ $p_t \in \mathbb {R}^{3J}$} {is a stick figure skeleton of 3D points consisting of \KG{$J$} joint positions for the predicted body pose of the camera wearer at frame $t$.} Note that our goal is to infer \K{articulated} pose \KG{as opposed to} \K{recognizing an} \KGCR{action.} Each predicted 3D body joint is positioned in a person-centric coordinate system with its origin at the \EN{camera on the wearer's chest}. The first axis is parallel to the ground and points towards the direction in which the wearer is facing. The second axis is parallel to the ground and lies along the same plane as the shoulder line. The third axis is perpendicular to the ground plane. \KG{To account for people of varying sizes,} we normalize each skeleton for scale based on the shoulder width of the individual. \subsection{Dynamic first-person motion features}\label{sec:feat1} \KG{Motion patterns observed from a first-person camera offer a strong scene-independent cue about the camera wearer's body articulations, despite the limbs themselves largely being out of the field of view.} For example, a sudden drop in elevation can indicate movement towards a sitting posture, or a counterclockwise rotation can indicate shoulders tilting to the left. To capture these patterns, we construct scene-invariant dynamic features by extracting a sequence of homographies between each successive video frame, following~\cite{ref1}. While a homography is only strictly scene invariant when the camera is purely rotating, the egocentric camera translates very little between successive frames when the frame rate is high. These homographies facilitate generalization to novel environments, since the motion signals are \KGtwo{independent of the exact appearance of the scene.} \EN{We estimate the homography from flow correspondences by solving a homogeneous linear equation via SVD~\cite{hartley2003multiple}.} Each element in the resulting \EN{$3 \times 3$} homography matrix is then normalized by the top-left corner element. The stack of normalized homographies over a given duration is used to represent the global camera movement within the interval. For frame $f_t$ at timestep $t$ in a given video, the motion representation is constructed by calculating the homographies between successive frames within the interval $[f_{t-15}, f_t]$. We then vectorize the homographies and combine them into a \EN{$m_t \in \mathbb {R}^{135}$ vector,} which represents a half-second interval of camera movements preceding frame $f_t$ \KG{(for 30 fps video)}. \subsection{Static first-person scene features}\label{sec:feat2} While the dynamic features reveal important \KG{cues} for sweeping actions that induce notable camera movements, such as running \K{or} sitting, they are more ambiguous for sequences with little motion in the egocentric video. To account for this, \KG{our second feature attends to the appearance of the surrounding scene.} In everyday life, many static scene structures are heavily associated with certain poses. For example, if the camera wearer leans forward to touch his/her toes, the egocentric camera may see the floor; \cctwo{if the camera wearer stands while looking at a computer monitor, the egocentric camera will see a different image than if the camera wearer sits while looking at the same monitor.} \KG{As with the dynamic features above, the surrounding scene provides cues about ego-pose without the camera wearer's body being visible.} To obtain static first-person scene features, we use a ResNet-152 model pre-trained on ImageNet. Dropping the last fully connected layer on the pre-trained model, we treat the rest of the ResNet-152 as a fixed feature extractor for video frames. Given frame $f_t$, we run the image through the modified ResNet-152, which outputs \EN{$ s_t \in \mathbb {R}^{2048}$.} \KG{Whereas the ego-pose method of~\cite{ref1} relies on a standing vs.~sitting image classifier to capture static context, we find our full visual encoding of the scene contributes to more accurate pose learning.} \KG{Note that this feature by default also captures elements of the second-person pose; however, without extracting the pose explicitly it would be much more data inefficient to learn it simply from ResNet features, as we will see in results.} \begin{figure}[t] \begin{center} \includegraphics[width=\linewidth]{features2.png} \end{center}\vspace*{-0.55in} \caption{Visualization of features extracted from ego-video frames. The ResNet Grad-CAM~\cite{selvaraju2017grad} heatmaps suggest that when a person is further away, the focus is on static objects in the room (couch, bike, wall rug) \KGtwo{which help capture coarse posture}, but when the interactee is closer, the focus is more on the person, \KGtwo{which influences finer details}. While the flow/homography does especially well capturing motion from the camera wearer's hands, many sequences lack global motion and produce flows similar to the bottom row example. OpenPose~\cite{ref28} generates a 2D representation of the interactee's pose even with slight occlusions.} \vspace*{-0.05in} \label{fig:features} \label{fig:onecol} \end{figure} \subsection{Second-person body pose interaction features}\label{sec:feat3} \KG{Our third and most important input consists of the ``second-person" pose of the person with whom the camera wearer is interacting.} Whereas both the dynamic and static features help capture poses that come from larger common actions, we propose to incorporate second-person pose to explicitly account for the \emph{interaction dynamics} that influence gestures and micro-actions \KG{performed in sequence between two people engaged in an interaction.} In human-human interactions, there is a great deal of symbiosis between both actors. Specific actions \KGCR{elicit} certain reactions, which in turn influence the body pose of the individual. For example, if we see an individual windup to throw a ball, our natural response is to raise our arms to catch the ball. \KG{Or more subtly, if we see a person turn to look at a passerby, we may turn to follow their gaze.} By understanding this dynamic, we can gather important ego-pose information for the camera wearer by simply observing the visible pose of the person with whom he/she interacts. Thus, \KG{our third feature records the} interactee's inferred pose. Still using the egocentric video, we estimate the pose of the interactee in each frame. \KGtwo{Here we can leverage recent} successes for pose estimation from a third-person perspective: \KG{unlike the camera wearer, the second person \emph{is} visible, i.e., the ego-camera footage gives a third-person view of the interactee.} \KG We use OpenPose~\cite{ref28} to infer interactee poses due to its efficiency and accuracy, though other third-person methods can also be employed.} OpenPose provides real-time multi-person keypoint detection: given a stack of frames, it returns a corresponding stack of \ENtwo{normalized} 25 2D keypoint joint estimations \ENtwo{(see Supp.~file)}. For each frame $f_t$, we flatten the output 25 keypoint estimates into a vector \EN{$o_t \in \mathbb {R}^{50}$} \KGtwo{(denoted $o_t$ for ``other").} \K{We set missing or occluded joints in $o_t$ to zeros, which can provide its own signal about the wearer's proximity to the interactee (e.g., no legs visible when he/she is closer).} Note that our learning approach \KGtwo{is flexible to the exact encodings of the ego- and second-person poses.} \ENtwo \K{Using normalized} 2D keypoints for the second-person pose \K{is compatible} \K{with using} person-centric 3D coordinates for the ego-pose (\K{cf.~Sec.~\ref{sec:problem}}); \K{whereas it would be problematic for a purely geometric method relying on spatial registration, for a learning-based approach mixing 2D and 3D in this way is consistent.} \K{Furthermore, while perfect 3D second-person poses would offer the most complete information, e.g., avoiding foreshortening,} we find that state-of-the-art 3D methods \cite{kanazawa2018end, xiang2019monocular, ref33} fail on our data due to extensive occlusions from the wearer's hands.} \K{See Sec.~\ref{sec:results} for experiments that concretely justify this design choice.} \KGtwo{Figure~\ref{fig:features} illustrates the complete set of \KGCR{features.}} \begin{figure*} \begin{center} \includegraphics[width=0.9\linewidth]{approach2.png} \vspace*{-0.20in} \end{center} \caption{Network architecture for our You2Me approach. (a) For each video frame, we extract three features. ResNet provides static visual cues about the scene. \KGtwo{Stacked homographies for the past 15 frames provide motion cues for the ego-camera.} Finally, we extract the \KG{inferred} 2D pose of the visible interactee with OpenPose~\cite{ref28}. All three \KG{features} are concatenated ($\oplus$) and fed into the LSTM. (b) illustrates our LSTM, which takes as input the feature vector from (a) and an embedding of the camera wearer's pose \KG{estimated from the previous frame}. Outputs from the LSTM produce ego-pose predictions, \KG{assigning one of the \K{fine-grained} quantized body poses to each frame.}} \label{fig:approach} \end{figure*} \subsection{Recurrent neural network for pose inference}\label{sec:lstm} \KG{All three video-based cues defined above serve as input to a recurrent neural network to perform pose estimation for the full sequence.} \KG{In particular, we define a Long Short-Term Memory (LSTM) network~\cite{graves2013generating, graves2014towards} for our task.} The LSTM learns the current state of the camera wearer\KG{, scene, and interactee,} and uses this \KG{encoding} to \KGthree{infer} the \KG{camera wearer's} \KGthree{next} poses. The LSTM's hidden state captures the sequential patterns of linked body poses that result from inter-person back-and-forth responses. \KG{While the LSTM can be trained to perform regression on the real-valued coordinates of the body pose, we found a \K{fine-grained} classification task to train more robustly, as often reported in the literature (\K{see} last row of Table \ref{tab:1}). Hence, we first quantize the space of training body poses into a large number of fine-grained poses using $K$-means \K{(details below)}. Now the task is to map to the closest possible quantized pose at each time step.} \EN{Given a hidden state dimension of $D$,} the hidden state \EN{vector $h_t \in \mathbb{R}^{D}$} of the LSTM at time $t$ captures the \KG{cumulative} latent representation of the camera wearer's pose at that instant in the video. For each frame $f_t$, we extract the \EN{homography matrix $m_t$,} the \EN{ResNet-152 scene feature vector $s_t$}, and the \EN{second-person joint position vector $o_t$}. \KGtwo{To provide a more compact representation of the scene to the LSTM (useful to conserve GPU memory), we project $s_t$ to a lower-dimensional embedding $x_t \in \mathbb{R}^E$:} \begin{equation} x_t = \phi_x(s_t; W_x), \end{equation} where $W_x$ \EN{is of size $E \times 2048$ and} consists of the embedding weights for $\phi_x(.)$. The embedding is then passed through a batch normalization layer. \EN{The LSTM uses the wearer's pose in the previous frame $p_{t-1}$ as input for the current frame. Let $p_{t-1}$ be a $K$-dimensional one-hot vector indicating the pose for the camera wearer at the previous frame $t-1$ \KGCR{(initialized at $t=0$ as the average training pose)}.} We learn a linear embedding for the pose indicator to map it to vector $z_t$: \begin{equation}\label{pose_embed} z_t = \phi_z(\EN{p_{t-1}}; W_z), \end{equation} where $W_z$ \EN{is of size $E \times K$ and} consists of the learned embedding weights for $\phi_z(.)$. \KG{All the features} are concatenated (indicated by \KGthree{the} operation $\oplus$) into a single vector $b_t \EN{\in \mathbb {R}^{135+ 50+ 2E}}$: \begin{equation} b_t = m_t \oplus o_t \oplus x_t \oplus z_t, \end{equation} which is then used as input to the LSTM cell for the corresponding prediction at time $t$. This introduces the following recurrence for the hidden state vector: \begin{equation}\label{recursion} \begin{aligned} h_t &= \text{LSTM}(h_{t-1}, b_t; \theta_l), \end{aligned} \end{equation} \EN{where $\theta_l$ denotes the LSTM parameters.} We define the loss for the network as the cross entropy loss across an entire sequence \KG{for predicting the correct (quantized) pose in each frame}. Specifically, the loss $\mathcal{L}$ for a video of length \EN{$N$} is \begin{equation}\label{loss} \mathcal{L}(W_x, W_z, W_p, \theta_l) = \EN{ -\sum_t^N \log( \sigma_{P}(W_p h_t))}, \end{equation} \KG{where $\sigma_{P}(\cdot)$ is the softmax probability of the correct pose ``class", and $W_p$ is the linear classifier layer of dimension $K \times D$.} Recall that the quantization is fine-grained, such that \K{each per-frame} estimate is quite specific; on average the nearest quantized pose \cctwo{in the codebook} is just \ENquant{0.27} cm away per joint (see Supp.~file). \KG{The inferred pose ID at time $t$ (i.e., the $\argmax$ over the pose posteriors at that timestep) is taken as the input for $z_{t+1}$ for the subsequent frame.} \K{Rather than uniformly \KG{quantize} all $J$ joints, we perform a mixed granularity clustering to account for the more subtle pose changes concentrated on the upper body.} \K{L}ower body poses across frames \K{exhibit less variance}, but upper body poses have more fine-grained important differences (\K{e.g., from arm gestures}). \ENquant{Hence, we use a sparser $K$-means clustering ($K_{bot}=100$) for the lower body joints and denser ($K_{upp}=700$) for the upper body. Any given pose is thus coded in terms of a 2D cluster ID. } At test time, we use the trained LSTM to predict the \ENtwo{pose sequence.} \EN{From time $t-1$ to $t$, we use the predicted cluster $\hat{p}_{t-1}$ from the previous LSTM cell in Eq. \ref{pose_embed}.} \KGtwo{Figure~\ref{fig:approach} overviews the model; see Supp.~for architecture details.} \section{\KG{You2Me Video Datasets}} We present a first-person interaction dataset consisting of \EN{42} two-minute sequences from one-on-one interactions between 10 individuals. We ask each individual (in turn) to wear a chest mounted GoPro camera and perform various interactive activities with another individual. We collect their egocentric video then synchronize it with the body-pose ground truth for both the camera wearer and the individual standing in front of the camera. The dataset captures four classes of activities: \emph{hand games}, \emph{tossing and catching}, \emph{sports}, and \emph{conversation}. The classes are broad enough such that intra-class variation exists. For example, the sports category contains instances of (reenacted) basketball, tennis, boxing, etc.; \KG{the conversation category contains} \EN{individuals playing charades, selling a product, negotiating, etc.} \KGtwo{In about 50\% of the frames, no first-person body parts are visible.} \cc{To ensure that our approach is generalizable,} we employ two methods of capture, as detailed next. \vspace*{-0.15in} \paragraph{Panoptic Studio capture} \KG{Our first capture mode uses a Panoptic Studio dome, following~\cite{ref75}.} The studio capture consists of \EN{14} sequences recorded in $1920 \times 1080$ resolution at 30 fps using the GoPro Hero3 chest mounted camera on the medium field of view setting. The \KG{ground truth} skeletons of the camera wearer and the \K{interactee} are then reconstructed at 30 fps, matching the \K{ego-video} frame rate. Each skeleton is parameterized by $J=19$ 3D joint positions obtained using the method of~\cite{ref75}. \KG{Capturing video in the dome offers extremely accurate ground truth, at the expense of a more constrained background environment.} A total of six participants of different height, body shape, and gender enacted sequences from each of the four activity classes. \vspace*{-0.15in} \paragraph{Kinect capture} \KG{Our second capture mode uses Kinect sensors for ground truth poses.} The Kinect capture consists of \EN{28} sequences also recorded in $1920 \EN{\times} 1080$ resolution at 30 fps. We use the GoPro Hero4 chest mounted camera on wide field of view setting. Both people's ground truth skeleton poses are captured at 30 fps using the Kinect V2 sensor. The pose is represented by $J=25$ 3D joint positions defined in the MS Kinect SDK. Given the greater mobility of the Kinect in contrast to the Panoptic Studio, we ask four participants to enact sequences from each of the activity classes in various places such as offices, labs, and apartment rooms. The videos from this dataset are taken in unconstrained environments but are all indoors due to limitations of the Kinect V2 sensor. \KG{While Kinect-sensed ground truth poses are noisier than those captured in the Panoptic Studio, prior work demonstrates that overall the Kinect poses are well aligned with human judgment of pose~\cite{ref1}.} \vspace*{0.05in} We stress that our method uses \emph{only the egocentric camera video as input} at test time for both datasets. Further, we emphasize that \KG{no existing dataset is suitable for our task.} Existing pose detection and tracking datasets (\eg, \cite{ref71, ref72}) are captured in the third-person viewpoint. \KG{Existing egocentric datasets are either limited to visible hands and arms~\cite{ref19,ref2}, contain only single-person sequences~\cite{ref1,ref71,ref72}, consist of synthetic test data~\cite{ref17}, or lack body-pose joint labels~\cite{ref65}.} \KG{All our data \KGCR{is} publicly available.\footnote{\KGCR{\texttt{http://vision.cs.utexas.edu/projects/you2me/}}} See Supp video for examples.} \section{Experiments}\label{sec:results} We evaluate our approach on both the Panoptic Studio and Kinect captures. Our method is trained and tested in \KGthree{an} activity-agnostic setting: the training and test sets are split such that each set contains roughly an equal number of sequences from each activity domain (conversation, sports, etc.). For the Panoptic Studio, we train on \EN{7} sequences and test on \EN{7}. For the Kinect set, we train on \EN{18} sequences and test on \EN{10} that are recorded at locations not seen in the training set. For both, we ensure that the people appearing in test clips do \emph{not} appear in the training set. \vspace*{-0.1in} \paragraph{Implementation details} We generate training data by creating sliding windows of size 512 frames with an overlap of 32 frames for each sequence in the training set. \KGCR{This yields 3.2K training sequences and 2.3K test sequences.} For the LSTM, we use an embedding dimension of \KGtwo{$E=256$}, fixed hidden state dimension of \KGtwo{$D=512$}, and batch size of 32. Learning rate is 0.001 for the first 10 epochs then decreased to 0.0001. \ENquant{In initial experiments, we found results relatively insensitive to values of $K_{upp}$ from 500 to 900 and $K_{bot}$ from 70 to 120, and fixed $K_{upp}=700$ and $K_{bot}=100$ for all results. \KGCR{Training time is 18 hours on a single GPU for 20 epochs; test time is 36 fps.} See Supp.} \vspace*{-0.1in} \paragraph{Baselines} \KG{We compare to the following methods:} \vspace*{-0.08in} \begin{itemize}[leftmargin=*] \item {\textbf Ego-pose motion graph (\emph{MotionGraph})~\cite{ref1}}: the current state-of-the art method for predicting body pose from real egocentric video~\cite{ref1}. We use the \KG{authors' code}\footnote{\texttt{http://www.hao-jiang.net/code/egopose/ego\_pose\_code.tar.gz}} and retrain their model on our dataset. \KG{This method also outputs quantized poses; }\ENthree{we find their method performs best on our data for $K=500$.} \vspace*{-0.08in} \item {\textbf{Third-person pose deconv network (\emph{DeconvNet})~\cite{ref44}}}: We adapt the human pose estimation baseline of~\cite{ref44} to our task.\footnote{\texttt{https://github.com/leoxiaobin/pose.pytorch}} Their approach adds deconvolutional layers to ResNet, and \KG{achieves the state-of-the-art on the 2017 COCO keypoint challenge.} We use the same network structure \cctwo{presented in the baseline}, but retrain it on our egocentric dataset\ENtwo{, altering the output space for 3D joints.} \KG{While this network is intended for detecting visible poses in third-person images, it is useful to gauge how well an extremely effective off-the-shelf deep pose method can learn from ego-video.} \vspace*{-0.08in} \item {\textbf{Ours without pose information (\emph{Ours w/o $o_t$})}}: This is a simplified version of our model in which we do not feed the second-person \KG{2D} joints to the LSTM. \cctwo{The remaining network is unchanged and takes as input the extracted image features and homographies.} \KG{This ablation isolates the impact of modeling interactee poses versus all remaining design choices in our method.} \vspace*{-0.08in} \item \textbf{Always standing (\emph{Stand})}} and {\textbf{Always sitting (\emph{Sit})}}: a simple guessing method (stronger than a truly random guess) that exploits the prior that most poses are somewhere near a standing or a sitting pose. The standing and sitting poses \KG{are} averaged over the training sequences. \end{itemize} \vspace*{-0.2in} \paragraph{Evaluation metric} We rotate each skeleton so the shoulder is parallel to the yz plane and the body center is at the origin, then calculate error as the Euclidean distance between the predicted 3D joints and the ground truth, \KGtwo{averaged over the sequence and scaled to centimeters (cm) based on a reference shoulder distance of 30 cm.} \KG{Note that \K{we judge accuracy against the exact \emph{continuous ground truth} poses \ENthree{---\emph{not} whether we \KGthree{infer} the right pose cluster}. While the predicted joints are a cluster center, the quantization is so fine-grained that on average the best discrete pose is only 0.70 cm from the continuous pose.}} \begin{table}[t] \begin{center}\footnotesize \begin{tabular}{|l||c|c|c||c|c|c|} \hline & \multicolumn{3}{|c||}{Kinect} & \multicolumn{3}{c|}{Panoptic} \\ \hline & \KG{Upp} & Bot & All & \KG{Upp} & Bot & All \\ \hline\hline Ours & {\bf 15.3} & {\bf 12.9} & {\bf 14.3} & {\bf 6.5} & {\bf 12.0} & {\bf 8.6} \\ Ours w/o $o_t$ & 19.4 & 15.6 & 18.0 & 11.2 & 15.4 & 12.8 \\ MotionGraph~\cite{ref1} & 24.4 & 15.7 & 21.2 & 11.9 & 20.7 & 15.2 \\ DeconvNet~\cite{ref44} & 26.0 & 20.3 & 23.3 & 18.3 & 21.2 & 19.4 \\ Stand & 27.8 & 23.1 & 25.4 & 10.6 & 18.5 & 13.5 \\ Sit & 21.8 & 43.3 & 28.5 & 17.3 & 28.9 & 21.6 \\ \ENtwo{Ours as Regression} & 22.9 & 20.0 & 20.9 & 12.3 & 16.8 & 14.6 \\ \hline \end{tabular} \end{center} \vspace*{-0.1in} \caption{\EN{Average joint e}rror (cm) for all methods on the two dataset captures. Our approach is stronger than the existing methods, and the second-person pose is crucial to its performance.} \label{tab:1} \end{table} \begin{figure}[t] \begin{center} \includegraphics[width=\linewidth]{priors2.png} \end{center}\vspace*{-1.48in} \caption Most common second-person 2D poses (top) seen immediately preceding a given predicted 3D pose cluster (bottom) for test sequences. You2Me captures useful interaction links like mutual reaches or tied conversation gestures. } \label{fig:priors} \label{fig:onecol} \end{figure} \begin{figure*} \begin{center} \includegraphics[width=0.8\linewidth]{success2.png} \end{center}\vspace*{-1.95in} \caption{\KG{Example inferred poses for} three different activity domains trained in a domain-agnostic setting. Row 1: ego-video view with OpenPose overlay \KG{(input to our method} is only the raw frame). Row 2: 3D ground truth poses \EN{in multicolor}, displayed as interacting with the 2D OpenPose skeletons in yellow. Note: for ease of viewing, we show them side by side. Row 3: results from our approach. Row 4: MotionGraph~\cite{ref1} results. In the last column, the interactee is fully occluded in the ego-view, but our predicted pose is still accurate. } \label{fig:success} \label{fig:onecol} \end{figure*} \begin{figure}[t] \begin{center} \includegraphics[width=\linewidth]{failure2.png} \end{center}\vspace*{-1.13in} \caption{Example failure cases. Typical failure cases are when the ego-view points at the ground or at feet, lacking the interactee's pose for a long duration. } \label{fig:failure} \label{fig:onecol} \end{figure} \vspace*{-0.1in} \paragraph{Results} Table \ref{tab:1} shows that the proposed method consistently gives better results than all of the competing methods. \KGtwo{We show errors averaged over all $J$ joints, and separately for the upper body joints which have the highest variance in everyday activity (head, elbow, wrists, hands) and the lower body joints (hips, knees, ankles, foot).} \ENtwo{See Supp.~file for \K{per-}joint errors.} Our approach outperforms {\bf MotionGraph}~\cite{ref1} and {\bf Ours w/o $o_t$.} \KG{This result supports our key technical novelty of modeling mutual pose interactions between the first and second person.} \KG{Our method's} improvement is even more significant in the upper body joints, \KG{which agrees with the fact that the most highly correlated inter-person poses occur with gestural motions of the head and arms.} The results show that the information provided by the pose of the interactee is essential for deriving \KG{accurate} body pose estimates for the camera wearer. We find our method's impact is greatest on conversation sequences, and lowest on sports sequences \ENtwo{(see Supp.~file).} This suggests that during conversation sequences which involve less global motion, second-person pose provides essential information for more accurate upper body ego-pose predictions. In sports sequences, on the other hand, the interactee often moves out of view for long periods, explaining our method's lower degree of impact for sports. While {\bf Sit} and {\bf Stand} offer a reasonable prior for most test frames, our method still makes significant gains on them, showing the ability to make more informed estimates on the limbs \ENquant{(e.g., 10 cm better on average} for the upper body keypoints). \ENtwo{{\bf Stand} outperforms \K{other} baselines \K{but not our method}. This is a well-known issue in motion forecasting: \cctwo{doing ``nothing" \K{can be} better than doing something, since} the average standing pose is in-between many test poses, representing a ``safe" estimate~\cite{martinez2017simple}. } Our method also outperforms {\bf DeconvNet}~\cite{ref44}, which suggests that approaches for detecting poses from a third-person point of view \KG{do not easily adapt to handle the first-person pose task.} \K{Replacing our model's classification objective with regression is significantly weaker, supporting our design choice (see last row Table~\ref{tab:1}).} \KGtwo{Figure~\ref{fig:priors} shows examples of the linked poses our method benefits from. We display the second-person pose estimates immediately preceding various ego-pose estimates for cases where our method improves over the \textbf{Ours w/o $o_t$} baseline. Intuitively, gains happen for interactions with good body language links, such as mutually extending hands or smaller conversational gestures.} Figures~\ref{fig:success} and~\ref{fig:failure} show example success and failure cases for our approach, respectively. In Figure~\ref{fig:success}, our method outperforms \textbf{MotionGraph}~\cite{ref1} in predicting upper body movements of the camera wearer, e.g., better capturing the swing of an arm before catching a ball or reaching out to grab an object during a conversation. The failures in Figure~\ref{fig:failure} show the importance of the second-person pose to our approach. Analyzing the frames with the highest errors, we find failure cases occur primarily when the camera wearer is crouched over, the camera is pointed towards the floor, or the view of the interactee is obstructed. While our \KGthree{model} has enough priors to continue to accurately predict poses for a few frames without the interactee pose, absent second person poses over extended periods are detrimental. \begin{table} \begin{center}\footnotesize \begin{tabular}{|l||c|c|c||c|c|c|} \hline & \multicolumn{3}{|c||}{Kinect} & \multicolumn{3}{c|}{Panoptic} \\ \hline & Upp & Bot & All & Upp & Bot & All \\ \hline\hline Ours & {\bf 15.3} & {\bf 12.9} & {\bf 14.3} & {\bf 6.5} & {\bf 12.0} & {\bf 8.6} \\ w/o $x_t$ & 16.1 & 13.8 & 15.3 & 7.0 & 13.3 & 9.4 \\ w/o $o_t$ & 19.4 & 15.6 & 18.0 & 11.2 & 15.4 & 12.8 \\ w/o both & 20.0 & 16.9 & 18.8 & 10.2 & 15.3 & 12.1 \\ \hline \end{tabular} \end{center}\vspace*{-0.1in} \caption{Ablation study \EN{to gauge the importance of the second-person pose features $o_t$ and scene features $x_t$.} Error in cm.}\label{tab:2} \end{table} Table \ref{tab:2} shows an ablation study, where we add or remove features from our \KGthree{model} to quantify the impact of the second-person pose. \EN{Recall that $o_t$ is the second-person pose and $x_t$ is the ResNet scene feature.} The results indicate that \textbf{Ours} and the \textbf{w/o $x_t$} model, which both use the \KG{second-person pose} (OpenPose estimates), consistently outperform the \textbf{w/o $o_t$} and \textbf{w/o both} models that lack the second-person pose estimate. Moreover, the results show that the addition of $o_t$ most significantly improves upper body predictions. The features of the interactee captured by the ResNet (\textbf{w/o $o_t$}) do not sufficiently capture the information encoded in the explicit pose estimate. \begin{table}[t] \begin{center}\footnotesize \begin{tabular}{|l||c|c|c||c|c|c|} \hline & \multicolumn{3}{|c||}{Kinect} & \multicolumn{3}{c|}{Panoptic} \\ \hline & Upp & Bot & All & Upp & Bot & All \\ \hline\hline $o_t$ & 15.3 & 12.9 & 14.3 & 6.5 & 12.0 & 8.6 \\ GT \K{3D} & {\bf 13.8} & {\bf 12.3} & {\bf 13.2} & {\bf 6.0} & {\bf 8.7} & {\bf 6.9} \\ Still & 20.5 & 15.6 & 18.7 & 11.7 & 16.0 & 13.1 \\ Zero & 21.0 & 16.1 & 19.1 & 11.5 & 16.8 & 13.3 \\ Random & 22.4 & 16.6 & 20.4 & 11.8 & 17.7 & 14.3 \\ \ENtwo{Predicted 3D} & 19.3 & 15.2 & 17.8 & 11.0 & 16.8 & 13.0 \\ \hline \end{tabular} \end{center} \vspace*{-0.1in} \caption{Effects of second-person pose source. Error in cm.}\label{tab:3} \end{table} Table~\ref{tab:3} analyzes \K{how the source of} the second-person pose estimates affects our results. First, we substitute in for $o_t$ the \K{3D} ground truth (GT) skeleton of the interactee, i.e., the true pose for the second person as given by the Panoptic Studio or Kinect. We see that more accurate second-person poses can further improve results, \cctwo{though the margins are smaller than those separating our method from the baselines.} \K{Using 2D OpenPose for $o_t$ is better than using predicted 3D poses~\cite{ref33};} 3D pose from monocular data remains challenging. This justifies our use of 2D for $o_t$. \KGtwo{Next, to confirm our network properly learns a correlative function between the interactee pose and the ego-pose, we feed \emph{incorrect} values for $o_t$: either the average standing pose (Still), empty poses (Zero)}\EN{, or random poses from another sequence of another class (Random).} In all cases, the network produces poorer results, showing that our method is indeed leveraging the true structure in interactions. \K{Please see Supp.~file for videos, per-joint and per-activity error breakdowns, depiction of the fine-grained quantization,} \ENthree{impact of quantization on approach, and additional architecture details.} \section{Conclusions} We presented \EN{the} You2Me approach to predict a camera wearer's pose given video from a single chest-mounted camera. Our key insight is to capture the ties in interaction between the first (unobserved) and second (observed) person poses. Our results on two capture scenarios from several different activity domains demonstrate the promise of our idea, and we obtain state-of-the-art results for ego-pose. \KGtwo{Future work will include reasoning about the absence of second-person poses when interactions are not taking place, extending to sequences with multiple ``second people", and exploring how ego-pose estimates might reciprocate to boost second-person pose estimates.} \noindent\textbf{Acknowledgements:} We thank Hao Jiang for helpful discussions. \KGCR{UT Austin is supported in part by ONR PECASE and NSF IIS-1514118.} {\small \bibliographystyle{ieee}
{'timestamp': '2020-03-31T02:07:14', 'yymm': '1904', 'arxiv_id': '1904.09882', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.09882'}
arxiv
\section{Introduction} The prospect of quantum computers potentially surpassing the computational abilities of classical computers has spawned much interest in studying and building large-scale quantum computers. Since such quantum systems would be very susceptible to disturbances from the environment and to imperfections in the quantum gates acting on the system, the implementation of a working quantum computer requires some form of error-correction. This has led to the study of quantum error-correcting codes, and although such codes are conceptually similar to their classical brethren, their construction call for different techniques. Nevertheless, results have been found that link classical codes to quantum ones, suggesting that good quantum codes may be found by considering good classical codes. A well-known class of algebraic geometric codes is the one-point codes from the Hermitian curve. For these one-point Hermitian codes, one of the simplest bounds on the minimal distance is the Goppa bound. For codes of sufficiently large dimension, however, the Goppa bound does not give the true minimal distance, and the order bound for dual codes \cite{handbook,DP10} and for primary codes \cite{GMRT11,AG08,NormTrace} give more information on the minimal distance of the codes. These improved bounds also give rise to a family of improved codes with designed minimal distances, and we shall refer to such codes as \emph{order bound improved} codes. The construction of quantum codes from one-point Hermitian codes has already been considered in \cite{SK06}, and from order bound improved Hermitian codes in \cite{qcHermit}. Neither of these works, however, explore the potential benefit from applying Steane-enlargement to the codes under consideration. Thus, this paper will address this question, and describe the quantum codes that can be obtained in this manner. The work is structured as follows. Section~\ref{sec:preliminaries} contains the preliminary theory on quantum codes and order bound improved Hermitian codes that will be necessary in the subsequent sections. Afterwards, Section~\ref{sec:steaneHermitian} covers the results of applying Steane-enlargement to one-point Hermitian codes and order bound improved Hermitian codes. The parameters of the resulting codes are then compared to those of codes already in the literature in Section~\ref{sec:comp-with-exist}. \section{Preliminaries}\label{sec:preliminaries} In this section, we shall reiterate the necessary definitions and results regarding both quantum error-correcting codes and order bound improved Hermitian codes. For both of these, we will be relying on nested pairs of classical codes, and on the relative distance of such pairs. Thus, recall that for classical, linear codes $\mathcal{C}_2\subsetneq\mathcal{C}_1$, we define the relative distance of the pair as \begin{equation*} d(\mathcal{C}_1,\mathcal{C}_2)=\min\{w_H(\vec{c})\mid\vec{c}\in\mathcal{C}_1\setminus\mathcal{C}_2\}, \end{equation*} where $w_H$ denotes the Hamming weight. \subsection{Quantum codes} A $k$-dimensional quantum code of length $n$ over $\mathbb{F}_q$ is a $q^k$-dimensional subspace of the Hilbert space $\mathbb{C}^{q^n}$. This space is subject to phase-shift errors, bit-flip errors, and combinations thereof. For a quantum code, we define its two minimal distances $d_z$ and $d_x$ as the maximal integers such that the code allows simultaneous detection of any $d_z-1$ phase-shift errors and any $d_x-1$ bit-flip errors. When such a code has length $n$ and dimension $k$, we refer to it as an $[[n,k,d_z/d_x]]_q$-quantum code. The literature contains many works based on the assumption that it is not necessary to distinguish between the two types of errors. Thus, the quantum code is only associated with a single minimal distance. That is, we say that its minimal distance is $d=\min\{d_z,d_x\}$, and the notation for the parameters is presented slightly more compactly as $[[n,k,d]]_q$. In this case, we refer to the quantum code as being \emph{symmetric}, and in the previous case we refer to it as being \emph{asymmetric}. One of the commonly used constructions of quantum codes was provided by Calderbank, Shore, and Steane \cite{CalderbankShor,Steane96}, and relies on a self-orthogonal, classical error-correcting code in order to obtain a quantum stabilizer code. It was later shown that the self-orthogonal code can be replaced by a pair of nested codes, giving asymmetric quantum codes. This generalized CSS-construction is captured in the following theorem found in \cite{SKR09}. \begin{theorem}\label{thm:css} Given $\mathbb{F}_q$-linear codes $\mathcal{C}_2\subsetneq\mathcal{C}_1$ of length $n$ and codimension $\ell$, the CSS-construc\-tion ensures the existence of an asymmetric quantum code with parameters \begin{equation*} [[n,\ell,d_z/d_x]]_q \end{equation*} where $d_z=d(\mathcal{C}_1,\mathcal{C}_2)$ and $d_x=d(\mathcal{C}_2^\perp,\mathcal{C}_1^\perp)$. \end{theorem} \begin{corollary}\label{cor:steaneSelfOrth} If the $[n,k,d]$ linear code $\mathcal{C}\subseteq\mathbb{F}_q^n$ is self-orthogonal, then a \begin{equation*} [[n,2k-n,d]]_q \end{equation*} symmetric quantum code exists. \end{corollary} When the CSS-construction is applied to a self-orthogonal binary linear code as in Corollary~\ref{cor:steaneSelfOrth}, Steane \cite{Steane99} proposed a procedure whereby the dimension of the resulting quantum code may be increased. In the best case, this can be done with little or no decrease in the minimal distance of the quantum code. This procedure -- eponymously named Steane-enlargement in the literature -- has later been generalized to $q$-ary codes as well \cite{Hamada,qArySteane}. \begin{theorem}\label{thm:qArySteane} Consider a linear $[n,k]$ code $\mathcal{C}\subseteq\mathbb{F}_q^n$ that contains its Euclidean dual $\mathcal{C}^\perp$. If $\mathcal{C}'$ is an $[n,k']$ code such that $\mathcal{C}\subsetneq\mathcal{C}'$ and $k'\geq k+2$, then an \begin{equation*} \Big[\Big[n,k+k'-n,\geq \min\big\{d,\big\lceil(1+\textstyle\frac{1}{q})d'\big\rceil\big\}\Big]\Big]_q \end{equation*} quantum code exists with $d=d(\mathcal{C},\mathcal{C}'^\perp)$ and $d'=d(\mathcal{C}',\mathcal{C}'^\perp)$. \end{theorem} When presenting the parameters of a Steane-enlarged code in propositions of this paper, we will often state the dimension in the form $2k-n+(k'-k)$. In this way, we highlight the dimension increase since $2k-n$ is the dimension of the non-enlarged quantum code. \subsection{Order bound improved Hermitian codes} \label{sec:order-bound-improved} Let $P_1,P_2,\ldots,P_{q^3},Q$ be the rational places of the Hermitian function field over $\mathbb{F}_{q^2}$, and define the divisor $D=P_1+P_2+\cdots+P_{q^3}$. Further, denote by $H(Q)$ the Weierstraß semigroup of $Q$. As in \cite{qcHermit,GMRT11}, we consider a special subset of $H(Q)$, namely \begin{equation*} H^\ast(Q)=\{\lambda\in H(Q)\mid C_{\mathcal{L}}(D,\lambda Q)\neq C_{\mathcal{L}}(D,(\lambda-1)Q)\}. \end{equation*} It may be shown that in fact \begin{equation*} H^\ast(Q)=\{iq+j(q+1)\mid 0\leq i<q^2,\; 0\leq j<q\}. \end{equation*} Now, fix an element $f_\lambda\in\mathcal{L}(\lambda Q)\setminus\mathcal{L}((\lambda-1)Q)$ for each $\lambda\in H^\ast(Q)$, and define the map $\sigma\colon H^\ast(Q)\rightarrow\mathbb{N}$ given by \begin{equation*} \sigma(iq+j(q+1))=\begin{cases} q^3-iq-j(q+1) &\text{if } 0\leq i<q^2-q\\ (q^2-i)(q-j) &\text{if } q^2-q\leq i<q^2 \end{cases}. \end{equation*} With this map, it was shown in~\cite{qcHermit} as a special case of \cite{NormTrace} that the improved primary code \begin{equation*} \tilde{E}(\delta)=\{(f_\lambda(P_1),f_\lambda(P_2),\ldots,f_\lambda(P_n))\mid\sigma(\lambda)\geq\delta\} \end{equation*} has minimal distance exactly $\delta$ whenever $\delta\in \sigma(H^\ast(Q))$. To obtain an improved dual code, let $\mu\colon H^\ast(Q)\rightarrow\mathbb{N}$ be given by $\mu(iq+j(q+1))=\sigma((q^2-1-i)q+(q-1-j)(q+1))$. Then, as explained in \cite{qcHermit}, the code \begin{equation*} \tilde{C}(\delta)=\big(\{(f_\lambda(P_1),f_\lambda(P_2),\ldots,f_\lambda(P_n))\mid\mu(\lambda)<\delta\}\big)^\perp \end{equation*} also has minimal distance exactly $\delta$ whenever $\delta\in\mu(H^\ast(Q))=\sigma(H^\ast(Q))$, and in fact $\tilde{E}(\delta)=\tilde{C}(\delta)$. For the order bound to produce an improved code, the designed distance must be sufficiently small. Otherwise, the code $\tilde{E}(\delta)$ simply corresponds to one of the usual one-point Hermitian codes. This correspondence is given in the following result from \cite[Cor.\,4]{qcHermit}. \begin{lemma}\label{lem:improvedEqualUsual} For $\delta>q^2-q$ we have $\tilde{E}(\delta)=C_{\mathcal{L}}(D,(q^3-\delta)Q)$, but the code $C_{\mathcal{L}}(D,(q^3-(q^2-q))Q)$ is strictly contained in $\tilde{E}(q^2-q)$. \end{lemma} For $\delta\leq q^2-q$, the work \cite{qcHermit} contains a lower bound on the dimension of $\tilde{E}(\delta)$. In Proposition~\ref{prop:hermitDimension} below, we give an explicit formula describing the dimension in this case. This formula relies on the number of (number theoretic) divisors of a certain type, as specified in the following definition. \begin{definition} For $n\in\mathbb{Z}_+$, we let $\tau^{(q)}(n)$ denote the number of divisors $d$ of $n$ such that $0\leq d\leq q$ and $n/d\leq q$. \end{definition} From the definition it should be clear that $\tau^{(q)}(n)$ can be computed in $\mathcal{O}(q)$ operations. \begin{proposition}\label{prop:hermitDimension} Let $1\leq\delta\leq q^2$, and write $\delta-1=aq+b$. Then \begin{equation*} \dim(\tilde{E}(\delta))= q^3-q^2 - \frac{a(a-1)}{2} - \min\{a,b\} + \sum_{i=\delta}^{q^2}\tau^{(q)}(i). \end{equation*} \end{proposition} \begin{proof} We give the proof by partitioning $H^\ast(Q)$ in three disjoint sets: \begin{align*} \Lambda_1 &=\{iq+j(q+1)\in H^\ast(Q)\mid i+j< q^2-q,\; 0\leq i<q^2-q,\; 0\leq j<q\}\\ \Lambda_2 &=\{iq+j(q+1)\in H^\ast(Q)\mid i+j\geq q^2-q,\; 0\leq i< q^2-q,\; 0\leq j<q\}\\ \Lambda_3 &=\{iq+j(q+1)\in H^\ast(Q)\mid q^2-q\leq i<q^2,\; 0\leq j<q \}. \end{align*} We first determine the cardinality of $\Lambda_2$. Considering some $iq+j(q+1)\in\Lambda_2$, and writing $i=q^2-q-k$, there are $q-k$ possible values of $j$. There are $q-1$ such integers $k$ since $q^2-2q+1\leq i<q^2-q$ within the set $\Lambda_2$. This implies that \begin{equation*} |\Lambda_2|=\sum_{k=1}^{q-1}(q-k)=\frac{q(q-1)}{2}=g, \end{equation*} where $g$ is the genus of the Hermitian curve. From this, it is also seen that $|\Lambda_1|=q^3-q^2-|\Lambda_2|=q^3-q^2-g$. All elements $\lambda$ of $\Lambda_1$ satisfy $\sigma(\lambda)=q^3-\lambda$. The largest element $\lambda'$ in $\Lambda_1$ is given by $\lambda'=(q^2-2q)q+(q-1)(q+1)$, which has $\sigma(\lambda')=q^2+1$. Thus, all elements of $\Lambda_1$ have $\sigma(\lambda)\geq\delta$, meaning that $\Lambda_1$ contributes $|\Lambda_1|=q^3-q^2-g$ to the dimension of $\tilde{E}(\delta)$. In order to determine the number of elements in $\Lambda_2$ that satisfy $\sigma(\lambda)\geq\delta$, we compute $|\Lambda_2|-|\{\lambda\in\Lambda_2\mid\sigma(\lambda)<\delta\}|$. As was the case for $\Lambda_1$, all elements of $\Lambda_2$ have $\sigma(\lambda)=q^3-\lambda$. From this it follows that \begin{equation*} \sigma(\Lambda_2)=\{q+1,2q+1,2q+2,3q+1,3q+2,3q+3,4q+1,\ldots, (q-1)q+(q-1)\}. \end{equation*} Combining this with the assumption that $\delta-1=aq+b$, the number of elements in $\sigma(\Lambda_2)$ smaller than $\delta$ is exactly \begin{equation*} \sum_{i=1}^{a-1}i+\min\{a,b\}=\frac{a(a-1)}{2}+\min\{a,b\}. \end{equation*} Because the total number of elements is $|\Lambda_2|=g$, the set $\Lambda_2$ contributes $g-a(a-1)/2-\min\{a,b\}$ to the dimension. Finally, consider $\sigma(\Lambda_3)=\{\sigma(\lambda)\mid\lambda\in\Lambda_3\}$ as a multiset. We will count (with multiplicity) the number of elements $s\in\sigma(\Lambda_3)$ with $s\geq\delta$. Observe that $\sigma(\lambda)=(q^2-i)(q-j)$ for all the elements $\lambda=iq+j(q+1)\in\Lambda_3$. Hence, $s\in\sigma(\Lambda_3)$, if and only if $s=d\cdot\frac{s}{d}$ where $d\leq q$ and $\frac{s}{d}\leq q$. Since there are $\tau^{(q)}(s)$ such divisors $d$, it follows that the multiplicity of $s$ in $\sigma(\Lambda_3)$ is given by $\tau^{(q)}(s)$. Subsequently, the number of elements satisfying $s\geq\delta$ is \begin{equation*} \sum_{s=\delta}^{q^2}\tau^{(q)}(s). \end{equation*} By summing the contribution from each of the sets $\Lambda_1$, $\Lambda_2$, and $\Lambda_3$, we obtain the dimension as claimed. \end{proof} We note that dimension formula in Proposition~\ref{prop:hermitDimension} does not provide an efficient method for computing the dimension of the code $\tilde{E}(\delta)$. Since the set $\Lambda_3$ defined in the proof has $q^2$ elements, we can loop over all of these to compute the dimension in $\Theta(q^2)$ operations, whereas the formula in Proposition~\ref{prop:hermitDimension} requires $\mathcal{O}(q^3)$. It does, however, provide an advantage when we are not interested in a dimension, but rather a codimension as will be the case in Section~\ref{sec:steaneHermitian}. Here, we will only need to compute $\tau^{(q)}$ for $m$ values, where $m$ is a small integer; typically $m=1$ or $m=2$. If only a lower bound for the dimension is needed, Lemma~6 of \cite{qcHermit} implies that the sum in Proposition~\ref{prop:hermitDimension} can be bounded below by $q^2-\lfloor\delta+\delta\ln(q^2/\delta)\rfloor$ for $q\leq\delta <q^2$ and by $q^2-\lfloor\delta+\delta\ln(\delta)\rfloor$ for $\delta<q$. \section{Steane-enlargement of Hermitian codes}\label{sec:steaneHermitian} In order to apply Steane-enlargement to the codes defined in Section~\ref{sec:order-bound-improved}, we now determine a necessary and sufficient condition for $\tilde{E}(\delta)$ to be self-orthogonal. While this is possible to do by considering the improved codes directly, it is easier to prove via the self-orthogonality of usual one-point Hermitian codes. The latter is well-known, and the following result was given in \cite{Tiersma}, and can also be found in \cite[Prop.\,8.3.2]{Stichtenoth}. \begin{proposition}\label{prop:selfOrthUsual} The code $C_{\mathcal{L}}(D,(q^3-\delta)Q)$ is self-orthogonal, if and only if \begin{equation}\label{eq:hermitianSelfOrthCond} \delta\leq \left\lfloor\frac{1}{2}(q^3-q^2+q)\right\rfloor+1. \end{equation} \end{proposition} \begin{corollary}\label{cor:selfOrthImprov} The code $\tilde{E}(\delta)$ is self-orthogonal, if and only if $\delta$ satisfies~\eqref{eq:hermitianSelfOrthCond}. \end{corollary} \begin{proof} For $\delta>q^2-q$, Lemma~\ref{lem:improvedEqualUsual} ensures that $\tilde{E}(\delta)=C_{\mathcal{}}(D,(q^3-\delta)Q)$, and the result follows from Proposition~\ref{prop:selfOrthUsual}. For smaller values of $\delta$, the result follows from the observation that $\tilde{E}(q^2-q+1)\subsetneq\tilde{E}(\delta)$. \end{proof} In Theorem~\ref{thm:qArySteane}, the relative distances of the code pairs are used to determine the distance of the resulting quantum code. In the case of one-point Hermitian codes and order bound improved Hermitian codes, however, the relative and non-relative distances coincide. To see this, consider codes $\mathcal{C}^\perp\subsetneq\mathcal{C}\subsetneq\mathcal{C}'$. Since $\mathcal{C}$ is self-orthogonal, Proposition~\ref{prop:selfOrthUsual} and Corollary~\ref{cor:selfOrthImprov} ensure that $\mathcal{C}'^\perp\subsetneq C_{\mathcal{L}}(D,(q^3-\delta_{\max})Q)\subseteq \mathcal{C}$ where $\delta_{\max}=\left\lfloor\frac{1}{2}(q^3-q^2+q)\right\rfloor+1$ as in \eqref{eq:hermitianSelfOrthCond}. In particular, this also implies the inclusions $\mathcal{C}'^\perp\subseteq C_{\mathcal{L}}(D,(q^3-\delta_{\max}-1)Q)$, so that every codeword of $\mathcal{C}'^\perp$ has Hamming weight at least $d(C_{\mathcal{L}}(D,(q^3-\delta_{\max}-1)Q))=\delta_{\max}+1$, which exceeds both $d(\mathcal{C})$ and $d(\mathcal{C}')$. Thus, relative distances satisfy $d(\mathcal{C},\mathcal{C}'^\perp)=d(\mathcal{C})$ and $d(\mathcal{C}',\mathcal{C}'^\perp)=d(\mathcal{C}')$. For this reason, we only need to consider the non-relative distances in the proofs below. In the following proposition, we explore the Steane-enlargement from Theorem~\ref{thm:qArySteane} applied to the usual one-point Hermitian codes. That is, we show by how much the dimension of the symmetric quantum error correcting code can be increased without decreasing its minimal distance. Before giving the result itself, we state the following lemma, which follows from \cite{YangKumar}. \begin{lemma}\label{lem:containedWeierstrass} If $\lambda\in\mathbb{N}$ satisfies $2g\leq \lambda<q^3$, then $\lambda\in H^\ast(Q)$. \end{lemma} \begin{proposition}\label{prop:enlargeUsualHermit} Assume that $\delta$ satisfies \eqref{eq:hermitianSelfOrthCond}, and additionally that $\delta\geq q^2+3$. If $k$ denotes the dimension of $C_{\mathcal{L}}(D,(q^3-\delta)Q)$, then there exists a quantum code with parameters \begin{equation}\label{eq:qeccUsualHermit} \Big[\Big[q^3,2k-q^3+\big\lceil\textstyle\frac{\delta-1}{q^2+1}\big\rceil,\geq\delta\Big]\Big]_{q^2}. \end{equation} \end{proposition} \begin{proof} According to Proposition~\ref{prop:selfOrthUsual}, the code $C_{\mathcal{L}}(D,(q^3-\delta)Q)$ is self-orthogo\-nal. Letting $\delta'=\delta-\lceil(\delta-1)/(q^2+1)\rceil$, it is also seen that $C_{\mathcal{L}}(D,(q^3-\delta)Q)\subseteq C_{\mathcal{L}}(D,(q^3-\delta')Q)$. Lemma~\ref{lem:containedWeierstrass} ensures that the $\lceil(\delta-1)/(q^2+1)\rceil$ integers $\delta-1,\delta-2,\ldots,\delta'$ are all included in $H^\ast(Q)$, meaning that the dimension of $C_{\mathcal{L}}(D,(q^3-\delta')Q)$ is $k+\lceil(\delta-1)/(q^2+1)\rceil\geq k+2$. Thus, we can apply Theorem~\ref{thm:qArySteane} to obtain a quantum code over $\mathbb{F}_{q^2}$ of length and dimension as in~\eqref{eq:qeccUsualHermit}. This code has minimal distance at least $\delta$ since \begin{equation*} \left(1+\frac{1}{q^2}\right)\delta'> \left(1+\frac{1}{q^2}\right)\left(\delta-\frac{\delta-1}{q^2+1}-1\right)=\delta-1, \end{equation*} and since Lemma~\ref{lem:improvedEqualUsual} ensures that $d\big(C_{\mathcal{L}}(D,(q^3-\delta)Q)\big)=d(\tilde{E}(\delta))=\delta$. \end{proof} We now turn our attention to the order bound improved codes, and begin by considering the case where both codes can be described as improved codes. \begin{proposition}\label{prop:enlargeImprovedHermit} Assume that $\delta\in\sigma(H^\ast(Q))$, and that $2\leq\delta\leq q^2$. Let $k$ denote the dimension of $\tilde{E}(\delta)$, and choose an $m\in\{1,2,\ldots,\delta-1\}$. Write $\delta-1=aq+b$ and $\delta-m-1=a'q+b'$ such that $0\leq b,b'<q$, and define \begin{equation}\label{eq:quantumParamsHermit} K=\min\{a,b\}-\min\{a',b'\}+\frac{a(a-1)-a'(a'-1)}{2}+\sum_{i=1}^{m}\tau^{(q)}(\delta-i). \end{equation} If $K\geq 2$, then there exists a $[[q^3,2k-q^3+K,\geq\delta-m+1]]_{q^2}$ quantum code. \end{proposition} \begin{proof} Consider any $m$ such that $1\leq m<\delta$, and define $\delta'=\delta-m$. By Corollary~\ref{cor:selfOrthImprov}, the code $\tilde{E}(\delta)$ is self-orthogonal. Furthermore, $\tilde{E}(\delta)\subseteq\tilde{E}(\delta')$, and Proposition~\ref{prop:hermitDimension} implies that the dimension difference is $\dim(\tilde{E}(\delta'))-\dim(\tilde{E}(\delta))=K$. Thus, if $K\geq 2$, we can apply Theorem~\ref{thm:qArySteane} to obtain a quantum code, whose dimension is $2k-q^3+K$. To determine its minimal distance, we see that \begin{equation*} \left\lceil\left(1+\frac{1}{q^2}\right)\delta'\right\rceil = \left\lceil(\delta-m)+\frac{\delta-m}{q^2}\right\rceil=\delta-m+1. \end{equation*} The result follows from the fact that $\min\{\delta,\delta-m+1\}=\delta-m+1$. \end{proof} To fully describe the quantum codes that can be constructed using the order bound improved codes, it is also necessary to consider the case where an ordinary one-point Hermitian code is enlarged to an improved code. Otherwise, we would neglect certain cases where the order bound improved codes are in some sense `too good' to be used for enlargement as shown in the following example. \begin{example} Consider the code pair $C_{\mathcal{L}}(D,52Q)\subsetneq C_{\mathcal{L}}(D,54Q)$ over $\mathbb{F}_{16}$. These codes have codimension $2$, and $C_{\mathcal{L}}(D,52Q)$ is self-orthogonal, meaning that we can apply Theorem~\ref{thm:qArySteane} to obtain a quantum code of dimension $2\cdot 47-64+2=32$ and minimal distance $d=\min\{12,(1+1/16)\cdot 10\}=11$. Using improved codes only, it is not possible to obtain as good parameters. The reason for this is that the codimension between $\tilde{E}(12)$ and $\tilde{E}(10)$ is only $1$. In fact, we have the inclusions \begin{equation*} C_{\mathcal{L}}(D,52Q)\subsetneq \tilde{E}(12)\subsetneq \tilde{E}(10)=C_{\mathcal{L}}(D,54Q). \end{equation*} Thus, if we restrict ourselves to improved codes only, we need to either start from a code smaller than $\tilde{E}(12)$ or enlarge to a code larger than $\tilde{E}(10)$. But neither option gives as good parameters as applying Steane-enlargement to $C_{\mathcal{L}}(D,52Q)\subsetneq\tilde{E}(10)$. \end{example} Despite the above observations, we shall refrain from stating the resulting parameters in a separate proposition since it would essentially say no more than Theorem~\ref{thm:qArySteane}. That is, such enlargements are in general not well-behaved enough to give meaningful formulae for their codimensions and minimal distances apart from the obvious ones, which already appear in Theorem~\ref{thm:qArySteane}. To conclude this section, we give a few examples over $\mathbb{F}_{16}$ to illustrate the constructions presented in this section. \begin{example} Let $q=4$, $\delta=20$, and consider $C_{\mathcal{L}}(D,(q^3-\delta)Q)=C_{\mathcal{L}}(D,44Q)$. As in Proposition~\ref{prop:enlargeUsualHermit} we set $\delta'=20-\lceil19/17\rceil=18$, and apply Theorem~\ref{thm:qArySteane} to the pair $C_{\mathcal{L}}(D,44Q)\subsetneq C_{\mathcal{L}}(D,46Q)$. This yields a quantum code with parameters $[[64,16,20]]_{16}$. Had we instead applied Corollary~\ref{cor:steaneSelfOrth} directly to $C_{\mathcal{L}}(D,44Q)$, the resulting parameters would be $[[64,14,20]]_{16}$. \end{example} \begin{example} The order bound improved code $\tilde{E}(5)$ is self-dual by Corollary~\ref{cor:selfOrthImprov}, and has parameters $[64,56,5]_{16}$. This code is contained in $\tilde{E}(4)$, which is a $[64,59,4]_{16}$-code. By applying the Steane-enlargement-technique, Theorem~\ref{thm:qArySteane}, we obtain a quantum code of length $64$, dimension $2\cdot 56-64+3$, and a minimal distance of at least \begin{equation*} \min\left\{5,\;\left\lceil\left(1+\frac{1}{16}\right)4\right\rceil\right\}=5. \end{equation*} That is, we can construct a $[[64,51,5]]_{16}$-quantum code. If only one-point Hermitian codes are used, the best quantum code of dimension $51$ has parameters $[[64,51,4]]_{16}$ stemming from $C_{\mathcal{L}}(D,60Q)\subsetneq C_{\mathcal{L}}(D,66Q)$. A graphical representation of the code inclusions can be found in Figure~\ref{fig:inclusions}. \end{example} \begin{figure}[hp] \centering \begin{tikzpicture}[xscale=0.7,yscale=0.5] \tikzset{every node/.style={inner sep=0,anchor=center,font=\scriptsize}} \path(-0.40,-0.40) -- (15.40,3.40); \draw[draw=none,preaction={clip,postaction={fill=white, draw=Gray!25,line width=3pt, dotted}},rounded corners=2pt] (-0.40,-0.40) -- (-0.40,3.40) -- (12.40,3.40) -- (12.40,2.40) -- (14.40,2.40) -- (14.40,0.40) -- (15.40,0.40) -- (15.40,-0.40) -- cycle; \fill[fill=Gray!30,rounded corners=2pt] (-0.40,-0.40) -- (-0.40,3.40) -- (11.40,3.40) -- (11.40,2.40) -- (13.40,2.40) -- (13.40,1.40) -- (14.40,1.40) -- (14.40,-0.40) -- cycle; \fill[fill=Gray!70,rounded corners=2pt] (-0.40,-0.40) -- (-0.40,3.40) -- (0.40,3.40) -- (0.40,1.40) -- (1.40,1.40) -- (1.40,0.40) -- (3.40,0.40) -- (3.40,-0.40) -- cycle; \draw(0,0)node{0} (0,1)node{5} (0,2)node{10} (0,3)node{15} (1,0)node{4} (1,1)node{9} (1,2)node{14} (1,3)node{19} (2,0)node{8} (2,1)node{13} (2,2)node{18} (2,3)node{23} (3,0)node{12} (3,1)node{17} (3,2)node{22} (3,3)node{27} (4,0)node{16} (4,1)node{21} (4,2)node{26} (4,3)node{31} (5,0)node{20} (5,1)node{25} (5,2)node{30} (5,3)node{35} (6,0)node{24} (6,1)node{29} (6,2)node{34} (6,3)node{39} (7,0)node{28} (7,1)node{33} (7,2)node{38} (7,3)node{43} (8,0)node{32} (8,1)node{37} (8,2)node{42} (8,3)node{47} (9,0)node{36} (9,1)node{41} (9,2)node{46} (9,3)node{51} (10,0)node{40} (10,1)node{45} (10,2)node{50} (10,3)node{55} (11,0)node{44} (11,1)node{49} (11,2)node{54} (11,3)node{59} (12,0)node{48} (12,1)node{53} (12,2)node{58} (12,3)node{63} (13,0)node{52} (13,1)node{57} (13,2)node{62} (13,3)node{67} (14,0)node{56} (14,1)node{61} (14,2)node{66} (14,3)node{71} (15,0)node{60} (15,1)node{65} (15,2)node{70} (15,3)node{75} ; \end{tikzpicture} \medskip \begin{tikzpicture}[xscale=0.7,yscale=0.5] \tikzset{every node/.style={inner sep=0,anchor=center,font=\scriptsize}} \path(-0.40,-0.40) -- (15.40,3.40); \draw[draw=none,preaction={clip,postaction={fill=white, draw=Gray!25,line width=3pt, dotted}},rounded corners=2pt] (-0.40,-0.40) -- (-0.40,3.40) -- (12.40,3.40) -- (12.40,2.40) -- (14.40,2.40) -- (14.40,0.40) -- (15.40,0.40) -- (15.40,-0.40) -- cycle; \fill[fill=Gray!30,rounded corners=2pt] (-0.40,-0.40) -- (-0.40,3.40) -- (11.40,3.40) -- (11.40,2.40) -- (13.40,2.40) -- (13.40,1.40) -- (14.40,1.40) -- (14.40,-0.40) -- cycle; \fill[fill=Gray!70,rounded corners=2pt] (-0.40,-0.40) -- (-0.40,3.40) -- (0.40,3.40) -- (0.40,1.40) -- (1.40,1.40) -- (1.40,0.40) -- (3.40,0.40) -- (3.40,-0.40) -- cycle; \draw(0,0)node{64} (0,1)node{59} (0,2)node{54} (0,3)node{49} (1,0)node{60} (1,1)node{55} (1,2)node{50} (1,3)node{45} (2,0)node{56} (2,1)node{51} (2,2)node{46} (2,3)node{41} (3,0)node{52} (3,1)node{47} (3,2)node{42} (3,3)node{37} (4,0)node{48} (4,1)node{43} (4,2)node{38} (4,3)node{33} (5,0)node{44} (5,1)node{39} (5,2)node{34} (5,3)node{29} (6,0)node{40} (6,1)node{35} (6,2)node{30} (6,3)node{25} (7,0)node{36} (7,1)node{31} (7,2)node{26} (7,3)node{21} (8,0)node{32} (8,1)node{27} (8,2)node{22} (8,3)node{17} (9,0)node{28} (9,1)node{23} (9,2)node{18} (9,3)node{13} (10,0)node{24} (10,1)node{19} (10,2)node{14} (10,3)node{9} (11,0)node{20} (11,1)node{15} (11,2)node{10} (11,3)node{5} (12,0)node{16} (12,1)node{12} (12,2)node{8} (12,3)node{4} (13,0)node{12} (13,1)node{9} (13,2)node{6} (13,3)node{3} (14,0)node{8} (14,1)node{6} (14,2)node{4} (14,3)node{2} (15,0)node{4} (15,1)node{3} (15,2)node{2} (15,3)node{1} ; \end{tikzpicture} \medskip \begin{tikzpicture}[xscale=0.7,yscale=0.5] \tikzset{every node/.style={inner sep=0,anchor=center,font=\scriptsize}} \path(-0.40,-0.40) -- (15.40,3.40); \draw[draw=none,preaction={clip,postaction={fill=white, draw=Gray!25,line width=3pt, dotted}},rounded corners=2pt] (-0.40,-0.40) -- (-0.40,3.40) -- (12.40,3.40) -- (12.40,2.40) -- (14.40,2.40) -- (14.40,0.40) -- (15.40,0.40) -- (15.40,-0.40) -- cycle; \fill[fill=Gray!30,rounded corners=2pt] (-0.40,-0.40) -- (-0.40,3.40) -- (11.40,3.40) -- (11.40,2.40) -- (13.40,2.40) -- (13.40,1.40) -- (14.40,1.40) -- (14.40,-0.40) -- cycle; \fill[fill=Gray!70,rounded corners=2pt] (-0.40,-0.40) -- (-0.40,3.40) -- (0.40,3.40) -- (0.40,1.40) -- (1.40,1.40) -- (1.40,0.40) -- (3.40,0.40) -- (3.40,-0.40) -- cycle; \draw(0,0)node{1} (0,1)node{2} (0,2)node{3} (0,3)node{4} (1,0)node{2} (1,1)node{4} (1,2)node{6} (1,3)node{8} (2,0)node{3} (2,1)node{6} (2,2)node{9} (2,3)node{12} (3,0)node{4} (3,1)node{8} (3,2)node{12} (3,3)node{16} (4,0)node{5} (4,1)node{10} (4,2)node{15} (4,3)node{20} (5,0)node{9} (5,1)node{14} (5,2)node{19} (5,3)node{24} (6,0)node{13} (6,1)node{18} (6,2)node{23} (6,3)node{28} (7,0)node{17} (7,1)node{22} (7,2)node{27} (7,3)node{32} (8,0)node{21} (8,1)node{26} (8,2)node{31} (8,3)node{36} (9,0)node{25} (9,1)node{30} (9,2)node{35} (9,3)node{40} (10,0)node{29} (10,1)node{34} (10,2)node{39} (10,3)node{44} (11,0)node{33} (11,1)node{38} (11,2)node{43} (11,3)node{48} (12,0)node{37} (12,1)node{42} (12,2)node{47} (12,3)node{52} (13,0)node{41} (13,1)node{46} (13,2)node{51} (13,3)node{56} (14,0)node{45} (14,1)node{50} (14,2)node{55} (14,3)node{60} (15,0)node{49} (15,1)node{54} (15,2)node{59} (15,3)node{64} ; \end{tikzpicture} \caption{Graphical representation of the inclusions $\tilde{E}(5)^\perp\subsetneq\tilde{E}(5)\subsetneq\tilde{E}(4)$ over $\mathbb{F}_{16}$. The top grid shows $H^\ast(Q)$, the middle $\sigma(H^\ast(Q))$, and the bottom $\mu(H^\ast(Q))$. The darkly shaded region represents the elements whose evaluations make up $\tilde{E}(5)^\perp$. The lightly shaded region represent those that are also contained in $\tilde{E}(5)$, and the dashed line shows the additional elements in $\tilde{E}(4)$. Applying Steane-enlargement to the codes $\tilde{E}(5)\subsetneq\tilde{E}(4)$ yields a $[[64, 51, 5]]_{16}$ quantum code.} \label{fig:inclusions} \end{figure} \section{Comparison with existing constructions}\label{sec:comp-with-exist} We will now compare the Steane-enlarged quantum codes from Section~\ref{sec:steaneHermitian} to some of those already in the literature. In order to conserve space, the examples presented in this section will primarily be those where the constructions of the present paper improve upon existing constructions. This is not meant to imply that such improvements can always be expected -- the cited works also contain specific examples of quantum codes whose parameters exceed what can be obtained using the results in Section~\ref{sec:steaneHermitian}. For the order bound improved Hermitian codes from Section~\ref{sec:steaneHermitian}, we give in Table~\ref{tab:qchermit} a number of examples where the Steane-enlargement in Proposition~\ref{prop:hermitDimension} yields better parameters than those achievable in~\cite{qcHermit}. In all of these examples, the construction of \cite{qcHermit} gives an asymmetric quantum code where $d_z-d_x=1$. By using the Steane-enlargement technique, the minimal distance $d_x$ can be increased by one, yielding a symmetric quantum code of the same dimension. Had we not applied Steane-enlargement in these cases, we would have to resort to the lower of the minimal distances when considering symmetric codes. \begin{table}[bp] \centering\scriptsize \begin{tabular}{cc} \toprule \textbf{Code} & \textbf{Dim. increase}\\ \midrule $[[\phantom{0}\ph8, \phantom{0}\ph4, \ph3]]_{4\phantom{0}}$ & $2$\\ $[[\ph27, \ph23, \ph3]]_{9\phantom{0}}$ & $2$\\ $[[\ph27, \ph19, \ph4]]_{9\phantom{0}}$ & $2$\\ $[[\ph27, \ph11, \ph7]]_{9\phantom{0}}$ & $2$\\ $[[\ph64, \ph60, \ph3]]_{16}$ & $2$\\ $[[\ph64, \ph56, \ph4]]_{16}$ & $2$\\ $[[\ph64, \ph51, \ph5]]_{16}$ & $3$\\ $[[\ph64, \ph40, \ph9]]_{16}$ & $2$\\ $[[\ph64, \ph36, 10]]_{16}$ & $2$\\ $[[\ph64, \ph30, 13]]_{16}$ & $2$\\ $[[125, 121, \ph3]]_{25}$ & $2$\\ $[[125, 117, \ph4]]_{25}$ & $2$\\ $[[125, 112, \ph5]]_{25}$ & $3$\\ $[[125, 107, \ph6]]_{25}$ & $2$\\ $[[125, \ph97, \ph9]]_{25}$ & $2$\\ $[[125, \ph91, 11]]_{25}$ & $2$\\ $[[125, \ph79, 16]]_{25}$ & $2$\\ $[[125, \ph75, 17]]_{25}$ & $2$\\ \bottomrule \end{tabular} \hspace{0.5cm} \begin{tabular}{cc} \toprule \textbf{Code} & \textbf{Dim. increase}\\ \midrule $[[125, \ph67, 21]]_{25}$ & $2$\\ $[[343, 339, \ph3]]_{49}$ & $2$\\ $[[343, 335, \ph4]]_{49}$ & $2$\\ $[[343, 330, \ph5]]_{49}$ & $3$\\ $[[343, 325, \ph6]]_{49}$ & $2$\\ $[[343, 319, \ph7]]_{49}$ & $4$\\ $[[343, 313, \ph8]]_{49}$ & $2$\\ $[[343, 308, \ph9]]_{49}$ & $3$\\ $[[343, 289, 15]]_{49}$ & $2$\\ $[[343, 284, 16]]_{49}$ & $3$\\ $[[343, 271, 21]]_{49}$ & $2$\\ $[[343, 267, 22]]_{49}$ & $2$\\ $[[343, 258, 25]]_{49}$ & $3$\\ $[[343, 251, 29]]_{49}$ & $2$\\ $[[343, 244, 31]]_{49}$ & $3$\\ $[[343, 235, 36]]_{49}$ & $2$\\ $[[343, 231, 37]]_{49}$ & $2$\\ $[[343, 219, 43]]_{49}$ & $2$\\ \bottomrule \end{tabular} \caption{Comparison between nearly symmetrical codes obtained via the procedure in Section~5 of \cite{qcHermit} and the Steane enlarged codes from this paper. A code $[[n,k,d]]_{q^2}$ listed here offers an improvement to a corresponding $[[n,k,d/(d-1)]]_{q^2}$ code from \cite{qcHermit}. All of the given codes retain their original minimal distance during enlargement, and the columns marked \emph{Dim. increase} indicate the increase in dimension when applying Theorem~\ref{thm:qArySteane} rather than Corollary~\ref{cor:steaneSelfOrth}.} \label{tab:qchermit} \end{table} To exemplify the advantage of using the order bound improved codes and the Steane-enlargement technique, Table~\ref{tab:techniqueComparison} shows a number of possible quantum code parameters over $\mathbb{F}_{16}$ when using different constructions based on the Hermitian curve. As is evident, the use of the order bound gives more knowledge on the minimal distance in column two, but also provides even better parameters when applying Steane-enlargement to the order bound improved codes. \begin{table}[tp] \scriptsize \centering \begin{tabular}{cccc} \toprule \multicolumn{2}{c}{\textbf{One-point codes}} & \multicolumn{2}{c}{\textbf{Order bound improved}}\\ \cmidrule(lr){1-2}\cmidrule(lr){3-4} \textbf{Goppa bound} & \textbf{Order bound} & \textbf{CSS} & \textbf{Steane-enlargement}\\ \midrule $[[64, 30, 12]]_{16}$ & $[[64, 30, 13]]_{16}$\ensuremath{\ast} & $[[64, 30, 12]]_ {16}$\phantom{\imprMark} & $[[64, 30, 13]]_{16}$\phantom{\imprMark} \\ $[[64, 32, 11]]_{16}$ & $[[64, 32, 11]]_{16}$\phantom{\imprMark} & $[[64, 32, 12]]_{16}$\ensuremath{\ast} & $[[64, 32, 11]]_{16}$\phantom{\imprMark} \\ $[[64, 34, 10]]_{16}$ & $[[64, 34, 10]]_{16}$\phantom{\imprMark} & $[[64, 34, 10]]_{16}$\phantom{\imprMark} & $[[64, 34, 10]]_{16}$\phantom{\imprMark} \\ $[[64, 36, \ph9]]_{16}$ & $[[64, 36, \ph9]]_{16}$\phantom{\imprMark} & $[[64, 36, \ph9]]_ {16}$\phantom{\imprMark} & $[[64, 36, 10]]_{16}$\ensuremath{\ast} \\ $[[64, 38, \ph8]]_{16}$ & $[[64, 38, \ph9]]_{16}$\ensuremath{\ast} & $[[64, 38, \ph9]]_{16}$\phantom{\imprMark} & $[[64, 38, \ph9]]_{16}$\phantom{\imprMark} \\ $[[64, 39, \ph7]]_{16}$ & $[[64, 39, \ph9]]_{16}$\ensuremath{\ast} & $[[64, 39, \ph6]]_{16}$\phantom{\imprMark} & $[[64, 39, \ph9]]_{16}$\phantom{\imprMark} \\ $[[64, 40, \ph7]]_{16}$ & $[[64, 40, \ph8]]_{16}$\ensuremath{\ast} & $[[64, 40, \ph8]]_ {16}$\phantom{\imprMark} & $[[64, 40, \ph9]]_{16}$\ensuremath{\ast} \\ $[[64, 42, \ph6]]_{16}$ & $[[64, 42, \ph6]]_{16}$\phantom{\imprMark} & $[[64, 42, \ph8]]_{16}$\ensuremath{\ast} & $[[64, 42, \ph7]]_{16}$\phantom{\imprMark} \\ $[[64, 44, \ph5]]_{16}$ & $[[64, 44, \ph5]]_{16}$\phantom{\imprMark} & $[[64, 44, \ph6]]_{16}$\ensuremath{\ast} & $[[64, 44, \ph7]]_{16}$\ensuremath{\ast} \\ $[[64, 45, \ph4]]_{16}$ & $[[64, 45, \ph5]]_{16}$\ensuremath{\ast} & $[[64, 45, \ph5]]_ {16}$\phantom{\imprMark} & $[[64, 45, \ph6]]_{16}$\ensuremath{\ast} \\ $[[64, 46, \ph4]]_{16}$ & $[[64, 46, \ph5]]_{16}$\ensuremath{\ast} & $[[64, 46, \ph6]]_{16}$\ensuremath{\ast} & $[[64, 46, \ph5]]_{16}$\phantom{\imprMark} \\ $[[64, 48, \ph3]]_{16}$ & $[[64, 48, \ph5]]_{16}$\ensuremath{\ast} & $[[64, 48, \ph5]]_{16}$\phantom{\imprMark} & $[[64, 48, \ph5]]_{16}$\phantom{\imprMark} \\ $[[64, 50, \ph2]]_{16}$ & $[[64, 50, \ph4]]_{16}$\ensuremath{\ast} & $[[64, 50, \ph4]]_{16}$\phantom{\imprMark} & $[[64, 50, \ph5]]_{16}$\ensuremath{\ast} \\ $[[64, 51, \ph0]]_{16}$ & $[[64, 51, \ph4]]_{16}$\ensuremath{\ast} & $[[64, 51, \ph4]]_{16}$\phantom{\imprMark} & $[[64, 51, \ph5]]_{16}$\ensuremath{\ast} \\ $[[64, 54, \ph0]]_{16}$ & $[[64, 54, \ph4]]_{16}$\ensuremath{\ast} & $[[64, 54, \ph4]]_{16}$\phantom{\imprMark} & $[[64, 54, \ph3]]_{16}$\phantom{\imprMark} \\ $[[64, 56, \ph0]]_{16}$ & $[[64, 56, \ph3]]_{16}$\ensuremath{\ast} & $[[64, 56, \ph3]]_{16}$\phantom{\imprMark} & $[[64, 56, \ph4]]_{16}$\ensuremath{\ast} \\ $[[64, 58, \ph3]]_{16}$ & $[[64, 58, \ph3]]_{16}$\ensuremath{\ast} & $[[64, 58, \ph3]]_{16}$\phantom{\imprMark} & $[[64, 58, \ph3]]_{16}$\phantom{\imprMark} \\ $[[64, 60, \ph0]]_{16}$ & $[[64, 60, \ph2]]_{16}$\ensuremath{\ast} & $[[64, 60, \ph2]]_ {16}$\phantom{\imprMark} & $[[64, 60, \ph3]]_{16}$\ensuremath{\ast} \\ $[[64, 62, \ph0]]_{16}$ & $[[64, 62, \ph2]]_{16}$\ensuremath{\ast} & $[[64, 62, \ph2]]_{16}$\phantom{\imprMark} & $[[64, 62, \ph2]]_{16}$\phantom{\imprMark} \\ \bottomrule \end{tabular} \caption{Comparison between different methods for constructing quantum codes from the Hermitian curve over $\mathbb{F}_{q^2}$. The codes in the first two columns stem from the CSS-construction applied to the usual one-point Hermitian codes, when bounding the distance by either the Goppa bound or the order bound. The third and fourth columns show the possible quantum code parameters when using order bound improved codes. In the third column, only the CSS-construction is used, and in the fourth Steane-enlargement is applied. Codes marked with {\ensuremath{\ast}} have better parameters than all preceding codes in the same row.} \label{tab:techniqueComparison} \end{table} \section*{References}\renewcommand{\chapter}[2]{\footnotesize} \input{ms.bbl} \end{document}
{'timestamp': '2019-04-24T02:00:44', 'yymm': '1904', 'arxiv_id': '1904.10007', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.10007'}
arxiv
\section{Introduction} In computing, \emph{scheduling} refers to the process of allocating computing resources to an application and mapping constituent components of that application onto those resources, in order to meet certain Quality of Service (QoS) and resource conservation goals~\cite{scheduling-book}. The \emph{application} itself may be represented in an abstract or concrete form using different programming primitives such as processes, threads, tasks, jobs, workflows, petri nets, and so on~\cite{process-thread-sched,job-sched,petri-sched,gannon-wfbook}. Similarly, the \emph{computing resource} may be diverse, ranging from local cores and processors on a host, to distributed resource like nodes in a cluster, virtual machines (VM) in a cloud, edge or mobile devices in an Internet of Things (IoT) deployment, or desktops in a volunteer computing network~\cite{hpc-sched,grid-survey2,zhan:csur:2015,8123913,BOINC}. \emph{QoS} for the application, such as their latency, and \emph{conservation goals}, such as minimizing the quanta of resource or their energy footprint, can likewise be used to determine the schedule. Consequently, examining application scheduling requires us to understand the behavior of the computing resources, application models, and QoS goals in an integrated manner. There is a growing availability of heterogeneous distributed computing resources. \emph{Cloud computing} is a capability offered by commercial service providers using a rental model. Here, virtualized compute and storage resources at large data center with thousands of servers are available on-demand~\cite{berkeley:2009}. In addition, there has been the emergence of devices at the \emph{Edge} of the network as part of the broader roll-out of \emph{Internet of Things (IoT)}. These can be sensors and devices that are part of Smart City infrastructure, lifestyle gadgets like wearables, and smart appliances or smart phones. Besides sensing and generating observation streams, these devices that number in the tens of thousands have spare compute, storage and memory capacities. These can be leveraged to execute IoT applications at the edge of the network~\cite{ghosh2018adaptive}. Further, there has been heightened interest in \emph{Fog resources}, that are between the edge and cloud in the network hierarchy, with compute, storage and memory capacities that fall between these layers as well~\cite{simmhan2018fog}. These edge and fog resources provide the opportunity for low latency processing of the generated data, closer to its source, and on the wide-area network~\cite{stojmenovic:2014}. As a result, there is critical need to understand how this diverse ecosystem of edge, fog and cloud resources can be effectively used by large-scale distributed applications. \emph{Scheduling applications on edge, fog and cloud} deals with the placement of the application's logic components onto these resources for execution, deciding their interactions within this compute and network hierarchy, and managing various forms of dynamism, to meet their QoS requirements. There can be resource mobility at the edge and fog layers. The applications may also impose requirements on logical mobility of processes and data. Further, there may be changes in the data generation rates, network behavior or energy levels of batteries that require reactive strategies~\cite{shi2012serendipity}. The application needs to be scheduled and coordinated in order to meet various QoS goals such as latency, energy and monetary constraints. As a result, scheduling within this complex ecosystem involves a multitude of online coordination and optimization decisions, and the flow of control signals and data that can impact the application performance and resource usage. There has been substantial work on examining scheduling approaches on clouds and clusters~\cite{zhan:csur:2015,kessaci:ipdpsw:2014}. However, given the nascency of edge and fog resources, \emph{there is a lack of a systematic review of distributing and scheduling applications on these resource classes individually, and together with clouds~\cite{hong:mcc:2013}.} \emph{Existing literature} has proposed the conceptual foundations of edge and fog computing~\cite{bonomi2012Fog,dasterdi:corr:2016,chiang-2016,simmhan2018fog}. Others, including us, have discussed the benefits and challenges involved in the coordination among \emph{edge, fog and cloud layers} in a hierarchical model~\cite{7721750,varshney2017icfec}, but fail to examine in detail their impact of the applications and their schedule. Several scheduling approaches also do not distinguish between the edge and the fog layers, and subsume the former into the latter (or vice versa)~\cite{skarlatprovisioning,skarlat2017towards,deng2016optimal}. There is also divergence in the assumptions made on the reliability and costing for the edge and fog layers. Hence, there is the need to understand the possible architectural patterns and scheduling mechanisms that have been proposed to cohesively schedule on these resource abstraction layers to inform researchers on open problems, and developers on available approaches and their relative merits. \emph{A literature survey} can offer a framework to examine and understand such fast-paced emerging research, in the context of existing works. Preliminary surveys on \emph{Mobile Edge Computing (MEC)}, review task offloading strategies adopted by \emph{mobile} edge devices that coexist with cloud resources, motivated by the growth in smart phones~\cite{8030322,7879258}. However, these tend to focus on scheduling individual smart phone apps on a single edge device and the cloud. We generalize beyond mobile edges to all types of edge resource, include fog computing as a first-class entity, and consider diverse application and scheduling models on them. Some of these also consider the evolution of mobile edge computing with the advent of 5G communication technologies, with capabilities like network slicing and network function virtualization~\cite{taleb2018survey}. We approach this survey from the application and Infrastructure as a Service (IaaS) perspective, rather than examine the internals of the hardware or communications architectures. Others have also summarized the relative characteristics of the three resource layers, similar to the System Design branch of our taxonomy~\cite{8123913}. However, they do not examine the impact of this on application design and scheduling models. We distinguish our work from numerous cloud computing surveys, that review \emph{the breadth of the cloud ecosystem}~\cite{zhan:csur:2015}, \emph{scheduling of VMs} onto hosts~\cite{kessaci:ipdpsw:2014,mann:csur:2015}, and use of multi-cloud environments~\cite{grozev:spe:2014}. These are at different levels of abstractions, even within cloud computing. We also contrast with specialized reviews on specific scheduling techniques or resource feature, such as meta-heuristics~\cite{wu:2015,tsai:jsyst:2014}, elasticity, and fault-tolerance~\cite{coutinho:2015,huang:jsw:2013}. Rather, we take a holistic view of these and other characteristics such as pricing, variable performance, and application models, and consider them in the presence of edge and fog resources as well. the application and system models as well. These related works are reviewed in greater detail in Section~\ref{sec:related}. We address these gaps and present a \emph{survey on scheduling of applications on to Edge, Fog and Cloud computing resources}, both independently and collectively, based on a review of contemporary scheduling literature. Specifically, we present a \textbf{taxonomy of concepts and approaches} for scheduling applications on edge, fog and cloud resources~(\S~\ref{sec:taxonomy}), based on a detailed review of research literature over the past decade. This classification covers \emph{properties of edge, fog and cloud resources} relevant to scheduling, \emph{characteristics of the application} that impacts the schedule, and the \emph{diverse QoS and constraints} that determine the performance of the schedule, and \emph{categories of scheduling algorithms} that exist. We then \textbf{tabulate key scheduling literature} using this taxonomy to offer a birds-eye view of the landscape of application scheduling on these resources ~(\S~\ref{sec:table}). We place our survey in the context of other \textbf{related surveys} that exist, and argue its novelty and impact~(\S~\ref{sec:related}). Lastly, we discuss \textbf{emerging trends} in this decade-old research area, and highlight open problems that the research community is actively exploring at present~(\S~\ref{sec:discussion}). At the same time, our \emph{goal is not} to examine specific implementations of edge or fog computing technologies, cloud service offerings beyond IaaS (and even that with an emphasis on computing resources), nor to offer case-studies of applications. We compare and contrast the conceptual features across these resources, and abstract the higher-order application models to help examine scheduling techniques. We also do not consider security and privacy aspects such as authentication, encryption and cyber-attacks on edge, fog and cloud. Networking and communications technologies, and data center management are out of scope as well. Existing literature, some of which we review in the related work, address these adequately. This article draws on \emph{our two prior works} that characterize the resource behavior of edge, fog and cloud~\cite{varshney2017icfec}, and offer an overview of fog computing~\cite{simmhan2018fog}. These content are selectively incorporated in the resource capabilities section (\S~\ref{sec:tax:sys}). However, the scope of this current review is substantially wider and more in-depth, as is seen by the rest of the article. In summary, our survey is based on the premise that: (1) it is important to consider edge, fog and cloud resources collectively and also in contrast to each other, to leverage their mutual benefits; (2) this has to be examined from the application definition and scheduling perspective as it faces the end users and developers on these resource, rather than the service providers; and (3) programming models and scheduling techniques on individual resource layers are translatable to others, in addition to exploring approaches that cut across these layers. To this end, we offer a novel and useful review of current literature and a consequent taxonomy related to these goals. As a result, it presents designers of scheduling algorithms for edge, fog and cloud applications with a clear set of system and application features they should consider for their target infrastructure. It also provides architects of application runtimes with the available options of scheduling algorithms that they can leverage to meet the needs of their end-users. Also, it highlights gaps in existing literature where the intersection between these resource layers have yet to be adequately addressed. \section{Background} In this section, we provide a background of edge and fog computing to motivate the need to consider them as first-class computing resources, while substantiating this with a conceptual taxonomy for them later in \S~\ref{sec:tax:sys}. We then briefly discuss prior work on Mobile Cloud Computing (MCC) (also called, Mobile Edge Computing (MEC)), which has generalized into edge and cloud computing. This offers a contrast from this conceptual predecessor, and scheduling strategies that have been attempted on it. Lastly, we offer a similar distinction from the extensive work on scheduling for High Performance Computing (HPC) resources, which is related to but has key distinctions from how applications are scheduled on the cloud. These establish clear contrasts from our effort while still offering a background on prior work on related technology domains. \subsection{Edge and Fog Computing as an Emerging Resource Abstractions} \label{sec:ef:abs} \emph{Edge computing} refers to the use of thousands of computing devices such as sensors, gateways, mobile devices or embedded systems at the edge of the network, often in the context of mobile phones or the Internet of Things (IoT), for performing computation. This complements their traditional role of data collection and actuation, while the cloud is used for computation and data analytics~\cite{hu2017survey,Bonomi2014}. \emph{Fog computing}~\cite{Bonomi2014}, also known as \emph{Cloudlets}~\cite{satya:pervasive:2009}, was introduced by Satyanarayanan, et al., and popularized by Cisco as a complementary resource-rich layer that sits between the edge and the cloud~\cite{varshney2017icfec}. Fog provides data, compute, storage, and application services to end-users similar to cloud data centers but with lower latency and faster response as it is typically 1-hop away from the edge~\cite{bittencourt2017mobility,stojmenovic:fedcsis:2014}. There are many \emph{applications} that motivate and benefit from edge and fog computing~\cite{varshney2017icfec}. There is a global push toward Smart Cities as a manifestation of IoT. Given the advances in deep learning, large-scale \emph{video surveillance} has been adopted for public safety and as a proxy for ambient observations using analytics, such as to identify parking violations, and classify vehicles and people ~\cite{yi:mobidata:2015,jin2012network}. Training the neural network models is computationally costly, and the source video streams at the edge are also large in size. Accelerated fog resources can complement edge resources available for deep learning while reducing data transfer costs to the cloud. \emph{Smart Power Grids} are another key domain in smart cities~\cite{simmhan:cise:2013,varshney2017icfec}, with net-connected smart meters reporting power demand at households and industries every few minutes to the utility ~\cite{amin2005toward}. Smart grid applications like \emph{Demand-response (DR) optimization} help shape or shift power demand using forecasting models on the cloud that trigger curtailment strategies on the edge when a load mismatch is detected~\cite{aman:tkde:2015,aman:smartgridcomm:2015}. \emph{State estimation} to determine the health of the distribution network is even more time sensitive, $\mathcal{O}(ms)$, and necessitating computing at the edge~\cite{moslehi2010reliability}. While edge and fog computing are still emerging technologies, this taxonomy throws more light on these resource abstractions and their effective use from an application and scheduling model, based on current literature and technology. \subsection{Scheduling on Mobile Clouds vs. Edge Computing} \label{sec:mcc} Mobile Cloud Computing (MCC) (also called Mobile Edge Computing (MEC) or Mobile Clouds) is a precursor to the more general edge computing concept~\cite{dinh2013survey,sanaei2014heterogeneity,fernando2013mobile}. It has a restricted design, motivated by cellular phones, both smart and feature phones, running applications or ``apps''. MCC is concerned with strategies for offloading these applications from the mobile devices to the cloud due to the constrained computing power of the device. It involves a simple network topology, and is often limited to direct communication between one mobile (edge) device and the cloud. In the most common form of MCC, the coordination between the mobile device and the cloud is often on a per-application basis, i.e., each application is designed to run a part of its logic on the phone and the rest on the cloud. E.g., the cloud may be used for data persistence, to look-up information, or to perform some costly computing tasks. The interaction may be using service endpoints, and this takes the form of a client-server architecture. However, there exist research on more general frameworks that decide which applications or modules to offload, and when. CloneCloud~\cite{chun2011cloneCloud} partitions a mobile application and migrates it to a device clone running in the cloud to minimize the application execution time and conserve the energy of the device. ~\cite{barbera2013offload} study the trade-off between off-loading and not off-loading computation and software/data backup from mobile edge devices to the cloud, using bandwidth and energy consumption as metrics. Others plan of such off-loading at the cellular network level for different devices to the cloud, with apps defined as workflows~\cite{deng2015computation}. MCC usually does not cooperatively schedule apps across a group of devices, due to security concerns of phones users, and energy constraints of the devices. Also, there are typically only the mobile device and the cloud layers. There is some literature on smart phones interacting with other nearby devices for performing computations~\cite{shi2012serendipity}, while others have also proposed using cellular towers as base-stations as a fog-like layer. We generalize this even further by considering edge, fog and cloud resource abstractions, and examining distributed scheduling across one or more of these. That said, MCC offers insights for such current efforts for scheduling and resource provisioning. \subsection{Scheduling on HPC Clusters vs. Cloud Computing} \label{sec:cloud:distinction} Traditionally, scheduling has been an important aspect for operating systems, high performance computing (HPC) and supercomputing clusters, and computing Grids~\cite{hpc-sched,grid-sched}. Grid computing offers shared distributed resources for which scheduling strategies are crucial, and these have been reviewed in detail~\cite{grid-survey1,grid-survey2}. In contrast, cloud computing is a distributed computing capability offered by data center operators using a service-based model ~\cite{berkeley:2009}, while edge and fog computing operate on a wide-area network, and these affect how applications are scheduled upon them~\cite{foster:360}. We summarize key resource distinctions of HPC that impacts application design and scheduling, and motivates the need to separately explore scheduling on edge, fog and cloud resources. HPC centers traditionally have captive cluster infrastructure that are accessed by the center users using a batch queue that schedules jobs based on arrival time. The emphasis is on how best to allocate the available resources to the waiting jobs from 10--100's of users. In contrast, public cloud infrastructure offer access to Virtual Machines (VM), on-demand without delay, and give the illusion of ``infinite'' resources to 1000's of users~\cite{saeid:fgcs:2013}. It also allows the number of VMs requested to be elastically scaled up and down ~\cite{imai:ucc:2012}. At the same time, each application request 10's of VMs rather than 100--1000's of cores common in HPC clusters. Grids and HPC clusters use high-end fault-tolerant servers and high-performance networks to support Floating Point Operations per Second (FLOPS) and communications numerical applications. Clouds on the other hand use commodity and virtualized hardware, run on Ethernet, and are not as resilient to hardware failure. They also offer VMs of different resources capacities unlike HPC nodes that are typically homogeneous. As a consequence, HPC clusters can host tightly-coupled large-scale applications with high throughput and reliability ~\cite{raicu:2008}. Application \emph{Makespan} is the primary measure of success for scheduling. Uniform nodes also limit the degrees of freedom when scheduling applications on such clusters~\cite{topcuoglu:tpds:2002}. Clouds are popular for loosely-coupled applications that run from seconds to days each and have variable resource needs ~\cite{jackson:2011}. Fault-tolerance is built in software due to weaker hardware robustness, and applications are more delay tolerant. Also, VMs may have variable performance due to virtualization and multi-tenancy ~\cite{iosup:ccgrid:2011}. Factors like VM acquisition lag and diverse VM sizes add to the scheduling complexity~\cite{mao:sc:2011, calheiros:tpds:2014,jackson:cloudcom:2010}. Lastly, Grids and HPC clusters encourage full use of their high-end infrastructure by their users to amortize the high capital costs. There is little or no financial cost to the users and at best quotas are imposed for fairness. As a result, scheduling algorithms prioritize the performance and makespan of the applications rather than conserve the resource usage~\cite{Sandholm:2004}. Public clouds follow a pay-as-you-go model~\cite{berkeley:2009} with resources billed only for resources acquired on-demand, and diverse costing models. These offer scheduling algorithms a different parameter space to optimize upon. \begin{figure}[t] \centering \includegraphics[width=0.9\columnwidth]{figures/taxonomy.pdf} \caption{Taxonomy of concepts and approaches for scheduling applications on Edge, Fog and Cloud resources} \label{fig:taxonomy} \end{figure} \section{The Taxonomy} \label{sec:taxonomy} Our taxonomy takes a holistic view of application scheduling on edge, fog and cloud resources, and offers a classification of the \emph{conceptual model} of system models, application models, and their goals, required to design scheduling algorithms. We categorize the scheduling algorithm design themselves, and approaches used to evaluate them. Specifically, the top levels of our taxonomy are: System design (\S~\ref{sec:tax:sys}), Application Model (\S~\ref{sec:tax:app}), QoS Goal (\S~\ref{sec:tax:qos}), and Scheduling Algorithm design (\S~\ref{sec:tax:algo}), as shown in Fig.~\ref{fig:taxonomy}. A full view of the taxonomy is provided in the Appendix, in Fig.~\ref{fig:tax:full}. In the following sections, we discuss each category in detail. \subsection{System Design} \label{sec:tax:sys} Edge, fog and cloud provide various types of computing resources with diverse capabilities and different pricing models. System design is concerned with the resource capacities, pricing features, and other system characteristics (Fig.~\ref{fig:tax:sys}). For the cloud layer, we base our characterization on the capabilities of popular public Infrastructure as a Service (IaaS) clouds from Amazon Web Services (AWS), Microsoft Azure and Google Cloud Engine in defining these dimensions. For the edge and fog resources, these are based on current research and early commercial offerings such as Amazon Greengrass and Azure IoT Edge. We distill the essential and generic capabilities of such systems, and avoid transient capabilities offered in this fast-changing landscape. \subsubsection{Resource Abstraction Layer} In this section, we offer a relative overview of the three resource layers on which the applications are scheduled, as highlighted in Fig~\ref{fig:pyramid:1} and examined before~\cite{varshney2017icfec}. We have already introduced these resource classes, and now we contrast their resource and performance characteristics. We base these on existing definitions~\cite{brogi2017qos,shi2016Edge,vaquero2014finding,mell2011nist,buyya2008market}, among many, which place fog computing as a resource layer that fits between the edge devices and the cloud data centers, with features that resemble both. The intrinsic distinction is the \emph{network distance} between the edge/leaf of the Internet, where edge and fog resources are present, and the core of the Internet where large cloud data centers are located. This affects the latency and available bandwidth between the different layers. This combined with where the data is generated, analytics are computed, decision signals are sent, and what QoS is required can affect the scheduling problem. In addition, it is also worth considering the \emph{physical distance} between the three computing paradigms, and their accessibility by clients. In Fig.~\ref{fig:physical}, four quadrants are formed from considering whether the resources within a layer are physically centralized or distributed (Y Axis), and whether their access is global or restricted (X Axis). Resources in a cloud data center are centrally located, but depending on whether the cloud is public or private, are available to anyone in a pay-as-you-go model, or only to users of the private corporation~\cite{luan:arxiv:2016}. That said, public cloud providers host geographically distributed data centers, sometimes several in a country or continent, while the number of large private data centers for an enterprise is more limited. Edge resources such as smart phones and set top boxes are distributed far and wide, but their access is restricted to individual users or managed applications~\cite{Bonomi2014,yi:mobidata:2015}. Fog resources are also physically distributed to be close to the edge, but not as dispersed. Additional specializations, on whether there is a fog for each city block, one for the whole city or other variants, depend on the business models and applications that will evolve. One also expects the fog to offer as a shared, pay-as-you-go IaaS or Platform as a Service (PaaS) model~\cite{bittencourt:pgcic:2015,yi:mobidata:2015}. Edge and fog resources are distributed which increases the probability of \emph{attacks and failures} as discussed in \S~\ref{sec:tax:sys:char}. The access restrictions on private clouds and edge devices translates to a \emph{zone of trust} for applications and services hosted on them, which enables sensitive data and services to be hosted on them. Fog and public clouds, however, are designed as shared resources with \emph{multi-tenancy}, which require higher measures of security and sandboxing. That said, there may be fog architectures where the resources are deployed for specific applications or organization (e.g., a Smart City municipality), similar to a private cloud~\cite{luan:arxiv:2016}. Further, the fog may sit at the boundary between public and private networks, and run proxy services that translate from one zone of trust to another, one service layer to another (e.g., CoAP to HTTP), or one network protocol to another (e.g., IPv6 to IPv4). \begin{figure}[t] \centering \includegraphics[width=0.85\columnwidth]{figures/system-design.pdf} \caption{Taxonomy of system design} \label{fig:tax:sys} \end{figure} \begin{figure}[t] \centering \subfloat[Physical presence vs access]{\includegraphics[width=0.4\columnwidth]{figures/distributionvsaccess.pdf}\label{fig:physical}}\qquad\qquad \subfloat[Physical mobility. Cloud is omitted as it is static.]{\includegraphics[width=0.45\columnwidth]{figures/mobility.pdf}\label{fig:mobility}} \caption{Physical presence, access limits and mobility of Cloud, Fog and Edge resources~\cite{varshney2017icfec}} \end{figure} It helps to understand the impact of \emph{mobility} on these three resource layers, as illustrated in Fig.~\ref{fig:mobility}, as this impacts the communications, applications and platform design. We distinguish between mobility of the \emph{physical resource}, discussed here, and mobility of the logical applications, which we examine later. Cloud data centers, obviously, are not mobile though their platforms can ease the mobility of data and applications among their data centers. Spatial mobility at edge devices is frequent, though not universal, e.g., mobility is seen in ubiquitous smart phones and autonomous vehicles, while they remain static in traffic cameras and smart power meters~\cite{stojmenovic:fedcsis:2014,Loke2015TheIO}. This is more so in the context of mobile cloud computing that is concerned with offloading computations from mobile edge devices like smart phones to cloud to save battery, speedup computations and for data/software backup~\cite{barbera2013offload}. Likewise, the fog layer can also be manifest as a static or mobile resource~\cite{luan:arxiv:2016}. A fog server can be installed at fixed sites such as a coffee shop or the airport, or on mobile vehicles such as taxi cabs or trains. This mobility can cause these resources to be unavailable which is discussed later in \S~\ref{sec:tax:sys:char}. Mobility at edge and fog layers also necessitates \emph{device discovery}, as devices join/leave/rejoin different parts of the network and resource fabric. This will on-board and make them available as part of the resource pool, and similarly remove them when they leave. The \emph{Open Fog Reference Architecture}~\cite{ofra} suggests a P2P model where a new fog node broadcasts its information to a fog cluster. Other have proposed a publish-subscribe model for edge and fog devices to announce themselves on arrival/departure~\cite{7721750}. This can be extended to a Distributed Hash Table (DHT) as well, for notifying arrival and departure, as well as for scheduling tasks~\cite{gedeon2017router}. Some also suggest a hierarchical discovery approach for edges partitioned into fog parents, and fogs themselves reporting to higher-level fogs, all of which is accumulated at a \emph{discovery server}~\cite{saurez2016incremental}. Some also use the transport-level protocols~\cite{soo2016proactive}, e.g., by having a \emph{leader device} broadcast a 802.11 WiFi beacon frame to notify spatially proximate devices that wish to join about the location of the leader to contact~\cite{rejiba2018f2c}. Discovery using the Software Defined Networking (SDN) layer is possible as well, as has been suggested for fog resources in a vehicular network~\cite{truong2015software}. As a result, depending on the mobility of the edge and fog layers, the application and platform will need to be designed based on \emph{permanent, transient, periodic, or ephemeral connectivity} between the layers and within the layers which can determine the \emph{reliability of access} to data, storage, network and computing resources. The application definition needs to be scheduled and coordinated in order to meet various QoS goals such as latency, energy and monetary constraints. This coordination can be done using different strategies, across edge, fog and cloud resource layers. Three common \emph{orchestration models} that are relevant in such a multi-layered and distributed resource environment are \emph{centralized, hierarchical} and \emph{peer-to-peer (P2P)}. We also distinguish between \emph{scheduling decisions}, the \emph{flow of control signals} and the \emph{flow of data}, and different coordination models could be applied to these. \emph{Centralized} orchestration has a single service, either per application or for the platform, that is located in one of the three resource layers, makes scheduling decisions, and coordinates the transfer of control signals and/or data items~\cite{dasterdi:corr:2016}. This is simple to design but can suffer from high latencies and transfer costs, and is a single point of failure. While this orchestrator often runs in the cloud (to coordinate across edge devices) or the edge (to interact with different cloud services), the fog layer could offer a sweet-spot for such a centralized coordinator~\cite{aazam:2014}. A \emph{hierarchical} architecture is a generalization of the centralized model, and allows only vertical communication of data and controls to take place between adjacent layers. This is a natural fit for fog computing as it leverages both the bandwidth and latency benefits of the fog layer in accelerating these flows, as well as the compute benefits closer to the observation source~\cite{yannuzzi:camad:2014,yi:mobidata:2015,stojmenovic:fedcsis:2014,dasterdi:corr:2016,hong:mcc:2013}. Often, the cloud forms the root of this tree and is used for global data aggregation and coordination. Local data analytics is delegated to Cloudlets and further to the edge devices. This allows a federated behavior that has shown to scale. \emph{P2P} is a form of distributed coordination that avoids a single point of failure. Here, peers in the same edge or fog layer can pass control and data directly among each other~\cite{vaquero2014finding}. The horizontal communication channels may initially be setup by an entity that has a global picture of the resources. This is typically done at the cloud or the fog, or one of the edge devices that serves as a leader. There are simple component-based models for composing and executing P2P applications, as well as complex ones that use Distributed Hash Table (DHT) to maintain an overlay network over peers that frequently enter and leave the system~\cite{luan:arxiv:2016,stojmenovic:2014}. In a \emph{hybrid} model, there are no strict limitations on the flow of control or data flows, and all layers are seen as having resources of heterogeneous characteristics. While there can be interconnections among resources within each layer (cloud, fog, edge), communication can also take place vertically~\cite{bittencourt:pgcic:2015}. This can require more complex coordination, but can potentially improve the resilience of the application when network connectivity between specific layers is interrupted~\cite{madsen2013reliability}. \subsubsection{Resource Capacities and Variability} \begin{figure}[t] \centering \includegraphics[width=0.7\columnwidth]{figures/resource-type-size.pdf} \caption{Taxonomy of resource variability.} \label{fig:tax:sys:vm-size} \end{figure} \begin{figure}[t] \centering \includegraphics[width=0.75\columnwidth]{figures/pyramids.pdf} \caption{Resource characteristics of Cloud, Fog and Edge computing systems~\cite{varshney2017icfec}} \label{fig:pyramid:1} \end{figure} Next, we consider the variability of the resource capacities offered on the different abstraction layers, with the shown in Fig.~\ref{fig:tax:sys:vm-size}. Schedulers often leverage the ability to acquire resources of variable types and capacities as it allows a best-fit between the application resource requirements and resources. Resources can vary in their \emph{types}, \emph{sizes} and \emph{capacities} across edge, fog and cloud layers. This is illustrated in Fig.~\ref{fig:pyramid:1} as inverted/upward pyramids that form a continuum across the layers, in increasing and decreasing order as applicable. \ssec{Homogeneous resources} Cloud computing resources are standardized within a service provider, and offered in different capacities based on a pay-as-you-go pricing model. IaaS providers offer Virtual Machines (VM) as their computing resource, characterized by their different compute capacities (CPU cores, clock speed, architecture generation), physical memory, and network bandwidth, with associated pricing. These VM sizes are crucial in the context of scheduling cloud applications, and one can rely on the cloud provider to offer numerous homogeneous instances of a single resource size. Homogeneity may be possible in large scale deployments of edge and fog, as a commercial service operation or by city utilities. Edge devices that are part of city-scale IoT infrastructure, such as net-connected smart power meters and traffic cameras for machine-to-machine (M2M) interactions, may have uniform specifications~\cite{simmhan:cise:2013}. Fog resources such as Nvidia Jetson TX1 and Dell Edge Gateway can also be deployed as a standard across the city for commercial use, such as Barcelona city's ``street-side cabinets'' ~\cite{yannuzzi-2017}. \ssec{Heterogeneous resources} At the cloud layer, a wide variety of VM sizes and configurations are offered, with AWS, e.g., offering $42$ different Elastic Compute Cloud (EC2) VM configurations. Besides resource capacities, these also vary in types of disks (SSD or HDD), presence of accelerators (GPUs), and higher-end architectures (DDR4 memory, latest CPU generation). While in the cloud, heterogeneity is a choice offered by the provider, on the edge and fog, this variability may be a necessity of the infrastructure deployment model. Heterogeneity is increased when the resources are consumer-owned instead of being available as part of commercial deployment, such as smart phones, smart watches, Virtual Reality (VR) headsets, etc. Edge platforms also tend to be constrained devices, with battery or memory capacity often being the limiting factor rather than even compute capability ~\cite{dastjerdi:computer:2016,varshney2017icfec}. The fog layer offers compute resources with a higher capacity than the edge but to a smaller scale than clouds~\cite{stojmenovic:fedcsis:2014,Bonomi2014}. However, their resource capacity can vary~\cite{simmhan2018fog}, with Raspberry Pi devices at one end, to ``micro'' or ``nano'' data-centers (MDC) on the other ~\cite{chiang-2016,lopez-2015}. The latter allow fogs to serve as a ``reverse CDN'' to let edge devices stage data on them and eventually push them to the cloud for archival, after some pre-processing~\cite{bonomi2012Fog,satya:pervasive:2015,dasterdi:corr:2016}. Resources may also have variable \emph{network characteristics}~\cite{varshney2017icfec}. While the Fog is close to the edge in the network topology, whether it is at a 1-hop or multi-hop depends on the deployment~\cite{satya:pervasive:2009}. The fog is also expected to have a reliable and high bandwidth Internet link~\cite{stojmenovic:2014}, but its connectivity to the edge may be less robust due to the use of wireless links for the last mile~\cite{luan:arxiv:2016}. However, such diversity explores the dimensions that the scheduling algorithm has to examine. To mitigate this, some algorithms assume a uniform, homogeneous resource capacity (and price) for simplicity, which is more feasible on cloud resources~\cite{malawski:sc:2012}. Algorithms may also limit themselves to leveraging just the compute diversity (e.g., different VM or container sizes) ~\cite{calheiros:tpds:2014,chu:ipdps:2014,poola:iccs:2014,hong:mcc:2013}. \begin{figure}[t] \centering \includegraphics[width=0.75\columnwidth]{figures/virtualization.pdf} \caption{Taxonomy of virtualization of resources} \label{fig:virtualization} \end{figure} \subsubsection{Virtualization} Various types of virtualization (or lack of it) is possible within the different resource types, as shown by the taxonomy in Fig.~\ref{fig:virtualization}. Clouds expose every resource ``as a Service'' using \emph{fabric software} for infrastructure management, and this in part is a reason for its success~\cite{bittencourt:pgcic:2015,stojmenovic:fedcsis:2014,varshney2017icfec}. Virtualization using \emph{hypervisors} offers two key benefits: (1) custom OS and software environments, and (2) sandboxing of VMs from each other using hardware-level support. The former allows user applications and Big Data platforms to work equally well on different clouds. They latter provides dependable resource allocation and security. Resource-rich fog devices may be able to support hypervisors, and this can hasten their adoption for IaaS similar to clouds~\cite{bittencourt:pgcic:2015,varshney2017icfec}. On the other hand, resource-light fogs can use \emph{containers} like \texttt{lxc} and Docker which offer users the control over the software environment and limited resource sandboxing~\cite{yannuzzi:camad:2014,bittencourt:pgcic:2015}. However, security within multi-tenant containers on a host is still a concern. That said, containers have limited memory overheads and rapid bootup time compared to VMs, and this makes them preferred even for application management in the cloud. \emph{Containers launched within VMs} is a growing practice, with VMs offering the resource and security sandboxing and billing units, while containers (potentially 10's in a VM) allow application environment management. Application management on the edge is a challenge, and done in either \emph{ad hoc} or tightly coupled to a platform like Android using sandboxed ``apps''~\cite{varshney2017icfec}. Lastly, even these light-weight wrappers may not be viable on severely constrained edge platforms. Hence, application may run on \emph{bare-metal}, or within a platform (rather than infrastructure) as a service. There are also \emph{software fabrics} that help manage such virtualized or containerized computing infrastructure, on the cloud, fog and edge. These serve as a form of distributed OS. While public clouds like Amazon, Microsoft and Google run their proprietary IaaS fabrics, \emph{OpenStack}~\cite{openstack} offers a full-suite of compute, data and network virtualization services for private clouds. \emph{Kubernetes} from Google focuses on container and compute management on large-scale clusters~\cite{kubernetes}. Both have also been extended to operate on fog and/or edge computing devices. While some have tried to use OpenStack as is on fog resources~\cite{yi2015fog}, others extend its features to be customized for specific limitations of edge and fog resources. Lebre, et al.~\cite{lebre2017revising} propose a decentralized P2P variant of OpenStack's Nova compute service to enable wide-area computing resources, while Chang, et al.~\cite{chang2014bringing} extend the Quantum virtual network networking to support devices present on a Network Address Translation (NAT) network. OpenStack is also natively working on porting their capabilities to edge, fog and Micro Data Center (MDC)~\cite{openstack-fog}. Similarly, Kubernetes has been used for compute containers on Raspberry Pi-class edge devices~\cite{tsai2017distributed}, and used to deploy software on the fly on fog resources~\cite{hong2016dynamic}. Besides these, there are also open-source fabrics specialized for edge and fog, such as Eclipse Kura and EdgeXFoundry~\cite{kura,2017feasibility, edgex} that are evolving. \subsubsection{Pricing Model} The monetary cost for accessing edge, fog and cloud resources is variable. While clouds offer a mature pay-as-you-go pricing model, edge and fog resources as yet have evolving business models. Typically, resource pricing is proportional to its compute capacity on a given resource abstraction. However, there are also pricing differences due to the variable access guarantees that are provided. One can broadly categorize the pricing model based on resources that are non-preemptible and those that pre-emptible (Fig.~\ref{fig:tax:sys:vm-price}). In the former, resources once provided are retained (and billed) until the application relinquishes them. In the latter, resources may be taken back by the service provider at any time, and the application is optionally compensated monetarily. \begin{figure}[t] \centering \includegraphics[width=0.8\columnwidth]{figures/pricing-model.pdf} \caption{Taxonomy of pricing model of resources.} \label{fig:tax:sys:vm-price} \end{figure} \ssec{Non-preemptible} These are the most common form of cloud resources where VMs have an associated fixed price per unit billing time based on their compute capacity. Clouds further distinguish this between \emph{on-demand VMs} which are acquired and released by the application flexibly, based on their current compute needs, and their billing intervals are as low as 1~second. \emph{Reserved VMs} are those that are acquired in bulk for longer periods of time (e.g., 1 month) at a cheaper unit rate, but billed in full irrespective of their usage. These are well-suited for users having a predictable long-term workload. The diversity in cloud VM sizes also implies an associated diversity in the pricing of the resources. Variable sized on-demand VMs allow scheduling algorithms to make smart choices in trading off price to performance for their application~\cite{zhou:tcc:2014,saeid:fgcs:2013,malawski:sc:2012,mao:sc:2011,calheiros:tpds:2014}. Commercial fog providers may use \emph{consumption-based} pricing where the users are billed as per their usage, or \emph{subscription based} pricing where the users pay a monthly fixed price and can use the fog resources network-wide, without being pinned to a particular instance~\cite{bittencourt:pgcic:2015,varshney2017icfec}. These are similar to the on-demand and reserved models in clouds. The infancy of fog deployments and their potential providers has implications on the operational costs as well~\cite{simmhan2018fog,vaquero2014finding,yi:mobidata:2015}. Alternatively, smart cities may make them available as a utility service for free or based on payment~\cite{yannuzzi-2017,luan:arxiv:2016,simmhan2018fog}. This may also extend to edge devices that are part of the city's deployment. \ssec{Pre-emptible} Cloud providers may have spare capacity in their data center which are rented at a lower price than their on-demand counterparts, even $10\times$ cheaper~\cite{agmon2013deconstructing}. This allows providers to increase the utilization and revenue of their data centers to offset the static operational overheads. While these VMs offer the same performance as a similarly sized on-demand VM, they are not guaranteed to be available for the user's required duration and may be revoked by the provider. This requires scheduling algorithms to actively manage application checkpointing for reliability. There are two models of such VMs available commercially. Amazon's Spot VMs use an \emph{auction-based model} that considers the highest price bids per billing interval for a VM size, with prices vary even within minutes. Amazon has recently started providing a \emph{$2$~min warning} when spot VMs are going to be revoked. Schedulers using such VMs must be aware of the current spot price and these revocation notices, but can in turn reduce application execution costs by over $80\%$~\cite{agmon2013deconstructing,chohan:usenix:2010,kushwaha:ccem:2014,voorsluys:aina:2012,subramanya2015spoton}. Google and Microsoft offer \emph{pre-emptible VMs} which have a \emph{fixed discounted price} that is significantly cheaper than their on-demand equivalents. This makes scheduling decisions easier than Amazon's spot VMs with variable pricing. However, such VMs are currently limited to being used for a maximum of 24~hours. Google gives a $30~sec$ warning before such VM are pre-empted. Most edge devices and many non-commercial fog deployments are unreliable and transient, due to mobility, device uptime and network connectivity issues. As a result, these resources have similarities to pre-emptible cloud resources where availability is not guaranteed. Here, the edge and fog resources are available \emph{opportunistically} and often for free, with no assurance that one can acquire them at a given time, or retain them for the required period. Applications may utilize the resources while they are in proximity but lose all progress if they go out of range or due to network unavailability. Mobile edge devices like smartphones are one such example of opportunistic computation, and schedulers like Serendipity~\cite{shi2012serendipity} offload tasks to neighboring edge devices to minimize the execution time and save energy. \ssec{Hybrid} Scheduling strategies may take advantage of a mix of resources with different pricing schemes. One hybrid approach is to use captive resource capacity, such as reserved VMs or private clouds/clusters which are already paid for, along with on-demand resources that are pay-as-you-go. Here, there are two possibilities: ``Cloud-bursting'' or ``Cloud-firsting''. In the former, the scheduler gives priority to maximizing the use of the free captive resources before moving to on-demand (cloud) resources~\cite{bittencourt:jisa:2011,guo:toit:2014,dornemann:ccgrid:2009}. In cloud-firsting, the on-demand (cloud) resources are used by default and the limited captive resources used for instantaneous capacity access by the scheduler~\cite{chu:ipdps:2014}. A second approach is to use a mix of on-demand and pre-emptible resources to reduce the cost of execution. \cite{chohan:usenix:2010} use spot instances along with on-demand instances to speed up the MapReduce jobs on the cloud, while others propose strategies to manage the job's life-cycle on spot, on-demand and captive resources~\cite{chu:ipdps:2014,poola:acm:2016,subramanya2015spoton}. A third approach is to use resources from different resource abstraction layers that may have variable prices. While cloud and fog resources are reliable and available, they have higher costs as well. Opportunistic edge devices may be free but unreliable. So, when end users want the benefit of both cost reduction and reliability, scheduling algorithms may need to use more than one abstraction layer. Further, any free edge or fog devices may also play the role of captive or pre-emptible resource, and mimic the first two approaches. E.g., MCC uses unreliable but cheap mobile devices along with reliable clouds for offload its computations/software/data when the edge runs low on compute, storage or battery~\cite{barbera2013offload,miettinen2010energy}. \begin{figure}[t] \centering \includegraphics[width=0.7\columnwidth]{figures/pricing-characteristics.pdf} \caption{Taxonomy of pricing characteristics of resources.} \label{fig:tax:sys:price-char} \end{figure} \subsubsection{Pricing Characteristics} There are other pricing characteristics of resources besides the pricing model that should be considered, as shown in Fig.~\ref{fig:tax:sys:price-char}. \ssec{Billing Interval} In a pay-as-you-go model, users are charged per billing interval for which they use a resource. Cloud providers such as Amazon used to have a billing granularity of $60$~mins, where each whole or partial VM hour was billed as a full hour. But this has drop down to per-second billing over the last few years, sometimes with some minimum time, such as $10$~mins, that is charged. This has a consequence on the sizes of applications that are scheduled on VMs, the temporal granularity of control required by the scheduler, and the price paid. E.g., in \cite{saeid:fgcs:2013}, two different time intervals of $1$~hour and $5$~mins are considered to evaluate the cost of scheduling, and as expected the normalized cost is lower when considering the shorter billing interval. Billing models for edge and fog resources are still evolutionary and there are not many commercial deployments that exist. They may under go a similar pricing evolution as cloud, over time. \ssec{Network Pricing} While the pricing models above focus on compute resources, the cost of network bandwidth into and out of a resource layer may be charged, say, for GigaBytes of data transferred. This can be between Edge-Fog, Fog-Cloud, Edge-Cloud, or between resources in the same layer. Network pricing can either be \textit{symmetric} or \textit{asymmetric}. In the former, the price for both moving data in and out of a resource layer is charged equally, while in the latter the bandwidth charges are different based on the direction. Often in cloud data centers, data-in and intra-data center bandwidth are kept free to encourage hosting data in the cloud. These impact the costs for moving input/output data to/from the application on the cloud and the user's machine, as well as decisions regarding using captive off-cloud resources that require migrating application state over the network. If edge and fog are deployed by the same provider or are a part of the same private network, such as a WiFi access point, then there may be no pricing costs for the network usage~\cite{simmhan2018fog}. The data transfer within a layer and between these layers will be free. However, if edge and fog are part of different networks or the capacity of a constrained network is being saturated, then the data transfers may be chargeable. Also, connectivity among edge devices on different networks may be through gateways and proxies present on the fog or the cloud, to account for firewalls and network visibility. There can be additional charges for such redirection. Network pricing between edge or fog and the cloud layer is dependent on the deployment scenario. E.g., edge/fog can be connected to the cloud with a broadband connection or 4G network which the local ISP may charge for. \ssec{Energy pricing} The \emph{energy profile} can influence the capability and availability of some resources~\cite{varshney2017icfec}. Cloud data centers reduce their energy footprint, but to limit operational costs~\cite{bittencourt:pgcic:2015}. The fog is expected to run off grid power and, like the cloud, be energy conscious to lower pricing~\cite{vaquero2014finding,Loke2015TheIO,dasterdi:corr:2016}. But there may be remote places where the fog runs on renewables like solar, when energy-aware usage is a key goal. Edge devices are often concerned with battery life, and the choice of using specific edge features can depend on the current battery level~\cite{mishra:iot:2015}. While resource providers usually include energy costs as part of the operational cost of a resource when pricing it, it may be possible to bill the energy costs separately based on the power consumed by an application. Alternatively, energy usage may be an application constraint or optimization specification when they run on edge and fog resources~\cite{dasterdi:corr:2016,Bonomi2014}. \ssec{Price to performance ratio} Trade-off between resource performance and its price is important while selecting a resource. Clouds leverage economies of scale and usually have the lowest operational cost per resource unit~\cite{varshney2017icfec}. The elastic nature of VMs means that cloud providers attempt to raise prices linearly with the VM size, but the performance of larger VMs may be super-linear due to reduced network latency and resource contention on the same host. Scheduling algorithms can exploit these size differences~\cite{bots-on-ondemand-vm-2}, normalize price to performance~\cite{sakellariou:coregrid:2007}, or leverage pricing arbitrage on spot VMs~\cite{chu:ipdps:2014}. Prices of edge and fog resources are dependent on the deployment scenario. The economies of scales will come into play if fog deployments are done at large scales. Consumer edge devices have lower capital costs due to their mass production, and zero operational costs if maintained by the user. However, fog/edge resources in the field, such as for IoT, may have higher operational costs due to maintenance and hence higher price to performance. \subsubsection{Other System Characteristics}\label{sec:tax:sys:char} Besides resource pricing, types and sizes, several other resource characteristics impact the design of scheduling algorithms (Fig.~\ref{fig:tax:sys:vm-char}), as we discuss below. \begin{figure}[t] \centering \includegraphics[width=0.85\columnwidth]{figures/system-characteristics.pdf} \caption{Taxonomy of other system characteristics of resources } \label{fig:tax:sys:vm-char} \end{figure} \ssec{Acquisition lag} It might take some time for a resource to be ready for use after it is requested by a user. This delay varies with the type of resource requested and can affect the performance adversely if the scheduling algorithm frequently instantiates and switches between resources~\cite{malawski:sc:2012}. Cloud VMs take 10's of seconds or minutes to be provisioned, booted up, and ready for use by the end-user, and this can vary with the number of VMs requested~\cite{iosup:ccgrid:2011}. Cloud scheduling algorithms may explicitly consider this lag in their planning ~\cite{chu:ipdps:2014,mao:sc:2011}. Edge or fog resources that run on bare-metal or on containers avoid the bootup time of hypervisor-based VMs, but may not always have adequate on-demand capacity. This can cause queuing delays which add to the acquisition time. Some scheduling algorithms may be able to plan deferred acquisition (or advanced reservation) where a slot is assigned for the execution of a task on a resource at some later point of time, and is available for the task with no lag at that time. \ssec{Performance variations} Virtualized resources may not offer deterministic performance in terms of execution and data transfer time. These variations are often due to multi-tenancy where VMs collocated on the same host compete for resources or due to fabric management overheads~\cite{iosup:ccgrid:2011}. This can occur in containers too as the resource sandboxing is done by the OS and may not be as effective as hardware virtualization~\cite{violet}. These can cause the expected and observed makespan of the workflow to diverge by as much as $30\%$, and hence affect the performance of static schedules~\cite{jackson:cloudcom:2010}. Some scheduling algorithms consider performance variations as a first-class characteristic when allocating resources on the cloud~\cite{calheiros:tpds:2014,rodriguez:tcc:2014,poola:iccs:2014,chen:2015,kumbhare:ccgrid:2014}. \ssec{Multi-tenancy} Multi-tenancy allows different users to run their applications on the same host resource~\cite{simmhan2018fog}. The tenants may be separated from each other by VMs, containers, platforms, or not at all. Besides causing performance variations as mentioned above, these also impact the security and privacy of the applications and the data they process ~\cite{vaquero2014finding,dastjerdi:computer:2016}. Also, edge and fog devices may not be physically secured like a cloud data center, adding to the attack surface ~\cite{chiang-2016}. Containerization offers less sandboxing between applications than virtualization, and data and applications in the fog and edge operate within a mix of trusted and untrusted zones~\cite{lopez-2015,Bonomi2014}. This can affect the scheduling of sensitive tasks in an application to be limited to trusted resources. \ssec{Failures}\label{failures} Cloud resources are prone to occasional failures, which may happen due to disk and memory module failures, transient errors in network, cloud fabric and hypervisor failures, and power issues~\cite{Vishwanath:socc:2010}. These failures are rare, with commercial providers promising a monthly uptime of at least 99.95\%. However, such infrequent failures can still affect the execution of mission-critical applications adversely, with some algorithms addressing such situations. Clouds being more centralized are single points of failures, but offer redundancy zones and alternate data centers. The wide area distributed nature of edge and fog resources increases their failure surface further~\cite{varshney2017icfec}. There is a higher chance of an edge device or fog server failing, their battery draining, or their network link dropping, and resiliency may need to be built into the scheduling strategy~\cite{madsen2013reliability}. \ssec{Availability}\label{availability} Immediate availability of resources is a key feature of public clouds. While on-demand VMs have seemingly infinite availability, these are in practice limited to about $1000$~VMs per customer~\footnote{https://aws.amazon.com/ec2/faqs/\#How\_many\_instances\_can\_I\_run\_in\_Amazon\_EC2},\footnote{https://azure.microsoft.com/en-in/documentation/articles/azure-subscription-service-limits}. However, during periods of high demand, it is possible that a specific type of VM instance in a specific data center may not be available. Availability for pre-emptible VMs is naturally intermittent, while reserved instances offer guaranteed availability. Edge and fog resources may become unavailable due to transient network failures or a discharged battery, but be back online eventually (as opposed to a failure)~\cite{varshney2017icfec,shi2012serendipity}. This can cause a transient loss of access to data or compute on the edge or fog. Application running across all three resources may be affected by the weakest link. \subsection{Application Model} \label{sec:tax:app} A \emph{scheduling unit} is the unit of application submitted by the user for resource allocation on the abstraction layers, along with QoS requirements. The application model we discuss here defines the constituent members of this scheduling unit, how it arrives, and when it is scheduled, as categorized in Fig.~\ref{fig:tax:app}. The scheduling algorithm may itself use a coarser or a finer granularity of scheduling. Also, the scheduling unit can have specific characteristics which help decide the resource mapping and techniques for fault tolerance. \begin{figure}[t] \centering \includegraphics[width=0.9\columnwidth]{figures/application-model.pdf} \caption{Taxonomy of application model} \label{fig:tax:app} \end{figure} \begin{figure}[t] \centering \includegraphics[width=0.9\columnwidth]{figures/structure.pdf} \caption{Taxonomy of structure of scheduling unit} \label{fig:tax:app:unit} \end{figure} \subsubsection{Structure of Scheduling Unit} The execution environment offered by edge, fog and cloud is inherently distributed, and the application space is vast~\cite{varshney2017icfec}. There are many application definitions in use, such as control flows, data flows, and event-driven models~\cite{simmhan2008}. Latency sensitive applications may prefer an event-driven model that reacts rapidly to changing situations~\cite{yi:mobidata:2015}. Events streams are also light-weight~\cite{stojmenovic:fedcsis:2014}. An application unit can have different structures (Fig.~\ref{fig:tax:app:unit}). \ssec{DAG} Workflows, represented as a \textit{Directed acyclic graph (DAG)}, are popular for capturing flow dependencies in complex distributed applications, and are widely used as a scheduling unit provided by the user for cloud, fog and edge computing~\cite{shi2012serendipity}. A workflow DAG is a graph \textit{G=(T,E)}, where $T$ is the set of task vertices, each of which form an \emph{atomic unit} of scheduling, and $E$ is a set of control or data dependency edges between tasks. A single workflow can consist of one, a few, or thousands of tasks. Fig.\ref{fig:DAG} shows a sample workflow with seven tasks and nine dependency edges. The number on each edge indicates the data size between the corresponding tasks, say, in MegaBytes. The dependencies can be used to identify the order of execution of the tasks. Workflows also offer additional information to guide their scheduling, such as the \emph{execution time} for each task on a standard resource or on each resource size~\cite{calheiros:tpds:2014,saeid:fgcs:2013}, or the \emph{number of instructions} required by that task~\cite{poola:iccs:2014}. The edges may be annotated with the \emph{size of the data} transferred between the tasks to account for network transfer time and cost~\cite{sakellariou:coregrid:2007,topcuoglu:tpds:2002,rodriguez:tcc:2014}. The data flowing between tasks may be based on \emph{streams, micro-batches or files}. The ability to define specialized data structures, compression and transport mechanisms for distinct stream types such as video may be necessary too. \emph{State} associated with a task offers a context for execution, and needs to migrate across resources~\cite{bittencourt:pgcic:2015,varshney2017icfec}. Tasks may also use \emph{location-awareness} or resource context in determining actions ~\cite{Loke2015TheIO}. \ssec{Task} An application may be monolithic, specified as a single task. Such as task degenerates to a singleton DAG. There are many application scheduling algorithms that limit themselves to scheduling just tasks rather than DAGs~\cite{chu:ipdps:2014,varshney:tpds:2018,voorsluys:aina:2012}. For the purposes of the scheduler, a task structure is an opaque logic unit that is the smallest atomic unit of scheduling with no other task dependencies. \begin{figure}[t] \centering \includegraphics[width=0.9\columnwidth]{figures/mode-of-submission.pdf} \caption{Taxonomy of number of scheduling units and their modes of submission} \label{fig:tax:app:mode:categories} \end{figure} \begin{figure*} \centering \subfloat[A sample workflow DAG]{\qquad\qquad\includegraphics[height=0.15\textheight]{figures/DAG.pdf}\label{fig:DAG}\qquad\qquad}~~ \subfloat[A sample Bag of Tasks with 35 tasks]{\qquad\qquad\includegraphics[height=0.12\textheight]{figures/bot.pdf}\label{fig:bot}\qquad\qquad}\\ \subfloat[A sample Bag of DAGs with 5 DAGs]{\qquad\qquad\includegraphics[height=0.12\textheight]{figures/bow.pdf}\label{fig:bow}\qquad\qquad}~~ \subfloat[A sample Bag of Tasks and DAGs]{\qquad\qquad\includegraphics[height=0.12\textheight]{figures/botw.pdf}\label{fig:botw}\qquad\qquad} \caption{Types of scheduling units. Fig.~\ref{fig:bot},~\ref{fig:bow} are examples of homogeneous scheduling units. Fig.~\ref{fig:botw} is an example of heterogeneous scheduling units } \label{fig:bags} \end{figure*} \subsubsection{Mode of Submission} Besides the unit of scheduling provided by the user, schedulers themselves may schedule individual or multiple units at a time, as shown in Fig.~\ref{fig:tax:app:mode:categories}. A user may provide a \emph{single} scheduling unit (e.g., DAG, task), whose QoS requirements are independently specified and the scheduler schedules just this single unit. On the other hand, users may provide a \emph{set or series} of units, with associated requirements, and the scheduler needs to meet the QoS across these \emph{multiple} scheduling units. These can further be classified as \emph{homogeneous}, where all the units have the same structure, as illustrated in Figs.~\ref{fig:bot} and \ref{fig:bow}, or \emph{heterogeneous} where units can have a mix of DAGs and tasks, as seen in Fig.~\ref{fig:botw}. This distinction helps in generating more efficient schedules. Heterogeneous scheduling units, while intuitive, are less common in existing literature. \cite{wu:2013}, for example, consider both tasks of DAGs and individual tasks while generating mapping between the tasks and VMs. Further, when multiple units are submitted for scheduling, all units may arrive at once as a \emph{batch} or may arrive over time, in a \emph{transactional} model, as shown in Fig.~\ref{fig:tax:app:mode}. This \emph{interval of submission} decides the information available to the scheduling algorithm. E.g., in a batch mode, the resource needs and QoS for all units can be used to decide a ``globally optimal'' schedule. But if the units arrive continuously, the scheduler may take individual decisions which can affect the effectiveness of the schedule of future units. Typically, a batch has a shared QoS requirement defined on it, rather than individual QoS for each unit within. A batch may also be called a \emph{bag} if there is no specific order in which the units need to be processed. \emph{Ensembles} are a special type of homogeneous batch where all DAGs have a similar or the same structure, but different parameters (e.g., a parameter sweep), number of tasks or task sizes~\cite{Callaghan:2011:MHS:2020806.2020814,5217932}. A \textit{bag of tasks (BoT)} consists of a homogeneous batch of tasks which can be executed in any order. BoTs can achieve a high degree of task parallelism and efficiency across VMs and devices since they do not have inter-dependencies~\cite{abramson:ipdps:2000,bots-on-ondemand-vm-2,varshney:tpds:2018}. A transactional mode is common when multiple users share the same application deployed on a resource (e.g., FaaS), or a stream of micro-batches arrive from an input source for processing by the application. Since requests arrive continuously, future workloads are hard to predict and resources needs to be dynamically allocated and deallocated ~\cite{zhou:tcc:2014,mao:sc:2011,maheswaran:hcw:1999,ghosh2018adaptive}. \begin{figure} \centering \includegraphics[width=0.9\columnwidth]{figures/granularity-of-scheduling.pdf} \caption{Taxonomy of granularity of scheduling considered by the scheduling algorithm} \label{fig:tax:app:gran} \end{figure} \begin{figure*} \centering \subfloat[Batch mode of submission]{ ~\includegraphics[width=0.7\textwidth]{figures/batch-mode.pdf} \label{fig:tax:app:mode:batch} }\\ \subfloat[Transactional mode of submission]{ \includegraphics[width=0.7\textwidth]{figures/transactional-mode.pdf} \label{fig:tax:app:mode:transactional} }\\ \caption{The top illustrates a user submitting 10 scheduling units in a batch mode, while the bottom shows submission of 10 scheduling units in a transactional mode.} \label{fig:tax:app:mode} \end{figure*} \subsubsection{Granularity of Scheduling} \ysnoted{CSUR Reviewer: \emph{``In page 13, granularity of scheduling (" how the algorithm processes the scheduling units after the user submits them") is proposed as a sub-division of application model. Again, it has nothing to do wit the application model and it seems belongs to the scheduling methods.''} This is a fair point. Should this move to Sec 3.4.x?} The taxonomy for granularity of scheduling is shown in Fig.~\ref{fig:tax:app:gran}, and it identifies the various ways in which an algorithm processes the scheduling units after the user submits them. \emph{Single} unit of scheduling means that the schedule is generated for one unit without considering other units which may be present, while in case of a \emph{collection} granularity, a schedule is generated for a collection of units as a whole, considering the impact of all units within the collection. This granularity of scheduling is related to the mode of submission. The natural choice is to schedule transaction mode of submissions as single units as they arrive, and batch mode of submissions as collections~\cite{mao:sc:2011,oprescu:cloudcom:2010,bots-on-ondemand-vm-2}. That said, it is possible for a scheduler to buffer units in a transactional workload for a certain period of time and generate a schedule for the collection, thereby increasing the resources efficiency, albeit at a higher latency~\cite{zhou:tcc:2014,xu:ispa:2009}. Similarly, if units within a batch do not have any collective QoS specified on them, the scheduler can ``flatten'' these units and consider then individually for scheduling. in~\cite{xu:ispa:2009}, workflows are submitted by the users transactionally, and the ready tasks from the workflows are stored into an ordered queue where the tasks are sorted according to some rules. In ~\cite{skarlat2017towards}, IoT applications arrive at any time but the scheduling is done periodically, for applications which are closer to their deadlines. \subsubsection{Scheduling unit characteristics} \label{sec:tax:app:char} We identify other characteristics of the scheduling unit that can impact the scheduling strategies, particularly under dynamic or failure conditions (Fig.~\ref{fig:tax:app:char}). \ssec{Resubmission} This allows a task (either individually, or as part of a DAG) that has failed to be re-executed completely from the start, without any side-effects. This statelessness or idempotence property is minimally required to ensure fault-tolerance of tasks on unreliable resources~\cite{simmhan:escience:2009}. \ssec{Replication} This feature allows multiple copies of a task to be run simultaneously on different resources, without any side-effect. This can enhance the guarantees for timely completion of a task even if one of the copies fail due to resource loss~\cite{poola:acm:2016,subramanya2015spoton}. This is particularly valuable for pre-emptible cloud resources, or transient or unreliable edge or fog. It can also be used to opportunistically replicate a task on spare (free) resources so that the first to complete wins, and can address resource under-performance~\cite{calheiros:tpds:2014}. \ssec{Checkpointing} This allows the scheduler to save the state for a partially executed task, and resume it from the latest checkpoint to meet deadline constraints. This can also useful when switching resources to improve the cost or time for execution. Checkpointing may require migration of the state to a persistent storage (e.g., a cloud storage service) or a different reliable resource before resumption, since the original device or VM may be transient. Checkpointing is leveraged when scheduling on pre-emptible VMs~\cite{yi2010reducing,jung:2014,chu:ipdps:2014,voorsluys:aina:2012}. On transient edge devices, CloneCloud uses trigger points to snapshot and migrate local state from the edge to its clone on the cloud to resume execution~\cite{chun2011cloneCloud}. \cite{bittencourt:pgcic:2015} migrates the user's data from one Cloudlet to another based on the user mobility, in order to minimize latency~\cite{varshney2017icfec}. The \emph{frequency of checkpointing} is important. It balances the progress lost after the last checkpoint when a resource fails with the time and cost overhead for taking a checkpoint. Authors have used hourly or user-defined periods~\cite{voorsluys:aina:2012,poola:iccs:2014}, the current and expected spot prices~\cite{chu:ipdps:2014}, the slack time allowed~\cite{subramanya2015spoton}, the mobility and connectivity loss~\cite{shi2012serendipity}, and the job's progress to decide this. Failure handling can be done at \textit{task level, DAG level} and \textit{bag/ensemble level}. However not all techniques can be used at all levels. E.g., while a workflow may be resubmitted upon failure, it may not be possible to resubmit an entire bag or ensemble. Also, while some critical tasks in a DAG may be replicated, it may be impractical to replicate the entire workflow. \begin{figure}[t] \centering \includegraphics[width=0.9\columnwidth]{figures/characteristics.pdf} \caption{Taxonomy of characteristics of scheduling unit} \label{fig:tax:app:char} \end{figure} \ssec{Predictable Runtime} The execution time of a task or DAG is deterministic if there is no uncertainty in its expected runtime on different resource sizes. In real world scenarios, the actual runtime might vary due to performance variations and acquisition lag on edge, fog and cloud resources (\S~\ref{sec:tax:sys:char}). The execution times may also change based on specific input parameters. These uncertainties affect the performance of scheduling algorithms~\cite{mao:sc:2011}. While many scheduling algorithms rely on the accurate runtime for scheduling units being available~\cite{saeid:fgcs:2013} , others use initial estimates for the workflow tasks but later use real-time monitoring to revise the execution time and replan the schedule dynamically~\cite{malawski:sc:2012,oprescu:cloudcom:2010,kim:sp:2011,chen:2015}. \ssec{Data Transfer time} Workflows and tasks may have large input and output data parameters that need to be transferred between tasks, within a DAG, or between a persistent storage location and the input/output interface to a single task or a DAG. These transfers can consume time and cost, both when moved between tasks on different resources in one layer, or between resources on different layers, using local or wide area networks. The application may specify these transfer sizes as part of its definition, and scheduling algorithms may consider them if provided. Data movement also requires storage and network to be available~\cite{varshney2017icfec}. In \cite{calheiros:tpds:2014}, VMs are prematurely started to allow time to transfer in the data for a task scheduled on it. Others include the data transfer time to calculate the length of the critical path in a DAG~\cite{saeid:fgcs:2013,poola:acm:2016}. Some applications that pin the tasks on specific layers, such as the data pre-processing on the edge and analytics on the fog and/or cloud may force additional network latencies~\cite{yannuzzi:camad:2014,bonomi2012Fog}. \begin{figure}[t] \centering \includegraphics[width=0.9\columnwidth]{QOS-Goal.pdf} \caption{Taxonomy of Quality of Service (QoS) Goal of scheduling algorithm} \label{fig:tax:qos} \end{figure} \subsection{Quality of Service (QoS) Goals} \label{sec:tax:qos} The goal of the scheduling algorithm is to determine a schedule that meets specific Quality of Service (QoS) requirements for the given scheduling unit. The QoS is characterized by the type of \textit{constraint} that is imposed, the \emph{guarantees} necessary in achieving the constraints, the \textit{optimization goal} to evaluate the performance, and the scheduling \textit{granularity} at which these requirements have to be met, as shown in the taxonomy tree in Fig.~\ref{fig:tax:qos}. Besides these, Quality of Experience (QoE) has been proposed as an alternative user-centric metric to QoS~\cite{aazam-2016}. It considers the user requirements and perceptions for a service in a particular context, and calculated using \emph{prediction based} or \emph{feedback-based} approaches. As such, this is a recent evolution, and not considered in our review. \subsubsection{QoS Constraint} Constraints indicate that the generated schedule must meet the constraint specification, while an optimization goal determines the performance of the schedule, provided the constraints are met. \emph{time}, \emph{cost}, \emph{energy} and \emph{robustness} are common metrics that are used as constraints and as optimization goals, as seen in Fig.~\ref{fig:tax:qos:constraint}. \ssec{Time} Temporal constraints are specified on the \emph{makespan} of the scheduling unit, which is the time between it being submitted and it completing execution. Makespan includes any queue waiting time and transfer time, besides the actual task execution time. Users can require that the scheduling unit should complete its execution within a given \emph{deadline} from the submission, based on its importance. Related to makespan is the concept of \emph{throughput}, where the number of scheduling units executed per second is the metric. This is relevant for transactional mode of submission where the current or a target rate of requests must be supported. \ssec{Cost} For pay-as-you-go resources, the monetary cost is a key factor, and users may specify a \emph{budget constraint} to bound the cost for running the scheduling unit. Schedulers may migrate applications to reliable but costlier resources when a deadline is imminent, but end up overpaying. So, rather than specify either or both of these constraints independently, users may include a \emph{utility function} that combines both time and cost into a single dimension. The QoS specification can require that this given utility function fall within a certain bound~\cite{Garg:2009:SPA:1862659.1862679,feng2003,saeid:fgcs:2013}. \begin{figure}[t] \centering \includegraphics[width=0.75\columnwidth]{QOS-Constraint.pdf} \caption{Taxonomy of QoS Constraint specified by user} \label{fig:tax:qos:constraint} \end{figure} \ssec{Energy} The overall power consumption by the execution may be specified as a constraint. This may be important for edge devices whose cost may be free but have a limited battery life that should not be exhausted. The energy use may be due to both compute and communication. Edge or fog resources on the field may also run on renewables like solar, which have recharge cycles as well that factor into the energy constraint when scheduling~\cite{ghosh2018adaptive}. \ssec{Spatial} Geo-spatial constraints may be imposed on applications must be processed on a device close to where the data is generated, e.g., on the same device, the same private network, or some geo-fenced region, to ensure privacy and comply with security policies~\cite{yannuzzi:camad:2014}. While the physical security and network access are concerns on edge and fog, the geographical location and legal jurisdiction are factors on the cloud~\cite{brogi2017qos,varshney2017icfec}. These are complementary to resource locality required due to performance. Some applications may also pin specific tasks to specific resources, for physical access to on-board sensors or for access to a specific user or device context~\cite{bittencourt:pgcic:2015,Loke2015TheIO,yi:mobidata:2015}. \ssec{Robustness} Mission critical applications may require guaranteed completion. This may pose a higher burden than just completing within a deadline, and may require that failures not happen at all, rather than just be able to recover from failures within the deadline. Examples include power grid management or traffic signaling ~\cite{stojmenovic:fedcsis:2014,yannuzzi:camad:2014}. \subsubsection{Constraint Guarantee} The constraint specified by the user can be \emph{hard} or \emph{soft} (Fig.~\ref{fig:tax:qos:guarantee}). A hard constraint is inviolable, and its failure is catastrophic for the end-user. \cite{jin2012network} refers to applications with hard time constraints as \emph{inelastic applications}, and they require real-time processing, typically to meet safety of humans, such as in autonomous vehicles~\cite{Bonomi2014}. Soft requirements, on the other hand, need not strictly be achieved and a best effort is sufficient~\cite{mao:sc:2011}. In such cases, penalty functions may be used when the constraints are not satisfied. Such \emph{elastic applications} (different from cloud elasticity) have flexibility in latencies and can perform batch processing, e.g., for analyzing surveys from drones~\cite{Loke2015TheIO,varshney2017icfec}. In scheduling literature, the auto-scaling mechanism in \cite{mao:sc:2011} considers soft deadlines for the workflows while RTBA~\cite{chu:ipdps:2014} enforces hard deadlines. LOSS and GAIN use hard budget constraint to find a schedule that gives the shortest makespan~\cite{sakellariou:coregrid:2007}. \begin{figure}[t] \centering \includegraphics[width=0.75\columnwidth]{Constraint-Guarantees.pdf} \caption{Taxonomy of Constraint Guarantees specified by user} \label{fig:tax:qos:guarantee} \end{figure} \subsubsection{Optimization Goal} The QoS optimization goal attempts to minimize or maximize an \emph{objective function} for the application's schedule, as shown in Fig.~\ref{fig:tax:qos:goal}. The metric for the objective function is similar to the ones for the QoS constraint, such as the makespan, throughput, monetary cost, energy, utilization, faults, or a functional combination of these. \ysnoted{CSUR Reviewer: \emph{``In page 18, I think dividing Optimization Goals to maximization and minimization is not interesting, because every optimization problem in the world belongs to one of these categories. Maybe it is better to divide Optimization Goals to the criteria such as makespan, throughput and ...''} One can argue both ways...Maybe we need both dimensions: makespan, throughput, monetary cost, energy, faults, utilization} \ssec{Minimization} Typically, the makespan, the cost or energy consumption, or the number of task failures are used as the objective function when minimizing it. A deadline constrained application may attempt to minimize the cost, with a number of such scheduling algorithms available~\cite{saeid:fgcs:2013,rodriguez:tcc:2014,mao:sc:2011,zhou:tcc:2014,poola:acm:2016,chu:ipdps:2014}. Similarly, under a budget constraint, the makepsan may be the minimization goal~\cite{sakellariou:coregrid:2007,bots-on-ondemand-vm-2}. Others may lack a constraint, and only aim to minimize, say, the makespan, the energy consumption, or both time and cost~\cite{topcuoglu:tpds:2002,hong:mcc:2013,shi2012serendipity,chun2011cloneCloud,deng2016optimal,ghosh2018adaptive,wu:2013,fard:tpds:2013}. \ssec{Maximization} Common objective metrics used when maximizing include the application throughput and the utilization of resources.~\cite{skarlatprovisioning, skarlat2017towards} maximize the utilization of cheap fog resources by trying to place more applications on it instead of the cloud to reduce the monetary cost. \cite{wang:ijcsns:2006} schedules BoTs to maximize the survivability given a deadline constraint, with task priorities used as a proxy for user-specific maximization goals. \cite{malawski:sc:2012} maximizes the number of high-priority workflows from an ensemble that complete, given a fixed budget and deadline constraint. \ssec{Neither} It is also possible that no optimization goal is specified. In \cite{calheiros:tpds:2014}, the user specifies a preferred deadline and a variable budget, and the goal is to meet the soft deadlines of workflows. Kushwaha, et al.~\cite{kushwaha:ccem:2014} analyze the trade-offs between cost savings over fixed price VMs and resilience when tasks are run on spot VMs. In~\cite{brogi2017qos}, users specify the hardware, software, bandwidth and latency requirements for tasks, and aim to enumerate all valid deployments on the fog and cloud. \begin{figure}[t] \centering \includegraphics[width=0.85\columnwidth]{optimization-goals.pdf} \caption{Taxonomy of Optimization Goals of scheduling algorithms} \label{fig:tax:qos:goal} \end{figure} \subsubsection{Granularity} The QoS optimization goals and constraints can be specified at various granularities, with the default being at the granularity of the single scheduling unit or the batch, depending on the mode of submission. However, other variations in specifying the granularity of constraints and optimizations exist as well, as seen in Fig.~\ref{fig:tax:qos:gran}. \ssec{DAG} Placing the QoS on the DAG means that it has to be met for the DAG as a whole without regard to the QoS for individual tasks. In such cases, the constraints and the optimization goals are specified at the same granularity~\cite{rodriguez:tcc:2014,poola:acm:2016,saeid:fgcs:2013}. However, these may be different as well. E.g., the makespan constraint may be specified at the DAG level, but the goal of minimizing cost specified for a \emph{batch} of DAGs~\cite{zhou:tcc:2014,mao:sc:2011,skarlat2017towards}. When constraints are specified for a DAG, the tasks lying on its critical path are essential to manage the makespan of the workflow. Scheduling algorithms may estimate and assign sub-deadlines for each task to decide their mapping to a suitable resource, with tasks in the critical path having the least flexibility. E.g., the IC-PCPD2 algorithm distributes the sub-deadline of a path in a DAG to each task in the path, in proportion to its minimum execution time~\cite{saeid:fgcs:2013} while~\cite{liu:hpca:2010} uses the average execution time. Sub-deadlines can be used to select the best resource that can execute the task within its sub-deadline. In Serendipity~\cite{shi2012serendipity}, sub-deadlines on each task are assigned to minimize the overall time and the energy consumed for executing the DAGs. \ssec{Batch} QoS can also be specified on a batch of scheduling units, be they a Bag of Tasks or an ensemble of workflows. The constraints and/or goals have to be met for the entire collection, without regard to individual units. E.g., Varshney and Simmhan~\cite{varshney:tpds:2018} define a deadline constraint and a cost minimization goal to schedule a Bag of Tasks executing on pre-emptible and on-demand VMs. It is possible that the scheduler may not compute the sub-constraints for the individual units of the batch~\cite{malawski:sc:2012}. In~\cite{deng2016optimal}, a delay constraint is specified for the batch of task and the goal is to minimize the overall power consumption on fog resources. ~\cite{skarlatprovisioning} periodically schedule a batch of tasks with the goals of minimizing the makespan for the batch and maximizing the resource utilization. \ssec{Task} The user may also specify goals or constraints for individual tasks, be they tasks of a DAG, tasks within a bag or single tasks~\cite{chu:ipdps:2014,kushwaha:ccem:2014,voorsluys:aina:2012}. It is also possible for users to indicate the constraints and optimization goals individually for different stages of the DAG. In such cases, different algorithms can be used to schedule the tasks of different stages according to the constraints and goal at each stage~\cite{diaz:tcc:2015} \begin{figure}[t] \centering \includegraphics[width=0.85\columnwidth]{granularity.pdf} \caption{Taxonomy of Granularity of QoS Goals} \label{fig:tax:qos:gran} \end{figure} \subsection{Scheduling Algorithms} \label{sec:tax:algo} Given the edge, fog and cloud resource environment, and the application model and QoS requirements, the scheduling algorithm is designed to schedule the application onto the resources to meet the QoS goal and meet the constraints. Solving this scheduling problem is computationally complex for non-trivial problem sizes. As a result, there is a large body of literature on techniques and algorithms to solve this problem, often to get an approximate rather than an optimal solution. Existing surveys classify scheduling algorithms based on various techniques that they employ, and these determine the quality of the schedule that is generated, and the time taken to generate the same~\cite{wu:2015,yu:buyya:survey:grid,huang:jsw:2013,zhan:csur:2015,liu:ccgrid:2014}. As such, there are no intrinsic reasons why these prior classifications, as illustrated in Fig.~\ref{fig:tax:algo}, are not equally applicable to application scheduling on edge, fog and clouds. However, having multiple resource layers across a wide area network also brings in the opportunity for delegating the scheduling hierarchically (e.g., cloud delegating a subset of the scheduling unit to a fog for scheduling on itself and its neighboring edges)~\cite{yannuzzi:camad:2014,stojmenovic:fedcsis:2014,yi:mobidata:2015,hong:mcc:2013}, or to make federated decisions~\cite{vaquero2014finding}, rather than just a centralized decision. We examine these and, to be holistic, also summarize outcomes from prior taxonomies in this section; we refer readers to these external sources for a detailed review of the algorithmic strategies. \subsubsection{Scheduling Techniques}\label{sec:tax:algo:tech} Finding the \emph{optimal schedule} is a combinatorial optimization problem and a variation of the classic ``job shop scheduling'' problem, the solution to which is NP Hard~\cite{yamada:1997:gaes}. \emph{Brute force algorithms} try all possible mappings of the scheduling units to the compute resources to arrive at a globally optimal solution while meeting the constraints. E.g., a simple case of optimally placing $M$ tasks to $R$ resources has a brute force computational complexity of $\mathcal{O}(R^M)$. This is intractable for practical applications with $10-100's$ of tasks and resources~\cite{Convolbo2016,ghosh-2018}. \begin{figure}[t] \centering \includegraphics[width=0.99\columnwidth]{algorithms.pdf} \caption{Taxonomy of the techniques used and types of schedules generated by scheduling algorithms} \label{fig:tax:algo} \end{figure} In some cases, one can stop the brute force search once a ``good enough'' solution is found and thus bound the cost of the algorithm, while not getting an optimal solution. There are also approaches that use \emph{dynamic programming (DP)}, wherein the original scheduling problem is decomposed into a set of \emph{overlapping} sub-problems, each of which can be solved optimally in tractable time. Then the solutions to the sub-problems are directly reused using ``memo\-iza\-tion'' when exploring the search space. E.g., RTBA uses DP to construct a strategy table for a task of a given size and deadline constraint, which is used to schedule all tasks that fall within this size and deadline~\cite{chu:ipdps:2014}. This has a time complexity of $\mathcal{O}(C^2T_{dl})$ where $T_{dl}$ is the deadline and $C$ is the compute time, and this is faster than the brute force approach which has a complexity of $\mathcal{O}(|A|^{T_{dl}})$, where $A$ is the set of possible scheduling actions. As we see, DP gives optimal solutions much faster than brute force. But it is still unlikely to be fast enough for practical use in online scheduling. \emph{Divide and conquer algorithms} partition the scheduling problem into smaller \emph{non-overlapping} sub-problems, and solve these sub-problems recursively. The solutions to the sub-problems (tasks) are combined into a solution to the original problem. In practice, such optimal solutions are used for small problem that then contribute to an overall approximate solution.~\cite{deng2016optimal} decomposed the overall problem of distributing a workload among fog and cloud resources into sub-problems using an approximate, and solve these sub-problems individually using different optimization techniques. Alternatively, the optimal solution, while impractical, offers a theoretical baseline against which to empirically compare their proposed approximate solution~\cite{Convolbo2016,chu:ipdps:2014}. Consequently, scheduling problems are often solved using \emph{sub-optimal} algorithms that resort to heuristics or meta-heuristics that, in practice, come close to optimal solutions but within a reasonable time. \emph{Greedy algorithms} select the most promising option from the solution space at any given stage. It makes a series of locally optimal choices with the expectation of finding the global optimum. Greedy DAG scheduling heuristics such as HEFT schedule DAGs over Grid resources~\cite{topcuoglu:tpds:2002}, and have been reused for scheduling on heterogeneous cloud VMs to give short makespan~\cite{zheng:jgc:2013,lin:cloud:2011}. HEFT has a complexity of $\mathcal{O}(E.R)$ where $E$ is the number of edges in the DAG and $R$ is the number of resources. These have also been extended to include cost/time budgets/goals using functions like GAIN and LOSS ~\cite{sakellariou:coregrid:2007,mao:sc:2011,diaz:tcc:2015}. There are greedy algorithms for scheduling BoTs on cloud resources~\cite{bots-on-ondemand-vm-1} and DAG scheduling on edge devices~\cite{shi2012serendipity,ghosh2018adaptive,brogi2017qos}. They use heuristics such as predicting the proximity between mobile edge devices for deadline planning, prioritizing tasks with the most resource constraints, and incrementally co-locating tasks on the same resource to avoid network latency. More sophisticated heuristics have also been proposed, such as the ToF planner and AutoBoT that uses a greedy approach to minimize the monetary cost for executing a bag of workflows or tasks on clouds~\cite{zhou:tcc:2014, varshney:tpds:2018}. Similarly, \emph{backtracking} algorithms follow one of many possible alternatives, and backtrack if it does not look promising~\cite{chen:2015,brogi2017qos}. Workflow scheduling problems are often reduced to \emph{Integer Linear Programming (ILP)} and its mixed variant~\cite{chun2011cloneCloud}. E.g., CloneCloud~\cite{chun2011cloneCloud} uses ILP to find partition points between edge and cloud in the application which minimize the overall execution time or energy consumption. While standard techniques exist to provide optimal solutions to ILP problems, they can only be used for small size problems due to their prohibitive computational cost. So, heuristics are used to solve these ILP problems as well~\cite{diaz:tcc:2015,jung:iscc:2011,malawski:sp:2015}. \emph{Meta-heuristics} are a class of high level guidelines that can be used to define heuristics to solve a wide class of optimization problems~\cite{blum:2003:csur}. Specific scheduling problems are refactored to fit the higher-order problem after which the heuristic guidelines can be applied to explore the solution space. Meta-heuristics have been categorized into trajectory-based and population-based methods, with \emph{simulated annealing} falling in the former category, and \emph{genetic algorithm (GA)}, \emph{particle swarm optimization (PSO)} and \emph{ant colony optimization (ACO)} featuring in the latter method. E.g., in \cite{rodriguez:tcc:2014}, a deadline-constrained workflow scheduling on clouds is mapped to a PSO problem. A particle's coordinates encode the mapping between the task and a resource, and the dimension of the particle matches the number of tasks. The fitness function for the PSO, which has to be minimized, is the total execution cost, and the schedule is generated by solving this PSO problem with a complexity of $\mathcal{O}(P.M^2.R)$ per iteration, where \textit{P} is the number of particles, \textit{M} is the number of tasks and \textit{R} is the number of resources. In~\cite{ghosh-2018}, a DAG scheduling problem across edge and cloud has been reduced to GA formulation. Each chromosome represents a mapping function from a task to an available edge or cloud resource. The chromosome which gives the minimum makespan, among all the solutions that do not violate compute and energy constraints, is selected from across generations. Scheduling heuristics are also tuned for operating across resource abstraction layers, such as tasks across mobile edge and cloud layers~\cite{chun2011cloneCloud}, or DAGs across fog and cloud~\cite{skarlat2017towards}. Some also use locality of tasks to layers. Bittencourt, et al.~\cite{bittencourt2017mobility} schedule DAGs that are submitted to a Cloudlet, and scheduler can execute it on the ``local'' or a remote fog, and/or cloud resources. Likewise, Ghosh and Simmhan~\cite{ghosh2018adaptive} schedule transactional DAGs on edge and cloud resources, but pin the source tasks to the edge and the sink tasks to the cloud. \subsubsection{Type of Schedule} \label{sec:tax:algo:sched} The scheduling algorithm can be designed as a \emph{static} (offline) algorithm that is run once when the scheduling unit arrives, or a \emph{dynamic} (online) algorithm that actively decides the schedule based on the current conditions through the lifetime of the unit. \ssec{Static schedule} In a static approach, the mapping from the scheduling unit to resource(s) is generated once before the unit starts, based on the information about other units and the resources available to the scheduling algorithm \emph{a priori}. This allocation is retained for the lifetime of the task or DAG, and does not respond to changes in the resources or tasks at runtime. It assumes that the prior knowledge is perfect. It also does not make use of checkpointing and resubmission. Abrishami, et al.~\cite{saeid:fgcs:2013} generate an offline schedule for a deadline constrained DAG. It assigns a partial deadline to tasks in the critical path of the DAG, along with their \emph{Earliest Start Time (EST)}, \emph{Earliest Finish Time (EFT)}, and \emph{Latest Finish Time (LFT)} ~\cite{topcuoglu:tpds:2002}. The algorithm then recursively assigns all the tasks on the path to a single VM which can finish each task before its LFT, with the minimum price. SPSS also uses static scheduling to schedule an ensemble of workflows~\cite{malawski:sc:2012}. They use \emph{admission control} to prevent scheduling of workflows which cannot complete within the deadline and budget constraints. While static algorithms do not consider runtime dynamism, \cite{calheiros:tpds:2014} mitigates the effects of variations in performance using task replication. It uses the budget surplus and the idle slots in the allocated resources, after performing a static schedule, for task replication. This increases the chances of the deadline being met. Static scheduling is also possible for a transactional mode of submission. Many cloud providers including Amazon, Google and Azure offer users \emph{rule based auto-scaling} for transactional tasks. Here, incoming tasks are routed, typically, in a round-robin manner to a pool of active VMs based on user rules that decide when and how to increase or decrease the number of VMs in this pool based on their utilization. These can efficiently handle the dynamic task-based transactional workloads if the user is able to select the right threshold value~\cite{mao:sc:2011,nathan:icac:2013}. Similarly, sensor and event based applications have a dynamic workload pattern that schedulers adapt to on edge and fog resources~\cite{hong:mcc:2013,ghosh2018adaptive}. However, some auto-scaling mechanisms use future workload prediction by monitoring current resource utilization to perform proactive auto-scaling~\cite{morais:ccgrid:2013}. Static schedules are useful when the workload is known in advance and the performance of resources is deterministic. Real-time applications, those with a closed control loop, and those sensitive to mobility require careful design. These may prefer a static schedule to ensure determinism, preclude the use of mobile resources, and/or retain the decision logic in a single resource~\cite{sadeghi:hipc:2016}. However, static planning, exclusively, cannot respond to faults and to dynamism in compute and network performance, acquisition time, and spot prices on edge, fog and cloud resources. These can cause sub-optimal QoS performance or, worse, violation of hard constraints. \ssec{Dynamic schedule} Dynamic algorithms use runtime knowledge about the resource performance and application behavior, besides static knowledge, to make scheduling decisions at the start and during the lifetime of the scheduling unit. This information helps them adapt their schedule on the fly to avoid QoS constraint violations, and/or to improve the optimization goals. Dynamic algorithms can either be \emph{just-in-time}, where the scheduling decision for a task in a workflow is made just once before the task's execution (but after the DAG itself has started executing), or \emph{fully dynamic} where running tasks can be remapped from one resource to another during its execution. DPDS maintains a priority queue of ready tasks from a batch of DAGs, ordered by the workflow priority, that are scheduled \emph{just-in-time}~\cite{malawski:sc:2012}. Whenever a VM is idle, the ready task at the head of the queue is assigned to it. Once a task completes, other dependent tasks in the DAG which are ready are added to this queue and the scheduling continues. A similar strategy is used for scheduling multiple workflows that are submitted in a transactional mode~\cite{xu:ispa:2009}. The tasks in the queue are mapped just-in-time to the best VM to ensure sub-deadline and sub-budget are not violated. Other just-in-time heuristics schedule workflow tasks onto both spot and on-demand VMs~\cite{poola:iccs:2014}. At runtime, it decides for each ready task whether to schedule it on a spot VM or an on-demand VM based on its \emph{Latest Time to On-demand (LTO)}, i.e., the slack time before which they must be executed, to avoid exceeding the deadline. Tasks that are ready before their LTO are scheduled on spot VMs while ones that arrive after their LTO are mapped to on-demand VMs. Elsewhere, the progress of each task is continuously monitored and if one gets delayed, it is dynamically rearranged and future tasks rescheduled to prevent an increase in the overall makespan of the application~\cite{chen:2015}. RTBA uses a \emph{fully dynamic algorithm} which actively manages the life-cycle of individual tasks on spot and on-demand VMs~\cite{chu:ipdps:2014}. It statically constructs a strategy table, as discussed earlier, and performs dynamic lookups on this table to decide actions based on the current spot price and task progress. The actions can checkpoint and migrate the task, change the bid price, or even pause the task for the bid price to drop. Similarly, CloneCloud~\cite{chun2011cloneCloud} initially builds a partition database for the application, and a partition configuration is selected from this at runtime based on the current resource availability and network conditions. The ToF planner combines both \emph{static and dynamic strategies} to schedule transactional workflows~\cite{zhou:tcc:2014}. It accumulates workflows arriving for a certain time period and statically assigns a provisional set of VMs to their tasks. However, the VM instance itself is only decided (or started) at runtime to enable the reuse of running VMs. Applications that are scheduled on edge and fog resources need to be particularly responsive to resource dynamism that are more acute on these platforms~\cite{varshney2017icfec,shi2012serendipity}. This also requires the runtime capabilities for monitoring to determine when such adaptation is required~\cite{dasterdi:corr:2016}. This may even require \emph{changing the coordination strategy} from, say, centralized to a federated or P2P one. \subsubsection{Algorithm Evaluation}\label{sec:tax:algo:eval} Lastly, we consider how the proposed scheduling algorithm is evaluated for its ability to meet the QoS for the application and system models. Others~\cite{coutinho:2015} already identify some of these categories of evaluations, such as experimental, analytical, simulation and combinations of these. These used in our classification for completeness. Some papers offer both \emph{analytical proofs} and experimental validation to measure the efficiency of their scheduling algorithm~\cite{fard:tpds:2013}. Several others consider only an \emph{empirical evaluation} using real world scientific applications like Cybershake, Genome, LIGO, and Montage~\cite{malawski:sc:2012,saeid:fgcs:2013,poola:iccs:2014,zhou:tcc:2014}, or domain-specific workloads~\cite{riotbench}. For scheduling across edge, fog and cloud, mobile applications such as virus scanning, image search and video analytics have been used for empirical evaluation~\cite{shi2012serendipity,chun2011cloneCloud,khochare:iscocw:2017}. But the predominant choice of validation in literature is limited to \emph{simulations} based on synthetically generated BoTs and DAGs~\cite{bots-on-ondemand-vm-1,lin:cloud:2011,ghosh2018adaptive}. During simulation, various probability distributions can be used to generate synthetic BoTs and to model the arrival rates of tasks in case of transactional mode~\cite{bots-on-ondemand-vm-1,maheswaran:hcw:1999,ghosh2018adaptive,shi2012serendipity}. Random DAG generators are also used to generate DAGs with parameters and distributions to control the number of tasks, number of dependency edges, range of task length, depth and width of DAG, outdegree, and communication to computation ratio~\cite{chen:2015,zeng:aina:2012,wu:2013}. Alternatively, publicly available cloud workloads, such as the Google Cluster Workload also offer the choice of realistic DAG and BoT simulations~\cite{reiss:Cloud:2012,varshney:tpds:2018}. The CloudSim~\cite{calheiros:spe:2011} and iFogSim~\cite{fogsim} simulation frameworks can model application execution on cloud infrastructure, and edge and fog infrastructure respectively, and are often used to evaluate scheduling algorithms~\cite{poola:iccs:2014,malawski:sc:2012,skarlatprovisioning,skarlat2017towards,bittencourt2017mobility}. Many algorithms consider system models that are \emph{realistic}, and similar to those provided by major cloud providers. Amazon AWS is a popular choice here, with many considering different EC2 on-demand VM types, and their prices and configurations in their simulation~\cite{mao:sc:2011,calheiros:tpds:2014,poola:acm:2016}. Some~\cite{ghosh2018adaptive,shi2012serendipity} also use real-world benchmarks and distributions of network and compute performance of edge and cloud resources. Algorithms which use pre-emptible VMs simulate the fluctuation in spot prices using historic spot price data provided by Amazon~\cite{poola:iccs:2014,varshney:tpds:2018}, and to train their price bidding models and expected lifetime estimation models~\cite{chohan:usenix:2010,chu:ipdps:2014}. The acquisition lag for VMs may be based on a distribution of past startup times~\cite{Schad:2010:RMC:1920841.1920902,rodriguez:tcc:2014}, or limited to a constant value~\cite{malawski:sc:2012,mao:sc:2011}. Similarly, the mobility of edge and fog devices can be captured using real-world mobility traces or generated synthetically using mobility models~\cite{shi2012serendipity}.~\cite{hong:mcc:2013} simulate random vehicle motion for a vehicle-to-vehicle streaming application, where each vehicle randomly picks another vehicle to start streaming a video to it. \begin{sidewaystable*} \scriptsize \centering \caption{{\small Classification of Scheduling Algorithms}} \label{tbl:review:1} \begin{tabular}{p{0.7cm}||p{0.7cm}||p{0.95cm}|p{0.6cm}|p{1.5cm}||p{0.65cm}|p{1.1cm}|p{1.9cm}||p{1cm}|p{1cm}|p{0.8cm}||p{1.6cm}|p{1.0cm}|p{2.2cm}} \hline \textbf{Paper} & \multicolumn{4}{c||}{\textbf{System Design}~\S~\ref{sec:tax:sys}} & \multicolumn{3}{c||}{\textbf{Application Model}~\S~\ref{sec:tax:app}} & \multicolumn{3}{c||}{\textbf{Quality of Service}~\S~\ref{sec:tax:qos}} & \multicolumn{3}{c}{\textbf{Algorithm}~\S~\ref{sec:tax:algo}} \\ \hline & Layer$^1$ & Size$^2$ & Price$^3$ & Char.$^4$ & Struct. & Mode$^5$ & Char. & Constr.$^6$ & Goal$^7$ & Gran.$^8$ & Technique & Schedule & Evaluation$^9$ \\ \hline \hline \cite{saeid:fgcs:2013} & C & HT & OD & BI-60,5~min, Linear PPR & DAG & S & Data transfer time & TD/H & MIN(C) & DAG, DAG & Divide and Conquer & Static & S -- \emph{Synthetic DAGs of CyberShake, Epigenomics, LIGO, Montage, SIPHT} \\ \hline \cite{bittencourt:jisa:2011} & C & HT & OFF, OD & BI-60~min & DAG & S & Data transfer time & TD/S & MIN(C) & DAG, DAG & Greedy & Static & S -- \emph{Synthetic DAGs of AIRSN, Chimera, CSTEM, LIGO, Montage, random}; E -- \emph{Image processing application} \\ \hline \cite{calheiros:tpds:2014} & C & HT & OD & BI-60~min, AL, PV & DAG & S & Resubmit, Replicate, Data transfer time & TD/S and CB/H & -- & DAG, DAG & Heuristic & Static & S -- \emph{Synthetic DAGs of Montage, CyberShake, LIGO, SIPHT} \\ \hline \cite{chen:2015} & C & HT & -- & Limited availability & DAG & \{M, HO, T\}/S & Non-deterministic runtime, Data transfer time & TD/S or -- & MAX(O) or MIN(T) & DAG, Batch & Backtracking & Dynamic & S -- \emph{Random DAGs} \\ \hline \cite{chohan:usenix:2010} & C & HO & OD, SP & BI-60~min, NP \emph{(asymm.)} & DAG & S & -- & -- & MIN(T) & --, DAG & Heuristic & Static & E -- \emph{WordCount, Pi, Sort on EC2} \\ \hline \cite{chu:ipdps:2014} & C & OD:HT, SP:HT, OFF:HO & OD, SP, OFF & BI-60~min, NP \emph{(asymm.)}, AL & Task & S & Checkpoint, Migrate, Data transfer time & TD/H & MIN(C) & Task, Task & Dynamic Programming & Dynamic & S -- \emph{Varying length tasks} \\ \hline \cite{fard:tpds:2013} & C & HT & OD & BI \emph{(novel pricing model)}, PV & DAG & S & Data transfer time & -- & MIN(C) and MIN(T) & DAG, DAG & Greedy & Dynamic & H -- \emph{Synthetic WIEN2k DAG, Random DAGs} \\ \hline \multicolumn{14}{l}{$^1$~E: Edge, F: Fog, C: Cloud, M: Spatial mobility} \\ \multicolumn{14}{l}{$^2$~HO: Homogeneous machine sizes, HT: Heterogeneous sizes} \\ \multicolumn{14}{l}{$^3$~OD: On-demand fixed price VMs, SP: Pre-emptible spot/variable price VMs, OFF: Off-Cloud resources, FR: Free Edge/Fog resources}\\ \multicolumn{14}{l}{$^4$~BI: Billing Interval, AL: Acquisition Lag considered, PV: Performance Variations considered, NP: Network Pricing, PPR: different Price to performance ratios considered}\\ \multicolumn{14}{l}{$^5$~S: Single scheduling unit submitted, M: Multiple units; HO: Homogeneous units, HT: Heterogeneous units; B: Batch submission, T: Transactional submission;}\\ \multicolumn{14}{l}{\quad(S): Single granularity of scheduling, /O: Ordered queue, /U: Unordered bag.}\\ \multicolumn{14}{l}{$^6$~TD: Time deadline, CB: Cost budget, E: Energy constraint, S: Spatial constraint /H: Hard constraint, /S: Soft constraint}\\ \multicolumn{14}{l}{$^7$~MIN: Minimize objective function, MAX: Maximize function, (T): Time, (C): Cost, (O): Other.}\\ \multicolumn{14}{l}{$^8$~Gran.: Granularity of QoS constraint, Granularity of QoS Goal}\\ \multicolumn{14}{l}{$^{9}$~A: Analytical, E: Empirical, S: Simulation, H: Hybrid} \\ \end{tabular} \end{sidewaystable*} \begin{sidewaystable*} \centering \scriptsize {\small Table 1. Classification of Scheduling Algorithms \emph{(continued)}}\\ \begin{tabular}{p{0.7cm}||p{0.7cm}||p{0.95cm}|p{0.6cm}|p{1.5cm}||p{0.65cm}|p{1.1cm}|p{1.9cm}||p{1cm}|p{1cm}|p{0.8cm}||p{1.6cm}|p{1.0cm}|p{2.2cm}} \hline \textbf{Paper} & \multicolumn{4}{c||}{\textbf{System Design}~\S~\ref{sec:tax:sys}} & \multicolumn{3}{c||}{\textbf{Application Model}~\S~\ref{sec:tax:app}} & \multicolumn{3}{c||}{\textbf{Quality of Service}~\S~\ref{sec:tax:qos}} & \multicolumn{3}{c}{\textbf{Algorithm}~\S~\ref{sec:tax:algo}} \\ \hline & Layer$^1$ & Size$^2$ & Price$^3$ & Char.$^4$ & Struct. & Mode$^5$ & Char. & Constr.$^6$ & Goal$^7$ & Gran.$^8$ & Technique & Schedule & Evaluation$^9$ \\ \hline \hline \cite{bots-on-ondemand-vm-1} & C & HT & OD & BI-60~min & Task & \{M, HO, B\}/O$^\dagger$; \{M, HO, T\}/S$^\ddagger$ & -- & -- & MIN(T) and MIN(C) & --, Batch (overall BoTs) & Greedy & Dynamic & S -- \emph{Random BoTs} \\ \hline \cite{kim:sp:2011} & C & HT & OFF, OD & BI-60~min, AL, PV, Failures & Task & \{M, HO, T\}/O & Resubmit, Non-deterministic runtime & TD/S or CB/S & MIN(T) or MAX(O) & Batch, Batch & Greedy & Dynamic & E -- \emph{DAG of Reservoir simulation ensemble, Kalman filter on TeraGrid, EC2} \\ \hline \cite{kushwaha:ccem:2014} & C & HT & SP & BI-60~min & Task & S & -- & -- & MIN(C) & --, DAG & Heuristic & Static & S -- \emph{Varying length tasks} \\ \hline \cite{lin:cloud:2011} & C & HT & OD & -- & DAG & S & Data transfer time & -- & MIN(T) & --, DAG & Greedy & Static & S -- \emph{Random DAGs} \\ \hline \cite{liu:hpca:2010} & C & HT & OD & BI-N/A, Linear PPR, Failures, Limited availability & DAG & \{M, HO, B\}/O & Resubmit, Data transfer time & TD/S & MIN(C) & Batch, Batch & Divide and Conquer & Dynamic & S -- \emph{Synthetic DAGs based on practical workflows such as bank cheque workflow processing} \\ \hline \cite{malawski:sc:2012} & C & HO & OD & BI-60~min, AL & DAG & \{M, HO, B\}/O & Non-deterministic runtime & TD/H and CB/H & MAX(O) & Batch, Batch & Heuristic (DPDS, WA-DPDS), Divide and Conquer (SPSS) & Dynamic (DPDS, WA-DPDS), Static (SPSS)& S -- \emph{Synthetic DAGs of CyberShake, Epigenomics, LIGO, Montage, SIPHT} \\ \hline \cite{mao:sc:2011} & C & HT & OD & BI-60~min, AL & DAG & \{M, HO, T\}/S & Non-deterministic runtime & TD/S & MIN(C) & DAG, Batch & Divide and Conquer & Dynamic & S -- \emph{Pipeline, Parallel, Hybrid DAGs} \\ \hline \cite{oprescu:cloudcom:2010} & C & HT & OD & BI-60~min, AL & Task & \{M, HO, B\}/U & Resubmit, Non-deterministic runtime & CB/S & MIN(T) & Batch, Batch & Dynamic Programming & Dynamic & S -- \emph{BoT w/ Normal Distribution} \\ \hline \cite{poola:iccs:2014} & C & OD:HT, SP:HO & OD, SP & BI-60~min, AL, PV & DAG & S & Checkpoint, Data transfer time & TD/S & MIN(C) & DAG, DAG & Heuristic & Dynamic & S -- \emph{Synthetic DAG of LIGO} \\ \hline \cite{poola:acm:2016} & C & HT & OD, SP & BI-60~min, AL, PV, Failures & DAG & S & Resubmit, Replicate, Data transfer time & TD/S & MIN(C) & DAG, DAG & Heuristic & Dynamic & S -- \emph{Synthetic DAG of LIGO}\\ \hline \multicolumn{14}{l}{$^\dagger$~Tasks of a BoT are submitted in a batch and scheduled as an ordered collection}\\ \multicolumn{14}{l}{$^{\ddagger}$~Multiple BoTs are submitted transactionally and each BoT is scheduled as a single unit as soon as it arrives}\\ \end{tabular} \end{sidewaystable*} \begin{sidewaystable*} \centering \scriptsize {\small Table 1. Classification of Scheduling Algorithms \emph{(continued)}}\\ \begin{tabular}{p{0.7cm}||p{0.7cm}||p{0.95cm}|p{0.6cm}|p{1.5cm}||p{0.65cm}|p{1.2cm}|p{1.8cm}||p{1cm}|p{1.4cm}|p{0.8cm}||p{1.6cm}|p{1.0cm}|p{2.2cm}} \hline \textbf{Paper} & \multicolumn{4}{c||}{\textbf{System Design}~\S~\ref{sec:tax:sys}} & \multicolumn{3}{c||}{\textbf{Application Model}~\S~\ref{sec:tax:app}} & \multicolumn{3}{c||}{\textbf{Quality of Service}~\S~\ref{sec:tax:qos}} & \multicolumn{3}{c}{\textbf{Algorithm}~\S~\ref{sec:tax:algo}} \\ \hline & Layer$^1$ & Size$^2$ & Price$^3$ & Char.$^4$ & Struct. & Mode$^5$ & Char. & Constr.$^6$ & Goal$^7$ & Gran.$^8$ & Technique & Schedule & Evaluation$^9$ \\ \hline \hline \cite{rodriguez:tcc:2014} & C & HT & OD & BI-60~min, AL, PV & DAG & S & Non-deterministic runtime, Data transfer time & TD/S & MIN(C) & DAG, DAG & PSO & Static & S -- \emph{DAGs of CyberShake, LIGO, Montage, SIPHT} \\ \hline \cite{subramanya2015spoton} & C & HT & OD, SP & BI-60~min, AL & Task & S & Resubmit, Replicate, Checkpoint, Migrate & -- & MIN(C) and MAX(O) & --, Task & Heuristic & Dynamic & S -- \emph{Random tasks, Google cluster trace on EC2} \\ \hline \cite{bots-on-ondemand-vm-2} & C & HT & OD & BI-60~min, different PPR, AL & Task & \{M, HO, B\}/U & -- & TD/H or CB/H & MIN(C) or MIN(T) & Batch, Batch & Heuristic & Static & S -- \emph{Random DAG} \\ \hline \cite{voorsluys:aina:2012} & C & HT & SP & BI-60~min & Task & \{M, HO, T\}/O & Replicate, Checkpoint, Migrate, Data transfer time & TD/S & MAX(O) and MIN(C) & Task, Batch & Heuristic & Dynamic & S -- \emph{Synthetic tasks based on job stream from LHC Grid} \\ \hline \cite{wu:2013} & C & HT & OD & BI-per unit time, PV w/ bounded randomness, PPR & DAG, Task & Service \{M, HO, T\}/S; Task \{M, HT, T\}/U & -- & TD/H and TB/H & MIN(C) or MIN(T) or (MIN(C) and MIN(T)) & DAG, Batch & Service-- Heuristic; Task-- GA, PSO, ACO & Static+ dynamic & S -- \emph{Random DAGs} \\ \hline \cite{xu:ispa:2009} & C & HT & OD & Limited avail\-abi\-li\-ty & DAG & \{M, HO, T\}/O & -- & TD/S and CB/S & MIN(T) and MIN(C) and MAX(O) & DAG, Batch & Divide and Conquer & Dynamic & S -- \emph{Random DAGs}\\ \hline \cite{zeng:aina:2012} & C & HT & OD & BI-60~min, AL & DAG & S & Data transfer time & CB/H & MIN(T) & DAG, DAG & Greedy & Static & S -- \emph{Random DAGs}\\ \hline \cite{zhou:tcc:2014} & C & HT & OD & BI-60~min & DAG & \{M, HO, T\}/O & Checkpoint & TD/S or CB/S & MIN(C) or MIN(T) & DAG, Batch & Greedy & Static+ dynamic & S -- \emph{Synthetic DAGs of LIGO, Montage on EC2, Rackspace}\\ \hline \end{tabular} \end{sidewaystable*} \begin{sidewaystable*} \centering \scriptsize {\small Table 1. Classification of Scheduling Algorithms \emph{(continued)}}\\ \begin{tabular}{p{0.7cm}||p{0.7cm}||p{0.95cm}|p{0.6cm}|p{1.9cm}||p{0.65cm}|p{1.1cm}|p{1.8cm}||p{1cm}|p{1cm}|p{0.8cm}||p{1.6cm}|p{1.0cm}|p{2.2cm}} \hline \textbf{Paper} & \multicolumn{4}{c||}{\textbf{System Design}~\S~\ref{sec:tax:sys}} & \multicolumn{3}{c||}{\textbf{Application Model}~\S~\ref{sec:tax:app}} & \multicolumn{3}{c||}{\textbf{Quality of Service}~\S~\ref{sec:tax:qos}} & \multicolumn{3}{c}{\textbf{Algorithm}~\S~\ref{sec:tax:algo}} \\ \hline & Layer$^1$ & Size$^2$ & Price$^3$ & Char.$^4$ & Struct. & Mode$^5$ & Char. & Constr.$^6$ & Goal$^7$ & Gran.$^8$ & Technique & Schedule & Evaluation$^9$ \\ \hline \hline \cite{skarlatprovisioning} & F, C & HT & F:FR, C:OD & BI-60~min, F - Limited availability & Task & \{M, HO, B\}/U & Data transfer time & -- & MAX(O) and MIN(T) & --, Batch & Heuristic & Static & S -- Same length tasks \\ \hline \cite{skarlat2017towards} & F, C & HT & F:FR, C:OD & BI-60~min, AL, F - Limited availability & DAG & \{M, HO, T\}/U & Data transfer time & TD/H & MAX(O) & DAG, Batch & ILP & Static & S -- \emph{Sense-process-actuate applications} \\ \hline \cite{deng2016optimal} & F, C & F:HT, C:HO & -- & F,C - Limited availability & Task & \{M, HO, T\}/U & Data transfer time & TD/H & MIN(E) & Batch, Batch & Approximation & Static & S -- \emph{Varying number of tasks}\\ \hline \cite{ghosh-2018} & E, C & HT & -- & E,C - Limited availability & DAG & \{S, HT, B\} & Data transfer, Streaming I/P, Src/Sink pinned & E/H & MIN(T) & DAG & GA, Brute Force & Static & S -- \emph{Real bench\-marks, CEP queries, Random DAGs}\\ \hline \cite{ghosh2018adaptive} & E, C & HT & -- & E,C - Limited availability & DAG & \{M, HO, T\}/U & Migrate, Data transfer time & E/H & MIN(T) & Batch, Batch & Heuristic, GA & Dynamic & S -- \emph{Random DAGs} \\ \hline \cite{chun2011cloneCloud} & E:M, C & -- & -- & E - Limited availability & DAG & S & Checkpoint, Migrate, Data transfer time & -- & MIN(E) or MIN(T) & --, DAG & ILP & Dynamic & E -- \emph{Virus scanning, image search and behavior profiling applications} \\ \hline \cite{shi2012serendipity} & E:M & HT & -- & AL (Deferred), Limited availability & DAG & \{M, HO, T\}/O & Resubmit, Migrate, Data transfer time & TD/H & MIN(E) or MIN(T) & DAG, MIN(E)-Batch; MIN(T)-DAG & Greedy & Dynamic & S, E -- \emph{Face detection and speech to text applications} \\ \hline \cite{hong:mcc:2013} & E:M, F, C & HT & -- & E - Limited availability & DAG & S & Migrate & S/H & MIN(T) & DAG, DAG & Heuristic & Dynamic & S -- \emph{Vehicle-to-vehicle video streaming and mobile CEP applications} \\ \hline \cite{brogi2017qos} & F, C & HT & -- & F - Limited availability & DAG & S & -- & S/H & -- & DAG, -- & Heuristic, Backtracking, Greedy & Static & S -- \emph{Fire alarm application} \\ \hline \cite{URGAONKAR2015205} & E:M, C & HT & NP & E-VM migrate, Time slots, Locality & Task & \{S, HT, T\}/O & Locality, Tasks on specific Edges & TD & MIN(O): NW use & Task & Markov Decision Process/ILP & Static & S -- \emph{Real mobility traces, cellular NW} \\ \hline \cite{bittencourt2017mobility} & F, C & HO & -- & F - Limited availability, locality & DAG & \{S, HT, T\} & DAG locality, Data transfer time & -- & MIN(T), MIN(O): NW use & DAG & Locality-aware, FIFO, Heuristic & Dynamic & S -- \emph{iFogSim, gaming, video processing} \\ \hline \end{tabular} \end{sidewaystable*} \section{Classification of Scheduling Algorithms using Taxonomy} \label{sec:table} Table~\ref{tbl:review:1} classifies $36$ key publications on application scheduling, based on the taxonomy we have proposed. $25$ of these papers propose scheduling exclusively on cloud resources, while $11$ use a mix of edge, fog and/or cloud. The skew toward cloud-based scheduling reflects the decade-long period of maturity of this resource, relative to edge and fog resources that are more recent. The footnotes of the table indicate the short-hand of the taxonomy terms used within the columns for brevity. In summary, on the \emph{system model} dimension, $23$ of the $25$ papers consider cloud infrastructure with heterogeneous VM sizes, $17$ use on-demand VMs with fixed prices, $2$ use pre-emptive VMs, and $5$ use a mix of both. For the mix of edge, fog and cloud, almost all the papers have considered heterogeneous resources and only $1$ paper considers homogeneous cloud resources. A majority of the cloud scheduling publications -- $19$ to be exact -- use hourly billing that was common among cloud providers, while $2$ others use more current fine-grained billing intervals. Further, $12$ of the papers cataloged consider VM acquisition lag in their schedule planning. Three of these papers also constrain the availability of resources from the provider, which is more representative of Grid and HPC systems than public clouds which provide seemingly unlimited resources on-demand. For edge, fog and cloud resources, most of the papers do not consider resource pricing at all. Only $2$ papers consider hourly billing and that too only for the cloud resources. Also $1$ paper has considered deployment lag and $1$ has considered deferred acquisition. All these papers constrain the availability of edge and fog resources, either on account of mobility or limited resources capacity, while $2$ limit the number of available cloud resources as well. $3$ papers consider spatial mobility of edge and fog resources, while two others are have spatial locality between the client and the edge or fog. The reviewed papers have diverse \emph{application characteristics} as well. Out of all the papers, $25$ use a DAG structure while $12$ use a task structure; $7$ publications allow batch submission while $14$ have a transactional mode of arrival; and $15$ consider applications that are scheduled as a collection rather than individually. As many as $13$ of the papers use time deadline as a constraint and cost as the optimization goal when specifying their \emph{QoS} requirements. However, $8$ articles use cost budget as a constraint as well. Most of the papers that include edge and fog resources aim at minimizing the power consumption, overall latency or network usage. Most of the research papers use a heuristic or greedy \emph{algorithm for scheduling}, of which $16$ schedule the applications statically, $19$ schedule them dynamically while $2$ use a mix of both approaches. Simulations based on synthetic DAGs or tasks tend to be the predominant means of evaluating these scheduling algorithms, though $5$ of the papers reviewed use real or realistic applications for validation. This diversity in the surveyed literature indicates the rich classes of problem definitions and corresponding research outcomes in this area of application scheduling on edge, fog and cloud. It also justifies the need for a detailed taxonomy such as ours to categorize and analyze this body of work -- both what has been done and future work that can benefit from these learnings, particularly for a mix of these resource abstractions. \section{Related Work} \label{sec:related} Several existing literature offer generic reviews of edge, fog or clouds, either independently or in comparison. They also offer complementary aspects of application models on each resource independently, or scheduling for other levels of the cloud abstractions. But none offer a holistic survey on the approaches to application scheduling on these distributed infrastructure, with structure and rigor as we have presented here. \subsection{Resource Characterization} There are several surveys on the characteristics of edge, fog and cloud resources. These describe the capabilities of the individual resource platforms, and their features that benefit both end users and service providers. This is necessary to examine application scheduling, but needs to be substantiated with applications models and scheduling techniques that leverage these features. A recent manifesto on cloud computing offers an \emph{overarching review} of contemporary cloud capabilities, and future potential and challenges~\cite{manifesto}. Our cloud resource characteristics are not as detailed, but focus on specific features of relevance to application scheduling. \cite{coutinho:2015} offers a more specialized bibliometric survey on \emph{elasticity of cloud resources}, along with the journals where the publications appear, country of origin of authors, and year of publication. A taxonomy of methods used to leverage as well as QoS metrics is also provided. While some of our resource characteristics, application characteristics and QoS topics overlap with this, we do not exclusively focus on elasticity but rather examine other dimensions of clouds such as pricing and resilience as well, in addition to application scheduling. Similarly, there have been several papers that conceptualize the idea of fog computing and Cloudlets~\cite{varshney2017icfec,Bonomi2014,satya:pervasive:2009}. Others examine specific applications that benefit from the fog layer, to complement edge and cloud computing, with smart cities and IoT being key drivers~\cite{dastjerdi:computer:2016,yannuzzi:camad:2014,stojmenovic:fedcsis:2014}. Some also prescribe different types of interactions between the edge, fog and cloud layers~\cite{stojmenovic:2014}. These are similar to our resource taxonomy, but fail to compare common and contrasting features across edge, fog and cloud, and how application models and schedulers leverage them. There are articles which discuss the use of edge, fog and cloud layers in a hierarchical architecture. ~\cite{7721750} consider mobility to be a characteristic feature of both the edge and fog layers, with challenges to resource discovery, service scheduling, QoS guarantee and security. A medical emergency use case is used to illustrate the relative benefits of using a cloud-only application deployment design, with one that uses all three. Latency is seen as a QoS goal, but they omit concerns on monetary cost and energy usage. Similarly~\cite{8123913} highlight the security and privacy issues in including edge resources for storage and computation of IoT applications, besides the cloud. A fog layer is not explicitly considered, and resource pricing is mentioned in passing. The benefits for different IoT applications such as smart grid, smart city and smart transportation are mentioned. Our survey goes beyond exemplars and considers how generic application can be conceptually specified in terms of their structure, mode of submission and QoS. We also provide a categorization of possible scheduling algorithms in literature. Individual and combined resource layers are included in our review, without limiting to a hierarchical model. \emph{Mobile Edge Computing (MEC)} has received particular attention due to early mobile phones that were resource constrained. ~\cite{7879258} surveys the existing research on computation offloading in MEC and how it is integrated with the mobile network architectures. They illustrate use cases that benefit from MEC and their application characteristics, such as whether the application can be partitioned and offloaded, dependencies between parts, predictability of the input data size. These affect how an application can be executed locally on the phone, partially offloaded or fully offloaded to the cloud to meet the QoS goals, such as minimization of delay or energy consumption. Techniques for responding to the device's mobility, like changing transmission power, VM migration, and communication route selection are suggested. ~\cite{8030322} offers a conceptual model of computing that moves between a mobile edge device and the cloud, with the intelligence on application scheduling present between them on the Radio Access Network (RAN). This communication-centric view considers fog and edge computing as the same resource layer. They review literature on computation offloading in MEC, with low latency processing, storage issues, and energy efficiency being QoS goals. Our survey while similar in spirit to these takes a more holistic and forward-looking view of the resource characteristics of edge, fog and cloud, including pricing and performance, and generalizes the application structure and their QoS. \subsection{Scheduling Techniques} Scheduling for different aspects cloud computing have been examined in the past. \cite{zhan:csur:2015} present a taxonomy of \emph{scheduling algorithms at various layers}: application, virtualization and infrastructure. Algorithms are classified based on the specific objectives that should be met at each layer. Scheduling at the virtualization layer has the goal of mapping VMs on to physical machines, which is of particular interest to service providers. This been addressed by other specialized surveys such as \cite{pietri:2016,mann:csur:2015}. The goal of scheduling at the infrastructure layer is to place the resources and services at different locations in various data centers. \cite{grozev:spe:2014} drill-down into this layer and offer a taxonomy for inter-cloud architectures, with application brokering in these systems. At the application layer, the problem is to schedule the user's application on VMs, and three goals are discussed by \cite{zhan:csur:2015}: user QoS, provider efficiency, and negotiation. In contrast, our survey focuses on just the application layer but goes in-depth by offering a detailed classification of edge, fog and cloud resources based on pricing models and system characteristics essential for scheduling algorithms. Moreover, we also categorize the structure of workflows, their characteristics and mode of submission. We further identify fault tolerance as a user QoS with scheduling techniques designed for application resilience on these resource layers. Our work is of broader interest to middleware and application developers using these distributed resources, who, arguably form a larger population that can put this survey to practical use, compared to commercial resource service providers who are less influenced by such research outcomes. Similarly, \cite{kessaci:ipdpsw:2014} also discuss \emph{scheduling at the three levels} -- service, task and VM -- for public and private clouds. We limit our focus to \emph{public clouds} that are exceedingly popular and where issues of elasticity and costing offer clear challenges and opportunities to end users, and complement this with emerging edge and fog resource layers. Our work also emphasizes the \emph{application layer}, a subset of which is the task level considered by~\cite{kessaci:ipdpsw:2014}, with the objective of meeting QoS requirements and/or budget constraints for the application. We also offer greater detail on various aspects of the unit of scheduling, which is lacking in these surveys. Likewise, \cite{huang:jsw:2013} limits itself to resource allocation in clouds in the presence of \emph{system failures}, with various ACO and GA based dynamic scheduling meta-heuristics to handle faults being explored. We go beyond system failure and also examine literature that handle failures due to pricing (out of bid) for pre-emptible and opportunistic resources. We also discuss several other scheduling algorithms that address diverse QoS constraints and goals. \cite{wu:2015} presents several \emph{categories of workflow scheduling algorithms} on clouds, including static and dynamic scheduling, to meet constraints such as budget, deadline and robustness. Similarly, \cite{liu:ccgrid:2014} offers a brief summary of workflows and their objective criteria for scheduling on the cloud, and review literature on scheduling algorithms to achieve the same. Others have surveyed \emph{meta-heuristic techniques} for scheduling workflows on the cloud~\cite{tsai:jsyst:2014}. These techniques include hill climbing, simulated annealing, tabu search, GA, PSO and ACO, and these have been used to generate a schedule for workflows on clouds. While these surveys consider multiple classes of scheduling algorithm and system characteristics that lie at the intersection of several dimensions we introduce, they do not offer a taxonomy of the dimensions themselves which is essential for a rigorous analysis of this space. Edge and fog resources which have gained prominence off-late are omitted as well. Some early research investigates platform and application models for edge and fog computing~\cite{varshney2017icfec}. ~\cite{hong:mcc:2013} propose a 3-level strictly hierarchical model where the computation is rooted in the cloud, resources are elastically acquired in the cloud and fog layers, and communication is possible between cloud and fog, or fog and edge. But their example applications do not use the cloud, and this degenerates to a client-server model between the edges and their fog parent. The role of virtualization in enabling cloud computing is discussed in~\cite{bittencourt:pgcic:2015}, and they see a similar role for the fog as well. They conceive of a VM encapsulating all dependencies for an edge application or user to be hosted on a Cloudlet within 1 hop of the edge, with this VM migrating to remain at 1-hop distance from the edge user. Such articles offer potential architectures for interactions between edge, fog and cloud, while out survey more broadly characterizes these resources and examines their impact on applications and how they are scheduled. \section{Discussion} \label{sec:discussion} This detailed review of application scheduling characteristics on edge, fog and cloud resources, along with the feature matrix, highlight several open problems, whose solutions require a mix of research, development and business models. There are also rapidly emerging technologies that can influence these directions. We discuss these along similar categories that we have proposed. \subsection{Evolution in Resource Abstractions} Public cloud providers are highly agile and respond rapidly to evolving technologies and market dynamics. One challenge is being addressed is \emph{light-weight application sandboxing}, in contrast to hypervisor based VMs. Cloud providers like Amazon EC2 and Microsoft Azure are offering Docker containers, which have minimal resource overheads and offer rapid instantiation compared to virtualization, and are useful when OS heterogeneity is not required. They even support basic migration between hosts. These containers however use kernel-based controls to enforce security and resource allocation, which are less effective than hardware virtualization. This can open up opportunities for trade-off between the ability to respond rapidly to application dynamism, multi-tenant container security, and handling performance variability. Recent work on minimalist OS like \emph{VMWare's PhotonOS}, light-weight virtualization like \emph{AWS Firecracker}, and even web-standards like \emph{W3C's WebAssembly} offer alternatives to containers and hypervisors. Some of these are motivated by the popularity of a serverless \emph{Function-as-a-Service (FaaS)} model, based on stateless micro-services that encapsulate user-defined functions that can be composed and executed~\cite{akkus2018sand}. This is similar to task scheduling in a transactional model. Besides cloud data centers, FaaS is also being pushed to the fog and edge layers using SDK's like \emph{Amazon Greengrass} and \emph{Azure Edge IoT} offered by the cloud providers. These cloud fabrics extend to edge devices, and allow for more centralized management of distributed edge and fog resources on the wide area network~\cite{azureiot,awsgreengrass,manifesto}. These are currently limited to running applications using a FaaS model, with their scheduling managed exclusively by the provider. But the ability to expose IaaS resources on the edge and fog can help further leverage scheduling designed for the cloud to be extended to the edge and fog, and ease the design of practical edge, fog and cloud applications. Besides the push of existing cloud providers, there are also alternative \emph{business and technology models for edge and fog computing} that can be sustainable~\cite{vaquero2014finding}, both for infrastructure deployments and platform support~\cite{varshney2017icfec}. They are more obvious in vertically integrated ``private'' scenarios rather than horizontal, reusable ``public'' ones, much in the way of cloud data centers evolving from private use by Amazon, Google and Microsoft to a commercial business model of a public cloud~\cite{yi:mobidata:2015,manifesto}. Potential providers of on-demand public fog computing are operators of cell-phone towers who have captive power, communications and space, and Smart Cities deployments with captive compute capacity as part of the city deployments of verticals like smart power grid or smart transportation ~\cite{stojmenovic:fedcsis:2014,Bonomi2014,amrutur:testbed:2017}. Likewise, the advent of energy-efficient and high-performance \emph{accelerators} like GPUs and Tensor Processing Units (TPUs), and low-power ARM64 servers as cloud and fog resources, introduces further resource diversity and application opportunities that impacts scheduling~\cite{kalyanasundaram:hipc:2017,8587006,manifesto}. Part of this is driven by the rapid adoption of machine learning models and deep neural networks, which analyze multimedia data (e.g., video surveillance from smart cities) and have high computing costs~\cite{8342120}. Novel edge and fog devices such as drones and other autonomous vehicles are starting to become a reality as well~\cite{Sathiaseelan:2016:CMC:2935620.2935625}, and introduce new challenges in the energy and compute-constrained mobile resources with transient communications. Likewise, the adoption of 5G communication technology can translate into wide-spread deployment and accessibility of edge and fog devices, offering a high-bandwidth and pervasive last-mile link~\cite{taleb2018survey}. These technology-shifts will require us to revisit many of the assumptions on the system models used for scheduling. At the same time, there is also a lack of \emph{standardized infrastructure and platform interfaces} for edge and fog computing, with much of the advances in fabric management, programming models, power and network management, fault tolerance and pricing models being limited to research prototypes ~\cite{varshney2017icfec}. However, initiatives such as OpenFog Consortium (which recently merged with the Industrial Internet Consortium)~\cite{ofra} and EdgeX Foundry~\cite{edgexfoundry} championed by various industries are starting to offer reference architectures and software stacks to address this gap. These will serve as the vehicle to incorporate and enact the scheduling models that are developed. \subsection{Application Models and QoS} Application models tend to evolve more slowly than hardware and communications technologies, which are driven by the industry. Research has tended to focus more on batch execution of workflows as the unit of scheduling. However, the growth in streaming data and online decision-making applications means that \emph{transactional workloads} and \emph{event-driven} models need to be better examined. In fact, processing streaming data and having a control-loop between sensors and actuators, with analytics scheduled in-between, is a common pattern in IoT applications~\cite{simmhan:iotn:2017}. A few of the literature we have tabulated consider such an event-driven or transactional model~\cite{URGAONKAR2015205,ghosh-2018}. Similarly, \emph{BoTs} are a common abstraction that are inadequately examined for scheduling, even as they make good candidates for off-loading to the cloud pr fog partitions for execution~\cite{ibarra:jacm:1977,varshney:tpds:2018}. The popularity of FaaS also pushes data to the compute, rather than the typical model of moving compute to the data, while easing weak-scaling of stateless micro-services~\cite{akkus2018sand}. The increasing importance of \emph{machine learning applications} means that scheduling that is sensitive to the goals of training and inferencing will be beneficial~\cite{Zhang:2017:SQS:3127479.3127490,ananthanarayanan2017real}. In particular, the QoS goals and constraints may need to include the quality of the training and inferencing accuracy as first-class metrics, besides the time taken. Further, with increasing \emph{personally identifiable data} being collected and processed from the edge, privacy and trust start playing a key role. This may impose limitations on where to run what applications, and if additional operations such as anonymization or masking is required before placing specific tasks on specific resources~\cite{Wang:2017:SPI:3083187.3083192}. This can require the application to be re-composed on the fly before being scheduled. Scheduling across \emph{different resource layers} also introduces independent constraints and priorities on each layer that need to be met. E.g., energy is a key concern for scheduling on edge and fog, while pricing and latency are user concerns when using the cloud. Additional research is required into capturing these resource-specific factors into the optimization goals or constraints. \subsection{Scheduling Approach} While there has been a lot of conceptual work on making use of edge, fog and cloud resources, there is a lack of literature on novel scheduling approaches that consider all the $3$ layers together while leveraging their relative merits. Further, the interactions between the layers currently tends to be limited to a hierarchy of cloud--fog--edge, or just a flat logical structure composed of heterogeneous resources across them. This is a need to examine distributed scheduling strategies rather than centralized ones to ensure scaling to thousands of resources on the local and wide area network, and also resilience to avoid a single point of failure. Techniques from P2P can play a role here~\cite{lo2004cluster}. Given the challenges in access to large scale edge and fog deployments, much of the validation of scheduling approaches for these resources are based on simulations, using frameworks like iFogSim~\cite{fogsim}. However, there has been work on \emph{virtual environments} like VIoLET~\cite{violet} that use containers running on VMs or clusters to replicate the behavior of edge, fog and cloud resources using container resource allocations. It can also control the network topology between the resources, and the resource dynamism and failures. These have the benefit of allowing real applications to be scheduled, executed and the schedule evaluated for realistic edge, fog and cloud resources, and offer a balance between empirical and simulation-based approaches. More such efforts are required to model communication diversity, device reliability, etc. \section{Conclusion} \label{sec:conclude} In this survey, we have offered a comprehensive taxonomy for defining and designing application scheduling algorithms on edge, fog and cloud infrastructure, based on a detailed literature review. These span the system model for the three layers, application model with an emphasis on DAG and task-based applications, and the QoS goals and constraints to be met, which collectively help define scheduling as an optimization problem. We also categorize existing approaches to solving this optimization problem and evaluating it, based on prior reviews. This taxonomy has been used to tabulate the characteristics of $36$ research papers on scheduling on edge, fog and/or cloud resources. The taxonomy presents \emph{designers} of scheduling algorithms for edge, fog and cloud applications with a clear set of system and application features they should consider for their target infrastructure and workload. The table provides \emph{architects} of application runtimes with the relevant classes of scheduling algorithms that they can leverage to meet the needs of their end-users. Learning from this body of work is essential as applications are increasingly designed for edge and fog environments, rather than just the cloud, and scheduling challenges are set to emerge within newer application platforms that can operate on these resources. To this end, we have also explored various emerging technology trends that will require us to re-examine current system and application models, and develop novel scheduling techniques for the next generating of computing. \bibliographystyle{plain}
{'timestamp': '2019-04-24T02:05:42', 'yymm': '1904', 'arxiv_id': '1904.10125', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.10125'}
arxiv
\section{Introduction} \label{sec:intro} A ``hero'' project is one where 80\% or more of the contributions come from 20\% of the developers. Those developers are called ``hero'' developers. In the literature, hero projects are deprecated since, it is said, they are like bottlenecks that slow down the project development process and causes information loss~\cite{bier2011online,boehm2006view,hislop2002integrating,morcovcomplex,wood2005multiview,fitzgerald2003making}. Recent studies have motivated a re-examination of the implications of heroes. In 2018, Agrawal et al.~\cite{Agrawal_2018} studied 661 open source projects and 171 in-house proprietary projects. In that sample, over 89\% of projects were hero-based\footnote{This text use ``hero'' for women and men since recent publications use it to denote admired people of all genders-- see bit.ly/2UhJCek.}. Only in the group of small open source projects (with under 15 core developers), non-hero projects were more prevalent. To say the least, this widespread prevalence of heroes is at odds with established wisdom in the SE literature. The usual stance in the literature is to warn against heroes since they may become bottlenecks in development and communication~\cite{bier2011online,boehm2006view,hislop2002integrating,morcovcomplex,wood2005multiview,ricca2010heroes,robles2006contributor,capiluppi2007adapting}. Hence, it is now an open and pressing issue to understand why so many projects are hero-based. To that end, this paper verifies the result which Agrawal et al.~\cite{Agrawal_2018} found out. All of project data was recollected from scratch from double the number of open source projects (over 1000 projects) than used by Agrawal et al. In this study, heroes are those who participate in 80\% (or more) of the total contribution in the project. At his ICSE'14 keynote, James Herbsleb stated that communication between developers is an important factor to find bugs when code interaction happens ~\cite{Herbsleb:2014}. So, we decided not to look at the percent of code contribution but also at the percent of communication involvement. As a result, we will say that ``hero'' developer is a developer who participates in 80\% or more of the code contribution or communications in a project. As shown below, the population of ``heroes'' defined in this way are an important segment of the development population (specifically, we will show that these ``communication heroes'' add far fewer bugs into software than anyone else). Despite our different ways to recognize ``heroes'' and despite our much larger sample, this study comes to a similar conclusions as Agrawal et al.. This study finds majority of our projects contain heroes, which is very similar to the Agrawal et al.'s result. More importantly, this study can explain {\em why} heroes are more important. As shown below, our ``hero'' commit patterns (where ``heroes'' are those who interact most with other developers) are associated with dramatically fewer defects than the commits from non-heroes (who interact with fewer people). Hence we conjecture that heroes are so common since they write better code. This is not the first paper to comment on the use of hero developers. For example, in 1975 Brooks~\cite{Brooks:1975} proposed basing programming teams around a small number of ``chief programmers'' (which we would call ``heroes'') who are supported by a large number of support staff (Brooks's analogy was the operating theater where one surgeon is supported by one or two anesthetists, several nurses, clerical staff, etc). The Agile Alliance~\cite{cockburn2006agile} and Bach et al.~\cite{bach1995enough} believed that heroes are the core ingredients in successful software projects saying ``... the central issue is the human processor - the hero who steps up and solves the problems that lie between a need express and a need fulfilled.'' In 2002, Mockus et al.~\cite{mockus2002two} analyzed Apache and Mozilla projects to show the presence of heroes in those projects and reported, surprisingly, their positive influence on the projects. That said, this article is different from previous works because: \begin{enumerate} \item This study clearly demonstrate the benefits of hero-based development, which is contrary to much prior pessimism~\cite{bier2011online,boehm2006view,hislop2002integrating,morcovcomplex,wood2005multiview,fitzgerald2003making}. \item Our conclusions come from over 1000+ projects, whereas prior work commented on heroes using data from just a handful of projects~\cite{544352,LI1993111,Zimmermann:2009:CDP:1595696.1595713,935855,841025,Bird:2011:DTM:2025113.2025119,Pamela,bell2,Kumar2017,jiarpakdee2018impact,8595100}. \item Our conclusions come from very recent projects instead of decades-old data~\cite{Jayanthi2018,Gupta2017,jiarpakdee2018impact,kemerer2009impact,Pamela,fengzhang}. \item This study shows curves that precisely illustrate the effects on code quality for different levels of communication. This is different to prior works that only offered general qualitative principles~\cite{wolf2009predicting,de2004sometimes,grinter1999geography,herbsleb1999splitting,cataldo2013coordination,cataldo2007coordination}. \item As discussed in Section~\ref{tion:metrics}, this paper makes its conclusions using more metrics than prior work. Not only do we observe an effect (using {\em process} and {\em resource} metrics) to report the frequency of developer contribution, but we also report the consequence of that effect (by joining to {\em product metrics} to reveal software quality). \item Instead of just reporting an effect (that heroes are common, as done by Agrawal et al.~\cite{Agrawal_2018}) this study can explain that effect (heroes are those that communicate more and that communication leads to fewer bugs). \item As a service to other researchers, all the scripts and data of this study can be downloaded from \href{http://tiny.cc/git_mine}{tiny.cc/git\_mine}. \end{enumerate} The practical implication of this research is as follows: \begin{itemize} \item Our results demand a change in the way we develop new technologies or modern software projects. Specifically, given the prominence and importance of heroes, future work could usefully explore methods to streamline the communication between a {\em very large population} of developers and a {\em very small number} of heroes that are critical for high quality software. \end{itemize} Before beginning, we make some definitional points. Firstly, when we say 1000+ projects, that is shorthand for the following. Our results used the intersection of two graphs of {\em code interaction graph} (of who writes what and whose code) with {\em social interaction} graph (who discusses what issue and with whom) from 1037 projects. Secondly, by code interaction graphs and social interaction graphs, we mean the following. Each graph has own nodes and edges $\{N,E\}$. For code interaction graphs: \begin{itemize} \item Individual developers have their own node $N_c$; \item The edge $E_c$ connects two nodes and indicates if ever one developer has changed another developer's code. $W_c$ denotes how much one developer has changed another developer's code. \end{itemize} \begin{figure}[!t] \begin{center} \includegraphics[width=\linewidth]{social_model.png} \end{center} \caption{An example of social interaction graph generated from our data. The number of nodes equals the number of unique people participating in issue conversation. The existence and width of each edge represents the frequency of conversation between pairs of developers. Hero programmers are those nodes which have very high node degree (i.e. who have participated in lot of unique conversations). Note that, in this example data, these hero programmers are few in number.} \label{fig:Socialgraph} \end{figure} For social interaction graphs like \fig{Socialgraph}: \begin{itemize} \item A node $N_s$ is created for each individual who has created or commented on an issue. \item An edge $E_s$ indicates a communication between two individuals (as recorded in the issue tracking system. If this happens $N$ times then the weight $W_s=N$. \end{itemize} Thirdly, we have defined heroes based on code contribution and communication. From the ``Code interaction graph'' , the developers who contribute more than 80\% are hero contributors and in the ``Social interaction graph'', the developers who are making 80\% of the communication are hero communicators. Both are ``hero developers'' for us. As we show in \S\ref{sec:Results}, both these definitions of heroes are insightful since more can be predicted about a project using {\em both} definitions that it either is applied separately. The rest of the paper is organized into the following sections. Section~\ref{sec:Background And Prior Work} provides background information that directly relates to our research questions, in addition to laying out the motivation behind our work. Section~\ref{sec:Data Collections} explains the data collection process and Section~\ref{sec:Experimental Setup}, a detailed description of our experimental setup and data is given, along with our performance criteria for evaluation is presented. It is followed by Section~\ref{sec:Results} the results of the experiments and answers to some research questions. Section~\ref{sec:Discussion} discusses their implication of our finding.It is followed by Section~\ref{sec:Threats to Validity}, which discusses threats to validity. Finally Section~\ref{sec:Conclusion} concludes the paper. \section{Background And Prior Work } \label{sec:Background And Prior Work} \subsection{Heroism in Software Development} Heroism in software development is a widely studied topic. Various researchers have found the presence of heroes in software projects. For example: \begin{itemize} \item Peterson analyzed the software development process on GitHub and found out a pattern that most development is done by a small group of developers \cite{Peterson}. He stated that for most of the GitHub projects, 95-100\% commits come from very few developers. \item In 2002, Koch et al.~\cite{koch2002effort} studied the GNOME project and showed the presence of heroes through out the project history. They conjectured (without proof) that the small number of hero developers may allow easy communication and collaboration. Interestingly, they also showed there is no relation between developer's time in the project and being a hero developer. \item In 2005, Krishnamurthy~\cite{KrishnamurthyS} studied 100 open source projects to find that a few individuals are responsible for the main contribution of the project in most of the cases. \item In 2006 and 2009, Robles et al.~\cite{robles2009evolution,robles2006contributor} explored in their research the presence and evolution of heroes in open source software community. \item In 2018, Agarwal et al. \cite{Agrawal_2018} stated that hero projects are very common. In fact, as software projects grow in size, nearly all projects become hero projects. \end{itemize} Most prior researchers deprecate heroism in software projects. They argue that \begin{itemize} \item Having most of the work being dependent on a small number of heroes can become a bottleneck that slows down project development ~\cite{bier2011online,morcovcomplex,hislop2002integrating,boehm2006view,wood2005multiview}. \item In the case of hero projects, there is less collaboration between team members since there are few active team members. So, heroes are affecting the collaboration which is essential \cite{1008000,4221622}. \end{itemize} This second point is problematic since, in the literature, studies that analyze distributed software development on social coding platforms like GitHub and Bitbucket~\cite{dias2016does,cosentino2017systematic} remark on how social collaborations can reduce the cost and efforts of software development without degrading the quality of software. Distributed coding effort is beneficial for agile community-based programming practices which can in turn have higher customer satisfaction, lower defect rates, and faster development times ~\cite{moniruzzaman2013comparative,rastogi2017empirical}. Customer satisfaction, it is argued, is increased when faster development leads to: \begin{itemize} \item Increasing the number of issues/bugs/enhancements being resolved~\cite{mockus2002two,jarczyk2014github,bissyande2013got,athanasiou2014test,gupta2014process,reyes2017analyzing}. \item Lowering the issues/bugs/enhancements resolution times~\cite{jarczyk2014github}. \end{itemize} Even more specifically, as to issues related to heroes, Bier et al. warn when project becomes complicated, it is always better to have a community of experts rather than having very few hero developers ~\cite{bier2011online}. Willams et al. have shown that hero programmers are often responsible for poorly documented software system as they remain more busy in coding rather than writing code related documents ~\cite{hislop2002integrating}. Also, Wood et al.~\cite{wood2005multiview} caution that heroes are often code-focused but software development needs workers acting as more than just coders (testers, documentation authors, user-experience analysts). Our summary of the above is as follows: with only isolated exceptions, most of the literature deprecates heroes. Yet as discussed in the introduction, many studies indicate that heroic projects are quite common. This mismatch between established theory and a widely observed empirical effect prompted the analysis discussed in this paper. \renewcommand{\xmark}{} \begin{table} \centering \scriptsize \caption{Some results from Google Scholar query {\em (software heroes) or ((software metrics) and (code quality))}. Hero-related publications have a color background. Rows colored in gray denote hero-related publication that offer no metrics in support of their arguments.} \vspace{-0.2cm} \label{tbl:survey2} \begin{tabular}{r|@{~}c|@{~}c|@{~}r|@{~}c|@{~}c|@{~}c} \begin{tabular}[c]{@{}c@{}}\textbf{Ref}\end{tabular} & \textbf{Year} & \textbf{cites} & \begin{tabular}[c]{@{}c@{}} \textbf{\#projects} \\\textbf{analyzed} \end{tabular} &\begin{tabular}[c]{@{}c@{}} \textbf{Uses}\\ \textbf{Product}\\ \textbf{Metrics?} \end{tabular} &\begin{tabular}[c]{@{}c@{}} \textbf{Uses }\\\textbf{Process }\\\textbf{Metric?} \end{tabular} &\begin{tabular}[c]{@{}c@{}} \textbf{Uses}\\ \textbf{Personnel}\\ \textbf{Metrics?} \end{tabular}\\ \hline \cite{544352} & 1996 & 1994 & 8 & \cmark & \xmark & \xmark \\ \rowcolor{blue!10} \textbf{\cite{mockus2002two}} & \textbf{2002} & \textbf{1961} & \textbf{2} & \xmark & \cmark & \cmark \\ \cite{LI1993111} & 1993 & 1268 & 2 & \cmark & \xmark & \xmark \\ \cite{BRIAND2000245} & 2000 & 779 & 1 & \cmark & \xmark & \xmark \\ \cite{Nagappan:2006:MMP:1134285.1134349} & 2006 & 772 & 5 & \cmark & \cmark & \xmark \\ \cite{1191795} & 2002 & 711 & 1 & \cmark & \cmark & \xmark \\ \cite{Zimmermann:2007:PDE:1268984.1269057} & 2007 & 636 & 3 & \cmark & \cmark & \xmark \\ \rowcolor{blue!10} \textbf{\cite{boehm2006view}} & \textbf{2006} & \textbf{667} & \textbf{0} & \xmark & \cmark & \xmark \\ \cite{1435354} & 2005 & 622 & 2 & \cmark & \cmark & \xmark \\ \cite{Zimmermann:2009:CDP:1595696.1595713} & 2009 & 466 & 12 & \cmark & \cmark & \xmark \\ \rowcolor{blue!10} \textbf{\cite{KrishnamurthyS}} & \textbf{2002} & \textbf{466} & \textbf{100} & \xmark & \cmark & \xmark \\ \cite{935855} & 2001 & 445 & 1 & \cmark & \xmark & \xmark \\ \cite{ELEMAM200163} & 2001 & 406 & 1 & \cmark & \xmark & \xmark \\ \cite{Cartwright} & 2000 & 400 & 1 & \cmark & \xmark & \xmark \\ \cite{ELISH2008649} & 2008 & 398 & 4 & \cmark & \xmark & \xmark \\ \cite{841025} & 1999 & 346 & 1 & \cmark & \xmark & \xmark \\ \rowcolor{blue!10} \textbf{\cite{koch2002effort}} & \textbf{2002} & \textbf{305} & \textbf{1} & \xmark & \cmark & \xmark \\ \cite{809745} & 1999 & 300 & 3 & \cmark & \xmark & \xmark \\ \rowcolor{blue!10} \textbf{\cite{4221622}} & \textbf{2007} & \textbf{298} & \textbf{0} & \xmark & \cmark & \xmark \\ \cite{5560680} & 2009 & 271 & 1 & \cmark & \cmark & \xmark \\ \cite{Menzies2010} & 2010 & 256 & 10 & \cmark & \xmark & \xmark \\ \cite{5611551} & 2011 & 256 & 17 & \cmark & \cmark & \xmark \\ \rowcolor{blue!10} \textbf{\cite{Bird:2011:DTM:2025113.2025119}} & \textbf{2011} & \textbf{233} & \textbf{2} & \xmark & \cmark & \cmark \\ \cite{Jureczko:2010:TIS:1868328.1868342} & 2010 & 229 & 38 & \cmark & \xmark & \xmark \\ \cite{FENTON200732} & 2004 & 223 & 30 & \xmark & \cmark & \xmark \\ \cite{Pinzger2008CanDN} & 2008 & 223 & 1 & \cmark & \cmark & \cmark \\ \cite{Meneely2008PredictingFW} & 2008 & 218 & 1 & \cmark & \cmark & \cmark \\ \cite{Wolf:2009:PBF:1555001.1555017} & 2009 & 197 & 1 & \xmark & \cmark & \cmark \\ \cite{1385642} & 2005 & 186 & SourceForge & \xmark & \xmark & \cmark \\ \cite{5362091} & 2009 & 177 & 6 & \cmark & \xmark & \cmark \\ \cite{671604} & 1998 & 172 & 2 & \cmark & \xmark & \xmark \\ \cite{Weyuker2008} & 2008 & 163 & 3 & \cmark & \cmark & \cmark \\ \cite{Pamela} & 2012 & 163 & 11 & \cmark & \cmark & \cmark \\ \cite{Okutan2014} & 2014 & 159 & 9 & \cmark & \cmark & \xmark \\ \cite{Knab} & 2006 & 131 & 1 & \cmark & \cmark & \xmark \\ \cite{HE2015170} & 2015 & 106 & 10 & \cmark & \cmark & \xmark \\ \cite{Majumder_2012} & 2012 & 103 & 905,470 & \xmark & \xmark & \cmark \\ \cite{Ratzinger:2008:RRS:1370750.1370759} & 2008 & 102 & 5 & \cmark & \xmark & \xmark \\ \rowcolor{blue!10} \textbf{\cite{robles2006contributor}} & \textbf{2006} & \textbf{99} & \textbf{21} & \cmark & \xmark & \xmark \\ \cite{McIntosh2016} & 2016 & 92 & 3 & \xmark & \cmark & \cmark \\ \cite{fengzhang} & 2014 & 87 & 1,398 & \cmark & \xmark & \xmark \\ \cite{gregmadey} & 2002 & 85 & 39,000 & \xmark & \xmark & \cmark \\ \cite{KUPIAINEN2015143} & 2015 & 85 & 0 & \cmark & \cmark & \cmark \\ \cite{Madeyski2015} & 2015 & 76 & 18 & \cmark & \cmark & \xmark \\ \rowcolor{blue!10} \textbf{\cite{moniruzzaman2013comparative}} & \textbf{2013} & \textbf{68} & \textbf{0} & \xmark & \cmark & \xmark \\ \rowcolor{blue!10} \textbf{\cite{robles2009evolution}} & \textbf{2009} & \textbf{65} & \textbf{1} & \xmark & \cmark & \cmark \\ \cite{lima2014coding} & 2014 & 61 & GitHub & \xmark & \xmark & \cmark \\ \cite{Ostrand:2010:PFP:1868328.1868357} & 2010 & 59 & 6 & \xmark & \cmark & \cmark \\ \rowcolor{blue!10} \textbf{\cite{bissyande2013got}} & \textbf{2013} & \textbf{58} & \textbf{100,000} & \cmark & \cmark & \xmark \\ \rowcolor{blue!10} \textbf{\cite{Abreu:2009:DCF:1595808.1595835}} & \textbf{2009} & \textbf{54} & \textbf{1} & \xmark & \cmark & \cmark \\ \cite{Jermakovics:2011:MVD:1984642.1984647} & 2011 & 48 & 2 & \xmark & \cmark & \cmark \\ \cite{bell2} & 2013 & 37 & 3 & \cmark & \cmark & \cmark \\ \rowcolor{gray!20} {\cite{wood2005multiview}} &{2005} & \textcolor{black}{36} & \textcolor{black}{0} & \xmark & \xmark & \xmark \\ \cite{Concas:2010:ESS:1945538.1972593} & 2010 & 30 & 2 & \cmark & \xmark & \xmark \\ \cite{Bicer:2011:DPU:1987875.1987888} & 2011 & 27 & 2 & \xmark & \cmark & \xmark \\ \rowcolor{blue!10} \textbf{\cite{jarczyk2014github}} & \textbf{2014} & \textbf{24} & \textbf{2,000} & \xmark & \cmark & \xmark \\ \cite{Udaya} & 2007 & 22 & 4 & \cmark & \xmark & \xmark \\ \cite{7539677} & 2016 & 19 & 235,000 & \cmark & \cmark & \xmark \\ \rowcolor{blue!10} \textbf{\cite{Peterson}} & \textbf{2013} & \textbf{14} & \textbf{1,000} & \xmark & \cmark & \xmark \\ \cite{Prasad} & 2015 & 12 & 1 & \cmark & \cmark & \xmark \\ \cite{Kumar2017} & 2017 & 11 & 10 & \cmark & \cmark & \xmark \\ \cite{jiarpakdee2018impact} & 2018 & 11 & 15 & \cmark & \cmark & \xmark \\ \rowcolor{blue!10} \textbf{\cite{Agrawal_2018}} & \textbf{2018} & \textbf{6} & \textbf{832} & \xmark & \cmark & \xmark \\ \cite{Gupta2017} & 2017 & 5 & 12 & \cmark & \xmark & \xmark \\ \rowcolor{gray!20} {\cite{bier2011online}} &{2011} & \textcolor{black}{3} & \textcolor{black}{0} & \xmark & \xmark & \xmark \\ \cite{Jayanthi2018} & 2018 & 2 & 4 & \cmark & \cmark & \xmark \\ \rowcolor{gray!20} {\cite{hislop2002integrating}} &{2002} & \textcolor{black}{2} & \textcolor{black}{0} & \xmark & \xmark & \xmark \\ \rowcolor{blue!10} {\cite{morcovcomplex}} &{2012} & \textcolor{black}{2} & \textcolor{black}{0} & \xmark & \xmark & \xmark \\ \cite{10.1007/978-981-13-1927-3_48} & 2018 & 0 & 5 & \cmark & \xmark & \xmark \\ \cite{prasad2018statistical} & 2018 & 0 & 1 & \cmark & \cmark & \xmark \\ \cite{dahab2018enhancing} & 2018 & 0 & 2 & \xmark & \cmark & \xmark \\ \cite{8595100} & 2018 & 0 & 1 & \cmark & \xmark & \xmark \\ \cite{vijay2017software} & 2017 & 0 & 50 & \xmark & \cmark & \xmark \\ \cite{10.1007/978-3-319-92270-6_42} & 2018 & 0 & 0 & \xmark & \cmark & \cmark \\ \end{tabular} \vspace{-0.3cm} \end{table} \subsection{Software Quality Metrics}\label{tion:metrics} Table \ref{tbl:survey2} offers some context for this research. While this paper product, process, and personnel metrics for 1000+ projects, most of the papers explore far fewer projects using a narrower range of metrics. For example, as shown by the {\em Number of Projects} column in Table \ref{tbl:survey2}, our sample size (1000+ projects) is orders of magnitude larger than the typical paper in this arena. This table was generated as follows. Firstly, using Google Scholar we searched for ``(software heroes) or ((software metrics) and (code quality))''. Secondly, for papers more than two years old, we pruned ``non-influential papers'' which we define has having less than ten citations per year. Thirdly, we read the papers to determine what kind of metrics they used. When presenting these results (in Table \ref{tbl:survey2}), hero-related publications have a blue background ( bold text also ) while rows colored in gray denote hero-related publication that offer no metrics in support of their arguments. Table \ref{tbl:survey2} also shows that most papers do not use a wide range of software metrics. Xenos \cite{Xenos} distinguishes software metrics as follows. {\em Product metrics} are metrics that are directly related to the product itself, such as code statements, delivered executable, manuals, and strive to measure product quality, or attributes of the product that can be related to product quality. {\em Process metrics} focus on the process of software development and measure process characteristics, aiming to detect problems or to push forward successful practices. Lastly, {\em personnel metrics} (a.k.a. {\em resource metrics}) are those related to the resources required for software development and their performance. The capability, experience of each programmer and communication among all the programmers are related to product quality \cite{wolf2009predicting,de2004sometimes,cataldo2013coordination,cataldo2007coordination}. In our work: \begin{itemize} \item Code interaction graph is a process metric; \item Social interaction graph is a personnel metric; \item Defect counts are product metrics. \end{itemize} (Aside: In this text we have used ``resource'' and ``peronnel'' interchangeably since, according to Center for Systems and Software Engineering, ~\cite{Xenos} resource metrics relating to programmer quality or communication related metrics are also called {\em personnel metrics}.) \begin{wrapfigure}{r}{6cm} \begin{center}\includegraphics[width=6cm]{Venn.png}\end{center} \caption{Summary of Table \ref{tbl:survey2}} \label{fig:venn} \end{wrapfigure} This paper explores all three kinds of metrics and applies the combination to exploring the effects of heroism on software development. There are many previous studies that explore one or two of these types of metrics. Fig \ref{fig:venn} summarizes Table \ref{tbl:survey2} and shows that, in that sample, very few papers in software metrics and code quality combine insights from product and process and personnel metrics. To the best of our knowledge, this is the first paper in this arena to discuss heroism using product and process and personnel metrics. Having worked with that data, we think we know why other publications do not report results using a wide range of metrics. Such reports require extensive and elaborate queries. The analysis of this paper required months of struggling with the GitHub API (and its queries/hour limits), followed by much scripting, followed by many tedious manual checks that our automatic tools were behaving sensibly. In all, we estimate that this paper required nine weeks of coding (40 hours per week) to join across process and product and personnel metrics. \subsection{Herbsleb Hypothesis (and Analogs)} One way to view this paper is as a check of the { \em Hersleb hypothesis} ~\cite{Herbsleb:2014}. At his ICSE'14 keynote, James Hersleb defined coding to be a socio-technical process where code and humans interact. According to the Hersleb hypothesis~\cite{Herbsleb:2014}, the following anti-pattern is a strong predictor for defects: \begin{itemize} \item If two code sections communicate... \item But the programmers of those two sections do not... \item Then that code section is more likely to be buggy. \end{itemize} To say that another way: \begin{quote} {\em Coding is a social process and better code arises from better social interactions. } \end{quote} Many other researchers offer conclusions analogous to the Herbsleb hypothesis. Developer communication/interaction is often cited as one of the most important factor for a successful software development \cite{Agile_software_development,Kraut:1995:CSD:203330.203345,1205177}. Many researchers have shown that successful communication between developers and adequate knowledge about the system plays a key role in successful software development \cite{TESCH2009657,Girba,841783}. As reported as early as 1975 in Brooks et al. text ``The Mythical Man Month''~\cite{brooks1995mythical}, communication failure can lead to coordination problem, lack of system knowledge in the projects as discussed by Brooks et al. in the Mythical Man-Month. The usual response to the above argument is to improve communication by ``smoothing it out'', i.e. by deprecating heroes since, it is argued, that encourages more communication across an entire project~\cite{bier2011online,boehm2006view,hislop2002integrating,morcovcomplex,wood2005multiview}. The premise of ``smoothing it out'' is that heroes are bad and should be deprecated. This paper tries to verify whether or not this premise holds true for open source GitHub projects or not. \section{Methodology} \label{sec:Methodology} \subsection{Data Collection} \label{sec:Data Collections} \fig{data} summarizes the Github data we used for this study. To understand this figure, we offer the following definitions: \begin{itemize} \item {\em Release:} (based on Git tags) mark a specific point in the repository's history. Number of releases defines different versions published, which signifies considerable amount of changes done between each version. \item {\em Duration:} length of project from its inception to current date or project archive date. It signifies how long a project has been running and in active development phase. \item {\em Stars:} signifies number of people liking a project or use them as bookmarks so they can follow what's going on with the project later. \item {\em Forks:} A fork is a copy of a repository. Forking a repository allows user to freely experiment with changes without affecting the original project. This signifies how people are interested in the repository and actively thinking of modification of the original version. \item {\em Watcher:} Watchers are GitHub users who have asked to be notified of activity in a repository, but have not become collaborators. This is a representative of people actively monitoring projects, because of possible interest or dependency. \item {\em Developer:} Developers are the contributors to a project, who work on some code, and submit the code using commit to the codebase. The number of developers signifies the interest of developers in actively participating in the project and volume of the work. \end{itemize} \begin{figure} \includegraphics[width=\linewidth]{meta_final3.png} \caption{Distribution of projects depending on Number of Releases, Duration of Project, Number of Stars, Forks. Watchers and Developers. Box plots show the min to max range. Central boxes show the 25th, 50th, 75th percentiles.} \label{fig:data} \end{figure} \begin{figure}[!t] \centering {\small \renewcommand{\baselinestretch}{0.7} \begin{tabular}{rrl} \textbf{Language} & \textbf{Projects} & \\ Shell & 416 &\rule{86.17pt}{8pt} \\ JavaScript & 396 &\rule{77.83pt}{8pt} \\ HTML & 344 &\rule{76.67pt}{8pt} \\ CSS & 314 &\rule{65.5pt}{8pt} \\ Python & 291 &\rule{51pt}{8pt} \\ Makefile & 229 &\rule{47.17pt}{8pt} \\ Ruby & 216 &\rule{44.17pt}{8pt} \\ C & 167 &\rule{41.83pt}{8pt} \\ Java & 150 &\rule{39.67pt}{8pt} \\ PHP & 146 &\rule{36.22pt}{8pt} \\ C++ & 126 &\rule{34pt}{8pt} \\ Batchfile & 81 &\rule{30.67pt}{8pt} \\ Perl & 67 &\rule{28pt}{8pt} \\ Objective-C & 67 &\rule{28pt}{8pt} \\ Dockerfile & 54 &\rule{26.17pt}{8pt} \\ CMake & 48 &\rule{22pt}{8pt} \\ M4 & 43 &\rule{21.83pt}{8pt} \\ CoffeeScript & 38 &\rule{19.83pt}{8pt} \\ Roff & 35 &\rule{16.33pt}{8pt} \\ Roff & 35 &\rule{16.67pt}{8pt} \\ C-Sharp & 34 &\rule{15.67pt}{8pt} \\ Emacs Lisp & 30 &\rule{14.5pt}{8pt} \\ Gherkin & 26 &\rule{12.5pt}{8pt} \\ Perl 6 & 21 &\rule{10.33pt}{8pt} \\ \end{tabular}} \caption{Distribution of projects depending on languages. Many projects use combinations of languages to achieve their results. Here, we show majority language used in the project.} \label{fig:lang_projects} \end{figure} \fig{lang_projects} shows that the projects we chose for our experiment comprise different languages. Note that we did not use all the data in Github. GitHub has over 100 million repositories as of May, 2019 so we only use data from the ``GitHub showcase project'' list. Many of these projects contain very short development cycles; are used for personal use; and are not be related to software development. Such projects may bias research findings. To mitigate that, we filter out projects using the standard ``sanity checks'' recommended in the literature~\cite{perils,curating}: \begin{itemize} \item {\textit{{Collaboration}}: refers to the number of pull requests. This is indicative of how many other peripheral developers work on this project. We required all projects to have at least one pull request.} \item {\textit{{Commits}}: The project must contain more than 20 commits.} \item {\textit{{Duration}}: The project must contain software development activity of at least 50 weeks.} \item {\textit{{Issues}}: The project must contain more than 10 issues.} \item {\textit{{Personal Purpose}}: The project must not be used and maintained by one person. The project must have at least eight contributors.} \item {\textit{{Software Development}}: The project must only be a placeholder for software development source code.} \item {\textit{Project Documentation Followed}: The projects should follow proper documentation standard to log proper commit comment and issue events to allow commit issue linkage.} \item {\textit{Social network validation}: The Social Network that is being built should have at least 8 connected nodes in both the communication and code interaction graph (this point is discussed further in \ref{sec:Personnel Metrics} and \ref{sec:Product Merics}).} \end{itemize} For each of the selected projects, the study recreates all the committed files to identify code changes in each commit file and identifies developers using the GitHub API, then downloads issue comments and events for a particular project, and uses the {\tt git log} command to mine the git commits added to the project throughout the project lifetime. Using the information from each commit message, this study uses keyword based identifier~\cite{rosen2015commit,hindle2008large,vasilescu2015quality} to label commits as buggy commit or not by identifying commits which were used to fix some bugs in the code and then identifies the last commit which introduced the bug. This commit is labeled as \textit{buggy commit}. \subsection{Metric Extraction} \label{sec:Experimental Setup} \subsubsection{Process Metrics} \label{sec:process metrics} Recall that the developer code interaction graph records who touched what and whose code, where a developer is defined as a person who has ever committed any code into the codebase. We create that graph as follows: \begin{itemize} \item Project commits were extracted from each branch in the git history. \item Commits are extracted from the git log and stored in a file system. \item To access the file changes in each commit we recreate the files that were modified in each commit by (a)~continuously moving the {\tt git head} chronologically on each branch. Changes were then identified using {\tt git diff} on two consecutive git commits. \item The graph is created by going through each commit and adding a node for the committer. Then we use {\tt git blame} on the lines changed to find previous commits following a similar process of SZZ algorithm~\cite{williams2008szz}. We identify all the developers of the commits from {\tt git blame} and add them as a node as well. \item After the nodes are created, directed edges were drawn between the developer who changed the code, to whose code was changed. Those edges were weighted by the change size between the developers. \end{itemize} \subsubsection{Personnel Metrics} \label{sec:Personnel Metrics} Recall that the developer social interaction graph records who talked to each other via issue comments. We create that graph as follows. \begin{itemize} \item A node is created for the person who has created the issue, then another set of nodes are created for each person who has commented on the issue. So essentially in Social interaction graph each node in the graph is any person (developer or non-developer) ever created an issue or commented on an issue. \item The nodes are connected by directed edges, which are created by (a) connecting from the person who has created the issue to all the persons who have commented in that issue and (b) creating edges from the person commenting on the issue to all other persons who have commented on the issue, including the person who has created the issue. \item The edges are weighted by the number of comments by that person. \item The weights are updated using the entire history of the projects. The creation and weight update is similar to Figure~\ref{fig:social_interaction_graph}. \end{itemize} \begin{figure*} \centering \scriptsize \noindent \centering \begin{tikzpicture} \node[main node,minimum size=0.8cm,fill={gray!20}] (v_{1}) {Ananya}; \node[main node,minimum size=0.8cm,fill={gray!20}] (v_{2}) [right = 0.7cm of v_{1}] {Maria}; \node[main node,minimum size=0.8cm,fill={gray!20}] (v_{3}) [below = 0.7cm of v_{2}] {Chen}; \node[main node,minimum size=0.8cm,fill={gray!20}] (v_{4}) [left = 0.7cm of v_{3}] {David}; \end{tikzpicture} \hspace{3em} \begin{tikzpicture} \node[main node,minimum size=0.8cm,fill={gray!20}] (v_{1}) {Ananya}; \node[main node,minimum size=0.8cm,fill={gray!20}] (v_{2}) [right = 0.7cm of v_{1}] {Maria}; \node[main node,minimum size=0.8cm,fill={gray!20}] (v_{3}) [below = 0.7cm of v_{2}] {Chen}; \node[main node,minimum size=0.8cm,fill={gray!20}] (v_{4}) [left = 0.7cm of v_{3}] {David}; \path[draw,thick,->] (v_{1}) edge node[midway,above] {$ {1} $} (v_{2}) (v_{1}) edge node[midway,above] {$ {1} $} (v_{3}) (v_{1}) edge node[midway,left] {$ {1} $} (v_{4}); \end{tikzpicture} \hspace{3em} \begin{tikzpicture} \node[main node,minimum size=0.8cm,fill={gray!20}] (v_{1}) {Ananya}; \node[main node,minimum size=0.8cm,fill={gray!20}] (v_{2}) [right = 0.7cm of v_{1}] {Maria}; \node[main node,minimum size=0.8cm,fill={gray!20}] (v_{3}) [below = 0.7cm of v_{2}] {Chen}; \node[main node,minimum size=0.8cm,fill={gray!20}] (v_{4}) [left = 0.7cm of v_{3}] {David}; \path [->,bend left=10,thick] (v_{1}) edge node[midway,above] {$ {1} $} (v_{2}) (v_{1}) edge node[right,above] {$ {1} $} (v_{3}) (v_{1}) edge node[midway,right] {$ {1} $} (v_{4}) (v_{2}) edge node[midway,below] {$ {1} $} (v_{1}) (v_{2}) edge node[midway,right] {$ {1} $} (v_{3}) (v_{2}) edge node[right,above] {$ {1} $} (v_{4}) (v_{3}) edge node[left,left] {$ {1} $} (v_{1}) (v_{3}) edge node[midway,left] {$ {1} $} (v_{2}) (v_{3}) edge node[midway,below] {$ {1} $} (v_{4}) (v_{4}) edge node[midway,left] {$ {1} $} (v_{1}) (v_{4}) edge node[midway,below] {$ {1} $} (v_{2}) (v_{4}) edge node[midway,above] {$ {1} $} (v_{3}); \end{tikzpicture} \hspace{3em} \begin{tikzpicture} \node[main node,minimum size=0.8cm,fill={gray!20}] (v_{1}) {Ananya}; \node[main node,minimum size=0.8cm,fill={gray!20}] (v_{2}) [right = 0.7cm of v_{1}] {Maria}; \node[main node,minimum size=0.8cm,fill={gray!20}] (v_{3}) [below = 0.7cm of v_{2}] {Chen}; \node[main node,minimum size=0.8cm,fill={gray!20}] (v_{4}) [left = 0.7cm of v_{3}] {David}; \node[main node,minimum size=0.8cm,fill={gray!20}] (v_{5}) [left = 0.7cm of v_{1}] {Vadim}; \path [->,bend left=10,thick] (v_{1}) edge node[midway,above] {$ {1} $} (v_{2}) (v_{1}) edge node[midway,above] {$ {1} $} (v_{3}) (v_{1}) edge node[midway,right] {$ {1} $} (v_{4}) (v_{2}) edge node[midway,above] {$ {1} $} (v_{1}) (v_{2}) edge node[midway,right] {$ {1} $} (v_{3}) (v_{2}) edge node[midway,left] {$ {1} $} (v_{4}) (v_{3}) edge node[midway,above] {$ {1} $} (v_{1}) (v_{3}) edge node[midway,left] {$ {1} $} (v_{2}) (v_{3}) edge node[midway,left] {$ {1} $} (v_{4}) (v_{4}) edge node[midway,left] {$ {1} $} (v_{1}) (v_{4}) edge node[midway,above] {$ {1} $} (v_{2}) (v_{4}) edge node[midway,left] {$ {1} $} (v_{3}); \end{tikzpicture} \hspace{3em} \begin{tikzpicture} \node[main node,minimum size=0.8cm,fill={gray!20}] (v_{1}) {Ananya}; \node[main node,minimum size=0.8cm,fill={gray!20}] (v_{2}) [right = 0.7cm of v_{1}] {Maria}; \node[main node,minimum size=0.8cm,fill={gray!20}] (v_{3}) [below = 0.7cm of v_{2}] {Chen}; \node[main node,minimum size=0.8cm,fill={gray!20}] (v_{4}) [left = 0.7cm of v_{3}] {David}; \node[main node,minimum size=0.8cm,fill={gray!20}] (v_{5}) [left = 0.7cm of v_{1}] {Vadim}; \path [->,bend left=10,thick] (v_{1}) edge node[midway,above] {$ {1} $} (v_{2}) (v_{1}) edge node[midway,above] {$ {1} $} (v_{3}) (v_{1}) edge node[midway,right] {$ {2} $} (v_{4}) (v_{2}) edge node[midway,above] {$ {1} $} (v_{1}) (v_{2}) edge node[midway,right] {$ {1} $} (v_{3}) (v_{2}) edge node[midway,left] {$ {1} $} (v_{4}) (v_{3}) edge node[midway,above] {$ {1} $} (v_{1}) (v_{3}) edge node[midway,left] {$ {1} $} (v_{2}) (v_{3}) edge node[midway,left] {$ {1} $} (v_{4}) (v_{4}) edge node[midway,left] {$ {2} $} (v_{1}) (v_{4}) edge node[midway,above] {$ {1} $} (v_{2}) (v_{4}) edge node[midway,left] {$ {1} $} (v_{3}) (v_{5}) edge node[midway,left] {$ {1} $} (v_{1}) (v_{5}) edge node[midway,left] {$ {1} $} (v_{4}) (v_{1}) edge node[midway,above] {$ {1} $} (v_{5}) (v_{4}) edge node[midway,above] {$ {1} $} (v_{5}); \end{tikzpicture} \caption{\textbf{Example of creating a social interaction graph between four GitHub developers.} \textbf{Step 1 (LHS):} Ananya,Maria,Chen and David are four developers in a GitHub project. \textbf{Step 2:} Ananya creates one issue where Maria,Chen and David comment. So, we join Ananya-Maria,Ananya-Chen,Ananya-David with edge of weight 1. \textbf{Step 3:} A new developer Vadim comes. \textbf{Step 4 (RHS):} Vadim creates one new issue where Ananya and David comments. So, two new edges are introduced - (Ananya-Vadim(1), David-Vadim(1)). Now we iterate for each developer, so all of them become connected and lastly, weight of Ananya-David increases to 2.} \label{fig:social_interaction_graph} \end{figure*} \subsubsection{Product Metrics} \label{sec:Product Merics} This study explores the effects of social and code communication to assess code quality, by measuring the percentage of buggy commits introduced by developers (hero and non-hero developers), but in order to do so we do need to identify the commits that introduced the bug in the code from the historic project data. This is a challenging task since there is no direct way to find the commits or the person who is responsible for the bug/issue introduction. Hence, our scripts proceed as follows: \begin{itemize} \item Starting with all the commits from {\tt git log}, we identify the commit messages. \item Next, to use the commit messages for labeling, we apply natural language processing~\cite{hindle2008large,rosen2015commit} (to do stemming, lemmatization and lowercase conversion to normalize the commit messages). \item Then to identify commit messages which are representation of bug/issue fixing commits, a list of words and phrases is extracted from previous studies of 1000+ projects (Open Source and Enterprise). The system checked for these words and phrases in the commit messages and if found, it marks these as commits which fixed some bugs. \item To perform sanity check, 5\% of the commits was manually verified by 7 graduate students using random sampling from different projects. Disagreements between manual labeling and keyword based labeling was further verified and keywords were added or removed to improve performance. \item These labeled commits were then processed to extract the file changes as the process mentioned in process metrics section~\ref{sec:process metrics}. \item Finally, {\tt git blame} is used to go back in the git history to identify a responsible commit where each line was created or changed last time. \end{itemize} By this process, commits that were responsible for introduction of the bugs in the system/project can be found. We label these commits as ``buggy commits'' and label the author of the commit as the ``person responsible'' for introducing the bug. \subsubsection{Final Feature Extraction} \label{sec:Finding Relation} To assess the prevalence of heroes in the software projects, we joined across all the metrics shown above. Specifically, using the two graphs, we calculated the node degree (number of edges touching a vertex) of the graphs (and note that vertices with higher degree represent more communication or interaction). For the sake of completeness, we varied our threshold of ``hero'' to someone belonging to 80\%, 85\%, 90\% and 95\% of the communication. In our studies,top contributors (or heroes) and non-heroes were defined as : \begin{equation} \label{eq:node-Degree} \mbox{ Node Degree of } N_i = D(N_i)= \sum_{j=1}^{n} a_{ij} \end{equation} \begin{equation} \label{eq:hero} \mbox{ Hero} = Rank\left(D(N_i)\right) > \frac{P}{100}*(N + 1) \end{equation} \begin{equation} \label{eq:non-hero} \mbox{ Non-Hero} = Rank\left(D(N_i)\right) < \frac{P}{100}*(N + 1) \end{equation} where: \begin{table}[h] \centering \begin{tabular}{|l|l|} \hline N & Number of Developers \\ \hline P & 80,85,90 and 95 Percentile \\ \hline Rank() & \begin{tabular}[c]{@{}l@{}}The percentile rank of a score is the percentage \\ of scores in its frequency distribution that is\\ equal to or lower than it.\end{tabular} \\ \hline a & \begin{tabular}[c]{@{}l@{}}Adjacency matrix for the graph \\ where $a_{ij}>0$ denotes a connection\end{tabular} \\ \hline \end{tabular} \end{table} Using these data and by applying the hero definition from formula (\ref{eq:hero}) and (\ref{eq:non-hero}) (look at the top 20\%,15\%,10\% and 5\%), we can find the developers who are responsible for 80\%,85\%,90\% and 95\% of the work. We use this to categorize the developers into 2 groups: \begin{itemize} \item The \textit{hero developers}; i.e. the core group of the developers of a certain project who make regular changes in the codebase. In this study this is represented by the developers whose node degree is above 80,85,90 and 95th percentile of the node degree (developers' communication and code interaction of the system graph). \item The \textit{non-hero developers} are all other developers; i.e. developers associated with nodes with a degree below the respective threshold percentile. \end{itemize} Following this for each selected projects, we merge the product data collected in section~\ref{sec:Product Merics} and section~\ref{sec:process metrics} to find each developer's code contribution according to the code interaction graph. Similarly process is followed for section~\ref{sec:Personnel Metrics} and section~\ref{sec:process metrics} in the social interaction graph. Using the above mentioned data, we can validate the code and social contribution of each developer along with their bug introduction percentage. This information will help us to answer the research questions asked in this study. \section{Results} \label{sec:Results} Our results are structured around three research questions: \begin{description} \item[{\bf RQ1:}] How common are hero projects? \item[{\bf RQ2:}] What impact does heroism have on code quality? \item[{\bf RQ3:}] Does the results support Herbsleb Hypothesis? \end{description} \subsection*{\textbf{RQ1: \textit{How common are hero projects?}}} Figure~\ref{fig:RQ1_following} shows the result for number of projects marked as hero and non-hero when the we vary the threshold from ``hero-ness'' from 80 to 95\%.The clear conclusion from this figure is that the phenomenon that we have defined as ``hero`` is very common. In fact, the phenomenon may be more pronounced than previously reported. Even when we require heroes to be involved in 95\% of the communication (which is a large amount), we find that that majority of the projects studied here exhibit ``hero-ness''. That is: \begin{result} Hero projects are overwhelmingly present in open source software community. That is, in the usual case, there are very few people in each project responsible for majority of the work. \end{result} \begin{figure} \includegraphics[width=\linewidth]{RQ1_Code.png} \caption{RQ1 Result: Distribution of hero projects vs non-hero projects based on hero threshold being 80\%, 85\%, 90\% and 95\% respectively. Here threshold being 80\% means in that project 80\% code is done by less than 20\% of developers} \label{fig:RQ1_following} \end{figure} \subsection*{\textbf{RQ2: \textit{What impact does heroism have on code quality?}}} RQ2 explores effect heroism have on code quality. In this study, we created the developer social interaction graph and developer code interaction graph, then identified the developer responsible for introducing those bugs into the codebase. Then we find the percentage of buggy commits introduced by those developers by checking (a)~the number of buggy commits introduced by those developers and (b)~their number of total commits. Fig~\ref{fig:RQ2_code} and Fig~\ref{fig:RQ2_social} shows the comparison between the performance of hero and non-hero developers. In those figures: \begin{itemize} \item The x-axis is different projects used in this study. \item The y-axis represents the median of the bug introduction percentage for all hero and non-hero developers for each project respectively. \end{itemize} \begin{figure}[!t] \begin{center} \includegraphics[width=.7\linewidth]{80_Code.png} \includegraphics[width=.7\linewidth]{90_Code.png} \includegraphics[width=.7\linewidth]{95_Code.png} \end{center} \caption{Code interaction graph results for RQ2: Percentage of bugs introduced by hero and non-hero developers from developer code interaction perspective in Hero Projects .} \label{fig:RQ2_code} \end{figure} Here projects are sorted by the number of non-hero developers. In those charts we note that: \begin{itemize} \item There exists a large number of non-heroes who always produce buggy commits, 100\% of the time (evidence: the flat right-hand-side regions of the non-hero plots in both figures). That population size of ``always buggy'' is around a third in Fig~\ref{fig:RQ2_code} and a fourth in Fig~\ref{fig:RQ2_social}. \item To say the least, heroes nearly always have fewer buggy commits than non-heroes. The 25th, 50th, 75th percentiles for both groups are shown in Table~\ref{tbl:team_size}. This table clearly shows why heroes are so prevalent, they generate commits that are dramatically less buggy than non-heroes, regardless of the size of the project. \end{itemize} \begin{figure}[]\begin{center} \includegraphics[width=.7\linewidth]{80_Social.png} \includegraphics[width=.7\linewidth]{90_Social.png} \includegraphics[width=.7\linewidth]{95_Social.png} \end{center} \caption{Social interaction graph results for RQ2: Percentage of bugs introduced by hero and non-hero developers from developer social interaction perspective in Hero Projects.} \label{fig:RQ2_social} \end{figure} \begin{table}[!b] \caption{The table summarizes of Fig~\ref{fig:RQ2_code}, Fig~\ref{fig:RQ2_social} and stratifies the data according to 25th, 50th and 75th percentile of the developers.} \label{tbl:team_size} \begin{center} \begin{tabular}{|c|c|c|c|c|} \hline \rowcolor[HTML]{EFEFEF} \textbf{} & \textbf{} & \multicolumn{3}{c|}{\cellcolor[HTML]{EFEFEF}\textbf{Percentile}} \\ \hline \rowcolor[HTML]{EFEFEF} \textbf{Metric} & \textbf{Group} & \textbf{25th} & \textbf{50th} & \textbf{75th} \\ \hline & \textbf{Hero} & 0.52 & 0.58 & 0.53 \\ \cline{2-5} & \textbf{Non-Hero} & 0.67 & 0.75 & 1.0 \\ \cline{2-5} \multirow{-3}{*}{\textbf{Code Interaction}} & \textbf{Ratio} & 1.3 & 1.3 & 1.9 \\ \hline & \textbf{Hero} & 0.44 & 0.5 & 0.5 \\ \cline{2-5} & \textbf{Non-Hero} & 0.67 & 0.75 & 0.67 \\ \cline{2-5} \multirow{-3}{*}{\textbf{Social Interaction}} & \textbf{Ratio} & 1.5 & 1.5 & 1.3 \\ \hline \end{tabular} \end{center \end{table} The other thing to note from Fig~\ref{fig:RQ2_code} and Fig~\ref{fig:RQ2_social} is that they are nearly identical. That is, no matter how we define ``hero'', we reach the same conclusions. Hence we say - \begin{result} In modern software projects, reflecting on who writes most of the code is just as insightful as reflecting on who participates in most of the discussion about the code. \end{result} \subsection*{\textbf{RQ3: \textit{Do the results support Herbsleb Hypothesis?}}} In this research question, we explored the Herbsleb hypothesis~\cite{Herbsleb:2014} from section~\ref{sec:Background And Prior Work}; i.e. does lack of communication between developers predict for bugs in the code? In order to do that for 1,037 projects, we discretized the developers into 3 groups (i.e. High, Medium and Low) based on their code contribution (Code Node Degree) and social communication frequency (Social Node Degree). In Table~\ref{fig:Herbsleb_stats}, group HH (High,High) represents the developers who have high high code contribution and social communication frequency and the value in the cell is median bug introduction percentage, while group LL (Low,Low) represents the developers who have low code contribution and low social communication frequency. \begin{table}[!h] \centering {\small {\small \begin{tabular}{lcrrc} \arrayrulecolor{darkgray} \rowcolor{gray!60} rank & group (code,social) & median & IQR & \\ 1 & L,H & 30 & 29 & \quart{18}{30}{29}{17} \\ 1 & M,H & 38 & 28 & \quart{26}{38}{28}{16} \\ \hline 2 & L,M & 38 & 31 & \quart{25}{38}{31}{18} \\ 2 & H,H & 42 & 18 & \quart{33}{42}{18}{9} \\ 2 & M,M & 46 & 21 & \quart{35}{46}{21}{10} \\ 2 & H,M & 46 & 21 & \quart{33}{46}{21}{8} \\ 2 & H,L & 48 & 30 & \quart{34}{48}{30}{16} \\ \hline 3 & M,L & 52 & 29 & \quart{38}{52}{29}{15} \\ \hline 4 & L,L & 67 & 55 & \quart{45}{67}{55}{33} \\ \end{tabular}} } \caption{This figure shows the result of statistical significance test and an effect size test on 9 different groups used to study the Herbsleb hypothesis. In this figure the ``group'' column represents the 9 different groups in this research question, where the first character represents the code node degree, while the later is social node degree. } \label{fig:Herbsleb_stats} \end{table} Table~\ref{fig:Herbsleb_stats} shows the result of statistical test performed on the 9 different groups representing different frequency and volume of communication. The ``rank'' column of that table shows a statistical analysis where one row has a higher rank than the previous one only if the two rows are \begin{itemize} \item Statistically {\em significant different.} For this test, we used the the Scott-Knot method recommended by Angelis and Mittas at TSE'13~\cite{mittas13}. \item And that difference is {\em not a small effect}. For this effect size test, we used the the A12 test recommended by Angelis and Briand at ICSE'11~\cite{arcuri11} \end{itemize} These statistical tests were selected since they were non-parametric; i.e. they do not assume normal distributions. To summarize the effect reported in Table~\ref{fig:Herbsleb_stats}, we need to look at the difference between the highest and lowest ranks: \begin{itemize} \item In the groups with highest defects and highest rank, the social and coding groups are both low. That, is non-hero-ness (for both code and social interaction) is associated with worst quality code. \item In the groups with lowest defects and lowest rank, the social group is always high while the code groups are either low or medium. That is, extensive social interaction even with low to medium code interaction is associated with best quality code. \end{itemize} From the above, we can say that:\ \begin{itemize} \item Prior definitions of ``hero'' based just on code interaction need now to be augmented. As shown in Table~\ref{fig:Herbsleb_stats}, social hero-ness is much more predictive for bugs than merely reflecting on code hero-ness \item Also, these results support the Herbsleb hypothesis, which suggests communication between developers is an important factor and lesser social communication can lead to more bugs. \end{itemize} This finding leads to the following conjecture (to be explored in future work): the best way to reduce communication overhead and to decrease defects is to {\em centralize the communicators}. In our data, commits with lower defects come from the small number of hero developers who have learned how to talk to more people. Hence, we would encourage more research into better methods for rapid, high-volume, communication in a one-to-many setting (where the ``one'' is the hero and the ``many'' are everyone else). In summary, we can say \begin{result} The Herbsleb hypothesis holds true for open source software projects. More research should be performed to find better methods for rapid, high-volume, communication in a one-to-many setting. \end{result} \section{Discussion} \label{sec:Discussion} One strange feature of our results is that what is old is now new. Our results (that heroes are important) echo a decades old concept. In 1975, Fred Brooks wrote of ``surgical teams'' and the ``chief programmer'' ~\cite{brooks1974mythical}. He argued that: \begin{itemize} \item Much as a surgical team during surgery is led by one surgeon performing the most critical work, while directing the team to assist with less critical parts. \item Similarly, software projects should be led by one ``chief programmer'' to develop critical system components while the rest of a team provides what is needed at the right time. \end{itemize} Brooks conjecture that ``good'' programmers are generally much more as productive as mediocre ones. This can be seen in the results that hero programmers are much more productive and less likely to introduce bugs into the codebase. Heroes are born when developers become are so skilled at what they do, that they assume a central position in a project. In our view, organizations need to acknowledge their dependency on such heroes, perhaps altering their human resource policies and manage these people more efficiently by retaining them. \section{Threats to Validity} \label{sec:Threats to Validity} \subsection{Sampling Bias} Our conclusions are based on 1000+ open source GitHub projects that started this analysis. It is possible that different initial projects would have lead to different conclusions. That said, our initial sample is very large so we have some confidence that this sample represents an interesting range of projects. \subsection{Evaluation Bias} In RQ1,RQ2 and RQ3, we said that heroes are prevalent and responsible for far less bug introduction than non-hero developers. It is possible that, using other metrics\footnote{E.g. do heroes reduce productivity by becoming bottleneck} then there may well be a difference in these different kinds of projects. But measuring people resources only by how fast releases are done or issues are fixed may not be a good indicator of measuring affects of having heroes in team. This is a matter that needs to be explored in future research. Another evaluation bias as we report cumulative statistics of lift curves where other papers reported precision and recall. The research in this field is not mature enough yet for us to say that the best way to represent results is one way versus another. Here we decided to use lift curves since, if we d used precision and recall, we had to repeat that analysis at multiple points of the lift curve. We find our current lift curves are a succinct way to represent our results. \subsection{Construct Validity} At various places in this report, we made engineering decisions about (e.g.) team size; and (e.g.) what constitutes a ``hero'' project. While those decisions were made using advice from the literature (e.g.~\cite{gautam2017empirical}), we acknowledge that other constructs might lead to different conclusions. That said, while we cannot prove that all of our constructs are in any sense ``optimum'', the results of Table~\ref{fig:Herbsleb_stats} suggest that our new definition of social hero-ness can be more informative than constructs used previously in the literature (that defined ``hero'' only in terms of code interaction). Another issue about our construct validity is that we have relied on a natural language processor to analyze commit messages to mark them as buggy commits. These commit messages are created by the developers and may or may not contain proper indication of if they were used to fix some bugs. There is also a possibility that the team of that project might be using different syntax to enter in commit messages. Yet another threat to construct validity is that we did not consider the different roles of the developers. We had trouble extracting that information from our data source, we found that people have multiple roles particularly our heroes who would often step in and assist in multiple activities. Nevertheless the exploration of different roles would be an interesting study. \subsection{External Validity} Previously Agrawal et al. were able to comment on the effects of hereos in open and closed source projects. That research group was fortunate enough to work on-site at a large open source software company. We were not as fortunate as them. We therefore acknowledge our findings (from open source projects) may not be the same for closed source projects. Similarly we have used GitHub issues and comments to create the communication graph, It is possible that the communication was not made using these online forums and was done with some other medium. To reduce the impact of this problem, we did take precautionary step to (e.g.,) include various tag identifiers of bug fixing commits, did some spot check on projects regarding communication etc. Our conclusion shows that almost all (when experimenting with 80\%, 85\%, 90\% threshold) of our sample projects are hero dominated. In case of large size public GitHub projects, there are official administrators and maintainers who are responsible for issue labelling or assigning. So, they frequently comment on all of the issues but though they are not active developers. These people should not be considered as hero developers. Finding these people needs manual inspection which is not possible for 1000+ projects. We decide to put it as a limitation of our study as we deal with a huge number of projects. We do not isolate hero projects and non-hero projects and look into them separately because there are very few non-hero projects and also there are a lot of developers who work in a large number of projects (some of them are hero projects and some of them are not). \section{Conclusion} \label{sec:Conclusion} The established wisdom in the literature is to depreciate ``heroes'', i.e., a small percentage of the staff who are responsible for most of the progress on a project. But, based on a study of 1000+ open source GitHub projects, we assert: \begin{itemize} \item Overwhelmingly, most projects are hero projects. \item Hero developers are far less likely to introduce bugs into the codebase than their non-hero counterparts. Thus having heroes in projects significantly affects the code quality. \end{itemize} Our empirical results call for a revision of a long-held truism in software engineering. Software heroes are far more common and valuable than suggested by the literature, particularly from code quality perspective. Organizations should reflect on better ways to find and retain more of these software heroes. More generally, we would comment that it is time to reflect more on long-held truisms in our field. Heroes are widely deprecated in the literature, yet empirically they are quite beneficial. What other statements in the literature need to be reviewed and revised? \section{Acknowledgements} \label{sec:ack} This work was partially funded by NSF Grant \#1908762. \bibliographystyle{plain}
{'timestamp': '2020-01-23T02:12:11', 'yymm': '1904', 'arxiv_id': '1904.09954', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.09954'}
arxiv
\section{Introduction}\label{sec:introduction} \IEEEPARstart{I}{mage} Super-Resolution (SR) has emerged as one of the most significant ill-posed image processing and vision problems due to a variety of applications in civilian domains as well as in law enforcement \cite{park2003super}. With an increase in the number of mobile cameras and devices, enhancing resolution via a fast, memory efficient process is highly desirable. SR problems are divided into multi-image SR \cite{farsiu2004fast, farsiu2004advances, yuan2012multiframe, li2010multi} and Single Image SR (SISR) according to the number of images required. Multi-image SR methods exploit geometric diversity in a set of LR images (of the same scene) to enhance resolution. The performance of these methods is limited by the number of LR images available and the success of geometric alignment/transformation methods that model the differences in the LR image set \cite{farsiu2004advances}. SISR has been of more recent interest and has been addressed largely by dictionary-based and sparsity constrained learning methods and more recently via deep learning algorithms. A typical learning/example based SR approach employs two dictionaries of HR/LR images/patches \cite{mallat2010super,chang2004super,glasner2009super,yang2010image,kim2010single}. These dictionaries are often learned with sparse-coding methods to reconstruct the SR results. Many of these methods require handcrafted dictionary features which are not readily available \cite{zhang17image}. Section \ref{sec:SR} discusses these methods in detail. Recently, deep learning methods have been shown to produce compelling state-of-the-art SR results and across a variety of different image collections \cite{Timofte_2017_CVPR_Workshops}. One of the earliest deep SR methods was SRCNN \cite{dong2014learning} and it has been extended to train multiple coupled networks \cite{tiantong16deep, bruna2015super, dong2016image,dong2016accelerating}. Other variants include \cite{wang2015self} which uses self-similar patches to explore the self-example based SR idea. Progressive \cite{lai2017deep}~and recursive networks \cite{kim2016deeply} also generate improved results with the help of diversified training data such as NTIRE\cite{Timofte_2017_CVPR_Workshops}. These spatial domain mappings were boosted by global and local bypass structures as introduced in residual learning \cite{Kim_2016_VDSR}. A key benefit of residual network structures is that they significantly reduce the training burden of the deep CNN, which is still constructed in the spatial domain. \textbf{Motivation}: A recent trend is deep SR but by mapping LR to HR image in the transform domain, such as the Discrete Fourier Transform (DFT) or Discrete Wavelet Transform (DWT) \cite{Timofte_2017_CVPR_Workshops,guo2017deep,Junxuan2017}. These methods show improved results by exploiting the ability of an image transform to separate coarse and fine details of an image and hence simplifying the SR task. Specifically, the DWT has been extensively explored for the SR problem in traditional model-based frameworks \cite{zhao2003wavelet,robinson2010efficient,wahed2007image,ji2009robust} and more recently also in deep networks \cite{guo2017deep}. We propose and develop a new adaptable transform domain deep SR method. Our starting point is the image DCT domain, in particular recognizing that the differences between a given LR-HR image pair manifest as change in high-frequency information while they typically share the same low-frequency signature (see analysis in Section \ref{sec:format}). The \textbf{contributions} of this paper are as follows: \begin{enumerate} \item We propose a novel network structure that addresses the SR problem in an image transform domain: the transform as well as its inverse are part of the network; providing an end-to-end SR mapping. \item We build a new convolutional DCT (CDCT) layer integrating the DCT procedure into the Deep SR network (DCT-DSR); as a key extension we generalize the CDCT to a transform layer allowing its filters to be trainable, so that we can optimize the image transform specifically for the image SR task. \item We add pairwise orthogonality constraint on the newly introduced `transform layer' to allow for efficient forward and inverse transform computations. This Orthogonally Regularized Deep SR network (ORDSR) simplifies the SR task by taking advantage of image transform domain while adapting the design of transform basis to the training image set. \item Inspired by the structure of DCT basis, which exhibit an increase in spatial complexity with index, we enforce a newly formulated {\em complexity order} constraint, which encourages the complexity of each learned basis to be close to its DCT counterpart. \item A key burden of deep SR has been identified as the requirement of generous training LR and HR image pairs; ORDSR shows a much more graceful degradation as training size is reduced with compelling improvements in the regime of limited training. \end{enumerate} To the best of our knowledge, ORDSR is the {\em first approach} that allows optimization of basis functions for transform domain image SR within a deep learning framework. A preliminary version of this work has appeared as a short conference article \cite{tiantong2018ortho}. This manuscript significantly extends the 4-page conference article: First, the complexity order constraint is introduced in this work for the first time and the network structure is modified for better performance. Second, more analytical descriptions are added to explain the formulation and the training procedure of the new regularized deep network. Third, more comprehensive experiments are reported over the short conference article. This includes detailed comparisons against state-of-the-art deep learning based SR methods and the impact of network configuration on performance, including discussions about DCT-DSR. Fourth, we extend the test image sets from Set5 \cite{bevilacqua2012low} and Set14 \cite{zeyde2010single} to additionally include BSD100 \cite{MartinFTM01} and Urban100 \cite{huang2015single}, each containing 100 test images. Fifth, a crucial new investigation is reported w.r.t varying training size(s) and ORDSR shows graceful degradation against a reduction in the number of training LR-HR pairs. Finally, an analysis of memory and computation is included to demonstrate the efficiency of ORDSR against competing alternatives. This paper is organized as follows: Section \ref{sec:related} reviews related literature; Section \ref{sec:format} presents a new DCT domain Deep SR network (DCT-DSR) and extensions to a regularized network that allows the `transform layer' to be trainable (ORDSR). Section \ref{sec:exp} provides experimental validation on benchmark datasets in both abundant and limited training scenarios. Section \ref{sec:conclusion} concludes the paper with thoughts for future work. \section{Related Work}\label{sec:related} \subsection{Single Image Super-Resolution}\label{sec:SR} In the literature on learning-based methods for SR, sparse-coding methods have shown to be particularly effective \cite{yang2010image,yang2008image}. These techniques employ two dictionaries containing example LR and HR images/image patches. The goal is to then represent an LR image (or patch) in terms of its sparse code obtained via an LR dictionary. An HR image is obtained by using the same sparse code but applied to the dictionary of HR image patches. Several extensions of sparsity based SR have been developed including \cite{zeyde2010single,mallat2010super,kim2010single}. The focus of these methods has been to design/learn more suitable dictionaries and to find the optimal sparse representations of image patches, often by using suitable prior structure on the dictionary/sparse code \cite{mousavi2017sparsity}. In addition to sparse-coding based methods, self-example based methods have demonstrated success by exploring the self-similarity of the patches from the input image itself \cite{glasner2009super, yang2010exploiting, FreFat10}. \subsection{SR With Image Transform Domain} In the sense of decomposing the image in terms of its different frequency components by an image transform, it is well acknowledged that the visual gaps which need to be filled between the LR and HR images lay within the high-frequency components of the image \cite{park2003super}. Producing SR results from LR input essentially becomes a problem of recovering the high-frequency components of the image based on the LR input, whose high-frequency details are missing. Transform domain methods can enable an alternate image representation where the SR mapping may be simpler and hence learned easily and accurately. The wavelet transform has been a popular choice \cite{robinson2010efficient,zhao2003wavelet,ji2009robust,nguyen2000efficient,jiji2004single,wahed2007image,anbarjafari2010image} for traditional image SR. Recently, \cite{guo2017deep} developed a CNN network to reconstruct wavelet coefficients of the HR image yielding significant practical improvements. \subsection{Deep Learning for Image Super-Resolution}\label{sec:deepsr} Other than the conventional SR methods, recently advanced computational abilities brought on by Graphic Computation Units (GPUs) have boosted research on deep CNNs for SR. These methods have quickly become the new state-of-the-art performance standard \cite{Kim_2016_VDSR, dong2016image}. Deep learning SR methods can further be divided into two classes: methods that focus on maintaining strong fidelity against ground truth HR image and those that encourage perceptually motivated and visually attractive results. A key example of the latter is Generative Adversarial Networks (GANs) \cite{goodfellow2014generative} such as \cite{johnson2016perceptual} which develops a photo-realistic styled SR method by sampling an HR image patch from an estimated distribution of the natural image patches. GAN based methods provide visually pleasing results but pay less attention to maintain pixel-value fidelity to the original HR data \cite{ledig2017photo}, which makes them unsuitable for certain practical settings. Our proposed work is consistent with a majority of the literature \cite{Timofte_2017_CVPR_Workshops} where the goal is to recover the HR image and training is based on minimizing the difference between network estimated SR and ground truth HR images. Specifically for SR, Dong et al. introduced an SR CNN with three layers that outperformed previous sparse-coding based methods by a considerable margin and set the tone of using CNN for SR problems \cite{dong2014learning,dong2016image}. SRCNN can be viewed as a non-linear mapping function between the input LR image and the target HR image. It takes the input as a whole and uses different filters convolving with the input image to generate different feature representations which later on are convolved with following neural layers for higher level representations. It has shown promising experimental performance and great flexibility with different neural network configurations. Since then, different efforts have been made to boost CNN performance by introducing deeper structures \cite{dong2016accelerating}, utilizing residual bypasses by adding the input directly to the output of the CNN \cite{Kim_2016_VDSR}, creating different branches of networks to handle specific features \cite{Timofte_2017_CVPR_Workshops}, etc. Fully Connected Networks have shown a considerable improvement in SR performance by combining ideas from sparse-coding\cite{tiantong16deep}. Prior information \cite{mousavi2018deep} has shown recent promise in the deep learning framework. \cite{chen2018fsrnet} uses the face prior to help composing the human face SR images, while \cite{wang2018recovering} uses the structural feature priors to guide the network towards recovering detailed features. Another combination of image transform domain and CNN was proposed recently \cite{Junxuan2017}. Li {\it et al.} convert an input image into its Fourier Domain and feed the DFT coefficients to the CNN. Since convolution of the filters and the image in the spatial domain is equivalent to the multiplications of the image and filters' corresponding Fourier Coefficients in Fourier Domain, they claim the operations of a CNN now becomes element-wise multiplications which speed up the training and inference of the network. Experimentally, the performance of this work is not at par with state of the art. Another limitation is the requirement of pre and post processing steps to compute the DFT/IDFT. Our work seeks to advance deep SR by developing an adaptable transform domain method (which we refer to as DCT-DSR). Analytically, we aim to exploit the full potential of image transforms and hence enable their explicit optimization (learning) via a new network structure and a regularized cost function (we refer to this method as ORDSR). Experimentally, our focus is on efficiency in the network: in the sense of memory, computation and the ability to succeed even in limited training regimes, which are inherent to domains such as radar and medical imaging \cite{vishal2017image,he2012learning,wu2016super ,bahrami2016reconstruction}. \begin{figure}\centering \includegraphics[width=0.7\linewidth]{./figs/DCTb.pdf}\vspace{-2pt}\sqz \caption{ With $N=8$: \textit{left}: the 64 DCT basis family; \textit{right}: the last DCT basis $\mathbf{w}^\text{dct}_{7,7}$, which has size of $8\times 8$.}\label{fig:dct_basis} \end{figure} \section{Orthogonally Regularized Deep SR} \label{sec:format} We first briefly review the DCT, IDCT and the SR problem with DCT. Then, we describe the ORDSR network structure while detailing the training and inference procedures. This paper uses following notations: $*$ denotes the convolution operation; $vec(\cdot)$ denotes the vectorization operation which converts the matrix into a column vector; $<\cdot,\cdot>_F$ denotes the real valued Frobenius inner product.\label{p:def} \subsection{DCT, IDCT and Super-resolution}\label{sec:DCTIDCT} An image $\mathbf{x}(n_1, n_2)$ of size $H\times W$ can be decomposed into $H/N\times W/N$ blocks of size $N\times N$.\footnote{We assume $H$ and $W$ are multiples of $N$ for simplicity of notation.} For the $(m,n)^{th}$ block, the DCT coefficients are computed as: \begin{equation}\resizebox{0.9\linewidth}{!}{$ \mathbf{X}_{m,n}(k_1,k_2) = \sum\limits_{n_2=0}^{N-1}\sum\limits_{n_1=0}^{N-1} \mathbf{x}_{m,n}(n_1,n_2)\times \mathbf{w}^\text{dct}_{k_1,k_2}(n_1,n_2)$} \end{equation} where $k_1, k_2 \in \{0,\ldots, N-1\}$, and $\mathbf{w}^\text{dct}_{k_1, k_2}(n_1, n_2)$ is the DCT basis function, specifically DCT-II basis, defined as: \begin{equation}\resizebox{0.9\linewidth}{!}{$ \mathbf{w}^\text{dct}_{k_1, k_2}(n_1, n_2) = C_{k_1,k_2}cos\left[\frac{\pi}{N}\left(n_1+\frac{1}{2}\right)k_1\right]cos\left[\frac{\pi}{N}\left(n_2+\frac{1}{2}\right)k_2\right]$}\label{eq:dct} \end{equation} where $C_{k_1, k_2} = \frac{\sqrt{1+\delta_{k_1}}\sqrt{1+\delta_{k_2}}}{N}$ and $\delta_k=1$ if $k=0$, $\delta_k=0$ otherwise. For $N=8$, there are $8\times 8$ DCT bases and each basis $\mathbf{w}^\text{dct}_{k_1,k_2}$ is of size $8\times 8$, as shown in Fig. \ref{fig:dct_basis}. Corresponding to the DCT, the inverse DCT (IDCT) for the $(m,n)^{th}$ block is computed as: \begin{equation}\resizebox{0.9\linewidth}{!}{$ \mathbf{x}_{m,n}(n_1,n_2) = \sum\limits_{k_2=0}^{N-1}\sum\limits_{k_1=0}^{N-1}\mathbf{X}_{m,n}(k_1,k_2)\times \mathbf{w}^\text{dct}_{k_1,k_2}(n_1,n_2)$}\label{eq:idct} \end{equation} Note that classical DCT is typically performed on $N\times N$ blocks of the original image \cite{gonzalez1977digital}. \textbf{Pairwise orthogonality of Basis Functions.} The basis functions $\{\mathbf{w}^\text{dct}_{k_1,k_2}\}_{k_1,k_2 =1,1}^{N,N}\in\mathbb{R}^{N\times N}$ are pairwise orthogonal, forming an orthogonal basis family: \begin{equation} <\mathbf{w}^\text{dct}_{k_1,k_2},\mathbf{w}^\text{dct}_{l_1,l_2}>=\begin{cases}1,&\text{if }k_1=l_1, \text{ and }k_2=l_2\\0,&\text{Otherwise}\end{cases} \label{equ:orthoDCT} \end{equation} where $<\mathbf{w}^\text{dct}_{k_1,k_2},\mathbf{w}^\text{dct}_{l_1,l_2}>$ denotes the inner product of two basis functions. We now develop a reorganization of the DCT coefficients and their computation, which we show in Section \ref{sec:netstructure} helps facilitate the implementation of DCT within a CNN. \textbf{Zig-zag reorder.} We treat DCT basis functions as filters and reorganize them in a zig-zag order as shown in Fig. \ref{fig:zigzag}. \begin{figure} \centering \includegraphics[trim=0cm 0.2cm 0cm 0cm,clip,width=0.9\linewidth]{./figs/dctbb.pdf} \caption{\textit{Left}: zig-zag reorder of the DCT basis family. \textit{Right}: average coefficient values generated by $\{\mathbf{w}^\text{dct}_i\}_{i= 1}^{64}$ of \textit{lena.bmp}.}\label{fig:zigzag} \end{figure} The zig-zag function maps $\{\mathbf{w}^\text{dct}_{k_1,k_2}\}_{k_1,k_2=1,1}^{N, N}$ to $\{\mathbf{w}^\text{dct}_i\}_{i= 1}^{N\times N}$. This reordering is similar to that used in the baseline JPEG compression procedure \cite{wallace1992jpeg}. \textbf{Complexity order.} Specifically, after the zig-zag reordering, as the index $i$ increases, the complexity of $\mathbf{w}^\text{dct}_i$ also increases, \textit{i.e.} the lower end (smaller $i$) of $\{\mathbf{w}^\text{dct}_i\}_{i= 1}^{N\times N}$ is corresponding to low-frequency filters, while the higher end (bigger $i$) represents the high-frequency ones. \begin{figure*} \centering \includegraphics[trim=1cm 0cm 0cm 0cm,clip,width=0.8\linewidth]{./figs/cubes.pdf}\vspace{-2pt}\sqz\vspace{-2pt} \caption{The ORDSR network structure. Please refer to color version. Inference steps are marked with step index which is described in Section \ref{sec:test}. The CDCT layer serves two purposes: producing a DCT cube (see blue arrow) and generating SR image from an SR-DCT cube (see orange arrow).}\label{fig:ORDSR} \end{figure*} Given an HR image, and its bicubic enlarged LR version\footnote{ An image is downsampled by a factor $c$ to generate the LR version, which is enlarged to its original size using bicubic interpolation.}, we can plot the average coefficient values generated by the reordered DCT filters $\{\mathbf{w}^\text{dct}_i\}_{i= 1}^{N\times N}$, as shown in Fig.\ \ref{fig:zigzag}. In the plot in Fig.\ \ref{fig:zigzag}, the difference between the coefficients increases with the (frequency) index. This suggests that the HR image and the LR image share the same low-frequency spectra, while they differ in high frequency content. In the DCT domain hence SR becomes the problem of recovering high-frequency DCT coefficients of the HR image from the corresponding LR ones. This insight is explicitly incorporated into the the proposed ORDSR network by focusing on reconstructing the high-frequency spectra -- see Fig.\ \ref{fig:ORDSR}. \subsection{Network Structure} \label{sec:netstructure} Let us denote the bicubic enlarged LR image as $\mathbf{x}$, which is treated as preprocessing of the real input low-resolution image. Now the LR image $\mathbf{x}$ has the same size $W\times H$ as the desired HR image $\mathbf{y}$. The ORDSR network takes the $\mathbf{x}$ and produces a resolution enhanced version of $\mathbf{x}$ which is as similar as possible to $\mathbf{y}$. The network's output can be denoted as $\mathbf{\hat{y}}$. We treat the effect that the network has on the input as a nonlinear function: $F(\mathbf{x})=\mathbf{\hat{y}}$. The ORDSR consists of three major operations: \begin{enumerate} \item {\it DCT cube representation}. The input image $\mathbf{x}$ passes through a special layer called Convolutional DCT (CDCT) layer. The outputs of the CDCT are the DCT coefficients of $\mathbf{x}$ which is referred to as the DCT cube. \item {\it Non-linear mapping}. The DCT cube is fed into a $D$-layer CNN for detail restoration. The CNN serves as a non-linear mapping function using the parameters learned from the training phase to restore the missing high-frequency details of the inputs. Particularly, ORDSR adopts a residual bypass structure \cite{he2016identity,Kim_2016_VDSR,guo2017deep} for faster convergence. The DCT cube is also divided into two parts which consist of low-frequency and high-frequency spectra respectively. \item {\it IDCT reconstruction}. The output of the $D$-layer CNN and the low-frequency parts from the input are appended together to form a DCT cube for the SR image. The SR DCT cube is passed through the CDCT layer again (with the same filters) to reconstruct the SR image by performing transpose convolution (i.e. IDCT). \end{enumerate} The overall network structure is shown in Fig. \ref{fig:ORDSR}. Next we provide a detailed description of each of the three operations mentioned above. \subsubsection{DCT Cube Representation}\label{sec:dct} To integrate the DCT analysis within a deep network framework, we construct a convolutional DCT (CDCT) layer. \textbf{Initialization.} The CDCT layer is initialized using the DCT bases $\{\mathbf{w}^\text{dct}_i\}_{i= 1}^{N\times N}$. For $N=8$, there are $64$ filters $\{\mathbf{w}_i\}_{i= 1}^{64}$ of size $8\times 8$ in the CDCT layer such that the complexity (high-frequency content) increases with the filter index. We set $N=8$ for ORDSR and from now on we take specific number 64 as the filter number of the CDCT layer . \begin{figure} \centering \includegraphics[trim=0cm 0.15cm 0.15cm 0cm,clip,width=0.7\linewidth]{./figs/CDCT.pdf}\vspace{-2pt}\sqz\vspace{-2pt} \caption{ The CDCT layer takes an input image and generates a DCT cube that is divided into two parts using a threshold $T$. The figure illustrates this for $N=8$, $S=2$. }\label{fig:cdct} \end{figure} The CDCT layer performs frequency analysis differently than traditional DCT. Unlike classical DCT that produces $8\times 8$ block-wise DCT coefficients, the CDCT layer produces $64$ frequency maps $\{\mathbf{f}_i\}_{i= 1}^{64}$ for the whole image by convolving $\{\mathbf{w}_i\}_{i= 1}^{64}$ with the input image $\mathbf{x}$ as in Eq. (\ref{equ:CDCTconv}) with a stride of $S$ where $*$ is the convolution operation. Note that this stride size has a significant role in the efficiency of ORDSR as analyzed in Section \ref{sec:memy}. \begin{equation} \mathbf{f}_i = \mathbf{w}_i * \mathbf{x} \label{equ:CDCTconv}, \forall i \in \{1,...,64\} \end{equation} These maps, $\{\mathbf{f}_i\}_{i= 1}^{64}$, form a cube called DCT cube. The DCT cube is essentially a reorganized version of classical block-wise DCT coefficients of the whole image as proved in the following Proposition. \begin{prop} Eq \eqref{equ:CDCTconv} which performs a convolution of the input image $\mathbf x$ with the CDCT layer filters, $\mathbf{w}_i$, generates a reorganized version of the DCT coefficients of the image and is equivalent to DCT transformation. \noindent {\it Proof:} See in Appendix \ref{sec:apx-1}. \end{prop} As $i$ increases, $\mathbf{f}_i$ corresponds to higher frequency components of the whole image. Thus, we divide the DCT cube into two parts by a threshold $T$, namely low-frequency spectral maps $\mathbf{f}_\text{low} = \{\mathbf{f}_i\}^T_{i=1}$ and high-frequency spectral maps $\mathbf{f}_\text{high} = \{\mathbf{f}_i\}^{64}_{i=T +1}$, as shown in Fig. \ref{fig:cdct}. Because ORDSR uses an unconventional stride\footnote{ORDSR standard setups, details see Section \ref{sec:exp-setup}.} $S=2$, computation requirement is reduced -- see Section \ref{sec:memy} for details. \subsubsection{Non-linear Mapping}\label{sec:CNN} The mapping of LR to HR hi-frequency components is accomplished via a CNN consisting of $D$ convolutional layers (see Fig.\ \ref{fig:ORDSR}). Each layer has a similar operation on its input $a_l$, given by: \begin{equation} \mathbf{z}_l = \max(\mathbf{a}_l * \mathbf{W}_l + \mathbf{b}_l, 0) \label{equ:C} \end{equation} where $\mathbf{z}_l$ is the output of the $l^{th}$ layer, $\mathbf{W}_l$ and $\mathbf{b}_l$ are the weights and bias of the $l^{th}$ layer. $\mathbf{W}_l$ is a representative notation of $m_l$ filters in $l^{th}$ layer; each has a dimension of $c_l\times n_l\times n_l$. $\mathbf{b}_l$ is an $m_l$ dimensional bias vector. As is shown in Eq. (\ref{equ:C}), the convolutional layer takes the input $\mathbf{a}_l$ and applies $m_l$ convolutions on the input. This results in $m_l$ output representation maps. Then the output is processed by the ReLU operation $\max(\cdot, 0)$ \cite{nair2010rectified}. For $l=1$, the Eq. (\ref{equ:C}) represents the processing of the input layer of the CNN, i.e.\ $\mathbf{a}_1 = \{\mathbf{f}_\text{low}, \mathbf{f}_\text{high}\}$. $\mathbf{W}_1$ is a representative notation of $m_1$ filters in layer $1$, where each of the filter has size $64\times n_1\times n_1$. For $l=2,...,D-1$, Eq. (\ref{equ:C}) represents processing of the center layers, which takes the output from the previous layer $\mathbf{z}_{l-1}$ as its input $\mathbf{a}_l=\mathbf{z}_{l-1}$. These layers have identical structure. $\mathbf{W}_l$ is a representative notation of $m_l$ filters in $l^{th}$ layer where each of the filters has the size of $c_l\times n_l \times n_l$, which are specified in Section \ref{sec:exp}. Note that for CNNs, the number of the channels of each filter is equal to the number of filters of the previous layer, {\it i.e.} $c_l = m_{l-1}$. \begin{equation} \mathbf{\hat{f}}_{\text{high}} = \max(\mathbf{z}_{n-1} * \mathbf{W}_D + \mathbf{b}_D, 0)+\mathbf{f}_{\text{high}} \label{equ:C+} \end{equation} For $l=D$, the Eq. (\ref{equ:C+}) computes the output layer of the CNN, which produces the restored $\mathbf{\hat{f}}_\text{high}$. The output layer $\mathbf{W}_D$ is a representative notation of $(64-T)$ filters, where each of the filters has a size of $c_D\times n_D\times n_D$. The output layer generates $(64-T)$ detail maps. The input $\mathbf{f}_\text{high}$ is added to the network output by utilizing a residual structure. Note that our choice of a residual structure is inspired by studies \cite{he2016identity,Kim_2016_VDSR,guo2017deep} which demonstrate that predicting the difference or residuals is typically a much simpler operation from an optimization standpoint. The $\mathbf{\hat{f}}_\text{high}$ serves as the final output of the $D$-layer CNN. Collectively, let us denote the parameter sets for the CNN as $(\mathbf{\Theta}^\text{cnn}, \mathbf{B})$, where $\mathbf{\Theta}^\text{cnn}=\{\mathbf{W}_l\}_{l=1}^D$ and $\mathbf{B}=\{\mathbf{b}_l\}_{l=1}^D$. Then we denote the collective parameter sets of the ORDSR as $(\mathbf{\Theta}, \mathbf{B})$, where $\mathbf{\Theta}=\{\mathbf{\Theta}^\text{cnn},\{\mathbf{w}_i\}_{i=1}^{64}\}$, which includes the filters from the CDCT (or transform) layer. \subsubsection{IDCT Reconstruction}\label{sec:idct} Based on the restored transform coefficients $\mathbf{\hat{f}}_\text{high}$ from the $D$-layer CNN, we can generate the SR results. First, we append the $\mathbf{\hat{f}}_\text{high}$ to the $\mathbf{f}_\text{low}$ which are the low-frequency components of the input LR image as defined in Section \ref{sec:dct}. This generates an SR DCT cube $\mathbf{f}_\text{SR} = \{\mathbf{f}_\text{low}, \mathbf{\hat{f}}_\text{high}\}$ with $64$ spectra. By transpose convolving\footnote{Some literature \cite{noh2015learning,dumoulin2016guide} refer this procedure as deconvolution, fractionally stride convolution or backward convolution in neural network setups.} the CDCT layer filters $\{\mathbf{w}_i\}_{i= 1}^{64}$ with the SR DCT cube $\mathbf{f}_\text{SR}$, the network output $\hat{\mathbf{y}}$ is generated. This procedure can be viewed as a convolution of $\mathbf{w}_i$ with a $S$ zero-padded $\mathbf{f}_i\in \mathbf{f}_\text{SR}$: \begin{equation} \hat{\mathbf{y}} = \sum_{i=1}^{64} \mathbf{w}_i * g_s(\mathbf{f}_i) \label{equ:CDCTdeconv} \end{equation} where $*$ is the convolution operation and $g_s(\cdot)$ is a $S$ zero-padding function detailed in the supplementary document \cite{techReport} (recall that $S$ is the stride used in DCT cube calculation.). Note that combined with the zero-padding function, the convolution between the $\mathbf{w}_i$ and $g_s(\mathbf{f}_i)$ can be viewed as a transposed convolutional operation between $\mathbf{w}_i$ and $\mathbf{f}_i$.\label{pg:tc} \begin{prop} Eq \eqref{equ:CDCTdeconv} with $\mathbf{f}_\text{SR}$ as input produces a spatial image, which is equivalent to the IDCT. \noindent {\it Proof:} See in Appendix \ref{sec:apx-2}. \end{prop} To summarize Section \ref{sec:dct} and \ref{sec:idct}, the CDCT layer can produce a DCT cube from an input image by performing convolution. At the same time, an image from a DCT cube can be generated by performing transpose convolution, which essentially is the IDCT. As shown in Fig. \ref{fig:ORDSR}, the CDCT layer constructs a bridge between image transform domain and the image spatial domain. Beyond enabling SR in the DCT domain, we show next that the basis filters of the CDCT layer can be trainable, {\it i.e. optimizable}. This opens a door towards finding customized and data-adaptive basis filters for the SR task. The optimization of CDCT/transform layer\footnote{\label{ft:DCT}After training, the filters in CDCT layer are new learned filters that can help perform a forward and inverse transform, which is indeed data-adaptive and {\em not} the DCT. For ease of exposition, we continue to refer to this layer as the CDCT layer and its output as the DCT cube respectively. Indeed the terms `transform layer' and `CDCT layer' are interchangeable in this paper and the context makes it clear whether the said transform is DCT or based on optimized filters/basis functions.} filters must however be constrained to yield improved results, this is detailed in the next Section. \subsection{Desired Transform Constraints} \label{sec:const} While transform domain mappings can enhance SR, an image transform (viz. the proposed CDCT layer) must obey certain properties. We pose two key constraints: \begin{enumerate} \item a pairwise orthogonality constraint on filters/basis functions of the CDCT layer to guarantee reconstruction via the transpose convolution based inverse, and \item preservation of the complexity of the basis in terms of its order. \end{enumerate} \textbf{Orthogonality constraint.} The aforementioned CDCT layer can, in fact, be learned and adapted to a given training image dataset. Pairwise orthogonality constraints can be captured by a regularization term given by \begin{equation} \forall i\neq j, \|vec(\mathbf{w}_i)^Tvec(\mathbf{w}_j)\|^2_2\label{equ:orthoCDCT} \end{equation} where $i, j \in \{1,..,64\}$ and $vec(\cdot)$ is the vectorization operation which converts the matrix into a column vector. This term is added to the network's total cost function -- see Eq. (\ref{eq:finalCostFn}). As suggested in Eq. (\ref{equ:orthoDCT}), any two distinct filter pairs in the CDCT layer should ideally have an inner product that evaluates to zero. \textbf{Complexity order constraint.} Because we are essentially designing a frequency domain mapping, it is desirable to preserve the order of complexity of the DCT basis. To enforce this, we introduce a new regularization term: \begin{equation} \|var(\mathbf{w}_t) - var(\mathbf{w}^\text{dct}_t)\|_2^2 = 0 \end{equation} where $t\in\{1,...,64\}$, $\mathbf{w}_t$ are the filters in CDCT/transform layer and $\mathbf{w}_t^\text{dct}$ is the corresponding DCT basis function/filter (as defined in Section \ref{sec:dct}). The variance of a filter $\mathbf{w}\in \mathbb{R}^{N\times N}$ is given by Bessel's correction version \cite{probabilitybook}: \begin{equation} var(\mathbf{w}) = \frac{1}{N^2-1}\sum_m (\mathbf{w}^m-\frac{1}{N^2}\sum_n\mathbf{w}^n)^2 \end{equation} where $N=8$, $\mathbf{w}^m$ and $\mathbf{w}^n$ denote an arbitrary scalar entry in filter $\mathbf{w}$. $\sum_m\mathbf{w}^m$ and $\sum_n\mathbf{w}^n$ denote the summation of all the elements inside $\mathbf{w}$. That is, we encourage the variance of the optimized filters to be close to that of their DCT counterparts. \subsection{Training and Inference: Regularized Optimization} To train ORDSR we minimize a cost function that captures the functionality of the network while maintaining the properties that the CDCT layer needs to satisfy. The inference for SR procedure is then described in detailed steps. \subsubsection{ORDSR Training The ORSDR network is trained by minimizing the following regularized loss function: \begin{equation} \label{eq:finalCostFn} \begin{split} \mathbf{L}(\mathbf{\Theta},\mathbf{B}) = \underbrace{\frac{1}{2}\|F(\mathbf{x}) - \mathbf{y}\|^2_2}_{\text{MSE loss}} + \sigma\frac{1}{2}\sum_{l}^{}\sum_{m}^{m_l}\underbrace{\|\mathbf{W}_{l_m}\|^2_2}_{\text{weight decay}}\\+\gamma \frac{1}{2}\sum_{(i,j), i\neq j} \underbrace{\|vec(\mathbf{w}_i)^Tvec(\mathbf{w}_j)\|^2_2}_{\text{orthogonality constraint}}\\+\lambda\frac{1}{2}\sum_t\underbrace{\|var(\mathbf{w}_t) - var(\mathbf{w}^\text{dct}_t)\|_2^2}_{\text{complexity order constraint}} \end{split} \end{equation} The cost function has four parts: Mean Square Error (MSE) loss, weight decay, orthogonality constraint and complexity order constraint. In these cost terms, MSE loss captures the similarity between the SR results $F(\mathbf{x})$ and the ground truth $\mathbf{y}$. Weight decay constraints are leveraged from the literature to prevent over-fitting \cite{goodfellow2016deep}. $\mathbf{W}_{l_m} \in \mathbf{\Theta}^\text{cnn}$ is the $m$-th weight of the CNN layer $l$ where there are $m_l$ filters in total. $\sum_l(\cdot)$ applies the weight decay term to each of the weights of the CNN and sums them together. Positive trade-off parameters $\gamma$ and $\lambda$ control the balance between the constraints and other cost terms. $\sum_{(i,j)}(\cdot)$ applies the orthogonality constraint on every distinct filter pair in the CDCT/transform layer then sums them together. Similarly, $\sum_{t}(\cdot)$ applies complexity order constraint on each pair of optimized and reference (DCT) filter and sums the total. The ORDSR is trained by using a back-propagation procedure that minimizes: \begin{equation} \label{eq:finalOp} \mathbf{\Theta},\mathbf{B} = \underset{\mathbf{\Theta},\mathbf{B}}{\arg\min} \mathbf{L}(\mathbf{\Theta},\mathbf{B}) \end{equation} \noindent Specifically, Eq. (\ref{eq:finalOp}) is minimized using a stochastic gradient descent method \cite{lecun1998gradient}. At iteration $t$, the CNN and the CDCT layer are updated as: $\mathbf{\Theta}^{t+1} = \mathbf{\Theta}^t - \eta \nabla_{\mathbf{\Theta}}\mathbf{L}$, where $\eta$ denotes the learning rate. As $\mathbf{\Theta} = \{\mathbf{\Theta}^\text{cnn}, \{\mathbf{w}_i\}_{i=1}^{64}\}$, and $\mathbf{\Theta}^\text{cnn}=\{\mathbf{W}_l\}_{l=1}^D$, the following gradients are to be computed\footnote{Note the update rules and the gradients for the bias terms are similar and are included in the supplementary document \cite{techReport}.}: $$\frac{\partial \mathbf{L}}{\partial \mathbf{W}_l}, \frac{\partial \mathbf{L}}{\partial \mathbf{w}_i}$$ where $\mathbf{W}_l$ denotes one of the filters at $l^{th}$ layer of the CNN, representatively, and $\mathbf{w}_i$ denotes the $i^{th}$ filter in the CDCT layer. The equation for computing the gradient of an arbitrary entry within filter $\mathbf{W}_l$ in layer $l\in\{1,...,D\}$ is given by: \begin{equation} \resizebox{0.9\linewidth}{!}{$ \frac{\partial \mathbf{L}}{\partial \mathbf{W}^a_l} = -<(\hat{\mathbf{y}} - \mathbf{y}),\frac{\partial \mathbf{y}}{\partial \mathbf{W}^a_l}>_F + \sigma<\mathbf{W}_l,\frac{\partial \mathbf{W}_l}{\partial \mathbf{W}^a_l}>_F\label{eq:pW}$} \end{equation} where $\mathbf{W}^a_l$ denotes an arbitrary scalar entry within the representative filter $\mathbf{W}_l$, and $<\cdot,\cdot>_F$ denotes the real value Frobenius inner product\footnote{For two real valued matrix $\mathbf{A}$ and $\mathbf{B}$ with same dimension, $<\mathbf{A},\mathbf{B}>_F := \sum_{i,j} A_{i,j}B_{i,j}$ where $i,j$ are the indexes of the entries.}. In Eq. (\ref{eq:pW}), $\frac{\partial \mathbf{y}}{\partial \mathbf{W}^a_l}$ is computed by following the standard backpropagation rule for each layer $l$ \cite{lecun1998gradient}. For the CDCT filter $\mathbf{w}_i$, the gradient w.r.t an arbitrary scalar entry $\mathbf{w}_i^a$ is given by: \begin{equation}\begin{split} \frac{\partial \mathbf{L}}{\partial \mathbf{w}^a_i} = &-<(\hat{\mathbf{y}} - \mathbf{y}),\frac{\partial \mathbf{y}}{\partial \mathbf{w}^a_i}>_F \\&+ \underbrace{\gamma \sum_{(j)}\left(vec(\mathbf{w}_i)^Tvec(\mathbf{w}_j)\right)\mathbf{w}_j^a}_{\text{gradient of orthogonality constraint w.r.t $\mathbf{w}_i^a$}} \\&+ \underbrace{\lambda \frac{\partial var(\mathbf{w}_i)}{\partial \mathbf{w}_i^a}\left(var(\mathbf{w}_i) - var(\mathbf{w}^\text{dct}_i)\right)}_{\text{gradient of complexity order constraint w.r.t $\mathbf{w}_i^a$}}\label{eq:pw} \end{split}\end{equation} where $\frac{\partial \mathbf{y}}{\partial \mathbf{w}^a_l}$ is computed following the standard backpropagation rule. $\frac{\partial var(\mathbf{w}_i)}{\partial \mathbf{w}_i^a}$ is the partial derivative of $var(\mathbf{w}_i)$ w.r.t $\mathbf{w}^a_i$ given by: \begin{equation}\resizebox{\linewidth}{!}{$ \frac{\partial var(\mathbf{w}_i)}{\partial \mathbf{w}_i^a} = \frac{2}{N^2(N^2-1)}\left[N^2\mathbf{w}_i^a-\sum_n\mathbf{w}_i^n-\sum_m\left(\mathbf{w}_i^m-\frac{1}{N^2}\sum_n\mathbf{w}_i^n\right)\right]\label{eq:pv}$} \end{equation} where $\mathbf{w}_i^a$ , $\mathbf{w}_i^m$, and $\mathbf{w}_i^n$ denote an arbitrary scalar entry in CDCT filter $\mathbf{w}_i$. $\sum_a\mathbf{w}_i^a$, $\sum_m\mathbf{w}_i^m$, and $\sum_n\mathbf{w}_i^n$ denote the summation of all the elements inside $\mathbf{w}_i$. Detailed notations and derivations of Eq. (\ref{eq:pW}), (\ref{eq:pw}), and (\ref{eq:pv}) can be found in the supplementary document \cite{techReport}. The CDCT layer is initialized by the DCT filters as described in Section \ref{sec:dct} and the $D$-layer CNN is initialized using the Xavier method \cite{glorot2010understanding}. We use the well-known stochastic gradient descent Adam optimizer \cite{goodfellow2016deep} during the training procedure. We adapt gradient clip and a step gradient descent for faster training. Specific choice of numerical optimization parameters is provided in Section \ref{sec:net-setup}. \subsubsection{DCT-DSR Training} Note that, without optimizing the CDCT layer filters ($\mathbf{w}_i\notin\mathbf{\Theta}$), the ORDSR is simplified to a baseline residual network performing SR in the DCT domain using a {\em fixed} CDCT layer. We call this network DCT-Deep SR (DCT-DSR). The DCT-DSR is trained by minimizing the following regularized loss function: \begin{equation} \resizebox{0.7\linewidth}{!}{$ \begin{split} \mathbf{L}(\mathbf{\Theta}^\text{cnn},\mathbf{B}) = \underbrace{\frac{1}{2}\|F(\mathbf{x}) - \mathbf{y}\|^2_2}_{\text{MSE loss}} + \sigma\frac{1}{2}\sum_{l}^{}\underbrace{\|\mathbf{W}_l\|^2_2}_{\text{weight decay}}\label{eq:finalCostFn-dsr} \end{split} $} \end{equation} Experiments in Section \ref{sec:exp} demonstrates the effectiveness of using DCT transform domain for image SR. Moreover, it further emphasizes that optimizing the transform layer basis functions with CDCT layer coefficients being learnable can significantly improve the image SR performance. \subsubsection{Inference}\label{sec:test} Fig. \ref{fig:ORDSR} shows the inference procedure of the ORDSR network with $N=8$. For an input LR image $\mathbf{x}$, the goal of ORDSR is to generate its SR version $\mathbf{\hat{y}}$ as follows: \begin{enumerate} \item The input LR image $\mathbf{x}$ is convolved with CDCT layer producing a DCT cube $\{\mathbf{f}_i\}_{i= 1}^{64}$ as in (\ref{equ:CDCTconv}). \item The DCT cube of $\mathbf{x}$ is divided into $\mathbf{f}_\text{low}$ and $\mathbf{f}_\text{high}$ corresponding to low and high-frequency spectra using a threshold $T$. The exact separation process is described in Section \ref{sec:CNN}; \item A $D$-layer CNN takes the DCT cube $\{\mathbf{f}_\text{low}, \mathbf{f}_\text{high}\}$ as input and recovers the missing high-frequency information using a residual network structure, generating $\hat{\mathbf{f}}_\text{high}$. \item The $\hat{\mathbf{f}}_\text{high}$ is appended to $\mathbf{f}_\text{low}$ forming the SR-DCT cube $\mathbf{f}_{\text{SR}}$. As the $\mathbf{f}_\text{low}$ is unchanged between $\mathbf{x}$ and its corresponding HR image, only $\mathbf{f}_\text{high}$ needs to be modified for generating $\mathbf{\hat{y}}$. \item The SR-DCT cube $\mathbf{f}_{\text{SR}}$ is transpose convolved with the filters in the CDCT/transform layer (to perform the IDCT/inverse transform) generating $\mathbf{\hat{y}}$. \end{enumerate} In Step 2, the CDCT layer uses an unconventional stride $S=2$, which reduces the spatial size of the feature maps by factor of $4$. This gives the ORDSR a huge advantage in the inference speed and memory requirements compared to most state of the art methods that operate in the spatial domain. Steps 1 and 5 are performed in the image spatial domain while Steps 2-4 are in the image transform domain where CDCT layer serves as a `bridge' between two image domains by performing DCT/IDCT. \section{Experiments}\label{sec:exp} \subsection{Training and Test Data} \label{sec:exp-setup} The widely used 291 images dataset \cite{Schulter_2015_CVPR} is used for training. The images are augmented using three methods: \begin{enumerate} \item Rotating the images by $\{45^{\circ}$, $90^{\circ}$, $135^{\circ}$, $180^{\circ}$, $225^{\circ}$, $270^{\circ}$, $315^{\circ}\}$; \item Horizontal and vertical flip; \item Scaling by factors of $\{0.7, 0.8, 0.9\}$. \end{enumerate} The augmented images are treated as HR images and then are down-sampled by the factor of $c$. Then the down-sampled images are enlarged using bicubic interpolation by the same factor $c$ to form the LR training images. Note that the HR image is cropped so that its width and height are multiples of $c$. All the LR/HR images are further cropped into $40\times40$ pixels sub-images with 10 pixels overlap for training. During the test phase, several standard data sets are used. Specifically, Set5 \cite{bevilacqua2012low}, Set14 \cite{zeyde2010single}, BSD100 \cite{MartinFTM01} and Urban100 \cite{huang2015single} are used to evaluate ORDSR\footnote{\label{ft:code}Test code and networks are available at \url{http://signal.ee.psu.edu/ORDSR.html.} Detailed training schemes are included in the supplementary document.}. The metrics used for image quality assessment are PSNR, SSIM \cite{wang2004image} and Information Fidelity Criterion (IFC) \cite{sheikh2005information}. Note that while a few published methods work with larger datasets such as DIV2K \cite{Timofte_2017_CVPR_Workshops}, ImageNet \cite{deng2009imagenet}, or MS-COCO \cite{lin2014microsoft} -- our choice of the 291 images dataset \cite{Schulter_2015_CVPR} is for consistency and fairness of comparison against a large body of competing methods that all employ this dataset. Both training and test phases of ORDSR and DCT-DSR only utilize the luminance channel information of the input images to be consistent with literature \cite{yang2010image, dong2011image,Kim_2016_VDSR}. Chrominance channels Cb and Cr are directly enlarged by bicubic interpolation from LR images. These enlarged chrominance channels are combined with SR luminance channel to produce color SR results. Both training and test are conducted on an NVIDIA Titan X GPU (12GB) with the Tensorflow package \cite{tensorflow2015-whitepaper}. \subsection{Network Setup} \label{sec:net-setup} In the training phase, the momentum and gradient clip are set to $0.9$ and $0.5$ respectively. The learning rate is initialized to $10^{-4}$ and updated every 30 epochs with a $25\%$ decrease. The network is first initialized using the non-learnable DCT bases and random Xavier \cite{glorot2010understanding} initialization for the CDCT layer and CNN layers, respectively. This forms the DCT-DSR network which is trained for $80$ epochs, only optimizing the CNN layers. Then the Orthogonality and Complexity Order constraints are enforced as well as including the CDCT layer in the trainable parameter set, {\it i.e.} $\mathbf{w}_i\in\mathbf{\Theta}$, forming ORDSR. ORDSR is then trained for $80$ epochs. The stride $S$ is set to $2$ to eliminate block effects as well as to reduce the memory and computational requirements (see Section \ref{sec:memy}). Unless stated otherwise, the standard configuration of ORDSR is as follows: $\gamma = 3.5$, $\lambda=0.75$, $D = 15$, $T=4$ (for $c=3$; for other scale factors see Section \ref{sec:T}), $m_i=64$ where $i\in\{1,...,14\}$ and $n_1=5$, $n_i=3$, where $i\in\{2,...,15\}$. All hyper-parameters are determined using cross-validation. During the training $128$ training patch pairs with the size of $40\times40$ are randomly extracted in each batch.\label{tx:train} \begin{figure} \centering \begin{subfigure}{\linewidth} \centering \includegraphics[trim=2cm 1.6cm 2cm 1.6cm, clip, width=1\linewidth]{./figs/E.pdf} \vspace{-15pt}\caption{Initialization DCT Filters, as used in DCT-DSR}\vspace{5pt} \end{subfigure} \begin{subfigure}{\linewidth} \centering \includegraphics[trim=2cm 1.6cm 2cm 1.6cm, clip, width=1\linewidth]{./figs/E001.pdf} \vspace{-15pt}\caption{Learned Filters, as used in ORDSR}\label{fig:e01}\vspace{5pt} \end{subfigure} \begin{subfigure}{\linewidth} \centering \includegraphics[trim=2cm 1.6cm 2cm 1.6cm, clip, width=1\linewidth]{./figs/random.pdf} \vspace{-15pt}\caption{Learned Filters, as used in ORDSR-RI}\label{fig:e01}\vspace{5pt} \end{subfigure} \caption{CDCT layer initialization and the learned filters of CDCT layer in ORDSR. (Filters are normalized and reordered for display purposes.)}\label{fig:filter} \end{figure} \begin{figure}[t] \centering \includegraphics[trim=1.2cm 0cm 2cm 0cm,clip,width=\linewidth]{./figs/Tpsnr.pdf} \caption{Avg. PSNR of Set14 with scale factor 3 on different $T$. When $T<5$ , decreasing $T$ will not affect the SR results. Hence we set $T=4$ for $c=3$.}\label{fig:T} \end{figure} \begin{figure} \centering \includegraphics[trim=0cm 0cm 0cm 0cm,clip,width=\linewidth]{./figs/CNNdepth.pdf}\vspace{-2pt}\sqz\vspace{-2pt} \caption{Avg. PSNR of Set5 with scale factor 3 across different number of layers. ORDSR outperforms VDSR for varying network depths.}\label{fig:layer} \end{figure} \begin{figure*}[ht] \centering \includegraphics[trim=0cm 0cm 0cm 0cm,clip,width=\linewidth]{./figs/magnify_butterfly_elg.pdf}\vspace{-2pt}\sqz\vspace{-2pt} \caption{The SR test results of \textit{monarch.bmp} for scale factor 3. The assessment metrics are shown as (PSNR, SSIM, IFC).}\label{fig:SR_but} \end{figure*} \begin{table}[] \centering \captionsetup{justification=centering} \caption{Average PSNR, SSIM and IFC results on Set14 with scale factor 3 -- different filter size and number setups.} \label{tb:size}\resizebox{0.95\linewidth}{!}{ \begin{tabular}{l c c c }\Xhline{3\arrayrulewidth} & \multicolumn{3}{c}{$m_i=32$, $i\in\{1,...14\}$} \\ \cline{2-4} &PSNR& SSIM& IFC\\\hline $n_1=5$, $n_i=3$, $i\in\{2,...,15\}$&29.95&0.8322& 4.43\\ $n_i=5$, $i\in\{1,...,15\}$&29.87&0.8316&4.39\\ $n_i=3$, $i\in\{1,...,15\}$&29.92&0.8318& 4.42\\\Xhline{3\arrayrulewidth} & \multicolumn{3}{c}{$m_i=64$, $i\in\{1,...14\}$} \\ \cline{2-4} &PSNR& SSIM& IFC\\\hline $n_1=5$, $n_i=3$, $i\in\{2,...,15\}$&\bf 30.26&\bf 0.8380&\bf 4.55\\ $n_i=5$, $i\in\{1,...,15\}$&29.96&0.8298&4.45\\ $n_i=3$, $i\in\{1,...,15\}$&30.08&0.8301&4.47\\\Xhline{3\arrayrulewidth} \end{tabular}} \end{table} \subsection{Impact of ORDSR Network Parameters} \subsubsection{Threshold T on DCT Cube} \label{sec:T} This threshold Separates the DCT cube into two parts as described in Section \ref{sec:DCTIDCT} and ORDSR focuses on restoring the high-frequency details $\hat{\mathbf{f}}_\text{high}$. Fig. \ref{fig:T} shows the effect of varying $T$ on the PSNR of the SR results. A small $T$ implies a smaller fraction of DCT cube ($\mathbf{f}_\text{low}$) is directly copied to the SR-DCT cube. Setting $T=0$ means that ORDSR exploits and maps all the frequency component maps. However, Fig. \ref{fig:T} reveals, for $T<5$, decreasing the threshold does not affect SR image quality for all practical purposes. This confirms that the low-frequency spectra between LR and HR image are indeed shared. Further for scale factor of $c=2$, $T$ is found to be $5$ and for $c=4$ we select $T=3$. For smaller scale factor, more low-frequency coefficients are preserved during the downsampling, hence a bigger $T$ is suitable.\label{pg:T} \subsubsection{Number of filters and filter size in the CNN} In ORDSR, filters emerge from two categories: CDCT layer filters and collectively $\mathbf{\Theta}^\text{cnn}$ of the CNN. For CDCT layer, the size of the filters are predefined by the DCT basis. In this study, the DCT basis used has a filter size $8\times 8$. Same for the number of the filters, it is associated with the filter size, {\it i.e.} $8\times 8 =64$. As has been shown in the past in many CNN based SR methods \cite{dong2011image,dong2016accelerating}, the filter size and the number of filters influences the performance of the CNN. In ORDSR, the CNN uses a residual bypass structure as in \cite{guo2017deep,Kim_2016_VDSR}. Though identical layer setups have shown effectiveness \cite{Timofte_2017_CVPR_Workshops}, some structural changes are necessary for ORDSR. From Section \ref{sec:CNN}, in the CNN, the output layer always has $m_D=(64-T)$ filters since it needs to preserve the number of spectra. Besides the fixed parameter, in Table \ref{tb:size}, we report some configurations and corresponding results of ORDSR by changing the number and the size of filters in the CNN. \begin{table}[]\centering \captionsetup{justification=centering} \caption{Different variants of ORDSR. OC stands for Orthogonality Constraint, CC stands for Complexity order Constraint. \ding{51} means the the layer is learnable or the constraint is in place during the learning.}\label{tb:ordsr_names} \resizebox{0.78\linewidth}{!}{\begin{tabular}{lccc}\Xhline{2\arrayrulewidth} Notation &CDCT layer learnable& OC & CC \\\hline ORDSR& \resizebox{\widthof{\checkmark}*\ratio{\widthof{x}}{\widthof{\normalsize x}}}{!}{\checkmark}&\resizebox{\widthof{\checkmark}*\ratio{\widthof{x}}{\widthof{\normalsize x}}}{!}{\checkmark}&\resizebox{\widthof{\checkmark}*\ratio{\widthof{x}}{\widthof{\normalsize x}}}{!}{\checkmark}\\ DSR-OC& \resizebox{\widthof{\checkmark}*\ratio{\widthof{x}}{\widthof{\normalsize x}}}{!}{\checkmark}&\resizebox{\widthof{\checkmark}*\ratio{\widthof{x}}{\widthof{\normalsize x}}}{!}{\checkmark}&-\\ DSR-CC& \resizebox{\widthof{\checkmark}*\ratio{\widthof{x}}{\widthof{\normalsize x}}}{!}{\checkmark}&-&\resizebox{\widthof{\checkmark}*\ratio{\widthof{x}}{\widthof{\normalsize x}}}{!}{\checkmark}\\ DSR-UC& \resizebox{\widthof{\checkmark}*\ratio{\widthof{x}}{\widthof{\normalsize x}}}{!}{\checkmark}&-&-\\ DCT-DSR& -&-&-\\\Xhline{2\arrayrulewidth} \end{tabular}} \end{table} As is apparent from Table \ref{tb:size}, ORDSR generally benefits from an increase in the number of filters. For the filter size, Table \ref{tb:size} shows that the ORDSR benefits from the first layer having slightly bigger filters. This indicates increasing the input receptive field can help CNN generate a better representation of the input for later use. Also, smaller filters for layers in the center of the CNN produces more favorable results. \subsubsection{Number of Layers in the CNN} Going deeper is a tempting thing to do. For many a problem domain though, diminishing returns have been reported before with an increase in the number of layers \cite{goodfellow2016deep}. For ORSDR, we observe a similar trend beyond $D=15$. Figure \ref{fig:layer} reveals that ORDSR can outperform VDSR \cite{Kim_2016_VDSR} with $D = 15$ layers. One advantage of not going too deep is benefit from a memory and computational standpoint. ORDSR's merits in this regard are elaborated upon in Section \ref{sec:memy}. It is also worth noticing that, at $D=20$, the $D$-layer CNN in ORDSR and VDSR have similar structure, and ORDSR still outperforms VDSR thanks to domain inspired regularization. \subsection{Ablation Study: Benefits of Orthogonality and Complexity Order Constraints}\label{sec:CE} To fully investigate the effects of the proposed constraints, we now introduce different variants of our proposed method. Table \ref{tb:ordsr_names} illustrates the 5 different versions of our method and covers the cases of whether the transform/CDCT layer is learned or fixed and which constraints (if any) are active. DCT-DSR is the precursor to ORDSR where the CDCT layer is fixed with DCT filters and hence non-trainable. For DCT-DSR, the same network setup/parameters are used as ORDSR except that the $\mathbf{w}_i\notin\mathbf{\Theta}$. For DCT-DSR hence, only the $D-$layer CNN is learned in Fig.\ \ref{fig:ORDSR}. Besides the variants in Table \ref{tb:ordsr_names}, we also add a method, where the CDCT layer before optimization is randomly initialized (as opposed to initializing with DCT basis filters) and still learned with both constraints in place. We name it as ORDSR-RI (Orthogonally Regularized Deep SR with Random Initialization). Fig. \ref{fig:filter} visualizes the filters that comprise the CDCT/transform layer in DCT-DSR, ORDSR, and ORDSR-RI. Note that the filters in ORDSR-RI are less interpretable compared to the DCT-DSR and ORDSR as the transform layer is initialized randomly.\label{pg:fig5} Table \ref{tb:ec} shows the performance of the aforementioned networks. Performance is evaluated both in abundant (using $100\%$ of the training data) and limited training scenarios (using $10\%$ of the training data). As is shown in Table \ref{tb:ec}, in both training scenarios, ORDSR gives the best performance followed by DSR-OC. Comparing the performance between DSR-OC, -CC, and -UC, the orthogonality constraints have the strongest influence while the complexity constraints help to boost the performance in the limited training scenarios. Comparing DCT-DSR with ORDSR results, we can observe that making the CDCT layer learnable while enforcing domain specific constraints is critical to performance improvement. Comparing ORDSR-RI with other variants, it is clear that DCT based initialization combined with enforcing one or more constraints outperforms ORDSR-RI. Meanwhile, ORDSR-RI is better than the variant where {\em no constraints} are used when optimizing this layer (DSR-UC) -- underscoring the value of using powerful domain specific constraints. \begin{table} \captionsetup{justification=centering} \centering \caption{Performance of variants of methods based on Table \ref{tb:ordsr_names}. Table shows average (PSNR/SSIM/IFC) results on Set14 with scale factor 3.}\label{tb:ec} \resizebox{\linewidth}{!}{ \begin{tabular}{rcc}\Xhline{2\arrayrulewidth} Training Data Used (\%)& $100\%$ & $10\%$\\\hline ORDSR & 30.26/0.8380/4.55&29.67/0.8265/4.30\\ DSR-OC& 30.18/0.8314/4.42&29.28/0.8197/4.01\\ DSR-CC& 30.02/0.8295/4.41&29.03/0.8131/3.78\\ DSR-UC& 29.51/0.8240/4.09&28.21/0.8059/3.46\\ DCT-DSR & 29.86/0.8337/4.39&29.10/0.8143/3.87\\ ORDSR-RI & 29.56/0.8280/4.17&28.76/0.8074/3.52\\\Xhline{2\arrayrulewidth} \end{tabular}} \end{table} \subsection{Comparison Against State-of-the-Art SR Methods} \label{sec:sota} In this Section, we compare ORDSR with representative state-of-the-art methods: both sparse-coding and deep learning based methods. Our experiments are partitioned into two scenarios -- abundant and limited training. In these tests, ORDSR outperforms the state-of-the-art methods and the gains are particularly pronounced when training is limited. We also demonstrate the efficiency of the ORDSR by analyzing the network size and memory requirements. \begin{table*} \centering\captionsetup{justification=centering} \caption{PSNR comparisons over Set5, Set14, BSD100, and Urban100. }\vspace{-2pt}\sqz\vspace{-2pt} \label{tb:PSNR}\resizebox{\textwidth}{!}{ \begin{tabular}{r c c c c c c c c c c c c c c c} \Xhline{2\arrayrulewidth} PSNR&Scale & \begin{tabular}[c]{@{}c@{}}Bicubic{}{}\end{tabular} & \begin{tabular}[c]{@{}c@{}}ScSR{}\\\cite{yang2010image}{}\end{tabular} & \begin{tabular}[c]{@{}c@{}}A+{}\\\cite{timofte2014a+}{}\end{tabular} & \begin{tabular}[c]{@{}c@{}}SelfEx{}\\\cite{huang2015single}{}\end{tabular} & \begin{tabular}[c]{@{}c@{}}SCN{}\\\cite{wang2015deep}{}\end{tabular} & \begin{tabular}[c]{@{}c@{}}SRCNN{}\\\cite{dong2014learning}{}\end{tabular} & \begin{tabular}[c]{@{}c@{}}FSRCNN{}\\\cite{dong2016accelerating}{}\end{tabular} & \begin{tabular}[c]{@{}c@{}}VDSR{}\\\cite{Kim_2016_VDSR}{}\end{tabular} & \begin{tabular}[c]{@{}c@{}}DWSR{}\\\cite{guo2017deep}{}\end{tabular} & \begin{tabular}[c]{@{}c@{}}RDN{}\\\cite{zhang2018residual}{}\end{tabular} & \begin{tabular}[c]{@{}c@{}}EDSR{}\\\cite{lim2017enhanced}{}\end{tabular} & \begin{tabular}[c]{@{}c@{}}DCT-DSR{}\\proposed{}\end{tabular} & \begin{tabular}[c]{@{}c@{}}ORDSR{}\\proposed{}\end{tabular} & \begin{tabular}[c]{@{}c@{}}ORDSR+{}\\proposed{}\end{tabular} \\ \hline Set5 & \begin{tabular}[c]{@{}c@{}}x2\\ x3\\ x4\end{tabular} & \begin{tabular}[c]{@{}c@{}}33.64\\ 30.39\\ 28.42\end{tabular} & \begin{tabular}[c]{@{}c@{}}35.78\\ 31.34\\ 29.07\end{tabular} & \begin{tabular}[c]{@{}c@{}}36.55\\ 32.58\\ 30.27\end{tabular} & \begin{tabular}[c]{@{}c@{}}36.50\\ 32.62\\ 30.32\end{tabular} & \begin{tabular}[c]{@{}c@{}}36.58\\ 32.61\\ 30.41\end{tabular} & \begin{tabular}[c]{@{}c@{}}36.66\\ 32.75\\ 30.48\end{tabular} & \begin{tabular}[c]{@{}c@{}}36.94\\ 33.06\\ 30.55\end{tabular} & \begin{tabular}[c]{@{}c@{}}37.52\\ 33.66\\ 31.35\end{tabular} & \begin{tabular}[c]{@{}c@{}}37.55\\ 33.69\\ 31.98\end{tabular} & \begin{tabular}[c]{@{}c@{}}37.93\\ 34.19\\ 32.54\end{tabular} & \begin{tabular}[c]{@{}c@{}}37.62\\ 33.72\\ 32.08\end{tabular} & \begin{tabular}[c]{@{}c@{}}37.50\\ 33.75\\ 32.05\end{tabular} & \begin{tabular}[c]{@{}c@{}}\bf 38.08\\ \bf 34.31\\ \bf 32.62\end{tabular} & \begin{tabular}[c]{@{}c@{}}\bf 38.12\\ \bf 34.37\\ \bf 32.65\end{tabular} \\ \hline Set14 & \begin{tabular}[c]{@{}c@{}}x2\\ x3\\ x4\end{tabular} & \begin{tabular}[c]{@{}c@{}}30.22\\ 27.53\\ 25.99\end{tabular} & \begin{tabular}[c]{@{}c@{}}31.64\\ 28.19\\ 26.40\end{tabular} & \begin{tabular}[c]{@{}c@{}}32.29\\ 29.13\\ 27.33\end{tabular} & \begin{tabular}[c]{@{}c@{}}32.24\\ 29.16\\ 27.40\end{tabular} & \begin{tabular}[c]{@{}c@{}}32.35\\ 29.16\\ 27.39\end{tabular} & \begin{tabular}[c]{@{}c@{}}32.42\\ 29.28\\ 27.40\end{tabular} & \begin{tabular}[c]{@{}c@{}}32.54\\ 29.37\\ 27.50\end{tabular} & \begin{tabular}[c]{@{}c@{}}33.02\\ 29.75\\ 28.01\end{tabular} & \begin{tabular}[c]{@{}c@{}}33.10\\ 29.77\\ 29.98\end{tabular} & \begin{tabular}[c]{@{}c@{}}33.89\\ 30.13\\ 28.68\end{tabular} & \begin{tabular}[c]{@{}c@{}}33.56\\ 30.01\\ 27.97\end{tabular} & \begin{tabular}[c]{@{}c@{}}33.08\\ 29.86\\ 28.03\end{tabular} & \begin{tabular}[c]{@{}c@{}}\bf 34.06\\ \bf 30.26\\ \bf 28.81\end{tabular} & \begin{tabular}[c]{@{}c@{}}\bf 34.09\\ \bf 30.30\\ \bf 28.84\end{tabular} \\ \hline BSD100 & \begin{tabular}[c]{@{}c@{}}x2\\ x3\\x4\end{tabular} & \begin{tabular}[c]{@{}c@{}}29.55\\ 27.21\\25.96\end{tabular} & \begin{tabular}[c]{@{}c@{}}30.77\\ 27.72\\26.61\end{tabular} & \begin{tabular}[c]{@{}c@{}}31.21\\ 28.18\\26.82\end{tabular} & \begin{tabular}[c]{@{}c@{}}31.18\\ 28.30\\26.84\end{tabular & \begin{tabular}[c]{@{}c@{}}31.26\\ 28.58\\26.88\end{tabular} & \begin{tabular}[c]{@{}c@{}}31.36\\ 28.20\\26.84\end{tabular} & \begin{tabular}[c]{@{}c@{}}31.66\\ 28.52\\26.92\end{tabular} & \begin{tabular}[c]{@{}c@{}}31.85\\ 28.82\\27.23\end{tabular} & \begin{tabular}[c]{@{}c@{}}31.83\\ 28.87\\27.29\end{tabular} & \begin{tabular}[c]{@{}c@{}}32.09\\ 29.28\\27.64\end{tabular} & \begin{tabular}[c]{@{}c@{}}31.97\\ 29.21\\27.32\end{tabular} & \begin{tabular}[c]{@{}c@{}}31.72\\ 28.93\\27.35\end{tabular} & \begin{tabular}[c]{@{}c@{}}\bf 32.24\\\bf 29.41\\\bf 27.80\end{tabular} & \begin{tabular}[c]{@{}c@{}}\bf 32.27\\ \bf 29.43\\ \bf 27.84\end{tabular} \\ \hline Urban100 & \begin{tabular}[c]{@{}c@{}}x2\\ x3\\ x4\end{tabular} & \begin{tabular}[c]{@{}c@{}}26.66\\ 24.46\\23.14\end{tabular} & \begin{tabular}[c]{@{}c@{}}28.26\\ 25.34\\24.02\end{tabular} & \begin{tabular}[c]{@{}c@{}}29.20\\ 26.03\\24.32\end{tabular} & \begin{tabular}[c]{@{}c@{}}29.54\\ 25.69\\24.78\end{tabular} & \begin{tabular}[c]{@{}c@{}}29.52\\ 25.56\\25.13\end{tabular} & \begin{tabular}[c]{@{}c@{}}29.50\\ 26.24\\24.52\end{tabular} & \begin{tabular}[c]{@{}c@{}}29.87\\ 26.35\\24.61\end{tabular} & \begin{tabular}[c]{@{}c@{}}30.76\\ 27.14\\25.15\end{tabular} & \begin{tabular}[c]{@{}c@{}}30.81\\ 27.07\\25.19\end{tabular} & \begin{tabular}[c]{@{}c@{}}31.32\\ 28.07\\25.63\end{tabular} & \begin{tabular}[c]{@{}c@{}}31.14\\ 27.96\\25.07\end{tabular} & \begin{tabular}[c]{@{}c@{}}30.88\\ 27.08\\25.17\end{tabular} & \begin{tabular}[c]{@{}c@{}}\bf31.59\\\bf28.18\\\bf 25.76\end{tabular} & \begin{tabular}[c]{@{}c@{}}\bf31.61\\\bf28.19\\\bf 25.79\end{tabular} \\\Xhline{2\arrayrulewidth} \end{tabular}} \end{table*} \begin{table*} \centering\captionsetup{justification=centering}\captionsetup{justification=centering} \caption{SSIM comparisons over Set5, Set14, BSD100, and Urban100. \\Higher SSIM score (max=1) corresponds to greater structural similarity.} \label{tb:SSIM}\resizebox{\textwidth}{!}{ \begin{tabular}{r c c c c c c c c c c c c c c c c} \Xhline{2\arrayrulewidth} SSIM&Scale & \begin{tabular}[c]{@{}c@{}}Bicubic{}{}\end{tabular} & \begin{tabular}[c]{@{}c@{}}ScSR{}\\\cite{yang2010image}{}\end{tabular} & \begin{tabular}[c]{@{}c@{}}A+{}\\\cite{timofte2014a+}{}\end{tabular} & \begin{tabular}[c]{@{}c@{}}SelfEx{}\\\cite{huang2015single}{}\end{tabular} & \begin{tabular}[c]{@{}c@{}}SCN{}\\\cite{wang2015deep}{}\end{tabular} & \begin{tabular}[c]{@{}c@{}}SRCNN{}\\\cite{dong2014learning}{}\end{tabular} & \begin{tabular}[c]{@{}c@{}}FSRCNN{}\\\cite{dong2016accelerating}{}\end{tabular} & \begin{tabular}[c]{@{}c@{}}VDSR{}\\\cite{Kim_2016_VDSR}{}\end{tabular} & \begin{tabular}[c]{@{}c@{}}DWSR{}\\\cite{guo2017deep}{}\end{tabular} & \begin{tabular}[c]{@{}c@{}}RDN{}\\\cite{zhang2018residual}{}\end{tabular} & \begin{tabular}[c]{@{}c@{}}EDSR{}\\\cite{lim2017enhanced}{}\end{tabular} & \begin{tabular}[c]{@{}c@{}}DCT-DSR{}\\proposed{}\end{tabular} & \begin{tabular}[c]{@{}c@{}}ORDSR{}\\proposed{}\end{tabular} & \begin{tabular}[c]{@{}c@{}}ORDSR+{}\\proposed{}\end{tabular} \\ \hline Set5 & \begin{tabular}[c]{@{}c@{}}x2\\ x3\\ x4\end{tabular} & \begin{tabular}[c]{@{}c@{}}0.9292\\ 0.8678\\ 0.8101\end{tabular} & \begin{tabular}[c]{@{}c@{}}0.9485\\ 0.8869\\ 0.8263\end{tabular} & \begin{tabular}[c]{@{}c@{}}0.9544\\ 0.9088\\ 0.8605\end{tabular} & \begin{tabular}[c]{@{}c@{}}0.9538\\ 0.9092\\ 0.8640\end{tabular} & \begin{tabular}[c]{@{}c@{}}0.9540\\ 0.9080\\ 0.8630\end{tabular} & \begin{tabular}[c]{@{}c@{}}0.9542\\ 0.9090\\ 0.8628\end{tabular} & \begin{tabular}[c]{@{}c@{}}0.9558\\ 0.9140\\ 0.8657\end{tabular} & \begin{tabular}[c]{@{}c@{}}0.9586\\ 0.9212\\ 0.8820\end{tabular} & \begin{tabular}[c]{@{}c@{}}0.9577\\ 0.9214\\ 0.8843\end{tabular} & \begin{tabular}[c]{@{}c@{}}0.9590\\ 0.9213\\ 0.9015\end{tabular} & \begin{tabular}[c]{@{}c@{}}0.9587\\ 0.9218\\ 0.8923\end{tabular} & \begin{tabular}[c]{@{}c@{}}0.9573\\ 0.9220\\ 0.8850\end{tabular} & \begin{tabular}[c]{@{}c@{}}{\bf 0.9599}\\{\bf 0.9226}\\{\bf0.9060}\end{tabular} & \begin{tabular}[c]{@{}c@{}}{\bf 0.9602}\\{\bf 0.9229}\\{\bf0.9063}\end{tabular} \\ \hline Set14 & \begin{tabular}[c]{@{}c@{}}x2\\ x3\\ x4\end{tabular} & \begin{tabular}[c]{@{}c@{}}0.8683\\ 0.7737\\ 0.7023\end{tabular} & \begin{tabular}[c]{@{}c@{}}0.8940\\ 0.7977\\ 0.7218\end{tabular} & \begin{tabular}[c]{@{}c@{}}0.9055\\ 0.8188\\ 0.7489\end{tabular} & \begin{tabular}[c]{@{}c@{}}0.9032\\ 0.8196\\ 0.7518\end{tabular} & \begin{tabular}[c]{@{}c@{}}0.9050\\ 0.8180\\ 0.7510\end{tabular} & \begin{tabular}[c]{@{}c@{}}0.9063\\ 0.8209\\ 0.7503\end{tabular} & \begin{tabular}[c]{@{}c@{}}0.9088\\ 0.8242\\ 0.7535\end{tabular} & \begin{tabular}[c]{@{}c@{}}0.9102\\ 0.8294\\ 0.7662\end{tabular} & \begin{tabular}[c]{@{}c@{}}0.9104\\ 0.8315\\ 0.7665\end{tabular} & \begin{tabular}[c]{@{}c@{}}0.9138\\ 0.8349\\ 0.7792\end{tabular} & \begin{tabular}[c]{@{}c@{}}0.9133\\ 0.8352\\ 0.7668\end{tabular} & \begin{tabular}[c]{@{}c@{}}0.9091\\ 0.8337\\ {0.7680}\end{tabular} & \begin{tabular}[c]{@{}c@{}}\bf 0.9184\\\bf 0.8380\\ \bf 0.7823\end{tabular} & \begin{tabular}[c]{@{}c@{}}\bf 0.9187\\\bf 0.8383\\ \bf 0.7826\end{tabular} \\ \hline BSD100 & \begin{tabular}[c]{@{}c@{}}x2\\ x3\\x4\end{tabular} & \begin{tabular}[c]{@{}c@{}}0.8425\\ 0.7382\\0.6672\end{tabular} & \begin{tabular}[c]{@{}c@{}}0.8744\\ 0.7647\\0.6983\end{tabular} & \begin{tabular}[c]{@{}c@{}}0.8864\\ 0.7836\\0.7087\end{tabular} & \begin{tabular}[c]{@{}c@{}}0.8855\\ 0.7778\\0.7106\end{tabular} & \begin{tabular}[c]{@{}c@{}}0.8850\\ 0.7910\\0.7110\end{tabular} & \begin{tabular}[c]{@{}c@{}}0.8879\\ 0.7863\\0.7101\end{tabular} & \begin{tabular}[c]{@{}c@{}}0.8920\\ 0.7897\\0.7201\end{tabular} & \begin{tabular}[c]{@{}c@{}}0.8960\\ 0.7976\\0.7238\end{tabular} & \begin{tabular}[c]{@{}c@{}}0.8947\\ 0.7980\\0.7243\end{tabular} & \begin{tabular}[c]{@{}c@{}}0.8979\\ 0.8007\\0.7316\end{tabular} & \begin{tabular}[c]{@{}c@{}}0.8975\\ 0.8011\\0.7276\end{tabular} & \begin{tabular}[c]{@{}c@{}}0.8954\\ 0.7992\\{0.7285}\end{tabular} & \begin{tabular}[c]{@{}c@{}}{\bf 0.8984}\\\bf0.8045\\{\bf 0.7363}\end{tabular} & \begin{tabular}[c]{@{}c@{}}{\bf 0.8986}\\\bf0.8048\\{\bf 0.7367}\end{tabular} \\ \hline Urban100 & \begin{tabular}[c]{@{}c@{}}x2\\ x3\\ x4\end{tabular} & \begin{tabular}[c]{@{}c@{}}0.8408\\ 0.7349\\0.6573\end{tabular} & \begin{tabular}[c]{@{}c@{}}0.8828\\ 0.7827\\0.7024\end{tabular} & \begin{tabular}[c]{@{}c@{}}0.8938\\ 0.7973\\0.7186\end{tabular} & \begin{tabular}[c]{@{}c@{}}0.8967\\ 0.7864\\0.7374\end{tabular} & \begin{tabular}[c]{@{}c@{}}0.8970\\ 0.8016\\0.7260\end{tabular} & \begin{tabular}[c]{@{}c@{}}0.8946\\ 0.7989\\0.7221\end{tabular} & \begin{tabular}[c]{@{}c@{}}0.9010\\ 0.7512\\0.7270\end{tabular} & \begin{tabular}[c]{@{}c@{}}0.9140\\ 0.8272\\0.7524\end{tabular} & \begin{tabular}[c]{@{}c@{}}0.9127\\ 0.8265\\0.7591\end{tabular} & \begin{tabular}[c]{@{}c@{}}0.9170\\ 0.8354\\0.7755\end{tabular} & \begin{tabular}[c]{@{}c@{}}0.9157\\ 0.8269\\0.7582\end{tabular} & \begin{tabular}[c]{@{}c@{}}0.9136\\ 0.8193\\{0.7608}\end{tabular} & \begin{tabular}[c]{@{}c@{}}{\bf 0.9181}\\\bf0.8381\\{\bf 0.7787}\end{tabular} & \begin{tabular}[c]{@{}c@{}}{\bf 0.9183}\\\bf0.8384\\{\bf 0.7789}\end{tabular} \\\Xhline{2\arrayrulewidth} \end{tabular}} \end{table*} \begin{table*} \centering\captionsetup{justification=centering} \caption{IFC comparisons over Set5, Set14, BSD100, and Urban100.\\ Higher IFC score indicates better alignment of natural scene statistics.}\vspace{-2pt}\sqz \label{tb:IFC}\resizebox{\textwidth}{!}{ \begin{tabular}{r c c c c c c c c c c c c c c c} \Xhline{2\arrayrulewidth} IFC&Scale & \begin{tabular}[c]{@{}c@{}}Bicubic{}{}\end{tabular} & \begin{tabular}[c]{@{}c@{}}ScSR{}\\\cite{yang2010image}{}\end{tabular} & \begin{tabular}[c]{@{}c@{}}A+{}\\\cite{timofte2014a+}{}\end{tabular} & \begin{tabular}[c]{@{}c@{}}SelfEx{}\\\cite{huang2015single}{}\end{tabular} & \begin{tabular}[c]{@{}c@{}}SCN{}\\\cite{wang2015deep}{}\end{tabular} & \begin{tabular}[c]{@{}c@{}}SRCNN{}\\\cite{dong2014learning}{}\end{tabular} & \begin{tabular}[c]{@{}c@{}}FSRCNN{}\\\cite{dong2016accelerating}{}\end{tabular} & \begin{tabular}[c]{@{}c@{}}VDSR{}\\\cite{Kim_2016_VDSR}{}\end{tabular} & \begin{tabular}[c]{@{}c@{}}DWSR{}\\\cite{guo2017deep}{}\end{tabular} & \begin{tabular}[c]{@{}c@{}}RDN{}\\\cite{zhang2018residual}{}\end{tabular} & \begin{tabular}[c]{@{}c@{}}EDSR{}\\\cite{lim2017enhanced}{}\end{tabular} & \begin{tabular}[c]{@{}c@{}}DCT-DSR{}\\proposed{}\end{tabular} & \begin{tabular}[c]{@{}c@{}}ORDSR{}\\proposed{}\end{tabular} & \begin{tabular}[c]{@{}c@{}}ORDSR+{}\\proposed{}\end{tabular} \\ \hline Set5 & \begin{tabular}[c]{@{}c@{}}x2\\ x3\\ x4\end{tabular} & \begin{tabular}[c]{@{}c@{}}5.72\\ 3.45\\ 2.28\end{tabular} & \begin{tabular}[c]{@{}c@{}}6.94\\ 3.98\\ 2.57\end{tabular} & \begin{tabular}[c]{@{}c@{}}8.48\\4.84\\3.26\end{tabular} & \begin{tabular}[c]{@{}c@{}}7.35\\4.05\\3.12 \end{tabular} & \begin{tabular}[c]{@{}c@{}}7.36\\4.32\\2.91\end{tabular} & \begin{tabular}[c]{@{}c@{}}8.05\\4.58\\ 3.01\end{tabular} & \begin{tabular}[c]{@{}c@{}}8.06\\4.56\\2.76\end{tabular} & \begin{tabular}[c]{@{}c@{}}8.76\\ 4.85\\ 3.36\end{tabular} & \begin{tabular}[c]{@{}c@{}}8.69\\ 4.47\\3.31\end{tabular} & \begin{tabular}[c]{@{}c@{}}8.80\\ 4.74\\ 3.81\end{tabular} & \begin{tabular}[c]{@{}c@{}}8.77\\ 4.79\\ 3.66\end{tabular} & \begin{tabular}[c]{@{}c@{}}8.56\\ {4.87}\\ 3.78\end{tabular} & \begin{tabular}[c]{@{}c@{}}{\bf8.82}\\ {\bf 4.96}\\ {\bf 4.02}\end{tabular} & \begin{tabular}[c]{@{}c@{}}{\bf8.83}\\ {\bf 4.98}\\ {\bf 4.03}\end{tabular} \\ \hline Set14 & \begin{tabular}[c]{@{}c@{}}x2\\ x3\\ x4\end{tabular} & \begin{tabular}[c]{@{}c@{}}5.74\\ 3.33\\ 2.18\end{tabular} & \begin{tabular}[c]{@{}c@{}}6.83\\ 3.75\\ 2.46\end{tabular} & \begin{tabular}[c]{@{}c@{}}7.35\\4.26\\2.94\end{tabular} & \begin{tabular}[c]{@{}c@{}}7.05\\4.12 \\2.32 \end{tabular} & \begin{tabular}[c]{@{}c@{}}7.08\\4.00\\2.65\end{tabular} & \begin{tabular}[c]{@{}c@{}}6.68\\ 3.81\\ 2.50\end{tabular} & \begin{tabular}[c]{@{}c@{}}7.47\\4.24\\2.55\end{tabular} & \begin{tabular}[c]{@{}c@{}}7.53\\ 4.33\\ 2.80\end{tabular} & \begin{tabular}[c]{@{}c@{}}7.40\\ 4.31\\2.97\end{tabular} & \begin{tabular}[c]{@{}c@{}}7.61\\ 4.38\\3.15\end{tabular} & \begin{tabular}[c]{@{}c@{}}7.58\\ 4.43\\ 3.06\end{tabular} & \begin{tabular}[c]{@{}c@{}}7.49\\ 4.39\\ {3.11}\end{tabular} & \begin{tabular}[c]{@{}c@{}}{\bf 7.67}\\ {\bf 4.55}\\ {\bf 3.20}\end{tabular} & \begin{tabular}[c]{@{}c@{}}{\bf 7.69}\\ {\bf 4.57}\\ {\bf 3.23}\end{tabular} \\ \hline BSD100 & \begin{tabular}[c]{@{}c@{}}x2\\ x3\\x4\end{tabular} & \begin{tabular}[c]{@{}c@{}}5.26\\ 2.98\\1.91\end{tabular} & \begin{tabular}[c]{@{}c@{}}6.20\\ 3.14\\2.22\end{tabular} & \begin{tabular}[c]{@{}c@{}}7.15\\ 3.23\\2.51\end{tabular} & \begin{tabular}[c]{@{}c@{}}6.84\\ 3.80\\2.44\end{tabular} & \begin{tabular}[c]{@{}c@{}}6.50\\ 3.46\\2.30\end{tabular} & \begin{tabular}[c]{@{}c@{}}6.09\\ 3.52\\2.18\end{tabular} & \begin{tabular}[c]{@{}c@{}}7.01\\ 3.71\\2.32\end{tabular} & \begin{tabular}[c]{@{}c@{}}7.16\\ 3.83\\2.62\end{tabular} & \begin{tabular}[c]{@{}c@{}}7.14 \\ 3.84\\2.57\end{tabular} & \begin{tabular}[c]{@{}c@{}}7.21 \\ 3.96\\2.70\end{tabular} & \begin{tabular}[c]{@{}c@{}}7.19\\ 3.85\\2.53\end{tabular} & \begin{tabular}[c]{@{}c@{}}{7.22}\\ 3.87\\{2.65}\end{tabular} & \begin{tabular}[c]{@{}c@{}}{\bf7.29}\\\bf 4.07\\{\bf 2.89}\end{tabular} & \begin{tabular}[c]{@{}c@{}}{\bf7.30}\\\bf 4.09\\{\bf 2.90}\end{tabular} \\ \hline Urban100 & \begin{tabular}[c]{@{}c@{}}x2\\ x3\\x4\end{tabular} & \begin{tabular}[c]{@{}c@{}}5.72\\ 3.42\\2.27\end{tabular} & \begin{tabular}[c]{@{}c@{}}6.98\\ 3.16\\2.75\end{tabular} & \begin{tabular}[c]{@{}c@{}}8.02\\ 3.78\\3.16\end{tabular} & \begin{tabular}[c]{@{}c@{}}7.96\\ 3.55\\3.21\end{tabular} & \begin{tabular}[c]{@{}c@{}}7.32\\ 3.32\\2.86\end{tabular} & \begin{tabular}[c]{@{}c@{}}6.66\\ 4.01\\2.63\end{tabular} & \begin{tabular}[c]{@{}c@{}}8.13\\ 4.43\\3.02\end{tabular} & \begin{tabular}[c]{@{}c@{}}8.27\\ 4.63\\3.40\end{tabular} & \begin{tabular}[c]{@{}c@{}}8.30\\ 4.71\\3.39\end{tabular} & \begin{tabular}[c]{@{}c@{}}8.34\\ 4.92\\3.40\end{tabular} & \begin{tabular}[c]{@{}c@{}}8.31\\ 4.85\\{3.42}\end{tabular} & \begin{tabular}[c]{@{}c@{}}{8.35}\\ 4.82\\3.36\end{tabular} & \begin{tabular}[c]{@{}c@{}}{\bf 8.42}\\\bf 5.03\\{\bf 3.45}\end{tabular} & \begin{tabular}[c]{@{}c@{}}{\bf 8.45}\\\bf 5.06\\{\bf 3.47}\end{tabular} \\\Xhline{2\arrayrulewidth} \end{tabular}} \end{table*} We select well known methods from model-based, sparse-coding and recently developed deep learning based methods: \begin{enumerate} \item ScSR \cite{yang2010image}: the most representative sparse-coding based SR method. ScSR constructs LR/HR image patch dictionaries with a shared sparse code representation of a given LR/HR image pair. \item A+ \cite{timofte2014a+}: a revised version of anchored neighborhood regression SR \cite{timofte2013anchored}. \item SelfEx \cite{huang2015single}: a model-based method that exploits the self-similarity within the image itself. \item SCN \cite{wang2015deep}: CNN based method with a sparse prior. \item SRCNN \cite{dong2014learning}: the most widely used CNN based SR method (the CNN consists of 3 layers). \item FSRCNN \cite{dong2016accelerating}: an enhanced version of SRCNN with deeper structure and transpose convolution layer. \item VDSR \cite{Kim_2016_VDSR}: CNN that utilizes residual structure with a network depth of $20$ layers. \item DWSR \cite{guo2017deep}: CNN that utilizes residual structure in the DWT domain. \item RDN \cite{zhang2018residual}: residual dense network that extracts abundant local features. \item EDSR \cite{lim2017enhanced}: the winning entry of the NTIRE contest held at CVPR 2017 \cite{Timofte_2017_CVPR_Workshops}, which utilizes $32$ residual blocks and output branches to handle different scale factors. Each residual block contains $2$ convolutional layer and each convolutional layer has $256$ filters. \item DCT-DSR: as described in Section \ref{sec:CE}. \end{enumerate} As is standard practice \cite{dong2016image}, to create LR test images the known HR images are down-sampled and inputs to the network are created using bicubic interpolation\footnote{Except for EDSR \cite{lim2017enhanced} which uses deconvolutional layer at end to enlarge the image to desired size.}. For fairness in comparison, comparison is focused on end-to-end deep SR models with all the deep learning models being (re)trained with the 291 image training dataset described in Section \ref{sec:exp-setup}. The $D$-layer CNN employed in ORDSR has a residual network structure, which is extendable to progressive and recursive models \cite{lai2017deep,kim2016deeply,tai2017image}. This is beyond the scope of this paper and a topic for future study. \subsubsection{Network Size and Memory Requirements} \label{sec:memy} Using the CDCT layer with an unconventional stride gives ORDSR a huge advantage in faster training and test with less memory requirements. A typical test image \textit{lena.bmp} of size $512\times512$, format {\it float32} takes {\it 257KB} disk space. Feeding the test image through VDSR, each layer produces $64$ activation maps and each feature map has same size as input image. Assuming that a prefect memory release/recycle mechanism is in-place\footnote{At any given time, only one layer's activation maps are stored.}, at any given time, VDSR requires a minimum memory of: $\text{\it 257KB} \times 64 \approx \text{\it 16MB}$. \begin{figure}[t] \centering \includegraphics[width=0.98\linewidth]{figs/parPSNR.pdf} \caption{ORDSR vs. state-of-the-art methods. PSNR on Set5 with scale factor of 3, plotted against number of parameters in the network.} \label{fig:par} \end{figure} Feeding the same test image through ORDSR's CDCT layer using a stride\footnote{Other results of stride $S=3, 4, 5, 8$ can be found in the supplementary document \cite{techReport}.} of $S=2$, as shown in Fig. \ref{fig:cdct}, reduces input image width and height both by a factor of $2$. At any given time, ORDSR requires a minimum memory of $\text{\it 257KB}/2/2 \times 64 \approx \text{\it 4MB}$, which is around a quarter of VDSR. This shows ORDSR uses about four times less memory than VDSR for activation maps during the inference. For a typical mobile camera image, which usually takes {\it 5MB} to {\it 10MB}\footnote{A standard smart-phone photo takes about {\it 8MB}.}, using ORDSR can save {\it 240MB} to {\it 480MB}. VDSR as reported in \cite{Kim_2016_VDSR} uses two $3\times3\times64$ and eighteen $3\times3\times64\times64$ convolutional layers. EDSR \cite{lim2017enhanced} has $32$ residual blocks where each has $2$ convolutional layers with $256$ filters in each layer. On the other hand, ORDSR in its most common realization uses: one $8\times8\times64$ CDCT layer, one $5\times5\times64\times64$, thirteen $3\times3\times64\times64$, and one $3\times3\times64\times60$ convolutional layers, which combines to produce about $44\text{\it K}$ fewer parameters than VDSR, and about $\mathbf{95\%}$ less parameters than EDSR\footnote{For detailed computation please see supplementary document \cite{techReport}.}. During training, EDSR generates network snapshots of about $160\text{\it MB}$, while ORDSR only uses $7\text{\it MB}$ with the Tensorflow \cite{tensorflow2015-whitepaper} API. As shown in Fig. \ref{fig:par}, the ORDSR achieves better performance among all deep learning based methods while using less parameters. \begin{figure*} \centering \includegraphics[trim=0cm 0cm 0cm 0cm,clip,width=\linewidth]{./figs/magnify_zebra_elg.pdf}\vspace{-2pt}\sqz\vspace{-2pt}\sqz\vspace{-2pt}\sqz\vspace{-2pt} \caption{The SR results of test image \textit{zebra.bmp} for scale factor 3. Three image quality metrics are reported along with the SR results (PSNR, SSIM, IFC). ORDSR produces best visual results, also corroborated by the quality metrics. }\label{fig:SR_zb} \end{figure*} \begin{figure*} \centering \includegraphics[trim=0cm 0cm 0cm 0cm,clip,width=\linewidth]{./figs/magnify_u425_elg.pdf} \caption{The SR test results from Urban100 for scale factor 4. The assessment metrics are shown as (PSNR, SSIM, IFC).}\label{fig:SR_BSD} \end{figure*} Since ORDSR produces smaller activation maps and has a network with less parameters, ORDSR requires less computations and trains faster than VDSR. Using the computational resources mentioned in Section \ref{sec:exp-setup}, VDSR takes $0.12 sec$ to train on one batch\footnote{Each batch is of size $128\times40\times40\times1$, for both VDSR and ORDSR.}, while ORDSR takes $0.043 sec$ per batch, which is about $2.7$ times faster. \subsubsection{Evaluation with Abundant Training} \label{sec:abundant} With $100\%$ of the training images used for training, Fig.\ \ref{fig:SR_but} and Fig.\ \ref{fig:SR_zb} display example test images in detail. Note that in Fig. \ref{fig:SR_but}, deep learning based methods generate better results than sparse-coding based methods. The enlarged parts show the antennae of the monarch. ORDSR produces more defined edges and smoother background around the antennae than competing methods. Tables \ref{tb:PSNR}, \ref{tb:SSIM} and \ref{tb:IFC} report the PSNR, SSIM and IFC results of ORDSR and other methods, respectively. Out of the $10$ methods reported in Tables \ref{tb:SSIM}, \ref{tb:IFC} and \ref{tb:PSNR}, VDSR, EDSR, DCT-DSR, and ORDSR produce superior results than the rest. Note that DCT-DSR can produce comparable results as EDSR and better results than VDSR by utilizing the DCT image transform domain. ORDSR further improves the performance by optimizing the transform basis. Overall, ORDSR produces best results while using $44\text{\it K}$ fewer parameters than VDSR does and $\mathbf{5\%}$ of the parameters as EDSR does. \label{pg:self}We adopt the geometric self-ensemble strategy (similar to \cite{timofte2016seven}) to enhance the SR results. During the test, the input image $\mathbf{x}$ is flipped and rotated generating $8$ augmented versions $\mathbf{x}_i = T_i(\mathbf{x})$ where $T_i$ is one of the $8$ transformations\footnote{These transformations are: vertical flip and $\{90^{\circ},180^{\circ},270^{\circ}\}$ rotations. Combining with identity, there are $8$ versions of the input image.} including identity. Then the corresponding SR outputs $\{\hat{\mathbf{y}}_i\}_{i=1}^8$ of ORDSR are flipped and rotated back using the inverse transformation $T^{-1}(\cdot)$. The final SR result is computed as $\hat{\mathbf{y}} = \frac{1}{8}\sum_i T^{-1}(\hat{\mathbf{y}}_i)$. We mark the results using this method as ORDSR+. As is shown in Tables \ref{tb:PSNR}, \ref{tb:SSIM} and \ref{tb:IFC}, this augmentation strategy can improve the SR results mildly. \begin{figure*} \centering \includegraphics[trim=0cm 0cm 0cm 0cm,clip,width=\linewidth]{./figs/all_in_one.pdf} \begin{subfigure}{0.33\linewidth} \caption{PSNR results}\label{fig:lim_1} \end{subfigure}% \begin{subfigure}{0.33\linewidth} \caption{SSIM results}\label{fig:lim_2} \end{subfigure}% \begin{subfigure}{0.33\linewidth} \caption{IFC results}\label{fig:lim_3} \end{subfigure} \caption{Plots of image quality metrics (PSNR, SSIM, IFC) vs. percentage of training samples obtained for SR images for five most competitive methods -- test Set14, scale factor 3. }\label{fig:lim} \end{figure*} \begin{figure*} \centering \includegraphics[trim=0cm 0cm 0cm 0cm,clip,width=\linewidth]{./figs/magnify_barbara_slim_elg.pdf}\vspace{-2pt}\sqz \caption{The SR results of test image \textit{barbara.bmp} for scale factor 3 -- results shown for $10\%$ and $35\%$, i.e.\ limited training scenarios. Three image quality metrics are reported along with the SR results (PSNR, SSIM, IFC). ORDSR produces best visual results, also corroborated by the quality metrics.}\label{fig:SR_zb_lim} \end{figure*} Fig. \ref{fig:SR_zb} illustrates the merits of ORDSR in overcoming artifacts introduced by bicubic interpolation and adding more details in the SR results. In the original image of Fig. \ref{fig:SR_zb}, there is no connection between these strips. However, after downsampling and rescaling using bicubic interpolation, the artifacts are generated as `new spurious blocks' appear that connect these strips diagonally. Note that even state of the art deep learning methods are unable to overcome this. As is shown in Fig. \ref{fig:SR_zb}, for all competing methods including VDSR and EDSR, this `fake edge' is present and sometimes even enhanced. On the contrary, by virtue of operating in a carefully optimized transform domain, ORDSR exploits inter-frequency spectra information, and nearly eliminates these artifacts. In Fig. \ref{fig:SR_BSD}, the deep learning based method SR results are shown under scale factor $4$. As is shown, the ORDSR can produce more details in the SR image and has higher numerical scores. \subsubsection{The Limited Training Scenario} \label{sec:limited-train} For many real-world applications, such as medical and radar image SR \cite{vishal2017image, he2012learning, wu2016super ,bahrami2016reconstruction}, abundant training is usually not available. We focus on two cases: $10\%$ and $35\%$ of the training image set employed in Section \ref{sec:abundant} is used. To eliminate selection bias, several random selections were made and averaged results are presented. \begin{table*} \centering\captionsetup{justification=centering} \caption{Image quality metric (PSNR/SSIM/IFC) comparisons over Set5 and Set14. $10\%$ training images are used. } \label{tb:lim}\resizebox{0.82\linewidth}{!}{ \begin{tabular}{r c c c c c c c c c} \Xhline{2\arrayrulewidth} &Scale & \begin{tabular}[c]{@{}c@{}}FSRCNN{}\\\cite{dong2016accelerating}{}\end{tabular} & \begin{tabular}[c]{@{}c@{}}VDSR{}\\\cite{Kim_2016_VDSR}{}\end{tabular} & \begin{tabular}[c]{@{}c@{}}EDSR{}\\\cite{lim2017enhanced}{}\end{tabular} & \begin{tabular}[c]{@{}c@{}}DCT-DSR{}\\ proposed{}\end{tabular} & \begin{tabular}[c]{@{}c@{}}ORDSR{}\\proposed{}\end{tabular} \\ \hline Set5 &\begin{tabular}[c]{@{}c@{}}x2\\ x3\\ x4\end{tabular} & \begin{tabular}[c]{@{}c@{}}36.18/0.9409/6.38\\ 32.23/0.9097/3.85\\ 29.87/0.8678/2.31\end{tabular} & \begin{tabular}[c]{@{}c@{}}36.82/0.9515/7.10\\ 32.84/0.9187/4.01\\ 30.57/0.8763/2.98\end{tabular} & \begin{tabular}[c]{@{}c@{}}36.75/0.9502/7.01\\ 32.76/0.9123/3.92\\ 30.35/0.8725/2.76\end{tabular} & \begin{tabular}[c]{@{}c@{}}36.98/0.9533/7.23\\ 32.87/0.9192/4.03\\ 30.76/0.8772/2.97\end{tabular} & \begin{tabular}[c]{@{}c@{}}\bf 37.24/0.9542/7.95\\\bf 33.42/0.9201/4.16\\\bf 31.14/0.8792/3.02\end{tabular} \\ \hline Set14 &\begin{tabular}[c]{@{}c@{}}x2\\ x3\\ x4\end{tabular} & \begin{tabular}[c]{@{}c@{}}32.29/0.8920/6.26\\ 28.60/0.8089/3.69\\ 26.82/0.7298/2.23\end{tabular} & \begin{tabular}[c]{@{}c@{}}32.35/0.8986/6.53\\ 29.03/0.8119/3.80\\ 27.25/0.7420/2.50\end{tabular} & \begin{tabular}[c]{@{}c@{}}32.32/0.8952/6.38\\ 28.78/0.8102/3.72\\ 27.26/0.7416/2.53\end{tabular} & \begin{tabular}[c]{@{}c@{}}32.56/0.8979/6.62\\ 29.10/0.8143/3.87\\ 27.35/0.7482/2.62\end{tabular} & \begin{tabular}[c]{@{}c@{}}\bf 32.98/0.9001/6.96\\\bf 29.67/0.8265/4.30\\\bf 27.89/0.7532/3.17\end{tabular} \\\Xhline{2\arrayrulewidth} \end{tabular}} \end{table*} We focus on five methods: FSRCNN, EDSR, VDSR, DCT-DSR, and ORDSR since they are shown to be most competitive. Figs. \ref{fig:lim_1}-\ref{fig:lim_3} show the PSNR, SSIM and IFC measures plotted against percentage of training data used for these five methods. Note further that, in Section \ref{sec:abundant} we compared methods exactly as they are reported in their respective articles. Here to particularly observe and isolate the effects of training size, for fairness each network is employed with the {\em same number} of layers ($10$); where EDSR is realized with $10$ residual blocks. The plots in Figs.\ \ref{fig:lim_1}-\ref{fig:lim_3} are for a scaling factor of $3$ and on the Set14 test set. Two major trends emerge: a.) ORDSR offers a more graceful degradation w.r.t a decrease in the number of training samples and compelling improvements when training is limited, and b.) DCT-DSR produces results somewhat comparable to VDSR and EDSR with complementary merits in low vs. high training regimes. The competitive performance of DCT-DSR shows the value of transform domain deep SR. Finally, the gains of ORDSR over DCT-DSR, particularly when training is low ($10\%$, $35\%$ cases) emphasizes the value of regularization in improving results. Fig. \ref{fig:SR_zb_lim} shows the limited training scenario SR results visually for the {\em barbara.bmp} image. Compared to FRCNN, EDSR, and VDSR, ORDSR generates better visual results as well as higher numerical assessments in both the $10\%$ and $35\%$ cases. Table \ref{tb:lim} provides more validation for the $10\%$ training case with scale factors varying from $2$-$4$ over test sets Set5 and Set14 using $10$-layer setups for all five methods. Quite clearly, ORDSR outperforms the competition and often by a fairly significant margin. \label{pg:lim}ORDSR does better in limited training because of two reasons: 1.) the SR mapping is simplified in the transform (for e.g. DCT) domain and hence even with limited training, the network can better approximate the non-linear mapping between LR and HR transform coefficients vs. methods that are based on spatial domain mappings, and 2.) the orthogonality and complexity regularizers play a crucial role in imparting desired structure to the transform/CDCT layer filters. As is readily apparent in Fig. \ref{fig:lim}, ORDSR is indeed the best, while DCT-DSR is the second best with 10 percent training because DCT-DSR also shares the two benefits mentioned above. Note also from Figs. \ref{fig:lim_1}-\ref{fig:lim_3} that DSR-UC, which optimizes the transform/CDCT layer but without {\em any} constraints, indeed does poorly in low-training while still being competitive in the 100 percent training case. Orthogonality is indeed a crucial property for guaranteed forward and inverse transforms in our design -- DSR-UC {\em naturally leans} towards more orthogonal transform filters when driven by abundant training but this property is significantly lost when training is limited. In Fig.\ \ref{fig:lim}, both abundant and limited training size(s) are relative to size of the test set which contains about $291$ images. \section{Conclusion} \label{sec:conclusion} We develop a novel network structure to tackle the SR problem in an image transform domain. We start with DCT as the choice of image transform by proposing methods that integrate it into the network structure as a convolutional DCT (CDCT) or transform layer. We evolve the said DCT-DSR into a regularized deep network that allows for constrained optimization of basis filters that comprise the transform layer. Because orthogonality constraints are central to the transform, we call our method: Orthogonally Regularized Deep Super-Resolution (ORDSR). ORDSR is subsequently shown to outperform state of the art SR methods, particularly when training imagery (LR and HR image pairs) is limited. In future research, other image transform domains such as DFT and DWT can be investigated for deep SR as presented in this work. This will require explicit integration of the transform within the network structure as well as design of new specialized constraints on the transform basis to arrive at new meaningful basis that are Fourier or wavelet like. \appendices \section{Proposition 1: Sketch of the Proof}\label{sec:apx-1} We need to show that the convolution of CDCT layer filters with the input image generates the DCT coefficients but in a zig-zag reordered form. We first define a \textbf{zig-zag mapping function} $Zig(\cdot)$, such that it maps a 2D matrix to a 1D vector following Fig. \ref{fig:zigzag}: $Zig(k_1,k_2)=i$ where $(k_1,k_2)\in[0,N-1] \footnote{Note that in the appendices, we use $[a,b]$ denotes discrete intervals.}\times[0,N-1]\rightarrow i\in[1,N\times N]$. Thus $Zig(k_1,k_2)=i$ and $Zig^{-1}(i)=(k_1,k_2)$\\ The proof contains two cases, one in which stride size is equal to DCT block size ($S=N$) and one in which stride size is less than DCT block size ($S<N$): we list here the key steps of the proof for each case:\\ \textbf{Case 1 $(S=N)$:} For DCT transform, we convolve the image $\mathbf{x}\in\mathbb{R}^{W\times H}$ with the DCT basis filters $\{\mathbf{w}_i\}_{i=1}^{N\times N}$. For $(m,n)\in[1,H/N]\times[1,W/N]$, $\mathbf{X}^\text{dct}_{m,n}(k_1,k_2)$ is the $(m,n)^{th}$ DCT coefficients block indexed by $(k_1,k_2)$. For CDCT layer, convolve $x$ with $w_i$ we get: $\mathbf{X}_i^\text{cdct}:=\mathbf{x}*\mathbf{w}_i$, where $\mathbf{X}_i^\text{cdct}\in\mathbb{R}^{\frac{W}{N}\times\frac{H}{N}}$. We then prove the proposition by mapping the DCT coefficients generated by the DCT basis to the convolutional results using the zig-zag function. For a fixed $(m, n)$, the $\mathbf{X}^\text{cdct}_i(m,n)\in\mathbb{R}^{N^2\times1}$ can be zig-zag re-indexed into $\mathbf{X}^\text{cdct}_{m,n}(i)\in\mathbb{R}^{N\times N}$ where $i\in[1,N^2]$. Then we show for a fixed $(m,n)$, $\mathbf{X}^\text{cdct}_i(m,n) = \mathbf{X}^\text{dct}_{m,n}(k_1,k_2)$ where $i\in[0,N^2]$ and $i=Zig(k_1,k_2)=i$ for $i\in[0,N^2]$. The detailed index mapping can be found in Sec. III-A of the supplementary document \cite{techReport}.\\ \textbf{Case 2 $(S<N)$:} There is an overlapping of $(N-S)$ pixels for both DCT transform and CDCT layer. The overlapping will create reorganized DCT coefficients based on overlapped inputs. Similar to Case 1, for a fixed $(m,n)$, the key steps of the proof are unchanged (see Sec. III-B of \cite{techReport}). \section{Proposition 2: Sketch of the Proof}\label{sec:apx-2} Similar to Appendix \ref{sec:apx-1}, we need to show CDCT layer and IDCT transform result in the same spatial image. We define a \textbf{zero-padding function}, $g_s(\cdot)$: For a given location $(p,q)\in[1,W]\times[1,H]$: \begin{equation}\resizebox{\linewidth}{!}{$ g_s(\mathbf{X}_i):=\bar{\mathbf{X}}_i(p,q) =\begin{cases}\frac{1}{(N/S)^2}\mathbf{X}_i(k,l),&\text{if }p= k\times S\text{ and }q=l\times S\\0,&\text{Otherwise}\end{cases},\label{xhat_N}$} \end{equation} where $k\in[1,\frac{W}{S}], l\in[1,\frac{H}{S}]$. Note that with $S=N$, the term $\frac{1}{(N/S)^2} = 1$ means that the $g_s(\cdot)$ keeps the $\mathbf{X}_i$ value as given and does not apply reweighing. This is a different case for $S< N$. We denote $g_s(\mathbf{X}_i):=\bar{\mathbf{X}}_i\in\mathbb{R}^{W\times H}$ which is a zero padded version of $\mathbf{X}_i$. Note that the transpose convolution between $\mathbf{w}_i$ and the $\mathbf{X}_i$ is the convolution between the $\mathbf{w}_i$ and the $g_s(\mathbf{X}_i)$.\\ \textbf{Case 1 $(S=N)$:} for a fixed block $(m,n)$, $k_1,k_2,n_1,n_2 \in [1,N]$, IDCT by DCT basis, $\mathbf{x}^\text{dct}_{m,n}(n_1,n_2)$ is the recovered image given as in Eq. \eqref{eq:idct}. On the other hand, IDCT using the CDCT layer is computed as: \begin{equation}\resizebox{\linewidth}{!}{$ \mathbf{x}^\text{cdct}_{m,n}(n_1,n_2)=\sum_{i=1}^{N \times N}\sum_{p=0}^{N-1}\sum_{q=0}^{N-1}\bar{\mathbf{X}}_i(m\times N + n_1-p,n\times N + n_2-q)\times \mathbf{w}_{i}(p,q)\label{idct_N}$} \end{equation} where $\bar{\mathbf{X}}_i(\cdot,\cdot)\neq 0$, while $n_1-p$ and $n_2-q$ are multiples of $N$ (based on the definition of $\bar{\mathbf{X}}$ from Eq. \eqref{xhat_N}). We then use $Zig^{-1}$ to reorder the indices to show that $\mathbf{x}^\text{dct}_{m,n}(n_1,n_2) = \mathbf{x}^\text{cdct}_{m,n}(n_1,n_2)$ in Sec. IV-A of \cite{techReport}.\\ \textbf{Case 2 $(S<N)$:} with overlapping of $N-S$ pixels, the aforementioned padding function remains the same but with $k\in[1,\frac{W}{S}], l\in[1,\frac{H}{S}]$. For a fixed block $(m,n)$, $k_1$, $k_2$, $n_1$, and $n_2 \in [1,N]$\\ IDCT by CDCT layer now is a weighted version of \eqref{idct_N} with $\frac{1}{(N/S)^2}$. When constructing the final output, at any given block $(m,n)$ for location $(n_1, n_2)$, \begin{equation*}\resizebox{\linewidth}{!}{$ \mathbf{x}^\text{cdct}_{m,n}(n_1,n_2) = \sum_{k=-N/2S}^{N/2S}\sum_{l=-N/2S}^{N/2S} \bar{\mathbf{x}}^\text{cdct}_{m-k,n-l}(n_1-k\times S, n_2-l\times S)\label{idct_S}$} \end{equation*} with the repeated elements in the summation as detailed in Sec. IV-A of \cite{techReport}, the overlapping effect is canceled by \begin{equation*}\resizebox{\linewidth}{!}{$ \mathbf{x}^\text{cdct}_{m,n}(n_1,n_2) = (N/S)^2\sum_i^{N\times N} \frac{1}{(N/S)^2} \mathbf{X}_i(m,n)\times\mathbf{w}_i(n_1,n_2)$} \end{equation*} We then use $Zig^{-1}$ to reorder the indices to show that $\mathbf{x}^\text{dct}_{m,n}(n_1,n_2) = \mathbf{x}^\text{cdct}_{m,n}(n_1,n_2)$ in Sec. IV-B of \cite{techReport}. \vspace{-5pt} \bibliographystyle{IEEEbib_ini}
{'timestamp': '2019-04-24T02:03:36', 'yymm': '1904', 'arxiv_id': '1904.10082', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.10082'}
arxiv
\section{Conclusion} Enable human-robots collaboration is a long-term goal. In this paper, we make a step further towards this goal by proposing a Remote Embodied Visual referring Expressions in Real Indoor Environments (REVERIE\xspace{}) task and dataset. The REVERIE\xspace{} is the first one to evaluate the capability of an agent to follow high-level natural languages instructions to navigate and identify the target object in previously unseen real images rendered buildings. We investigate several baselines and an interactive Navigator-Pointer agent model, of which the performance consistently demonstrate the significant necessity of further researches in this field. We reach three main conclusions: First, REVERIE\xspace{} is interesting because existing vision and language methods can be easily plugged in. Second, the challenge of understanding and executing high-level instructions is significant. Finally, the combination of instruction navigation and referring expression comprehension is a challenging task due to the large gap to human performance. \section{Experiments} \label{exp} In this section, we first present the training details of the interactive navigator--pointer model. Then, we provide extensive evaluation and analysis. \subsection{Implementation Details} The simulator image resolution is set to 640$\times$480 pixels with a vertical field of view of 60 degrees. For each instruction in the train split, images and object bounding boxes at the goal viewpoint (for the views where the target object is visible) are organised following the format as in MAttNet for pointer training. With the trained pointer, assistant object information is provided for the navigator as described in Section~\ref{sec:interaction} to train the navigator. The code and dataset will be released. \subsection{REVERIE\xspace Experimental Results} We first evaluate several baseline models and state-of-the-art (SoTA) navigation models, combined with the MattNet, \ie, the pointer module. {After the navigation models decide to stop, the pointer module is used to predict the target object. In addition, we also test human performance using an interactive web interface (see details in the supplementary). Below is a brief introduction of the evaluated baseline and state-of-the-art models. }There are four baseline models, which are: \begin{itemize} \vspace{-8pt} \item{\textbf{Random}} exploits the characteristics of the dataset by randomly choosing a path with random steps (maximum 10) and then randomly choose an object as the predicted target. \vspace{-8pt} \item{\textbf{Shortest}} always follows the shortest path to the goal. % \vspace{-8pt} \item{\textbf{R2R-TF and R2R-SF ~\cite{r2r}}} are the first batch of navigation baselines, which trains a basic LSTM~\cite{lstm} with attention mechanism~\cite{attnbengio}. The difference between R2R-TF and R2R-SF is that R2R-TF is trained with the ground truth action at each step (Teacher-Forcing, TF) while R2R-SF adopts an action sampled from the predicted probability over its action space (Student-Forcing, SF). \vspace{-5pt} \end{itemize} The evaluated four SoTA navigation models are: \begin{itemize} \vspace{-8pt} \item{\textbf{SelfMonitor~\cite{selfMonitor}}} uses a visual-textual co-grounding module to highlight the instruction for the next action and a progress monitor to reflect the progress. \vspace{-8pt} \item{\textbf{RCM~\cite{cross}}} employs reinforcement learning to encourage global matching between instructions and trajectories, and performs cross-model grounding. \vspace{-8pt} \item{\textbf{FAST-Short~\cite{fast}}} introduces backtracking into SelfMonitor. \vspace{-8pt} \item{\textbf{FAST-Lan-Only}} employs above FAST-Short model but we only input the language instruction without any visual input. {This model is used to check whether our task/dataset has a bias on language input.} \vspace{-5pt} \end{itemize} \noindent{\textbf{Results.}} The detailed experimental results are presented in Tab.~\ref{tab:finaltab}, of which the first four rows are results for baselines, the following four rows are for SoTA methods, and the last two rows are for our model and human performance. According to the baseline section in Tab.~\ref{tab:finaltab}, the Random model only achieves a REVERIE\xspace{} success {around} $1\%$, which indicates the REVERIE\xspace{} task has a huge solution space. The sequence-to-sequence baselines R2R-TF and R2R-SF \cite{r2r} achieve good results on the Val-Seen split but decrease a lot on the unseen splits. Student-Forcing is generally better than Teacher-Forcing. The Shortest model achieves the perfect performance because the ground-truth path to the goal is directly given. In the second part, the best REVERIE\xspace{} success rate is achieved by the combination of SoTA navigation (FAST) and referring expression (MAttNet) models. However, the REVERIE\xspace{} success rate is only $7.07\%$ on the test split, falling far behind human performance $77.84\%$. The navigation-only accuracy of these SoTA navigation models indicates the challenge of our navigation task. Nearly $30\%$ drops on the unseen splits are observed compared to the performance on previous R2R \cite{r2r}. For example, the navigation SPL score of FAST-Short~\cite{fast} on Val-UnSeen split drops from $43\%$ on the R2R dataset to $6.17\%$ on REVERIE\xspace. To test whether our dataset has strong language bias, \ie, whether a language-only model can achieve good performance, we implement a FAST-Lan-Only model with only instructions as its input. We observe a big drop on both seen and unseen splits, which suggests jointly considering language and visual information is necessary to our task. Overall, these SoTA model results show that a simple combination of SoTA navigation and referring expression methods would not necessarily lead to the best performance as failures from either the navigator or the pointer would decrease the overall success. In this paper, we make the first attempt to enable the navigator and pointer to work interactively as described in Sec.~\ref{sec:interaction}. The results in Tab.~\ref{tab:finaltab} show that our interactive model achieves consistently better results than non-interactive ones. The FAST-Short can be treated as our ablated model that without our proposed interaction module. Our final model achieves a gain of $4.2\%$ on the test split. \vspace{-8pt} \paragraph{Referring Expression-Only.} We also report the Referring Expression-Only performance. In this setting, the agent is placed at the ground-truth target location, and then referring expression comprehension models are tested. We test the SoTA models such as MattNet~\cite{mattnet} and CM-Erase~\cite{cm-erase} as well as a simple CNN-RNN baseline model with triplet ranking loss. Tab.~\ref{tab:grounding-only} presents the results with human performance. It shows that the SoTA models achieve around $50\%$ accuracy on the test split\footnote{These SoTA models achieve $80\%$ accuracy on ReferCOCO \cite{YuPYBB16}, a golden benchmark for referring expression.} which are far more better than the results when jointly considering the navigation and referring expression shown in Tab. \ref{tab:finaltab}. Even though, there is still a $40\%$ gap to human performance, suggesting that our proposed REVERIE\xspace{} task is challenging. \begin{table}[t] \centering \small \vspace{1mm} \begin{tabular}{lccc} \hline & Val Seen & Val UnSeen& Test \\ \hline Baseline &30.69&18.63& 16.18 \\ MAttNet \cite{mattnet} & 68.45&56.63 & 48.98 \\ CM-Erase \cite{cm-erase} &65.21&54.02 & 45.25 \\ Human & -- & -- & 90.76\\ \hline \end{tabular}% \vspace{1mm} \caption{Referring expression comprehension success rate ($\%$) at the ground truth goal viewpoint of our REVERIE\xspace{} dataset.} \vspace{-3mm} \label{tab:grounding-only}% \end{table}% \section{Introduction} \begin{figure}[!t] \begin{center} \includegraphics[width=\linewidth]{title.pdf} \end{center} \vspace{-4mm} \caption{REVERIE\xspace task: an agent is given a natural language instruction referring to a remote object (here in the red bounding box) in a photo-realistic 3D environment. The agent must navigate to an appropriate location and identify the object from multiple distracting candidates. The blue discs indicate nearby navigable viewpoints provided by the simulator. } \label{fig:title} \end{figure} You can ask a 10-year-old child to bring you a cushion, and there is a good chance that they will succeed (even in an unfamiliar environment), while the probability that a robot will achieve the same task is significantly lower. Children have a wealth of knowledge learned from similar environments that they can easily apply to such tasks in an unfamiliar environment, including the facts that cushions generally inhabit couches, that couches inhabit lounge rooms, and that lounge rooms are often connected to the rest of a building through hallways. Children are also able to interpret natural language instructions and associate them with the visual world. However, the fact that robots currently lack these capabilities dramatically limits their domain of application. \begin{table*}[!t] \centering \resizebox{\linewidth}{!}{ \begin{tabular}{l} \toprule 1. Fold the towel in the bathroom with the fishing theme. \\ 2. Enter the bedroom with the letter E over the bed and turn the light switch off. \\ 3. Go to the blue family room and bring the framed picture of a person on a horse at the top left corner above the TV. \\ 4. Push in the bar chair, in the kitchen, by the oven. \\ 5. Windex the mirror above the sink, in the bedroom with the large, stone fireplace. \\ 6. Could you please dust the light above the toilet in the bathroom that is near the entry way? \\ 7. At the top of the stairs, the first set of potted flowers in front of the stairs need to be dusted off. \\ 8. To the right at the end of the hall, where the large blue table foot stool is, there is a mirror that needs to be wiped. \\ 9. Go to the hallway area where there are three pictures side by side and get me the one on the right. \\ 10. There is a bottle in the office alcove next to the piano. It is on the shelf above the sink on the extreme right. Please bring it here. \\ \bottomrule \end{tabular}}% \vspace{2mm} \caption{Indicative instruction examples from the REVERIE\xspace dataset illustrating various interesting linguistic phenomena such as dangling modifiers (\eg 1), spatial relations (\eg 3), imperatives (\eg 9), co-references (\eg 10), \etc. Note that the agent in our task is required to identify the referent object, but is not required to complete any manipulation tasks (such as folding the towel).} \vspace{-3mm} \label{tab:challengeInstr}% \end{table*}% Therefore, to equip robots with such abilities and to advance real-world vision-and-language research, we introduce a new problem, which we refer to as \emph{Remote Embodied Visual referring Expression in Real Indoor Environments} --- \emph{REVERIE\xspace}. An example of the REVERIE\xspace task is illustrated in Fig.~\ref{fig:title}. A robot spawns at a starting location and is given a natural language instruction that refers to a remote target object at another location within the same building. To carry out the task, the agent is required to navigate closer to the object and return a bounding box encompassing the target object specified by the instruction. It demands the robot to infer the probable location of the object using knowledge of the environments, and explicitly identify the object according to the language instruction. In distinction to other embodied tasks such as Vision-and-Language Navigation (VLN)~\cite{r2r} and Embodied Question Answering (EQA)~\cite{eqa}, REVEVIE evaluates the success based on explicit object grounding rather than the point navigation in VLN or the question answering in EQA. This more clearly reflects the necessity of robots' capability of natural language understanding, visual navigation, and object grounding. More importantly, the concise instructions in REVERIE represent more practical tasks that humans would ask a robot to perform (see Tab.~\ref{tab:challengeInstr}). Those high-level instructions are fundamentally different from the fine-grained visuomotor instructions in VLN, and would empower high-level reasoning and real-world applications. Moreover, compared to the task of Referring Expression (RefExp) \cite{referitgame,mao2016generation} that selects the desired object from a single image, REVERIE is far more challenging in the sense that the target object is not visible in the initial view and needs to be discovered by actively navigating in the environment. Hence, in REVERIE, there are at least an order of magnitude more object candidates to choose from than RefExp. We build the REVERIE dataset upon the Matterport3D Simulator~\cite{r2r,mp3d}, which provides panoramas of all the navigable locations and the connectivity graph in a building. To provide object-level information of the environments, we have extended the simulator to incorporate object annotations, including labels and bounding boxes from Chang~\etal~\cite{mp3d}. The extended simulator can project bounding boxes onto images of different viewpoints and angles, thus able to accommodate evaluation on every possible location. The REVERIE\xspace dataset comprises 10,567 panoramas within 90 buildings containing 4,140 target objects, and 21,702 crowd-sourced instructions with an average length of 18 words. Tab.~\ref{tab:challengeInstr} demonstrates sample instructions from the dataset, which illustrate various linguistic phenomena, including spatial relations, multiple long and dangling modifiers, and coreferences, etc. We investigate the difficulty of the REVERIE\xspace{} task by directly combining state-of-the-art (SoTA) navigation methods and referring expression methods, and none of them shows promising results. We then propose an Interactive Navigator-Pointer model serving as a strong baseline for the REVERIE\xspace{} task. We also provide the human performance of the REVERIE task on the test set to quantify the machine-human gap. In summary, our main contributions are: \begin{enumerate} \item A new embodied vision-and-language problem, Remote Embodied Visual referring Expressions in Real 3D Indoor Environments (REVERIE), where given a natural language instruction that represents a practical task to perform, an agent must navigate and identify a remote object in real indoor environments. \item The first benchmark dataset for the REVERIE task, which contains large-scale human-annotated instructions and extends the Matterport3D Simulator \cite{r2r} with additional object annotations. \item A novel interactive navigator-pointer model that provides strong baselines for the REVERIE\xspace{} dataset under several evaluation metrics. \end{enumerate} \section{The Interactive Navigator-Pointer Model} \label{sec:ourModel} As our REVERIE\xspace{} task requires an agent to navigate to the goal location and point out the target object, a naive solution is to employ state-of-the-art navigation (as a navigator) and referring expression comprehension (as a pointer) methods jointly. However, it is of great importance how the navigator and pointer should work together. Ideally, we want the navigator and pointer to benefit each other. Here, we propose a simple yet effective interactive manner that achieves the best performance as a strong baseline. Specifically, our module includes three parts: a \textit{navigator module} that decides the action to take for the next step, a \textit{pointer module} that attempts to localise the target object according to the language guidance, and an \textit{interaction module} that responses for sending the referring expression comprehension information obtained from the pointer to the navigator to guild it to make more accurate action prediction. \vspace{-3pt} \subsection{The Navigator Module} \vspace{-2pt} \label{sec:navigator} The backbone of our navigator module is a `short' version of FAST~\cite{fast}, which uses a sequence-to-sequence LSTM architecture with an attention mechanism and a backtracking mechanism to increase the action accuracy. Specifically, let $\bm{X}\in\mathbb{R}^{L\times512}$ denote instruction features obtained from $\mathcal{X}$ by an LSTM, and $\bm{V'}=[\bm{v'}_{t,1};\dots;\bm{v'}_{t,K}]\in\mathbb{R}^{K\times4736}$ denote updated visual features obtained by our interactive module (Sec.~\ref{sec:interaction}) for panoramic images $\mathcal{V}_t$ at step $t$. FAST-short learns the local logit $l_t$ signal, which is calculated by a visual and textual co-grounding model adopted from~\cite{selfMonitor}. First, grounded text $\hat{\bm{x}}_t =\bm{\alpha}_t^\top\bm{X}$ and grounded visual $\hat{\bm{v}}'_t=\bm{\beta}_t^\top\bm{V'}$ are learned by \begin{align} \bm{\alpha}_t&=\mathrm{softmax}(PE(\bm{X})(\bm{W}_x \bm{h}_{t-1})) \\ \bm{\beta}_t&=\mathrm{softmax}(g(\bm{V'})(\bm{W}_v \bm{h}_{t-1})) \label{equ:2} \end{align} where $\bm{\alpha}_t\in\mathbb{R}^{L\times1}$ is textual attention weight, $\bm{\beta}_t\in\mathbb{R}^{K\times1}$ is visual attention weight, $\bm{W}_x$ and $\bm{W}_v$ are learnable parameters, {$PE(\cdot)$ is the positional encoding~\cite{pe} that captures the relative position between each word within an instruction}, $g(\cdot)$ is a one-layer Multi-Layer Perceptron (MLP), $\bm{h}_{t-1}\in\mathbb{R}^{512\times1}$ is previous encoder context. The new context is updated by an LSTM taking as input the newly grounded text and visual features as well as previous selected action \begin{equation} \label{eq:cellupdate} (\bm{h}_t, \bm{c}_t)=\mathrm{LSTM}([\hat{\bm{x}}_t,\hat{\bm{v}}'_t,\bm{a}_{t-1}],(\bm{h}_{t-1}, \bm{c}_{t-1})). \end{equation} Then the logit $l_t$ can be computed via an inner-product between each candidate's encoded context and instruction by \begin{equation} l_{t,k} = (\bm{W}_a[\bm{h}_t,\hat{\bm{x}}_t])^\top g(\bm{v'}_{t,k}) \label{equ:3} \end{equation} where $\bm{W}_a$ is a learnable parameter matrix. Based on logit $l_t$, FAST-short maintains one candidate queue and one ending queue. All navigable viewpoints (including the current viewpoint) at the current location are pushed into the candidate queue, but only the viewpoint with the largest accumulated logit $\sum_{\tau=0}^t{l_\tau}$ is popped out as the selected next step. Each passed viewpoint is pushed into the ending queue. One episode ends if the current viewpoint is selected or the candidate queue is empty or the maximum step is reached. Finally, the viewpoint with the largest accumulated logits is chosen as the actual stop location. \subsection{The Pointer Module} \label{sec:pointer} { We use MAttNet~\cite{mattnet} as our pointer because of its good generalisation ability. It decomposes an expression into three modular components related to subject appearance, location, and relationship to other objects via the attention mechanism $q^m = \sum_{j=1}^{L}{a_{m,j}e_j},$ where $m\in \{\mathrm{subj, loc, rel}\}$, $e_j$ is the embedding of each word in the expression/instruction $\mathcal{X}$. $a_{m,j}$ is the attention on each word for each module. Then three kinds of matching scores $S(o_i|q^m)$ are computed for each object $o_i$ conditioned on each modular phrase embedding $q^m$. Specifically, $S(o_i|q^{\mathrm{subj}}) = F(\tilde{v}_i^{\mathrm{subj}},q^{\mathrm{subj}})$, $S(o_i|q^{\mathrm{loc}}) = F(\tilde{l}^{\mathrm{loc}}_i,q^{\mathrm{loc}}),$ and $ S(o_i|q^{\mathrm{rel}})=\max_{j\neq i}F(\tilde{v}^{\mathrm{rel}}_{ij},q^{\mathrm{rel}})$, where $F(\cdot)$ is a two-layer MLP, $\tilde{v}_i^{\mathrm{subj}}$ is a `in-box' attended feature for each object using a $14\times 14$ grid. $\tilde{l}_i^{\mathrm{loc}}$ is the location representation of object $o_i$ obtained by a fully-connected layer taking as input the relative position offset and area ratio to its up to five surrounding objects of the same category. $\tilde{v}^{\mathrm{rel}}_{ij}$ is the visual representation of the surrounding object $o_j$ regardless of categories. The final matching score of object $o_i$ and the instruction $\mathcal{X}$ is a weighted sum: \vspace{-5pt} \begin{equation} \vspace{-5pt} S = \sum{S(o_i|q^m)w_m} \vspace{-3pt} \end{equation} where $w_m = \mathrm{softmax}(W_m^L[h_0,h_L]+b_m)$. } \subsection{The Interaction Module} \label{sec:interaction} Intuitively, we want the Navigator and Pointer to interact with each other so that both navigation and referring expression accuracy can be improved. For example, the navigator can use the visual grounding information to decide when and where to stop, and the pointer accuracy can be improved if the navigator can reach the correct target location. To this end, we propose an interaction module that can plug the pointer's output into the navigator. Specifically, we first perform referring expression comprehension using the above pointer module to select the top-3 matching objects in each candidate view. Then we use a trainable bi-direction LSTM to encode the category labels of these selected objects $\mathcal{X}_O=\{\mathrm{Label}_{i\in top3}\}$ \begin{equation} \bm{x}_{t,k}^o = \mathrm{bi\_LSTM}(\mathcal{X}_O) \end{equation} as the textual representation for the $k$-th candidate viewpoint. In addition, the averaged output of ResNet FC7 layer of these object regions is used as the visual representation $\bm{v}^o_{t,k}$. Finally, we update the candidate viewpoint feature by concatenation \begin{equation} \bm{v'}_{t,k}= [\bm{v}_{t,k},\bm{x}_{t,k}^o,\bm{v}^o_{t,k}] \end{equation} which is send to the navigator (see Equ.~\ref{equ:2} and \ref{equ:3}). The pointer in such an interaction serves as hard attention for each candidate viewpoint, which highlights the most target-related objects for the navigator to take into account. \subsection{Loss Functions} \label{sec:loss} Our final loss consists of two parts, the navigation loss $L_{nav}$ and referring expression loss $L_{exp}$. The $L_{nav}$ is a cross-entropy loss for action selection and a mean squared error loss for progress monitor: {\small \begin{equation} L_{nav} = -\lambda_1\sum^{T}_{t=1}{y_{t}^{a}log(l_{t,k})-(1-\lambda_1)\sum^{T}_{t=1}(y_t^{pm}-p_t^{pm})^2} \end{equation}} where $y_t^a$ is the ground truth action at step $t$, $\lambda_1=0.5$ is the weight balancing the two loss, $y_t^{pm}\in[0,1]$ is the normalised distance in units of length from the current viewpoint to the goal, $p_t^{pm}$ is the predicted progress. The referring expression loss $L_{exp}$ is a ranking loss:% {\small \begin{equation} \begin{split} L_{exp} = \sum_{i}[\lambda_2\mathrm{max}(0,\delta+S(o_i|r_j)-S(o_i|r_i))\\ +\lambda_3\mathrm{max}(0,\delta+S(o_k|r_i)-S(o_i|r_i))] \end{split} \end{equation}} where $\lambda_2=1.0$, $\lambda_3=1.0$, $(o_i,r_i)$ is a positive (object, expression) pair, $(o_i,r_j)$ and $(o_k,r_i)$ are negative (object, expression) pairs, $\delta$ is the distance margin between positive and negative pairs. % All of the losses are summarised together: \begin{equation} L=L_{nav}+\lambda_4L_{exp} \end{equation} to train our Interactive Navigator-Pointer model. We set $\lambda_4$ to $1.0$ by default. \section{Related Work} \paragraph{Referring Expression Comprehension.} The referring expression comprehension task requires an agent to localise an object in an image given a natural language expression. Recent work casts this task as looking for the object that can generate its paired expressions~\cite{HuXRFSD16,Luos17,YuPYBB16} or jointly embedding the image and expression for matching estimation~\cite{ChenKN17,HuRADS17,Liu0017,mattnet}. Yu \etal~\cite{YuPYBB16} propose to compute the appearance difference of the same category objects to enhance the visual features for expression generation. Instead of treating each expression as a unit,~\cite{mattnet} learns to decompose an expression into appearance, location, and object relationship three components. Different from referring expression, REVERIE\xspace{} introduces three new challenges: i) The refereed object is not visible in the initial scene and only can be accessed after navigating to a closed location. ii) In contrast to previous referring expression tasks that select the target object from a single image, object candidates in REVERIE\xspace{} come from panoramas of all the possible viewpoints. iii) The objects in referring expression are normally captured from the front view, while in our setting, the visual appearances of objects may vary largely due to different observation angles and viewpoints. \vspace{-10pt} \paragraph{Vision-and-Language Navigation.} Vision-and-language navigation (VLN) is the task where an agent is to navigate to a goal location in a 3D simulator given detailed natural language instructions such as ``Turn right and go through the kitchen. Walk past the couches on the right and into the hallway on the left. Go straight until you get to a room that is to the left of the pictures of children on the wall. Turn left and go into the bathroom. Wait near the sink."~\cite{r2r}. A range of VLN methods~\cite{vlnNips,fast,regret,selfMonitor,cross,vlnEccv} have been proposed to address this VLN task. Although the proposed REVERIE\xspace{} task also requires an agent to navigate to a goal location, it differs from existing VLN tasks in two important aspects: i) {The challenge is much more closely related to the overarching objective of enabling natural language robot tasking } because the goal is to localise a target object specified in an instruction, not just a location. This removes the artificial constraint that the instruction is restricted to solely to navigation, and reflects the reality of the fact that most objects can be seen from multiple viewpoints. ii) Our collected navigation instructions are semantic-level commands which better reflect the way humans communicate. They are thus closer to `the cold tap in the first bedroom on level two' rather than step by step navigation instructions such as `go to the top of the stairs then turn left and walk along the hallway and stop at the first bedroom on your right'. The most closely related challenge to that proposed here is that addressed in \cite{nguyen2019help,nguyen2019vision,vdn} whereby an agent must identify an object by requesting and interpreting natural language assistance. The instructions are of the form `Find a mug', and the assumption is that there is an oracle following the agent around the environment willing to provide natural language assistance. The question is then whether the agent can effectively exploit the assistance provided by the omniscient oracle. REVERIE\xspace{}, in contrast, evaluates whether the agent can carry out a natural-language instruction alone. Another closely related work is TOUCHDOWN \cite{chen2019touchdown}, that requires an agent to find a location in an urban outdoor environment on the basis of detailed navigation instructions. \vspace{-8pt} \paragraph{Embodied Question Answering.} Embodied question answering (EQA)~\cite{eqa} requires an agent to answer a question about an object or a room in a synthetic environment. Gordon \etal~\cite{iqa} introduce an interactive version of the EQA task, where the agent may need to interact with the environment/objects to correctly answer questions. Our REVERIE\xspace{} task differs from previous works that only output a simple answer or a series of actions, as we ask the agent to output a bounding box around a target object. This is a more challenging but realistic setting because if we want a robot to carry out a task that relates to an object, we need its precise location. Tab.~\ref{tab:datacmp} displays the difference between our task and other related embodied vision-language tasks. \section{Acknowledgments} We thank Sam Bahrami and Phil Roberts for their great help in the building of the REVERIE dataset. {\small \bibliographystyle{ieee_fullname} \section{The REVERIE\xspace{} Dataset} We now describe the REVERIE\xspace{} task and dataset, including the task definition, evaluation metrics, simulator, data collection policy, and analysis of the collected instructions. \subsection{The REVERIE\xspace{} Task} As shown in Fig. \ref{fig:title}, our REVERIE\xspace{} task requires an intelligent agent to correctly localise a remote target object (can not be observed at starting location) specified by a concise high-level natural language instruction (see samples in Tab.~\ref{tab:challengeInstr}). It is worth noting that our instructions are much closer to practical scenarios in daily life than the detailed instructions in VLN~\cite{r2r}, because the latter ones are so complex and long that are unrealistic for human to command robots. Since the target object is in a different room from the starting one, the agent needs first to navigate to the goal location. {Formally, at the beginning of each episode, the agent is given as input a high-level natural language instruction $\mathcal{X}=\langle w_1,w_2,\cdots,w_L\rangle$, where $L$ is the length of the instruction and $w_i$ is a single word token. Following the common practice in VLN, the agent has access to surrounding panoramic images $\mathcal{V}_0=\{v_{0,k}, k\in1,\dots,36\}$ and navigable viewpoints at the current location, where $v_{0,k}$ is determined by the agent's states comprising a tuple of 3D position, heading and elevation $\tuple{s}_{0,k}=\langle p_0,\phi_{0,k},\theta_{0,k}\rangle$ (3 elevation and 12 heading angles are used). Then the agent needs to make a sequence of actions $\langle a_0,\cdots,a_T\rangle$ to reach the goal location, where each action is choosing one of the navigable viewpoints or choosing the current viewpoint which means to stop. The action can also be a `detecting' action that outputs the target object bounding-box refereed by the instruction. It is worth noting that the agent can attempt to localise the target at any step, which is totally up to algorithm design. But we only allow the agent output once in each episode, which means the agent only can guess the answer once in a single run. If the agent `thinks' it has localised the target object and decides to output it, it is required to output a bounding box or choose from several candidates provided by the simulator. A bounding box is denoted as $\langle b_x,b_y,b_w,b_h\rangle$, where $b_x$ and $b_y$ are the coordinate of the left-top point, $b_w$ and $b_h$ denote the width and height of the bounding box, respectively. The episode ends after the agent outputs the target bounding box.} \subsection{Evaluation Metrics} \label{sec:evmetrics} The performance of a model is mainly measured by REVERIE\xspace{} success rate, which is the number of successful tasks over the total number of tasks. A task is considered successful if it selects the correct bounding box of the target object from a set of candidates (or the IoU between the predicted bounding box and the ground-truth bounding box $\geq 0.5$, when candidate objects bounding boxes are not given). Because the target object can be observed at different viewpoints or camera views, we treat it as a success as long as the agent can identify the target within 3 meters, regardless of from different viewpoints or views. We also measure the navigation performance with four kinds of metrics, including success rate, oracle success rate, success rate weighted by path length (SPL), and path length (in meters)~\cite{r2r}. Please note that in our task, a navigation is considered successful only when the agent stops at a location within 3 meters from the target object. More details of evaluation metrics can be found in supplementary materials. \subsection{The REVERIE\xspace{} Simulator} Our simulator is based on the Matterport3D Simulator~\cite{r2r}, a large-scale interactive environment constructed from the Matterport3D dataset~\cite{mp3d}. In the simulator, an embodied agent is able to virtually `move' throughout each building by iteratively selecting adjacent nodes from the graph of panoramic viewpoints and adjusting the camera pose at each viewpoint. At each viewpoint, it returns a rendered colour image that captures the current view, as shown in Fig.~\ref{fig:title}. \label{sec:addbbox} \begin{figure}[t] \begin{center} \includegraphics[width=1\linewidth]{annotation.pdf} \end{center} \vspace{-5pt} \caption{Object bounding boxes (BBox) in our simulator. The BBox size and aspect ratio of the same object may change after the agent moves to another viewpoint or changes its camera view. } \label{fig:cmp2R2R} \vspace{-12pt} \end{figure} \vspace{-10pt} \paragraph{Adding Object-level Annotations.} Object bounding boxes are needed in our proposed task, which are either provided as object hypotheses or used to assess the agent's ability to localise the object that is referred to by a natural expression. The main challenge of adding the object bounding boxes into the simulator is that we need to handle the changes in visibility and coordinate of 2D bounding boxes as the camera moves or rotates. To address these issues, we calculate the overlap between bounding boxes and object depth in each view. If a bounding box is fully covered by another one and it has a larger depth, we treat it as an occluded case. Specifically, for each building the Matterport3D dataset provides all the objects appearing in it with centre point position $\overrightarrowa{c}=\langle c_x,c_y,c_z\rangle$, three axis directions $\overrightarrowa{d}_i=\langle d_i^x,d_i^y,d_i^z\rangle, i\in \{1,2,3\}$, and three radii $r_i$, one for each axis direction. To correctly render objects in the web simulator, we first calculate the eight vertexes using $\overrightarrowa{c},\overrightarrowa{d}_i$ and $r_i$. Then these vertexes are projected into the camera space by the camera pose provided by Matterport3D dataset. % Both C++ and web simulators will be released with the code. Fig. \ref{fig:cmp2R2R} presents an example of projected bounding boxes. % Note that the target object may be observed at multiple viewpoints in one room, but we expect a robot can reach the target in a short distance. Thus, we only preserve objects within three meters to a viewpoint. For each object, {a class label and a bounding box are} associated. But it is worth noting that we adjust the size and aspect-ratio accordingly as the viewpoint and camera angle change. In total, we obtain 20k object annotations. \subsection{Data Collection} Our goal is to collect high-level human daily commands that may be assigned to a home robot in future, such as `Open the left window in the kitchen' or `Go to my bedroom and bring me a pillow'. We develop an interactive 3D WebGL simulator to collect such instructions on Amazon Mechanical Turk (AMT). The web simulator first shows a path animation and then randomly highlights one object at the goal location for workers to provide instructions to find or operate with. There is no style limitation of the command as long as it can lead the robot to the target object. Assistant room and object information are provided to workers facilitating them to provide unambiguous instructions if there are similar rooms or objects. The workers can look around at the goal location to learn the environment. For each target object, we collect three referring expressions. The full collection interface (see in supplementary) is the result of several rounds of experimentation. Over {1,000 workers} took part in the data collection, totally contributing around {2,648 hours} of annotation time. Examples of the collected data can be found in Tab.~\ref{tab:challengeInstr}, and more are in supplementary. \begin{figure}[t] \centering \resizebox{1.04\linewidth}{!}{ \begin{tabular}{cc} \hspace{-10pt} \includegraphics[width=0.5\linewidth]{instruLenDist.pdf}& \hspace{-10pt}\includegraphics[width=0.5\linewidth]{mentionedobjs.pdf} \end{tabular}} \caption{The distribution of the number of words (left) and objects (right) in each instruction.} \vspace{-2mm} \label{fig:distri} \end{figure} \subsection{Dataset Analysis} The REVERIE\xspace{} dataset contains totally 21,702 instructions and a vocabulary of over 1,600 words. The average length of collected instructions is 18 words involving both navigation and referring expression information. Considering the detailed navigation instructions provided in the R2R~\cite{r2r} with an average length of 29 words and the previous largest dataset RefCOCOg \cite{YuPYBB16} contains an average of 8 words, our instructions command is much more concise and natural, and thus more challenging. Fig. \ref{fig:distri} (left) displays the length distribution of the collected instructions, which shows that most instructions have $10\sim 22$ words while the shortest annotation could be only 3 words, such as `Flush the toilet'. Fig.~\ref{fig:wcInstr} (left) presents the relative amount of words used in instructions in the form of word cloud. It shows that people prefer `go' for navigation, and most instructions involve `bathroom'. We also compute the number of mentioned objects in instructions and its distribution is presented in Fig.~\ref{fig:distri} (right). It shows that $56\%$ instructions mention 3 or more objects, $28\%$ instructions mention 2 objects, and the remaining $15\%$ instructions mention 1 object. On average, there are 7 objects with 50 bounding boxes at each target viewpoint. There are 4,140 target objects in the dataset, falling into 489 categories, which are 6 times more than the 80 categories in ReferCOCO \cite{YuPYBB16}, a most popular referring expression dataset at present. Fig.~\ref{fig:wcInstr} (right) shows the relative amount of target objects in different categories. \begin{figure}[t] \centering \resizebox{1.04\linewidth}{!}{ \begin{tabular}{cc} \hspace{-10pt} \includegraphics[width=0.5\linewidth]{allword.jpg}& \hspace{-10pt}\includegraphics[width=0.5\linewidth]{targetObjs.jpg} \end{tabular}} \caption{Word cloud of instructions (left) and target objects (right) in the REVERIE\xspace{} dataset. The bigger the font, the more percentage it occupies.} \vspace{-10pt} \label{fig:wcInstr} \end{figure} \vspace{-15pt} \paragraph{Data Splits} We follow the same train/val/test split strategy as the R2R~\cite{r2r} datasets. The training set consists of 59 scenes and 10,466 instructions over 2,353 objects. The validation set including seen and unseen splits totally contains 63 scenes, 953 objects, and 4,944 instructions, of which 10 scenes and 3,573 instructions over 525 objects are reserved for val unseen split. For the test set, we collect 6,292 instructions involving 834 objects randomly scattered in 16 scenes. All the test data are unseen during training and validation procedures. The ground truth for the test set will not be released, and we will host an evaluation server where agent trajectories and detected bounding boxes can be uploaded for scoring. \section{Evaluation Metrics} \begin{itemize} \item Navigation Success: a navigation is considered successful only if the target object can be observed at the stop viewpoint. Please note that to encourage the agent to approach closer to the target object, we set the objects visible if they are within 3 meters away from the current location. \item Navigation Oracle Success: a navigation is considered oracle successful if the target object can be observed at one of its passed viewpoints. \item Navigation SPL: it is the navigation success weighted by the length of navigation path, which is \begin{equation} \frac{1}{N}\sum_{i=1}^{N}{S_i\frac{\ell_i}{\max(\ell_i,p_i)}} \end{equation} where $N$ is the number of tasks, $S_i\in\{0,1\}$ is a binary indicator of success of task $i$, $\ell_i$ is the shortest length between the starting viewpoint and the goal viewpoint of task $i$, and $p_i$ is the path length of an agent for task $i$. \item Navigation Length: trajectory length in meters. \item REVERIE Success: a task is considered REVERIE successful if the output bounding box has an IoU (intersection over union) $\geq0.5$ with the ground truth. % \end{itemize} \section{Typical Samples of The REVERIE\xspace{} Task} In Figure~\ref{fig:samples}, we present several typical samples of the proposed REVERIE\xspace{} task. It shows the diversity in object category, goal region, path instruction, and target object referring expression. \section{Data Collecting Tools} To collect data for the REVERIE\xspace{} task, we develop a WebGL based data collecting tool as shown in Figure~\ref{fig:instruction} and Figure~\ref{fig:submit}. To facilitate the workers, we provide real-time updated reference information in the web page according to the location of the agent, including the current level/total level, the current region, and the number of regions in the build having the same function. At the goal location, in addition to highlighting the target object with a red 3D rectangle, we also provide the label of the target object and the number of objects falling in the same category with the target object. Text and video instructions are provided for workers to understand how to make high quality annotations as shown in Figure~\ref{fig:instruction}. \section{Human Performance Test} To obtain the machine-human performance gap, we develop a WebGL based tool as shown in Figure~\ref{fig:eval} to test human performance. In the tool, we show an instruction about a remote object to the worker. Then the worker needs to navigate to the goal location and select one object as the target object from a range of object candidates. The worker can look around and go forward/backword by dragging or clicking. \section{Visualisation of REVERIE Results} In Figure~\ref{fig:vis}, we provide the visualisation of several REVERIE results obtained by the typical state-of-the-art method, FAST-short, and the typical baseline method, R2R-SF. \begin{figure*}[!htbp] \centering \includegraphics[width=0.8\linewidth]{instruction_example.pdf} \caption{Several typical samples of the collected dataset, which involves various object category, goal region, path instruction, and object referring expression.} \label{fig:samples} \end{figure*} \begin{figure*}[!b] \centering \includegraphics[width=\linewidth]{instruction.pdf}\\ \caption{Data collecting interface part I: instructions for AMT workers. } \label{fig:instruction} \end{figure*} \begin{figure*}[t] \centering \includegraphics[width=\linewidth]{submit.pdf}\\ \caption{Data collecting interface Part II: assistant information and user input field.} \label{fig:submit} \end{figure*} \begin{figure*}[t] \centering \includegraphics[width=\linewidth]{eval.pdf}\\ \caption{Human test interface. Workers need first to navigate to the goal location by clicking or dragging mouse, and then identify the target object. Only objects within 3 meters from the current location are highlighted. Different colors are used to facilitate workers to distinguish one object from others.} \label{fig:eval} \end{figure*} \begin{figure*}[!htbp] \centering \includegraphics[width=0.83\linewidth]{visualization.pdf} \caption{Visualisation of several REVERIE results, including trajectories and referring expression grounding of three typical methods. Colorized dots denote reachable locations, and different colors mark locations belonging to different regions according to the Matterport dataset.} \label{fig:vis} \end{figure*} \end{document}
{'timestamp': '2020-01-07T02:15:22', 'yymm': '1904', 'arxiv_id': '1904.10151', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.10151'}
arxiv
\section{Introduction} In order to further advance eye tracking research and push forward the use of eye trackers in industry, the identification of eye movements is highly desired. To date there are six primary types of eye movements exhibited by the human oculo-motor system (HOS): fixations, saccades, smooth pursuits (SPs), optokinetic reflex, vestibulo-ocular reflex, as well as vergence \cite{leigh2015neurology}. Of these, fixations, saccades, and SPs are the most frequently studied. Intuitively, fixations are what one experiences when staring at a stationary object. Due to such, it can be easily classified using an overall relative velocity of zero degrees per second, or alternatively using a net zero movement over a period of time. As noise is likely to be present in most eye movement samples, algorithms that employ single threshold classification, especially if the assumption is made that fixations will have zero velocity, may require adjustment on a sample by sample basis. Saccades are where one quickly moves their eyes from one object to another, commonly exhibiting speeds in excess of 300 degrees per second \cite{dodge1901angle}. Thus, classifying saccades based off of a high overall velocity between points can be an effective method. SPs are a function of the HOS that can be described as when ones eyes attempt to maintain high acuity on a moving object \cite{duchowskit, poole2005lj}. Occasionally one would get distracted or lose focus of the object, in which case a catch up saccade may be exhibited to regain focus. As SPs have variability in their speed, identifying them while also in the presence of fixations can be difficult. This is especially pertinent when noise is present in the data. As fixations are exhibited when someone is focused on an object, they are frequently used in human-computer interaction applications as a selection method \cite{istance2010designing}. Additionally researchers have found abnormalities in saccade and SPs that have led to the diagnosis of some pathologies of the HOS \cite{isotalo2009oculomotor}. Thus the continued development of methods for the classification of these eye movement types is still thought to be an important area of research. I-VT and I-DT are foundational threshold algorithms used to separate fixations from saccades. I-VT uses a velocity threshold that takes advantage of the large distinction in velocity between the fast moving saccade and the relatively stationary fixation \cite{Salvucci2000}. I-DT uses two thresholds to make the distinction: duration and dispersion. The duration threshold can be dependent on the users and the stimulus. However, the threshold is commonly used with a minimum limit due to the HOS's inability to pick up information in less than 100 ms \cite{widdel1984operational}. Dispersion is the sensitivity of the algorithm in regards to an eye movement's position graphically. It acts as a noise filter by allowing any points within the window to be considered a fixation. I-DT places a window the size of the duration threshold over a series of eye movement points. In the case of a saccade, the points would break the dispersion threshold over that window and be classified as such. Under ideal conditions, the dispersion threshold for a fixation would be zero. However, as noise is inherent in eye movement classification, assuming the threshold is zero can lead to poor results. Classifying saccades from fixations is effective when using approaches that search for single features such as I-VT and I-DT. However, classifying the two from smooth pursuits is not possible using these methods alone. Two algorithms, I-VVT and I-VDT \cite{Komogortsev2013}, build off of the previous foundational algorithms and incorporate an additional threshold to make this classification. Both I-VVT and I-VDT use an initial velocity threshold to classify between saccades and both fixations and SPs. The remaining points are then classified either using another velocity threshold in I-VVT or using a dispersion threshold as in I-VDT. Threshold algorithms have the ability to provide promising results. However, the thresholds used in the algorithms tend to vary based on the input data. In some cases eye trackers provide substantially more noise than others, in which case dispersion and velocity thresholds should be updated accordingly. Thresholds aren't the only method in eye movement classification, however. Other methods previously used in the field include classification using the main-sequence relationship, amplitude-duration relationship, saccades' wave form \cite{leigh2015neurology}, or statistical probabilities \cite{Santini2016}. Hidden Markov Models (HMM) are statistical models that attempt to discover hidden states. The forward algorithm, also known as the Viterbi algorithm \cite{forney1973viterbi}, is used to determine the most likely sequence of hidden or unobserved states. This is done by calculating three probabilities: the observational probability of each of \textit{n} states, the transitional probabilities between each state, and the probability at each time step that any of the previous states will lead to the current state. At the beginning of the algorithm two matrices are created: a traceback matrix and an emission matrix. The emission matrix is populated at each step by determining the maximum probability given some transition. The traceback matrix is populated by determining which of the \textit{n} state probabilities is higher at a given time step. Following the completion of the algorithm, an iterator will travel from the last column index in the traceback matrix, starting in the row with the highest probability, and go backward through the traceback matrix using the value of that cell. Effectively, the Viterbi algorithm works by choosing the series of classifications which has the highest probability \cite{forney1973viterbi}. An approach to automatically classify binary eye movements using a HMM has been noted \cite{Salvucci2000} and has been appropriately named I-HMM. Behavioral scores provide an automated method of creating meaningful classifications when using a step-ramp stimulus \cite{komogortsev2010standardization}. The scores are created under the assumption that the saccade and fixation stimulus are encoded to follow a normal HOS's behavior. It follows that the selected thresholds will hold the same performance when given different stimulus. As the equipment is unlikely to change following the calibration procedure, behavioral scores allow the automated selection of thresholds for classification immediately after calibration. As eye tracking is a quickly growing field, meaningful improvements in the classification of eye movements continues to be a sought after goal. In this paper we propose a new hybrid algorithm, I-VDT-HMM, which builds off of the previous work of I-VDT \cite{Komogortsev2013} and I-HMM \cite{Salvucci2000} in an attempt to take the advantages of a threshold algorithm while statistically enhancing our results using the Viterbi algorithm \cite{forney1973viterbi}. To determine the benefits of our algorithm in a variety of conditions, we subsampled the high quality eye tracking data into 8 subsample frequencies and tested it across 8 subjects. Our results are compared against the state of the art I-BDT algorithm \cite{Santini2016}, and the I-VDT algorithm \cite{Komogortsev2013}. Our \textit{MATLAB} implementation of I-VDT-HMM can be found on GitHub at \href{https://github.com/BerndtSam/I-VDT-HMM}{https://github.com/BerndtSam/I-VDT-HMM}. \section{Related Work and Evaluated Algorithms} \subsection{I-VDT} I-VDT is a seminal algorithm in tertiary eye movement classification \cite{Komogortsev2013}. The algorithm is a combination of the I-VT and I-DT algorithms, using a velocity threshold to identify saccades, while a moving dispersion window is used to separate fixations and smooth pursuits. I-VDT is noted for fast evaluation time, accurate classification, as well as ease of implementation \cite{Komogortsev2013}. \subsection{I-BDT} Bayesian Decision Theory Identification, I-BDT, is a probability based algorithm designed for low resolution eye trackers proposed in \cite{Santini2016}. I-BDT requires no calibration as it is based entirely on eye positional data and so is operational at run time. I-BDT uses a bayesian decision theory approach where it relies on a prior and likelihoods to calculate the posterior probability of a classification using velocity and a movement ratio over a temporal window as classification features. I-BDT uses the assumption that the velocity and movement ratio of a fixation must be zero, which will be discussed later. A more robust description of the algorithm can be found in \cite{Santini2016}. \subsection{I-VDT-HMM} I-VDT-HMM is an offline hybrid algorithm proposed in this work. It is derived from I-VDT \cite{Komogortsev2013} in that it uses a velocity threshold to separate out saccades, and a dispersion window to separate fixations from smooth pursuits. In order to statistically ensure the resulting scores, two two-state Viterbi algorithms are employed; once after I-VT and the other after I-DT. The first HMM, like I-VT, is used to separate saccades from a combination of both fixations and smooth pursuits. In this HMM iteration, the velocity of each state is used as the feature classifier. This works well as both fixations and SPs have relatively the same velocity when compared in a noisy environment, and saccades tend to be much faster than the two. The second HMM is ran after the dispersion window separates fixations from smooth pursuits. This HMM once again has two states; one for fixations and the other for smooth pursuits. In this HMM iteration, similar to I-DT, the dispersion of each class is employed as the feature inputs to our classifier. Thus rather than using the velocity to make classifications, we create a dispersion window for each previously classified fixation and smooth pursuit eye record and then take the difference, the dispersion, between the maximum and minimum. We then take the average and standard deviation of the dispersion as our feature inputs to the PDF function. Upon completion of each HMM, we determine whether a set of epsilon values, the difference between each iteration of a set of variables, has been met. If the change in values are less than the epsilon value, ensuring that the algorithm has converged, it then proceeds onto the next step. As I-VDT-HMM employs the Viterbi algorithm \cite{forney1973viterbi} which requires the iteration over all states, the algorithm is an off-line classification algorithm. The pseudocode for I-VDT-HMM can be found in Algorithms \ref{alg:I-VDT-HMM}, and \ref{alg:viterbi}. HMMs use three probabilities to determine hidden states, the observed probability, transitional probabilities between states, and the probability that any of the previous states will lead to the current state: the emission probability. The transitional probability is calculated using the sum of the transitions from one particular state to another over the total number of eye records. The calculation for transitional probabilities can be found in Equation \ref{eq:transition}, where \textit{s} is the current state, \textit{p} is the previous state, \textit{n} is the number of eye records, \textit{i} is the index of the iterator iterating the eye records, \textit{$p_0$} is the "from" portion of the transition we're calculating and \textit{$s_0$} is the "to" portion. To calculate the observational probabilities, the probability density function (PDF) using the means and standard deviations of the respective classes are used where the results are then normalized. The equation for the PDF can be found in Equation \ref{eq:pdf} where \textit{$\sigma^2$} is the standard deviation, \textit{$\mu$} is the mean, and \textit{$x$} is the current observation. The emission probability for each state is calculated using the product of the previous emission probabilities, the transitional probabilities given the current and previous states, and the observational probability given the current state. The calculation for the emission probability can be found in Equation \ref{eq:emission}, where \textit{s} is the current state, \textit{p} is the previous state, and \textit{i} is the current state's index. \begin{equation} P_{transition, s, p, s_0, p_0} = \frac{1}{n}\sum_{i=1}^{n} X; \\ X = \begin{cases} 1, & \text{if $p \Rightarrow s \cap p=p_0 \cap s=s_0$} \\ 0, & \text{otherwise} \end{cases} \label{eq:transition} \end{equation} \begin{equation} P_{observation} = \frac{1}{\sqrt[]{2\pi\sigma^2}}e^\frac{-(x-\mu)^2}{2\sigma^2} \label{eq:pdf} \end{equation} \begin{equation} P_{emission,s,p} = P_{emission,p,i-1} * P_{transition,p,s} * P_{observation,s} \label{eq:emission} \end{equation} When calculating the probability of a fixation given a saccade input, the PDF function used to calculate the observation probability would occasionally return zero due to rounding errors. Being that the Viterbi algorithm builds its probabilities off of the previous probability, and that any number multiplied by zero returns zero, this can lead to poor results. Under this circumstance we reset the probability to an arbitrary lower bound of one ten-thousandth of the other state. In an instance that both probabilities equaled zero, a flag was set for the reset of both probabilities to an initial state. In a similar case, the PDF function would return a very small probability. After several iterations this would lead to a cascading effect where one classification would much outweigh the other using the same multiplicative probability property described above. In the instance the lower bound on probabilities has been exceeded, a flag was set to multiply both numbers by the log base 10 of the maximal probability, thus maintaining the probabilistic ratio between either state. \begin{algorithm} \SetAlgoLined \SetKwInOut{Input}{Input}\SetKwInOut{Output}{Output} \Input{array of eye position points, velocity threshold - $V_t$, dispersion threshold - $D_t$, minimum temporal window size - $W_t$} \Output{list of fixations, saccades, and smooth pursuits} Calculate velocities for each point\; Mark all points above $V_t$ as saccades\; Viterbi Algorithm(array of eye positions, [fixations, saccades], velocity, $V_t$)\; Filter saccades\; Initialize temporal window of size $W_t$ over remaining eye movements\; \While{temporal window not reaching end of array} { Calculate dispersion of points in window\; \eIf{dispersion < $D_t$} { \While{dispersion < $D_t$} { Mark point as fixation\; Add unclassified point to window\; Calculate dispersion of points in window\; } }{ Mark first point as smooth pursuit\; Move window to next point\;} } Viterbi Algorithm(array of eye positions, [fixations, smooth pursuits], dispersion, [$D_t$, $W_t$])\; Merge saccades back into eye position data\; Return list of classifications\; \caption{I-VDT-HMM} \label{alg:I-VDT-HMM} \end{algorithm} \begin{algorithm} \SetAlgoLined \SetKwInOut{Input}{Input}\SetKwInOut{Output}{Output} \Input{array of eye position points, classes, feature, thresholds} \Output{list of classified classes} Calculate mean of feature for classes\; Calculate standard deviation of feature for classes\; Count transitions between each state\; \While{not converged}{ Initialize emission and classification matrices\; Calculate observation probabilities\; Insert observation probabilities into first column of emission matrix\; \For{column in emission matrix > 1}{ Calculate observation probabilities\; \If{observation probability == 0}{ Set observation probability to lower bound\; } Calculate transitional probabilities\; Set classification matrix state to highest probability\; \If{emission probability < lower bound}{ Normalize probabilities\;} } Calculate maximum final probability\; \For{last record to first record} { Set previous records highest probability as classification for current record\; } Calculate means and standard deviations of features\; Count state transitions\; \If{Previous iterations epsilon values are met}{ converged\; } } \caption{Viterbi Algorithm} \label{alg:viterbi} \end{algorithm} \section{Methodology} \subsection{Data} The data used in our experiments was recorded using an EyeLink 1000 eyetracker recorded at 1000 Hz \cite{EyeLink1000} on a 21-in CRT monitor with a refresh rate of 80 Hz and a resolution of 1,024 by 768 pixels. The data consists of 11 subjects whom were recorded in monocular mode and produced various amounts of noise. The stimulus presented to the subjects was a 2-D step-ramp stimulus where the recorded data was converted into degrees of visual angle. The subject's eye records were classified into clean and noisy data, and given a ground truth label. This data was originally recorded, classified, and published in \cite{Komogortsev2013}, where you can find additional information. \subsubsection{Data Subsampling} As a high quality eye tracker is not always available, the data was subsampled into 7 different sampling frequencies: 30, 50, 60, 100, 200, 300, and 500 Hz. The three algorithms evaluated in this paper are tested on 8 of the 11 subjects at each of the 8 sampling frequencies. 3 of the subjects were dropped due to an issue with our parameter estimation algorithm. Of the data used we will focus primarily on the extremes for analysis of the reported algorithms: low, 30 Hz, and high, 1000 Hz, frequencies for clean, subject 007, and noisy, subject 010, datasets. \subsection{Behavioral Scores} We use the behavioral scores proposed in \cite{komogortsev2010standardization} and \cite{Komogortsev2013} in order to evaluate our algorithm due to their effectiveness in providing meaningful classifications in an automated setting. The behavioral scores provide a better result than direct classification accuracy as they take into account multiple factors found within a healthy individual's HOS which would affect such a classification method. For example, when considering a pursuits quantitative score (PQnS), the latency between seeing the target move and the HOS's response, the pursuit latency, as well as the time it takes for the HOS to catch up to the object are considered. The assumption then is made that the behavior of eye movements is matched with those of a healthy person's HOS. The scores measured in this work are the fixation quantitative score (FQnS), the saccade quantitative score (SQnS), pursuit quantitative score (PQnS), misclassified fixation score (MisFix), fixation qualitative score (PQlS), and the pursuit qualitative scores for positional (PQlS\_P) and velocity (PQlS\_V) accuracy. The ideal scores for each of the behavioral scores can be found in Table \ref{tab:IdealScores}. The FQnS gives the means of computing the amount of fixation points classified correctly as fixations. We use the derivation of the ideal FQnS found in \cite{Komogortsev2013}, which takes into account the effects of SP on fixation classification. Through our calculations we found 81.6 to be the ideal behavioral score which differs slightly from the 83.87 score found in \cite{Komogortsev2013}. The SQnS is defined as the ratio between the detected number of saccades and the total number of saccades in the stimulus \cite{komogortsev2010standardization}. In \cite{Komogortsev2013} the SQnS was modified to account for the detection of SPs in the stimulus using a temporal window over the step stimulus. This method considers anticipatory and corrective saccades. Ideally, the SQnS would be 100 as it would indicate the algorithm was able to successfully identify all saccades within the stimulus window. The intuitive idea behind the PQnS is the ratio of correctly classified SPs over the total amount of SP stimulus. The ideal PQnS takes into account the latency and resulting corrective saccade exhibited by the HOS when given a SP stimulus. The calculation for ideal PQnS, 52.04, may be found in \cite{Komogortsev2013}. The MisFix score is calculated as the amount of fixation points that are classified as a smooth pursuits over the total amount of fixation stimulus \cite{Komogortsev2013}. The ideal score takes into consideration the fact that the termination phase of a SP happens after the SP into the following fixation stimulus. This makes the assumption that each SP is followed by a fixation. The calculation for the ideal score can be found in \cite{Komogortsev2013}, which comes out to 7.1. Intuitively, the FQlS is measured as the euclidean distance between a fixation stimulus and the detected fixation centroid \cite{komogortsev2010standardization}. The score is normalized by the total amount of points compared. The ideal score for FQlS is 0, however, the score is unlikely to be achieved due to inaccuracy of eye trackers and normal behavior of the HOS \cite{komogortsev2010standardization}. The pursuit qualitative scores, PQlS\_P and PQlS\_V, like the FQlS, are used to compare the proximity as well as the velocity of the detected SPs to the corresponding stimulus \cite{Komogortsev2013}. The scores are then normalized over the amount of points compared. Due to calibration errors, corrective saccadic behaviors, HOS latency, and classification errors, the ideal scores of 0 may not be achievable \cite{Komogortsev2013}. \subsection{Parameter estimation} A parameter estimation algorithm was used in order to detect the ideal velocity and dispersion thresholds for the proposed algorithm. Every 5 velocity thresholds between 70 and 150 were used to optimize saccade detection during the initial phase of our algorithm. Testing every 0.1\degree\ between 0.1\degree\ and 2.0\degree's were used to optimize our dispersion threshold for the later part of our algorithm. As the minimum pause time of the eye is 200 ms \cite{salthouse1980determinants}, and that the minimum amount of time for the HOS to pick up any information is 100 ms \cite{widdel1984operational}, the assumption was made that while there is some variability in the HOS, at least 150 ms must pass while fixated in order to detect anything. Thus, a duration threshold of 150 ms was employed. As PQlS\_P and PQlS\_V are generally quite high due to catch up saccadic behavior, a multiplicative weight of 10 was added on to the difference between the classification and the ideal scores for the remaining behavioral scores. \section{Results} \subsection{I-BDT} I-BDT was implemented in our environment on our data using the original code linked in \cite{Santini2016}. The classification results on clean 1000 Hz and 30 Hz data are shown in Figures \ref{fig:IBDT_s007_1000_0} and \ref{fig:IBDT_s007_30_0} respectively. The assumption made in \cite{Santini2016} was that fixations had a velocity of 0, and that the temporal window would be able to correctly discern between smooth pursuits and fixations. As eye trackers and the HOS have inherent noise associated with them, we tested the same 1000 Hz and 30 Hz data on a series of different fixation thresholds. The results are shown in Figures \ref{fig:IBDT_s007_1000_Mult_Fixation} and \ref{fig:IBDT_s007_30_Mult_Fixation} respectively. These results indicated that the fixation mean, $\mu$, may prove to provide better results on an average case as the fixation threshold when considering sample rates. The results of a fixation threshold of $\mu$ is shown on clean 1000 Hz data in Figure \ref{fig:IBDT_s007_1000_Mu}. Using $\mu$ as the fixation threshold, we were able to achieve the following results on clean and noisy data on sampling frequencies 30 Hz, 100 Hz, 500 Hz, and 1000 Hz shown in Figure \ref{fig:IBDT-optimal-results}. \begin{figure}[h] \caption{Original I-BDT Code implemented in our environment and ran on subject s-007 on original 1000 Hz data } \label{fig:IBDT_s007_1000_0} \includegraphics[width=\columnwidth,height=5cm,keepaspectratio]{IBDTClassificationResults/IBDTClassificationResults0/IBDTClassification-s007-1000_0.png} \centering \end{figure} \begin{figure}[h] \caption{Original I-BDT Code Implemented and Ran on Subject s-007 on Sampled 30 Hz Data } \label{fig:IBDT_s007_30_0} \includegraphics[width=\columnwidth,height=5cm,keepaspectratio]{IBDTClassificationResults/IBDTClassificationResults0/IBDTClassification-s007-30_0.png} \centering \end{figure} \begin{figure}[h] \caption{I-BDT Results Using Multiple Fixation Thresholds on 1000 Hz Data} \label{fig:IBDT_s007_1000_Mult_Fixation} \includegraphics[width=\columnwidth]{IBDTFixationThreshold/HighFrequencyCleanFixationThreshold.png} \centering \end{figure} \begin{figure}[h] \caption{I-BDT Results Using Multiple Fixation Thresholds on 30 Hz Data} \label{fig:IBDT_s007_30_Mult_Fixation} \includegraphics[width=\columnwidth]{IBDTFixationThreshold/LowFrequencyCleanFixationThreshold.png} \centering \end{figure} \begin{figure}[h] \caption{I-BDT Results Using $\mu$ as Fixation Threshold on 1000 Hz Data} \label{fig:IBDT_s007_1000_Mu} \includegraphics[width=\columnwidth,height=5cm,keepaspectratio]{IBDTClassificationResults/IBDTClassification-s007-1000_mu.png} \end{figure} \begin{figure}[h] \caption{I-BDT Results Using $\mu$ as Fixation Threshold Shown in Behavioral Scores on Clean and Noisy 30 Hz, 100 Hz, 500 Hz and 1000 Hz Data} \label{fig:IBDT-optimal-results} \includegraphics[width=\columnwidth]{IBDTOptimalResults/I-BDTOptimalThresholdResultsperFrequency.png} \centering \end{figure} \subsection{I-VDT} I-VDT was first proposed using the same environment and data we are using \cite{Komogortsev2013}. One difference is that we have subsampled the data to get an idea of how each algorithm is affected by sampling frequencies. The results of I-VDT on a clean dataset sampled at 1000 Hz is shown in Figure \ref{fig:IVDT-s007-1000}. Using the optimal thresholds detailed in \cite{Komogortsev2013}, we compiled the results on sampling frequencies of 30 Hz, 100 Hz, 500 Hz, and 1000 Hz on both clean and noisy data shown in Figure \ref{fig:IVDT-optimal-results}. \begin{figure}[h] \caption{I-VDT Results on Subject 007 Sampled at 1000 Hz} \label{fig:IVDT-s007-1000} \includegraphics[width=\columnwidth,height=5cm,keepaspectratio]{IVDTClassificationResults/IVDTClassification-s007-1000.png} \centering \end{figure} \begin{figure}[h] \caption{I-VDT Results Using Optimal Thresholds Shown in Behavioral Scores on Clean and Noisy 30 Hz, 100 Hz, 500 Hz and 1000 Hz Data} \label{fig:IVDT-optimal-results} \includegraphics[width=\columnwidth]{IVDTOptimalResults/IVDTOptimalThresholdsPerFrequency.png} \centering \end{figure} \subsection{I-VDT-HMM} The proposed algorithm in this work, I-VDT-HMM, was tested on all of our subjects and frequencies in order to determine its optimal thresholds. The results which are averaged across the subjects are shown in Figure \ref{fig:IVDTHMM-optimal-thresholds}. The optimal thresholds selected for our data are shown in Table \ref{tab:optimalThresholds}. These optimal thresholds give the behavioral scores as shown in Figure \ref{fig:IVDTHMM-optimal-threshold-results} on subjects 007 and 010 across frequencies 30 Hz, 100 Hz, 500 Hz, and 1000 Hz. When using these thresholds on eye record data, we achieve the classification results using clean, subject 007, data on 1000 Hz and 30 Hz sampling frequencies shown in Figures \ref{fig:IVDTHMM-optimal-threshold-classification-results-1000} and \ref{fig:IVDTHMM-optimal-threshold-classification-results-30} respectively. The behavioral scores attributed to these classification results can be found in Table \ref{tab:behavioralScoresIVDTHMM}. \begin{table} \begin{tabular}{ |c|c| } \hline Behavioral Score & Ideal Score \\ \hline FQnS & 81.6\\ SQnS & 100\\ PQnS & 52.04\\ MisFix & 7.1\\ PQlS & 0\\ PQlS\_P & 0\\ PQlS\_V & 0\\ \hline \end{tabular} \centering \caption{Ideal Behavioral Scores} \label{tab:IdealScores} \end{table} \begin{table} \begin{tabular}{ |c|c| } \hline Velocity Threshold & 75 \\ Dispersion Threshold & 0.67 \\ Duration Threshold & 150 \\ \hline \end{tabular} \caption{Optimal Thresholds for I-VDT-HMM} \label{tab:optimalThresholds} \centering \end{table} \begin{table} \begin{tabular}{ |c|c|c| } \hline Behavioral Score & 1000 Hz Result & 30 Hz Result\\ \hline FQnS & 73.91 & 69.41 \\ SQnS & 92.13 & 102.06 \\ PQnS & 48.26 & 12.43\\ MisFix & 10.01 & 3.82\\ FQlS & 0.39 & 0.43\\ PQlS\_P & 3.06 & 6.02\\ PQlS\_V & 29.34 & 86.00\\ \hline \end{tabular} \caption{Behavioral Scores using I-VDT-HMM for Subject 007 on 1000 Hz and 30 Hz Data} \label{tab:behavioralScoresIVDTHMM} \centering \end{table} \begin{figure}[h] \caption{I-VDT-HMM Optimal Thresholds Across Frequencies, Averaged Over Subjects} \label{fig:IVDTHMM-optimal-thresholds} \includegraphics[width=\columnwidth,height=5cm,keepaspectratio]{IVDTHMMOptimalThresholds/ThresholdsByFrequency.png} \centering \end{figure} \begin{figure}[h] \caption{I-VDT-HMM Optimal Threshold Results given in Behavioral Scores on Clean and Noisy 30 Hz, 100 Hz, 500 Hz, and 1000 Hz Data} \label{fig:IVDTHMM-optimal-threshold-results} \includegraphics[width=\columnwidth]{IVDTHMMOptimalThresholds/IVDTHMMOptimalThresholdResultsPerFrequency.png} \centering \end{figure} \begin{figure}[h] \caption{I-VDT-HMM Optimal Threshold Classification Results on Subject 007 at 1000 Hz} \label{fig:IVDTHMM-optimal-threshold-classification-results-1000} \includegraphics[width=\columnwidth,height=5cm,keepaspectratio]{IVDTHMMClassificationResults/IVDTHMM-Classification-s007-1000.png} \centering \end{figure} \begin{figure}[h] \caption{I-VDT-HMM Optimal Threshold Classification Results on Subject 007 at 30 Hz} \label{fig:IVDTHMM-optimal-threshold-classification-results-30} \includegraphics[width=\columnwidth,height=5cm,keepaspectratio]{IVDTHMMClassificationResults/IVDTHMM-Classification-s007-30.png} \centering \end{figure} \subsection{Cross Algorithm Results} Figure \ref{fig:classificationTime} presents the average classification time between algorithms over all tested frequencies and subjects. The X axis represents the frequency the eye records were sampled to, and the Y axis represents the classification time. Figures \ref{fig:algorithms-007-1000} and \ref{fig:algorithms-007-30} compare all algorithms using the clean data set, provided by subject 007, while Figures \ref{fig:algorithms-010-1000} and \ref{fig:algorithms-010-30} compare all algorithms using the noisy data set, provided by subject 010, on sample frequencies 1000 Hz and 30 Hz respectively. \begin{figure}[h] \caption{Comparison of Algorithms Mean Classification Times by Frequency} \centering \label{fig:classificationTime} \includegraphics[width=\columnwidth,height=5cm,keepaspectratio]{AlgorithmComparison/ClassificationSpeedByFreqAndNoise.png} \end{figure} \begin{figure}[h] \caption{Comparison of Algorithms on Subject 007 Data using 1000 Hz Sample Frequency} \label{fig:algorithms-007-1000} \includegraphics[width=\columnwidth]{AlgorithmComparison/AlgorithmComparison-S007-1000.png} \end{figure} \begin{figure}[h] \caption{Comparison of Algorithms on Subject 007 Data using 30 Hz Sample Frequency} \centering \label{fig:algorithms-007-30} \includegraphics[width=\columnwidth]{AlgorithmComparison/AlgorithmComparison-S007-30.png} \end{figure} \begin{figure}[h] \caption{Comparison of Algorithms on Subject 010 Data using 1000 Hz Sample Frequency} \centering \label{fig:algorithms-010-1000} \includegraphics[width=\columnwidth]{AlgorithmComparison/AlgorithmComparison-S010-1000.png} \end{figure} \begin{figure}[h] \caption{Comparison of Algorithms on Subject 010 Data using 30 Hz Sample Frequency} \centering \label{fig:algorithms-010-30} \includegraphics[width=\columnwidth, keepaspectratio]{AlgorithmComparison/AlgorithmComparison-S010-30.png} \end{figure} \section{Discussion} On a clean dataset, as shown in the original paper \cite{Santini2016}, I-BDT was able to achieve outstanding scores averaging 94.98\% classification accuracy. On the basis of Figures \ref{fig:IBDT_s007_1000_0} and \ref{fig:IBDT_s007_30_0}, we can determine that the assumption made about fixation velocities being equal to zero to be poorly made when introduced to a relatively noisy dataset. When determining a more optimal fixation threshold, we tested fixation thresholds 0, $\mu$, and several $\mu$'s plus multiples of the standard deviation to see how the scores would fare. For lower sampling rates, the higher the fixation threshold the better the algorithm did. This is likely a result of how noisy data can affect the velocity of points. For higher sampling rates after averaging the overall thresholds we found that the mean velocity of a fixation proved to be the most reliable. Using the mean velocity for the fixation threshold we were able to produce the classification results for clean 1000 Hz data found in Figure \ref{fig:IBDT_s007_1000_Mu}. Through the algorithm comparison figures, \ref{fig:algorithms-007-1000}, \ref{fig:algorithms-007-30}, \ref{fig:algorithms-010-1000} and \ref{fig:algorithms-010-30}, we can see that I-VDT and I-VDT-HMM are the most closely matched algorithms, with I-VDT-HMM obtaining a closer-to-ideal score roughly half of the time. As expected, in Figure \ref{fig:classificationTime} we can see that I-VDT is substantially faster than I-VDT-HMM. I-VDT-HMM aims to optimize results at the cost of time. Observing Figure \ref{fig:algorithms-010-1000} we can see that the SQnS score is quite low on the high frequency noisy data for I-VDT-HMM. An issue with the Viterbi Algorithm \cite {forney1973viterbi} convergence method is that when introduced to data that has too much noise, the noise will greatly affect the mean velocity of each of the states. Being that the mean velocity is included in our epsilon values, adding additional data points to a class will affect its mean. Assuming the fixation velocity starts out high, as to be expected in noisy data, the mean velocity of saccades will continue to rise until the only saccades left are near peak velocity. Once the mean becomes too high, the PDF function will eventually return a 0 result for fixations leading to our aforementioned PDF issue. It is interesting to note that when this data is subsampled, the scores become much better as can be seen in Figure \ref{fig:algorithms-010-30}. This is likely due to much of the noise being filtered out, leaving a more clean eye record to classify. \section{Conclusion} In this work we provide an analysis of multiple tertiary eye movement classification algorithms: I-VDT \cite{Komogortsev2013}, a threshold based algorithm, I-BDT \cite{Santini2016}, a probability based algorithm, and a newly proposed algorithm: I-VDT-HMM, a hybrid threshold and probability based algorithm. We use the behavioral scores introduced in \cite{komogortsev2010standardization} and \cite{Komogortsev2013} to assess the quality of each algorithm due to their accounting of normal behavior associated with the HOS while also providing automated threshold selection. Our findings show that the proposed algorithm, I-VDT-HMM, has promising results on high frequency low noise data while performing poorly on noisy data. The next thing that will be done is deriving a solution to the round-to-zero error we're experiencing with the PDF function in calculating the observational probabilities as it will vastly improve the algorithm's ability to handle noise. In the future, we will test I-VDT-HMM on more subjects and use cross-fold validation in order to acquire more statistically significant results. Using precision recall and F1 scores would provide a secondary method of algorithm comparison. It would be interesting to see the results that would come from the forward-backward algorithm applied in a similar way, as well as compare the results of I-HMM \cite{Salvucci2000}. \clearpage \bibliographystyle{ACM-Reference-Format}
{'timestamp': '2019-04-24T02:03:52', 'yymm': '1904', 'arxiv_id': '1904.10085', 'language': 'en', 'url': 'https://arxiv.org/abs/1904.10085'}
arxiv